Determining if a point is inside a polygon or along the outer edge
이전 댓글 표시
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
Jos (10584)
2013년 7월 16일
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
2013년 7월 16일
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
2013년 7월 17일
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Sparse Matrices에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!