Determining if a point is inside a polygon or along the outer edge
Show older comments
I have a 2D polygon in 3 dimensions. Some of the points are inside of this polygon, and some define the outer edge of it. How can I detect which points are inside the polygon, and which define the outside of it?
My initial idea is to create a vector that is defined by a set of 2 points, then see if that vector intersects a line segment in the positive and negative direction. If it only intersects on one side, then the point is on the outside of the polygon. If it intersects a line segment in the positive and negative direction, then the point is inside the polygon. But, in order for that to be any use, I need to figure out a condition that tells me if the line defined by that vector intersects any of the line segments defined by the other points.
Any ideas?
4 Comments
Jos (10584)
on 16 Jul 2013
You mean that the vertices are in a single plane that is oriented in 3D space? You could rotate the plane parallel to the XY plane, transform the points accordingly, and then use INPOLYGON.
the cyclist
on 16 Jul 2013
If all the points are guaranteed to be on the same plane, can you just project onto (x,y) instead of rotating? Seems easier if it works.
No matter what you do, you will need to define some tolerances. No set of 2D points are ever exactly coplanar in 3D when floating point calculation errors are involved. Likewise, no 3 points that are all supposed to lie at the edge of a polygon can be relied upon to be exactly colinear.
Joshua
on 17 Jul 2013
Accepted Answer
More Answers (0)
Categories
Find more on Computational Geometry in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!