Nearest point on a line.
-
Hi, I have a (straight) line between two Point's. I want to find the nearest point on that line to another arbitrary point. How can I do this? Thanks, Steve
off top of head just loop through all points in the line and calulate the distance from that point to the 'other point' with pythagorus theory or something. shortest distance = nearest point maybe would be easier to apply roation to the line and point first so the line is completely vertical then just use the yPos of the point and match it to the yPos within the line
Life goes very fast. Tomorrow, today is already yesterday.
modified on Wednesday, March 18, 2009 11:19 AM
-
Hi, I have a (straight) line between two Point's. I want to find the nearest point on that line to another arbitrary point. How can I do this? Thanks, Steve
StephenWhitfield wrote:
I have a (straight) line between two Point's. I want to find the nearest point on that line to another arbitrary point. How can I do this?
Wouldn't the answer to that be the adjacent points in either direction, or am I missing something? :confused: Ah I see, the arbitrary point is not on the line.
-
Hi, I have a (straight) line between two Point's. I want to find the nearest point on that line to another arbitrary point. How can I do this? Thanks, Steve
If you say the line runs between points A and B, the nearest point on this line C to an arbitrary point X is such that AB is perpendicular to CX. It's a long time since I've done any graphics work but this sounds like it should be solved with some basic trigonometry??
It definitely isn't definatley
-
off top of head just loop through all points in the line and calulate the distance from that point to the 'other point' with pythagorus theory or something. shortest distance = nearest point maybe would be easier to apply roation to the line and point first so the line is completely vertical then just use the yPos of the point and match it to the yPos within the line
Life goes very fast. Tomorrow, today is already yesterday.
modified on Wednesday, March 18, 2009 11:19 AM
-
Hi, I have a (straight) line between two Point's. I want to find the nearest point on that line to another arbitrary point. How can I do this? Thanks, Steve
-
hmmm... well do a search for 'line drawing algorithm'[^] or something like that. instead of drawing each pixel, you use each pixel to check distance with other point
Life goes very fast. Tomorrow, today is already yesterday.
Or you could google for nearest point on a line[^] and get a geometric solution!? :)
It definitely isn't definatley
-
Or you could google for nearest point on a line[^] and get a geometric solution!? :)
It definitely isn't definatley