-
Notifications
You must be signed in to change notification settings - Fork 0
Intersection Tests
ExodusCoder9 edited this page Jun 20, 2026
·
1 revision
Intersectiond and Intersection are static utility classes with optimized intersection algorithms.
// Ray-Triangle (Möller-Trumbore)
double t = Intersectiond.intersectRayTriangle(origin, dir, v0, v1, v2, result);
// result receives barycentric coordinates (u, v), returns t or NaN
// Ray-AABB (slab method)
double t = Intersectiond.intersectRayAABB(origin, dir, aabb);
// returns t of nearest hit, or NaN
// Ray-Sphere
double t = Intersectiond.intersectRaySphere(origin, dir, sphere);
// returns t or NaN
// Ray-Plane
double t = Intersectiond.intersectRayPlane(origin, dir, plane);
Segment Intersections
// Segment-Triangle
double t = Intersectiond.intersectSegmentTriangle(p0, p1, v0, v1, v2, result);
// Segment-AABB
boolean hit = Intersectiond.intersectSegmentAABB(p0, p1, aabb);
// Segment-Sphere
double t = Intersectiond.intersectSegmentSphere(p0, p1, sphere);
// Segment-Plane
Vector3d point = Intersectiond.intersectSegmentPlane(p0, p1, plane);
Shape Intersections
// Triangle-Triangle
boolean hit = Intersectiond.intersectTriangleTriangle(v0, v1, v2, v3, v4, v5);
// AABB-AABB
boolean hit = Intersectiond.intersectAABBAABB(a, b);
// Sphere-Sphere
boolean hit = Intersectiond.intersectSphereSphere(a, b);
Distance & Closest Point
double dist = Intersectiond.distancePointSegment(point, segA, segB);
double dist = Intersectiond.distancePointTriangle(point, v0, v1, v2);
Intersectiond.closestPointSegmentSegment(p0, p1, q0, q1, destP, destQ);
Vector3d closest = Intersectiond.closestPointPointTriangle(point, v0, v1, v2);