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 |
(n,dim) numpy double array
|
Query points coordinates |
required |
v1 |
(n,dim) numpy double array
|
First triangle vertex coordinates |
required |
v2 |
(n,dim) numpy double array
|
Second triangle vertex coordinates |
required |
v3 |
(n,dim) numpy double array
|
Third triangle vertex coordinates |
required |
Returns:
Name | Type | Description |
---|---|---|
b |
(n,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 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 |
|