Function tetrahedron_barycentric

Source
pub fn tetrahedron_barycentric(
    corners: [DVec3; 4],
    point: DVec3,
    tolerance: Tolerance,
) -> Result<[f64; 4], BarycentricError>
Expand description

Barycentric coordinates of point in a tetrahedron, as weights of its four corners in order.

Each weight is the signed volume of the sub-tetrahedron opposite its corner over the tetrahedron’s volume, so the corner order’s handedness does not matter.

§Errors

BarycentricError::NonFinite, or BarycentricError::Degenerate when the tetrahedron’s least altitude is not above tolerance.linear().