I need to calculate triangles of a polygon. Polygon can contain holes. And Req an efficient way. So I think I need Constrained Delaunay Triangulation.
I must do that in c#, only need calculation not drawing or something.
poly2tri seems good but idk its not working for me :S
Anyway I need help. How can I calculate that triangles? (If your best offer is poly2tri, i can explain my problem on it)
One way to triangulate a simple polygon is based on the two ears theorem, as the fact that any simple polygon with at least 4 vertices without holes has at least two 'ears', which are triangles with two sides being the edges of the polygon and the third one completely inside it.
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].
Theorem: Every polygon has a triangulation. Proof by Induction. Base case n = 3. Pick a convex corner p.
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.
Delaunay was not designed for this, use Ear Clipping instead.
I suppose my simple solution on github:gist (but it's rather old and probably not optimal).
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