Measuring the dynamics for a given state

Hi,

I wish to query the system's dynamics, e.g. to calculate derivatives of the dynamics via finite differences.

Given a world (with some bodies and joints) whose structure remains unchanged, I would like to set the system's "state" (positions + velocities for all bodies), make a single step forward, read the resulting state, and then set a new, possibly different state, again for one step only.

My concern is with internal state information the world is caching out of my sight. I am not going to remove or add bodies or joints, but it may well be that a contact is made in one state and then absent from the next.

Could you help me identify the relevant calls to deal with such a manipulation of the system? After calling SetXForm and Set*Velocity (for all bodies), is there anything I should do before calling world.Step ? Anything I should do after calling the various Get* functions, before I call the next Set* ?
Are there any implicit assumptions I will be breaking with such a use of the system?

Thanks,
-Tom
Box2D uses warm starting: it re-uses old forces (impulses) as initial guesses for the solver. If you want high accuracy, you'll have to use a lot of iterations. In this case the warm starting isn't necessary. You can use b2World::SetWarmStarting to turn off warm starting. In that case, there should be no internal state besides position/velocity that will affect your results.

Original thread: https://box2d.org/forum/viewtopic.php?t=867