Perpendicular on a line from a given point

前端 未结 14 1656
名媛妹妹
名媛妹妹 2020-11-29 18:34

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

14条回答
  •  悲&欢浪女
    2020-11-29 19:10

    First, calculate the linear function determined by the points (x1,y2),(x2,y2).

    We get:

    y1 = mx+b1 where m and b1 are constants.
    

    This step is easy to calculate by the formula of linear function between two points.


    Then, calculate the linear function y that goes through (x3,y3).

    The function slope is -m, where m is the slope of y1.


    Then calculate the const b2 by the coordinates of the point (x3,y3).

    We get y2 = -mx+b2 where m and b2 are constants.


    The last thing to do is to find the intersection of y1, y2. You can find x by solving the equation: -mx+b2 = mx+b1, then place x in one of the equations to find y.

提交回复
热议问题