util module
Define functions to be used everywhere in the subpackage.
- triangles_ray_intersections(origin, direction, m_mesh, edges_1, edges_2, vertices_1, normals, eps)[source]
Detect collision between a single ray and several triangles of mesh.
Based on Möller–Trumbore intersection algorithm. Stolen and adapted from printrun library. Parallel implementation taken from @V0XNIHILI.
- Parameters:
origin (np.ndarray(3, )) – Holds the starting point of the ray.
direction (np.ndarray(3, )) – Holds the direction of the ray.
m_mesh (int) – Number of triangles under study.
edges_1 (np.ndarray(m_mesh, 3)) – The first edge of every triangle.
edges_2 (np.ndarray(m_mesh, 3)) – The second edge of every triangle.
vertices_1 (np.ndarray(m_mesh, 3)) – The junction point of
edges_1andedges_2for every triangle.normals (np.ndarray(m_mesh, 3)) – Normal vector of every triangle.
eps (float) – Tolerance.
- Return type:
- Returns:
collisions (np.ndarray(m_mesh, )) – Array of booleans telling if there was a collision or not.
distances (np.ndarray(m_mesh, )) – Array of floats giving distance between
originand the triangle.impact_angles (np.ndarray(m_mesh, )) – Holds the impact angles in radians, or a nan.