from visual import * import math #key = scene.kb.getkey() # wait for and get keyboard info scene.forward = (5.5,-3.0,-10) scene.center= (40,-3,26) scene.autoscale= None scene.background=color.black scene.width = 1000 scene.height = 700 scene.autoscale = 0 scene.range = (100, -100.1, 10.1) # slorot is not yet used dang = .01 def slorot(dang): scene.forward=scene.forward*math.cos(dang) - math.sin(dang)*scene.up.cross(scene.forward) #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=(10.5,0,0)) fLowWheel=frame(frame=fworld, pos=(40,-13,0)) fpart=frame(frame=fLowWheel, pos=(13,5,0)) fsaw=frame(frame=fpart, pos=(0,0,15)) gear = shapes.gear(radius=20,pos=(0,0),phi=10,addendum=6,dedendum=4,fradius=4/8,res=1,n=8) straight = [(0,0,0),(3,0,0)] extrusion(frame=fwheel,pos=straight, shape=gear, color=color.yellow) rod= cylinder(frame=fwheel,pos=(0,0,0), axis=(40,0), radius=2) crown= cylinder(frame=fwheel,pos=(40,0,0), axis=(2,0,0), radius=6) water = sphere(make_trail=True,pos=(0,350*math.pi/20,-20), radius=3, color=color.cyan) peg= cylinder(frame=fcrown, pos=(1,6,0), axis=(0,2,0), radius=.5) peg=cylinder(frame=fcrown, pos=(1,-6,0), axis=(0,-2,0), radius=.5) peg=cylinder(frame=fcrown, pos=(1,0,6), axis=(0,0,2), radius=.5) peg=cylinder(frame=fcrown, pos=(1,0,-6), axis=(0,0,-2), radius=.5) peg=cylinder(frame=fcrown, pos=(1,6*math.cos(pi/4),6*math.sin(pi/4)), axis=(0,math.sqrt(2),math.sqrt(2)), radius=.5) peg=cylinder(frame=fcrown, pos=(1,-6*math.cos(pi/4),6*math.sin(pi/4)), axis=(0,-math.sqrt(2),math.sqrt(2)), radius=.5) peg=cylinder(frame=fcrown, pos=(1,6*math.cos(pi/4),-6*math.sin(pi/4)), axis=(0,math.sqrt(2),-math.sqrt(2)), radius=.5) peg=cylinder(frame=fcrown, pos=(1,-6*math.cos(pi/4),-6*math.sin(pi/4)), axis=(0,-math.sqrt(2),-math.sqrt(2)), radius=.5) rot=math.pi/20 water.velocity = vector(0,-2*25*rot,0) deltat = 0.5 ax=(1,0,0) #but we had to move this out of the function encasement tt = 0 # this is our counter, it is very important so I made it into tt and also do something #presumed beginning of the water droplet animation. def waterdrop(until): if (tt < until): water.pos = water.pos + water.velocity*deltat fwheel.rotate(axis=ax, angle=.93) LowCrown= cylinder (frame=fLowWheel, pos=(0,0,0), axis= (.7,0,0), radius=6) LowCrown= cylinder (frame=fLowWheel, pos=(2.3,0,0), axis= (.7,0,0), radius=6) LowCrownPaddle= box(frame=fLowWheel, pos=(1.5,0,0), length=2,height=12, width=1, up=(0,1,0)) LowCrownPaddle= box(frame=fLowWheel, pos=(1.5,0,0), length=2,height=12, width=1, up=(1,0,0)) LowCrownPaddle= box(frame=fLowWheel, pos=(1.5,0,0), length=2,height=12, width=1, up=(0,1,1)) LowCrownPaddle= box(frame=fLowWheel, pos=(1.5,0,0), length=2,height=12, width=1, up=(0,1,-1)) LowShaft= cylinder(frame=fLowWheel, pos=(-3,0,0), axis=(15,0,0), radius=1) ConnectDisc= cylinder(frame=fLowWheel, pos=(10,0,0), axis=(.7,0,0), radius=6) DiscPeg=cylinder(frame=fLowWheel, pos=(10.7,5,0), axis=(3,0,0), radius=.5) #presumed end of droplet animation part=cylinder(frame=fpart, pos=(0,0,0), axis=(0,0,16), radius=.6) saw=cylinder(frame=fsaw, pos=(0,0,0), axis=(0,0,21), radius=.5) SawHold=cylinder(frame=fsaw, pos=(0,-5,3), axis=(0,10,0), radius=.7) SawHold=cylinder(frame=fsaw, pos=(0,-5,19), axis=(0,10,0), radius=.7) SawBlade=box(frame=fsaw, pos=(0,-4,11),length=.2, height=1, width=16) marker=cylinder(pos=(53,-8,30,), axis=(0,0,40), radius=.2) def waterwheel(until): if(tt < until): fwheel.rotate(axis=ax, angle=-rot) fLowWheel.rotate(axis=ax, angle=rot) fpart.rotate(axis=ax, angle=-rot) fsaw.pos=fsaw.pos + (0,.08,0) fwheel.rotate(axis=ax, angle=-rot) fLowWheel.rotate(axis=ax, angle=rot) fpart.rotate(axis=ax, angle=-1.1*rot) fsaw.rotate(ax=ax,angle=.1*rot) fsaw.pos=fsaw.pos + (0,.08,0) while 1: rate(10) tt += 1 waterdrop(20) waterwheel(30)