Game Development Reference
two-dimensional shape, you can balance it on your finger by placing your finger at
the center of mass.
If you think of an object as being made up of millions of tiny particles (atoms,
for example), you can think of the center of mass as being the average position of all
these little particles, where each particle contributes to the average depending on its
mass. In fact this is how we can calculate the center of mass. We split the object into
tiny particles and take the average position of all of them:
p cofm =
m i p i
where p cofm is the position of the center of mass, m is the total mass of the object, m i
is the mass, and p i is the position of particle i .
The center of mass of a sphere of uniform density will be located at the center
point of the sphere. Similarly with a cuboid, the center of mass will be at its geometric
center. The center of mass isn't always contained within the object. A donut has its
center of mass in the hole, for example. Appendix A gives a breakdown of a range of
different geometries and where their center of mass is located.
The center of mass is important because if we watch the center of mass of a rigid
body, it will always behave like a particle . In other words, we can use exactly the same
formulae we have used so far in this topic to perform the force calculations and update
the position and velocity for the center of mass. By selecting the center of mass as our
origin position we can completely separate the calculations for the linear motion of
the object (which is the same as for particles) and its angular motion (for which we'll
need extra mathematics).
Any physical behavior of the object can be decomposed into the linear motion of
the center of mass and the angular motion around the same point. This is a profound
and crucial result, but one that takes some time to prove; if you want the background,
any good undergraduate textbook on mechanics will give details.
If we choose any other point as the origin, we can no longer separate the two
kinds of motion, so we'd need to take into account how the object was rotating in
order to work out where the origin is. Obviously this would make all our calculations
considerably more complicated.
Some authors and instructors work through code either way (although typically
only for a few results; when the mathematics gets really hard, they give up). Personally
I think it is a very bad idea to even consider having your origin anywhere else but at
the center of mass. I'll assume this will always be the case for the rest of the topic; if
you want your origin somewhere else, you're on your own!
O RIENTATION IN T HREE D IMENSIONS
In two dimensions we started out with a single angle for orientation. Problems with
keeping this value in bounds led us to look at alternative representations. In many