Programas en Python
Programas en Python
print("""
""")
r=3
a1 = a2 = a3 = 0.0
color=color.magenta, material=materials.emissive)
color=color.yellow, material=materials.emissive)
color=color.green, material=materials.emissive)
l1 = local_light(pos=b1.pos, color=b1.color)
l2 = local_light(pos=b2.pos, color=b2.color)
l3 = distant_light(direction=b3.pos, color=b3.color)
while True:
rate(100)
a1 += 0.02
a2 += 0.055
scene.autocenter = True
scene.width = 1024
scene.height = 768
# Create contactor
g1 = shapes.circle(radius=1.2)
ns=24
for i in range(ns):
# Second, subtract rectangular pieces to get a slice for each contact surface
t = shapes.rectangle(pos=(1.2*cos(i*2*pi/ns),1.2*sin(i*2*pi/ns)),
g1 = g1 - t
cl = 2.0
material=materials.rough, frame=rfrm)
# Create contactor soldering tips, same as above
g2 = shapes.circle(radius=1.4)
ns=24
sphs = []
for i in range(ns):
t = shapes.rectangle(pos=(1.2*cos(i*2*pi/ns),1.2*sin(i*2*pi/ns)),
g2 = g2 - t
sphs.append(sldr)
material=materials.rough, frame=rfrm)
sc = shapes.circle(radius=0.5, thickness=0.05)
# Extrude the ring to get a thin hollow cylinder insulator over the shaf
material=materials.plastic, frame=rfrm)
material=materials.blazed)
# Use the gear shape to define the shape, note radius, addendum, dedendum sizes
gr = shapes.gear(n=9, radius=0.455, addendum=0.04, dedendum=0.06, fradius=0.01)
material=materials.blazed)
# Normally the core should have been built of many very thin sheets
g3 = shapes.circle(radius=3.0)
ns=12
for i in range(ns):
t1 = shapes.rectangle(pos=(3*cos(i*2*pi/ns),3*sin(i*2*pi/ns)),
t2 = shapes.trapezoid(pos=(2.*cos(i*2*pi/ns),2.*sin(i*2*pi/ns)),
rotate=i*2*pi/ns+pi/2, )
ps = 5.5
dlt = 0.05
thk = 5.04
nl = 1 # nl = 100
cf = frame(frame=rfrm, pos=(0,0, thk/2.+cl/2.0))
for i in range(nl):
N = 20 # coils
vright = vector(.3,1.3)
r = mag(vright)/(2*N)
vright = norm(vright)
for n in range(N):
right = vector(0,-.65)+(r+n*2*r)*vright
P = shapes.rectangle(width=.5, height=thk)
wrfs = []
for i in range(ns):
wrfs.append(wrf)
color=(.7,.5,.15), material=materials.rough)
# Make angular corrections to position on the rotor core
for i in range(ns):
color=(0.4,0.2,0))
color=(0,0,1))
# Create Brushes
# From a rectangular cross section, subtract rotor contactor circle, leaving us two
material=materials.rough, shape=br)
# Extrude the rectangular frame to obtain hollow boxes for each housing
material=materials.rough)
material=materials.rough)
scrh.scale(0.15,0.15)
material=materials.rough)
material=materials.rough)
scrb = shapes.rectangle(scale=0.1)
# Extrude the square with twist parameter to get the teeth of the screw
material=materials.rough)
material=materials.rough)
# Use a rectangular block, subtract rotor circle to allow space for the rotor
material=materials.plastic, shape=crdl)
radius=0.03, color=ge1.color)
cbl1o = curve(frame=mfrm, pos=[scrhw1.pos[-2], scrhw1.pos[-2]- vector(-1.5,0,0)],
radius=0.05, color=(0,0,1))
radius=0.03, color=ge1.color)
cbl2i.append(pos=cbl2i.pos[-1]+(0,-2,0))
cbl2i.append(pos=cbl2i.pos[-1]+(7,0,0))
cbl2o.pos[-1]-= (0.5,0,0)
# From a rectangular shape subtract the circles for the balls, and then
# Extrude the cross section along a full circle to get a ball bearing
material=materials.blazed)
b1f.rotate(angle=pi/2)
material=materials.blazed)
b2f.rotate(angle=pi/2)
bbrs1 = []
bbrs2 = []
for i in range(7):
radius=0.25, material=materials.rough))
# We did not include all stator parts here for better visualisation
# Subtract some more holes for fixing the stator core on the motor body
shapes.circle(pos=(2.6,-2.1), radius=0.3) -
shapes.circle(pos=(2.0,-3.4), radius=0.15) -
shapes.circle(pos=(-2.6,-2.1), radius=0.3) -
shapes.circle(pos=(-2.0,-3.4), radius=0.15))
# Here is a complex path definition for stator winding, which is not planar.
tp = []
cp = pp.contour(0)[0:len(pp.contour(0))//2]
for p in cp:
tp.append((0,-p[0],p[1]))
tmp.extend(tp)
tmp.reverse()
tp.append(vector(tp[-1])-vector(thk+0.7,0,0))
for p in tmp:
tp.append(vector(p)-vector(thk+0.7,0,0))
tp.append(vector(tp[-1])+vector(thk+0.7,0,0))
# Just a simple winding cross section for the whole of the stator winding
sts = shapes.circle(radius=0.3)
shape=sts, color=(1,0,0))
sfrm.rotate(axis=(0,1,0), angle=-pi/2)
# Add two rounded rectangles which will cover all the rotor and stator.
cvrc = Polygon(cvr.contour(0))
cvrc.scale(0.95,0.95)
# Subtract the smaller one to get a thin "skin" to represent the cover
# We do not need the full profile, take out the lower half, allowing some
cfrm = frame(pos=(-4.6,0,0))
# Rotate the profile around the shaf along an arc to get the cover.
# Do not use full circle, so that we can see the inside of the motor
cfrm.rotate(angle=pi/2)
cfrm.rotate(axis=(0,1,0), angle=pi/2)
cfrm.rotate(axis=(1,0,0), angle=-pi/2)
angl = pi/400
run = True
while True:
rate(100)
if run:
rfrm.rotate(angle=angl, axis=(0,0,1))
if scene.mouse.events:
m = scene.mouse.getevent()
if m.click == 'lef':