1
\$\begingroup\$

I'm attempting to have a planet (with a known mass and radius) orbit it's sun (also with a known mass and radius). It doesn't have to be 100% realistic, but it should be possible that the sun have more than one planet orbit it at a time.

What equations should I use to accomplish this?

\$\endgroup\$
2
  • \$\begingroup\$ Indeed, use a simulation of Newtons law of universal gravitation as suggested in the answers to the duplicate-question. \$\endgroup\$
    – Philipp
    Feb 7 '14 at 15:22
  • 2
    \$\begingroup\$ I believe the duplicate was calculating the gravity at a given point around a spherical body. Calculating the speed and distance from a body to have a stable orbit is different. See here to get you started: en.wikipedia.org/wiki/Orbital_speed \$\endgroup\$
    – House
    Feb 7 '14 at 16:01
1
\$\begingroup\$

If the players will never know the difference, then don't worry about mass or radius. For the oribiting planet store - the distance to the center planet (radius of rotation) - current position in degrees - orbit-speed (degrees per game tick)

For each game tick - change the position by adding the speed - calculate the new position (using Cos and Sin)

Would this simplified method work?

\$\endgroup\$
1
  • \$\begingroup\$ This is what I ended up going with, although it's not really the answer to the question. \$\endgroup\$
    – terrorcell
    Feb 8 '14 at 5:28
1
\$\begingroup\$

If players have no effect over the orbit (such as moving planets) then the best option would simply be to define paths for the planet to travel along (using bezier curves etc). It's stable and simple. You would never be able to affect the movement in game (unless you went to the trouble of altering the defined path) and may open up unrealistic possibilities (like crazy orbits).

Just remember to keep in mind Kepler's law of planetary motion, especially the second one as this will affect how you move the planet along the path.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .