Sometimes it is desired to derive attributes for an arbitrary position based on the attributes of some known points. Imagine for example a triangle where each of the three base points has its own colour and you want to derive the colour of any other position in the grid. In such cases, barycentric coordinates are useful. This coordinate system is built upon some base points (say three for a triangle) and every other point inside or outside of the triangle can be represented by a linear combination of these base points
\begin{equation*} \fvec{x} = \alpha_1 \fvec{x}_1 + \alpha_2 \fvec{x}_2 + \alpha_3 \fvec{x}_3. \end{equation*}Each point \(\fvec{x}_i\) is weighted into the resulting point by the corresponding weighting factor \(\alpha_i\). Weights can be positive (for points inside the triangle) or negative (for points outside of the triangle). Important is that in total they sum up to
\begin{equation*} \sum_{i=1}^3 \alpha_i = 1. \end{equation*}As an example consider the representation of the first base point itself
\begin{equation*} \fvec{\alpha} = \begin{pmatrix} 1 \\ 0 \\ 0 \end{pmatrix} \Rightarrow 1 \cdot \fvec{x}_1 + 0 \cdot \fvec{x}_2 + 0 \cdot \fvec{x}_3 = \fvec{x}_1. \end{equation*}The resulting weights can also be used to interpolate between colours associated with the base points. In total, each point in the grid gets its own (unique) weight vector.
The technique can also be expanded to higher dimensions, e.g. four weights and corresponding points forming a tetrahedron.
List of attached files:
- BarycentricCoordinates.nb [PDF] (Mathematica notebook used to create the visualization)
← Back to the overview page