Jump to content

  • Log In with Google      Sign In   
  • Create Account

Awesome job so far everyone! Please give us your feedback on how our article efforts are going. We still need more finished articles for our May contest theme: Remake the Classics

#Actualdud3z

Posted 02 May 2012 - 05:41 PM

newVelocity = oldVelocity * exp(-friction * elapsedTime)


Hi guys, just wanted to take part to this interesting discussion and wanted to have some feedback about *not* using the exp function and using pow instead.
Let me explain why: i'm not sure if by using the approximation to the Euler's number is introducing some error that could accumulate in time or not, it could be barely noticeable anyway, but the thing that itch me with exp is that you need to work out yet another factor.
As an example, assuming we are working with a fixed timestep, let's suppose that your first version, at 60hz, is good with a friction of 0.975, then the exp factor should be ~1.5 so that:

exp(-1.5 * (1/60))=0.975309
and
exp(-1.5 * (1/30))=0.951229

By using pow instead, you are sure you are not introducing any "error" and you don't need to "search" for the correct factor since:

pow(0.975, 60*(1/60))=0.975
and
pow(0.975, 60*(1/30))=0.950625

I tested both in my engine and they behave and looks pratically the same, so it's basically a non-issue, but visual results aside, what do you all think from a mathematical standpoint?

#1dud3z

Posted 02 May 2012 - 05:33 PM

newVelocity = oldVelocity * exp(-friction * elapsedTime)


Hi guys, just wanted to take part to this interesting discussion and wanted to have some feedback about *not* using the exp function and using pow instead.
Let me explain why: i'm not sure if by using the approximation to the Euler's number is introducing some error that could accumulate in time or not, it could be barely noticeable anyway, but the thing that itch me with exp is that you need to work out yet another factor.
As an example, assuming we are working with a fixed timestep, let's suppose that your first version, at 60hz, is good with a friction of 0.975, then the exp factor should be ~1.5 so that:

exp(-1.5 * (1/60))=0.975309
and
exp(-1.5 * (1/30))=0.951229

By using pow instead, you are sure you are not introducing any "error" and you don't need to "search" for the correct factor since:

pow(0.975, 60*(1/60))=0.975
and
pow(0.975, 60*(1/30))=0.950625

I tested both in my engine and they behave and looks pratically the same, so it's basically a non-issue, but visual results aside, what do you all think of the pure mathematical standpoint?

PARTNERS