diff options
-rw-r--r-- | bitstorage.scad | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/bitstorage.scad b/bitstorage.scad new file mode 100644 index 0000000..aa443df --- /dev/null +++ b/bitstorage.scad @@ -0,0 +1,60 @@ +use <gridfinity.scad> + +mm_1_4_inch = 6.35; + +diam = mm_1_4_inch; +wall = 1.5; + +bit_depth = 5; + +// size in GF units +ux = 2; +uy = 2; + +function r_from_d(d) = d/2 / sin(60); +function staggered_offset(d, w) = r_from_d(d)*1.5 + sin(60) * w; + +function hc_max_y(max_y, d, w) = floor( max_y / (diam + wall) - 1 ); +function hc_max_x(max_x, d, w) = floor( (max_x - r_from_d(d)/2 ) / (staggered_offset(d,w)) - 1 ); + +// d is from flat side to flat side -> wrench size +module hexagon(d) { + l = r_from_d(d); + translate([l,l]) circle(l, $fn=6); +} + +// d = wrench size, w = wall +module honeycomb(cnt_x, cnt_y, d, w) { + // we want wall distance also at a 60deg angle. + x_offset = staggered_offset(d,w); + + for (ix = [0:cnt_x]) { + // every second row is offset + offs = ix%2 == 1 ? (d + w) / 2 : 0; + x = x_offset * ix; + + for (iy = [0 : cnt_y - ix%2]) { + y = iy * (d + w) + offs; + translate([x,y]) hexagon(d); + } + } +} + +module honeycomb_fit(x, y, d, w) { + honeycomb(hc_max_x(x,d,w), hc_max_y(y,d,w), d, w); +} + +module honeycomb_fit_center(x, y, d, w) { + // mostly educated guessing, certainly not perfectly center + offs_y = (y - ((hc_max_y(y, d, w) + 1) * (d+w))) /2; + offs_x = (x - (hc_max_x(x, d, w) + 1) * staggered_offset(d, w) - r_from_d(d)/2) / 2; + + translate([offs_x, offs_y]) honeycomb_fit(x,y,d,w); +} + +difference() { + gridfinity(ux, uy, 3, lip=true, magnets=false, fill = false, bottom_height = bit_depth); + translate(gf_inner_origin()) translate(gf_top_vec(0)) + linear_extrude(bit_depth + 0.01) + honeycomb_fit_center(gf_inner(ux), gf_inner(uy), diam,wall); +} |