Barycentric coordinate is a coordinate system in which the location of a point is specified by reference to points on a simplex (i.e., a line, triangle, tetrahedron, etc.) rather than with respect to global coordinates.
We can view Barycentric coordinates as normalized weighted average of vertices. 1 Another way to view Barycentric coordinates is to view the coordinates as masses assigned to vertices. In this case, the point is at the geometric centroid of the shape. 2
Aside: affine combination and convex combination
A linear combination that expresses multiple points as a normalized weighted sum (where sum of weight is equal to
) is an affine combination if the weights can be any value and and a convex combination if they are limited between .
Barycentric coordinates are useful in both rasterization and ray-triangle intersection, and can be used for interpolation during shading.
Lines
See also: lerp and inverse lerp
Barycentric coordinate can be seen as a generalization of linear interpolation (lerp). With lerp, we represent a point
If we let
Triangles
For triangles, barycentric coordinate expresses the location of any point coplanar with a triangle in three scale
The three coordinates satisfy the relationship
Barycentric coordinates are proportion to area of sub-triangles.For this reason, it is also known as areal coordinates: 3
To find barycentric coordinate of a point, we can calculate the area of the triangle and sub-triangles. The area of triangle is the area of the parallelogram formed by two edges divided by 2. In 3D, we can use cross product for this purpose:
We can similarly compute the area of a sub-triangles, and use this information for barycentric coordinates:
Tetrahedra
Barycentric coordinates for Tetrahedra and higher dimension is analogous to it for triangles and lines. 14
See Also
- the Möller–Trumbore algorithm use Barycentric coordinates to check whether a ray-plane intersection lies in triangle