pub fn wachspress_coordinates2(
polygon: &Polygon2,
point: DVec2,
tolerance: Tolerance,
) -> Result<Vec<f64>, BarycentricError>Expand description
Wachspress coordinates of point in a strictly convex polygon, one
weight per vertex (Wachspress 1975, in the determinant form of Meyer,
Lee, Barr and Desbrun 2002).
For vertex i, w_i = C_i / (A_{i-1} * A_i) where C_i is twice the
area of the corner triangle (v_{i-1}, v_i, v_{i+1}) and A_i is twice
the area of (v_i, v_{i+1}, point); the result is w_i normalized to sum
to one. Inside the polygon the weights are positive, smooth, and
reproduce the point; on the boundary, within the linear tolerance, they
are the boundary’s own linear interpolation. Outside the polygon they are
the formula’s rational extension wherever it does not divide by zero. The
polygon may wind either way.
§Errors
BarycentricError::NonFinite, BarycentricError::TooFewVertices,
BarycentricError::ShortEdge, BarycentricError::SelfIntersecting,
BarycentricError::Degenerate for a polygon with no area to speak of,
BarycentricError::NotConvex for a polygon that is not strictly
convex, and BarycentricError::Undefined where a denominator vanishes
(on the line through a non-adjacent edge, extended past its endpoints).