Skip to main content

Module triangulate

Module triangulate 

Source
Expand description

Triangulating a face.

The second half of tessellation. A face is a trimmed region of a surface, so the triangulation is built in the surface’s (u, v) parameter space (where the region is an ordinary polygon with holes) and then lifted back into space by evaluating the surface at each vertex.

§Why parameter space

Triangulating in 3D would mean deciding which side of a curved boundary a point falls on, in space, which is the point-in-solid problem. In parameter space the boundary is a closed 2D polygon and the question is a winding count. The surface does the rest.

The cost is that parameter space is distorted: equal steps in (u, v) cover very different distances near a sphere’s pole than near its equator. So the interior points are chosen by measuring deflection in space and the triangulation is done in parameter space: measuring where the answer matters, connecting where it is easy.

§Watertightness

A face’s boundary points come from discretizing the edge’s 3D curve and evaluating the pcurve at those same parameters. Two faces sharing an edge therefore place their boundary vertices at identical spatial positions, and the join has no gap. Discretizing each face’s pcurve independently would give each face its own idea of where the edge runs, and the seams would show.

Functions§

edge_chords_for
The chords the faces below shape agree to draw their shared edges to.
face_boundary
A face’s trimming boundary, in its surface’s parameter space.
inside_boundary
Whether a point in parameter space lies inside the region rings bound.
inside_boundary_with
As inside_boundary, with the predicate implementation named.
polyline_of_edge
Discretize an edge into a polyline in space, for display or coarse queries.
triangle_normal
The unit normal of a triangle, or None if it is degenerate.
triangulate
Triangulate every face below a shape, welded into one mesh.
triangulate_face
Triangulate one face.
triangulate_face_with
As triangulate_face, with the edge chords the shape agreed on (the answer of edge_chords_for), so the face’s boundary matches its neighbours’ point for point along every edge the map names.

Type Aliases§

EdgeChords
The rings bounding a face in parameter space, and whether every boundary edge met its deflection. Boundary rings with, per ring vertex, the 3D anchor its edge’s own curve provides; None where an edge has no 3D curve to defer to. The chord each edge must be drawn with, where the caller’s is too coarse.