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.
you can use
FCurve.evaluate function to get the position of one object:
action = bpy.data.actions
curve = action.fcurves
# 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
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.