Tricks of the Windows Game Programming Gurus:Playing God: Basic Physics Modeling

All ITKnowledge Source Code Search Tips Advanced Search |

| Tricks of the Windows Game Programming Gurus by Andre LaMothe Sams, Macmillan Computer Publishing ISBN: 0672313618 Pub Date: 09/27/99

Search this book:

Previous | Table of Contents | Next

Isn’t that interesting? It’s almost identical to the formulas we got when we combined the kinetic energy equations with the linear momentum equations. And in fact the assumption we made when we combined the kinetic energy equations with the linear momentum equations was that kinetic energy was conserved. If we assume that now then we set e=1 and we get

    vaf = ((1+1)*mb*vbi + vai*(ma – 1*mb))/(ma + mb)

    vbf = ((1+1)*ma*vai - vbi*(ma – 1*mb))/(ma + mb)

or

    vaf = (2*mb*vbi + vai*(ma – mb))/(ma + mb)

    vbf = (2*ma*vai - vbi*(ma – mb))/(ma + mb)

These indeed are the equations with both kinetic energy and linear momentum conserved! So it looks like we’re on the right track. We have equations 1 and 2, so we should be able to solve the problem. But there’s a catch; the equations are still in 1D, so we need to write them in 2D and then find a solution.

Referring back to Figure 13.33, you see there are two extra axes labeled—the n and t axes. The n axis is in the direction of the line of collision and the t axis or tangential axis is perpendicular to n. Assuming we have computed the vectors representing these axes (I’ll show how a little later) then we can write some equations.

The first set of equations we’re going to write relates the tangential component of the velocities before and after the collision. Since there are no frictional forces and no impulsive forces acting tangentially to the line of collision (trust me), the tangential linear momentum (and therefore the velocities) must be the same before and after, right? If there are no forces then this must be true, thus we can write

Equation 3: Relationship between initial and final tangential momentum/velocities

    ma*(vai)t = ma(vaf)t

    mb*(vbi)t = mb(vbf)t

And if you wish you can combine them like this:

    ma*(vai)t + mb*(vbi)t = ma(vaf)t + mb(vbf)t

Since the masses are the same before and after the collision we can deduce that the velocities are the same by dividing the masses out:

Equation 4: Velocities after collision are equal in tangential direction

    (vai)t = (vaf)t

    (vbi)t = (vbf)t

Cool. Now that we have half the problem solved we know the final velocities of the tangential components. Let’s find the final velocities of the normal components, or the velocities in the line of collision n. We know that linear momentum is conserved always because there are no outside forces acting on the balls when they hit, so we can write:

Equation 5: Linear momentum is conserved in the n axis or line of collision

    ma*(vai)n + mb*(vbi)n = ma*(vaf)n + mb*(vbf)n

And we can also write e in terms of the n axis:

Equation 6: The coefficient of restitution in the n axis

Now let’s take a look at what we have. If you look at equations 5 and 6, I have highlighted the variables that we don’t have: (vaf)n, and (vbf)n. Just the normal components of the final velocity. Bingo! We have two equations and two unknowns, so we can solve for them. But we already have the answer! Equation 2 still holds for any particular axis, so I can rewrite it for the component along n:

Equation 7: Final velocities in the normal direction

    vaf = ((e+1)*mb*(vbi)n + (vai)n*(ma – e*mb))/(ma + mb)

    vbf = ((e+1)*ma*(vai)n – (vbi)n*(ma – e*mb))/(ma + mb)

That’s it!

Previous | Table of Contents | Next

Copyright © Macmillan Computer Publishing, Inc.

Products | Contact Us | About Us | Privacy | Ad Info | Home
Use of this site is subject to certain Terms & Conditions, Copyright © 1996-2000 EarthWeb Inc. All rights reserved. Reproduction in whole or in part in any form or medium without express written permission of EarthWeb is prohibited. Read EarthWeb's privacy statement.