iTriangle
A fast and efficient library for Delaunay triangulation and converting complex polygons into convex shapes — with full support for self-intersections, holes, Steiner points, and multi-polygons.
Delaunay triangulation
Breaking into convex polygons
Features
- Raw Triangulation: Fast and robust implementation for generating simple triangulations.
- Delaunay Triangulation: Efficient and robust implementation for generating Delaunay triangulations.
- Convex Polygons: Break complex polygons into simpler convex polygons.
- Polygon Flexibility: Supports complex polygon configurations — including multi-polygons, holes, self-intersections, and Steiner points.
Demo
Documentation
Getting Started
Add the following to your Cargo.toml:
[dependencies]
i_triangle = "^0.29.0"
After that, represent your polygon as an array of vertices. Here's an example of a cheese polygon:
let shape = vec!;
let triangulation = shape.triangulate.to_triangulation;
println!;
println!;
let delaunay_triangulation = shape.triangulate
.into_delaunay
.to_triangulation;
println!;
println!;
let convex_polygons = shape.triangulate
.into_delaunay
.to_convex_polygons;
println!;
Output Triangulation: triangles indices and vertices, where all triangles oriented in a counter-clockwise direction.