Given a triangle and a point inside the triangle in Cartesian coordinate system, I compute the Barycentric coordinate of the point like this:double v2_1[3], v2_3[3], v2_t[3];double bary[3];vtkMath::Subtract(p1, p2, v2_1);vtkMath::Subtract(p3, p2, v2_3);vtkMath::Subtract(t, p2, v2_t);float d00 = vtkMath::Dot(v2_1, v2_1);float d01 = vtkMath::Dot(v2_1, v2_3);float d11 = vtkMath::Dot(v2_3, v2_3);float denom = d00 * d11 - d01 * d01;float d20 = vtkMath::Dot(v2_t, v2_1);float d21 = vtkMath::Dot(v2_t, v2_3);bary[0] = (d11 * d20 - d01 * d21) / denom;bary[1] = (d00 * d21 - d01 * d20) / denom;bary[2] = 1.0f - bary[0] - bary[1];return bary;Now, how can I use the values in bary to interpolate the vertex normal at p1, p2 and p3? Specifically, I'm confused which coefficient belongs to which vertex.
How do I use barycentric coordinates to interpolate vertex normal?
interpolation
Thats the way your defining the vectors. See your defining vectors $V_1$ and $V_2$ as pointing outwards from the point $P_2$.Now then $denom$ is the square of the area of the parallelogram of formed by completing the triangle with a duplicate of itself. Another way to look at this is that its the 2 tines the square of the are of the triangle.Now then the calculation:(d11 * d20 - d01 * d21)Is the square area of the parallelogram of $P_2$-$T$-$P_3$Now if you divide this with denom, then you have calculated the total area relative area of triangle $P_2$-$T$-$P_3$. So the formula (d11 * d20 - d01 * d21) / denom is the triangle size in relation to whole triangle size of: This is the weight that the opposing corner exerts on the point. which in other words it is the barycenter weight related to point $P_1$.The next line is simply the relative area of triangle $P_2$-$T$-$P_1$ or:Which is opposite to $P_3$ being the barycentric coordinate of $P_3$.Lastly you calculate the rest which is the remaining triangle which is opposite of $P_2$ using 1 - bary[0] - bary[1].Note: You could have chosen the first vectors differently for a different order.