Fix indentiation

This commit is contained in:
Florian Festi 2016-07-09 12:29:37 +02:00
parent 1fcb6c67b1
commit ab05372bcc
1 changed files with 77 additions and 77 deletions

View File

@ -48,10 +48,10 @@ two_pi = 2 * pi
__version__ = '0.9' __version__ = '0.9'
def uutounit(self,nn,uu): def uutounit(self,nn,uu):
try: try:
return self.uutounit(nn,uu) # inkscape 0.91 return self.uutounit(nn,uu) # inkscape 0.91
except: except:
return inkex.uutounit(nn,uu) # inkscape 0.48 return inkex.uutounit(nn,uu) # inkscape 0.48
def linspace(a,b,n): def linspace(a,b,n):
""" return list of linear interp of a to b in n steps """ return list of linear interp of a to b in n steps
@ -181,63 +181,63 @@ def gear_calculations(num_teeth, circular_pitch, pressure_angle, clearance=0, ri
def generate_rack_points(tooth_count, pitch, addendum, pressure_angle, def generate_rack_points(tooth_count, pitch, addendum, pressure_angle,
base_height, tab_length, clearance=0, draw_guides=False): base_height, tab_length, clearance=0, draw_guides=False):
""" Return path (suitable for svg) of the Rack gear. """ Return path (suitable for svg) of the Rack gear.
- rack gear uses straight sides - rack gear uses straight sides
- involute on a circle of infinite radius is a simple linear ramp - involute on a circle of infinite radius is a simple linear ramp
- the meshing circle touches at y = 0, - the meshing circle touches at y = 0,
- the highest elevation of the teeth is at y = +addendum - the highest elevation of the teeth is at y = +addendum
- the lowest elevation of the teeth is at y = -addendum-clearance - the lowest elevation of the teeth is at y = -addendum-clearance
- the base_height extends downwards from the lowest elevation. - the base_height extends downwards from the lowest elevation.
- we generate this middle tooth exactly centered on the y=0 line. - we generate this middle tooth exactly centered on the y=0 line.
(one extra tooth on the right hand side, if number of teeth is even) (one extra tooth on the right hand side, if number of teeth is even)
""" """
spacing = 0.5 * pitch # rolling one pitch distance on the spur gear pitch_diameter. spacing = 0.5 * pitch # rolling one pitch distance on the spur gear pitch_diameter.
# roughly center rack in drawing, exact position is so that it meshes # roughly center rack in drawing, exact position is so that it meshes
# 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 fudge = +0.5 * spacing
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 * int(0.5*tooth_count-.5) - spacing - tab_length - tasc + fudge
#inkex.debug("angle=%s spacing=%s"%(pressure_angle, spacing)) #inkex.debug("angle=%s spacing=%s"%(pressure_angle, spacing))
# 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))
points.append((x_lhs, base_top)) points.append((x_lhs, base_top))
x = x_lhs + tab_length+tasc x = x_lhs + tab_length+tasc
# An involute on a circle of infinite radius is a simple linear ramp. # An involute on a circle of infinite radius is a simple linear ramp.
# We need to add curve at bottom and use clearance. # We need to add curve at bottom and use clearance.
for i in range(tooth_count): for i in range(tooth_count):
# move along path, generating the next 'tooth' # move along path, generating the next 'tooth'
# pitch line is at y=0. the left edge hits the pitch line at x # pitch line is at y=0. the left edge hits the pitch line at x
points.append((x-tasc, base_top)) points.append((x-tasc, base_top))
points.append((x+tas, -addendum)) points.append((x+tas, -addendum))
points.append((x+spacing-tas, -addendum)) points.append((x+spacing-tas, -addendum))
points.append((x+spacing+tasc, base_top)) points.append((x+spacing+tasc, base_top))
x += pitch x += pitch
x -= spacing # remove last adjustment 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.
# points.append((x_lhs, base_bot)) # points.append((x_lhs, base_bot))
# Draw line representing the pitch circle of infinite diameter # Draw line representing the pitch circle of infinite diameter
guide_path = None guide_path = None
if draw_guides: if draw_guides:
p = [] p = []
p.append( (x_lhs + 0.5 * tab_length, 0) ) p.append( (x_lhs + 0.5 * tab_length, 0) )
p.append( (x_rhs - 0.5 * tab_length, 0) ) p.append( (x_rhs - 0.5 * tab_length, 0) )
guide_path = points_to_svgd(p) guide_path = points_to_svgd(p)
# return points ready for use in an SVG 'path' # return points ready for use in an SVG 'path'
return (points, guide_path) return (points, guide_path)
def generate_spur_points(teeth, base_radius, pitch_radius, outer_radius, root_radius, accuracy_involute, accuracy_circular): def generate_spur_points(teeth, base_radius, pitch_radius, outer_radius, root_radius, accuracy_involute, accuracy_circular):
@ -256,7 +256,7 @@ def generate_spur_points(teeth, base_radius, pitch_radius, outer_radius, root_ra
points = [] points = []
for c in centers: for c in centers:
# Angles # Angles
pitch1 = c - half_thick_angle pitch1 = c - half_thick_angle
base1 = pitch1 - pitch_to_base_angle base1 = pitch1 - pitch_to_base_angle
offsetangles1 = [ base1 + x for x in angles] offsetangles1 = [ base1 + x for x in angles]
@ -586,9 +586,9 @@ class Gears(inkex.Effect):
# alas annotation cannot handle the degree symbol. Also it ignore newlines. # alas annotation cannot handle the degree symbol. Also it ignore newlines.
# so split and make a list # so split and make a list
warnings.extend(msg.split("\n")) warnings.extend(msg.split("\n"))
if self.options.undercut_alert: if self.options.undercut_alert:
inkex.debug(msg) inkex.debug(msg)
else: else:
print >>self.tty, msg print >>self.tty, msg
# All base calcs done. Start building gear # All base calcs done. Start building gear