chiark / gitweb /
95593388de4bb6fdd04dcdcdc7e0333e834dcdf0
[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 = 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 = 3.0;
34
35 // calculated
36
37 ym = psz[1]/2;
38 outer_cnr_rad = inner_cnr_rad + thick[2];
39
40 x_sliced = outer_cnr_rad * (1-sin(45));
41
42 module RoundedProfile(sz, cnr_rad){
43   hull(){
44     for (x=[ cnr_rad, sz[0]-cnr_rad ])
45       for (y=[ cnr_rad, sz[1]-cnr_rad ])
46         translate([x,y])
47           circle(r= cnr_rad, $fn=20);
48   }
49 }
50
51 module RoundedCube(sz, cnr_rad){
52   hull(){
53     for (x=[ cnr_rad, sz[0]-cnr_rad ])
54       for (y=[ cnr_rad, sz[1]-cnr_rad ])
55         for (z=[ cnr_rad, sz[2]-cnr_rad ])
56           translate([x,y,z])
57             sphere(r= cnr_rad, $fn=20);
58   }
59 }
60
61 module Case(){
62   difference(){
63     mirror([1,0,0])
64       translate(-thick +
65                 - [1,0,0] * x_sliced)
66       RoundedCube(psz
67                   + 2*thick
68                   - [1,0,0] * (thick[0])
69                   + [1,0,0] * (x_sliced)
70                   - [case_x_less, 0, 0],
71                   outer_cnr_rad);
72
73     for (yp= [ btn_yprop, 1-btn_yprop ])
74       translate([ -btn_x,
75                   yp * psz[1],
76                   0.5 * psz[2] ])
77         cylinder(r= btn_dia/2, h=20);
78
79     translate([ -abtn_x,
80                 btn_yprop * psz[1],
81                 psz[2] ])
82       cube(concat(abtn_sz, [ thick[2]*3 ]), center=true);
83
84     mirror([1,0,0])
85       translate([ screen_xbot,
86                   (psz[1] - screen_sz[1])/2,
87                   psz[2]-1 ])
88       cube(concat(screen_sz, [ thick[2]+2 ]));
89
90     hull(){
91       for (x=[ thumb_xbot+thumb_dia/2, psz[0]+10 ])
92         translate([ -x,
93                     ym,
94                     -thick[2]-1 ])
95           cylinder(r= thumb_dia/2,
96                    h= thick[2] + 2,
97                    $fn= 20);
98     }
99
100     translate([ thick[0], -10, -10 ])
101       cube([ 10, psz[1]+20, psz[2]+20 ]);
102
103     //translate([-50,-50,10]) cube([100,100,100]);
104
105     mirror([1,0,0])
106       difference(){
107         RoundedCube(psz + [1,0,0],
108                     inner_cnr_rad);
109
110         if (0) for (m=[0,1]) {
111           translate([0,ym,0]) mirror([0,m,0]) translate([0,-ym,0])
112             translate([-1,-1, psz[2]-rail_zsz])
113             cube([psz[0]+1, rail_ysz+1, rail_zsz+1]);
114         }
115       }
116   }
117 }
118
119 Case();
120 //RoundedCube(psz, inner_cnr_rad);