Skip to main content

enclosed_volume

Function enclosed_volume 

Source
pub fn enclosed_volume(triangles: &[StlTriangle]) -> f64
Expand description

The volume triangles, wound outward, enclose: the sum of the signed tetrahedra they span with a corner of the mesh, negative if they are wound in. Exact for a closed mesh, up to its f32 corners.

The apex is a corner of the mesh, not the origin: in f32, a corner far from the origin is rounded by more than the mesh’s own size there, and the tetrahedra spanned from the origin weigh that rounding by their distance: a plate at (10000, -5000, 2000) summed from the origin came out 5.5 over for a bore of 142, back when faces met in two polygons of an edge a sliver apart.