   How to determine what body another body is orbiting IE the Moon
  I'm writing an orbit simulator, and am having a bit of a problem -- I'm trying to draw orbits for bodies relative to the body that they are orbiting. I was originally going to determine that body by which body puts the greatest force onto it, but that won't work with an object like the Moon, as technically the Moon orbits the Sun (it pulls with twice the force of the Earth).I thought about using the system barycenter relative to the object, but that would make orbits look very strange indeed.Any suggestions?   
  I was almost certain that the Moon orbited the Earth and that the Earth orbited the sun. I'm also pretty sure than gravity decreases with the square of the distance between the bodies...Anyway I'm not really sure what you're after..You may find this this lecture, interesting.   ;  Yes, I'm aware of universal gravitation -- the Sun still imparts twice the force than the Earth does onto the Moon.I'm trying to determine relative to what position I should draw orbits for my orbiting bodies -- especially in the case of the Moon - it would look better if it's orbit is drawn relative to the Earth and not the Sun, but I see no way of 'dynamically' knowing that it's in the Earth's system, and I don't want to hardcode it.TECHNICALLY, the Earth and the Moon orbit the Sun, and their mutual gravity merely holds them together. In other cases, several moons of Jupiter are indeed being pulled more by Jupiter than the Sun, so they are easier.   ;  Let me rephrase my problem ---It's an orbit simulator. I want to trace orbits -- but I want it to look nice -- I was going to make traced orbits relative to the objects they are orbiting, so you'd see circles around Jupiter instead of corkscrews around the Sun. As is, I don't know a way of mathematically determining what object an object orbits .. my example is the Moon -- the Sun imparts more than twice the gravitational pull upon it than the Earth does, so technically with that sort of system it orbits the Sun. What can I do to correct this? Rendering relative to the barycenter might cause very odd effects, indeed.   ;  I think it is not clearly possible to determine this.Think of two planets with one moon that will orbit these two inan 8-curve. Which one is it orbiting then?However you could ceep track of the objects position for a whileand with that determine another object that aplies the force on itthat makes it orbit around.If you know the period of the orbiting object you could let it makea full turn and look which object is "within the circle".   ;  Hello Ameise,as far as I understand you description, you use some sort of numerics based on gravitational forces to compute a body's position. If this is the case, then how can you know the path on which a body is moving beforehand anyway? It seems to me that your problem is in fact deeply rooted in the nature of reality ;). Forseable orbital paths which can be visualized as circles or ellipses are an abstract, artifical concept. The moon never "knows" where it will be in the next second, because this depends on factors which might change at any time (although sudden extreme changes are admittedly improbable). And for the very same reason, your simulation can't know it, too.   ;Quote:Original post by SpynackerI think it is not clearly possible to determine this.Think of two planets with one moon that will orbit these two inan 8-curve. Which one is it orbiting then?However you could ceep track of the objects position for a whileand with that determine another object that aplies the force on itthat makes it orbit around.If you know the period of the orbiting object you could let it makea full turn and look which object is "within the circle".Danke für die Antwort - du könntest mit mir auf Deutsch sprechen, wenn das wird für dich besser seien.I have a feeling that that would be difficult to implement programatically, especially in my system... object tracking would kill it speed-wise.Wurstbrot:No, it's a simulation -- I'm marking where it's been -- I wanted to draw orbits locally to their parent bodies by making the markings relative to their positions, but I need to determine the parent body.   ;  You could always just have objects leave a "trail" behind them.  This will be nearly the effect you want: By the end of one orbital period, so long as your trail doesn't fade away too slowly, you'll get the appearance, roughly, of an ellipse.Another way to look at it: The whole notion of "one body orbiting another" comes from the idea that all but one force on a given body is negligible.  So a quick hack that comes to mind is to classify any body 'A' as orbiting body 'B' if-and-only-if the magnitude of the force exerted on 'A' by 'B' is greater than or equal to some large constant 'K' times the next highest force exerted on 'A.'  Then, neglecting all other bodies, you can assume that 'A' orbits the center of mass of 'A' and 'B,' and compute the ellipse in closed form.  You'll notice that with this method some bodies may be classified as not orbiting any one other body, and have no ellipse drawn.Another thought is to just draw isocontours of the overall gravitational potential field (leaving out one body at a time)... if you're in 2d this could be a nice effect.  You'd probably either want to do it with piecewise linear continuation, or on the graphics card with stencil/z-buffer/shader tricks.[Edited by - Emergent on May 15, 2010 5:14:02 PM];Quote:Original post by EmergentYou could always just have objects leave a "trail" behind them.  This will be nearly the effect you want: By the end of one orbital period, so long as your trail doesn't fade away too slowly, you'll get the appearance, roughly, of an ellipse.Another way to look at it: The whole notion of "one body orbiting another" comes from the idea that all but one force on a given body is negligible.  So a quick hack that comes to mind is to classify any body 'A' as orbiting body 'B' if-and-only-if the magnitude of the force exerted on 'A' by 'B' is greater than or equal to some large constant 'K' times the next highest force exerted on 'A.'  Then, neglecting all other bodies, you can assume that 'A' orbits the center of mass of 'A' and 'B,' and compute the ellipse in closed form.  You'll notice that with this method some bodies may be classified as not orbiting any one other body, and have no ellipse drawn.Another thought is to just isocontours of the overall gravitational potential field (leaving out one body at a time)... if you're in 2d this could be a nice effect.  You'd probably want to do it with piecewise linear continuation.I want to do that, but it doesn't work with the Moon -- the the Sun puts twice the force of the Earth, but they are still both signifigant to it. I don't want a weird corkscrew around the Sun :DThe system you proposed won't work with systems with multiple suns, like Binary stars... I can imagine situations where there could be hundreds of 'signifigant' objects -- this isn't JUST a simulation of our solar system, that's just the best example.   ;Here some formulae. I suck at math so you're on your own here. :)   