pyvista.PolyDataFilters.multi_ray_trace#
- PolyDataFilters.multi_ray_trace( )[source]#
Perform multiple ray trace calculations.
This requires a mesh with only triangular faces, an array of origin points and an equal sized array of direction vectors to trace along.
The embree library used for vectorization of the ray traces is known to occasionally return no intersections where the VTK implementation would return an intersection. If the result appears to be missing some intersection points, set
retry=Trueto run a second pass over rays that returned no intersections, usingPolyDataFilters.ray_trace().- Parameters:
- originsarray_like[
float] Starting point for each trace.
- directionsarray_like[
float] Direction vector for each trace.
- first_pointbool, default:
False Returns intersection of first point only.
- retrybool, default:
False Will retry rays that return no intersections using
PolyDataFilters.ray_trace().
- originsarray_like[
- Returns:
- intersection_points
numpy.ndarray Location of the intersection points. Empty array if no intersections.
- intersection_rays
numpy.ndarray Indices of the ray for each intersection point. Empty array if no intersections.
- intersection_cells
numpy.ndarray Indices of the intersection cells. Empty array if no intersections.
- intersection_points
Examples
Compute the intersection between rays from the origin in directions
[1, 0, 0],[0, 1, 0]and[0, 0, 1], and a sphere with radius 0.5 centered at the origin>>> import pyvista as pv >>> sphere = pv.Sphere() >>> points, rays, cells = sphere.multi_ray_trace( ... [[0, 0, 0]] * 3, ... [[1, 0, 0], [0, 1, 0], [0, 0, 1]], ... first_point=True, ... ) >>> string = ', '.join( ... [ ... f'({point[0]:.3f}, {point[1]:.3f}, {point[2]:.3f})' ... for point in points ... ] ... ) >>> f'Rays intersected at {string}' 'Rays intersected at (0.499, 0.000, 0.000), (0.000, 0.497, 0.000), (0.000, 0.000, 0.500)'