Skip to content
This repository has been archived by the owner on Nov 12, 2021. It is now read-only.
/ poly2tri.java Public archive

Contribution to poly2tri project. This is a temporary fork, in order to add various features.

License

Notifications You must be signed in to change notification settings

orbisgis/poly2tri.java

Repository files navigation

Poly2Tri

Contribution to poly2tri project: https://github.com/greenm01/poly2tri.java

This is a temporary fork, in order to add various features.

A 2D constrained Delaunay triangulation library

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

BSD 3-Clause License

How to use

import org.poly2tri.Poly2Tri;
import org.poly2tri.geometry.polygon.Polygon;
import org.poly2tri.geometry.polygon.PolygonPoint;
import org.poly2tri.triangulation.delaunay.DelaunayTriangle;

import java.util.Arrays;

public class Main {
  public static void main(String[] args) {
    // Prepare input data
    Polygon polygon = new Polygon(Arrays.asList(new PolygonPoint(0, 0, 0),
      new PolygonPoint(10, 0, 1),new PolygonPoint(10, 10, 2),new PolygonPoint(0, 10, 3)));
    // Launch tessellation  
    Poly2Tri.triangulate(polygon);
    // Gather triangles
    List<DelaunayTriangle> triangles = polygon.getTriangles();
  }
}

About

Contribution to poly2tri project. This is a temporary fork, in order to add various features.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages