2D Orbit Simulation

2D Orbital Simulation

Click Here to Try It

Using Newton’s Universal Law of Gravitation: F = G * ( M * m ) / d^2

  • F – Force of Attraction
  • G – Gravitational Constant
  • M – Mass of Earth
  • m – Mass of Satellite
  • d – Distance between satellite and geocenter of Earth
I have put together a simple CANVAS simulation which attempts to provide a user with the ability to model how a satellite may orbit a planet:
  • The user can click anywhere on the canvas and a satellite will begin to move using the initial velocities and mass set on the Satellite parameters control.
  • For each cycle the force of gravity will be calculated and applied to the satellite.
  • Adjusting the Earth Mass slider will change the Mass of the Earth as you slide the control.
  • The colors of the tail are determined by comparing the speed at a point against your initial speed. ¬†Faster points are colored red, slower points are colored blue, and points close to the initial speed are colored yellow.
The software as it is now has several notable limitations:
  • Only tested in Firefox and Chrome
  • Performing calculations in only 2 Dimensions
  • Force is only being calculated between each satellite and the center of the Earth
  • No collision detection has been implemented between the satellites
  • Not accounting for many other forces which may impact a satellite orbiting a planet
Possible future endeavors may include:
  • Adjust the coloring of the satellite tails to be a gradient based on the absolute speeds
  • Remove the ends of tails after they have reached a certain length
  • Use real units of measurement for the display
  • Provide a zoom/scaling feature – Implementing something which converts those units to pixels
  • Provide a reference for distance – like a radial grid
Any comments or feedback is certainly welcome!

2 thoughts on “2D Orbit Simulation”

  1. Nice demo. Been thinking of doing something like this in my spare time too, but.. haven’t had any spare time! The one thing I’d love to see is taking the forces to n-body rather than just against the Earth. I was getting confused at first when my satellites weren’t interacting and this behavior can cause the most interesting outcomes.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>