pyFM.spectral.projection_utils.point_to_triangles_projection¶
- pyFM.spectral.projection_utils.point_to_triangles_projection(triangles, point, return_bary=False)¶
Project a p-dimensional point on each of the given p-dimensional triangles.
This is a parallelized version of pointTriangleDistance.
All operations are parallelized, which makes the code quite hard to read. For an easier take, follow the code in the function below (not written by me) for projection on a single triangle.
The algorithm is based on [1].
The algorithm first finds for each triangle in which of the following regions the projected point lies, then solves for each region.
Note
- Most notations come from :
[1] “David Eberly, ‘Distance Between Point and Triangle in 3D’, Geometric Tools, LLC, (1999)”
- Parameters:
triangles ((m, 3, p) np.ndarray) – Set of m p-dimensional triangles.
point ((p,) np.ndarray) – Coordinates of the point.
return_bary (bool, optional) – Whether to return barycentric coordinates inside each triangle.
- Returns:
final_dists ((m,) np.ndarray) – Distance from the point to each of the triangles.
projections ((m, p) np.ndarray) – Coordinates of the projected point on each triangle.
bary_coords ((m, 3) np.ndarray) – Barycentric coordinates of the projection within each triangle. Returned ONLY if return_bary is True.