from __future__ import division from visual import * scene.background = color.white scene.height = scene.width = 600 scene.x = scene.y = 0 ## print ''' Set "position" to drop clay with different impact parameters 0=full radius on left, 1=left, 2=top, 3=right, 4=full radius on right This is mostly a visualization ''' # clay position 0=full radius on left, 1=left, 2=top, 3=right, 4=full radius on right position = 0 if position > 4: position = 4 # wheel m = 0.2 w = frame() bb = [] R = 10 I = 8*m*R**2 for theta in arange(0,2*pi,pi/4): b = sphere(pos=(-R*cos(theta), R*sin(theta),0), radius=1.5, color=color.red, frame = w) bb.append(b) for b in bb[:4]: cylinder(pos=(b.pos), axis = (bb[bb.index(b)+4].pos - b.pos), color=(.7,.7,.7), radius = 0.3, frame=w) axle = cylinder(pos=(0,0,-R/4), axis = (0,0,R/2), radius=1, color=(.7,.7,.7), frame=w) clay = sphere(pos=(bb[position].x,20,0), radius=.5, color=(.7,.5,0)) clay.p = vector(0,-10,0) clay.m = 0.1 psc = 0.5 clay.pa = arrow(pos=clay.pos, axis=clay.p*psc, color=color.green, visible = 0) r = (clay.pos - w.pos) clay.L = cross(r, clay.p) scene.range = 22 scene.mouse.getclick() clay.pa.visible = True # drop clay dt = 0.01 while clay.y > bb[position].y+2+clay.radius: rate(20) clay.pos = clay.pos + (clay.p/clay.m)*dt clay.pa.pos = clay.pos clay.frame = w clay.pa.visible = False # all L transferred to wheel # neglect m of clay omega = mag(clay.L)/I dtheta = omega*dt if position > 2: dtheta = -dtheta theta = 0 while 1: rate(50) w.rotate(angle = dtheta, axis = (0,0,1)) theta += dtheta