barycentric_coordinates
barycentric_coordinates(p, v1, v2, v3)
Per-vertex weights of point inside triangle
Computes the barycentric coordinates of a point inside a triangle in two or three dimensions. If 3D, computes the coordinates of the point's projection to the triangle's plane.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
p |
(dim,) numpy double array
|
Query point coordinates |
required |
v1 |
(dim,) numpy double array
|
First triangle vertex coordinate |
required |
v2 |
(dim,) numpy double array
|
Second triangle vertex coordinate |
required |
v3 |
(dim,) numpy double array
|
Third triangle vertex coordinate |
required |
Returns:
Name | Type | Description |
---|---|---|
b |
(3,) numpy double array
|
Vector of barycentric coordinates |
Examples:
from gpytoolbox import barycentric_coordinates
# Generate random triangle points
v1 = np.random.rand(3)
v2 = np.random.rand(3)
v3 = np.random.rand(3)
# Generate random query point using barycentric coordinates
q = 0.2*v1 + 0.3*v2 + 0.5*v3
# Find barycentric coordinates
b = gpytoolbox.barycentric_coordinates(q,v1,v2,v3)
Source code in src/gpytoolbox/barycentric_coordinates.py
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
|