chiark / gitweb /
fairphone-case: fix CodeBase_*flip
[reprap-play.git] / fairphone-case.scad
1 // -*- C -*-
2
3 phone_height = 146.5;
4 phone_width = 76.75;
5
6 phone_cnr_rad = 4.0;
7
8 phone_edge_thick = 9.0;
9 phone_total_thick = 12.0;
10 phone_backside_slope = 1.0; // larger means shallower
11
12 case_th_bottom = 2;
13 case_th_lid = 2;
14 case_th_side = 2;
15 case_th_lip = 1.2;
16
17 case_lip = 2;
18
19 $fa = 5;
20 $fs = 0.1;
21
22 // calculated
23
24 phone_backside_slope_thick = phone_total_thick - phone_edge_thick;
25
26 //lid_lip_overlap_width xxx bad name = ;
27 //lid_lip_inner_slope = [ 5, 5 ]; // xxx
28
29 epp0 = [0,0];
30 epp1 = [0, -phone_edge_thick];
31 epp2 = epp1 + phone_backside_slope_thick * [ phone_backside_slope, -1 ];
32 epp3 = epp2 + [10, 0];
33 epp4 = epp0 - [1,0] * (case_th_side - case_th_lip);
34 epp5 = epp0 + [1,0] * case_lip;
35 epp6 = epp5 + [0,1] * case_th_lip;
36
37 module rectfromto(a,b) { translate(a) square(b - a); }
38 module circleat(c,r) { translate(c) circle(r); }
39
40 module EdgeProfile(){
41   difference(){
42     hull(){
43       circleat(epp3, r=case_th_bottom);
44       circleat(epp2, r=case_th_bottom);
45       circleat(epp1, r=case_th_side);
46       circleat(epp4, r=case_th_lip);
47       rectfromto(epp0, epp6);
48     }
49     polygon([ epp6 + [10,10],
50               epp6 + [0,10],
51               epp5,
52               epp0,
53               epp1,
54               epp2,
55               epp3 + [10,0] ]);
56   }
57 }
58
59 module CaseBase_rhsflip(rhs) {
60   translate([phone_width/2, 0, 0])
61     mirror([rhs,0,0])
62     translate([-phone_width/2, 0, 0])
63     children();
64 }
65
66 module CaseBase_botflip(bot) {
67   translate([0, -phone_height/2, 0])
68     mirror([0, bot, 0])
69     translate([0, phone_height/2, 0])
70     children();
71 }  
72
73 module CaseBase(){
74   for (rhs=[0,1]) {
75     CaseBase_rhsflip(rhs){
76       translate([0, -phone_cnr_rad, 0])
77         rotate([90,0,0])
78         linear_extrude(height = phone_height - phone_cnr_rad*2)
79         EdgeProfile();
80     }
81   }
82   for (rhs=[0,1]) {
83     CaseBase_rhsflip(rhs){
84       translate([+1,-1] * phone_cnr_rad)
85         intersection(){
86           rotate_extrude()
87             intersection(){
88               mirror([1,0,0])
89                 translate([-1,0] * phone_cnr_rad)
90                 EdgeProfile();
91               rectfromto([0,-20],[10,20]);
92             }
93           translate([-10, 0, -20] + 0.01 * [+1,-1, 0] )
94             cube([10,10,40]);
95         }
96     }
97   }
98   for (bot=[0,1]) {
99     CaseBase_botflip(bot){
100       translate([ phone_width - phone_cnr_rad, 0,0 ])
101         rotate([90,0,-90])
102         linear_extrude(height = phone_width - phone_cnr_rad*2)
103         EdgeProfile();
104     }
105   }
106 }
107
108 //EdgeProfile();
109 CaseBase();