region2.triangulate
A constrained Delaunay triangulation of the region with its holes left empty, optionally refined to a minimum angle.
Usage
region.triangulate(options?: { minAngleDeg?: number; maxSteiner?: number }): Result<Triangulation2>Parameters
options.minAngleDegnumberRefine with Steiner points until no triangle angle is below this, in degrees; 0 is a plain constrained Delaunay triangulation. Default
0. Range [0, 34].options.maxSteinernumberBudget of added points for ring crossings and refinement; a non-negative integer (kernel2d clamps it to 2^20). Default
10000. In count.
Returns
Ok with the triangulation: every ring’s corners in rings() order, then any Steiner points, and counter-clockwise triangles. Region2.empty gives an empty triangulation, without needing kernel2d.
Errors
Guarantees
- with minAngleDeg θ, Triangulation2.minAngleDeg(t) ≥ θ, except triangles at ring corners, crossings or T-junctions sharper than 60°, at ring pieces too short to split in f64, and a few unreachable circumcentres
- the first points are the input corners, unchanged and in order; t.steinerCount === t.points.length − the number of input corners
- every triangle is counter-clockwise, and their total area equals the enclosed area (Triangulation2.toMesh(t).value.area())
- the triangles’ total area equals region.area() for a valid region
- The same result on every machine.
Example
const r = Region2.of(Polygon2.rectangle(4, 4).value, [Polygon2.rectangle(2, 2).value]).triangulate({ minAngleDeg: 30 }) // → smallest angle ≥ 30°, once loadGeometryKernel() has run