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