[Math] Clarificaiton on barycentric coordinates

algorithmsbarycentric-coordinatesgeometry

This is related to ray tracing (which I learnt and then forgot).

Given a triangle in 3D $\widehat{ABC}$, where $A,B,C$ are the points of the triangle

And a parametric line described by $(O,\vec v)$ (origin and direction vector)

We find the point $P$ as the intersection of the line and the plane described by the triangle.

From here I become confused. The barycentric coordinates are basically the "normalized" areas of the triangles formed by taking $P$ and 2 of the vertices of the triangle. However this definition only makes sense when $P$ is inside of the triangle, when it's outside it stands that at least one of the coordinates must be negative.

My confusion comes when trying to understand how and why one of the 3 coordinates becomes negative when calculating the barycentric coordinates.

The formal definition tells us that $P=u*A+v*B+w*C$

Or that $P$ is a weighted sum of the vertices of the triangle such that $u+v+w=1$

When $P$ is inside the triangle each weight can be simply described as

$\frac{\widehat{PXY}}{XYZ}$ where $(X,Y,Z)$ represents any permutation of $(A,B,C)$

But off course this cannot be the case when $P$ is outside the triagle as at least one of the areas must be negative.

How are $u,v,w$ calculated exactly? I am not looking so much for a formal answer, but rather I want to understand the intuition behind the weight calculation.

Best Answer

The word barycentric literally means “weight-centered.” The barycentric coordinates of a point relative to a polygon are the masses that you’d have to place at the vertices of the polygon for its center of mass to be at that point. Approaching it from the other direction, the point represented by the triangular barycentric coordinates $m_A:m_B:m_C$ is the center of mass of three point masses $m_A,m_B,m_C\gt0$ placed at the points $A$, $B$ and $C$, respectively, thus the formula for conversion of (unnormalized) barycentric to Cartesian coordinates: $${m_AA+m_BB+m_CC \over m_A+m_B+m_C}$$ literally a weighted average of the vertices. Relative to a triangle, these coordinates are proportional to the areas of certain triangles, which is the definition that you’ve learned.

For the triangle to balance along an edge, say $\overline{AB}$, there must be no mass at vertex $C$, so this physical model of barycentric coordinates extends easily to zero values. Negative coordinates are a bit trickier to interpret as masses, since (tantalizing ideas in physics notwithstanding), we don’t have negative mass. N.Bach’s model in another answer of attractors/repulsors at the vertices is a nice way to work negative coordinates into a mental image. In terms of masses, you can think of a negative barycentric coordinate as the amount you’d have to remove to shift the center of mass to the point or as describing having to place the mass on the opposite side of the point from the vertex to balance the masses there.