mirror of
https://github.com/BelfrySCAD/BOSL2.git
synced 2025-01-04 03:09:45 +00:00
Fixes for gear tooth profiles.
This commit is contained in:
parent
88c912c9bb
commit
3775149591
1 changed files with 22 additions and 21 deletions
43
gears.scad
43
gears.scad
|
@ -2002,6 +2002,9 @@ function _gear_tooth_profile(
|
||||||
helical = 0,
|
helical = 0,
|
||||||
internal = false,
|
internal = false,
|
||||||
profile_shift = 0.0,
|
profile_shift = 0.0,
|
||||||
|
mod,
|
||||||
|
diam_pitch,
|
||||||
|
pitch,
|
||||||
center = false
|
center = false
|
||||||
) = let(
|
) = let(
|
||||||
// Calculate a point on the involute curve, by angle.
|
// 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)],
|
let(b=a*PI/180) base_r * [cos(a)+b*sin(a), sin(a)-b*cos(a)],
|
||||||
|
|
||||||
steps = 16,
|
steps = 16,
|
||||||
|
circ_pitch = circular_pitch(pitch=pitch, circ_pitch=circ_pitch, diam_pitch=diam_pitch, mod=mod),
|
||||||
|
|
||||||
// Calculate the important circle radii
|
// Calculate the important circle radii
|
||||||
arad = outer_radius(circ_pitch, teeth, helical=helical, profile_shift=profile_shift, internal=internal),
|
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.
|
// The u values to use when generating the tooth.
|
||||||
us = [
|
us = [
|
||||||
for (i=[0:1:20-1]) 0.2*sin(i/20*90),
|
for (i=[0.0:0.02:0.2-EPSILON]) i,
|
||||||
for (i=[2:1:steps-1]) i/(steps-1),
|
for (i=[0:1:steps-1]) 0.2 + i/(steps-1)*0.8,
|
||||||
],
|
],
|
||||||
|
|
||||||
// Generate the left half of the tooth.
|
// Generate the left half of the tooth.
|
||||||
|
@ -2089,26 +2093,23 @@ function _gear_tooth_profile(
|
||||||
) polar_to_xy(ma_rad, a),
|
) 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.
|
// Strip "jaggies" if found.
|
||||||
tooth_half = len(minima)<2? tooth_half_raw : [
|
strip_left = function(path,i)
|
||||||
for (i = idx(tooth_half_raw))
|
i > len(path)? [] :
|
||||||
let(p = tooth_half_raw[i])
|
norm(path[i]) >= prad? [for (j=idx(path)) if(j>=i) path[j]] :
|
||||||
if (i <= minima[0] || i >= last(minima))
|
let(
|
||||||
p
|
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<prad) a
|
||||||
|
],
|
||||||
|
mti = !angs? 0 : min_index(angs),
|
||||||
|
out = concat([path[i]], strip_left(path, i + mti + 1))
|
||||||
|
) out,
|
||||||
|
tooth_half = strip_left(tooth_half_raw, 0),
|
||||||
|
|
||||||
// Mirror the tooth to complete it.
|
// Mirror the tooth to complete it.
|
||||||
tooth = deduplicate([
|
tooth = deduplicate([
|
||||||
|
|
Loading…
Reference in a new issue