Guest User

Untitled

a guest
May 20th, 2018
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. from visual import *
  2.  
  3. print """
  4. Right button drag to rotate "camera" to view scene.
  5. On a one-button mouse, right is Command + mouse.
  6. Middle button to drag up or down to zoom in or out.
  7. On a two-button mouse, middle is left + right.
  8. On a one-button mouse, middle is Option + mouse.
  9. """
  10.  
  11. side = 4.0
  12. thk = 0.3
  13. s2 = 2*side - thk
  14. s3 = 2*side + thk
  15. wallR = box (pos=( side, 0, 0), length=thk, height=s2, width=s3, color = color.red)
  16. wallL = box (pos=(-side, 0, 0), length=thk, height=s2, width=s3, color = color.red)
  17. wallB = box (pos=(0, -side, 0), length=s3, height=thk, width=s3, color = color.blue)
  18. wallT = box (pos=(0, side, 0), length=s3, height=thk, width=s3, color = color.blue)
  19. wallBK = box(pos=(0, 0, -side), length=s2, height=s2, width=thk, color = (0.7,0.7,0.7))
  20.  
  21. ball = sphere (color = color.green, radius = 0.4)
  22. ball.mass = 1.0
  23. ball.p = vector (-0.15, -0.23, +0.27)
  24.  
  25. side = side - thk*0.5 - ball.radius
  26.  
  27. dt = 0.5
  28. t=0.0
  29. while True:
  30. rate(100)
  31. t = t + dt
  32. ball.pos = ball.pos + (ball.p/ball.mass)*dt
  33. if not (side > ball.x > -side):
  34. ball.p.x = -ball.p.x
  35. if not (side > ball.y > -side):
  36. ball.p.y = -ball.p.y
  37. if not (side > ball.z > -side):
  38. ball.p.z = -ball.p.z
Add Comment
Please, Sign In to add comment