- 
      
- 
        Save restrepo/1895375 to your computer and use it in GitHub Desktop. 
    From arXiv:1107.5216
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | #!/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