I am making a simulation of the solar system in the unity game engine.

A planet is orbiting a stationary star for now using Newton's law of gravitation where $F = Gm_1m_2/r^2$ for the orbit (force is applied after each frame).

I need to display the trajectory of the orbit before running the simulation, while adjusting initial starting conditions including velocity. Using the iterative method above makes it difficult to quickly calculate and display the orbit as increasing the time intervals the force is calculated over, decreases accuracy as error accumulates over time. I know that a deterministic method can be used to calculate the path of orbit as a function of time. I have been trying to derive an equation in terms of time for the x and y components of the position of the planet given its initial conditions. This is so that I can plot the orbit from a series of points calculated for different points in time.

I have been unable to find any solutions when reading about the Kepler problem.

The question is how would I be able to calculate the position of the planet orbiting a stationary star at a certain time, given the mass of both the star and the planet, and the initial position and velocity of the planet? Both bodies are point masses and the sun is the origin.

Thank you for any help and if anything mentioned is unclear then please ask.

  • $\begingroup$ Is this just a two body problem? $\endgroup$ Commented Dec 30, 2020 at 15:09
  • $\begingroup$ I believe it is however only one body will be in motion. $\endgroup$
    – Tom Benson
    Commented Dec 30, 2020 at 15:20

1 Answer 1


It seems to me your problem is the inverse of a case that is relatively simple.

I am going to assume that the initial velocity is in tangential direction. That means the initial position is either the aphelion or the perihelion. If that applies then that narrows things down a lot.

Given an initial distance between Sun and planet, and the eccentricity of the orbit, the total size and shape of the orbit follows mathematically, given that a Kepler orbit is an ellipse with the Sun at one focus.

With the size and shape known, the velocity at every point of the orbit follows mathematically.

As I wrote: your case is an inverse of that:

If it so happens that the initial velocity is just the velocity for circular orbit then circular orbit it is.

If the initial velocity is slower than the one for circular orbit then the initial position is the aphelion of the orbit.

If the initial velocity is faster than the one for circular orbit then the initial position is the perihelion of the orbit.

So I think your starting point should be that you find, maybe on wikipedia, a formula that gives the size and shape of an orbit, given the eccentricity. Then combine that with a calculation of corresponding velocity at aphelion/perihelion

You would then need to convert that formula such that it gives a value for the eccentricity of the orbit, with initial velocity as input.

With the value for the excentricity obtained it is possible to set up a formula that precomputes the orbit as a function of time.

  • $\begingroup$ I have found the equation to calculate eccentricity from velocity, position and standard gravitational parameter from some point in time, however I am unable to find a formula to find the shape of the orbit given eccentricity. Where would I be able to find this formula? $\endgroup$
    – Tom Benson
    Commented Dec 31, 2020 at 1:08
  • $\begingroup$ @TomBenson I'm guessing the wikipedia article about Kepler orbit is already your source. A formula for the shape given the eccentricity is among the first formulats listed. (With such a wealth of formula's I find it hard to see the trees for the forest, and I imagine your experience is similar.) $\endgroup$
    – Cleonis
    Commented Dec 31, 2020 at 7:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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