Converting between barycentric and trilinear coordinates

Barycentric coordinates describe the position of a point relative to the three vertices of a triangle. Trilinear coordinates describe the position of a point relative to the three sides of a triangle. It’s surprisingly simple to convert from one to the other.

Why should this be surprising? Because the distance from a point to a line is more complicated to compute than the distance between two points. Hiding this complication is one of the things that makes trilinear coordinates convenient for some tasks.

Both barycentric and trilinear coordinates are homogeneous. This means the coordinates are only unique up to a scaling factor. The proportions between the components are unique, not the components themselves. Barycentric and trilinear coordinates are written with colons separating the components as a reminder that they are proportions rather than absolute numbers.

If the vertices of our triangle are A, B, and C, the barycentric coordinates of a point P are proportional to the distances from P to A, B, and C. The trilinear coordinates of P are proportional to the distances from P to the sides opposite A, B, and C.

Let a be the length of the side opposite vertex A and similarly for b and c. Then a point with trilinear coordinates

x : y : z

has barycentric coordinates

ax : by : cz

Similarly, a point with barycentric coordinates

α : β : γ

has trilinear coordinates

α/a : β/b : γ/b.

If you have trilinear coordinates x : y : z you can find the actual distances to the sides of the triangle by scaling by a factor involving the area of the triangle. The distances to sides opposite A, B, and C are kx, ky, and kz respectively, where

k = area / (ax + by + cz).

Note that the denominator is the sum of the corresponding barycentric coordinates. This is because barycentric coordinates of P can be interpreted as the areas of the three triangles formed by drawing lines from P to each of the vertices.