chiark / gitweb /
simplephone-case: wip rounding
[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          2.5,
13          ];
14
15 btn_x = 58;
16 btn_dia = 13;
17 btn_yprop = 0.23;
18
19 abtn_x = 45;
20 abtn_sz = [ 11, 13 ];
21
22 screen_xbot = 67;
23 screen_sz = [ 45, 46 ];
24
25 thumb_xbot = 90;
26 thumb_dia = 25;
27
28 rail_ysz = 2.5;
29 rail_zsz = 2.5;
30
31 case_x_less = 0; //case_x_less = 10;
32
33 inner_cnr_rad = 2.0;
34
35 // calculated
36
37 ym = psz[1]/2;
38
39 module RoundedProfile(sz, cnr_rad){
40   hull(){
41     for (x=[ cnr_rad, sz[0]-cnr_rad ])
42       for (y=[ cnr_rad, sz[1]-cnr_rad ])
43         translate([x,y])
44           circle(r= cnr_rad, $fn=20);
45   }
46 }
47
48 module RoundedCube(sz, cnr_rad){
49   hull(){
50     for (x=[ cnr_rad, sz[0]-cnr_rad ])
51       for (y=[ cnr_rad, sz[1]-cnr_rad ])
52         for (z=[ cnr_rad, sz[2]-cnr_rad ])
53           translate([x,y,z])
54             sphere(r= cnr_rad, $fn=20);
55   }
56 }
57
58 module Case(){
59   difference(){
60     mirror([1,0,0])
61       translate(-thick)
62       cube(psz
63            + 2*thick
64            - [1,0,0] * (thick[0])
65            - [case_x_less, 0, 0]);
66
67     for (yp= [ btn_yprop, 1-btn_yprop ])
68       translate([ -btn_x,
69                   yp * psz[1],
70                   0.5 * psz[2] ])
71         cylinder(r= btn_dia/2, h=20);
72
73     translate([ -abtn_x,
74                 btn_yprop * psz[1],
75                 psz[2] ])
76       cube(concat(abtn_sz, [ thick[2]*3 ]), center=true);
77
78     mirror([1,0,0])
79       translate([ screen_xbot,
80                   (psz[1] - screen_sz[1])/2,
81                   psz[2]-1 ])
82       cube(concat(screen_sz, [ thick[2]+2 ]));
83
84     hull(){
85       for (x=[ thumb_xbot+thumb_dia/2, psz[0]+10 ])
86         translate([ -x,
87                     ym,
88                     -thick[2]-1 ])
89           cylinder(r= thumb_dia/2,
90                    h= thick[2] + 2,
91                    $fn= 20);
92     }
93
94     mirror([1,0,0])
95       difference(){
96         cube(psz + [1,0,0]);
97
98         for (m=[0,1]) {
99           translate([0,ym,0]) mirror([0,m,0]) translate([0,-ym,0])
100             translate([-1,-1, psz[2]-rail_zsz])
101             cube([psz[0]+1, rail_ysz+1, rail_zsz+1]);
102         }
103       }
104   }
105 }
106
107 Case();
108 //RoundedCube(psz, inner_cnr_rad);