[ODE] Re: Dinamic gravity vector
Ruari O'Sullivan
ro1615 at bris.ac.uk
Sat Aug 21 09:54:21 MST 2004
One thing you might try is calculating the total energy - potential +
kinetic - of each body every frame, then applying slightly less gravity
to bodies that have 'lost' energy (eg, fallen inwards) and slightly more
to bodies that have 'gained' energy (fallen outwards).You aren't going
to get perfect orbits without horrible hacks or solving the n-body
problem, but this could be a start. ;) Beware that this is fundamentally
a spring system, so you're going to get nasty oscillations unless you
damp it down a bit somehow. It should really be very fast, with the
minor issue that things may slowly wobble a bit up and down from their
"proper" orbit positions and take fractionally shorter or longer to make
a full orbit than they should. I imagine you can sort this out to the
point where things are only allowed to slide out of position for a few
physics steps before they're restored, so a tiny fraction of a second.
Finally, note that anything with a thruster or suchlike is going to be
changing its own total energy, and quite validly... you'll need to
correct for this. One way might be to just hold off on this energy
compensation while something's under thrust, since it's not going to be
holding an orbit anyway (until it's done, at least).
For systems where moon A orbits planetary body B which is in orbit
around sun C... forget force simulation and just manually move each of
them around to where they should be around the body they're orbiting.
Then apply the energy fix above for bodies moving around where total
accuracy of the orbit isn't essential, eg. spaceships, asteroids, minor
satellites, debris.
Of course, if you *are* trying to physically simulate entire star
systems to great accuracy, instead of just providing a neat environment
in which to fly a spaceship around... good luck. :p
-randomnine-
>If that's no good you should be able to do a mangled version of
>Runge-Kutta integration, but it might be a bit of a waste of processor
>cycles. For each time step: Save the state of the simulation somehow,
>step it forward half a time step, work out the force of gravity using
>the Euler method, go back to the saved simulation state, apply the
>force you just calculated, do one full time step forward.
>
>
More information about the ODE
mailing list