Function mean_value_coordinates2

Source
pub fn mean_value_coordinates2(
    polygon: &Polygon2,
    point: Point2,
    tolerance: Tolerance,
) -> Result<Vec<Scalar>, BarycentricError>
Expand description

Mean-value coordinates of point in a simple polygon, one weight per vertex (Floater 2003, in the form for arbitrary polygons of Hormann and Floater 2006).

Inside a simple polygon, convex or not, the weights are positive-sum, smooth, and reproduce the point. On the boundary, within the linear tolerance, they are the boundary’s own linear interpolation: one at a vertex, or the two endpoint weights of an edge. Outside the polygon they are defined wherever the raw weights do not cancel, which is everywhere outside a convex polygon. The polygon may wind either way.

The polygon is checked for simplicity pairwise, O(n^2) in its vertex count, since mean-value coordinates of a crossing polygon mean nothing.

§Errors

BarycentricError::NonFinite, BarycentricError::TooFewVertices, BarycentricError::ShortEdge, BarycentricError::SelfIntersecting, BarycentricError::Degenerate for a polygon with no area to speak of, and BarycentricError::Undefined where the weights cancel.