## Raycast Axis Aligned Bounding Box

Any ray that intersects an AABB will do so twice. The first intersection is where the ray enters the AABB; the second is where the ray exists. If we know both intersection points, the point closest to the origin of the ray is the intersection point.

We can simplify finding the intersections points by visualizing the problem top down. Looking only at the X and Y axis. In this example, the AABB is represented by two slabs. The intersections of the slabs form four planes. These planes represent the faces of the AABB. We cast a ray and check if it's intersecting the X slab:

We found two points as a result of testing the ray intersection against the X slab. We call the near point and the far point . We repeat the same intersection against the Y slab:

We now have two more points, and . The ray enters the Y slab, and then leaves the Y slab. Next, the ray enters the X slab, and then leaves the X slab. There is **no intersection**. We can prove this, the **greatest minimum...**