Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Find all polygons in points using MATLAB

I have a set of points in the plane and I want to find all convex polygons without including a point inside them.

For example I want to find all triangles, all four sized polygons, all four five sized polygons and so on until is possible to find them without including a point inside them.

In the image, row a corresponds to convex polygons of size 3. While column 1 and 2 show correct examples of what I want, column 3 shows a triangle including two points inside of it, which I dont want.

Rows b and c show examples of polygons of size 4 and 5.

b3 shows an example of a non convex polygon

enter image description here

I wonder if there is a function in MATLAB or any other language or if someone knows about an algorithm that can do it.

The algorithm could receive, beside the points, the size of the polygons to search, it would return all possibly correct polygons or empty if does not contain any polygon of that size.

I appreciate the help.

like image 426
jessica Avatar asked Feb 17 '14 21:02

jessica


People also ask

How do you find a point inside a polygon in Matlab?

in = inpolygon( xq , yq , xv , yv ) returns in indicating if the query points specified by xq and yq are inside or on the edge of the polygon area defined by xv and yv . [ in , on ] = inpolygon( xq , yq , xv , yv ) also returns on indicating if the query points are on the edge of the polygon area.

How do you check a point is inside a polygon?

Draw a horizontal line to the right of each point and extend it to infinity. Count the number of times the line intersects with polygon edges. A point is inside the polygon if either count of intersections is odd or point lies on an edge of polygon.

What is polygon in Matlab?

Y = polyconf(p,X) evaluates the polynomial p at the values in X . p is a vector of coefficients in descending powers. [Y,DELTA] = polyconf(p,X,S) takes outputs p and S from polyfit and generates 95% prediction intervals Y ± DELTA for new observations at the values in X .


1 Answers

Step 1: Perform a Delaunay-Triangulation of the points.

Step 2:

  • For polygons of size 3: resulting triangles are the result.
  • For polygons of size 4: pick any pair of triangles that share two corners
  • For polygons of size 5: pick any polygon of size 4 and pair it with a triangle that shares exactly two corners
like image 151
Jonas Avatar answered Oct 15 '22 01:10

Jonas