Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from math import *
- from vpython import *
- def create2Drandomwalk(step,nsteps):
- ball = sphere(pos=vec(0,0,0), radius = 2, color = color.yellow, make_trail = True)
- sleep(0.5)
- t = 0
- dt = 0.05
- count = 0
- while count < nsteps:
- rate(1000)
- theta = random()
- theta = theta*2*pi
- x = step * cos(theta)
- y = step * sin(theta)
- ball.pos.x = ball.pos.x + x
- ball.pos.y = ball.pos.y + y
- count += 1
- create2Drandomwalk(5,100000)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement