I am looking at various integration methods for my n-body simulation and I'm slightly confused about actual implementation of leapfrog integration.
According to the wikipedia page leapfrog method is defined like this:
When I imagine how to code it, i come up with something like this:
while true:
dt = time since last frame
for every object:
object.position += object.velocity * dt
for every object:
acceleration = object.calculate_acceleration()
object.velocity += acceleration * dt
render()
But this is Euler integration, right?
So moving the initial velocity back by one half step makes a first order method into a second order method? But for me a small change of initial velocity is not important, it will be set as a random value anyway...
Why I won't just use velocity verlet: This is for a game where tens of thousands particles fly around affected by forces roughly resembling gravity. I'd like to keep amount of data stored in every partile as low as possible to improve cache locality, which is why I don't want to use a method that requires storing acceleration (and recalculating it would be too slow).