Returns the barycentric coordinates of points, given the triangles where they belong.
For more information on barycentric coordinates, see Wikipedia
Assumes:: 1) points are given as numpy arrays (crashes if not met)
Parameters : | p :
p1,p2,p3 :
|
---|---|
Returns : | [lambda1,lambda2,lambda3] :
|
Examples
>>> [p,p1,p2,p3] = np.array([[0.5,0.5, 0],
... [ 0, 0, 0],
... [ 1, 0, 0],
... [ 0, 1, 0]])
>>> barycentricCoordinates(p,p1,p2,p3)
array([ 0. , 0.5, 0.5])
Will also work for arrays:
>>> p = np.tile(p,(3,1)); p1 = np.tile(p1,(3,1))
>>> p2 = np.tile(p2,(3,1)); p3 = np.tile(p3,(3,1))
>>> barycentricCoordinates(p,p1,p2,p3)