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