# Barycenter coordinates depend on the determinant of the matrix (triangle’s method)

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?

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

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

=================
{"found_math": false, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 0, "mathjax_display_tex": 0, "mathjax_asciimath": 0, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0, "url": "http://www.learn-math.top/barycenter-coordinates-depend-on-the-determinant-of-the-matrix-triangles-method/", "fetch_time": 1537741270000000000, "content_mime_type": "text/html", "warc_filename": "crawl-data/CC-MAIN-2018-39/segments/1537267159820.67/warc/CC-MAIN-20180923212605-20180923233005-00124.warc.gz", "warc_record_offset": 359005430, "warc_record_length": 9319, "token_count": 828, "char_count": 2501, "score": 3.984375, "int_score": 4, "crawl": "CC-MAIN-2018-39", "snapshot_type": "latest", "language": "en", "language_score": 0.8265353441238403, "file_path": "/sailhome/yjruan/project/latent-lm/data/processed/finemath-4plus/finemath-4plus/train-00037-of-00064.parquet"}