quinta-feira, 2 de fevereiro de 2012

Approximating damping calculations using Taylor expansions in physics simulation

I was happily following Game Physics Engine Development Book when I came across the damping approximation. Without any real explanations we got this 2 lines of code:
// Impose drag.
velocity *= real_pow(damping, duration);
An equation that involves a power of t, I freaked out. How is this possible? And then, researching a little about this I tried to understand how to numerical approximate the friction equation F = -cv. Researching more, I started to explore Box2D code, when I finnaly got a reasonable explanation, but still, there was some magical steps. Time to get my calculus books from the shelf.

This can be coded in as3 as:
velocity.scaleBy(1 - damping*duration);

It's always nice when you have the opportunity to use the stuff you learned in your undergrad course. I still don't understand the power of t thing, but I can accept this solution.

Nenhum comentário:

Postar um comentário