MATLAB: Determining if a point is inside a polygon or along the outer edge

intersectionline segmentpolygonvector

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?

Best Answer

If the polygon is convex, then using vert2lcon and lcon2vert available here you could do
[A,b,Aeq,beq]=vert2lcon(points);
vertices = lcon2vert(A,b,Aeq,beq);
All points that are not vertices are considered by the code as lying inside of it or along an edge, up to the tolerance parameters of the code.
If you really have to distinguish between interior points and edge points. the points satisfying
A*points<=b-tolInterior
can be considered interior points up to a tolInterior tolerance parameter set by you..