chiark / gitweb /
fairphone-case: wip lanyard, proper profiles
[reprap-play.git] / brompton-computer-guard.scad
1 // -*- C -*-
2
3 arch_height = 18;
4 arch_width = 75;
5 end_width = 25;
6
7 arch_thick = 4;
8
9 arch_breadth = 25;
10
11 hole_dia = 4 + 0.5;
12
13 pbase_tab = 12;
14 pbase_thick = 4;
15
16 // computed
17
18 arch_alpha = atan(arch_height / (arch_width/2));
19 arch_beta = 2*arch_alpha;
20 echo(arch_alpha,arch_beta);
21 arch_in_rad = arch_width/2 / sin(arch_beta);
22 arch_to_chord = arch_in_rad * cos(arch_beta);
23
24 inner_pbase_thick = 8;
25 echo(inner_pbase_thick);
26
27 inner_pbase_rad = arch_in_rad * 2;
28
29 end_thick = arch_thick;
30
31 holes = [[[  5  , 5  ], [16  , 21]], // left
32          [[ 18.5, 4.5], [ 4.5, 21]]]; // right
33
34 module ArchCircle(rad){
35   translate([0,-arch_to_chord])
36     circle(rad, $fa=0.1);
37 }
38
39 module ArchProfile(pbase){
40   intersection(){
41     translate([-200,0])
42       square([400,200]);
43     difference(){
44       union(){
45         ArchCircle(arch_in_rad + arch_thick);
46         for (m=[0,1])
47           mirror([m,0])
48             translate([arch_width/2,0])
49             multmatrix([[1,pbase ? -0.75 : 0,0,0],
50                         [0,1,0,0],
51                         [0,0,1,0],
52                         [0,0,0,1]])
53             square([end_width, pbase ? pbase_tab : end_thick]);
54       }
55     }
56   }
57 }
58
59 module Holes(){
60   for (m=[0,1]) {
61     mirror([1-m,0])
62       translate([arch_width/2, 50, 0])
63       rotate([90,0,0])
64       for (h=holes[m]) {
65         translate(h)
66           cylinder(r=hole_dia/2, h=100, $fn=20);
67       }
68   }
69 }
70
71 module MainCutout(){
72   ArchCircle(arch_in_rad);
73 }
74
75 module Arch(){
76   difference(){
77     rotate([0,0,180]){
78       linear_extrude(height=arch_breadth) {
79         difference(){
80           ArchProfile(false);
81           MainCutout();
82         }
83       }
84       difference(){
85         translate([0,0, arch_breadth - pbase_thick])
86         linear_extrude(height=pbase_thick){
87           difference(){
88             hull(){
89               ArchProfile(true);
90               ArchProfile(false);
91             }
92             intersection(){
93               MainCutout();
94               translate([0, -inner_pbase_thick
95                          - (inner_pbase_rad - arch_in_rad)])
96                 ArchCircle(inner_pbase_rad);
97             }
98           }
99         }
100       }
101     }
102     Holes();
103   }
104 }
105
106 rotate([0,0,45]) translate([0,0,arch_breadth]) rotate([0,180,0]) Arch();