chiark / gitweb /
simplephone-case: TestLoop
[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 $screen = true;
49
50 module RoundedProfile(sz, cnr_rad){
51   hull(){
52     for (x=[ cnr_rad, sz[0]-cnr_rad ])
53       for (y=[ cnr_rad, sz[1]-cnr_rad ])
54         translate([x,y])
55           circle(r= cnr_rad, $fn=20);
56   }
57 }
58
59 module RoundedCube(sz, cnr_rad){
60   hull(){
61     for (x=[ cnr_rad, sz[0]-cnr_rad ])
62       for (y=[ cnr_rad, sz[1]-cnr_rad ])
63         for (z=[ cnr_rad, sz[2]-cnr_rad ])
64           translate([x,y,z])
65             sphere(r= cnr_rad, $fn=8);
66   }
67 }
68
69 module Case(){
70   difference(){
71     mirror([1,0,0])
72       translate(-thick +
73                 - [1,0,0] * x_sliced)
74       RoundedCube(psz
75                   + 2*thick
76                   - [1,0,0] * (thick[0])
77                   + [1,0,0] * (x_sliced)
78                   - [case_x_less, 0, 0],
79                   outer_cnr_rad);
80
81     for (yp= [ btn_yprop, 1-btn_yprop ])
82       translate([ -btn_x,
83                   yp * psz[1],
84                   0.5 * psz[2] ])
85         cylinder(r= btn_dia/2, h=20);
86
87     translate([ -abtn_x,
88                 btn_yprop * psz[1],
89                 psz[2] ])
90       cube(concat(abtn_sz, [ thick[2]*3 ]), center=true);
91
92     if ($screen)
93       mirror([1,0,0])
94       translate([ screen_xbot,
95                   (psz[1] - screen_sz[1])/2,
96                   psz[2]-1 ])
97       cube(concat(screen_sz, [ thick[2]+2 ]));
98
99     hull(){
100       for (x=[ thumb_xbot+thumb_dia/2, psz[0]+10 ])
101         translate([ -x,
102                     ym,
103                     -thick[2]-1 ])
104           cylinder(r= thumb_dia/2,
105                    h= thick[2] + 2,
106                    $fn= 20);
107     }
108
109     mirror([1,0,0])
110       translate([ (vol_xbot+vol_xtop)/2, 0, psz[2]/2 + vol_zoff ])
111       cube([ vol_xtop-vol_xbot, vol_depth*2, vol_zsz ], center=true);
112
113     translate([ thick[0], -10, -10 ])
114       cube([ 10, psz[1]+20, psz[2]+20 ]);
115
116     //translate([-50,-50,10]) cube([100,100,100]);
117
118     mirror([1,0,0])
119       difference(){
120         RoundedCube(psz + [1,0,0],
121                     inner_cnr_rad);
122
123         if (0) for (m=[0,1]) {
124           translate([0,ym,0]) mirror([0,m,0]) translate([0,-ym,0])
125             translate([-1,-1, psz[2]-rail_zsz])
126             cube([psz[0]+1, rail_ysz+1, rail_zsz+1]);
127         }
128       }
129   }
130 }
131
132 module TestLoop(){
133   intersection(){
134     Case($screen=false);
135     translate([ -vol_xbot, 0,0 ])
136       cube([ 4, 200,200 ], center=true);
137   }
138 }
139
140 Case();
141 //TestLoop();
142 //RoundedCube(psz, inner_cnr_rad);