chiark / gitweb /
nook-case: edge ledge
[reprap-play.git] / nook-case.scad
1 // -*- C -*-
2
3 include <utils.scad>
4
5 nook_th = 12.41 + 0.50 - 1.50;
6 nook_w = 127.12 + 0.75 - .95;
7 nook_h = 123.44 + 21.88 + 21.05 + 0.75 - 1.90;
8
9 edge_ledge_w = 9.60;
10 edge_ledge_h = 2.44;
11 edge_ledge_inc_ang = 10; // degrees
12
13 usb_w = 14.5;
14 usb_below = 1.5;
15
16 open_recess_w = 12.5;
17 open_recess_h = 2.5;
18
19 nook_cnr_rad = 10;
20
21 case_th = 2.5;
22 ledge_w = 4;
23 tape_th = 1.75;
24 tape_inside = 2.0;
25
26 gap = 0.5 * [1,1];
27
28 tape_w = 15;
29
30 test_pillar = 4;
31
32 engage_l0 = 10;
33 engage_l1 = 10;
34 engage_l2 = 3;
35
36 tooth_inward = gap[0] * 1.0;
37 tooth_x = nook_w * 1/6;
38 tooth_w = 15;
39
40 $test = false;
41
42 $fa = $test ? 10 : 3;
43 $fs = $test ? 0.1 : 1;
44
45 // calculated
46
47 tooth_height = nook_th;
48 ledge_h = case_th;
49 lid_th = case_th;
50 tooth_th = case_th;
51
52 spp0 = [0,0];
53 spp1 = spp0 + case_th * [-1,0];
54 spp9 = spp0 + ledge_h * [0,-1];
55 spp8 = spp9 + nook_th * [0,-1];
56 spp7 = spp8 + case_th * [-1,-1];
57
58 spp11y = spp1[1] - tape_th;
59 spp4y  = 0.5 * (spp0[1] + spp7[1]);
60 spp3y = spp4y + tape_inside/2;  spp5y = spp4y - tape_inside/2;
61 spp2y = spp3y + tape_th;        spp6y = spp5y - tape_th;
62
63 spp20 = spp8 + nook_cnr_rad * [1,0];
64 spp20x = spp20[0];
65
66 tppA = spp0 + gap;
67 tppB = spp1 + [0, gap[1]];
68 tppC = tppB + lid_th * [0,1];
69 tppD = [ spp20x, tppC[1] ];
70 tppE = [ spp20x, tppB[1] ];
71 tppF = tppA + ledge_w * [1,0];
72 tppG = tppF + ledge_h * [0,-1];
73 tppH = [ tppA[0], tppG[1] ];
74
75 tppJx = tppA[0] + tape_th;
76
77 tppK = [ tppC[0], tppG[1] ];
78 spp31 = tppK - [0, gap[1]];
79 spp30 = [ spp8[0], spp31[1] ];
80
81 nom_cnr = 0.5 * [nook_w, nook_h, 0] - nook_cnr_rad * [1,1,0];
82
83 etxa = nom_cnr[0] - engage_l2;
84 etxb = etxa - engage_l1;
85 etxc = -(nom_cnr[0] - engage_l2);
86
87 tapa = nom_cnr[1] - engage_l2;
88 tapb = tapa - tape_w;
89
90 opra = nom_cnr[1] - engage_l2;
91 oprb = opra - open_recess_w;
92
93 tppS = tppB + [-gap[0], 0];
94 tppP = [ tppS[0] - tooth_th, tppC[1] ];
95 tppQ = tppP + tooth_height * [0,-1] + tooth_inward * [1,0];
96 tppR = [ tppS[0] + tooth_inward, tppQ[1] ];
97 tppM = (tppQ + tppR) * 0.5 + tooth_th * 0.5 * [0,1];
98
99 edge_ledge_rad = edge_ledge_h;
100
101 module RightSideMainProfile() {
102   rectfromto(spp7, spp0);
103   rectfromto(spp7, spp20);
104   EdgeLedgeProfile();
105 }
106
107 module LeftSideMainProfile() {
108   rectfromto(spp7, spp30);
109   rectfromto(spp7, spp20);
110   EdgeLedgeProfile();
111 }
112
113 module EdgeLedgeProfile() {
114   intersection(){
115     hull(){
116       for (t=[[0,0], [-20,0], [0,-10]]) {
117         translate(spp8
118                   + [edge_ledge_w, edge_ledge_h]
119                   + edge_ledge_rad * [ -sin(edge_ledge_inc_ang),
120                                        -cos(edge_ledge_inc_ang) ]
121                   + t)
122           circle(edge_ledge_rad);
123       }
124     }
125     translate(spp7)
126       square(30);
127   }
128 }
129
130 module TopTapeCutout() {
131   polygon([ tppA,
132             tppA + [-40, 0],
133             tppG + [-40,-1],
134             [ tppJx, tppH[1]-1 ],
135             [ tppJx, tppC[1]+1 ],
136             [ tppA[0], tppC[1]+1 ]]);
137 }
138
139 module RightTopMainProfile() {
140   l = [ tppA, tppB, tppC, tppD, tppE, tppF, tppG, tppH ];
141   polygon(l);
142 }
143
144 module LeftTopMainProfile() {
145   l = [ tppC, tppD, tppE, tppF, tppG, tppK ];
146   polygon(l);
147 }
148
149 module SideTapeCutout1(y0,y1) {
150   rectfromto([ spp7[0]-1, y0 ],
151              [ spp8[0]+1, y1 ]);
152 }
153
154 module SideTapeCutout() {
155   SideTapeCutout1(spp6y, spp5y);
156   SideTapeCutout1(spp3y, spp2y);
157   SideTapeCutout1(spp3y, spp2y);
158   SideTapeCutout1(spp11y, spp1[1] + 1); // obsolete I think
159 }
160
161 module ToothProfile(){
162   polygon([tppA,
163            tppB,
164            tppS + [-0.1,0],
165            tppP,
166            tppC]);
167   hull(){
168     polygon([tppP,
169              tppM,
170              tppS]);
171     translate(tppM)
172       circle(r= tooth_th/2);
173   }
174 }
175
176 module Demo(){ ////toplevel
177   translate([-1,0,0]) {
178     translate([0,0,-2]) LeftSideMainProfile(); 
179     translate([0,0,-2]) color("yellow") LeftTopMainProfile();
180     color("red") difference(){
181       LeftSideMainProfile();
182       SideTapeCutout();
183     }
184     translate([0,0,-4]) color("brown") EdgeLedgeProfile();
185     translate(concat(spp8 + [edge_ledge_w, edge_ledge_h], [2]))
186       rotate(-edge_ledge_inc_ang) {
187       color("blue") square(3);
188       color("lightblue") mirror([1,0]) square(3);
189     }
190   }
191   translate([0,0,0]) color("purple") difference(){
192     LeftTopMainProfile();
193     TopTapeCutout();
194   }
195   translate([nook_cnr_rad*2 + 5, 0,0]) mirror([1,0,0]) {
196     color("red") RightSideMainProfile();
197     color("purple") RightTopMainProfile();
198     color("grey") translate([0,0,-2]) ToothProfile();
199   }
200   //%SideTapeCutout();
201 }
202
203 module FaceCore(z0,z1, extra_left, extra_right){
204   difference(){
205     for (mx=[0,1]) mirror([mx,0,0]) {
206         for (my=[0,1]) mirror([0,my,0]) {
207             translate(-nom_cnr) {
208               rotate_extrude(angle=90, convexity=10) {
209                 intersection(){
210                   translate(-[1,0,0] * nook_cnr_rad)
211                     children(mx);
212                   rectfromto([-100,-100], [0,100]);
213                 }
214               }
215             }
216           }
217         translate([nook_w/2, 0,0])
218           linextr_y_xz(-nom_cnr[1]-0.1, nom_cnr[1]+0.1)
219           children(1-mx);
220       }
221     for (my=[0,1]) mirror([0,my,0]) {
222         translate([-nook_w/2, 0,0])
223           mirror([1,0,0])
224           linextr_y_xz(tapb, tapa)
225           children(2);
226       }
227   }
228   for (my=[0,1]) mirror([0,my,0]) {
229       translate([0, -nook_h/2, 0]) {
230         linextr_x_yz(-nom_cnr[0]-0.1,    etxc + extra_left)  children(0);
231         linextr_x_yz(etxc - extra_right, etxb + extra_right) children(1);
232         linextr_x_yz(etxb - extra_left,  etxa + extra_left)  children(0);
233         linextr_x_yz(etxa - extra_right, nom_cnr[0]+0.1)     children(1);
234       }
235     }
236   if (!$test) {
237     linextr(z0,z1)
238       rectfromto(-nom_cnr, nom_cnr);
239   }
240 }
241
242 module Base(){ ////toplevel
243   difference(){
244     FaceCore(spp7[1],spp8[1], 0.3, 0) {
245       LeftSideMainProfile();
246       RightSideMainProfile();
247       SideTapeCutout();
248     }
249     translate([0, -nook_h/2, 0])
250       mirror([0,1,0])
251       linextr_x_yz(-usb_w/2, usb_w/2)
252       rectfromto(spp8 + [-40, usb_below], [40, 40]);
253 /*
254     translate([nook_w/2, 0, 0])
255       linextr_y_xz(oprb, opra)
256       translate(spp0)
257       rectfromto([-40, -open_recess_h], [40, 1]);
258 */
259   }
260 }
261
262 module Top(){ ////toplevel
263   FaceCore(tppE[1],tppD[1], -gap[0], gap[0] + 0.3) {
264     LeftTopMainProfile();
265     RightTopMainProfile();
266     TopTapeCutout();
267   }
268   translate([tooth_x, nook_h/2, 0])
269     linextr_x_yz(-tooth_w/2, +tooth_w/2)
270     mirror([1,0])
271     ToothProfile();
272 }
273 module TopPrint(){ ////toplevel
274   rotate([0,0,90]) rotate([180,0,0]) Top();
275 }
276 module BasePrint(){ ////toplevel
277   rotate([0,0,90]) Base();
278 }
279
280 module TestExtrude(){
281   difference(){
282     linextr_y_xz(-test_pillar, tape_w+test_pillar) children(0);
283     linextr_y_xz(           0, tape_w            ) children(1);
284   }
285 }
286
287 module BaseTestRest(){ ////toplevel
288   cube([30,15, spp8[1]-spp7[1]]);
289 }
290
291 module Demo3(){ ////toplevel
292   color("purple") Top();
293   color("red") Base();
294 }
295
296 module TestSide(){ ////toplevel
297   TestExtrude() { LeftSideMainProfile(); SideTapeCutout(); }
298 }
299
300 module TestTop(){ ////toplevel
301   TestExtrude() { LeftTopMainProfile(); TopTapeCutout(); }
302 }
303 module TestTopPrint(){ ////toplevel
304   rotate([180,0,0]) TestTop();
305 }