Solved

Position of a point with respect to a line

Posted on 2013-12-04
6
294 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
Comment Utility
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
Comment Utility
Yes
0
 
LVL 43

Author Comment

by:Saqib Husain, Syed
Comment Utility
On a drawing, they are texts written next to lines at a defined distance.
0
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 27

Expert Comment

by:d-glitch
Comment Utility
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
Comment Utility
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
Comment Utility
Great, thanks. Working perfectly.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

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 …
Lithium-ion batteries area cornerstone of today's portable electronic devices, and even though they are relied upon heavily, their chemistry and origin are not of common knowledge. This article is about a device on which every smartphone, laptop, an…
This video shows where to find the word count, how to display it, and what it breaks down to in Microsoft Word.
This Micro Tutorial well show you how to find and replace special characters in Microsoft Word. This is similar to carriage returns to convert columns of values from Microsoft Excel into comma separated lists.

762 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now