warp.geometry.intersect_tri_tri#
- warp.geometry.intersect_tri_tri( ) bool[source]#
Test whether two triangles intersect.
Overloads accept
vec3orvec3dvertices, each with a float32 or float64tol. All vertices must have the same type and be in the same coordinate space. Coplanar overlap counts as an intersection.The test follows Möller’s division-free method. A vertex’s plane value is
d = dot(n, p) - dot(n, a), wheren = cross(b - a, c - a)is the other triangle’s unnormalized normal. Values satisfyingabs(d) < tolare snapped to zero. Consequently,tolis not a world-space distance: for a nondegenerate triangle its corresponding distance threshold istol / length(n). Uniformly scaling all coordinates bysscales plane values byabs(s)**3; scaletolby the same factor to preserve the classification, apart from roundoff. Interval and coplanar edge tests receive no additional tolerance.The omitted tolerance matches
warp.intersect_tri_tri()and is stored in float64 even forvec3inputs. Explicit float32 tolerances use their rounded float32 values. To spell the exact default explicitly, usetol=wp.float64(1e-6); an ordinary kernel literaltol=1e-6is float32 and differs immediately at the cutoff.This is a floating-point predicate, not an exact orientation test. Results near degeneracy may be inaccurate; use
vec3dfor greater precision. Zero-area triangles are not supported. The discrete result is not differentiable.- Parameters:
v0 – First vertex of the first triangle.
v1 – Second vertex of the first triangle.
v2 – Third vertex of the first triangle.
u0 – First vertex of the second triangle.
u1 – Second vertex of the second triangle.
u2 – Third vertex of the second triangle.
tol – Nonnegative finite plane-equation tolerance, in float32 or float64. Zero disables snapping but retains exact floating-point coplanarity and boundary checks. Increasing it does not dilate triangle edges.
- Returns:
Trueif the triangles intersect, orFalseotherwise.
Example
Given triangle vertices inside a Warp kernel or function:
hit = wp.geometry.intersect_tri_tri(v0, v1, v2, u0, u1, u2) hit = wp.geometry.intersect_tri_tri(v0, v1, v2, u0, u1, u2, tol=1.0e-5) hit = wp.geometry.intersect_tri_tri(v0, v1, v2, u0, u1, u2, tol=0.0)
- warp.geometry.intersect_tri_tri( ) bool[source]
Double-precision overload of
warp.geometry.intersect_tri_tri().Use the same coordinate space for all six vertices. Return
Truefor an intersection, including coplanar overlap, orFalseotherwise. The plane tolerance and limitations are the same as for the single-precision overload.
- warp.geometry.intersect_tri_tri( ) bool[source]
Overload accepting a float32 plane tolerance; see
warp.geometry.intersect_tri_tri().