Skip to main content

discrete_harmonic_coordinates2

Function discrete_harmonic_coordinates2 

Source
pub fn discrete_harmonic_coordinates2(
    polygon: &Polygon2,
    point: DVec2,
    tolerance: Tolerance,
) -> Result<Vec<f64>, BarycentricError>
Expand description

Discrete harmonic coordinates of point in a strictly convex polygon, one weight per vertex (Pinkall and Polthier’s cotangent weights, applied to the triangle fan (point, v_i, v_{i+1}); Floater’s survey calls this scheme “discrete harmonic”).

For vertex i, sharing a fan edge with the two triangles on either side of it, w_i = (cot(gamma) + cot(beta)) / r_i^2, where beta and gamma are the unsigned angles at v_i in those two triangles and r_i = |point - v_i|; the result is w_i normalized to sum to one. On the boundary, within the linear tolerance, the weights are the boundary’s own linear interpolation. Unlike Wachspress coordinates, discrete harmonic weights are not guaranteed positive inside a convex polygon, and have poles where a fan angle is a multiple of a straight angle (point, vertex and a neighbor collinear): both refused as BarycentricError::Undefined, since the caller cannot act on an infinite or cancelled weight either way. The polygon may wind either way.

§Errors

As wachspress_coordinates2.