Allow passing a list of angles to generate_spokes()
This commit is contained in:
parent
1472d250bc
commit
e3d552fe91
|
@ -409,7 +409,7 @@ class Gears():
|
||||||
# circular_pitch defines the size in mm
|
# circular_pitch defines the size in mm
|
||||||
return circular_pitch
|
return circular_pitch
|
||||||
|
|
||||||
def generate_spokes(self, root_radius, spoke_width, spoke_count, mount_radius, mount_hole,
|
def generate_spokes(self, root_radius, spoke_width, spokes, mount_radius, mount_hole,
|
||||||
unit_factor, unit_label):
|
unit_factor, unit_label):
|
||||||
""" given a set of constraints
|
""" given a set of constraints
|
||||||
- generate the svg path for the gear spokes
|
- generate the svg path for the gear spokes
|
||||||
|
@ -423,6 +423,15 @@ class Gears():
|
||||||
messages = [] # messages to send back about changes.
|
messages = [] # messages to send back about changes.
|
||||||
spoke_holes = []
|
spoke_holes = []
|
||||||
r_outer = root_radius - spoke_width
|
r_outer = root_radius - spoke_width
|
||||||
|
|
||||||
|
try:
|
||||||
|
spoke_count = spokes
|
||||||
|
spokes = [i*2*pi/spokes for i in range(spoke_count)]
|
||||||
|
except TypeError:
|
||||||
|
spoke_count = len(spokes)
|
||||||
|
spokes = [radians(a) for a in spokes]
|
||||||
|
spokes.append(spokes[0]+two_pi)
|
||||||
|
|
||||||
# checks for collision with spokes
|
# checks for collision with spokes
|
||||||
# check for mount hole collision with inner spokes
|
# check for mount hole collision with inner spokes
|
||||||
if mount_radius <= mount_hole/2:
|
if mount_radius <= mount_hole/2:
|
||||||
|
@ -435,10 +444,12 @@ class Gears():
|
||||||
messages.append("Mount support too small. Auto increased to %2.2f%s." % (mount_radius/unit_factor*2, unit_label))
|
messages.append("Mount support too small. Auto increased to %2.2f%s." % (mount_radius/unit_factor*2, unit_label))
|
||||||
|
|
||||||
# then check to see if cross-over on spoke width
|
# then check to see if cross-over on spoke width
|
||||||
if spoke_width * spoke_count +0.5 >= two_pi * mount_radius:
|
for i in range(spoke_count):
|
||||||
adj_factor = 1.2 # wrong value. its probably one of the points distances calculated below
|
angle = spokes[i]-spokes[i-1]
|
||||||
mount_radius += adj_factor
|
if spoke_width >= angle * mount_radius:
|
||||||
messages.append("Too many spokes. Increased Mount support by %2.3f%s" % (adj_factor/unit_factor, unit_label))
|
adj_factor = 1.2 # wrong value. its probably one of the points distances calculated below
|
||||||
|
mount_radius += adj_factor
|
||||||
|
messages.append("Too many spokes. Increased Mount support by %2.3f%s" % (adj_factor/unit_factor, unit_label))
|
||||||
|
|
||||||
# check for collision with outer rim
|
# check for collision with outer rim
|
||||||
if r_outer <= mount_radius:
|
if r_outer <= mount_radius:
|
||||||
|
@ -449,7 +460,7 @@ class Gears():
|
||||||
else: # draw spokes
|
else: # draw spokes
|
||||||
for i in range(spoke_count):
|
for i in range(spoke_count):
|
||||||
self.boxes.ctx.save()
|
self.boxes.ctx.save()
|
||||||
start_a, end_a = i * two_pi / spoke_count, (i+1) * two_pi / spoke_count
|
start_a, end_a = spokes[i], spokes[i+1]
|
||||||
# inner circle around mount
|
# inner circle around mount
|
||||||
asin_factor = spoke_width/mount_radius/2
|
asin_factor = spoke_width/mount_radius/2
|
||||||
# check if need to clamp radius
|
# check if need to clamp radius
|
||||||
|
|
Loading…
Reference in New Issue