-
Notifications
You must be signed in to change notification settings - Fork 0
Geometry Types
ExodusCoder9 edited this page Jun 20, 2026
·
1 revision
// Construction
AABB box = new AABB(); // empty (infinite min/max)
AABB box = new AABB(min, max); // from min/max vectors
AABB box = new AABB(point); // from single point (zero-size)
// Query
Vector3d center = box.center();
Vector3d extent = box.extent(); // half-size
Vector3d size = box.size();
// Containment
boolean inside = box.contains(point);
boolean inside = box.contains(otherBox);
// Intersection
boolean overlap = box.intersects(otherBox);
// Expansion
box.union(otherBox);
box.union(point);
// Intersection volume
AABB intersection = box.intersection(otherBox);
// Transform
AABB transformed = box.transform(matrix);
// State
boolean empty = box.isEmpty();
boolean inf = box.isInfinite();
Ray (mutable)
// Construction
Ray ray = new Ray(); // origin=(0,0,0), dir=(0,0,1)
Ray ray = new Ray(origin, direction); // from origin + direction
Ray ray = new Ray(from, to); // from two points
// Parametric
Vector3d pt = ray.pointAt(t);
// Distance
double dist = ray.distanceTo(point);
Vector3d closest = ray.closestPoint(point);
// Intersection tests (returns boolean)
boolean hit = ray.intersects(aabb);
boolean hit = ray.intersects(sphere);
boolean hit = ray.intersects(plane);
// Triangle intersection (Möller-Trumbore)
double t = ray.intersectsTriangle(v0, v1, v2); // returns t or Float.NaN
// Transform
ray.transform(matrix);
Plane (record, immutable)
Plane equation: ax + by + cz + d = 0
// Construction
Plane p = new Plane(normal, point); // from normal + point
Plane p = new Plane(v0, v1, v2); // from three points
Plane p = new Plane(a, b, c, d); // from coefficients
// Query
Vector3d n = p.normal();
double dist = p.signedDistance(point);
double dist = p.distance(point);
// Intersection
double t = p.intersects(ray); // returns parameter t
Ray line = p.intersects(otherPlane); // plane-plane intersection
// Normalize
Plane normalized = p.normalize();
Sphere (record, immutable)
// Construction
Sphere s = new Sphere(center, radius);
// Containment
boolean inside = s.contains(point);
// Intersection
boolean overlap = s.intersects(otherSphere);
boolean hit = s.intersects(ray);
boolean hit = s.intersects(aabb);