chiark / gitweb /
cliphook wip
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 26 Aug 2012 16:38:09 +0000 (17:38 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 26 Aug 2012 16:38:09 +0000 (17:38 +0100)
cliphook.scad

index de9c4ae..87787d8 100644 (file)
@@ -1,30 +1,32 @@
 
-tau = 6.283;
-function rads2degs(rads) = rads * 360/tau;
-
 function ClipHook_r2(w,g,l,ye,k) = w/2 + g + w/2;
-function ClipHook_r3(w,g,l,ye,k) = k * ClipHook_r2(w,g,l,ye,k);
-function ClipHook_yce(w,g,l,ye,k) = g/2 + w + g + w/2 - ClipHook_r3(w,g,l,ye,k);
+function ClipHook_r3(w,g,l,ye,k) = k * (ClipHook_r2(w,g,l,ye,k) + w + g);
+function ClipHook_yd(w,g,l,ye,k) = g/2 + w + g + w/2 - ClipHook_r3(w,g,l,ye,k);
 function ClipHook_xe(w,g,l,ye,k) =
+        l*1.5 + w +
        sqrt(pow( ClipHook_r3(w,g,l,ye,k),      2) -
-            pow( ClipHook_yce(w,g,l,ye,k) + ye, 2));
+            pow( ClipHook_yd(w,g,l,ye,k) + ye, 2));
 
-module ClipHook(w=1.2, g=0.2, l=0.0, ye=0, k=3.0, h=3.5) {
+module ClipHook_2D(w,g,l,ye,k,h) {
   r2 =  ClipHook_r2(w,g,l,ye,k);
   r3 =  ClipHook_r3(w,g,l,ye,k);
-  yce = ClipHook_yce(w,g,l,ye,k);
+  yd =  ClipHook_yd(w,g,l,ye,k);
   xe =  ClipHook_xe(w,g,l,ye,k);
 
+  xd = l*1.5 + w;
   xc = -l/2;
   yc = g/w + w/2;
 
+  alpha = atan2((xe-xd)/r3, (ye-yd)/r3);
+
   echo("ClipHook(w g l ye k h) ", w, g, l, ye, k, h);
-  echo("ClipHook r2 r3 yce xe =", r2, r3, yce, xe);
+  echo("ClipHook r2 r3 xd yd xe =", r2,r3, xd,yd, xe);
 
   $fn = 20;
 
   module jcirc(x,y) { translate([x,y,0]) circle(r=w/2); }
-  module jarc(cx,cy,r,a1=0,a2=tau) {
+  module jbox(y,x1,x2) { translate([x1,y-w/2,0]) square(size=[x2-x1, w]); }
+  module jarc(cx,cy,r,a1=0,a2=360) {
     astep = (a2-a1)/6;
     size = 5*(r+w/2);
     translate([cx,cy,0]) {
@@ -34,12 +36,12 @@ module ClipHook(w=1.2, g=0.2, l=0.0, ye=0, k=3.0, h=3.5) {
                translate([0,0,-1])
                        circle(r=r-w/2, h=h+2);
        }
-       scale(size,size) {
+       scale(size) {
          for (ai=[0:4]) {
-           echo(" jarc ", a1,a2, astep, ai, rads2degs(a1 + astep*ai) );
-           rotate(rads2degs(a1 + astep*ai)) {
+           echo(" jarc ", a1,a2, astep, ai, a1 + astep*ai );
+           rotate(a1 + astep*ai) {
              polygon([ [0,0], [1,0],
-                       [cos(rads2degs(astep*2)),sin(rads2degs(astep*2))] ]);
+                       [cos(astep*2),sin(astep*2)] ]);
            }
          }
        }
@@ -47,10 +49,21 @@ module ClipHook(w=1.2, g=0.2, l=0.0, ye=0, k=3.0, h=3.5) {
     }
   }
 
-  linear_extrude(height=h) {
-    jcirc(-xc, -yc);
-    jarc(xc, yc, r2, tau*0.25, tau*0.75);
-  }
+
+  jcirc(-xc, -yc);
+  jbox(-yc, xc, -xc);
+  jarc(xc, yc, r2, 90, 270);
+  jbox(yc+r2, xc, xd);
+  jarc(xd, yd, r3, 90-alpha, 90);
+  jcirc(xe,ye);
+}
+
+module ClipHook(w=1.2, g=0.2, l=0.0, ye=0, k=2.0, h=3.5, demo=false) {
+  linear_extrude(height=h)
+    ClipHook_2D(w,g,l,ye,k);
+  if (demo)
+    %linear_extrude(height=h)
+      translate([l+w,0,0]) rotate(180) ClipHook_2D(w,g,l,ye,k);
 }
 
-ClipHook(l=3);
+ClipHook(l=3, ye=1.5, k=1, demo=true);