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.center= (30,8,0) scene.autoscale= None scene.background=color.black 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=(10.5,0,0)) fLowWheel=frame(frame=fworld, pos=(40,-13,0)) fpart=frame(frame=fLowWheel, pos=(13,5,0)) fsaw=frame(frame=fworld, pos=(50,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 t = 0 water.pos = water.pos + water.velocity*deltat ax=(1,0,0) 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) 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) fsaw.velocity=vector(0,0,math.sin(deltat)) marker=cylinder(pos=(53,-8,30,), axis=(0,0,40), radius=.2) var=0 x = 9 fsaw.pos = (53,-13,x+4) vx = 150 k = 10.0 mass = .01 ampl = .002 t = 0 dt = 0.005 while(1): rate(100) fwheel.rotate(axis=ax, angle=-rot) fLowWheel.rotate(axis=ax, angle=rot) fpart.rotate(axis=ax, angle=-rot) fsaw.pos=fsaw.pos + fsaw.velocity*deltat sleep(.1) rate(1/dt) a = -(k/mass) * x vx = vx + a*dt x = x + vx*dt-2 fsaw.pos = (53, -13, x+20) t = t + dt sleep(.001) """ 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) """