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.
 A: 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.
The mathematical expression for effective potential is usually derived within the context of the larger topic of central force motion.  If the wikipedia page on effective potential doesn't provide enough explanation for you to be able to figure out how to plug in real numbers and correctly perform a practical calculation, then I'd recommend that you step back and try to understand it within the context of the larger problem of central force motion.  Your choices for doing this include an online open course, or alternatively, many of the more commonly used classical mechanics text books will usually have a chapter about it; "Classical Dynamics of Particles and Systems" by Stephen T. Thornton and Jerry B. Marion, for example, has a pretty good discussion.  Or just google "Central Force Motion" and see what else comes up.
BTW, the truly "full physics"and most generic version of the space simulation program that you're working on is customarily described as the gravitational N-body problem, and a lot of people in the astronomy and space community have already developed their own solutions.  Some have even written textbooks about how they did it; e.g., "Gravitational N-body Simulations, Tools and Algorithms", by Sverre J. Aarseth.  Since the full physics problem you're attempting to solve is inherently complicated and difficult, you may wish to consider acquiring one of them.
