triangulation2.toMesh

The triangulation as a Mesh of triangles in the z = 0 plane, facing +z.

GeometricSince 0.4.0

Usage

TypeScript
Triangulation2.toMesh(t: Triangulation2): Result<Mesh>

Parameters

  • tTriangulation2

    The triangulation: points, then three point indices per triangle.

    Required

Returns

Ok with a mesh of one point per triangulation point (z = 0) and one triangle face per triangle; a mesh with no faces for an empty triangulation.

Errors

Guarantees

  • mesh.faceCount === t.triangles.length / 3
  • mesh.area() equals the triangulated area
  • for counter-clockwise triangles every faceNormal is +z
  • The same result on every machine.

Example

TypeScript
const t = { points: [Point2.of(0, 0), Point2.of(1, 0), Point2.of(0, 1)], triangles: new Uint32Array([0, 1, 2]), steinerCount: 0 }
Triangulation2.toMesh(t).value.area() // → 0.5

See also