Velocity and Gravity
Every moving object has a particular velocity, which is a three-dimensional vector. The velocity of an object indicates how quickly it is moving in each direction. For example, a velocity of (3, -2, -5) means that an object is moving 3 units per second in the positive x direction, 2 units per second in the downward direction, and 5 units per second in the negative z direction.
The effect of gravity, both in our programs and in the real world, is to decrease the y component of the velocity of each object at a certain rate. In the real world, this rate is 9.8 meters per second per second. In our programs, gravity will be measured in units per second per second.
To simulate gravity, we can adjust the velocity of an object in small steps. We could, for example, decrease the y component of the velocity of each object by 0.01 times the gravity every 0.01 seconds.