Solved

Position of a point with respect to a line

Posted on 2013-12-04
6
300 Views
Last Modified: 2013-12-04
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.
0
Comment
Question by:Saqib Husain, Syed
  • 3
  • 2
6 Comments
 
LVL 84

Expert Comment

by:ozo
ID: 39696718
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)?
0
 
LVL 43

Author Comment

by:Saqib Husain, Syed
ID: 39696721
Yes
0
 
LVL 43

Author Comment

by:Saqib Husain, Syed
ID: 39696729
On a drawing, they are texts written next to lines at a defined distance.
0
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 27

Expert Comment

by:d-glitch
ID: 39696730
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.
0
 
LVL 84

Accepted Solution

by:
ozo earned 500 total points
ID: 39696743
distance = |(x1-x)(y2-y)-(x2-x)(y1-y)|/sqrt((x1-x2)^2+(y1-y2)^2)

when ((x1-x2)*(x-x2)+(y1-y2)*(y-y2))/((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)) is between 0 and 1, the point is within the end points
0
 
LVL 43

Author Closing Comment

by:Saqib Husain, Syed
ID: 39697064
Great, thanks. Working perfectly.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever thought of installing a power system that generates solar electricity to power your house? Some may say yes, while others may tell me no. But have you noticed that people around you are now considering installing such systems in their …
Microsoft Word is a program we have all encountered at some point, but very few of us have dug deep into its full scope of features, let alone customized it to suit our needs. Luckily making the ribbon (aka toolbar, first introduced in Word 2007) wo…
This video walks the viewer through the process of creating an MLA formatted document, as well as a bibliography with citations.
This video shows where to find the word count, how to display it, and what it breaks down to in Microsoft Word.

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question