9.3
85 3D: Bounds, rays, and planes
3D reference map · First 3D picture
Constructs an inclusive axis-aligned box. Both corners must be vec3
values ordered coordinatewise, or both must be #f for the empty box.
Recognizes a spatial AABB.
procedure
(aabb3-minimum bounds) → (or/c #f vec3?)
bounds : aabb3?
Returns the lower corner or #f when empty.
procedure
(aabb3-maximum bounds) → (or/c #f vec3?)
bounds : aabb3?
Returns the upper corner or #f when empty.
value
The empty AABB.
procedure
(aabb3-empty? bounds) → boolean?
bounds : aabb3?
Reports whether bounds are empty.
procedure
(aabb3-union first second) → aabb3?
first : aabb3? second : aabb3?
Returns their least enclosing AABB.
procedure
(aabb3-from-points points) → aabb3?
points : (listof vec3?)
Returns enclosing bounds, or aabb3-empty for no points.
procedure
(aabb3-transform bounds map) → aabb3?
bounds : aabb3? map : affine3?
Transforms all eight corners and encloses them.
procedure
(aabb3-center bounds) → vec3?
bounds : aabb3?
Returns nonempty bounds’ centre; empty bounds raise an exception.
procedure
(aabb3-size bounds) → vec3?
bounds : aabb3?
Returns nonempty bounds’ nonnegative size; empty bounds raise an exception.
procedure
(aabb3-contains? bounds point) → boolean?
bounds : aabb3? point : vec3?
Tests inclusive containment.
A ray (+ origin (* t direction)) for t at least zero. Its
direction must be nonzero but is not normalized automatically.
Constructs a point-normal plane and normalizes its nonzero normal.
Recognizes a spatial plane.
procedure
(plane3-point plane) → vec3?
plane : plane3?
Returns one point in the plane.
procedure
(plane3-normal plane) → vec3?
plane : plane3?
Returns its normalized normal.
struct
(struct ray3-plane-hit (point distance) #:transparent) point : vec3? distance : nonnegative-real?
A forward ray-plane intersection.
struct
(struct ray3-aabb-hit (entry exit) #:transparent) entry : nonnegative-real? exit : nonnegative-real?
The inclusive ray-parameter interval inside an AABB.
struct
(struct ray3-triangle-hit (point distance barycentric normal) #:transparent) point : vec3? distance : nonnegative-real? barycentric : vec3? normal : vec3?
An exact, double-sided ray/triangle hit. barycentric holds the weights
for the triangle’s first, second, and third vertices, and normal
follows the triangle’s declared winding.
procedure
ray : ray3? distance : finite-real?
Returns the algebraic point at distance.
procedure
(ray3-intersect-plane ray plane) → (or/c #f ray3-plane-hit?)
ray : ray3? plane : plane3?
Returns the nearest forward hit, or #f when parallel or behind the origin.
procedure
(ray3-intersect-aabb ray bounds) → (or/c #f ray3-aabb-hit?)
ray : ray3? bounds : aabb3?
Returns forward entry/exit parameters, or #f for no hit.
procedure
(ray3-intersect-triangle ray first second third) → (or/c #f ray3-triangle-hit?) ray : ray3? first : vec3? second : vec3? third : vec3?
Returns the nearest exact forward intersection with the finite triangle, or
#f. Both windings are pickable; renderer back-face culling is a
separate display decision.