Polygon Partitioning vs Triangulation
Asked Answered
M

2

7

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:

  1. Is Polygon Partitioning, or Triangulation of Polygons faster?

  2. How does Polygon Partitioning work/ How do you do it?


Don't forget Triangulation doesn't require convex shapes to be made either...

Malonis answered 15/7, 2011 at 2:31 Comment(0)
C
4

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.

Cyton answered 15/7, 2011 at 2:47 Comment(4)
i just wanted to know if you knew if it was faster,i'll put it back if you don't.Malonis
Triangle has a runtime complexity of O(nlogn), which is generally pretty fast asymptotically. If you can find an O(n) algorithm then obviously that may be faster, but I'm not aware of any algorithms in this class. Maybe check this out code.google.com/p/polypartition and compare the reported complexities. To actually find the fastest method you would need to benchmark, and get some real timing results...Cyton
Another consideration is triangulation quality, since many valid triangulations can be generated for a given polygon. A Delaunay based algorithm (such as Triangle) is in some sense optimal, because it constructs the triangulation which maximises the smallest angle.Cyton
That link you gave to the PolyPartition Library looks really interesting/ Useful! There's no guide to it is there? I'm trying to figure it out from the source code right now.Malonis
M
4

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.

Moslem answered 15/7, 2011 at 2:40 Comment(6)
that would be GREAT! please do =)Malonis
@MK: You can triangulate concave polygons directly, although it may be easier to triangulate convex ones...Cyton
@Malonis I've updated answer with the link to the code. Good luck.Moslem
@MK: So in the readme.txt you say "Algorithm consists of two phases: first polygon is split into monotone polygons, then each monotone polygon is triangulated in linear time." I know how to do this, so does any of the source actually partion a polygon to convex shapes?Malonis
um... I guess it doesn't. Sorry, confused convex and montone :(Moslem
all good! just make sure to upvote the question cuz i've been looking for answer for a while...Malonis
C
4

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.

Cyton answered 15/7, 2011 at 2:47 Comment(4)
i just wanted to know if you knew if it was faster,i'll put it back if you don't.Malonis
Triangle has a runtime complexity of O(nlogn), which is generally pretty fast asymptotically. If you can find an O(n) algorithm then obviously that may be faster, but I'm not aware of any algorithms in this class. Maybe check this out code.google.com/p/polypartition and compare the reported complexities. To actually find the fastest method you would need to benchmark, and get some real timing results...Cyton
Another consideration is triangulation quality, since many valid triangulations can be generated for a given polygon. A Delaunay based algorithm (such as Triangle) is in some sense optimal, because it constructs the triangulation which maximises the smallest angle.Cyton
That link you gave to the PolyPartition Library looks really interesting/ Useful! There's no guide to it is there? I'm trying to figure it out from the source code right now.Malonis

© 2022 - 2024 — McMap. All rights reserved.