Merge pull request #1232 from BelfrySCAD/revarbat_dev

Implemented herringbone racks.
This commit is contained in:
Revar Desmera 2023-07-31 19:30:10 -07:00 committed by GitHub
commit f74f0565df
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1226,6 +1226,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
@ -1283,8 +1284,9 @@ module rack(
backlash = 0.0,
clearance,
helical,
herringbone = false,
profile_shift = 0,
gear_travel=0,
gear_travel = 0,
circ_pitch,
diam_pitch,
mod,
@ -1303,7 +1305,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);
@ -1334,18 +1337,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();
@ -1362,11 +1383,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
@ -1383,7 +1405,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),
@ -1403,19 +1426,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),