# [ODE] Very Important: ODE and TIMESTEP. How to do it???

Bram Stolk bram at sara.nl
Sun Aug 6 07:40:53 MST 2006

```michael kapelko wrote:
> I read this and that articles, but I need smth concrete. Not
> blah-blah-blah about extrapolation and interpolation. This pseudo-code
> explains nothing. I need to extrapolate physics, not renderer, but ODE
> doesn't allow this. It does all calculations itself.
> Any better idea?
> Thanks.
> _____________________________________________

Extrapolation of an ODE state would involve:

- Getting orientation and position of all the bodies
using these functions:

dBodyGetQuaternion()
dBodyGetPosition()

- Linear extrapolation of positions should be easy:
result vector is linear combination of two vectors with
weights w0 and w1.
You could probably set with w1>1, w0<0, w0+w1==1
Smoother extrapolation maybe be achieved with Hermite splines e.g.

- The tricky part is extrapolating quaternions.
I cannot find 'slerp' functionality in ODE's math api.
You need to implement ODE's variant of this:
http://en.wikipedia.org/wiki/SLERP

- Alternatively:
You could interpolate the axes of the coordsystems, and normalize
the results. You effectively build a new coordsys based on 2 vectors.
e.g.

Use dBodyGetRotation() twice to get the x0,y0,z0 and x1,y1,z1 axes.
interpolate x0 and x1 to x
normalize x
interpolate y0 and y1 to y
normalize y
z = cross(x,y)
y = cross(z,x)
NOTE: This is ugly, and will fail if delta's are large, e.g: 90
deg deltas for axes.
NOTE: You could improve this by selecting the best 2 axes to
interpolate, and create the 3rd axis with crossproduct.
Here, the 3rd axis is set fixed to z.

But I agree with the fellow-posters in this thread:
what is the exact purpose of the extrapolation?
You say it is not for syncing with graphics, as explained in
"Finishing Touch" section of http://www.gaffer.org/articles/Timestep.html
Is it for networked sim?
It would help if we knew what problem you are trying to solve.

__
> ODE mailing list
> ODE at q12.org
> http://q12.org/mailman/listinfo/ode

```