How to calculate an object's speed?

Hi everyone!

I've animated an object and how could I get its speed at each frame?

Thanks!

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Anubis's picture

This method is suitable for

This method is suitable for straightforward motion but if you change the direction it needs a little math to calculate a trajectory and I am not very good at math :)

my recent MAXScripts RSS (archive here)

aphexx's picture

hi, this is very cool!

hi, this is very cool! although i'm no scripter at all :)

ausn's picture

I figured out this method:

I figured out this method:

prePos = at time (currentTime - 1t) self.pos
nextPos = at time (currentTime + 1t) self.pos
d = distance prePos nextPos
v = d*4800/2 -- unit:inch/s
v = v*2.54/1000 -- unit:m/s
v = v*60*60/1000 -- unit:km/h

It could be precise enough for most circumstances.

And a friend showed me this method:

prePos = at time (currentTime - 1t) self.pos
curPos = self.pos
nextPos = at time (currentTime + 1t) self.pos
d1 = distance prePos curPos
d2 = distance curPos nextPos
d = (d1+d2)/2
v = d*4800/2 -- unit:inch/s
v = v*2.54/1000 -- unit:m/s
v = v*60*60/1000 -- unit:km/h

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.