Contribution to poly2tri project: https://github.com/greenm01/poly2tri.java
This is a temporary fork, in order to add various features.
Based on the paper "Sweep-line algorithm for constrained Delaunay triangulation" by V. Domiter and and B. Zalik
Officially supported langs: C++, Java
Community based langs (unsupported):
* AS3
* C
* C#, C#(basic)
* Go
* Haxe
* Javascript
* Python, Python3
* Ruby
Try it out online: click me or me!
Video poly2tri-java
If you want to triangulate complex or weak polygons you will need to prepare your data
with a polygon clipping library like:
Clipper (C++, C#, Delphi)
Javascript Clipper
Java Clipper
importorg.poly2tri.Poly2Tri;
importorg.poly2tri.geometry.polygon.Polygon;
importorg.poly2tri.geometry.polygon.PolygonPoint;
importorg.poly2tri.triangulation.delaunay.DelaunayTriangle;
importjava.util.Arrays;
publicclassMain {
publicstaticvoidmain(String[] args) {
// Prepare input dataPolygonpolygon = newPolygon(Arrays.asList(newPolygonPoint(0, 0, 0),
newPolygonPoint(10, 0, 1),newPolygonPoint(10, 10, 2),newPolygonPoint(0, 10, 3)));
// Launch tessellation Poly2Tri.triangulate(polygon);
// Gather trianglesList<DelaunayTriangle> triangles = polygon.getTriangles();
}
}