University of Calgary

ball bouncing calculator

Ball Bouncing calculator
source: Jared Hopf, 2003

Description:

This program will calculate the trajectory of a bouncing ball with in a room.  The ball will start of with some initial momentum and will react due to gravity. 
Some physics you will need to know for this assignment are as follows:
These simple physics equations will provide you with motion of the ball as it moves through space.  Now onto the math and equations to bounce the ball off of a generic wall.  This also does the ground too.  :)

Determining the point of contact to a plane:

The First thing we need to know is what the plane equation is...  
The equation of the plane is given by the first equation and the Normal to the plane is given by the second equation.  Remember to normalize the normal for dealing with these equations.
To determine the closest point of the ball to a given plane we need to use the following equations.
The closest point on the plane is going to be the point that connects the plane to the position of the ball along the normal of the plane.  t represents how far along the normal the ball is away from the plane.  (Eqn 1)
We also know that the closest point on the plane taken with the dot product of the normal of the plane will give the Plane equation.  (Eqn 2)
Combining the first two equations we can devise a solution for t. (Eqn. 3-5)
Using our solution for t we can then solve the Closest point on the plane.
Now, if the distance from the position of the ball and the closest point on the plane is greater than the radius of the ball, then the ball doesn't hit the wall.  However if it is equal or less than the radius then the ball hits the plane and we should resolve the collision....

Resolving a collision with a plane:

The above diagram shows the vectors of how a balls velocity vector would alter if it comes into contact with a planer surface (IE. Wall or Floor.)
Using the normal to the plane we can use the following equations to convert the vector V into the vector R:
Remember to multiply R by some dampening constant so that the ball will lose energy as it bounces.  We now have a simulation that handles a ball bouncing off any planer surface.

Minimum Requirements:

A single ball in 2D that will bounce off the ground.

Optional Requirements:

3D balls and movement calculations.
Balls bouncing off each other. (detection)
balls reacting to each other. (resolution)
Balls bouncing off walls.
Interface with graphics.
Solutions for ball getting stuck.

Concepts:

Time stepping
Basic class methods, data, encapsulation, etc
Numerical Methods ( Euler )
I/O
Calculations

Optional Concepts:

Random numbers
File I/O
Memory Management
Arrays
Sorting



Updated: August 10, 2005 11:25 PM