Find perpendicular line using points on that line

六眼飞鱼酱① 提交于 2019-12-23 06:11:06

问题


I have a line (P1, P2), and a point on that line (midpoint). What equation can I used to find the perpendicular line of line (P1, P2), that passes through midpoint. The point labelled with a '?' is unknown. I do not wish to use angles, only the 3 points given (P1, P2, midpoint). The line P1, P2 can be of any orientation/angle.

Thanks in advance.


回答1:


Let define vector

D = P2 - P1  (dx=x2-x1, dy = y2-y1)

and middle point

mx = (x2+x1)/2
my = (y2+y1)/2

Perpendicular to D vector

PD = (-dy, dx)

Unit (normalized) perpendicular vector

U = (-dy / L, dx / L)
where
L = Sqrt (dx * dx + dy * dy)

And coordinates of point lying at distance F from the middle are

x = mx + U.x * F
y = my + U.y * F

or (for point at another side)

x = mx - U.x * F
y = my - U.y * F



回答2:


Coordinates of P1: (x1,y1) Coordinates of P2: (x2,y2)

Coordinates of midpoint: ( (x1+x2)/2 , (y1+y2)/2) Slope of the P1P2 line: (y1-y2)/(x1-x2) Slope of any perpendicular line to P1P2: (x2-x1)/(y1-y2)

Equation of the red line: y - (y1+y2)/2 = ((x2-x1)/(y1-y2))*(x - (x1+x2)/2)

If you have the actual values of coordinates of P1 y P2, then just make a substitution.



来源:https://stackoverflow.com/questions/47040213/find-perpendicular-line-using-points-on-that-line

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!