Because the shortest distance between two thoughts is a straight line
Friday 8 April 2011
Polygon Triangulation via Ear-Clipping with Delaunay Refinement
After this thread on the JTS list Michael Bedward was inspired to create a polygon triangulation algorithm using the Ear-Clipping approach. Standard Ear-Clipping algorithms don't handle polygons with holes, but Michael made a nice extension to do this. (David Eberly has a good write-up on this subject here, and of course there's always Wikipedia).
One problem with ear-clipping is that it produces sub-optimal triangulations (in the the sense that it creates lots of very skinny triangles, which are visually and computationally unappealing). I suggested that he add a refinement step based on "flipping triangles" to improve the quality of the output triangle mesh. This is similar to the approach used in Delaunay triangulation algorithms, and in fact it turns out that a good flipping criteria is to test for the Delaunay condition. (Two adjacent triangles which form a convex quadrilateral are Delaunay if neither lies in the circumcircle of the other. Wikipedia has a nice visual explanation).
This code will get added to JTS in the next release. In the meantime, here's some cool pictures showing how it works.
A gnarly test polygon:
A country that has been in the news recently:
Update (Nov 1, 2021): JTS now has Polygon Triangulation code. See this post for details.