Find all polygons in points using MATLAB
Asked Answered
C

2

6

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.

Correspondence answered 17/2, 2014 at 21:4 Comment(5)
you can also try asking at math.stackexchange.com . Just make sure that you formulate your problem mathematically and not from MATALB programming point-of-view.Araminta
I'm not sure I understand your problem: "[...] all triangles, all four sized polygons, [...] until is possible to find them without including a point inside them." Can you please try and reformulate it more clearly?Wideangle
@jessica, I take it the size of the polygon is an input parameter?Corporate
Should the polygons be convex? I expect they should, but your example b3 tells me different.Puccoon
Good observation Heuster, that's why I put the point in blue color, but somehow I forgot to explain that.Correspondence
V
2

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
Vercelli answered 18/2, 2014 at 8:12 Comment(2)
Small clarification: To avoid "looping" back around a corner for higher point counts the additional triangle should share exactly two corners with the polygon.Coremaker
@Vercelli I think that Delaunay-Triangulation would let me out some possible traingles, for example a1 and a2 wouldn't be returned using Delaunay.Correspondence
S
0

You can try the naive solution if it is feasible :-

  1. select k points for k sided polygon
  2. apply convex hull alogrithm on it
  3. if convex hull size equal k then the set of points form desired k sided polygon.

Time Complexity:- O(2^N*N*logN)

Strohl answered 18/2, 2014 at 9:23 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.