physics/src/hull.rs#
Source: lib/physics/src/hull.rs
hull -- a convex hull from points (quickhull in 3D) and its support function
Quickhull: a first tetrahedron from extreme points, every other point in the outside set of the face it
lies farthest above; then, as long as a face has an outside set, its farthest point (the eye) removes the
faces it sees (a connected region from that face), the horizon around them gets new faces to the eye,
and the points of the removed faces go to the new ones (or are inside now). A point within `eps` of a
face's plane counts as on it, so the hull can leave out points that lie that close to it. Everything in
a fixed order (faces and points by index, ties to the lower index): the same hull on every target.
/// at most this many input points for [`ConvexHull::new`]
MAX_HULL_POINTS: usize = 1 << 16
enum HullErrorwhy [ConvexHull::new] refused the pointsCount-- fewer than 4 points, or more than [MAX_HULL_POINTS]NotFinite-- a coordinate is NaN or infiniteFlat-- all points lie on a plane (or a line or a point), within the tolerance: no volume
struct ConvexHullA convex polyhedron: the hull of the points it was made from. Vertices, triangles (counter-clockwise seen from outside) and their planes, in its own coordinates.
impl ConvexHull
fn new(points: &[Vec3]) -> Result<ConvexHull, HullError>the convex hull ofpoints(at least 4, not all on a plane)fn points(&self) -> &[Vec3]the vertices (a subset of the input points, in their order)fn faces(&self) -> &[[u32; 3]]the triangles, as indices into [ConvexHull::points], counter-clockwise seen from outsidefn planes(&self) -> &[(Vec3, f64)]per face the outward unit normal n and d, with n . p = d on the facefn aabb(&self) -> Aabbthe box around the hull in its own coordinatesfn tolerance(&self) -> f64the tolerance of the construction: an input point lies at most this far outside the hullfn support(&self, d: Vec3) -> Vec3a vertex farthest in directiond: the first of equals among up to 32 vertices, beyond that by hill climbing over the vertex adjacency (exact for a convex polyhedron, always the same path)fn volume(&self) -> f64the volume (for tests and mass properties later)