mymesh.rays.RayTrianglesIntersection#

mymesh.rays.RayTrianglesIntersection(pt, ray, Tris, bidirectional=False, eps=1e-14)[source]#

Vectorized Möller-Trumbore intersection algorithm to detect whether a ray intersects with 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]

This is a vectorized form of RayTriangleIntersection for multiple triangles. For multiple rays, see RaysTrianglesIntersection().

When choosing between RayTriangleIntersection(), RayTrianglesIntersection(), and RaysTrianglesIntersection(), 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 than RayTrianglesIntersection() if only one triangle is being considered, but RayTrianglesIntersection() will be significantly faster than using RayTriangleIntersection() many times within a loop.

Parameters:
  • pt (array_like) – 3D coordinates for the starting point of the ray.

  • ray (array_like) – 3D vector of ray direction. This should, in general, be a unit vector.

  • 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 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:

  • intersections (np.ndarray) – Indices of triangles that are intersected by ray.

  • intersectionPts (np.ndarray) – Coordinates of intersection points for each intersection.