aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Jonas Gunz <himself@jonasgunz.de> 2023-01-24 02:40:06 +0100
committerGravatar Jonas Gunz <himself@jonasgunz.de> 2023-01-24 02:40:06 +0100
commitc08de309e09f1153b3187f3e9b4f823ca1d45d3b (patch)
tree70b3cef9b40e852872d2fca33ac893c94c7f8d19
parentd7c7274170dc4dc3704e5b88c76d44ca9d9cbd83 (diff)
downloadoscad_gridfinity-c08de309e09f1153b3187f3e9b4f823ca1d45d3b.tar.gz
flexible bit storage
-rw-r--r--bitstorage.scad60
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);
+}