Parametric curves
There are many situations where we don't know the exact position that an object will have at a given time but we know an equation that describe its movement. These equations are known as parametric curves and are called like that because the position depends on one parameter: the time.
There are many examples of parametric curves. We can think for instance of a projectile that we shoot on a game, a car that is going downhill or a bouncing ball. In each case, there are equations that describe the motion of these objects under ideal conditions. The next diagram shows the parametric equation that describes free fall motion.
We are going to use parametric curves for animating objects in a WebGL scene. In this example, we will model a set of bouncing balls.
Note
The complete source code for this exercise can be found in /code/ch5_BouncingBalls.html
.
Initialization steps
We will create a global variable that will store the time (simulation time).
var sceneTime = 0;
We also create the...