As you can see in the image below, my question is how to determine the polygons formed by a series of points.
In the left figure, the sequence of points {A, B, C, D, E, A}, therefore, it simply forms 1 polygon {A, B, C, D, E}.
On the right side of the figure is a sequence of points {A, B, C, D, E, F, A}. It creates 2 polygons {A, F, G } and {B, C, D, E, G }, where G is the intersection point from the line AB and FE.
I'm not only interested in the number of polygons, but I also want to know information about the polygons (polygonal rows of points) that are created from it.
These algorithms will be used in the mobile device in real time, so it must be fast enough to calculate. Oh, and a series of points will be created by custom touch points.
Assumptions:
- Only consists of 2 collinear points
- This is not always a closed polygonal chain. For example, from the figure on the right, a number of points are {A, B, C, D, E, F}, there is no edge FA.
I was thinking about a solution, and looking at the intersection points, I was stuck with a solution O (N ^ 2), N = number of edges. The optimization that I can make of this is to maintain sets of strings in some regions, so I just minimize the total strings that can be computed by each other.
As for the solution for extracting those polygons, I'm still stuck.

algorithm graph-algorithm
Agung pratama
source share