acorn: hollow acorn out using a dome
[clinton/3d-models.git] / acorn / acorn-threads.scad
index 50eb524..688ef30 100644 (file)
@@ -14,6 +14,18 @@ thread_angle = 50;
 
 function contains (x, lst) = len([ for (i = lst) if (x == i) i]) > 0;
 
+// dome module from https://github.com/Sembiance/common/blob/master/openscad/dome.scad, Public Domain
+module dome(d=5, h=2, hollow=false, wallWidth=0.5) {
+     sphereRadius = (pow(h, 2) + pow((d/2), 2) ) / (2*h);
+     translate([0, 0, (sphereRadius-h)*-1]) {
+         difference() {
+              sphere(sphereRadius);
+              translate([0, 0, -h]) cube([2*sphereRadius, 2*sphereRadius, 2*sphereRadius], center=true);
+              if(hollow) sphere(sphereRadius-wallWidth);
+         }
+     }
+}
+
 module acorn (thread_pitch = 3.0,
              thread_size = 2.5,
              thread_height = 3.5,
@@ -32,6 +44,8 @@ module acorn (thread_pitch = 3.0,
      thread_tooth_height = (thread_tooth_height == AUTO_CALCULATE) ? ((thread_pitch - 0.4 > 0) ? thread_pitch - 0.4 : thread_pitch) : thread_tooth_height;
      base_height = (base_height == AUTO_CALCULATE) ? inner_d : base_height;
 
+     echo ("outer_d = ", outer_d);
+
 
      module acorn_thread (outer_d = outer_d, internal = false, ring = true) {
          if (internal) {
@@ -74,27 +88,38 @@ module acorn (thread_pitch = 3.0,
      }
 
 
-     module cap_keychain_holes (hole_d=3, spacing=15 /*12*/) {
+     module cap_keychain_holes (hole_d=3, spacing=12) {
          h=100;
          translate ([-spacing/2, 0, 0]) cylinder (d=hole_d, h=h, $fs=0.1);
          translate ([spacing/2, 0, 0]) cylinder (d=hole_d, h=h, $fs=0.1);
      }
 
-     module cap () {
-         scale_f = outer_d / 171;
+     module cap (model="3D/RaleighAcorn_Filled_simple.stl", native_d = 168) {
+         scale_f = outer_d / native_d; //168;
+         echo ("scale_f = ", scale_f);
          difference () {
               scale ([scale_f, scale_f, scale_f]) {
                    difference () {
                         union () {
-                             translate ([0, 0, -1]) import ("Acorn_Unthreaded/cap_reduced.stl");
+                             translate ([0, 0, -1]) import (model);
                              echo ("h = ", thread_height/scale_f);
-                             cylinder (d = 180, h=thread_height/scale_f);
                         }
+                        // todo: only makes sense for RaleighAcorn, fix in original model...
                         translate ([0, 0, -0.51]) cube ([200, 200, 1], center=true);
                    }
               }
               if (keychain) cap_keychain_holes ();
-              acorn_thread (internal = true, ring = false);
+
+              // hollow it out (make parametric later, this is pretty ugly now, but calc seems to be ok for RaleighAcorn)
+              diam_to_height_ratio = 3.2;
+              dome_h = outer_d / diam_to_height_ratio - thread_height;
+              echo ("dome_h = ", dome_h);
+              difference () {
+                   translate ([0, 0, thread_height-0.01]) dome (d=outer_d, h=dome_h);
+              }
+
+
+              translate ([0, 0, -0.01]) acorn_thread (internal = true, ring = false);
          }
      }
 
@@ -106,7 +131,7 @@ module acorn (thread_pitch = 3.0,
          if (contains ("body", acorn_parts))
               translate ([outer_d+10, 0, 0,])  nut ();
          if (contains ("cap", acorn_parts))
-              cap ();
+              cap (native_d=167);//model="3D/RaleighAcorn_ExaggeratedCap_Decimated.stl", native_d = 178);
          if (contains ("gasket", acorn_parts))
              translate ([-(outer_d+10), 0, 0,])  gasket ();
      }
@@ -114,7 +139,16 @@ module acorn (thread_pitch = 3.0,
      nuts ();
 }
 
-$fs = 1;
-$fa = 1;
+//$fs = 1;
+//$fa = 1;
 
-acorn ();
+acorn_parts = [ "cap"];
+
+//acorn ();
+huge_acorn ();
+
+module huge_acorn () {
+     acorn (inner_d=100, base_height=80,
+           thread_size=4, thread_pitch=4, thread_height=8,
+           keychain=false);
+}