mymesh.rays.RaysTrianglesIntersection#
- mymesh.rays.RaysTrianglesIntersection(pts, rays, Tris, bidirectional=False, eps=1e-14)[source]#
Vectorized Möller-Trumbore intersection algorithm to detect intersections between a pairwise set of rays and a set of triangles. Möller, T., & Trumbore, B. (2005). Fast, minimum storage ray/triangle intersection. In ACM SIGGRAPH 2005 Courses, SIGGRAPH 2005. https://doi.org/10.1145/1198555.1198746 [MollerT05]
Note
With this version of the intersection test, there must be one ray for each triangle. itertools.combinations can be useful for constructing such a set of pairwise combinations, or see
RaysSurfIntersection()
which handles this and can utilize octree acceleration.This is a vectorized form of
RayTriangleIntersection()
for multiple triangles. For a single ray with multiple triangles, seeRaysTrianglesIntersection()
.When choosing between
RayTriangleIntersection()
,RayTrianglesIntersection()
, andRaysTrianglesIntersection()
, one should generally only choose the one that has as much vectorization as is needed, and not more. For example, RayTriangleIntersection will generally be slightly more efficient thanRayTrianglesIntersection()
if only one triangle is being considered, butRayTrianglesIntersection()
will be significantly faster than usingRayTriangleIntersection()
many times within a loop.- Parameters:
pts (array_like) – 2D array-like of 3D coordinates for the starting point of the rays. Should have shape (n, 3) for n rays.
rays (array_like) – 2D array-like of 3D vectors of ray directions. These should, in general, be unit vectors. Should have shape (n, 3) for n rays.
Tris (array_like) – Coordinates of triangle vertices for each triangle in the format
np.array([[[a, b, c], [d, e, f], [g, h, i]], [[...],[...],[...]], ...)
. Should have shape (n,3,3) for n triangles.bidirectional (bool, optional) – Determines whether to check for intersections only in the direction the ray is pointing, or in both directions (±ray), by default False.
eps (float, optional) – Small parameter used to determine if a value is sufficiently close to 0, by default 1e-14
- Returns:
_description_
- Return type:
_type_