warp.geometry.intersect_seg_tri#
- warp.geometry.intersect_seg_tri( ) bool[source]#
Test whether a closed segment intersects a triangle.
Overloads accept
vec3orvec3dpoints, each with a float32 or float64tol. All points must have the same type and be in the same coordinate space. Endpoint, edge, vertex, and coplanar contact count as intersections. A zero-length segment is treated as a point. A zero-area triangle returnsFalse.With
n = cross(v1 - v0, v2 - v0), endpoint plane valuesd = dot(n, p) - dot(n, v0)satisfyingabs(d) < tolare snapped to zero. Such endpoints are treated as lying in the triangle’s plane; the dominant-axis projection determines their position within that plane. Barycentric and projected edge tests receive no additional tolerance.The normal is unnormalized: the corresponding world-space distance threshold is
tol / length(n), sotoldepends on triangle area. Under uniform coordinate scaling bys, scaletolbyabs(s)**3to preserve the classification, apart from roundoff. Seewarp.geometry.intersect_tri_tri()for the default tolerance’s float64 representation and the rounding of explicit float32 tolerances.This floating-point predicate is not exact and may be inaccurate near degeneracy. Use
vec3dfor greater precision. The result is not differentiable.- Parameters:
p0 – First endpoint of the segment.
p1 – Second endpoint of the segment.
v0 – First vertex of the triangle.
v1 – Second vertex of the triangle.
v2 – Third vertex of the 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 segment intersects the triangle, orFalseotherwise.
Example
Given segment and triangle vertices inside a Warp kernel or function:
hit = wp.geometry.intersect_seg_tri(p0, p1, v0, v1, v2, tol=0.0) hit = wp.geometry.intersect_seg_tri(p0, p1, v0, v1, v2, tol=user_tolerance)
user_tolerancemay be a runtime float32 or float64 scalar.
- warp.geometry.intersect_seg_tri( ) bool[source]
Double-precision overload of
warp.geometry.intersect_seg_tri().Return
Truefor an intersection, including boundary and coplanar contact. The tolerance and limitations are the same as for the single-precision overload.
- warp.geometry.intersect_seg_tri( ) bool[source]
Overload accepting a float32 plane tolerance; see
warp.geometry.intersect_seg_tri().