chiark / gitweb /
sewing-table: RoundCorner rework: introduce ctr3 (nfc)
[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 = 40.2;
45 nestledr = 43.9;
46 //   differences in width, depth, at bottom:
47 nestledwl = 2.1;
48 nestledwr = 1.4;
49 nestleddf = 4.0;
50 nestleddbl = 5.7;
51 nestleddbr = 5.2;
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 = 1;
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 = 4.7;
84 nestleceilh = 6.0;
85 nestlewallmin = 10.0;
86 nestlearchslope = 0.75 * sqrt(0.5);
87
88 // Consequential values
89 holderdcw = DoveClipPairSane_width(holderdccount);
90
91 module GpsPlugPlug(slop){
92   effhslop = slop - plughstep;
93   effplugw = plugw + slop*2;
94   effplugh = plugh + effhslop*2;
95   translate([plug2lhs-slop, plug2bot-effhslop, -1])
96     cube([effplugw, effplugh, model_outert+2]);
97 }
98
99 module GpsBodyOuterBevel(len){
100   translate([0,-1,0]) {
101     rotate([-90,0,0]) {
102       linear_extrude(height=len+2) {
103         polygon([[-outerbackbevel, 0],
104                  [ 0, outerbackbevel],
105                  [outerbackbevel, 0],
106                  [ 0, -outerbackbevel]]);
107       }
108     }
109   }
110 }
111
112 module GpsBody() { ////toplevel
113   difference(){
114     union(){
115       difference(){
116         cube([model_outerw, model_outerh, model_outert]);
117         translate([bezelw, bezelboth, screent])
118           cube([model_outerw-bezelw*2,
119                 model_outerh-bezelboth-bezeltoph,
120                 model_outert]);
121         translate([model_outerw-spkr2rhs, spkr2bot, -1])
122           cylinder(r=spkrdia/2, h=model_outert+2);
123       }
124       translate([plug2lhs+plugw/2, plug2bot+plugh/2, 0])
125         cylinder(r=(plugw+plugh)/2, h=model_outert);
126       for (x=[plug2lhs-plugstrutw, plug2lhs+plugw])
127         translate([x, 0.1, 0])
128           cube([plugstrutw, model_outerh-0.2, plugstrutt-0.10]);
129     }
130     GpsPlugPlug(0);
131     for (x=[0,model_outerw]) translate([x,0,0]) GpsBodyOuterBevel(model_outerh);
132     for (y=[0,model_outerh]) translate([0,y,0])
133       rotate([0,0,-90]) GpsBodyOuterBevel(model_outerw);
134   }
135 }
136
137 module GpsPlug() {
138   plugwireh = plug2bot + plugwiremoreh;
139   translate([-plugslop,0,0]) GpsPlugPlug(-plugslop);
140   mirror([0,0,1]) translate([plug2lhs, plug2bot, 0]) {
141     cube([plugw, plugh, plugtotald-0.05]);
142     translate([0, -plugwireh, pluggapd])
143       cube([plugw, plugwireh+0.05, plugtotald-pluggapd]);
144   }
145 }
146
147 lhsteethu = 2;
148
149 module GpsLHSMask(xslop=0){
150   translate([plug2lhs + plugw+plugh+plugstrutw,
151              0,
152              -50]) {
153     for (iter=[-100/lhsteethu : 100/lhsteethu]) {
154       translate([0, iter*lhsteethu*2, 0]) {
155         linear_extrude(height=100) {
156           polygon([[-300,     0],
157                    [   0,     0],
158                    [lhsteethu,lhsteethu],
159                    [   0,     lhsteethu*2],
160                    [-300,     lhsteethu*2+0.1]]);
161         }
162       }
163     }
164   }
165 }
166
167 module GpsAssembled(){ ////toplevel
168   GpsBody();
169   GpsPlug();
170 }
171
172 module GpsBodyLT(){
173   intersection(){
174     GpsBody();
175     GpsLHSMask();
176   }
177 }
178
179 module GpsBodyRT(){
180   difference(){
181     GpsBody();
182     GpsLHSMask(bodylhsrhsslop);
183   }
184 }
185
186 module GpsPlugT(){ ////toplevel
187   rotate([0,-90,0]) GpsPlug();
188 }
189
190 module NestleCubeCutout(ca,cb,d){
191   dist = cb - ca;
192   cuth = -nestleh + nestlefloorh;
193   mirror([0,1,0]){
194     translate([0,1,0])
195     rotate([90,0,0]){
196       linear_extrude(height=d+2){
197         polygon([[ca+nestlebevel, cuth],
198                  [ca, cuth+nestlebevel*2],
199                  [ca, -dist/2/nestlearchslope-nestleceilh],
200                  [(ca+cb)/2, -nestleceilh],
201                  [cb, -dist/2/nestlearchslope-nestleceilh],
202                  [cb, cuth+nestlebevel*2],
203                  [cb-nestlebevel, cuth]]);
204       }
205     }
206   }
207 }
208
209 module NestleCube(){ ////toplevel
210   midw = nestlew/2;
211   midd = min(nestledl,nestledr);
212   midddb = max(nestleddbl,nestleddbr);
213
214   based0 = nestleddf;
215   based1 = midd - midddb;
216   basew0 = -nestledwr;
217   basew1 = +nestledwl-nestlew;
218
219   echo("wl,wr=", basew1, basew0);
220   echo("df,dbl,dbm,dbr",
221        based0, nestledl-nestleddbl, based1, nestledr-nestleddbr);
222
223   cutd0 = based0 + nestlewallmin;
224   cutd1 = based1 - nestlewallmin;
225   cutw0 = basew0 - nestlewallmin;
226   cutw1 = basew1 + nestlewallmin;
227
228   bevth = -nestleh + nestlebevel*2;
229   bevw = nestlebevel;
230   bevd = nestlebevel;
231
232   translate([-(basew0+basew1)/2, -(based0+based1)/2, 0]) {
233     difference(){
234       polyhedron
235         (points=
236          [[          +0      ,            +0,        0], // 0
237           [          +0      ,            +nestledr, 0], // 1
238           [          -midw   ,            +midd,     0], // 2
239           [          -nestlew,            +nestledl, 0], // 3
240           [          -nestlew,            +0,        0], // 4
241           [-nestledwr+0      , +nestleddf +0,        bevth], // 5
242           [-nestledwr+0      , -nestleddbr+nestledr, bevth], // 6
243           [          -midw   , -midddb    +midd,     bevth], // 7
244           [+nestledwl-nestlew, -nestleddbl+nestledl, bevth], // 8
245           [+nestledwl-nestlew, +nestleddf +0,        bevth], // 9
246           [-nestledwr+0      -bevw, +nestleddf +0       +bevd, -nestleh], // 10
247           [-nestledwr+0      -bevw, -nestleddbr+nestledr-bevd, -nestleh], // 11
248           [          -midw        , -midddb    +midd    -bevd, -nestleh], // 12
249           [+nestledwl-nestlew+bevw, -nestleddbl+nestledl-bevd, -nestleh], // 13
250           [+nestledwl-nestlew+bevw, +nestleddf +0       +bevd, -nestleh]], // 14
251          triangles=[// main side panels
252                     [0,1,6],[6,5,0],
253                     [1,2,7],[7,6,1],
254                     [2,3,8],[8,7,2],
255                     [3,4,9],[9,8,3],
256                     [4,0,5],[5,9,4],
257                     // bevels
258                     [6,7,12],[12,11,6],
259                     [7,8,13],[13,12,7],
260                     [8,9,14],[14,13,8],
261                     [9,5,10],[10,14,9],
262                     [5,6,11],[11,10,5],
263                     // top and bottom
264                     [4,3,2],[2,1,0],[0,4,2],
265                     [12,13,14],[10,11,12],[12,14,10]],
266          convexity=3);
267       union(){
268         #NestleCubeCutout(cutw1, cutw0, max(nestledl,nestledr));
269         #rotate([0,0,90]) NestleCubeCutout(cutd0, cutd1, nestlew);
270       }
271     }
272   }
273
274   translate([gpsrightwardoffset,-gpsrearwardoffset,0])
275     rotate([0,0,90+gpsazimuth])
276     translate([nestledoveclipw/2,0,DoveClip_depth()-0.5])
277     rotate([0,-90,0])
278     DoveClipPairSane(count=3, h=nestledoveclipw);
279 }
280
281 module NestleCubeBaseTest(){ ////toplevel
282   intersection(){
283     translate([0,0,nestleh]) NestleCube();
284     translate([-100,-100,0]) cube([200,200,nestlebevel*5]);
285   }
286   cube([5,5,10]);
287 }
288
289 module NestleCubeCeilTest(){ ////toplevel
290   intersection(){
291     translate([0,0,3]) NestleCube();
292     translate([-100,-100,0]) cube([200,200,5.5]);
293   }
294   cube([5,5,10]);
295 }
296
297 module NestleCubePin(){ ////toplevel
298   DoveClipPin(nestledoveclipw*0.4);
299 }
300
301 module HolderSideL(){ ////toplevel
302   minz = -(bezelw - holderbezelmore) - holderbackt;
303   holdert = holder_outert + holderwallt*2;
304   cylr = 0.5*sqrt(holderdcw*holderdcw + holderdoveclipl*holderdoveclipl);
305   difference(){
306     translate([-holderh,
307                -holderwallt,
308                minz]) {
309       cube([holderh + holderhgap + cylr,
310             holdert,
311             -minz]);
312       translate([holderh + holderhgap + cylr, holdert/2, 0]) {
313         cylinder(r=cylr, h=-minz);
314         rotate([0,0,gpselevation])
315           translate([0, -holderdoveclipl/2, -minz + DoveClip_depth()])
316           rotate([0,-90,-90])
317           DoveClipPairSane(count=holderdccount, h=holderdoveclipl);
318       }
319     }
320     translate([-holderh-1,
321                0,
322                minz + holderbackt])
323       cube([holderh+1,
324             holder_outert,
325             bezelw]);
326   }
327 }
328
329 module HolderSideR(){ ////toplevel
330   mirror([0,1,0]) HolderSideL();
331 }
332
333 module ChassisBar(){ ////toplevel
334   dist = holder_outerw - 2*((bezelw - holderbezelmore) + DoveClip_depth());
335   cliph = holderdcw;
336   for (mir=[0,1]) {
337     mirror([mir,0,0]) {
338       translate([dist/2, cliph/2, 0])
339         DoveClipPairSane(h=holderdoveclipl, count=holderdccount);
340       translate([-1, 0, 0])
341         cube([dist/2 - DoveClip_depth() + 1.1, chassish, chassist]);
342     }
343   }
344   translate([-gpsrightwardoffsetonbar, -DoveClip_depth(), 0])
345     rotate([0,0,-90])
346     DoveClipPairSane(h=nestledoveclipw, count=3,
347                      baseextend=chassist/2);
348 }
349
350 module HolderSidePin(){ ////toplevel
351   DoveClipPin(holderdoveclipl*0.5);
352 }
353
354 module Pins(){ ///toplevel
355   for (i=[1:4*holderdccount]) {
356     translate([i*10, 0, 0]) HolderSidePin();
357   }
358   for (i=[1:6]) {
359     translate([i*10, 20, 0]) NestleCubePin();
360   }
361 }
362
363 //GpsPlugT();
364 //GpsAssembled();
365 //GpsBody();
366 //NestleCube();
367 //NestleCubeBaseTest();
368 //NestleCubeCeilTest();
369 //NestleCubePin();
370 //HolderSideL();
371 //HolderSideR();
372 //HolderSidePin();
373 //ChassisBar();
374 //Pins();