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