Skip to content

Instantly share code, notes, and snippets.

@ahmedazizkhelifi
Created August 19, 2020 00:31
Show Gist options
  • Save ahmedazizkhelifi/49048e4a1161f4e12d581d1d10b97f54 to your computer and use it in GitHub Desktop.
Save ahmedazizkhelifi/49048e4a1161f4e12d581d1d10b97f54 to your computer and use it in GitHub Desktop.
while True:
vp.rate(500)
#calculte the force using gravitationalForce function
star.force = gravitationalForce(star,planet)
planet.force = gravitationalForce(planet,star)
#Update momentum, position and time
star.momentum = star.momentum + star.force*dt
planet.momentum = planet.momentum + planet.force*dt
star.pos = star.pos + star.momentum/star.mass*dt
planet.pos = planet.pos + planet.momentum/planet.mass*dt
t+= dt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment