chiark / gitweb /
anke-gps-bracket: NestleCube: add NestleCubeBaseTest
[reprap-play.git] / anke-gps-bracket.scad
1 // -*- C -*-
2
3 include <doveclip.scad>
4
5 // Dimensions of the main GPS body
6 outerw = 120;
7 outerh =  75;
8 outert =  15;
9 outerbackbevel = 3;
10
11 // Dimensions for the holder
12 holder_outerw = outerw - 0.0;
13 holder_outerh = outerh + 0.0;
14 holder_outert = outert + 0.0;
15
16 // Dimensions for the model
17 model_outerw = outerw + 2.5;
18 model_outerh = outerh - 0.2;
19 model_outert = outert - 1.0;
20
21 // Dimensions of the bezel area round the edges
22 bezelw =    11 - 0.5;
23 bezelboth = 11 - 0.5;
24 bezeltoph =  7 - 0.5;
25
26 // Dimensions of the speaker at the back
27 spkrdia =  22;
28 spkr2bot = 19;
29 spkr2rhs = 25;
30
31 // Dimensions of the plug and wire
32 plugw =      12;
33 plugh =       9;
34 plug2bot =   11;
35 plug2lhs =   11;
36 plugtotald = 15;
37 pluggapd =    5;
38
39 // Dimensions of the hole in the tray
40 //   width and height (vertical) at the top
41 nestleh = 53;
42 nestlew = 60.9;
43 //   depths (back to front distance):
44 nestledl = 38.3 + 1.9;
45 nestledr = 42.2 + 1.7;
46 //   differences in width, depth, at bottom:
47 nestledwl = 3.0;
48 nestledwr = 2.4;
49 nestleddf = 4.0;
50 nestleddbl = 3.3;
51 nestleddbr = 3.6;
52
53 // Adjustment for the GPS attitude and position
54 gpsazimuth = 45;
55 gpselevation = 40;
56 gpsrightwardoffset = 5;
57 gpsrearwardoffset = 2;
58 gpsrightwardoffsetonbar = 0;
59
60 // Amount of wire protrusion to allow for
61 plugwiremoreh = 25;
62
63 // Slops and steps etc.
64 plugslop = 0.5;
65 plughstep = 1.5;
66 bodylhsrhsslop = 0.5;
67 holderhgap = 5;
68 holderbezelmore = 2;
69 nestlebevel = 2;
70
71 // Dimensions for strength only
72 screent = 1.0;
73 plugstrutw = 4;
74 plugstrutt = min(model_outert, 5);
75 nestledoveclipw = 20;
76 holderh = model_outerh * 0.5;
77 holderwallt = 2.5;
78 holderbackt = 2.8;
79 holderdccount = 2;
80 holderdoveclipl = 15;
81 chassish = 13;
82 chassist = 13;
83 nestlefloorh = 2.0;
84 nestleceilh = 2.0;
85 nestlewallmin = 3.0;
86
87 // Consequential values
88 holderdcw = DoveClipPairSane_width(holderdccount);
89
90 module GpsPlugPlug(slop){
91   effhslop = slop - plughstep;
92   effplugw = plugw + slop*2;
93   effplugh = plugh + effhslop*2;
94   translate([plug2lhs-slop, plug2bot-effhslop, -1])
95     cube([effplugw, effplugh, model_outert+2]);
96 }
97
98 module GpsBodyOuterBevel(len){
99   translate([0,-1,0]) {
100     rotate([-90,0,0]) {
101       linear_extrude(height=len+2) {
102         polygon([[-outerbackbevel, 0],
103                  [ 0, outerbackbevel],
104                  [outerbackbevel, 0],
105                  [ 0, -outerbackbevel]]);
106       }
107     }
108   }
109 }
110
111 module GpsBody() { ////toplevel
112   difference(){
113     union(){
114       difference(){
115         cube([model_outerw, model_outerh, model_outert]);
116         translate([bezelw, bezelboth, screent])
117           cube([model_outerw-bezelw*2,
118                 model_outerh-bezelboth-bezeltoph,
119                 model_outert]);
120         translate([model_outerw-spkr2rhs, spkr2bot, -1])
121           cylinder(r=spkrdia/2, h=model_outert+2);
122       }
123       translate([plug2lhs+plugw/2, plug2bot+plugh/2, 0])
124         cylinder(r=(plugw+plugh)/2, h=model_outert);
125       for (x=[plug2lhs-plugstrutw, plug2lhs+plugw])
126         translate([x, 0.1, 0])
127           cube([plugstrutw, model_outerh-0.2, plugstrutt-0.10]);
128     }
129     GpsPlugPlug(0);
130     for (x=[0,model_outerw]) translate([x,0,0]) GpsBodyOuterBevel(model_outerh);
131     for (y=[0,model_outerh]) translate([0,y,0])
132       rotate([0,0,-90]) GpsBodyOuterBevel(model_outerw);
133   }
134 }
135
136 module GpsPlug() {
137   plugwireh = plug2bot + plugwiremoreh;
138   translate([-plugslop,0,0]) GpsPlugPlug(-plugslop);
139   mirror([0,0,1]) translate([plug2lhs, plug2bot, 0]) {
140     cube([plugw, plugh, plugtotald-0.05]);
141     translate([0, -plugwireh, pluggapd])
142       cube([plugw, plugwireh+0.05, plugtotald-pluggapd]);
143   }
144 }
145
146 lhsteethu = 2;
147
148 module GpsLHSMask(xslop=0){
149   translate([plug2lhs + plugw+plugh+plugstrutw,
150              0,
151              -50]) {
152     for (iter=[-100/lhsteethu : 100/lhsteethu]) {
153       translate([0, iter*lhsteethu*2, 0]) {
154         linear_extrude(height=100) {
155           polygon([[-300,     0],
156                    [   0,     0],
157                    [lhsteethu,lhsteethu],
158                    [   0,     lhsteethu*2],
159                    [-300,     lhsteethu*2+0.1]]);
160         }
161       }
162     }
163   }
164 }
165
166 module GpsAssembled(){ ////toplevel
167   GpsBody();
168   GpsPlug();
169 }
170
171 module GpsBodyLT(){
172   intersection(){
173     GpsBody();
174     GpsLHSMask();
175   }
176 }
177
178 module GpsBodyRT(){
179   difference(){
180     GpsBody();
181     GpsLHSMask(bodylhsrhsslop);
182   }
183 }
184
185 module GpsPlugT(){ ////toplevel
186   rotate([0,-90,0]) GpsPlug();
187 }
188
189 module NestleCubeCutout(ca,cb,d){
190   dist = cb - ca;
191   cuth = -nestleh + nestlefloorh;
192   mirror([0,1,0]){
193     translate([0,1,0])
194     rotate([90,0,0]){
195       linear_extrude(height=d+2){
196         polygon([[ca+nestlebevel, cuth],
197                  [ca, cuth+nestlebevel*2],
198                  [ca, -dist/2-nestleceilh],
199                  [(ca+cb)/2, -nestleceilh],
200                  [cb, -dist/2-nestleceilh],
201                  [cb, cuth+nestlebevel*2],
202                  [cb-nestlebevel, cuth]]);
203       }
204     }
205   }
206 }
207
208 module NestleCube(){ ////toplevel
209   midw = nestlew/2;
210   midd = min(nestledl,nestledr);
211   midddb = max(nestleddbl,nestleddbr);
212
213   based0 = nestleddf;
214   based1 = midd - midddb;
215   basew0 = -nestledwr;
216   basew1 = +nestledwl-nestlew;
217
218   cutd0 = based0 + nestlewallmin;
219   cutd1 = based1 - nestlewallmin;
220   cutw0 = basew0 - nestlewallmin;
221   cutw1 = basew1 + nestlewallmin;
222
223   bevth = -nestleh + nestlebevel*2;
224   bevw = nestlebevel;
225   bevd = nestlebevel;
226
227   translate([-(basew0+basew1)/2, -(based0+based1)/2, 0]) {
228     difference(){
229       polyhedron
230         (points=
231          [[          +0      ,            +0,        0], // 0
232           [          +0      ,            +nestledr, 0], // 1
233           [          -midw   ,            +midd,     0], // 2
234           [          -nestlew,            +nestledl, 0], // 3
235           [          -nestlew,            +0,        0], // 4
236           [-nestledwr+0      , +nestleddf +0,        bevth], // 5
237           [-nestledwr+0      , -nestleddbr+nestledr, bevth], // 6
238           [          -midw   , -midddb    +midd,     bevth], // 7
239           [+nestledwl-nestlew, -nestleddbl+nestledl, bevth], // 8
240           [+nestledwl-nestlew, +nestleddf +0,        bevth], // 9
241           [-nestledwr+0      -bevw, +nestleddf +0       +bevd, -nestleh], // 10
242           [-nestledwr+0      -bevw, -nestleddbr+nestledr-bevd, -nestleh], // 11
243           [          -midw        , -midddb    +midd    -bevd, -nestleh], // 12
244           [+nestledwl-nestlew+bevw, -nestleddbl+nestledl-bevd, -nestleh], // 13
245           [+nestledwl-nestlew+bevw, +nestleddf +0       +bevd, -nestleh]], // 14
246          triangles=[// main side panels
247                     [0,1,6],[6,5,0],
248                     [1,2,7],[7,6,1],
249                     [2,3,8],[8,7,2],
250                     [3,4,9],[9,8,3],
251                     [4,0,5],[5,9,4],
252                     // bevels
253                     [6,7,12],[12,11,6],
254                     [7,8,13],[13,12,7],
255                     [8,9,14],[14,13,8],
256                     [9,5,10],[10,14,9],
257                     [5,6,11],[11,10,5],
258                     // top and bottom
259                     [4,3,2],[2,1,0],[0,4,2],
260                     [12,13,14],[10,11,12],[12,14,10]],
261          convexity=3);
262       intersection(){
263         #NestleCubeCutout(cutw1, cutw0, max(nestledl,nestledr));
264         #rotate([0,0,90]) NestleCubeCutout(cutd0, cutd1, nestlew);
265       }
266     }
267   }
268
269   translate([gpsrightwardoffset,-gpsrearwardoffset,0])
270     rotate([0,0,90+gpsazimuth])
271     translate([nestledoveclipw/2,0,DoveClip_depth()-0.5])
272     rotate([0,-90,0])
273     DoveClipPairSane(count=3, h=nestledoveclipw);
274 }
275
276 module NestleCubeBaseTest(){ ////toplevel
277   intersection(){
278     translate([0,0,nestleh]) NestleCube();
279     translate([-100,-100,0]) cube([200,200,nestlebevel*5]);
280   }
281   cube([5,5,15]);
282 }
283
284 module NestleCubePin(){ ////toplevel
285   DoveClipPin(nestledoveclipw*0.4);
286 }
287
288 module HolderSideL(){ ////toplevel
289   minz = -(bezelw - holderbezelmore) - holderbackt;
290   holdert = holder_outert + holderwallt*2;
291   cylr = 0.5*sqrt(holderdcw*holderdcw + holderdoveclipl*holderdoveclipl);
292   difference(){
293     translate([-holderh,
294                -holderwallt,
295                minz]) {
296       cube([holderh + holderhgap + cylr,
297             holdert,
298             -minz]);
299       translate([holderh + holderhgap + cylr, holdert/2, 0]) {
300         cylinder(r=cylr, h=-minz);
301         rotate([0,0,gpselevation])
302           translate([0, -holderdoveclipl/2, -minz + DoveClip_depth()])
303           rotate([0,-90,-90])
304           DoveClipPairSane(count=holderdccount, h=holderdoveclipl);
305       }
306     }
307     translate([-holderh-1,
308                0,
309                minz + holderbackt])
310       cube([holderh+1,
311             holder_outert,
312             bezelw]);
313   }
314 }
315
316 module HolderSideR(){ ////toplevel
317   mirror([0,1,0]) HolderSideL();
318 }
319
320 module ChassisBar(){ ////toplevel
321   dist = holder_outerw - 2*((bezelw - holderbezelmore) + DoveClip_depth());
322   cliph = holderdcw;
323   for (mir=[0,1]) {
324     mirror([mir,0,0]) {
325       translate([dist/2, cliph/2, 0])
326         DoveClipPairSane(h=holderdoveclipl, count=holderdccount);
327       translate([-1, 0, 0])
328         cube([dist/2 - DoveClip_depth() + 1.1, chassish, chassist]);
329     }
330   }
331   translate([-gpsrightwardoffsetonbar, -DoveClip_depth(), 0])
332     rotate([0,0,-90])
333     DoveClipPairSane(h=nestledoveclipw, count=3,
334                      baseextend=chassist/2);
335 }
336
337 module HolderSidePin(){ ////toplevel
338   DoveClipPin(holderdoveclipl*0.5);
339 }
340
341 module Pins(){ ///toplevel
342   for (i=[1:4*holderdccount]) {
343     translate([i*10, 0, 0]) HolderSidePin();
344   }
345   for (i=[1:6]) {
346     translate([i*10, 20, 0]) NestleCubePin();
347   }
348 }
349
350 //GpsPlugT();
351 //GpsAssembled();
352 //GpsBody();
353 //NestleCube();
354 //NestleCubePin();
355 //HolderSideL();
356 //HolderSideR();
357 //HolderSidePin();
358 //ChassisBar();
359 //Pins();