Skip to content

Instantly share code, notes, and snippets.

@restrepo
Forked from llimllib/gist:1120117
Created February 23, 2012 22:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save restrepo/1895375 to your computer and use it in GitHub Desktop.
Save restrepo/1895375 to your computer and use it in GitHub Desktop.
From arXiv:1107.5216
#!/usr/bin/env python
#From arXiv:1107.5216
from __future__ import division
from visual import *
craft = sphere(pos = vector(10e7,0,0), color = color.white, radius = 1e6)
Earth = sphere(pos = vector(0,0,0), color = color.blue, radius = 6.3e6)
trail = curve(color = craft.color)
G = 6.67e-11
mcraft = 1500
mEarth = 5.97e24
vcraft = vector(0,2400,0)
pcraft = mcraft*vcraft
t = 0
deltat = 60
tf = 365*24*60*60
while t < tf:
r = craft.pos-Earth.pos
rhat = r/mag(r)
Fgrav = -G*mEarth*mcraft/mag(r)**2*rhat
pcraft = pcraft+Fgrav*deltat
craft.pos = craft.pos + pcraft/mcraft*deltat
trail.append(pos = craft.pos)
t = t + deltat
print 'Craft final position: ', craft.pos, 'meters.'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment