diff --git a/gears.scad b/gears.scad index 62c60d6..89a2539 100644 --- a/gears.scad +++ b/gears.scad @@ -1246,6 +1246,7 @@ module ring_gear2d( // mod = The metric module/modulus of the gear, or mm of pitch diameter per tooth. // diam_pitch = The diametral pitch, or number of teeth per inch of pitch diameter. Note that the diametral pitch is a completely different thing than the pitch diameter. // helical = The angle of the rack teeth away from perpendicular to the rack length. Used to match helical spur gear pinions. Default: 0 +// herringbone = If true, and helical is set, creates a herringbone rack. // profile_shift = Profile shift factor x. Default: 0 // pressure_angle = Controls how straight or bulged the tooth sides are. In degrees. Default: 20 // backlash = Gap between two meshing teeth, in the direction along the circumference of the pitch circle. Default: 0 @@ -1303,8 +1304,9 @@ module rack( backlash = 0.0, clearance, helical, + herringbone = false, profile_shift = 0, - gear_travel=0, + gear_travel = 0, circ_pitch, diam_pitch, mod, @@ -1323,7 +1325,8 @@ module rack( assert(clearance==undef || (is_finite(clearance) && clearance>=0)) assert(is_finite(backlash) && backlash>=0) assert(is_finite(helical) && abs(helical)<90) - //assert(is_bool(herringbone)) + assert(is_bool(herringbone)) + assert(is_finite(profile_shift)) assert(is_finite(gear_travel)); trans_pitch = pitch / cos(helical); a = _adendum(pitch, profile_shift); @@ -1354,18 +1357,36 @@ module rack( size = [l, thickness, 2*bottom]; attachable(anchor,spin,orient, size=size, anchors=anchors) { right(gear_travel) - skew(sxy=-tan(helical)) xrot(90) { - linear_extrude(height=thickness, center=true, convexity=teeth*2) { - rack2d( - pitch = pitch, - teeth = teeth, - bottom=bottom, - pressure_angle = PA, - backlash = backlash, - clearance = clearance, - helical = helical, - profile_shift = profile_shift - ); + xrot(90) { + if (herringbone) { + zflip_copy() + skew(axz=-helical) down(0.01) + linear_extrude(height=thickness/2, center=false, convexity=teeth*2) { + rack2d( + pitch = pitch, + teeth = teeth, + bottom = bottom, + pressure_angle = PA, + backlash = backlash, + clearance = clearance, + helical = helical, + profile_shift = profile_shift + ); + } + } else { + skew(axz=helical) + linear_extrude(height=thickness, center=true, convexity=teeth*2) { + rack2d( + pitch = pitch, + teeth = teeth, + bottom = bottom, + pressure_angle = PA, + backlash = backlash, + clearance = clearance, + helical = helical, + profile_shift = profile_shift + ); + } } } children(); @@ -1382,11 +1403,12 @@ function rack( backlash = 0.0, clearance, helical, + herringbone = false, profile_shift = 0, circ_pitch, diam_pitch, mod, - gear_travel=0, + gear_travel = 0, anchor = CENTER, spin = 0, orient = UP @@ -1403,7 +1425,8 @@ function rack( assert(clearance==undef || (is_finite(clearance) && clearance>=0)) assert(is_finite(backlash) && backlash>=0) assert(is_finite(helical) && abs(helical)<90) - //assert(is_bool(herringbone)) + assert(is_bool(herringbone)) + assert(is_finite(profile_shift)) assert(is_finite(gear_travel)) let( trans_pitch = pitch / cos(helical), @@ -1423,19 +1446,23 @@ function rack( path = rack2d( pitch = pitch, teeth = teeth, - bottom=bottom, + bottom = bottom, pressure_angle = PA, backlash = backlash, clearance = clearance, helical = helical, profile_shift = profile_shift ), - vnf = linear_sweep(path, height=thickness, anchor="origin", orient=FWD), - m = product([ - right(gear_travel), - if (helical) skew(sxy=-tan(helical)) - ]), - out = apply(m, vnf), + vnf = herringbone + ? sweep(path, [ + left(adj_ang_to_opp(thickness/2,helical)) * + back(thickness/2) * xrot(90), + xrot(90), + left(adj_ang_to_opp(thickness/2,helical)) * + fwd(thickness/2) * xrot(90), + ], style="alt", orient=FWD) + : skew(axy=-helical, p=linear_sweep(path, height=thickness, anchor="origin", orient=FWD)), + out = right(gear_travel, p=vnf), size = [l, thickness, 2*bottom], anchors = [ named_anchor("tip", [0,0,a], BACK),