Advertisement
bwukki

Untitled

Feb 15th, 2018
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.09 KB | None | 0 0
  1. from visual import *
  2. scene=display(title="ball drop",x=0, y=0, width=800,
  3.               height=600,range=vector(10000,10000,10000),
  4.               center=vector(0,0,0))
  5. t = 0.0
  6. C = 0.8 #<- This is our drag coefficient
  7. dt = 0.1
  8. m = 70
  9. a = vector(0.0,0.0,0.0) # This is our acceleration
  10. A = 3.14159*0.4*0.4
  11. rho = 1.2
  12. s = vector(0.0, 5000.0, 0.0)
  13. v = vector(0.0,0.0,0.0)
  14. g = vector(0.0,9.8,0.0)
  15. ball = sphere(pos=s,radius = 200, color = color.blue)
  16. balllabel = label(pos=ball.pos,text = 'Vy=%1.2f' %v.y,
  17.                   xoffset=-100,yoffset=0)
  18. balllabel2 = label(pos=ball.pos,text='Distance Fallen = %1.2f' %s.y,
  19.                    xoffset=100,yoffset=0)
  20.  
  21. while t < 50:
  22.     rate(50)  # This slows down the computer to 50 frames per second
  23.     fnet = 0.5*C*rho*A*vector(0,mag2(v),0)-m*g # <-- Current force on skydiver
  24.     a = fnet/m # <-- current acceleration on skydiver
  25.     v = v + a*dt
  26.     s = s+v*dt
  27.     ball.pos=s
  28.     balllabel.pos=s
  29.     balllabel.text='v=%1.2f m/s' %v.y
  30.     balllabel2.text='Vertical Position=%1.1f m' %(s.y)
  31.     print 't=',t , '    s=',s, '  v=',v
  32.     t = t + dt
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement