240 module construct_knuckle
262 gl = (ml != 0) ? g/2 : 0;
263 gr = (mr != 0) ? g/2 : 0;
269 if ((ml == 5) || (mr == 5))
271 translate([-l/2 + gl,
eps/2, -w/2])
272 cube([sl,
eps, w], center=false);
283 mc_l = [
if (ml == 1) [+1, 1, +(gl +
eps*4)],
if (mr == 1) [-1, 0, -(gr +
eps*4)] ];
284 fc_l = [
if (ml == 2) [+1, 0, +(gl -
eps*4)],
if (mr == 2) [-1, 1, -(gr -
eps*4)] ];
289 translate([0, 0, -l/2 + gl])
290 cylinder(d=d, h=sl, center=
false);
296 cone(d=pd, h=ph, vr=[0, pvr]);
299 if ((ml == 4) || (mr == 4))
300 cylinder(d=pd, h=l +
eps*8, center=
true);
307 cone(d=pd, h=ph, vr=[0, pvr]);
312 module assemble_ehhs()
315 hht_ls = [[0, -1, 1], [1, 1, 0]];
317 for ( s = [0: len(hht_ls)-1] )
323 for ( hht_l = hht_lse )
339 echo(
strl([
"side=", ns,
", w=", p_w,
", vr=", p_vr,
340 ", vrm=", p_vrm,
", bores=", pbo_l ]));
347 cs_len = l_h/(k_spc*2+1);
348 cs_xos = -(l_h - cs_len)/2;
352 cs_hl = (hs == +1) ? [0:2:k_spc*2] : [1:2:k_spc*2];
353 cs_hf = [
for ( x=cs_hl ) x];
357 translate([(cs_xos + cs_len * s) * hs, 0, 0])
360 is_fst = (s ==
first(cs_hf));
361 is_lst = (s ==
last(cs_hf));
365 mc = is_fst ? is_eve ? [0, 3] : 3
366 : is_lst ? is_eve ? [3, 0] : 3
370 ms = is_fst ? is_eve ? [0, 5] : 5
371 : is_lst ? is_eve ? [5, 0] : 5
377 is_fst ? is_eve ? [0, 1] : 2
378 : is_lst ? is_eve ? [1, 0] : 2
383 is_fst ? is_eve ? [0, 2] : 1
384 : is_lst ? is_eve ? [2, 0] : 1
389 is_fst ? is_eve ? [0, 4] : 4
390 : is_lst ? is_eve ? [4, 0] : 4
401 construct_knuckle(m=mc, d=k_dia -
eps*4, l=cs_len, g=k_gap, p=k_pin);
404 translate([0, (k_dia/2 + k_yo) * hs, k_zo])
405 construct_knuckle(m=ms, l=cs_len, w=wth, g=k_gap, p=k_pin);
409 translate([0, k_dia/2 * hs, -wth/2 + k_zo])
411 construct_knuckle(m=ms, l=cs_len, w=k_dia/2, g=k_gap, p=k_pin);
416 construct_knuckle(m=mc, d=k_dia, l=cs_len+
eps*4, g=k_gap, p=k_pin);
421 construct_knuckle(m=mp, d=k_dia, l=cs_len, g=k_gap, p=k_pin);
425 translate([0, (p_w/2 + k_dia/2 + k_yo) * hs, k_zo])
431 pg_rectangle([p_l, p_w], vr=p_vr, vrm=p_vrm, center=true);
448 translate([xo, yo, 0])
449 screw_bore(d=pb_d, l=pb_l, h=pb_h, n=pb_n, f=pb_f);
452 echo(
strl([ "bore=[", xo, ", ", yo, "]" ]));
478 screw_bore(d=pb_d, l=pb_l, h=pb_h, n=pb_n, f=pb_f);
496 l_plr = [l_pl, l_pr];
502 w_plr = [w_pl, w_pr];
523 echo(
strl([
"size: l=", l,
", w=", w ]));
524 echo(
strl([
"size: hinge=", l_h,
525 ", left-plate=[", w_pl,
", ", l_pl,
"]",
526 ", right-plate=[", w_pr,
", ", l_pr,
"]"]));
527 echo(
strl([
"knuckle: mode=", k_mps,
", diameter=", k_dia,
528 ", count=", k_spc,
", gap=", k_gap,
", pin=", k_pin ]));
529 echo(
strl([
"offset: zo=", k_zo,
", yo=", k_yo ]));
543 [0, -l_h, -l_pl, -l_pr, +l_pr, +l_pl, +l_h]/2,
544 [0, -ey, -ey-w_pr/2, -ey-w_pr, +ey, +ey+w_pl/2, +ey+w_pl ],
545 [0, -ez, -ez+wth/2, -ez+wth]
553 translate([align_x, align_y, align_z])
776 offset = offset_df[n],
777 mbores = mbores_df[n],
839 size_df = [ [[l_h, l_pl, l_pml], [w_pl, w_pml]],
840 [[l_h, l_pr, l_pmr], [w_pr, w_pmr]] ];
848 offset_df = [ [k_zo, kl_yo],
851 mbores_df = [ [mbores_l, mbores_ml],
852 [mbores_r, mbores_mr] ];
854 mode_df = [ mode_dl, mode_dr ];
856 pivot_df = [ [pivot_l, 0], [pivot_r, 0] ];
860 echo(
strl([
"size: l=", l,
", w=", w ]));
864 ", left-plate=[", w_pl,
", ", l_pl,
"]",
865 ", right-plate=[", w_pr,
", ", l_pr,
"]",
866 ", middle-left-plate=[", w_pml,
", ", l_pml,
"]",
867 ", middle-right-plate=[", w_pmr,
", ", l_pmr,
"]"
870 echo(
strl([
"offset: zo=", k_zo,
", left-yo=", kl_yo,
", right-yo=", kr_yo ]));
873 "bores: left-plate=", mbores_l,
", right-plate=", mbores_r,
874 ", middle-left-plate=", mbores_ml,
", middle-right-plate=", mbores_mr
888 xap = [l_h, l_pl, l_pr, l_pml, l_pmr]/2,
892 yapl = [w_pml, w_pml+eyl, w_pml+eyl*2, w_pml+eyl*2+w_pl/2, w_pml+eyl*2+w_pl],
896 yapr = [w_pmr, w_pmr+eyr, w_pmr+eyr*2, w_pmr+eyr*2+w_pr/2, w_pmr+eyr*2+w_pr],
900 zap = [-kr, kr, ez-wth, ez-wth/2, ez]
903 concat(0, -xap, 0, +xap),
904 concat(0, -yapr, 0, +yapl),
914 translate([align_x, align_y, align_z])
eps
<decimal> Epsilon, small distance to deal with overlapping shapes.
function binary_and(v1, v2, bv=1)
Base-2 binary AND operation for integers.
function binary_bit_is(v, b, t=1)
Test if a binary bit position of an integer value equals a test bit.
function binary_ishr(v, s=1)
Base-2 binary right-shift operation for an integer.
function defined_e_or(v, i, d)
Return an element of an iterable when it exists or a default value otherwise.
function third(v)
Return the third element of an iterable value.
function last(v)
Return the last element of an iterable value.
function second(v)
Return the second element of an iterable value.
function defined_eon_or(v, i, d)
Return the list element or scalar numeric value, if either is defined, otherwise the default value.
function first(v)
Return the first element of an iterable value.
function select_ci(v, i, l=true)
Select specified element from list or return a default.
function strl(v)
Convert a list of values to a concatenated string.
function is_defined(v)
Test if a value is defined.
function is_even(v)
Test if a numerical value is even.
module screw_bore(d=1, l=1, h, n, t, s, f, a)
Flat and beveled-head fastener bore with nut, nut slot, and bore tolerance.
module hinge_bf(wth=1, size, vr, vrm, knuckle, offset, pbore, mbore, mbores, support=true, mode=7, pivot, align, verb=0)
A print-in-place bi-fold hinge generator.
module hinge_sf(wth=1, size, vr, vrm, knuckle, offset, pbore, mbore, mbores, support=true, mode=3, pivot, align, verb=0)
A print-in-place single-fold hinge generator.
module cone(r=1, h, d, vr)
A cone.
module pg_rectangle(size=1, o, vr, vrm=1, vfn, center=false)
A polygon rectangle with vertex rounding.