daily pastebin goal
41%
SHARE
TWEET

CSH2012 FINAL ballistics01.py

calcpage Jun 21st, 2013 83 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/usr/bin/python
  2. #ballistics01.py    MrG     2013.0531
  3. #inspired by http://vpython.erikthompson.com
  4. #vertical displacement without air resitance a la Galileo
  5. #position is a vector!
  6. from visual import *
  7.  
  8. scene.width=800
  9. scene.height=600
  10. scene.autoscale=0
  11. scene.range=(100,100,100) #(l,w,h)
  12. scene.center=(0,40,0) #pos vector
  13.  
  14. ball=sphere(pos=(0,102,0),radius=2,color=color.red)
  15. ground=box(pos=(0,-1,0),size=(10,2,10),color=color.orange)
  16.  
  17. g=9.8 #m/s/s
  18. t=0
  19. dt=0.01
  20.  
  21. finished=False
  22. while not finished:
  23.     rate(100) #loop 100 times per sec
  24.     t+=dt
  25.     y=-0.5*g*t**2+0*t+100 #y(t)=-g*t^2/2+v0*t+y0
  26.     print "t= " + str(t) + " y= " + str(y)
  27.     ball.pos=(0,y,0)
  28.     if y-2<0:
  29.         finished=True
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top