瀏覽代碼

h2n: major reorganization of the code, factor blocks into several modules, make everything tilt according to the angle of the support columns, clean up all the major and minor junctures between pieces, almost everything seems to fall into place automatically

Fernando Pablo Lopez-Lezcano 9 年之前
父節點
當前提交
cb04cae2e8
共有 1 個文件被更改,包括 168 次插入 和 88 次删除
  1. 168 88
      TinySpHEAR_H2N_common.scad

+ 168 - 88
TinySpHEAR_H2N_common.scad

@@ -46,6 +46,40 @@ h2n_depth = 42.66;
 
 
 h2n_width_up = 57.0;
 h2n_width_up = 57.0;
 
 
+h2n_column_height = 40;
+transition_height = 30;
+
+// measured = 11.50, should be 13.1 -> ratio = 
+
+// h2n_side_radius = 18.2;
+h2n_side_radius = 18.4;
+h2n_side_band = 1.5;
+h2n_side_band_w = 13.4;
+h2n_width_m = 63.0;
+h2n_depth_m = 36.4;
+
+h2n_band_height = 6.0;
+
+// base band width
+h2n_band_wall = 1.6;
+
+// walls for the columns
+h2n_col_wall = 2 * wall;
+
+// tilt for the columnds
+h2n_col_tilt = 4.0;
+
+// radius of mount stalk
+h2n_mount_radius = mount_radius;
+
+// fit for connector from column to bridge
+h2n_mount_fit = 0.04;
+
+// bridge dimensions
+h2n_bridge_base_height = 10.0;
+h2n_bridge_stalk_height = 20.0;
+
+
 module tube(or, ir, h) {
 module tube(or, ir, h) {
     difference() {
     difference() {
         cylinder(r = or, h = h, $fn = facets);
         cylinder(r = or, h = h, $fn = facets);
@@ -55,27 +89,23 @@ module tube(or, ir, h) {
 
 
 // main support ring
 // main support ring
 
 
-module h2n_ring(width, depth, radius, height, slot_w, slot_d, band_wall, wall, col_rad, col_wall) {
+module h2n_ring(width, depth, radius, height, tilt, slot_w, slot_d, band_wall, wall, col_rad, col_wall) {
     // main support ring
     // main support ring
     difference() {
     difference() {
-        rounded_block(height, width / 2 + band_wall, depth / 2 +  band_wall, radius - thin_mint);
-        rounded_block_relative(height, width / 2 + band_wall, depth / 2 + band_wall, radius - band_wall - thin_mint, - band_wall);
+        conical_rounded_box(height, width / 2 + band_wall, depth / 2 +  band_wall, radius - thin_mint, band_wall, height * tan(tilt));
         for (m = [0, 1]) mirror([m, 0, 0]) {
         for (m = [0, 1]) mirror([m, 0, 0]) {
-            translate([width / 2 + col_rad - col_wall, 0, 0]) {
-                cylinder(r = col_rad, h = height + thin_mint, $fn = facets);
+            translate([-(width / 2 + col_rad - col_wall), 0, 0]) {
+                tilted_cylinder(col_rad, height, height * tan(tilt));
             }
             }
         }
         }
     }
     }
     // inner band
     // inner band
     difference() {
     difference() {
-        difference() {
-            rounded_block(height, width / 2 + wall - h2n_side_band, depth / 2 + band_wall, radius - thin_mint);
-            rounded_block_relative(height, width / 2 + wall - h2n_side_band, depth / 2 + band_wall, radius - wall - thin_mint, - wall);
-        }
+        conical_rounded_box(height, width / 2 + wall - h2n_side_band, depth / 2 + band_wall, radius - thin_mint, wall, height * tan(tilt));
         for (m = [0, 1]) mirror([m, 0, 0]) {
         for (m = [0, 1]) mirror([m, 0, 0]) {
             // cut slots on the sides
             // cut slots on the sides
             translate([-width / 2, -h2n_side_band_w / 2, 0]) {
             translate([-width / 2, -h2n_side_band_w / 2, 0]) {
-                cube([width / 2, h2n_side_band_w, height]);
+                cube([width / 2, h2n_side_band_w, height + thin_mint]);
             }
             }
         }
         }
     }
     }
@@ -83,32 +113,92 @@ module h2n_ring(width, depth, radius, height, slot_w, slot_d, band_wall, wall, c
 
 
 // side columns
 // side columns
 
 
-module h2n_columns(width, height, ring_height, tilt, band, transition, radius, wall) {
+module tilted_cylinder(radius, height, offset) {
+    hull() {
+        cylinder(r = radius, h = thin_mint, $fn = facets);
+        translate([offset, 0, height]) {
+            cylinder(r = radius, h = thin_mint, $fn = facets);
+        }
+    }
+}
+
+module tilted_rounded_box(height, width, depth, radius, wall, offset) {
+    difference() {
+        hull() {
+            rounded_block(thin_mint, width, depth, radius);
+            translate([offset, 0, height]) {
+                rounded_block(thin_mint, width, depth, radius);
+            }
+        }
+        hull() {
+            rounded_block_relative(thin_mint, width, depth, radius, -wall);
+            translate([offset, 0, height]) {
+                rounded_block_relative(thin_mint, width, depth, radius, -wall);
+            }
+        }
+    }
+}
+
+module conical_rounded_box(height, width, depth, radius, wall, inset) {
+    difference() {
+        hull() {
+            rounded_block(thin_mint, width, depth, radius);
+            translate([0, 0, height]) {
+                rounded_block_relative(thin_mint, width, depth, radius, -inset);
+            }
+        }
+        hull() {
+            rounded_block_relative(thin_mint, width, depth, radius, -wall);
+            translate([0, 0, height]) {
+                rounded_block_relative(thin_mint, width, depth, radius, -(wall + inset));
+            }
+        }
+    }
+}
+
+module tilted_cube(height, width, depth, offset) {
+    hull() {
+        cube([width, depth, thin_mint]);
+        translate([offset, 0, height]) {
+            cube([width, depth, thin_mint]);
+        }
+    }
+}
+
+module tilted_half_rounded_box(height, width, depth, radius, wall, offset, e = 0.1) {
+    difference() {
+        tilted_rounded_box(height, width, depth, radius, wall, offset);
+        translate([0, -(depth + e), 0]) {
+            tilted_cube(height, width + e, (depth + e) * 2, offset);
+        }
+    }
+}
+
+module half_rounded_box(height, width, depth, radius, wall, e = 0.1) {
+    difference() {
+        rounded_box(height, width , depth, radius, wall);
+        translate([0, -(depth + e), 0]) {
+            cube([width + e, 2 * (depth + e), height]);
+        }
+    }
+}
+
+module h2n_columns(width, height, ring_height, tilt, transition, radius, col_wall, wall) {
     // side tubes for cables
     // side tubes for cables
+    slot_height = 25.0;
     for (m = [0, 1]) mirror([m, 0, 0]) {
     for (m = [0, 1]) mirror([m, 0, 0]) {
-        translate([-(width / 2 + mount_radius - wall), 0, 0]) {
+        translate([-(width / 2 + radius - col_wall), 0, 0]) {
             difference() {
             difference() {
-                // angled column (4 degrees inward tilt)
-                hull() {
-                    cylinder(r = radius, h = thin_mint, $fn = facets);
-                    translate([height * tan(tilt) - wall/2, 0, height]) {
-                        cylinder(r = radius, h = thin_mint, $fn = facets);
-                    }
-                }
-                hull() {
-                    cylinder(r = radius - wall, h = thin_mint, $fn = facets);
-                    translate([height * tan(tilt) - wall/2, 0, height]) {
-                        cylinder(r = radius - wall, h = thin_mint, $fn = facets);
-                    }
-                }
+                // angled column
+                tilted_cylinder(radius + col_wall, height, height * tan(tilt));
+                tilted_cylinder(radius, height, height * tan(tilt));
                 // slots in the columns for cables
                 // slots in the columns for cables
-                translate([mount_radius - wall - ring_height * tan(tilt), - mount_radius * 2, -ring_height]) {
-                    slot_height = 25.0;
+                translate([radius - col_wall - ring_height * tan(tilt), - radius * 2, -ring_height]) {
                     rotate([0, tilt, 0]) {
                     rotate([0, tilt, 0]) {
-                        cube([5.0, mount_radius * 4, slot_height]);
-                        translate([mount_radius + wall, mount_radius - wall, slot_height]) {
+                        cube([5.0, radius * 4, slot_height]);
+                        translate([radius + col_wall, radius - col_wall, slot_height]) {
                             rotate([0, 90, 90]) {
                             rotate([0, 90, 90]) {
-                                cylinder(r = mount_radius + wall, h = 15.0, $fn = facets);
+                                cylinder(r = radius + col_wall, h = 15.0, $fn = facets);
                             }
                             }
                         }
                         }
                     }
                     }
@@ -116,29 +206,43 @@ module h2n_columns(width, height, ring_height, tilt, band, transition, radius, w
             }
             }
         }
         }
         // connector to bridge
         // connector to bridge
-        translate([-(width / 2 + mount_radius - wall / 2 - height * tan(tilt)), 0, height]) {
-            tube(mount_radius + wall / 2 - h2n_mount_fit, mount_radius, 5.0);
+        translate([-(width / 2 + radius - col_wall - height * tan(tilt)), 0, height]) {
+            tube(radius + wall - h2n_mount_fit, radius, 5.0);
+        }
+        // side sleeves
+        sleeve_height = slot_height - mount_radius - col_wall;
+        for (m = [0, 1]) mirror([m, 0, 0]) {
+            // we should derive the geometry for the aligment magic below...
+            side_fit = 1.05;
+            translate([-(width / 2 - (radius + col_wall) / 2 + wall - side_fit), 0, 0]) {
+                difference() {
+                    tilted_half_rounded_box(sleeve_height, 3.8, h2n_side_band_w / 2 + wall, 2.0, wall, sleeve_height * tan(tilt));
+                    translate([col_wall / 2 + wall - radius * 3 / 2 - side_fit, 0, 0]) {
+                        tilted_cylinder(radius, height, height * tan(tilt));
+                    }
+                }
+            }
         }
         }
     }
     }
 }
 }
 
 
 // bridge that connects to capsule array
 // bridge that connects to capsule array
 
 
-module semi_cylinder(r, h) {
+module semi_cylinder(r, h, e = thin_mint) {
     difference() {
     difference() {
         cylinder(h, r, r, $fn = facets);
         cylinder(h, r, r, $fn = facets);
-        translate ([-r*2, -r, 0])
-            cube([2*r, 2*r, h]);
+        translate ([-(r+e)*2, -r, 0])
+            cube([2*(r+e), 2*(r+e), h]);
     }
     }
 }
 }
 
 
-module quarter_sphere(r) {
+module quarter_sphere(r, e = thin_mint) {
     difference() {
     difference() {
         sphere(r, $fn = facets);
         sphere(r, $fn = facets);
-        translate([-r, -r, -r])
-            cube([2*r, 2*r, r]);
-        translate([-r, -r, 0])
-            cube([r, 2*r, r]);
+        translate([-(r+e), -(r+e), -(r+e)])
+            cube([2*(r+e), 2*(r+e), r+e]);
+        translate([-(r+e), -(r+e), -e])
+            cube([r, 2*(r+e), (r+e)]);
     }
     }
 }
 }
 
 
@@ -157,15 +261,15 @@ module cylcube(width, depth, height, wall) {
     }
     }
 }
 }
 
 
-module h2n_bridge(width, height, ring_height, ring_wall, tilt, band, transition, radius, col_wall, wall) {
+module h2n_bridge(width, base_height, stalk_height, radius, col_wall, wall) {
     // capsule array mount
     // capsule array mount
-    translate([0, 0, band + 20.0]) {
+    translate([0, 0, base_height + stalk_height]) {
         tetra_capsule_array_mount([-45, 135]);
         tetra_capsule_array_mount([-45, 135]);
     }
     }
     // stalk
     // stalk
-    translate([0, 0, band]) {
+    translate([0, 0, base_height]) {
         difference() {
         difference() {
-            tube(mount_radius + wall, mount_radius, 20.0 + 1.0);
+            tube(radius + wall, radius, stalk_height);
             // remove stalk segment that is inside the bridge
             // remove stalk segment that is inside the bridge
             translate([width / 2, 0, -1.0]) {
             translate([width / 2, 0, -1.0]) {
                 rotate([0, -90, 0]) {
                 rotate([0, -90, 0]) {
@@ -175,16 +279,16 @@ module h2n_bridge(width, height, ring_height, ring_wall, tilt, band, transition,
         }
         }
     }
     }
     // top of bridge
     // top of bridge
-    translate([width / 2 + wall, 0, band]) {
+    translate([width / 2, 0, base_height]) {
         rotate([0, -90, 0]) {
         rotate([0, -90, 0]) {
             difference() {
             difference() {
                 // curvy ceiling
                 // curvy ceiling
-                semi_cylinder(r = radius + col_wall, h = width + 2 * wall);
-                semi_cylinder(r = radius + col_wall - wall, h = width + 2 * wall);
+                semi_cylinder(r = radius + col_wall, h = width);
+                semi_cylinder(r = radius + col_wall - wall, h = width);
                 // make a hole for the cables
                 // make a hole for the cables
                 translate([0, 0, width / 2]) {
                 translate([0, 0, width / 2]) {
                     rotate([0, 90, 0]) {
                     rotate([0, 90, 0]) {
-                        cylinder(r = mount_radius, h = 10, $fn = facets);
+                        cylinder(r = radius, h = 10, $fn = facets);
                     }
                     }
                 }
                 }
             }
             }
@@ -192,7 +296,7 @@ module h2n_bridge(width, height, ring_height, ring_wall, tilt, band, transition,
     }
     }
     // caps at ends
     // caps at ends
     for (m = [0, 1]) mirror([m, 0, 0]) {
     for (m = [0, 1]) mirror([m, 0, 0]) {
-        translate([width / 2 + wall, 0, band]) {
+        translate([width / 2, 0, base_height]) {
             difference() {
             difference() {
                 quarter_sphere(r = radius + col_wall);
                 quarter_sphere(r = radius + col_wall);
                 quarter_sphere(r = radius + col_wall - wall);
                 quarter_sphere(r = radius + col_wall - wall);
@@ -202,8 +306,8 @@ module h2n_bridge(width, height, ring_height, ring_wall, tilt, band, transition,
     // base of bridge
     // base of bridge
     translate([0, 0, 0]) {
     translate([0, 0, 0]) {
         for (m = [0, 1]) mirror([m, 0, 0]) {
         for (m = [0, 1]) mirror([m, 0, 0]) {
-            translate([width / 2 + wall, 0, 0]) {
-                cylcube(width / 2 + wall, radius + col_wall, band, wall);
+            translate([width / 2, 0, 0]) {
+                cylcube(width / 2, radius + col_wall, base_height, wall);
             }
             }
         }
         }
     }
     }
@@ -212,62 +316,38 @@ module h2n_bridge(width, height, ring_height, ring_wall, tilt, band, transition,
         cube([col_wall, (radius + wall) * 2, col_wall]);
         cube([col_wall, (radius + wall) * 2, col_wall]);
     }
     }
     for (m = [0, 1]) mirror([m, 0, 0]) {
     for (m = [0, 1]) mirror([m, 0, 0]) {
-        translate([-width / 2 + radius, -(radius + wall), 0]) {
+        translate([-width / 2 + radius + wall, -(radius + wall), 0]) {
             cube([col_wall, (radius + wall) * 2, col_wall]);
             cube([col_wall, (radius + wall) * 2, col_wall]);
         }
         }
     }
     }
 }
 }
 
 
-connector_height = 40;
-transition_height = 30;
-
-// measured = 11.50, should be 13.1 -> ratio = 
-
-// h2n_side_radius = 18.2;
-h2n_side_radius = 18.4;
-h2n_side_band = 1.5;
-h2n_side_band_w = 13.1;
-h2n_width_m = 63.0;
-h2n_depth_m = 36.4;
-
-h2n_band_height = 6.0;
-
-// base band width
-h2n_band_wall = 1.6;
-
-// walls for the columns
-h2n_col_wall = 2 * wall;
-
-// tilt for the columnds
-h2n_col_tilt = 4.0;
-
-// fit for connector from column to bridge
-h2n_mount_fit = 0.1;
-
 // render the whole thing
 // render the whole thing
 
 
 difference() {
 difference() {
 union() {
 union() {
 
 
-h2n_ring(h2n_width_m, h2n_depth_m, h2n_depth * 0.425, h2n_band_height, h2n_side_band_w, h2n_side_band, h2n_band_wall, wall, mount_radius, h2n_col_wall);
+h2n_ring(h2n_width_m, h2n_depth_m, h2n_depth * 0.425, h2n_band_height, h2n_col_tilt, 
+         h2n_side_band_w, h2n_side_band, h2n_band_wall, wall, mount_radius, h2n_col_wall);
 
 
-h2n_columns(h2n_width_m, connector_height, h2n_band_height, h2n_col_tilt, 10.0, transition_height, mount_radius + h2n_col_wall, h2n_col_wall);
+h2n_columns(h2n_width_m, h2n_column_height, h2n_band_height, h2n_col_tilt, 
+            transition_height, h2n_mount_radius, h2n_col_wall, wall);
 
 
-translate([0, 0, connector_height]) {
-    h2n_bridge(h2n_width_m - connector_height * tan(h2n_col_tilt), connector_height, 
-               h2n_band_height, h2n_band_wall, h2n_col_tilt, 10.0, transition_height, mount_radius, h2n_col_wall, wall);
+translate([0, 0, h2n_column_height]) {
+    h2n_bridge((h2n_width_m / 2 + mount_radius - h2n_col_wall - h2n_column_height * tan(h2n_col_tilt)) * 2, 
+               h2n_bridge_base_height, h2n_bridge_stalk_height, mount_radius, h2n_col_wall, wall);
 }
 }
 
 
+rotate([0, 0, 0]) {
+    render_tetra_capsule_array(h2n_column_height + h2n_bridge_base_height + h2n_bridge_stalk_height + 27);
 }
 }
-translate([-40, -50, 0]) {
+
+}
+*translate([-40, -50, 0]) {
     cube([80, 50, 80]);
     cube([80, 50, 80]);
 }
 }
 }
 }
 
 
-// capsule holders and connector to main body
-*rotate([0, 0, 0]) {
-    render_tetra_capsule_array(connector_height + transition_height + 30);
-}
 
 
 // make sure dimensions are fine
 // make sure dimensions are fine
 *translate([-(h2n_width_m - 0.1) / 2, - 0.5, 0]) {
 *translate([-(h2n_width_m - 0.1) / 2, - 0.5, 0]) {