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

Now we’re ready to solve the problem completely. Here are the steps:

  1. Compute n and t (use equation 8).
  2. Resolve all the components of vai and vbi into magnitudes along n and t (use equation 9).
  3. Plug values into final velocity shown in equation 7 and remember the tangential components of the final velocities are the same as the initial.
  4. The results to the problem are in terms of the coordinate axes n and t, so you must transform back into x,y.

I’ll leave step 4 up to you. Now let’s talk about tensors. Just kidding, just kidding. Let’s finish this bad boy off. At this point we have the final velocities:

Final velocity for Ball A in terms of n,t:

    (vaf)nt=<(vaf)n,(vaf)t>

Final velocity for Ball B in terms of n,t:

    (vbf)nt=<(vbf)n,(vbf)t>

Now, let’s forget about collisions and think about vector geometry. Take a look at Figure 13.36; it illustrates the problem we have.

Figure 13.36 Transforming a vector from basis to basis.

Stated in plain Vulcan, we have a vector in one coordinate system n-t that we want to resolve into x,y. But how? Again, we are going to use dot products. Take a look at the vector (vaf)nt in Figure 13.36, forgetting about the n,t axes. We just want (vaf)nt in terms of the axis x,y. To compute this we’re going to need the contribution of (vaf)nt along both the x- and y-axes. This can be found with dot products. All we need to do are the following dot products:

For Ball A, va in terms of n,t is

    va = (vaf)n * n + (vaf)t * t

         (vaf)n * <nx,ny> + (vaf)t * <tx,ty>

Therefore writing with dot products,

    xaf = <nx,0> . (vaf)n + <tx,0> . (vaf)t

        = nx*(vaf)n + tx*(vaf)t

    yaf = <0,ny> . (vaf)n + <0,ty> . (vaf)t

        = ny*(vaf)n + ty*(vaf)t

For Ball B:

    vb = (vbf)n * n + (vbf)t * t

         (vbf)n *<nx,ny> + (vbf)t * <tx,ty>

Therefore,

    xbf = <nx,0> . (vbf)n + <tx,0> . (vbf)t

        = nx*(vbf)n + tx*(vbf)t

    ybf = <0,ny> . (vbf)n + <0,ty> . (vbf)t

        = ny*(vbf)n + ty*(vbf)t

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.