Properly center rack and make it a single line for negative base heights

Preparation for RackEdge
This commit is contained in:
Florian Festi 2016-10-12 22:44:50 +02:00
parent accb6eb45d
commit fc36515fbd
1 changed files with 11 additions and 8 deletions

View File

@ -147,15 +147,16 @@ def generate_rack_points(tooth_count, pitch, addendum, pressure_angle,
# nicely with the spur gear. # nicely with the spur gear.
# -0.5*spacing has a gap in the center. # -0.5*spacing has a gap in the center.
# +0.5*spacing has a tooth in the center. # +0.5*spacing has a tooth in the center.
fudge = +0.5 * spacing
if tab_length <= 0.0:
tab_length = 1E-8
tas = tan(radians(pressure_angle)) * addendum tas = tan(radians(pressure_angle)) * addendum
tasc = tan(radians(pressure_angle)) * (addendum+clearance) tasc = tan(radians(pressure_angle)) * (addendum+clearance)
base_top = addendum+clearance base_top = addendum+clearance
base_bot = addendum+clearance+base_height base_bot = addendum+clearance+base_height
x_lhs = -pitch * int(0.5*tooth_count-.5) - spacing - tab_length - tasc + fudge x_lhs = -pitch * 0.5*tooth_count - tab_length
# Start with base tab on LHS # Start with base tab on LHS
points = [] # make list of points points = [] # make list of points
points.append((x_lhs, base_bot)) points.append((x_lhs, base_bot))
@ -173,9 +174,8 @@ def generate_rack_points(tooth_count, pitch, addendum, pressure_angle,
points.append((x+spacing+tasc, base_top)) points.append((x+spacing+tasc, base_top))
x += pitch x += pitch
x -= spacing # remove last adjustment
# add base on RHS # add base on RHS
x_rhs = x+tasc+tab_length x_rhs = x - tasc + tab_length
points.append((x_rhs, base_top)) points.append((x_rhs, base_top))
points.append((x_rhs, base_bot)) points.append((x_rhs, base_bot))
# We don't close the path here. Caller does it. # We don't close the path here. Caller does it.
@ -427,6 +427,7 @@ class Gears():
- mount_radius is adjusted so that spokes fit if there is room - mount_radius is adjusted so that spokes fit if there is room
- if no room (collision) then spokes not drawn - if no room (collision) then spokes not drawn
""" """
# Spokes # Spokes
collision = False # assume we draw spokes collision = False # assume we draw spokes
messages = [] # messages to send back about changes. messages = [] # messages to send back about changes.
@ -620,7 +621,9 @@ class Gears():
self.boxes.cc(callback, None) self.boxes.cc(callback, None)
self.boxes.moveTo(width/2.0, base_height+addendum, -180) self.boxes.moveTo(width/2.0, base_height+addendum, -180)
self.drawPoints(points) if base_height < 0:
points = points[1:-1]
self.drawPoints(points, close=base_height >= 0)
self.drawPoints(guide_points, kerfdir=0) self.drawPoints(guide_points, kerfdir=0)
self.boxes.move(width, height, move) self.boxes.move(width, height, move)