Module barycentric

Source
Expand description

Barycentric and mean-value coordinates, for interpolating values given at the corners of a triangle, a tetrahedron or a polygon (#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.

Enums§

BarycentricError
Why coordinates could not be computed.

Functions§

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).
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.