Link to home
Start Free TrialLog in
Avatar of Saqib Husain
Saqib HusainFlag for Pakistan

asked on

Position of a point with respect to a line

Given a point (x,y)
and a line defined by (x1, y1) and (x2, y2)

what is the distance between the point and the line? and
what is the check whether the point lies within the end points?
All in terms of x's and y's for plugging in a computer program.
Avatar of ozo
ozo
Flag of United States of America image

What does "within the end points" mean?
Is it a region bounded by lines through (x1, y1) and (x2, y2) perpendicular to the line between (x1, y1) and (x2, y2)?
Avatar of Saqib Husain

ASKER

Yes
On a drawing, they are texts written next to lines at a defined distance.
There is a formula for the distance from a point to a line (not a line segment).

       http://en.wikipedia.org/wiki/Distance_from_a_point_to_a_line

You would have to convert your line segment into the   ax + by + c = 0 form.
ASKER CERTIFIED SOLUTION
Avatar of ozo
ozo
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Great, thanks. Working perfectly.