Wednesday, June 6, 2007

Simulating Drag

One thing the book only touches on briefly is how drag, a.k.a. air friction, is simulated in Armadillo Run. I have been thinking about this and realizing how complex drag is to simulate.

If your dealing with a
dense object moving at low speeds, like a rolled up armadillo for instance, drag is proportional to velocity. Armadillo Run uses this approach for its drag calculation each time slice, and it works just fine.

Unfortunately having drag proportional to velocity becomes increasingly inaccurate as an object approaches terminal velocity. Near terminal velocity drag (typically) increases proportional to the object's speed squared. On the other hand a sphere's streamline quality makes it a bit different than something like a box moving through the air. I once read the drag measured on a golf ball ended up being roughly proportional to the ball's velocity to the power of 1.3. Golf balls have evolved to minimize drag, though I suspect the spherical shape plays a major role.

The orientation of a moving object effects drag enormously. For instance a real metal sheet falling parallel to the ground will experience a much higher drag force than a metal sheet falling perpendicular to the ground. If the metal sheet were spinning it would experience a rotational drag force, and this would continually decrease angular velocity. Lift forces occur as well making the math even more involved.

Every complication adds to the CPU work required to calculate the next frame. An extremely accurate simulation would have a more limited number of objects that could be simulated and still have the program run in real time. Hopefully in the next Armadillo Run update Peter will find a nice trade-off between speed and accuracy for drag.

No comments: