Learning path

Full curriculum

Full curriculum

Unit content

Barycentric coordinates and interpolation on triangles

A point in a triangle can be represented as a weighted combination of its vertices:

$$\mathbf{p}=\lambda_0\mathbf{p}_0+\lambda_1\mathbf{p}_1+\lambda_2\mathbf{p}_2,$$

with

$$\lambda_0+\lambda_1+\lambda_2=1.$$

The weights $(\lambda_0,\lambda_1,\lambda_2)$ are barycentric coordinates. A point lies inside or on the triangle when all three weights are nonnegative.

The same weights interpolate any quantity attached to the vertices. If the vertices carry colors $C_0,C_1,C_2$, then

$$C=\lambda_0C_0+\lambda_1C_1+\lambda_2C_2.$$

Normals, texture coordinates and other attributes can be interpolated in the same way, subject to the correction required after perspective projection.

Barycentric coordinates connect geometry to rendering: they provide both an inside-triangle test and a principled way to vary attributes continuously across a rasterized triangle.