Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
As an alternative to bounding areas, you can use ray casting, which is more precise than bounding areas, to detect collisions. The application shown in Figure 8.5 uses ray casting to determine if the ball falls into the bucket. The application consists of a simple launch pad on the left and the bucket on the right. When the application starts, the ball rests on the launch pad. When a user clicks the mouse, the application launches the ball in the direction of the mouse cursor, with a velocity proportional to the distance from the cursor to the launch pad.
Figure 8.5. Ray casting
Ray casting is simple: You cast a ray from an object coincident with the object’s velocity vector. Then you cast another ray from another object and see where the two rays intersect.