chiark / gitweb /
ce8ad76b92aad21900835c04b326df6fb271f37d
[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, -phone_cnr_rad, 0])
61     mirror([rhs,0,0])
62     translate([-phone_width/2,0,0])
63     children();
64 }
65
66 module CaseBase(){
67   for (rhs=[0,1]) {
68     CaseBase_rhsflip(rhs){
69       rotate([90,0,0])
70         linear_extrude(height = phone_height - phone_cnr_rad)
71         EdgeProfile();
72     }
73   }
74   for (rhs=[0,1]) {
75     CaseBase_rhsflip(rhs){
76       translate([+1,0] * phone_cnr_rad)
77         intersection(){
78           rotate_extrude()
79             intersection(){
80               mirror([1,0,0])
81                 translate([-1,0] * phone_cnr_rad)
82                 EdgeProfile();
83               rectfromto([0,-20],[10,20]);
84             }
85           translate([-10, 0, -20] + 0.01 * [+1,-1, 0] )
86             cube([10,10,40]);
87         }
88     }
89   }
90   translate([ phone_width - phone_cnr_rad, 0,0 ])
91     rotate([90,0,-90])
92     linear_extrude(height = phone_width - phone_cnr_rad*2)
93     EdgeProfile();
94 }
95
96 //EdgeProfile();
97 CaseBase();