I cannot figure out how we go from uAB-vector + vAC-vector + PA-vector = 0 to the linear system with those subscripts x and y? Is there another way of explaining how we take three vectors, split them into x and y type vectors, and produce a cross-product that can be used to find the barycentric coords (u, v, w)?

Also, I am not sure why there is a division by the z component of the cross product in last line of the barycentric function. Maybe the answer to my first question will make this more obvious.

Below is a picture of the section of the tutorial where I am stuck. Link to full page is above.

enter image description here

  • 1
    \$\begingroup\$ This looks very similar to your previous question. Please edit your existing question to add additional information, rather than posting a new one that's nearly identical, leaving dead ends for future searchers. \$\endgroup\$
    – DMGregory
    Commented Jan 3, 2021 at 18:14
  • \$\begingroup\$ Does this answer your question? What's the most efficient way to find barycentric coordinates? \$\endgroup\$
    – Almo
    Commented Jan 3, 2021 at 18:33
  • \$\begingroup\$ @DMGregory my previous question is directed at how do we obtain u(AB-vector)+v(AC-vector)+PA-vector = 0-vector. I edited my previous question to remove the extra stuff that I would like to see addressed in this question. \$\endgroup\$ Commented Jan 3, 2021 at 19:41
  • \$\begingroup\$ @Almo thank you for for that link, I will go over it. It looks like there are lots of ways to solve this problem, but I am very curious about the one in my linked article. \$\endgroup\$ Commented Jan 3, 2021 at 19:46

1 Answer 1


I think I understand now what is going on with the cross-product of the two vectors with three values. In the triangle ABC with point P given, lying somewhere inside or outside of the triangle, the author determines what the u, v, and 1-u-v values are (barycentric coordinates). They act like weights on the triangle to determine P, and if any are less than 0, the point is outside the triangle. This relies on three cross products. The cross product of two vectors divided by two gives us the area of a triangle and that is key for figuring out where P lies in the triangle. First and second vectors are calculated by determining the area of the sub-triangles for (AC and AP) and (AB and AP). Crossing vectors AB and vector AP, then another cross product for vector AC and vector AP. The third vector is for vector AB and vector AC. In the last line of the barycentric function you can see the three sub-area values divided by the total area of the triangle to get the barycentric values.

I think I had trouble with this because the variables u, and v, and x, y, z are used in different contexts in the code than what I am used to from what I see when googling barycentric coordinates. Also, other sources wouldn't put the three cross product calculations into one larger cross product. I just needed more time to unpackage this part of the tutorial. I still don't understand how the author of this tutorial explains what he is doing, but from looking at other sources and looking at his code, I believe I understand well enough how barycentric coordinates work to find u,v,w while having P, or the other way around.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .