# Barycentric coordinate system (mathematics)

{{#invoke:Hatnote|hatnote}} In geometry, the barycentric coordinate system is a coordinate system in which the location of a point is specified as the center of mass, or barycenter, of masses placed at the vertices of a simplex (a triangle, tetrahedron, etc.). Barycentric coordinates are a form of homogeneous coordinates. The system was introduced (1827) by August Ferdinand Möbius.

## Definition

Let ${\displaystyle {\textbf {x}}_{1}\ldots {\textbf {x}}_{n}}$ be the vertices of a simplex in a vector space A. If, for some point ${\displaystyle {\textbf {p}}}$ in A,

${\displaystyle (a_{1}+\cdots +a_{n}){\textbf {p}}=a_{1}\,{\textbf {x}}_{1}+\cdots +a_{n}\,{\textbf {x}}_{n}}$

and at least one of ${\displaystyle a_{1}\ldots a_{n}}$ does not vanish then we say that the coefficients (${\displaystyle a_{1}\ldots a_{n}}$) are barycentric coordinates of ${\displaystyle {\textbf {p}}}$ with respect to ${\displaystyle {\textbf {x}}_{1}\ldots {\textbf {x}}_{n}}$. The vertices themselves have the coordinates ${\displaystyle {\textbf {x}}_{1}=(1,0,0,...,0),{\textbf {x}}_{2}=(0,1,0,...,0),\ldots ,{\textbf {x}}_{n}=(0,0,0,...,1)}$. Barycentric coordinates are not unique: for any b not equal to zero, (${\displaystyle ba_{1}\ldots ba_{n}}$) are also barycentric coordinates of p.

When the coordinates are not negative, the point ${\displaystyle {\textbf {p}}}$ lies in the convex hull of ${\displaystyle {\textbf {x}}_{1}\ldots {\textbf {x}}_{n}}$, that is, in the simplex which has those points as its vertices.

## Barycentric coordinates on triangles

Barycentric coordinates ${\displaystyle (\lambda _{1},\lambda _{2},\lambda _{3})}$ on an equilateral triangle and on a right triangle.

In the context of a triangle, barycentric coordinates are also known as area coordinates, because the coordinates of P with respect to triangle ABC are proportional to the (signed) areas of PBC, PCA and PAB. Areal and trilinear coordinates are used for similar purposes in geometry.

Barycentric or areal coordinates are extremely useful in engineering applications involving triangular subdomains. These make analytic integrals often easier to evaluate, and Gaussian quadrature tables are often presented in terms of area coordinates.

First let us consider a triangle T defined by three vertices ${\displaystyle {\textbf {r}}_{1}\,}$, ${\displaystyle {\textbf {r}}_{2}\,}$ and ${\displaystyle {\textbf {r}}_{3}\,}$. Any point ${\displaystyle {\textbf {r}}}$ located on this triangle may then be written as a weighted sum of these three vertices, i.e.

${\displaystyle {\textbf {r}}=\lambda _{1}{\textbf {r}}_{1}+\lambda _{2}{\textbf {r}}_{2}+\lambda _{3}{\textbf {r}}_{3},}$
${\displaystyle \lambda _{1}+\lambda _{2}+\lambda _{3}=1\,}$

which means that

${\displaystyle \lambda _{3}=1-\lambda _{1}-\lambda _{2}\,}$

Following this, the integral of a function ${\displaystyle f({\textbf {r}})}$ on T is

${\displaystyle \int _{T}f({\textbf {r}})\ d{\textbf {r}}=2A\int _{0}^{1}\int _{0}^{1-\lambda _{2}}f(\lambda _{1}{\textbf {r}}_{1}+\lambda _{2}{\textbf {r}}_{2}+(1-\lambda _{1}-\lambda _{2}){\textbf {r}}_{3})\ d\lambda _{1}\ d\lambda _{2}\,}$

Note that the above has the form of a linear interpolation. Indeed, area coordinates will also allow us to perform a linear interpolation at all points in the triangle if the values of the function are known at the vertices.

### Converting to barycentric coordinates

Given a point ${\displaystyle {\textbf {r}}\,}$ inside a triangle it is also desirable to obtain the barycentric coordinates ${\displaystyle \lambda _{1}\,}$, ${\displaystyle \lambda _{2}\,}$ and ${\displaystyle \lambda _{3}\,}$ at this point. We can write the barycentric expansion of vector ${\displaystyle {\textbf {r}}}$ having Cartesian coordinates ${\displaystyle (x,y)\,}$ in terms of the components of the triangle vertices (${\displaystyle {\textbf {r}}_{1}}$, ${\displaystyle {\textbf {r}}_{2}}$, ${\displaystyle {\textbf {r}}_{3}}$) as

${\displaystyle {\begin{matrix}x=\lambda _{1}x_{1}+\lambda _{2}x_{2}+\lambda _{3}x_{3}\\y=\lambda _{1}y_{1}+\lambda _{2}y_{2}+\lambda _{3}y_{3}\\\end{matrix}}\,}$

substituting ${\displaystyle \lambda _{3}=1-\lambda _{1}-\lambda _{2}\,}$ into the above gives

${\displaystyle {\begin{matrix}x=\lambda _{1}x_{1}+\lambda _{2}x_{2}+(1-\lambda _{1}-\lambda _{2})x_{3}\\y=\lambda _{1}y_{1}+\lambda _{2}y_{2}+(1-\lambda _{1}-\lambda _{2})y_{3}\\\end{matrix}}\,}$

Rearranging, this is

${\displaystyle {\begin{matrix}\lambda _{1}(x_{1}-x_{3})+\lambda _{2}(x_{2}-x_{3})+x_{3}-x=0\\\lambda _{1}(y_{1}-y_{3})+\lambda _{2}(y_{2}-y_{3})+y_{3}-y=0\\\end{matrix}}\,}$

This linear transformation may be written more succinctly as

${\displaystyle {\textbf {T}}\cdot \lambda ={\textbf {r}}-{\textbf {r}}_{3}\,}$

Where ${\displaystyle \lambda }$ is the vector of barycentric coordinates, ${\displaystyle {\textbf {r}}}$ is the vector of Cartesian coordinates, and ${\displaystyle {\textbf {T}}}$ is a matrix given by

${\displaystyle {\textbf {T}}=\left({\begin{matrix}x_{1}-x_{3}&x_{2}-x_{3}\\y_{1}-y_{3}&y_{2}-y_{3}\\\end{matrix}}\right)}$

Now the matrix ${\displaystyle {\textbf {T}}}$ is invertible, since ${\displaystyle {\textbf {r}}_{1}-{\textbf {r}}_{3}}$ and ${\displaystyle {\textbf {r}}_{2}-{\textbf {r}}_{3}}$ are linearly independent (if this were not the case, then ${\displaystyle {\textbf {r}}_{1}}$, ${\displaystyle {\textbf {r}}_{2}}$, and ${\displaystyle {\textbf {r}}_{3}}$ would be collinear and would not form a triangle). Thus, we can rearrange the above equation to get

${\displaystyle \left({\begin{matrix}\lambda _{1}\\\lambda _{2}\end{matrix}}\right)={\textbf {T}}^{-1}({\textbf {r}}-{\textbf {r}}_{3})\,}$

Finding the barycentric coordinates has thus been reduced to finding the inverse matrix of ${\displaystyle {\textbf {T}}}$, an easy problem in the case of 2×2 matrices.

Explicitly, the formulae for the barycentric co-ordinates of ${\displaystyle {\textbf {r}}=(x,y)}$ are:

${\displaystyle \lambda _{1}={\frac {(y_{2}-y_{3})(x-x_{3})+(x_{3}-x_{2})(y-y_{3})}{\det(T)}}={\frac {(y_{2}-y_{3})(x-x_{3})+(x_{3}-x_{2})(y-y_{3})}{(y_{2}-y_{3})(x_{1}-x_{3})+(x_{3}-x_{2})(y_{1}-y_{3})}}\,,}$
${\displaystyle \lambda _{2}={\frac {(y_{3}-y_{1})(x-x_{3})+(x_{1}-x_{3})(y-y_{3})}{\det(T)}}={\frac {(y_{3}-y_{1})(x-x_{3})+(x_{1}-x_{3})(y-y_{3})}{(y_{2}-y_{3})(x_{1}-x_{3})+(x_{3}-x_{2})(y_{1}-y_{3})}}\,,}$
${\displaystyle \lambda _{3}=1-\lambda _{1}-\lambda _{2}\,.}$

### Determining if a point is inside a triangle

Since barycentric coordinates are a linear transformation of Cartesian coordinates, it follows that they vary linearly along the edges and over the area of the triangle. If a point lies in the interior of the triangle, all of the Barycentric coordinates lie in the open interval ${\displaystyle (0,1)}$. If a point lies on an edge of the triangle, at least one of the area coordinates ${\displaystyle \lambda _{1...3}}$ is zero, while the rest lie in the closed interval ${\displaystyle [0,1]}$.

Summarizing,

Point ${\displaystyle {\textbf {r}}}$ lies inside the triangle if and only if ${\displaystyle 0<\lambda _{i}<1\;\forall \;i{\text{ in }}1,2,3}$.
Otherwise, ${\displaystyle {\textbf {r}}}$ lies on the edge or corner of the triangle if ${\displaystyle 0\leq \lambda _{i}\leq 1\;\forall \;i{\text{ in }}1,2,3}$.
Otherwise, ${\displaystyle {\textbf {r}}}$ lies outside the triangle.

### Interpolation on a triangular unstructured grid

Barycentric coordinates provide a convenient way to interpolate a function on an unstructured grid or mesh, as long as the function's value is known at all vertices of the mesh.

To interpolate a function ${\displaystyle f}$ at a point ${\displaystyle {\textbf {r}}}$, we go through each triangular element and transform ${\displaystyle {\textbf {r}}}$ into the barycentric coordinates of that triangle. If ${\displaystyle 0\leq \lambda _{i}\leq 1\;\forall \;i{\text{ in }}1,2,3}$, then the point lies in the triangle or on its edge (explained in the previous section). Now, we interpolate the value of ${\displaystyle f({\textbf {r}})}$ as

${\displaystyle f({\textbf {r}})=\lambda _{1}f({\textbf {r}}_{1})+\lambda _{2}f({\textbf {r}}_{2})+\lambda _{3}f({\textbf {r}}_{3})}$

This linear interpolation is automatically normalized since ${\displaystyle \lambda _{1}+\lambda _{2}+\lambda _{3}=1}$.

## Barycentric coordinates on tetrahedra

Barycentric coordinates may be easily extended to three dimensions. The 3D simplex is a tetrahedron, a polyhedron having four triangular faces and four vertices. Once again, the barycentric coordinates are defined so that the first vertex ${\displaystyle {\textbf {r}}_{1}}$ maps to barycentric coordinates ${\displaystyle \lambda =(1,0,0,0)}$, ${\displaystyle {\textbf {r}}_{2}\to (0,1,0,0)}$, etc.

This is again a linear transformation, and we may extend the above procedure for triangles to find the barycentric coordinates of a point ${\displaystyle {\textbf {r}}}$ with respect to a tetrahedron:

${\displaystyle \left({\begin{matrix}\lambda _{1}\\\lambda _{2}\\\lambda _{3}\end{matrix}}\right)={\textbf {T}}^{-1}({\textbf {r}}-{\textbf {r}}_{4})\,}$

where ${\displaystyle \mathbf {T} }$ is now a 3×3 matrix:

${\displaystyle {\textbf {T}}=\left({\begin{matrix}x_{1}-x_{4}&x_{2}-x_{4}&x_{3}-x_{4}\\y_{1}-y_{4}&y_{2}-y_{4}&y_{3}-y_{4}\\z_{1}-z_{4}&z_{2}-z_{4}&z_{3}-z_{4}\end{matrix}}\right)}$

Once again, the problem of finding the barycentric coordinates has been reduced to inverting a 3×3 matrix. 3D barycentric coordinates may be used to decide if a point lies inside a tetrahedral volume, and to interpolate a function within a tetrahedral mesh, in an analogous manner to the 2D procedure. Tetrahedral meshes are often used in finite element analysis because the use of barycentric coordinates can greatly simplify 3D interpolation.

## Generalized barycentric coordinates

{{ safesubst:#invoke:Unsubst||$N=Unreferenced section |date=__DATE__ |$B= {{ safesubst:#invoke:Unsubst||$N=Unreferenced |date=__DATE__ |$B= {{#invoke:Message box|ambox}} }} }}

Barycentric coordinates (a1, ..., an) that are defined with respect to a polytope instead of a simplex are called generalized barycentric coordinates. For these, the equation

${\displaystyle (a_{1}+\cdots +a_{n})p=a_{1}x_{1}+\cdots +a_{n}x_{n}}$

is still required to hold where x1, ..., xn are the vertices of the given polytope. Thus, the definition is formally unchanged but while a simplex with n vertices needs to be embedded in a vector space of dimension of at least n-1, a polytope may be embedded in a vector space of lower dimension. The simplest example is a quadrilateral in the plane. Consequently, even normalized generalized barycentric coordinates (i.e. coordinates such that the sum of the coefficients is 1) are in general not uniquely determined anymore while this is the case for normalized barycentric coordinates with respect to a simplex.

More abstractly, generalized barycentric coordinates express a polytope with n vertices, regardless of dimension, as the image of the standard ${\displaystyle (n-1)}$-simplex, which has n vertices – the map is onto: ${\displaystyle \Delta ^{n-1}\twoheadrightarrow P.}$ The map is one-to-one if and only if the polytope is a simplex, in which case the map is an isomorphism; this corresponds to a point not having unique generalized barycentric coordinates.

Dual to generalized barycentric coordinates are slack variables, which measure by how much margin a point satisfies the linear constraints, and gives an embedding ${\displaystyle P\hookrightarrow (\mathbf {R} _{\geq 0})^{f}}$ into the f-orthant, where f is the number of faces (dual to the vertices). This map is one-to-one (slack variables are uniquely determined) but not onto (not all combinations can be realized).

This use of the standard ${\displaystyle (n-1)}$-simplex and f-orthant as standard objects that map to a polytope or that a polytope maps into should be contrasted with the use of the standard vector space ${\displaystyle K^{n}}$ as the standard object for vector spaces, and the standard affine hyperplane ${\displaystyle \{(x_{0},\ldots ,x_{n})\mid \sum x_{i}=1\}\subset K^{n+1}}$ as the standard object for affine spaces, where in each case choosing a linear basis or affine basis provides an isomorphism, allowing all vector spaces and affine spaces to be thought of in terms of these standard spaces, rather than an onto or one-to-one map (not every polytope is a simplex). Further, the n-orthant is the standard object that maps to cones.

### Applications

Generalized barycentric coordinates have applications in computer graphics and more specifically in geometric modelling. Often, a three-dimensional model can be approximated by a polyhedron such that the generalized barycentric coordinates with respect to that polyhedron have a geometric meaning. In this way, the processing of the model can be simplified by using these meaningful coordinates.

## References

• {{#invoke:citation/CS1|citation

|CitationClass=book }}