Bouncing off horizontal or vertical walls

In the first application of collision physics, we will look at how to make a ball bounce off a straight wall that is either horizontal or vertical in a 2D simulation space such as a floor, ceiling, or room wall. For illustration, we use a vertical wall, but similar principles will apply to horizontal walls as well.

We'll look at elastic and inelastic bouncing in turn (bouncing in which the kinetic energy of the ball is or is not conserved).

Elastic bouncing

If the ball bounces elastically off a wall, its kinetic energy just after bouncing must equal its kinetic energy just before bouncing. Because k.e. = ½ mv2, this implies that its velocity magnitude is unchanged by the collision.

Consider first a special ...

Get The Essential Guide to Physics for Flash Games, Animation, and Simulations now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.