from visual import * import math scene.forward = (5.5,-3.0,-10) scene.center= (30,0,0) scene.autoscale= None scene.background=(.5,.7,.8) scene.width = 1000 scene.height = 700 scene.autoscale = 0 scene.range = (100, -100.1, 10.1) #Frames fworld=frame() fwheel=frame() frod=frame(frame=fwheel, pos=(-5,0,0)) fshaft=frame(frame=fwheel,pos=(30,0,0)) fcrown=frame(frame=fshaft,pos=(2,0,0)) fpinion=frame(frame=fworld, pos=(49,4,0)) straight = [(0,0,0),(1,0,0)] wheeledge1= box(pos=(1,0,0), axis=(1,0,0), length=1, height=2, width=40, frame=fwheel, color=(.7,.5,.1)) wheeledge2= box(pos=(1,0,0), axis=(1,0,0), length=1, height=40, width=2, frame=fwheel, color=(.7,.5,.1)) OuterWheelEdge=outer InnerWheelEdge=inner outer = shapes.circle(pos=(0,0,0), radius=25,) inner = shapes.circle(pos=(0,0,0), radius=18,) extrusion(pos=straight, shape=outer-inner, color=(.7,.5,.1), frame=fwheel) outerr = shapes.circle(pos=(0,0,0), radius=25,) innerr = shapes.circle(pos=(0,0,0), radius=18,) extrusion(pos=[(-10,0,0),(-9,0,0)], shape=outerr-innerr, color=(.7,.5,.1), frame=fwheel) wheeledge1= box(pos=(-10,0,0), axis=(1,0,0), length=1, height=2, width=40, frame=fwheel, color=(.7,.5,.1)) wheeledge2= box(pos=(-10,0,0), axis=(1,0,0), length=1, height=40, width=2, frame=fwheel, color=(.7,.5,.1)) paddle=box(frame=fwheel, pos=(-4.5,21.5,0), up=(0,1,0), length=9, height=7, width=1, color=(.9,.7,.4)) paddle=box(frame=fwheel, pos=(-4.5,-21.5,0), up=(0,1,0), length=9, height=7, width=1, color=(.9,.7,.4)) paddle=box(frame=fwheel, pos=(-4.5,0,21.5), up=(0,0,1), length=9, height=7, width=1, color=(.9,.7,.4)) paddle=box(frame=fwheel, pos=(-4.5,0,-21.50), up=(0,0,1), length=9, height=7, width=1, color=(.9,.7,.4)) paddle=box(frame=fwheel, pos=(-4.5,21.5*math.cos(math.pi/4),21.5*math.sin(math.pi/4)), up=(0,1,1), length=9, height=7, width=1, color=(.9,.7,.4)) paddle=box(frame=fwheel, pos=(-4.5,-21.5*math.cos(math.pi/4),21.5*math.sin(math.pi/4)), up=(0,1,-1), length=9, height=7, width=1, color=(.9,.7,.4)) paddle=box(frame=fwheel, pos=(-4.5,-21.5*math.cos(math.pi/4),-21.5*math.sin(math.pi/4)), up=(0,1,1), length=9, height=7, width=1, color=(.9,.7,.4)) paddle=box(frame=fwheel, pos=(-4.5,21.5*math.cos(math.pi/4),-21.5*math.sin(math.pi/4)), up=(0,-1,1), length=9, height=7, width=1, color=(.9,.7,.4)) rod= cylinder(frame=fwheel,pos=(-11,0,0), axis=(52,0,0), radius=1.5, color=(.9,.7,.4)) crown= cylinder(frame=fwheel,pos=(40,0,0), axis=(2,0,0), radius=10) peg= cylinder(frame=fcrown,pos=(10,8,0),axis=(6,0,0),radius=.5, color=color.cyan) peg= cylinder(frame=fcrown,pos=(10,-8,0),axis=(6,0,0),radius=.5) peg=cylinder(frame=fcrown,pos=(10,8*cos(math.pi/4),8*cos(math.pi/4)),axis=(6,0,0),radius=.5) peg=cylinder(frame=fcrown,pos=(10,-8*cos(math.pi/4),8*cos(math.pi/4)),axis=(6,0,0),radius=.5) peg=cylinder(frame=fcrown,pos=(10,8*cos(math.pi/4),-8*cos(math.pi/4)),axis=(6,0,0),radius=.5) peg=cylinder(frame=fcrown,pos=(10,-8*cos(math.pi/4),-8*cos(math.pi/4)),axis=(6,0,0),radius=.5) peg=cylinder(frame=fcrown,pos=(10,0,-8),axis=(6,0,0),radius=.5) peg=cylinder(frame=fcrown,pos=(10,0,8),axis=(6,0,0),radius=.5) peg=cylinder(frame=fcrown,pos=(10,8*cos(math.pi/8),8*sin(math.pi/8)),axis=(6,0,0),radius=.5) peg=cylinder(frame=fcrown,pos=(10,-8*cos(math.pi/8),8*sin(math.pi/8)),axis=(6,0,0),radius=.5) peg=cylinder(frame=fcrown,pos=(10,8*cos(math.pi/8),-8*sin(math.pi/8)),axis=(6,0,0),radius=.5) peg=cylinder(frame=fcrown,pos=(10,-8*cos(math.pi/8),-8*sin(math.pi/8)),axis=(6,0,0),radius=.5) peg=cylinder(frame=fcrown,pos=(10,8*cos(math.pi*3/8),8*sin(math.pi*3/8)),axis=(6,0,0),radius=.5) peg=cylinder(frame=fcrown,pos=(10,-8*cos(math.pi*3/8),8*sin(math.pi*3/8)),axis=(6,0,0),radius=.5) peg=cylinder(frame=fcrown,pos=(10,8*cos(math.pi*3/8),-8*sin(math.pi*3/8)),axis=(6,0,0),radius=.5) peg=cylinder(frame=fcrown,pos=(10,-8*cos(math.pi*3/8),-8*sin(math.pi*3/8)),axis=(6,0,0),radius=.5) pinionbase= cylinder (frame=fpinion, pos= (0,0,0), axis=(0,1,0), radius=2.5) ppeg= cylinder (frame=fpinion, pos= (2,1,0), axis= (0,7,0), radius=.4) ppeg= cylinder (frame=fpinion, pos= (-2,1,0), axis= (0,7,0), radius=.4, color=color.cyan) ppeg= cylinder (frame=fpinion, pos= (0,1,-2), axis= (0,7,0), radius=.4,) ppeg= cylinder (frame=fpinion, pos= (0,1,2), axis= (0,7,0), radius=.4, ) piniontop= cylinder (frame=fpinion, pos= (0,8,0), axis= (0,1,0), radius = 2.5) flourshaft= cylinder(frame=fpinion, pos= (0,9,0), axis= (0,18,0), radius=.8) bottomstone=cylinder(pos= (49,27.6,0), axis=(0,1,0), radius=10) topstone= cylinder (frame=fpinion, pos=(0,25,0), axis= (0,1,0),radius=10) marker=cylinder (frame=fpinion, pos=(-9.0*cos(-math.pi/6.5),26,9.5*sin(math.pi/6.5)), axis=(0,.5,0), radius=.5, color=color.cyan) fpinion.rotate(axis= (0,20,0), angle=-math.pi/6.5) #to line crown and pinion to not run into each other water = sphere(make_trail=True,pos=(-4.5,323*math.pi/20,20), radius=3, color=color.cyan) water.velocity = vector(0,-2*20*math.pi/40,0) deltat = 0.5 t = 0 water.pos = water.pos + water.velocity*deltat stand=box(pos=(48,5.5,0), width=25, height=45, length=25, opacity=.2, color=(.5,.5,.3)) floor=box(pos=(48,-17,0), width=25, height=1, length=25, opacity=.9) #Rotate Wheel var=0 """while(1): rate(100) water.pos = water.pos + water.velocity*deltat t = t + deltat var=var+1 fwheel.rotate(axis=(20,0,0), angle=-math.pi/40) fpinion.rotate(axis= (0,20,0), angle=-math.pi/10) sleep(.0001) """ text(text='Click Mouse to Start', pos=(0,35,0), height=5, align='center', depth=0.6, axis=(1,0,.2,), color=color.black) scene.waitfor('click') while (var<20): rate(200) water.pos = water.pos + water.velocity*deltat t = t + deltat var=var+1 fwheel.rotate(axis=(20,0,0), angle=math.pi/40) fpinion.rotate(axis= (0,20,0), angle=math.pi/10) sleep(.001) water.pos=(-4.5,323*math.pi/20,20) while (var<40): rate(200) water.pos = water.pos + water.velocity*deltat t = t + deltat var=var+1 fwheel.rotate(axis=(20,0,0), angle=math.pi/40) fpinion.rotate(axis= (0,20,0), angle=math.pi/10) sleep(.001) var=0 water.pos=(-4.5,323*math.pi/20,20)