Perpendicular on a line from a given point

2019-01-10 07:48发布

How can I draw a perpendicular on a line segment from a given point? My line segment is defined as (x1, y1), (x2, y2), If I draw a perpendicular from a point (x3,y3) and it meets to line on point (x4,y4). I want to find out this (x4,y4).

10条回答
别忘想泡老子
2楼-- · 2019-01-10 08:14

Compute the slope of the line joining points (x1,y1) and (x2,y2) as m=(y2-y1)/(x2-x1)

Equation of the line joining (x1,y1) and (x2,y2) using point-slope form of line equation, would be y-y2 = m(x-x2)

Slope of the line joining (x3,y3) and (x4,y4) would be -(1/m)

Again, equation of the line joining (x3,y3) and (x4,y4) using point-slope form of line equation, would be y-y3 = -(1/m)(x-x3)

Solve these two line equations as you solve a linear equation in two variables and the values of x and y you get would be your (x4,y4)

I hope this helps.

cheers

查看更多
啃猪蹄的小仙女
3楼-- · 2019-01-10 08:17

Mathematica introduced the function RegionNearest[] in version 10, 2014. This function could be used to return an answer to this question:

{x4,y4} = RegionNearest[Line[{{x1,y1},{x2,y2}}],{x3,y3}]
查看更多
欢心
4楼-- · 2019-01-10 08:18

I solved the equations for you:

k = ((y2-y1) * (x3-x1) - (x2-x1) * (y3-y1)) / ((y2-y1)^2 + (x2-x1)^2)
x4 = x3 - k * (y2-y1)
y4 = y3 + k * (x2-x1)

Where ^2 means squared

查看更多
在下西门庆
5楼-- · 2019-01-10 08:26

You know both the point and the slope, so the equation for the new line is:

y-y3=m*(x-x3)

Since the line is perpendicular, the slope is the negative reciprocal. You now have two equations and can solve for their intersection.

y-y3=-(1/m)*(x-x3)
y-y1=m*(x-x1)
查看更多
登录 后发表回答