chiark / gitweb /
nook-case: wip, engage
[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 nook_cnr_rad = 10;
10
11 case_th = 2.5;
12 ledge_w = 4;
13 tape_th = 1.75;
14 tape_inside = 2.0;
15
16 gap = 0.5 * [1,1];
17
18 tape_w = 15;
19
20 test_pillar = 4;
21
22 $test = false;
23
24 engage_l0 = 10;
25 engage_l1 = 10;
26 engage_l2 = 3;
27
28 // calculated
29
30 ledge_h = case_th;
31 lid_th = case_th;
32
33 spp0 = [0,0];
34 spp1 = spp0 + case_th * [-1,0];
35 spp9 = spp0 + ledge_h * [0,-1];
36 spp8 = spp9 + nook_th * [0,-1];
37 spp7 = spp8 + case_th * [-1,-1];
38
39 spp11y = spp1[1] - tape_th;
40 spp4y  = 0.5 * (spp0[1] + spp7[1]);
41 spp3y = spp4y + tape_inside/2;  spp5y = spp4y - tape_inside/2;
42 spp2y = spp3y + tape_th;        spp6y = spp5y - tape_th;
43
44 spp20 = spp8 + nook_cnr_rad * [1,0];
45 spp20x = spp20[0];
46
47 tppA = spp0 + gap;
48 tppB = spp1 + [0, gap[1]];
49 tppC = tppB + lid_th * [0,1];
50 tppD = [ spp20x, tppC[1] ];
51 tppE = [ spp20x, tppB[1] ];
52 tppF = tppA + ledge_w * [1,0];
53 tppG = tppF + ledge_h * [0,-1];
54 tppH = [ tppA[0], tppG[1] ];
55
56 tppJx = tppA[0] + tape_th;
57
58 tppK = [ tppC[0], tppG[1] ];
59 spp31 = tppK - [0, gap[1]];
60 spp30 = [ spp8[0], spp31[1] ];
61
62 nom_cnr = 0.5 * [nook_w, nook_h, 0] - nook_cnr_rad * [1,1,0];
63
64 etxa = nom_cnr[0] - engage_l2;
65 etxb = etxa - engage_l1;
66 etxc = -(nom_cnr[0] - engage_l2);
67
68 module RightSideMainProfile() {
69   rectfromto(spp7, spp0);
70   rectfromto(spp7, spp20);
71 }
72
73 module LeftSideMainProfile() {
74   rectfromto(spp7, spp30);
75   rectfromto(spp7, spp20);
76 }
77
78 module TopTapeCutout() {
79   polygon([ tppA,
80             tppA + [-40, 0],
81             tppG + [-40,-1],
82             [ tppJx, tppH[1]-1 ],
83             [ tppJx, tppC[1]+1 ],
84             [ tppA[0], tppC[1]+1 ]]);
85 }
86
87 module RightTopMainProfile() {
88   l = [ tppA, tppB, tppC, tppD, tppE, tppF, tppG, tppH ];
89   polygon(l);
90 }
91
92 module LeftTopMainProfile() {
93   l = [ tppC, tppD, tppE, tppF, tppG, tppK ];
94   polygon(l);
95 }
96
97 module SideTapeCutout1(y0,y1) {
98   rectfromto([ spp7[0]-1, y0 ],
99              [ spp8[0]+1, y1 ]);
100 }
101
102 module SideTapeCutout() {
103   SideTapeCutout1(spp6y, spp5y);
104   SideTapeCutout1(spp3y, spp2y);
105   SideTapeCutout1(spp3y, spp2y);
106   SideTapeCutout1(spp11y, spp1[1] + 1);
107 }
108
109 module Demo(){ ////toplevel
110   translate([0,0,-2]) LeftSideMainProfile(); 
111   translate([0,0,-2]) color("yellow") LeftTopMainProfile();
112   color("red") difference(){
113     LeftSideMainProfile();
114     SideTapeCutout();
115   }
116   translate([0,0,0]) color("purple") difference(){
117     LeftTopMainProfile();
118     TopTapeCutout();
119   }
120   translate([nook_cnr_rad*2 + 5, 0,0]) mirror([1,0,0]) {
121     color("red") RightSideMainProfile();
122     color("purple") RightTopMainProfile();
123   }
124   //%SideTapeCutout();
125 }
126
127 module FaceCore(z0,z1, extra_left, extra_right){
128   for (mx=[0,1]) mirror([mx,0,0]) {
129       for (my=[0,1]) mirror([0,my,0]) {
130           translate(-nom_cnr) {
131             rotate_extrude(angle=90, convexity=10)
132               translate(-[1,0,0] * nook_cnr_rad)
133               children(mx);
134           }
135         }
136       translate([nook_w/2, 0,0])
137         linextr_y_xz(-nom_cnr[1]-0.1, nom_cnr[1]+0.1)
138         children(1-mx);
139     }
140   for (my=[0,1]) mirror([0,my,0]) {
141       translate([0, -nook_h/2, 0]) {
142         linextr_x_yz(-nom_cnr[0]-0.1,    etxc + extra_left)  children(0);
143         linextr_x_yz(etxc - extra_right, etxb + extra_right) children(1);
144         linextr_x_yz(etxb - extra_left,  etxa + extra_left)  children(0);
145         linextr_x_yz(etxa - extra_right, nom_cnr[0]+0.1)     children(1);
146       }
147     }
148   if (!$test) {
149     linextr(z0,z1)
150       rectfromto(-nom_cnr, nom_cnr);
151   }
152 }
153
154 module Base(){ ////toplevel
155   FaceCore(0,0, 0.3, 0) {
156     LeftSideMainProfile();
157     RightSideMainProfile();
158   }
159 }
160
161 module Top(){ ////toplevel
162   FaceCore(0,0, -gap[0], gap[0] + 0.3) {
163     LeftTopMainProfile();
164     RightTopMainProfile();
165   }
166 }
167
168 module TestExtrude(){
169   difference(){
170     linextr_y_xz(-test_pillar, tape_w+test_pillar) children(0);
171     linextr_y_xz(           0, tape_w            ) children(1);
172   }
173 }
174
175 module TestSide(){ ////toplevel
176   TestExtrude() { LeftSideMainProfile(); SideTapeCutout(); }
177 }
178
179 module TestTop(){ ////toplevel
180   TestExtrude() { LeftTopMainProfile(); TopTapeCutout(); }
181 }
182 module TestTopPrint(){ ////toplevel
183   rotate([180,0,0]) TestTop();
184 }