Game Development Reference
In-Depth Information
* integration is simpler and because in real-time
* simulation it is more useful to have objects with
* infinite mass (immovable) than zero mass
* (completely unstable in numerical simulation).
*/
real inverseMass;
};
It is really important to remember that you are dealing with the inverse mass,
and not the mass. It is quite easy to set the mass of the particle directly, without
remembering, only to see it perform completely inappropriate behavior on screen—
barely movable barrels zooming off at the slightest tap, for example.
To help with this, I've made the inverseMass data field protected in the Particle
class on the CD. To set the inverse mass you need to use an accessor function. I have
provided functions for setInverseMass and setMass . Most of the time it is more con-
venient to use the latter, unless we are trying to set an infinite mass.
3.2.5
M OMENTUM AND V ELOCITY
Although Newton 1 is often introduced in terms of velocity, that is a misrepresenta-
tion. It is not velocity that is constant in the absence of any forces, but momentum.
Momentum is the product of velocity and mass. Since mass is normally constant,
we can assume that velocity is therefore constant by Newton 1. In the event that a
traveling object were changing mass, then its velocity would also be changing, even
with no forces.
We don't need to worry about this for our physics engine because we'll not deal
with any situation where mass changes. It will be an important distinction when we
come to look at rotations later, however, because rotating objects can change the way
their mass is distributed. Under the rotational form of Newton 1, that means a change
in rotational speed, with no other forces acting.
3.2.6
T HE F ORCE OF G RAVITY
The force of gravity is the most important force in a physics engine. Gravity applies
between every pair of objects: attracting them together with a force depends on their
mass and their distance apart. It was Newton who also discovered this fact, and along
with the three laws of motion he used it to explain the motion of planets and moons
with a new level of accuracy.
The formula he gave us is the “law of universal gravitation”:
G m 1 m 2
r 2
=
f
[3.3]
Search Nedrilad ::




Custom Search