O'Reilly logo

Beginning Math and Physics for Game Programmers by Wendy Stahler

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required