Trying to triangulate a set of **simple 2d polygons**, I've come up with this algorithm:

- 1) For each vertex in the polygon, compute the angle between the two linked edges
- 2) Sort vertices by decreasing angle relative to the interior of the polygon
- 3) If there is less than 3 vertices in the set, we're done
- 4) Take the last vertex in the set and output the triangle formed by it and its two neighbours
- 5) Remove the vertex from the set
- 6) Update the angle of the two neighbours
- 7) Jump to 2

I've tested it, and found it to work even on really big and complicated **simple 2d polygon** (it don't work for polygon with a hole or self intersecting polygons).

Is there corner cases that will produce degenerate result?

Does this algorithm is a known one?

If not, I would like to be sure this algorithm is rock solid but I have not the mathematical background to prove it.

Thanks a lot.

## Best Solution

You are doing a version of "ear clipping" approach to triangulation, see: http://en.wikipedia.org/wiki/Polygon_triangulation

Your algorithm fails if another polygon vertex (say from the other side of the polygon) ends up inside the triangle 'ear' you form. Consider this example:

Your algorithm will choose A first, and make a triangle with the two adjacent edges (connected with the dashed line). But this triangle includes another vertex (B) and is clearly incorrect.

The generalized ear clipping approach depends on finding ears you can clip off that do not have any included vertices.