1. Limited time only! Sign up for a free 30min personal tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Orbital simulation - Calculate object position over time in a 2d plane

  1. Apr 9, 2014 #1

    Im busy creating an application to simulation a rocket in orbit. Im having trouble as the results im getting are incorrect. Could someone please check if im using the correct method as stated below.

    Everything works on a 2d plane, and has a x and y coordinate and a x and y velocity and a mass
    coordinates are in meters and the mass is in kg.

    Calculate the distance between the rocket and the planet using the distance formula
    distance = sqrt[ ( x2 - x1)^2 - (y2 - y1)^2 ]

    calculate the force earth exerts on the rocket using the The Universal Law of Gravitation where G is the Gravitational constant m is the mass of an object and r is the distance between them
    force = (G*m1*m2) / distance^2

    Using the inverse of tan get the angle to calculate the the x and y components ( I know for a fact im getting this is correct, its a bit tricky to explain) I calculate the angle for each quadrant going from the x axis to the y axis

    Calculate the acceleration of the rocket
    acceleration = force / mass

    Calculate velocity change over timer ( this is usually 0.01 seconds )
    deltaVelocity = acceleration * time

    Calculate the x velocity component
    deltaXvelocity = deltaVelocity * cos(angle)

    Calculate the y velocity component
    deltaYvelocity = deltaVelocity * sin(angle)

    Calculate the new x velocity
    newXvelocity = currentXvelocity + deltaXvelocity

    Calculate the new y velocity
    newYvelocity = currentYvelocity + deltaYvelocity

    set the new position of the rocket
    newXposition = currentXposition + ( newXvelocity * time )
    newYposition = currentYposition + ( newYvelocity * time )

    Something is wrong with this method and i do know what.
    I know for a fact that a an object in orbit round about 420km travelling at round about 7700 m/s should be in a roughly circular orbit and one that has a high eccentricity.

    Currently with the results im getting to obtain a roughly circular orbit at 420km i need to have a velocity of round about 5500m/s

    Thanks for taking the time
  2. jcsd
  3. Apr 9, 2014 #2


    User Avatar
    Science Advisor

    It sounds like you are using the Euler method, which is numerically unstable.
    You should try Verlet integration https://en.wikipedia.org/wiki/Verlet_integration
    or a Runge-Kutta method https://en.wikipedia.org/wiki/Runge–Kutta_method
    both of which have better stability properties.

    Or try https://en.wikipedia.org/wiki/Leapfrog_method which is almost as simple as the Euler method.

    This page has a decent description of why Euler method fails. https://en.wikipedia.org/wiki/Euler_integration
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook