I’m trying to understand barycenter coordinates. I have a problem where they give us 33 cartesian points (p1,p2,p3p_1, p_2, p_3), which represent the vertices of a triangle. Then I’m giving two other cartesian points pp and p′p’ for which I need to find the barycenter coordinates.

I managed to do it using the linear system (given, for example, by Wikipedia):

x=λ1×1+λ2×2+(1−λ1−λ2)x3y=λ1y1+λ2y2+(1−λ1−λ2)y3\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}

but trying to find λ1,λ2,λ3\lambda_1, \lambda_2, \lambda_3 using the method of the areas of the subtriangles (which is not clear enough to me) I’m having some problems. The idea of this method is that λ1,λ2,λ3\lambda_1, \lambda_2, \lambda_3 are equivalent to the sub-areas w1,w2,w3w_1, w_2, w_3 of the triangle p1,p2,p3p_1, p_2, p_3 (with area WW), which are formed basically by connecting 22 vertices of the triangle and the point pp (or p′p’). Then λ1=w1÷W,λ2=w2÷W,λ3=w3÷W\lambda_1 = w_1 \div W, \lambda_2 = w_2 \div W, \lambda_3 = w_3 \div W.

To calculate an area, I use the following formula:

trianglearea=det(A)triangle_{area} = det(A)

where AA is a matrix that looks like

(uv)\begin{pmatrix}

u & v

\end{pmatrix}

where uu and vv are two vectors formed as follows:

u=(p2−p)u = \begin{pmatrix}p_2 – p\end{pmatrix}

and v=(p3−p)v = \begin{pmatrix}p_3 – p\end{pmatrix}

This is the case we want to find the barycenter coordinates of pp.

The problem is that depending on if we put uu before vv or vv before uu to form the matrix AA we change the sign of the determinant. This is bad because I didn’t understand the order that I need to use to find λ1,λ2,λ3\lambda_1, \lambda_2, \lambda_3 (for pp and p′p’) with this method.

I know that this method actually calculates signed areas, but I’ve other doubts (apart from the ones mentioned so far):

Do barycenter coordinates sum always up to 11, no matter if the pp is outside the triangle? I think that if a point pp lies outside a triangle (p1,p2,p3p_1, p_2, p_3, then we should not be able to find pp as λ1p1+λ2p2+λ3p3\lambda_1 p_1 + \lambda_2 p_2 + \lambda_3 p_3, but I’m not sure if they should still sum up to 11 or not.

Can the areas be negative even if the point lies inside the triangle?

=================

=================

=================