How can I calculate the acceleration of an object?

Is there some easy way to calculate the acceleration of an object at every point in time, between the two closest keyframe?

I'm thinking that the easiest way would be to calculate the velocity of the object and then calculate it's derivative. However, for that I need the time difference, which I don't know how to calculate.

Is this even possible (currently :D)?

However, for that I need the time difference, which I don't know how to calculate.

You can use the second order finite differencing to approximate the acceleration. And by using a central differencing scheme you can achieve second order accuracy.

In Blender, you can use FCurve.evaluate function to get the position of one object:

action = bpy.data.actions[0]
curve = action.fcurves[0]
# Evaluate object's position at time t
position = curve.evaluate(t)


And you can use central second order differencing to calculate the acceleration at time t:

def D(curve, t):
h = 1e-4
return (curve.evaluate(t + h) - curve.evaluate(t) * 2 + curve.evaluate(t - h)) / (h * h)


Note that you have to use backward or forward differencing scheme at boundary of an action curve since the value at t + h or t - h may not be defined there.

Also note that you will see an extraordinary large acceleration at jump point, which may be a problem when you build animations from the calculated acceleration.

Something I put together a few years back.