I'm working on a game, that is set in space. The game is about orbits and my problem is the following:

I want to be able to draw a predicted orbit for my satellite. Currently, my satellite orbits the host planet. What I have available from the physics simulator is the satellite's velocity, its position and the pulling force from the planet.

As I have researched, I understand that I should be able to calculate the ellipse of the orbit and a starting point could be to first calculate the semi major axis of the ellipse using the total energy equation (taken from Calculating specific orbital energy, semi-major axis, and orbital period of an orbiting body):

\begin{align} E &= \frac{1}{2}v^2 - \frac{\mu}{r}= -\frac{\mu}{2a}, \end{align}

Which can be rewritten to \begin{align} a &= - \frac{\mu r}{r v^2 - 2 \mu } \end{align}

Where $a$ is the semi major axis, $\mu = G(M+m)$, $v$ is the velocity and $M$, $m$ are the bigger and smaller masses, respectively. Using a simulation with two bodies, a planet (with mass 9999999999) and a satellite (with mass 1) placed 10 units from the planet, and a circular orbit, I expect the semi major axis to be 10 but what I get is a negative number.

P.S I want the planet to be the primary.

Any hints of what might be wrong?

  • $\begingroup$ I see mass and length are defined without a unit of measure. No problem with that, but how did you define G then? If you used the SI value $6.67 \times 10^{-11}$ N m$^2$/kg$^2$, then this is the wrong constant for your simulation, since every other parameter isn't measured in SI units. $\endgroup$
    – GRB
    Nov 28, 2016 at 22:56
  • $\begingroup$ Sorry, forgot to mention that. My system is currently "unitless", so everything is just measured in ... units. The underlying physics system let you choose any unit you want. So my units can be considered SI units. My G constant is defined as 6.67×10−11. $\endgroup$
    – mrmclovin
    Nov 29, 2016 at 9:06
  • $\begingroup$ If I consider everything to be SI, then my G value should be correct? @GRB .. I will review my units again to see if I have made a mistake regarding the units.. $\endgroup$
    – mrmclovin
    Nov 29, 2016 at 12:03
  • $\begingroup$ Exactly, otherwise depending on the ratio between your units and SI units your simulated gravity can be stronger or weaker than in our universe and orbits can change dramatically. $\endgroup$
    – GRB
    Nov 29, 2016 at 12:37

1 Answer 1


From your answers it seems the problem is the choice of units of measure. There isn't a clearly defined conversion between your units and SI units, so gravity can't be simulated properly. Everything seems to revolve around the value of G, that sets the strength of gravity in your simulation.

As an example, I'll set 1 unit of mass as $10^5$ kg, 1 unit of length as $10^5$ m and 1 unit of time as 1 s, but you can choose any conversion you desire and apply the following procedure. In this example the satellite has a mass of 100 metric tons and a distance of 1000 km from the center of the planet, while the planet has a mass of about $10^{15}$ kg, so it's quite a small body, about the same mass as Deimos, the smallest moon of Mars.

Once you have the conversions, you need to reverse them. In my example, 1 kg is equivalent to $\frac{1}{10^5} = 10^{-5}$ units of mass, while 1 m corresponds to $10^{-5}$ units of length. Now, since G has a unit of N m$^2$/kg$^2$ = m$^3$ kg$^{-1}$ s$^{-2}$, we can replace these units with the conversion factors found above and find that in these custom units G must be multiplied by $10^{-10}$ to scale gravity properly. This means that G = $6.67 \times 10^{-21}$.

With this particular conversion, it results that the gravity of your simulation was ten order of magnitudes stronger than the gravity of our universe.

  • $\begingroup$ You were right. I had my masses converted erroneously, at a place in the code which I had forgot existed. $\endgroup$
    – mrmclovin
    Nov 29, 2016 at 18:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.