trimesh.ray.ray_pyembree module¶
Ray queries using the embreex package with the API wrapped to match our native raytracer.
- class trimesh.ray.ray_pyembree.RayMeshIntersector(geometry, scale_to_box=True)¶
Bases:
object
- __init__(geometry, scale_to_box=True)¶
Do ray- mesh queries.
- Parameters:
geometry (Trimesh object) – Mesh to do ray tests on
scale_to_box (bool) – If true, will scale mesh to approximate unit cube to avoid problems with extreme large or small meshes.
- contains_points(points)¶
Check if a mesh contains a list of points, using ray tests.
If the point is on the surface of the mesh, behavior is undefined.
- Parameters:
points ((n, 3) points in space)
- Returns:
contains – Whether point is inside mesh or not
- Return type:
(n,) bool
- intersects_any(ray_origins, ray_directions)¶
Check if a list of rays hits the surface.
- Parameters:
ray_origins ((n, 3) float) – Origins of rays
ray_directions ((n, 3) float) – Direction (vector) of rays
- Returns:
hit – Did each ray hit the surface
- Return type:
(n,) bool
- intersects_first(**kwargs)¶
Find the index of the first triangle a ray hits.
- Parameters:
ray_origins ((n, 3) float) – Origins of rays
ray_directions ((n, 3) float) – Direction (vector) of rays
- Returns:
triangle_index – Index of triangle ray hit, or -1 if not hit
- Return type:
(n,) int
- intersects_id(**kwargs)¶
Find the triangles hit by a list of rays, including optionally multiple hits along a single ray.
- Parameters:
ray_origins ((n, 3) float) – Origins of rays
ray_directions ((n, 3) float) – Direction (vector) of rays
multiple_hits (bool) – If True will return every hit along the ray If False will only return first hit
max_hits (int) – Maximum number of hits per ray
return_locations (bool) – Should we return hit locations or not
- Returns:
index_tri ((m,) int) – Indexes of mesh.faces
index_ray ((m,) int) – Indexes of ray
locations ((m) sequence of (p, 3) float) – Intersection points, only returned if return_locations
- intersects_location(ray_origins, ray_directions, multiple_hits=True)¶
Return the location of where a ray hits a surface.
- Parameters:
ray_origins ((n, 3) float) – Origins of rays
ray_directions ((n, 3) float) – Direction (vector) of rays
- Returns:
locations ((m) sequence of (p, 3) float) – Intersection points
index_ray ((m,) int) – Indexes of ray
index_tri ((m,) int) – Indexes of mesh.faces