Introduction
In this chapter, we are going to test if rays or line segments intersect primitives. The primitives that we are going to test against are Sphere, Axis Aligned Bounding Box (AABB), Oriented Bounding Box (OBB), and plane. Raycast intersections will return the distance along the ray that the intersection has happened. Line segment intersections will simply return a Boolean value.
Raycasting is one of the most powerful tools we have. Let's assume for example that you want to make sure a character always stands on the ground. You could cast a ray down on the negative Y axis, where the ray hits the ground you place the character. This technique is often referred to as ground clamping.