Advertisement
Guest User

Untitled

a guest
Jul 21st, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. from math import *
  2. from vpython import *
  3.  
  4. def create2Drandomwalk(step,nsteps):
  5. ball = sphere(pos=vec(0,0,0), radius = 2, color = color.yellow, make_trail = True)
  6. sleep(0.5)
  7. t = 0
  8. dt = 0.05
  9. count = 0
  10. while count < nsteps:
  11. rate(1000)
  12. theta = random()
  13. theta = theta*2*pi
  14. x = step * cos(theta)
  15. y = step * sin(theta)
  16. ball.pos.x = ball.pos.x + x
  17. ball.pos.y = ball.pos.y + y
  18. count += 1
  19.  
  20. create2Drandomwalk(5,100000)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement