Tecnología > Mecánica
Relación de engranajes
(1/1)
Carlos Net:
--- Código: (Python) ---# Relatran
relation = 3.1415927
gears = 2
dientes_min = 8
dientes_max = 32
rels = {}
for t1 in range(dientes_min, dientes_max+1):
for t2 in range(dientes_min, dientes_max+1):
rel = float(t1)/t2
if not rel in rels:
rels[rel] = [t1, t2, rel]
best_r = 1
for r1 in rels:
for r2 in rels:
error = abs(((r1 * r2)/relation) - 1)
if error < best_r:
best_r = error
print error, rels[r1], rels[r2], r1*r2
--- Fin del código ---
Carlos Net:
--- Código: (python) ---# Relatran
import math
relation = math.exp(1)
gears = 2
teeth_min = 8
teeth_max = 32
rels = {}
for t1 in range(teeth_min, teeth_max+1):
for t2 in range(teeth_min, teeth_max+1):
rel = float(t1)/t2
if not rel in rels:
rels[rel] = [t1, t2, rel]
best_r = 1
rels12 = {}
for r1 in rels:
for r2 in rels:
r12 = r1 * r2 / relation
if not r12 in rels12:
rels12[r12] = [r1, r2]
count = len(rels)
paso = 0
for r3 in rels:
if paso <= 0:
paso = len(rels) / 100
print (100*count)/len(rels),
count -= paso
paso -=1
for rel12 in rels12:
if abs(rel12 * r3 - 1) < best_r:
best_r = abs(rel12 * r3 - 1)
r1, r2 = rels12[rel12]
print '\n\n', best_r, rels[r1], rels[r2], rels[r3], r1*r2*r3
--- Fin del código ---
Navegación
Ir a la versión completa