chiark / gitweb /
poster-tube-lid: sloping bottom of catch tip
[reprap-play.git] / poster-tube-lid.scad
index d1debf9859d61a50bba95a9c527916981522e62c..d4f2ccf12318579e7b55fb54db6921b8dde39a83 100644 (file)
@@ -1,5 +1,7 @@
 // -*- C -*-
 
+include <funcs.scad>
+
 coarse = false;
 
 main_dia = 71.2 + 0.50 - 2.26;
@@ -75,18 +77,25 @@ sm_bolt_y_over = 0.5;
 
 sm_closure_cnr = 3.0;
 
-catch_stem_h = 3;
-catch_stem_len = 50;
-catch_stem_th = 3;
+catch_stalk_h = 5.0;
+catch_stalk_len = 50;
+catch_tip_th = 5;
+catch_head_th = 3;
+
+catch_pin_slop = 0.25; // each side, and above
+catch_pin_slop_x_extra = -0.55; // only on one side
+catch_stalk_above_gap = 1.5;
+catch_stalk_eff_bend_rad = catch_stalk_len * 0.75;
+
+catch_strap_width = 12;
+catch_stalk_base_width = catch_stalk_h;
 
 catch_knob_dia = 6;
-catch_knob_above_gap = 8;
-catch_pin_height = 7;
+catch_knob_above_gap = 5;
+catch_knob_height = 3.0;
 
-catch_stem_below_gap = 1.0;
-catch_stem_beside_gap = 2.0;
-catch_pin_gap = 0.5;
-catch_hook_slope = 0.15;
+catch_stalk_below_gap = 1.0;
+catch_stalk_beside_gap = 2.0;
 
 // calculated
 
@@ -141,47 +150,11 @@ smc_max_y = smc_bolt_y + sm_bolt_y_over
 smc_cnr_c_x = sm_bolt_shaft/2 - sm_closure_cnr
   + sm_bolt_head_thick/2 + smc_bolt_nut_eff_thick/2;
 
-catch_cr = catch_knob_dia/2 + catch_stem_beside_gap;
-catch_strap_width = sm_main_width;
+catch_cr = catch_knob_dia/2 + catch_stalk_beside_gap;
 catch_strap_thick = sm_main_thick;
-catch_stem_end_h = catch_stem_h;
-catch_pin_width = (rivet_entry_width * sm_inner_rad / bayo_nom_rad)
-                  - catch_pin_gap;
 
 echo("R ", sm_inner_rad, bayo_real_rad, bayo_nom_rad);
 
-cppy6 = -catch_strap_width/2;
-cppxC = 0.34 * sm_inner_rad * TAU;
-cppB = [ catch_pin_width/2,
-        cppy6
-        + catch_stem_below_gap
-        + catch_pin_height
-        + catch_knob_dia/2 ];
-cpp0 = [ 0,
-        cppB[1]
-        + catch_knob_dia
-        + catch_knob_above_gap ];
-cpp12 = cpp0 + [1,0] * (catch_pin_height * catch_hook_slope);
-cpp1 = cpp0 + [0,1] * catch_pin_height;
-cpp2 = cpp1 + [1,0] * catch_pin_width;
-cpp4 = cpp0 + [0,-1] * catch_stem_end_h;
-cpp3 = [ cpp2[0], cpp4[1] ];
-cpp5 = [ cpp0[0] - catch_stem_len,
-        -catch_stem_h ];
-cpp6 = [ cpp5[0], catch_cr ];
-cpp7 = cppB + [1,-1] * catch_knob_dia/2
-            + [ catch_stem_beside_gap, -catch_stem_below_gap ]
-            + [ 0, -catch_pin_height ]
-            + [-1,1] * catch_cr;
-cpp11 = cpp7 + [1,0] * catch_cr;
-cpp10 = [ cpp11[0], 0 - catch_cr ];
-cpp8 = cpp10 + [1,0] * catch_cr;
-cpp9 = cpp8 + [0,1] * catch_cr;
-cppC = [ cppxC, cpp9[1] ];
-cppA = [ -cppxC, 0 ];
-cppD = cppC + [0,-1] * catch_strap_width;
-cppE = [ cppA[0], cppD[1] ];
-
 $fs= coarse ? 2.5 : 0.5;
 $fa= coarse ? 5 : 1;
 
@@ -225,6 +198,62 @@ bayo_polygon = [ bayo_a,
 
 echo(bayo_polygon);
 
+// CATCH
+
+cppxC = 0.41 * sm_inner_rad * TAU;
+
+// catch pin
+
+cpp_adj = (bayo_n[0] - bayo_f[0]) * (1 - sm_inner_rad / bayo_nom_rad);
+// radius scaling due to nom and actual radius difference in
+// bayo entry construction
+
+cppa = bayo_f + [1,-1] * catch_pin_slop + [1,0] * cpp_adj;
+cppb = bayo_g + [1,-1] * catch_pin_slop + [1,0] * cpp_adj;
+cppd = [ bayo_n[0]
+        - catch_pin_slop - catch_pin_slop_x_extra,
+        -catch_stalk_above_gap ];
+cppi = [ cppa[0], cppd[1] ];
+cppc = [ cppd[0], cppb[1] ];
+cpph = cppd + [0,-1] * catch_stalk_h;
+cppe = cppd + [0,-1] * (catch_knob_above_gap + catch_knob_dia/2);
+cppf = [ cppa[0], cppe[1] ];
+cppg = [ cppa[0], cpph[1] ];
+cppB = 0.5 * (cppf + cppe);
+
+echo("RR", sm_inner_rad / bayo_nom_rad);
+
+// catch assembly depression below pin
+
+cppy6 = cppB[1] - (catch_knob_dia/2
+                  + (cppc[1] - cppd[1])
+                  + catch_stalk_below_gap);
+cpp7 = [ cppB[0], cppy6 + catch_cr ];
+cpp11 = cpp7 + [1,0] * catch_cr;
+cppy9 = cppy6 + catch_strap_width * 1/3;
+cpp9 = [ cpp7[0] + catch_cr * 2, cppy9 ];
+cpp8 = cpp9 + [0,-1] * catch_cr;
+cpp10 = cpp8 + [-1,0] * catch_cr;
+cppC = [ cppxC, cpp9[1] ];
+cppD = cppC + [0,-1] * catch_strap_width;
+
+// catch assembly stalk and so on
+
+catch_cr3 = catch_cr + catch_stalk_h;
+
+cppF = [ cppg[0] - catch_stalk_eff_bend_rad, cppd[1] ];
+cpp4 = [ cppg[0] - catch_stalk_len, cpph[1] ] + [1,-1] * catch_cr;
+cpp5 = [ cpp4[0], cppC[1] + catch_cr ];
+cpp2 = cpp5 + [-1,0] * (catch_cr * 2 + catch_stalk_base_width);
+cpp2r = cpp2 + [1,0] * catch_cr;
+cpp2d = cpp2 + [0,-1] * catch_cr;
+cpp3 = [ cpp2[0] + catch_cr + catch_cr3, cppd[1] - catch_cr3 ];
+cppA = [ -cppxC, cpp9[1] ];
+cppE = [ cppA[0], cppD[1] ];
+
+catch_assembly_dy = -cppy9 + catch_strap_width;
+
+
 module MainProfile(){
   main_cnr_pos = [ side_thick, top_z ] - [1,1]*main_cnr;
   difference(){
@@ -464,31 +493,32 @@ module ImplHeadCupTest(){ ////toplevel
       ImplHeadCup();
 }
 
-module SomeStrap(){
+module SomeStrap(width){
   // children(0) is to add, (1) subtract
   difference(){
     union(){
-      cylinder(r=sm_outer_rad, h=sm_main_width);
+      cylinder(r=sm_outer_rad, h=width);
       StrapMountProtrusion(smc_cnr_c_x + sm_closure_cnr,
                           smc_max_y,
-                          sm_closure_cnr);
+                          sm_closure_cnr,
+                          width);
       children(0);
     }
     translate([0,0,-1])
-      cylinder(r=sm_inner_rad, h=sm_main_width+2);
+      cylinder(r=sm_inner_rad, h=width+2);
     translate(smc_pos)
-      StrapMountBolt(10);
+      StrapMountBolt(10, width);
     translate(smc_pos)
       cube([ sm_bolt_tighten_allow, 40,100 ], center=true);
     children(1);
   }
 }
 
-module StrapMountBolt(l_delta){ ///toplevel
+module StrapMountBolt(l_delta, strap_width){ ///toplevel
   // positioned relative to smc_pos
   translate([(smc_bolt_nut_eff_thick - sm_bolt_head_thick)/2,
             smc_bolt_y,
-            sm_main_width/2]){
+            strap_width/2]){
     translate([ -sm_bolt_shaft/2-1, 0,0 ]){
       rotate([0,90,0]) cylinder(r= sm_bolt_dia/2, h= sm_bolt_shaft+2);
     }
@@ -502,9 +532,9 @@ module StrapMountBolt(l_delta){ ///toplevel
   }
 }
 
-module StrapMountProtrusion(half_x, max_y, cnr){
+module StrapMountProtrusion(half_x, max_y, cnr, width){
   translate(smc_pos){
-    linear_extrude(height=sm_main_width, convexity=10){
+    linear_extrude(height=width, convexity=10){
       hull(){
        for (m = [0,1]) mirror([m,0,0]) {
          translate([-(half_x - cnr), max_y - cnr])
@@ -518,7 +548,7 @@ module StrapMountProtrusion(half_x, max_y, cnr){
 }
 
 module StrapMount(){ ////toplevel
-  SomeStrap(){
+  SomeStrap(sm_main_width){
     rotate([0,0,180]){
       StrapMountProtrusion(strap_hoop_inside/2 + strap_hoop_thick,
                           strap_hoop_thick,
@@ -532,69 +562,119 @@ module StrapMount(){ ////toplevel
   }
 }
 
-module CatchCoreProfile(){ ////toplevel
-  hull(){
-    translate(cppB) circle(r= catch_knob_dia/2);
-    polygon([cpp4,
-            cppB,
-            cpp3]);
-  }
-  translate(cpp8)
-    circle(catch_cr);
-  polygon([
-          cpp4,
-          cppB,
-          cpp3,
-          cpp2,
-          cpp1,
-          cpp12,
-          ]);
+module CatchAssemblyCoreProfile(){
   difference(){
-    polygon([ cpp4,
-             cpp3,
-             cpp12,
-             cppA,
-             cppE,
-             cppD,
-             cppC,
-             cpp9,
-             cpp10,
-             cpp11,
-             cpp7,
-             cpp5,
-             ], convexity=10);
+    union(){
+      hull(){
+       translate(cpp3) circle(r= catch_cr3);
+       polygon([ cpp3,
+                 cpp2r,
+                 cpp5,
+                 cpph,
+                 cppd
+                 ]);
+      }
+      polygon([cppD,
+              cppC,
+              cpp9,
+              cpp10,
+              cpp11,
+              cpp4,
+              cpp2r,
+              cpp2d,
+              cppA,
+              cppE
+              ]);
+      translate(cpp8) circle(r= catch_cr);
+    }
     hull(){
+      translate(cpp4) circle(r= catch_cr);
+      translate(cpp5) circle(r= catch_cr);
       translate(cpp7) circle(r= catch_cr);
-      polygon([ cpp7,
-               cpp5,
-               cpp11 ]);
+      polygon([cpp4,
+              cppg,
+              cpph,
+              cpp10,
+              cpp11,
+              ]);
     }
-    hull(){
-      translate(cpp6) circle(catch_cr);
-      polygon([ cppA,
-               cpp0,
-               cpp1 ]);
+    translate(cpp2) circle(r= catch_cr);
+  }
+  // if cpp11 is above cpp10, the subtracted hull above
+  // can go down too far.  Ensure we do not cut off below cppy6.
+  polygon([ cppE,
+           cppD,
+           cpp9,
+           [ cpp9[0],            cppy6 ],
+           [ cpp7[0] - catch_cr, cppy6 ],
+           cpp2d
+           ]);
+}
+
+module CatchTipProfile(dy){
+  ddy = [0,dy];
+  intersection(){
+    translate(cppF){
+      difference(){
+       circle(r = dist2d(cppF, cppd));
+       //circle(r = dist2d(cppF, cppa));
+      }
     }
+    polygon([ cppa,
+             cppi + ddy,
+             cppd + ddy,
+             cppc,
+             cppb ]);
+  }
+}
+
+module CatchHeadProfile(){
+  polygon([ cppd,
+           cppd,
+           cppi,
+           cppf,
+           cppe,
+           cpph ]);
+}
+
+
+module CatchCore(){ /////toplevel
+  linear_extrude(height=catch_strap_thick, convexity=10)
+    CatchAssemblyCoreProfile();
+
+  hull(){
+    linear_extrude(height=catch_head_th, convexity=10)
+      CatchTipProfile(0);
+    linear_extrude(height=catch_tip_th, convexity=10)
+      CatchTipProfile(catch_tip_th - catch_head_th);
+  }
+
+  linear_extrude(height=catch_head_th, convexity=10)
+    CatchHeadProfile();
+
+  translate(concat(cppB,[0])) hull(){
+    translate([0,0, catch_knob_height + catch_head_th - catch_knob_dia/2])
+      sphere(r = catch_knob_dia/2);
+    cylinder(r = catch_knob_dia/2, h = 0.1);
   }
 }
 
 module CatchPreDistort(){ /////toplevel
   scale(100 / sm_inner_rad)
     rotate([90,0,0])
-    linear_extrude(height=catch_strap_thick, convexity=10)
-    CatchCoreProfile();
+    CatchCore();
 }
 
 module CatchAssembly(){ /////toplevel
-  rotate([0,0, -0.5 * (cpp1[0] + cpp2[0]) / sm_inner_rad * 360/TAU])
-    translate([0,0, catch_strap_width])
+  rotate([0,0, -(cppe[0] + cppB[0] + catch_pin_slop) / sm_inner_rad * 360/TAU])
+    translate([0,0, catch_assembly_dy])
     scale(sm_inner_rad / 100)
     import(str("poster-tube-lid,CatchPostDistort-fa",
               (coarse ? 20 : 3),
               ".stl"),
           convexity=20);
 
-  SomeStrap(){
+  SomeStrap(catch_strap_width){
     union(){ }
     union(){
       translate([-200, -200, -200])
@@ -605,8 +685,7 @@ module CatchAssembly(){ /////toplevel
 
 module CatchDemo(){ /////toplevel
   color("blue") translate([0,0,
-            -catch_strap_width
-            -cpp0[1]
+                          -catch_assembly_dy
             ])
     CatchAssembly();
   translate([0,0,+side_height
@@ -616,8 +695,7 @@ module CatchDemo(){ /////toplevel
 
 module CatchDemoS(){ /////toplevel
   color("blue") translate([0,0,
-            -catch_strap_width
-            -cpp0[1]
+            -catch_assembly_dy
             ])
     CatchAssembly();
   intersection(){
@@ -635,11 +713,12 @@ module CatchPinProfileDemo(){ /////toplevel
   echo("G ",
        cpp2[0] - cpp1[0],
        bayo_n[0] - bayo_e[0]);
-  color("blue") translate([-cpp2[0],
-                          -cpp2[1],
+  color("blue") translate([0,0,
                           +1,
-            ])
-    CatchCoreProfile();
+            ]) {
+    CatchAssemblyCoreProfile();
+    CatchHeadProfile();
+  }
   polygon(bayo_polygon, convexity=10);
 }