Barycentric coordinates

As each triangle is rendered, information from it is mapped from the virtual world onto the screen. This is usually accomplished using barycentric coordinates (see Figure 7.7), which expresses each point in the triangle interior as a weighted average of the three vertices:

$\displaystyle p = \alpha_1 p_1 + \alpha_2 p_2 + \alpha_3 p_3$ (7.10)

for which $ 0 \leq \alpha_1,\alpha_2,\alpha_3 \leq 1$ and $ \alpha_1 + \alpha_2 + \alpha_3 = 1$. The closer $ p$ is to a vertex $ p_i$, the larger the weight $ \alpha_i$. If $ p$ is at the centroid of the triangle, then $ \alpha_1 = \alpha_2 = \alpha_3 = 1/3$. If $ p$ lies on an edge, then the opposing vertex weight is zero. For example, if $ p$ lies on the edge between $ p_1$ and $ p_2$, then $ \alpha_3 = 0$. If $ p$ lies on a vertex, $ p_i$, then $ \alpha_i = 1$, and the other two barycentric coordinates are zero.

The coordinates are calculated using Cramer's rule to solve a resulting linear system of equations. In particular, let $ d_{ij} = e_i \cdot e_j$ for all combinations of $ i$ and $ j$. Furthermore, let

$\displaystyle s = 1/(d_{11}d_{22} - d_{12}d_{12}).$ (7.11)

The coordinates are then given by

\begin{displaymath}\begin{array}{l} \alpha_1 = s (d_{22} d_{31} - d_{12} d_{32})...
...12} d_{31})  \alpha_3 = 1 - \alpha_1 - \alpha_2 . \end{array}\end{displaymath} (7.12)

The same barycentric coordinates may be applied to the points on the model in $ {\mathbb{R}}^3$, or on the resulting 2D projected points (with $ i$ and $ j$ coordinates) in the image plane. In other words, $ \alpha_1$, $ \alpha_2$, and $ \alpha_3$ refer to the same point on the model both before, during, and after the entire chain of transformations from Section 3.5.

Furthermore, given the barycentric coordinates, the test in (7.9) can be replaced by simply determining whether $ \alpha_1 \geq 0$, $ \alpha_2 \geq 0$, and $ \alpha_3 \geq 0$. If any barycentric coordinate is less than zero, then $ p$ must lie outside of the triangle.

Steven M LaValle 2020-01-06