Collision with a Stationary Object

The simplest type of collision to model is one in which a moving object collides with a fixed stationary object, such as a billiard ball hitting the bumper. The bumper doesn't move, so you only need to model the resulting motion of one object, the ball. This type of scenario can be modeled using vector reflection, which refers to the motion of the moving object—in this case, the ball. An interesting symmetry exists: The angle that the ball comes in at must equal the angle at which it leaves. In other words, the angle of incidence (incoming) must equal the angle of reflection (outgoing), as shown in Figure 13.1.

Figure 13.1. Vector reflection.

This process is very simple to program if the wall is perfectly horizontal ...

Get Beginning Math and Physics for Game Programmers now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.