Suppose a given point is p=(x,y,z)
and you have found that it's located in a triangle p1=(x1, y1, z1)
, p2=(x2, y2, z2)
, and p3=(x3, y3, z3)
(on the convex hull). Now if I understand correctly, we want to compute three non-negative real-valued a
, b
, and c
, such that a * p1 + b * p2 + c * p3 = p
and a + b + c = 1
(linear combination of the triangle's vertices). It can be defined by a matrix like M = [p1;p2;p3]
with an equation like [a b c] * M = p
. Hence, [a b c] = p * inv(M)
. You can do it for all other points.
Notice that if p
is not inside the triangle, the solved [a b c]
will not satisfy the non-negativity or a + b + c = 1
.