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