#copyright (c) Aaron Titus, 2004 #licensed under the gpl license #http://linus.highpoint.edu/~atitus/mandi/vpython from visual import * print "Simulation of a Ferris Wheel" print "----------------------------" print "" print "The yellow vector is the force of the chair on you. The blue vector is the gravitational force of the Earth on you. The green vector is the net force on you." print "" print "Change the period, T, to 5 seconds and you'll notice that you need a seatbelt at the top of the Ferris Wheel" print "" print "Change T to 10 seconds and you don't need a seatbelt at the top." dtheta = 45./180.*pi #increment angle to draw ferris wheel bars r=10. #radius of Ferris wheel theta0=0. #starting angle rodRadius=dtheta/10. #radius of wheel spokes rodColor=color.yellow #color of wheel spokes chairColor=color.magenta #color of chairs fnetColor=color.green #color of net force vector fChairColor=color.yellow #color of chair force (on you) vector fGravColor=color.blue #color of grav force vector chairW=r/10. #chair width fScale=1./2.0e2 #scales force vector vecShaftWidth=0.5 #shaftwidth for vectors m=90. #mass of person scene.autoscale=0 scene.range=1.2*r phi=0. #angle of rotation T=5. # period of rotation omega=2.*pi/T #initial angular speed alpha=0. #angular acceleration #lists rods=[] chairs=[] fnetVectors=[] fChairVectors=[] fGravVectors=[] #create objects for theta in arange(theta0, 2.*pi, dtheta): chairPos=vector(r*cos(theta),r*sin(theta),0) chairs.append(box(length=chairW, width=chairW, height=chairW, pos=chairPos, color=chairColor)) rods.append(cylinder(radius=rodRadius, pos=vector(0,0,0), axis=chairPos, color=rodColor)) fnetVectors.append(arrow(pos=chairPos,axis=vector(0,0,0),color=fnetColor,shaftwidth=vecShaftWidth)); fChairVectors.append(arrow(pos=chairPos,axis=vector(0,0,0),color=fChairColor,shaftwidth=vecShaftWidth)) fGravVectors.append(arrow(pos=chairPos,axis=vector(0,0,0),color=fGravColor,shaftwidth=vecShaftWidth)) #time interval #dt=T/1000. dt=T/100. while 1: rate(10) omega=omega+alpha*dt dphi=omega*dt s=omega*r for i in range(len(rods)): rod=rods[i] rod.axis=rotate(rod.axis,angle=dphi) chair=chairs[i] chair.pos=rotate(chair.pos,angle=dphi) if i==0: rVec=chair.pos rUnit=rVec/mag(rVec) fnet=m*s**2/r*(-rUnit) fnetVectors[i].axis=fnet*fScale fnetVectors[i].pos=rVec fGrav=m*vector(0,-10,0) fGravVectors[i].axis=fGrav*fScale fGravVectors[i].pos=rVec fChair=fnet-fGrav fChairVectors[i].axis=fChair*fScale fChairVectors[i].pos=rVec