Game Development Reference
In-Depth Information
where m 1 and m 2 are the masses of the two objects, r is the distance between their cen-
ters, f is the resulting force, and G is the “universal gravitational constant”—a scaling
factor derived from observation of planetary motion.
The effects of gravity between two objects the size of a planet are significant; the
effects between (relatively) small objects such as a car, or even a building, are small.
On earth our experience of gravity is completely dominated by the earth itself. We
notice the pull of the moon in the way our tides work, but other than that we only
experience gravity pulling us down to the planet's surface.
Because we are only interested in the pull of the earth, we can simplify equa-
tion 3.3. First we can assume that m 1 is always constant. Second, and less obviously,
we can assume that r is also constant. This is due to the huge distances involved. The
distance from the surface of the earth to its center is so huge (6,400 km) that there is
almost no difference in gravity between standing at sea level and standing on the top
of a mountain. For the accuracy we need in a game, we can therefore assume the r
parameter is constant.
Equation 3.3 simplifies to
f
=
mg
[3.4]
where m is the mass of the object we are simulating; f is the force, as before; and g is a
constant that includes the universal gravitational constant, the mass of the earth, and
G m earth
r 2
=
g
The constant, g ,isanacceleration,whichwemeasureinmeterspersecondper
second. On earth this g constant has a value of around 10 m/s 2 . (Scientists sometimes
use a value of 9 . 807 m/s 2 , although because of the variations in r and other effects,
this is a global average rather than a measured value.)
Notice that the force depends on the mass of the object. If we work out the accel-
eration using equation 3.2, then we get
1
m mg
¨
=
=
p
g
In other words, no matter what mass the object has, it will always accelerate at the
same rate due to gravity. As the legend goes, Galileo dropped heavy and light objects
from the Tower of Pisa and showed that they hit the ground at the same time.
What this means for our engine is that the most significant force we need to apply
can be applied directly as an acceleration. There is no point using equation 3.4 to
calculate a force and then using equation 3.2 to convert it back into an acceleration.
In this iteration of the engine we will introduce gravity as the sole force at work on
particles, and it will be applied directly as an acceleration.