Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Simulation of Kepler orbits

  1. Jan 3, 2016 #1

    I'm writing a simulation of (an approximation of) the solar system. So far I've been able to translate the Wikipedia article on Kepler's laws to a function that uses a description of an elliptical orbit (eccentricity, periapsis, known position in time) to return a position when passed an arbitrary time. My issue is with generating the ellipse when given only a position and a velocity; my analytical geometry-fu is too weak for conics. I can't find much info on this, beyond references to offloading the calculation to software suites (e.g. HORIZONS and SPICE), which is of no use to me.
    Can anyone give me a nudge in the right direction?

  2. jcsd
  3. Jan 3, 2016 #2
    I think you could have a problem in that 'many body' systems can be really hard to get right.
    Especially when many of the bodies making up the whole system are either not well known, or not known at all.
    You could probably use Keplers laws to give a reasonable prediction for the solar system using just the Sun and major planets for maybe a few thousands of years.
    I think that beyond that extent it could not be reliable due to chaos caused by the minor planets (and other things that are not included in the 'perfect' model)
  4. Jan 3, 2016 #3
    Thanks for replying.
    Sorry, I forgot to mention that this is just an approximation for a game; I'm not trying to predict the real future locations of objects. Heavy objects will be put on Kepler rails, and only negligible mass objects will use n-body dynamics. I need to be able to find an ellipse from position and velocity because I want to be able to detect stable orbits of negligible mass satellites to avoid computing the n-body dynamics when not necessary.
  5. Jan 4, 2016 #4


    User Avatar
    Staff Emeritus
    Science Advisor
    Gold Member

    If you are starting with position and velocity you can work out the orbit in the following way:

    From the formula
    [tex]v^2 = GM\left ( \frac{2}{r}- \frac{1}{a} \right )[/tex]
    (where r is the length of the radial line and v is the magnitude of the velocity. )

    you can solve for a, the semi-major axis. From which, you can get the period of the orbit.

    Then from:
    [tex]\pi a^2 \frac{\sqrt{1-e^2}}{P} = \frac{rv \cos \theta }{2}[/tex]

    Where theta is the angle between a line perpendicular to the radial line and the velocity vector ( i.e., for a perfectly circular orbit theta would always be 0), and P is the period of the orbit found above, you can solve for e, the eccentricity of the orbit.(each side of the equation gives the Areal velocity)

    Then you can use [tex]r= \frac{a(1-e^2)}{1+ e \cos \phi}[/tex]

    to solve for phi, which gives you the angular distance from the present position to periapis.

    This should give you the shape of and the orientation for the line of apsides for your orbit.
  6. Jan 4, 2016 #5
    Thanks. That's what I was looking for.
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Similar Discussions: Simulation of Kepler orbits
  1. Orbit Simulator (Replies: 17)

  2. Orbital simulation (Replies: 11)

  3. Kepler orbits (Replies: 4)

  4. Kepler Orbit (Replies: 1)