Find a line intersecting a known line at right angle, given a point

后端 未结 6 645
隐瞒了意图╮
隐瞒了意图╮ 2020-12-29 15:53

This is basic graphics geometry and/or trig, and I feel dumb for asking it, but I can\'t remember how this goes. So:

  1. I have a line defined by two points (x1, y1
6条回答
  •  情歌与酒
    2020-12-29 16:00

    The answer line is:

    y=ax+b
    where a=(x1-x2)/(y2-y1)
          b=yp-(x1-x2)*xp/(y2-y1)
    

    How the result was obtained:

    1) slope for the original line:   (y2-y1)/(x2-x1)
    
    2) slope for the answer: -1/((y2-y1)/(x2-x1)) = (x1-x2)/(y2-y1)
    
    3) Plug this into (xp,yp) we can have the result line.
    

    Just calculate the answer from the lines after this (this is too long... I am hungry).

提交回复
热议问题