home *** CD-ROM | disk | FTP | other *** search
/ Garbo / Garbo.cdr / pc / demo / ode.zoo / orbit.ode < prev    next >
Text File  |  1990-01-04  |  378b  |  22 lines

  1. # ORBIT.ODE
  2. # A planetary orbit around a fixed star.   It should be an ellipse.
  3. # Use 4th order Runge-Kutta, fixed step size, 200 steps, solve to t=50.
  4. $m -4
  5. $n 200
  6. $t 50
  7.  
  8. # Planet is at (x,y)
  9. x  = 1
  10. y  = 0
  11.  
  12. # Initial velocity
  13. vx = 0
  14. vy = 1
  15.  
  16. # Dynamics given by Newton's second law:
  17. r3  = cub(sqrt(sqr(x)+sqr(y)))
  18. x'  = vx
  19. y'  = vy
  20. vx' = -x/r3
  21. vy' = -y/r3
  22.