EBGeometry
Compact, header-only C++ library for fast evaluation of signed distance functions
Loading...
Searching...
No Matches
Functions
EBGeometry::TriangleRay Namespace Reference

The triangle ray-crossing kernel. More...

Functions

template<class V , class Source >
EBGEOMETRY_HOST_ALWAYS_INLINE V crossing (const Source &a_triangle, const TriangleDistance::Vec3V< V > &a_origin, const TriangleDistance::Vec3V< V > &a_direction, const V a_tMin, const V a_tMax) noexcept
 Where a ray crosses a triangle, or one triangle per lane (Möller–Trumbore).
 

Detailed Description

The triangle ray-crossing kernel.

Function Documentation

◆ crossing()

template<class V , class Source >
EBGEOMETRY_HOST_ALWAYS_INLINE V EBGeometry::TriangleRay::crossing ( const Source &  a_triangle,
const TriangleDistance::Vec3V< V > &  a_origin,
const TriangleDistance::Vec3V< V > &  a_direction,
const V  a_tMin,
const V  a_tMax 
)
inlinenoexcept

Where a ray crosses a triangle, or one triangle per lane (Möller–Trumbore).

The ray is origin + t * direction. A crossing counts where t is in [a_tMin, a_tMax], from either side of the triangle. The barycentric tests are widened by the rounding error of the crossing point, a distance of a few ulps of the ray origin's and the triangle's coordinates, so that a ray through an edge or vertex shared by two triangles crosses at least one of them however far it comes from; a ray in the triangle's plane does not cross it. A ray passing outside a triangle within that distance counts as crossing it (on the safe side, as a grazing marched ray does). The triangle is read through a_triangle, which provides vertex(k) for k = 0, 1, 2 as TriangleDistance::Vec3V<V> (see TriangleDistance::signedDistance()). For a SIMD::Pack every lane computes every test, so the kernel has no branches.

Template Parameters
VScalar (float or double) or SIMD::Pack.
SourceTriangle accessor.
Parameters
[in]a_triangleTriangle accessor.
[in]a_originRay origin, the same in every lane.
[in]a_directionRay direction, the same in every lane.
[in]a_tMinStart of the interval.
[in]a_tMaxEnd of the interval.
Returns
The distance along the ray of the crossing, or +infinity where there is none.