scionaltera / delaunator-java

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

delaunator-java

This library is Java port of Delaunator, an incredibly fast and robust JavaScript library for Delaunay triangulation of 2D points.

The port was produced by referring to the c++ and c# versions of Delaunator.

delaunay example delaunay example

Example

List<DPoint> list = new ArrayList<>();
for (int i = 0; i < 10000; i++) {
	double x = Math.random() * 1000;
	double y = Math.random() * 1000;
	DPoint p = new DPoint((int) x, (int) y);
	list.add(p);
}

Delaunator del = new Delaunator(list);
for (DTriangle t : del.getTriangles()) {
	DEdge edgeA = t.ab; // edge A of Tri
	DEdge edgeB = t.bc; // edge B of Tri
	DEdge edgeC = t.ca; // edge C of Tri
	DTriangle[] wingA = edgeA.getWing(); // wing A0, A1 of edge A
	DTriangle[] wingB = edgeB.getWing(); // wing B0, B1 of edge B
	DTriangle[] wingC = edgeC.getWing(); // wing C0, C1 of edge C
}

Ports to other languages

About

License:Apache License 2.0


Languages

Language:Java 100.0%