intersection_ray_mesh

intersection_ray_mesh(ray, M)[source]

Compute the intersection(s) between a ray and a mesh.

Parameters:
raytuple[list[float], list[float]]

A ray represented by a point and a direction vector.

Mtuple[list[list[float]], list[list[int]]]

A mesh represented by a tuple of (vertices, faces) where vertices are 3D points and faces are triangles

Returns:
list[tuple[int, float, float, float]]

The array contains a tuple per intersection of the ray with the mesh. Each tuple contains:

  1. the index of the intersected face

  2. the u coordinate of the intersection in the barycentric coordinates of the face

  3. the u coordinate of the intersection in the barycentric coordinates of the face

  4. the distance between the ray origin and the hit