Calculating the barycentric coordinates for a point in a triangle?

4.3k Views Asked by At

How would I find the corresponding $\alpha$, $\beta$, and $\gamma$ for the point $p$ with respect to the triangle with vertices $a$, $b$, and $c$?

enter image description here

3

There are 3 best solutions below

0
On BEST ANSWER

You can use a very simple method presented in "Beginner's guide to mapping simplexes affinely" and "Workbook on mapping simplexes affinely", namely calculate $$ \vec{\Lambda} = (-1) \frac{ \det \begin{pmatrix} 0 & \vec{e}_1 & \vec{e}_2 & \vec{e}_3 \\ p_x & a_x & b_x & c_x \\ p_y & a_y & b_y & c_y \\ 1 & 1 & 1 & 1 \end{pmatrix} }{ \det \begin{pmatrix} a_x & b_x & c_x \\ a_y & b_y & c_y \\ 1 & 1 & 1 \end{pmatrix} } = \alpha \vec{e}_1 + \beta \vec{e}_2 + \gamma \vec{e}_3 $$ Here $\vec{e}_1$, $\vec{e}_2$, and $\vec{e}_3$ are some formal orthonormal vectors. Components of "vector" $\vec{\Lambda}$ will be equal to barycentric coordinates.

EXAMPLE

Let $a = (-2;-1)$, $b = (3; -1)$, and $c = (1;4)$. I want to calculate barycentric coordinates of $p = (2;1)$. The equation above gives $$ \vec{\Lambda} = (-1) \frac{ \det \begin{pmatrix} 0 & \vec{e}_1 & \vec{e}_2 & \vec{e}_3 \\ 2 & -2 & 3 & 1 \\ 1 & -1 & -1 & 4 \\ 1 & 1 & 1 & 1 \end{pmatrix} }{ \det \begin{pmatrix} -2 & 3 & 1 \\ -1 & -1 & 4 \\ 1 & 1 & 1 \end{pmatrix} } = \frac{1}{25} \vec{e}_1 + \frac{14}{25} \vec{e}_2 + \frac{2}{5}\vec{e}_3, $$ thus barycentric coordinates of $p$ are $\alpha=1/25$, $\beta=14/25$, and $\gamma=2/5$.

MULTIPLE DIMENSIONS

The general formula for any dimension is $$ \vec{\Lambda} = (-1) \frac{ \det \begin{pmatrix} 0 & \vec{e}_{1} & \vec{e}_{2} & \dots & \vec{e}_{n+1} \\ \begin{matrix} x_{1} \vphantom{x_{1}^{(1)}} \\ x_{2} \vphantom{x_{1}^{(1)}} \\ \cdots \\ x_{n} \vphantom{x_{1}^{(1)}} \\ \end{matrix} & % \begin{matrix} x_{1}^{(1)} \\ x_{2}^{(1)} \\ \cdots \\ x_{n}^{(1)} \\ \end{matrix} & % \begin{matrix} x_{1}^{(2)} \\ x_{2}^{(2)} \\ \cdots \\ x_{n}^{(2)} \\ \end{matrix} & % \cdots & % \begin{matrix} \!x_{1}^{(n+1)}\! \\ \!x_{2}^{(n+1)}\! \\ \cdots \\ \!x_{n}^{(n+1)}\! \\ \end{matrix} \\ % 1 & 1 & 1 & \cdots & 1 \end{pmatrix} }{ \det \begin{pmatrix} \begin{matrix} x_{1}^{(1)} \\ x_{2}^{(1)} \\ \cdots \\ x_{n}^{(1)} \\ \end{matrix} & % \begin{matrix} x_{1}^{(2)} \\ x_{2}^{(2)} \\ \cdots \\ x_{n}^{(2)} \\ \end{matrix} & % \cdots & % \begin{matrix} \! x_{1}^{(n+1)}\! \\ \!x_{2}^{(n+1)}\! \\ \!\cdots \! \\ \! x_{n}^{(n+1)} \!\\ \end{matrix} \\ % 1 & 1 & \cdots & 1 \end{pmatrix} }. $$ Here $\vec{x}^{\,(1)}$, $\dots$, $\vec{x}^{\,(n+1)}$ are vertices of the simplex, $x_{1}$, $\dots$, $x_{n}$ --- coordinates of the point, which barycentric coordinates you want to know, and $\vec{e}_{1}$, $\dots$, $\vec{e}_{n+1}$ are some formal orthonormal vectors. As a result you get a "vector" $\vec{\Lambda}$, which components are barycentric coordinates of the point $\vec{x}$.

REFERENCES

To read more on the theory everything relies on, you may want to check "Beginner's guide to mapping simplexes affinely" that is written by authors of the formula, or check concrete example in their "Workbook on mapping simplexes affinely".

0
On

You have $$\alpha + \beta + \gamma = 1.$$
You also have $$\alpha a + \beta b + \gamma c = p.$$ Harvest three equations in three unknowns by unpacking the coordinates in the second equation.

0
On

Lemma about areas If triangles APQ and BPQ have common side PQ, then the ratio in which the line PQ divides AB is up to a sign equal to $S_{APQ}:S_{BPQ}$

So, $[S_{PBC} : S_{PAC} : S_{PAB}]$ are (not normalized) barycentric coordinates of $P$ with respect to $ABC$.

In your problem, $[S_{PBC} : S_{PAC} : S_{PAB}] = [1 : S_{PAC}: \frac{3}{2}] = [1 : 3- 1 -\frac{3}{2}: \frac{3}{2}] = [2: 1 : 3] $