trimesh.ray.ray_pyembree module

Ray queries using the pyembree package with the API wrapped to match our native raytracer.

Classes

RayMeshIntersector(geometry[, scale_to_box])

class trimesh.ray.ray_pyembree.RayMeshIntersector(geometry, scale_to_box=True)

Bases: object

Methods

contains_points(points)

Check if a mesh contains a list of points, using ray tests.

intersects_any(ray_origins, ray_directions)

Check if a list of rays hits the surface.

intersects_first(**kwargs)

Find the index of the first triangle a ray hits.

intersects_id(**kwargs)

Find the triangles hit by a list of rays, including optionally multiple hits along a single ray.

intersects_location(ray_origins, ray_directions)

Return the location of where a ray hits a surface.

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