From 37751495914cca4335328b6be17dfa93424e09e0 Mon Sep 17 00:00:00 2001 From: Revar Desmera Date: Fri, 21 Jul 2023 00:05:53 -0700 Subject: [PATCH] Fixes for gear tooth profiles. --- gears.scad | 43 ++++++++++++++++++++++--------------------- 1 file changed, 22 insertions(+), 21 deletions(-) diff --git a/gears.scad b/gears.scad index d56e9d9..a3ef1b9 100644 --- a/gears.scad +++ b/gears.scad @@ -2002,6 +2002,9 @@ function _gear_tooth_profile( helical = 0, internal = false, profile_shift = 0.0, + mod, + diam_pitch, + pitch, center = false ) = let( // Calculate a point on the involute curve, by angle. @@ -2009,6 +2012,7 @@ function _gear_tooth_profile( let(b=a*PI/180) base_r * [cos(a)+b*sin(a), sin(a)-b*cos(a)], steps = 16, + circ_pitch = circular_pitch(pitch=pitch, circ_pitch=circ_pitch, diam_pitch=diam_pitch, mod=mod), // Calculate the important circle radii arad = outer_radius(circ_pitch, teeth, helical=helical, profile_shift=profile_shift, internal=internal), @@ -2072,8 +2076,8 @@ function _gear_tooth_profile( // The u values to use when generating the tooth. us = [ - for (i=[0:1:20-1]) 0.2*sin(i/20*90), - for (i=[2:1:steps-1]) i/(steps-1), + for (i=[0.0:0.02:0.2-EPSILON]) i, + for (i=[0:1:steps-1]) 0.2 + i/(steps-1)*0.8, ], // Generate the left half of the tooth. @@ -2089,26 +2093,23 @@ function _gear_tooth_profile( ) polar_to_xy(ma_rad, a), ]), - // Find undercut bottom "jaggie" if it exists. - minima = [ - for (i = idx(tooth_half_raw)) - let(p = tooth_half_raw[i]) - if (i > 0 && i < len(tooth_half_raw)-1 && norm(p) <= prad) - let( - pp = tooth_half_raw[i-1], - np = tooth_half_raw[i+1] - ) - if (p.x > pp.x && p.x > np.x) - i - ], - // Strip "jaggies" if found. - tooth_half = len(minima)<2? tooth_half_raw : [ - for (i = idx(tooth_half_raw)) - let(p = tooth_half_raw[i]) - if (i <= minima[0] || i >= last(minima)) - p - ], + strip_left = function(path,i) + i > len(path)? [] : + norm(path[i]) >= prad? [for (j=idx(path)) if(j>=i) path[j]] : + let( + angs = [ + for (j=[i+1:1:len(path)-1]) let( + p = path[i], + np = path[j], + r = norm(np), + a = v_theta(np-p) + ) if(r