I recently asked this question about how to cut down a concave polygon to convex ones, and I was suggested to do Triangulation or Polygon Partitioning.
The library I'm using (SFML\Box2D) only takes convex shapes.
This is what I want to know:
Is Polygon Partitioning, or Triangulation of Polygons faster?
How does Polygon Partitioning work/ How do you do it?
Don't forget Triangulation doesn't require convex shapes to be made either...
Computing the triangulation of a polygon is a fundamental algorithm in computational geometry. In computer graphics, polygon triangulation algorithms are widely used for tessellating curved geometries, as are described by splines [Kumar and Manocha 1994].
Every simple polygon admits a triangulation. 2. Every triangulation of an n-gon has exactly n − 2 triangles.
The most remarkable and important property of triangles is that any polygon can be split up into triangles simply by drawing diagonals of the polygon. This fact forms the basis for understanding why the interior angles of polygons add up to 180(n-2) degrees.
A triangulation of a polygon can be thought of as a set of chords that divide the polygon into triangles such that no two chords intersect (except possibly at a vertex). This is a triangulation of the same polygon: An optimal triangulation is one that minimizes some cost function of the triangles.
Not a full answer to your question, but if you have a general polygon (concave, convex, whatever) and you are looking to triangulate it (for subsequent openGL style rendering perhaps) you could look into "constrained Delaunay triangulation" packages. One such example is the Triangle package, which is reputed to be fast and robust.
As I understand it, the algorithms used in Triangle exhibit O(nlogn)
runtime complexity.
Polygon partitioning splits your polygon into convex polygons.
Triangulation splits it into triangles.
As far as I understand, partitioning into triangles requires that you first perform polygon partitioning, since partitioning convex polygon into triangles is relatively trivial.
Splitting polyon into convex polygons is the hard part.
I have written a program that does both for a class and if you want I can dig it up.
Here's my code: https://github.com/meshko/triangulator/tree/master/som
I haven't touched in 10 years so beware of.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With