From: Katherine A. <arr...@ma...> - 2014-11-29 18:12:52
|
How to do write a while loop for a ring and cylinder to rotate or turn. I am programming a stimulation that shows how a simple electric motor work. This is what I have so far : from __future__ import division from math import e from visual import* import math scene.title='Simple Electric motor simulation' scene.width = 1000 scene.height = 500 scene.autoscale = 0 scene.range = (35,35,35) scene.center = (12,0,) area=box(pos=(12,0,14),length=400,height=400,width=400,material=materials.plastic,color=(.5,0.5,2)) fcharge=1.6e-19 pweight=1.67e-11 count=0 mfrm=frame(axis=(350,5,10)) #Motor Frame rfrm=frame(frame=mfrm) #Rotor Frame #Electric motor-Jon's battery=frame() cylinder(frame=battery,pos=(0,0,10),axis=(0,0,.2),radius=1.5,color=color.blue,material=materials.emissive) cylinder(frame=battery,pos=(0,0,10.2),axis=(0,0,7.8),radius=1.5,color=(0.5,0.5,0.2)) cylinder(frame=battery,pos=(0,0,12),axis=(0,0,7),radius=.75,color=color.red,material=materials.emissive) #wire-Mine wire=curve(pos=[(0,-6.5,20), (0,0,20), (0,0,8.5),(0,-6.5,8.5)], radius=0.25) #Magnet of motor-Mine floor1 = box (pos=(0,-1.75,14), length=2, height=0.5, width=6, color=color.red) floor2 = box (pos=(0,-2.25,14), length=2, height=0.5, width=6, color=color.blue) #Rotor stucture-Mine # Add Ring and Rod # The armature coil (ring) ring(pos=(0,-6,14),axis=(350,5,10), radius=1.75, thickness=0.5,color=(1,0.5,0.3),material=materials.blazed,) rod1=cylinder(pos=(0,-6,8.5),length=11.5,axis=(0,0.5,100),radius=0.45,color=(1,0.5,0.3), material=materials.blazed,) ring(pos=(0,-6,14),axis=(350,5,10), radius=1.75, thickness=0.5,color=(1,0.5,0.3),material=materials.blazed,) #labeling of program-Mine label1=label(pos=(0,0,10.2), text='Battery', xoffset=17, yoffset=17) label2=label(pos=(0,-6,10), text='Armature', xoffset=47, yoffset=47) print 'end of stimulation' thanks! Kathy |