Guest User

Untitled

a guest
Apr 26th, 2018
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. from visual import *
  2. scene = display(x=0, y=0, height=400, range=10)
  3. scene.up = vector(0,0,1)
  4. scene.forward = vector(0,-1,0)
  5.  
  6. ball = sphere(radius=1.0, color=color.cyan)
  7. ball.pos = (0.0,0.0,1.0)
  8. ball.velocity = vector(0, 0, 1.0)
  9. ball.accel = vector(0, 0, -9.8)
  10.  
  11. dt = 0.01
  12. t = 0.0
  13. e = 1.0
  14. b = 0.01
  15. m = 1.0
  16.  
  17. while t < 10:
  18. rate(200)
  19. ball.pos = ball.pos + ball.velocity * dt
  20. ball.accel = vector(0, 0, -9.8)-(b/m)*ball.velocity.mag*ball.velocity
  21. ball.velocity = ball.velocity + ball.accel * dt
  22.  
  23. if ball.pos.z < 0:
  24. ball.velocity = -e* ball.velocity
  25. print('抵抗なしX= -0.039939999999999455,抵抗ありX=',ball.pos.z)
  26.  
  27. t = t + dt
Add Comment
Please, Sign In to add comment