# Tracing a 2d path through multiple gravity fields

For a projectile starting at origin O, an initial velocity V, and several stationary planets P[n], how would I pre-calculate and store the path it would take without actually stepping through each frame along the curve?

I have some idea of how to do this for a single gravity source (conic section, parametric curves), but how do you blend multiple forces, and thus multiple curves, together?

The idea is to give the player some idea of the trajectory their shot will take, so it doesn't need to reflect the actual path exactly, but the closer the better.

• If you are really dead-set against running the simulation frame-by-frame (even offline), you may want to ask this over on the physics site instead. (If you do, please delete this question or let me know so I can delete it.) – Josh Dec 13 '13 at 18:00
• A continuous physics equation isn't likely to match very well with the actual discrete frame-by-frame simulation. You're likely much better off faking it by simulating the discrete simulation in advance. – MichaelHouse Dec 13 '13 at 18:03
• Do any of the other bodies move? If so, welcome to the n body problem. – DampeS8N Dec 13 '13 at 18:35
• They're fixed in place. I'll add some more background to the question. – jzx Dec 13 '13 at 20:15

You step through the simulation quickly, in a for loop or a while loop depending on what the goal is. You're essentially simulating the frames in the loop with predetermined time steps, ideally with the same value as your fixed time step. Depending on how you have your game set up, this could be as easy as using your existing functions.