Function triangle_barycentric2

Source
pub fn triangle_barycentric2(
    triangle: &Triangle2,
    point: Point2,
    tolerance: Tolerance,
) -> Result<[Scalar; 3], BarycentricError>
Expand description

Barycentric coordinates of point in a 2D triangle, as weights of a, b and c.

Each weight is the signed area of the sub-triangle opposite its corner over the triangle’s area, so the result does not depend on the triangle’s winding.

§Errors

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