PDA

View Full Version : How to determine if a point is on a line


Al Hart
12-17-2007, 10:36 AM
We're trying to determine if a given point is on a line created by 2 other known points. We see $colin to help determine if it's on the line, but don't see how to determine if it is between the 2 end points. Any help is appreciated.

$perp should do it.

It returns #true if a perpendicular from the point to the line is between the end points of the line and #false if the perpendicular lies outside the end points.

It works even if the point is already on the line.

Al Hart
12-17-2007, 10:45 AM
I have modified the documention for $perp to make this more clear.

$perp(new, end1, end2)

Description

Given a line in space, and a point in space, determines the
point on the line which creates a perpendicular to the given point.
Also tells you whether the perpendicular point is between the end points.

Parameters

new - The point that the perpendicular line will include.

end1 - One endpoint of the line to find a perpendicular for.

end2 - The other endpoint of that line.

Return Value

Returns #true if the perpendicular falls between the endpoints.
Returns #false if the perpendicular falls outside the endpoints.

In either case, sets the #lnpt variable to the point on the line where
the lines intersect.
Use $getvar(#lnpt) to get this point.

You can use #colin and #perp to determine if a point is one a line.