differt.rt.rays_intersect_any_triangle#
- rays_intersect_any_triangle(ray_origins, ray_directions, triangle_vertices, active_triangles=None, *, hit_tol=None, smoothing_factor=None, batch_size=512, **kwargs)[source]#
Return whether rays intersect any of the triangles using the Möller-Trumbore algorithm.
This function should be used when allocating an array of size
*batch num_triangles 3(or bigger) is not possible, and you are only interested in checking if at least one of the triangles is intersected.A triangle is considered to be intersected if
t < (1 - hit_tol) & hitevaluates toTrue.- Parameters:
ray_origins (
Float[ArrayLike, '*#batch 3']) – An array of origin vertices.ray_directions (
Float[ArrayLike, '*#batch 3']) – An array of ray direction. The ray ends should be equal toray_origins + ray_directions.triangle_vertices (
Float[ArrayLike, '*#batch num_triangles 3 3']) – An array of triangle vertices.active_triangles (
Bool[ArrayLike, '*#batch num_triangles']|None) –An optional array of boolean values indicating which triangles are active, i.e., should be considered for intersection.
If not specified, all triangles are considered active.
hit_tol (
Float[ArrayLike, '']|None) –The tolerance applied to check if a ray hits another object or not, before it reaches the expected position, i.e., the ‘interaction’ object.
Using a non-zero tolerance is required as it would otherwise trigger false positives.
If not specified, the default is ten times the epsilon value of the currently used floating point dtype.
smoothing_factor (
Float[ArrayLike, '']|None) –If set, hard conditions are replaced with smoothed ones, as described in [2], and this argument parameterizes the slope of the smoothing function. The second output value is now a real value between 0 (
False) and 1 (True).For more details, refer to Smoothing Discontinuities for Fully Differentiable Ray Tracing.
The number of triangles to process in a single batch. This allows to make a trade-off between memory usage and performance.
The batch size is automatically adjusted to be the minimum of the number of triangles and the specified batch size.
If
None, the batch size is set to the number of triangles.kwargs (
Any) – Keyword arguments passed torays_intersect_triangles.
- Return type:
- Returns:
For each ray, whether it intersects with any of the triangles.