IT lexicon › Programming › Slab method

Slab method

Programming På svenska → Updated: 2026-10-27

The fast test for whether a ray hits an axis-aligned box: intersect it with three pairs of parallel planes and compare the intervals.

An AABB is just the overlap of three slabs — the space between two parallel planes along x, y and z. For each axis, work out when the ray enters and leaves that slab. The latest entry and the earliest exit settle it: if the entry comes before the exit, and the exit lies in front of the ray's origin, the ray hits the box.

Timothy Kay and James Kajiya described it in 1986. With a precomputed inverse direction it boils down to a few multiplies, mins and maxes, with no branches, and IEEE infinities handle rays exactly parallel to an axis — provided nobody ends up computing 0 × ∞. A ray tracer runs it millions of times per frame while walking a BVH, so every saved instruction shows.

← Back to the lexicon