chiark / gitweb /
sleepphone-cable-box: support trick, print orientation
[reprap-play.git] / brompton-computer-guard.scad
index 9620bdd..35b0a18 100644 (file)
 // -*- C -*-
 
-cover_ysz = 45;
-cover_len = 70;
+arch_height = 18;
+arch_width = 75;
+end_width = 25;
 
-attach_tube_dia = 18;
+arch_thick = 4;
 
-attach_cx = -15;
-attach_cdy = -5;
-attach_w = 25;
+arch_breadth = 25;
 
-attach_inrad = 25; ///
-attach_hole_dist = 5; ///
-attach_hole_dia = 4 + 0.5; ///
-attach_ang = 45;
+hole_dia = 4 + 0.5;
 
-// calculated
+pbase_tab = 12;
+pbase_thick = 4;
 
-cover_lcircle_r = cover_ysz / (1 + 1/sqrt(2));
+// computed
 
-base_len = cover_len - cover_lcircle_r;
+arch_alpha = atan(arch_height / (arch_width/2));
+arch_beta = 2*arch_alpha;
+echo(arch_alpha,arch_beta);
+arch_in_rad = arch_width/2 / sin(arch_beta);
+arch_to_chord = arch_in_rad * cos(arch_beta);
 
-attach_straight_len =
-  attach_inrad + attach_tube_dia + attach_hole_dist + attach_hole_dia/2
-  - attach_w / 2 + attach_hole_dist;
+inner_pbase_thick = 8;
+echo(inner_pbase_thick);
 
-module RearSideTemplate(){
-  polygon([[0.1,0],
-          [-base_len,0],
-          [-base_len,-cover_ysz],
-          [0.1,      -cover_ysz]]);
-  translate([-base_len, -cover_ysz + cover_lcircle_r])
-    circle(r=cover_lcircle_r);
+inner_pbase_rad = arch_in_rad * 2;
+
+end_thick = arch_thick;
+
+holes = [[[  5  , 5  ], [16  , 21]], // left
+        [[ 18.5, 4.5], [ 4.5, 21]]]; // right
+
+module ArchCircle(rad){
+  translate([0,-arch_to_chord])
+    circle(rad, $fa=0.1);
 }
 
-module AttachTemplate(){
-  hull(){
-    polygon([[0,   0],
-            [-0.1, 0],
-            [-0.1, -cover_ysz],
-            [0,    -cover_ysz]]);
-    translate([attach_cx, -attach_cdy]) rotate([0,0,-attach_ang]) {
-      polygon([[-attach_cx,          attach_w/2],
-              [0,                   -attach_w/2],
-              [attach_straight_len, -attach_w/2],
-              [attach_straight_len, attach_w/2]]);
-      translate([attach_straight_len, 0])
-       circle(r=attach_w/2);
+module ArchProfile(pbase){
+  intersection(){
+    translate([-200,0])
+      square([400,200]);
+    difference(){
+      union(){
+       ArchCircle(arch_in_rad + arch_thick);
+       for (m=[0,1])
+         mirror([m,0])
+           translate([arch_width/2,0])
+           multmatrix([[1,pbase ? -0.75 : 0,0,0],
+                       [0,1,0,0],
+                       [0,0,1,0],
+                       [0,0,0,1]])
+           square([end_width, pbase ? pbase_tab : end_thick]);
+      }
     }
   }
 }
 
-module Tube(){
-  %translate([attach_cx, -attach_cdy, -20]) {
-    rotate_extrude(convexity=10) {
-      translate([attach_inrad + attach_tube_dia/2, 0])
-       circle(r=attach_tube_dia/2);
-    }
+module Holes(){
+  for (m=[0,1]) {
+    mirror([1-m,0])
+      translate([arch_width/2, 50, 0])
+      rotate([90,0,0])
+      for (h=holes[m]) {
+       translate(h)
+         cylinder(r=hole_dia/2, h=100, $fn=20);
+      }
   }
 }
 
-module Bolts(){
-  %translate([0,0,-50]) linear_extrude(height=80) {
-    translate([attach_cx, -attach_cdy]) rotate([0,0,-attach_ang]) {
-      translate([attach_inrad - attach_hole_dist - attach_hole_dia/2, 0])
-       circle(r=attach_hole_dia/2, $fn=20);
-      translate([attach_inrad + attach_tube_dia
-                +attach_hole_dist + attach_hole_dia/2, 0])
-       circle(r=attach_hole_dia/2, $fn=20);
+module MainCutout(){
+  ArchCircle(arch_in_rad);
+}
+
+module Arch(){
+  difference(){
+    rotate([0,0,180]){
+      linear_extrude(height=arch_breadth) {
+       difference(){
+         ArchProfile(false);
+         MainCutout();
+       }
+      }
+      difference(){
+       translate([0,0, arch_breadth - pbase_thick])
+       linear_extrude(height=pbase_thick){
+         difference(){
+           hull(){
+             ArchProfile(true);
+             ArchProfile(false);
+           }
+           intersection(){
+             MainCutout();
+             translate([0, -inner_pbase_thick
+                        - (inner_pbase_rad - arch_in_rad)])
+               ArchCircle(inner_pbase_rad);
+           }
+         }
+       }
+      }
     }
+    Holes();
   }
 }
 
-color("blue") RearSideTemplate();
-AttachTemplate();
-Tube();
-Bolts();
+rotate([0,0,45]) translate([0,0,arch_breadth]) rotate([0,180,0]) Arch();