Skip to main content

Module barycentric

Module barycentric 

Source
Expand description

Barycentric and mean-value coordinates, for interpolating values given at the corners of a triangle, a tetrahedron, a polygon or a closed triangle mesh (#143).

Every function returns one weight per corner. The weights sum to one and reproduce the point: sum(w_i * corner_i) == point, up to rounding. A point on a corner gets weight exactly one there and zero elsewhere, so corner values are reproduced exactly.

Shapes thinner than the linear tolerance are refused rather than given weights that are mostly rounding noise; a triangle’s or tetrahedron’s thinness is its least altitude. Weights outside [0, 1] are not an error: they place the point outside the triangle or tetrahedron, which is how callers extrapolate or test containment.

Four polygon schemes are offered, trading generality for positivity: mean_value_coordinates2 answers for any simple polygon, convex or not; wachspress_coordinates2 and discrete_harmonic_coordinates2 require a strictly convex polygon (refused by name otherwise), and the latter can still produce an infinite or cancelled weight at a pole, which is refused the same way mean-value cancellation is. mean_value_coordinates3 extends the 2D mean-value scheme to a closed triangle mesh in space.

Enums§

BarycentricError
Why coordinates could not be computed.

Functions§

discrete_harmonic_coordinates2
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”).
mean_value_coordinates2
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).
mean_value_coordinates3
Mean-value coordinates of point in a closed triangle mesh, one weight per vertex (Floater, Kos and Reimers 2005).
tetrahedron_barycentric
Barycentric coordinates of point in a tetrahedron, as weights of its four corners in order.
triangle_barycentric2
Barycentric coordinates of point in a 2D triangle, as weights of a, b and c.
triangle_barycentric3
Barycentric coordinates of point in a 3D triangle, as weights of a, b and c.
wachspress_coordinates2
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).