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