[Math] Barycentric coordinates of a triangle

analytic geometrylinear algebratriangles

I have to do what described next:

Consider the planar triangle $[p_1,p_2,p_3]$ with vertices
$$
p_1=\left(\begin{array}[c]\,-2\\-1\end{array}\right),
p_2=\left(\begin{array}[c]\,3\\-1\end{array}\right),
p_1=\left(\begin{array}[c]\,1\\4\end{array}\right),
$$
compute the barycen-tric coordinates $\lambda_1,\lambda_2,\lambda_3$ of the point $$p=\left(\begin{array}[c]\,2\\1\end{array}\right),$$ and verify that $p$ can indeed be expressed as the convex combination $\lambda_1p_1+\lambda_2p_2+\lambda_3p_3$.

Repeat this computation for the point $$p'=\left(\begin{array}[c]\,3\\3\end{array}\right).$$ Finally, transform the triangle and the point p with the linear mapping
$$\phi:R^2 \to R^2, \phi\left(\begin{array}[c]\,x\\y\end{array}\right)
=\left(\begin{array}[c]\,2x-1\\x-3y-2\end{array}\right), $$
and compute the barycen-tric coordinates of the transformed point $q=\phi(p)$ with respect to the transformed triangle $[q_1,q_2,q_3]$, where $q_i=\phi(p_i)$, for $i=1,2,3$.

Consider the planar triangle $[p_1,p_2,p_3]$ with vertices
$p_1=\begin{pmatrix}-2\\-1\end{pmatrix}$,
$p_2=\begin{pmatrix}3\\-1\end{pmatrix}$,
$p_3=\begin{pmatrix}1\\4\end{pmatrix}$,
compute the barycentric coordinates of the point
$p=\begin{pmatrix}2\\1\end{pmatrix}$,
and verify that $p$ can indeed be expressed as the convex combination $\lambda_1p_1+\lambda_2p_2+\lambda_3p_3$. Repeat this computation with the point
$p'=\begin{pmatrix}3\\3\end{pmatrix}$.
Finally transform the triangle and the point $p$ with the linear mapping $\phi \colon \mathbb R^2\to\mathbb R^2$, $\phi\begin{pmatrix}x\\y\end{pmatrix}=\begin{pmatrix}2x-1\\x-3y+2\end{pmatrix}$, and compute the barycentric coordinates of the transformed point $q=\phi(p)$ with respect to the transformed triangle $[q_1,q_2,q_3]$, where $q_i=\phi(p_i)$, for $i=1,2,3$.

Any ideas on how to do this?

Best Answer

To calculate the barycentric cooordinates of a point wrt a given triangle, the wikipedia formulae are fine. You can write the formulae in terms of triangle areas or vector cross products, instead, if you want. This makes them look tidier, certainly, and provides some intuituion: http://mathworld.wolfram.com/BarycentricCoordinates.html

If you're writing code, the formulae based on areas or cross products will be more convenient if you already have functions for computing the latter.

Again, if you're writing code, you have to think about which two coordinates you will get from the quotient formulae, and which one you'll compute by subtraction. Some calculations will be more stable than others.