warp.intersect_tri_tri#
- warp.intersect_tri_tri( ) int#
Test whether two triangles
(v0, v1, v2)and(u0, u1, u2)intersect, using Möller’s method.All six vertices must be in the same coordinate space. Coplanar triangles are handled (an overlap within their common plane counts as an intersection). This single-precision overload may return incorrect results in near-degenerate cases; use the
wp.intersect_tri_tri(v0, v1, v2, u0, u1, u2)overload withvec3dvertices for greater robustness.- Returns:
1if the triangles intersect,0otherwise.
Example
@wp.kernel def tri_tri(out: wp.array[wp.int32]): a0, a1, a2 = wp.vec3(0.0, 0.0, 0.0), wp.vec3(2.0, 0.0, 0.0), wp.vec3(0.0, 2.0, 0.0) b0, b1, b2 = wp.vec3(1.0, 1.0, -1.0), wp.vec3(1.0, 1.0, 1.0), wp.vec3(1.0, -1.0, 0.0) out[0] = wp.intersect_tri_tri(a0, a1, a2, b0, b1, b2) out = wp.zeros(1, dtype=wp.int32) wp.launch(tri_tri, dim=1, inputs=[out]) print("intersect:", out.numpy()[0])
intersect: 1
- warp.intersect_tri_tri( ) int
Test whether two triangles
(v0, v1, v2)and(u0, u1, u2)intersect, using Möller’s method.All six vertices must be in the same coordinate space. Coplanar triangles are handled (an overlap within their common plane counts as an intersection). This double-precision overload is more accurate than the
wp.intersect_tri_tri(v0, v1, v2, u0, u1, u2)overload withvec3vertices.- Returns:
1if the triangles intersect,0otherwise.
Example
@wp.kernel def tri_tri(out: wp.array[wp.int32]): a0, a1, a2 = wp.vec3d(0.0, 0.0, 0.0), wp.vec3d(2.0, 0.0, 0.0), wp.vec3d(0.0, 2.0, 0.0) b0, b1, b2 = wp.vec3d(1.0, 1.0, -1.0), wp.vec3d(1.0, 1.0, 1.0), wp.vec3d(1.0, -1.0, 0.0) out[0] = wp.intersect_tri_tri(a0, a1, a2, b0, b1, b2) out = wp.zeros(1, dtype=wp.int32) wp.launch(tri_tri, dim=1, inputs=[out]) print("intersect:", out.numpy()[0])
intersect: 1