chiark / gitweb /
5da6f53549da4ffea6559c60f5dd83fe1225f3ff
[reprap-play.git] / simplephone-case.scad
1 // -*- C -*-
2
3 psz = [
4        120,
5        56 + 5,
6        15 + 3,
7        ];
8
9 thick = [
10          2,
11          2,
12          1.5,
13          ];
14
15 btn_x = 56.4;
16 btn_dia = 13;
17 btn_yprop = 0.23;
18
19 abtn_x = 43.15;
20 abtn_sz = [ 11, 13 ];
21
22 screen_xbot = 79;
23 screen_sz = [ 35, 46 ];
24
25 thumb_xbot = 90;
26 thumb_dia = 25;
27
28 vol_xbot = 87.4;
29 vol_xtop = 106.7;
30 vol_depth = 1.0;
31 vol_zsz = 9;
32 vol_zoff = 0;
33
34 rail_ysz = 2.5;
35 rail_zsz = 2.5;
36
37 case_x_less = 0; //case_x_less = 10;
38
39 inner_cnr_rad = 3.0;
40
41 // calculated
42
43 ym = psz[1]/2;
44 outer_cnr_rad = inner_cnr_rad + thick[2];
45
46 x_sliced = outer_cnr_rad * (1-sin(45));
47
48 module RoundedProfile(sz, cnr_rad){
49   hull(){
50     for (x=[ cnr_rad, sz[0]-cnr_rad ])
51       for (y=[ cnr_rad, sz[1]-cnr_rad ])
52         translate([x,y])
53           circle(r= cnr_rad, $fn=20);
54   }
55 }
56
57 module RoundedCube(sz, cnr_rad){
58   hull(){
59     for (x=[ cnr_rad, sz[0]-cnr_rad ])
60       for (y=[ cnr_rad, sz[1]-cnr_rad ])
61         for (z=[ cnr_rad, sz[2]-cnr_rad ])
62           translate([x,y,z])
63             sphere(r= cnr_rad, $fn=20);
64   }
65 }
66
67 module Case(){
68   difference(){
69     mirror([1,0,0])
70       translate(-thick +
71                 - [1,0,0] * x_sliced)
72       RoundedCube(psz
73                   + 2*thick
74                   - [1,0,0] * (thick[0])
75                   + [1,0,0] * (x_sliced)
76                   - [case_x_less, 0, 0],
77                   outer_cnr_rad);
78
79     for (yp= [ btn_yprop, 1-btn_yprop ])
80       translate([ -btn_x,
81                   yp * psz[1],
82                   0.5 * psz[2] ])
83         cylinder(r= btn_dia/2, h=20);
84
85     translate([ -abtn_x,
86                 btn_yprop * psz[1],
87                 psz[2] ])
88       cube(concat(abtn_sz, [ thick[2]*3 ]), center=true);
89
90     mirror([1,0,0])
91       translate([ screen_xbot,
92                   (psz[1] - screen_sz[1])/2,
93                   psz[2]-1 ])
94       cube(concat(screen_sz, [ thick[2]+2 ]));
95
96     hull(){
97       for (x=[ thumb_xbot+thumb_dia/2, psz[0]+10 ])
98         translate([ -x,
99                     ym,
100                     -thick[2]-1 ])
101           cylinder(r= thumb_dia/2,
102                    h= thick[2] + 2,
103                    $fn= 20);
104     }
105
106     mirror([1,0,0])
107       translate([ (vol_xbot+vol_xtop)/2, 0, psz[2]/2 + vol_zoff ])
108       cube([ vol_xtop-vol_xbot, vol_depth*2, vol_zsz ], center=true);
109
110     translate([ thick[0], -10, -10 ])
111       cube([ 10, psz[1]+20, psz[2]+20 ]);
112
113     //translate([-50,-50,10]) cube([100,100,100]);
114
115     mirror([1,0,0])
116       difference(){
117         RoundedCube(psz + [1,0,0],
118                     inner_cnr_rad);
119
120         if (0) for (m=[0,1]) {
121           translate([0,ym,0]) mirror([0,m,0]) translate([0,-ym,0])
122             translate([-1,-1, psz[2]-rail_zsz])
123             cube([psz[0]+1, rail_ysz+1, rail_zsz+1]);
124         }
125       }
126   }
127 }
128
129 Case();
130 //RoundedCube(psz, inner_cnr_rad);