# Determine if an object is in orbit

I am planning on doing a space simulation program with full physics and as part of a hack to avoid too many issues with number precision I was going to switch orbiting objects to a calculated orbit (rather than rely on accurate gravity effects to keep it in perfect orbit). For this, I need to know if an object is in orbit at the moment and if it is, switch it across to using the formula in place of the less accurate application of gravity every frame.

How would I go about determining if an object is in orbit assuming I know its velocity, distance from centre of planet and the planet's mass.

Obviously I'm not looking for someone to do my work for me, but I have been unable to find any reading material online.

-
Not enough for an answer obviously, but you can search for things like "orbital capture" and use some results there to get ideas. But it's not as simple as a binary "in orbit," "not in orbit" situation. – tpg2114 Nov 6 '13 at 4:46
For a two body problem this is trivial (negative total energy when measuring potential as zero at infinite remove), but as soon as there are perturbations in the system it gets to be a lot less trivial. You would need to define what you mean by "in orbit" well enough to build a mathematical condition around it. – dmckee Nov 6 '13 at 4:46
To clarify -- from a physics standpoint it's a bit clearer (when an object is captured vs not captured) but from a simulation standpoint it's actually harder. You might miss the capture event if you apply the wrong formulas, or you might end up spending so much effort checking that it would be cheaper to just use the full equation to begin with. But those details are off-topic – tpg2114 Nov 6 '13 at 4:47
@gregsan That prescription is equivalent to the energy condition I suggested above and it can fail when there are more than two bodies in the system; worse the whole project is only interesting if there are more than two bodies in the system, – dmckee Nov 6 '13 at 5:49
@MrUniverse, If you want to plot a perfect trajectory of an object under influence of multiple massive bodies, you'll have to solve the kinematical equations using newtonian gravity, which is possible(I think) but tough and no general solution usually exists. So you will have to compute the trajectory for every case separately. – udiboy1209 Nov 7 '13 at 17:08

I believe the concept you're probably looking for is the gravitational effective potential. For cases where the mass of one of a pair of orbiting bodies is much larger than the other (i.e., M >> m) or where the problem has been reduced to an "equivalent one-body problem" through the use of the reduced mass, the smaller mass (or the only mass, in the equivalent one-body problem) will become "trapped" in a fixed orbit if its total energy $E$ satisfies the criterion $E < 0$. (The wikipedia page actually claims here that the condition for a trapped orbit is $U_{eff} < E$ but this appears to differ from what I've seen printed in classical mechanics textbooks, so check your sources carefully!). At any rate, the utility of the effective potential from your perspective is that whenever the conditions for a gravitationally bound orbit are met, it gives you a simple mechanism for calculating the aspides of the orbit. Once you have the apsides (i.e., the detailed shape and eccentricity of the elliptical orbit) you should be able to use concepts such as Kepler's Laws to help you work out the specific time evolution of each individual orbit.