Jump to content
Developer Wiki and Function Reference Links ×

Determine if point lies on selected polygon


Recommended Posts

Yes, I know a way but involves a bit more work.

You can use:

PROCEDURE LineLineIntersection( l1start :POINT;

l1end :POINT;

l2start :POINT;

l2end :POINT;

VAR parallel :BOOLEAN;

VAR intOnLines:BOOLEAN;

VAR sectpt :POINT);

line1 is the segment between two vertices of the polygon.

line2 is a line perpendicular to the segment passing through the point in question.

intOnlines will return true if the intersecting point is on the polygon line segment.

Or you can test for distance with the resulting sectpt if within a tolerance factor.

Before this procedure was added, I calculated the distance from the intersecting point to each end of the line segment. If the sum of the 2 distances equaled the length of the line segment then the point was on the line.

Link to comment

This one's an easy one to guess. By trial usage I determined the following:

PtOnLine returns TRUE if point Pt is on the line segment defined between points BegPt and EndPt, inclusive; or within a distance, defined by Tolerance, of that line segment. Otherwise it returns FALSE.

Pt = point to be tested, stored as a vector (Pt.x, Pt.y, Pt.z)

BegPt = first point of line segment, stored as a vector (BegPt.x, BegPt.y, BegPt.z)

EndPt = second point of line segment, stored as a vector (EndPt.x, EndPt.y, EndPt.z)

Notes:

1) For 2D lines and points, the z component of the three vectors is 0.

2) Because of the nature of real numbers stored in computers, Tolerance should not be set to 0. Make it a suitably small number for your use. 1e-6 or 1e-9 should work for most architectural needs. Anything greater than 1e-323 will work for the number system employed by VW (at least as I've tested it on a Mac).

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...