Previous Section  < Day Day Up >  Next Section

Rotational Dynamics

The preceding section described the angular equivalent of Chapter 8. Now we can talk about angular displacement, velocity, and acceleration. The last thing we need to look at is what causes rotational motion. In Chapter 11, "Newton's Laws," you looked at what causes linear motion. Basically, Newton's Second Law says that adding up all the forces acting on an object determines how the object accelerates as a result of the net force being applied. We assumed that all these forces were acting on the object's center of mass, so the result was a simple translation. But what if the force is applied to one of the vertices? That would cause the object to rotate about the center of mass rather than just translating the entire object.

Suppose an object gets hit by a tangential force on one of the vertices rather than head-on. According to Newton's Second Law:

Ft = mat

Now multiply each side by the radius from that vertex to the center of mass:

Ft(r) = mat(r)

In the preceding section, we found that

at = ra

so that means

Ft(r) = m(ra)(r) = mr2a

The left side of that equation is the torque (t), which rotates an object about its axis of rotation through the center of mass.

Torque

t = mr2a

where m = mass, r = radius, and a = angular acceleration.


NOTE

As long as you stay consistent with metric units for everything else, the units for torque are N*m.


By now, you should hopefully start spotting similarities between linear motion and rotational motion. A minute ago, we mentioned Newton's Second Law, F = ma. If torque is the angular equivalent of force, there should be an angular version of Newton's Second Law, right? You just learned that t = mr2a. Mass has an angular equivalent—inertia (I)—which equals mr2. This means that torque must be equal to the inertia times the angular acceleration. Sounds a lot like Newton's Second Law, doesn't it?

Newton's Second Law Revisited

t = Ia

where I = inertia (mr2) and a = angular acceleration.


Just as net force causes linear acceleration, torque causes angular acceleration. Also as before, as soon as you know the angular acceleration, you can use the equations of motion to calculate the resulting velocity or displacement.

Example 14.6: Car Crash

Suppose you're coding a game like Grand Theft Auto, and one car hits another on the corner of the rear bumper with 5000N*m of torque. If the car that gets hit has a mass of 1200kg, and the distance from the bumper to the center of mass is 3m, what's the resulting angular acceleration?

Solution

Let's go straight to the equation derived earlier:

t = mr2a

5000N*m = 1200kg(3m)2(a)

a = 0.463rad/s2

Just as you did with linear acceleration, as soon as you know the angular acceleration, you can use it in the five equations of motion to calculate the resulting angular velocity and displacement. Remember that in game programming it all goes back to how the object moves as time is incremented frame by frame.

Two more quantities can be translated from linear motion into rotational motion—momentum and kinetic energy. Think about how you used these quantities to model linear motion. In both cases, you ended up calculating a final speed or velocity so that you could track displacement as time incremented. The same concepts can be applied to rotational dynamics. Let's look at kinetic energy first.

If inertia is related to mass, and angular velocity is related to speed, you might be able to guess the definition of rotational kinetic energy.

Rotational Kinetic Energy

KER = ½I w2

where I = inertia (mr2) and w = angular velocity.


NOTE

From this point forward, linear (or translational) kinetic energy will be labeled as KET and rotational kinetic energy will be labeled as KER.


As discussed in Chapter 12, "Energy," conservation of energy still holds. You just have one additional type of energy to add to each side of the equation—rotational kinetic energy.

Example 14.7: Rolling Ball

Suppose you're coding a game like Crash Bandicoot where the player moves around in a hamster ball for one level. The ball with a mass of 0.5kg starts from rest and rolls down a hill from an initial height of 10m. If the inertia of a sphere equals (2/5)mr2, what is the ball's linear speed when it reaches the bottom of the hill?

Solution

Let's revisit conservation of energy with the additional kinetic energy:

PEi + KETi + KERi = PEf + KETf + KERf

graphics/14inl10.gif

graphics/14inl02.gif

graphics/14inl03.gif

graphics/14inl04.gif

graphics/14inl05.gif

Remember that v = rw, so v2 = r2w2:

graphics/14inl06.gif

graphics/14inl07.gif

graphics/14inl08.gif

graphics/14equ10.gif

vf 11.832 m/s

Tackling this mathematical model is a bit more complicated, but let's give it a try. Here is a function that will calculate the linear speed of the ball given the height, mass, and inertia as provided in the previous example:


#define GRAVITY 9.81

void LinearSpeed()

    {

     //lots of floats.

     float mass,initialHeight,inertia,energy =0.0f;

float halfMass,halfInertiaMass linearSpeed,temp = 0.0f;



     cout<<"Let's calculate the linear speed of a rolling object!\n";

     cout<<"First, we need some information...\n";

     cout<<"Please specify a mass for the ball in kg\n";

     cin>>mass;



     cout<<"Next, give us an initial height for the ball in meters\n";

     cin>>initialHeight;



     cout<<"Lastly, give us an inertia for the ball\n";

     cin>>inertia;

     cout<<"\n";



     //first figure out what is known for sure.

     energy = mass*initialHeight*GRAVITY;



     //this term is used to hold the math equivalent of 1/2(m)vf^2

     halfMass = mass/2;



     //this term hold on to the formula equivalent of

     //1/2(inertia)*(mass) r^2 * wf^2



     halfInertiaMass = inertia*mass/2;



     //make a holding place.

     temp = energy/(halfMass+halfInertiaMass);



     //take the square root to find the speed in m/s

     linearSpeed = sqrt(temp);



     cout<<"The final linear speed is "<<linearSpeed<< " meters/second\n";



    }

There's lots of stuff happening in here, so let's look it over. The first thing to do is figure out the initial Potential Energy. Then the term halfMass is assigned to hold the mass/2. This value skips to the chase in code dividing the mass by two. Then we assign the result of half the inertia*mass and assign it to halfInertiaMass. Energy is then divided by the sum of those two terms. The linear speed of the ball at the bottom of the hill is the square root of the temp value. The square root function is from the math.h. It is CPU-intensive and should be used as sparingly as possible.

The trick with modeling math code for a game is to understand the function well enough to be able to distill out the most basic components, and then build code that will compute the values as quickly as possible. Getting the speed for complete calculations is usually the difficult part.

The other quantity that you can extend to rotational motion is momentum. If you follow the same parallel, angular momentum must be the product of inertia and angular velocity.

Angular Momentum

L = Iw

where I = inertia (mr2) and w = angular velocity.


Remember how in Chapter 13, "Momentum and Collisions," we rearranged Newton's Second Law from F = ma to the impulse-momentum theorem? We ended up saying that an impulse applied to an object results in a change in momentum. We can apply this same concept to rotation. Any angular (off-center) impulse results in a change in angular momentum.

As you can see, rotational motion is a natural extension of all the concepts we've discussed in terms of linear motion. The formulas stay the same, and the quantities are modified only slightly to fit a rotating object. If you understood all the chapters that discussed linear motion in depth, you should be able to start drawing your own parallels to rotation. At this point you have a strong-enough foundation to start experimenting with commercial physics engines such as Havok and MathEngine. In fact, a number of commercial game engines that incorporate physics subsystems make their development tools freely available to the mod community. For example, Unreal Tournament 2003 ships with an editor that incorporates MathEngine's Karma physics library. Although they generally don't expose the underlying mathematics directly, it's certainly a good opportunity to explore the ways in which physics can support gameplay. Or, with enough programming experience, you can start coding your own simulations from scratch. Please don't close this book and think you have arrived. I hope you put this book down only to venture out and discover all the other texts that will now make sense to you. This is just the beginning!

Self-Assessment

1.

Suppose a parent gives the merry-go-round another good push. This push delivers an angular acceleration of 6rad/s2. If the radius is still 2.5m, and the total mass with the kids is 500kg, how much torque does the parent deliver?

2.

Suppose you're coding a crazy taxi type of game. The taxi hits a parked 1000kg car on the edge of the bumper with 3000N*m or torque. If the distance from the point of collision and the car's center of mass is 2m, what was the resulting angular acceleration?


    Previous Section  < Day Day Up >  Next Section