chiark / gitweb /
anke-gps-bracket: HolderSideR
[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 = 55.4 - 0.5;
43 //   depths (back to front distance):
44 nestledl = 38.8 - 0.5;
45 nestledr = 42.7 - 0.5;
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 nestlewallmin = 4;
54 nestleceilmin = 4;
55
56 // Adjustment for the GPS attitude
57 gpsazimuth = 45;
58 gpselevation = 40;
59 gpsrightwardoffset = 5;
60 gpsrearwardoffset = 2;
61
62 // Amount of wire protrusion to allow for
63 plugwiremoreh = 25;
64
65 // Slops and steps etc.
66 plugslop = 0.5;
67 plughstep = 1.5;
68 bodylhsrhsslop = 0.5;
69 holderhgap = 5;
70 holderbezelmore = 2;
71
72 // Dimensions for strength only
73 screent = 1.0;
74 plugstrutw = 4;
75 plugstrutt = min(model_outert, 5);
76 nestledoveclipw = 20;
77 holderh = model_outerh * 0.5;
78 holderwallt = 2.5;
79 holderbackt = 2.8;
80 holderdccount = 2;
81 holderdoveclipl = 15;
82
83 // Consequential values
84 holderdcw = DoveClipPairSane_width(holderdccount);
85
86 module GpsPlugPlug(slop){
87   effhslop = slop - plughstep;
88   effplugw = plugw + slop*2;
89   effplugh = plugh + effhslop*2;
90   translate([plug2lhs-slop, plug2bot-effhslop, -1])
91     cube([effplugw, effplugh, model_outert+2]);
92 }
93
94 module GpsBodyOuterBevel(len){
95   translate([0,-1,0]) {
96     rotate([-90,0,0]) {
97       linear_extrude(height=len+2) {
98         polygon([[-outerbackbevel, 0],
99                  [ 0, outerbackbevel],
100                  [outerbackbevel, 0],
101                  [ 0, -outerbackbevel]]);
102       }
103     }
104   }
105 }
106
107 module GpsBody() { ////toplevel
108   difference(){
109     union(){
110       difference(){
111         cube([model_outerw, model_outerh, model_outert]);
112         translate([bezelw, bezelboth, screent])
113           cube([model_outerw-bezelw*2,
114                 model_outerh-bezelboth-bezeltoph,
115                 model_outert]);
116         translate([model_outerw-spkr2rhs, spkr2bot, -1])
117           cylinder(r=spkrdia/2, h=model_outert+2);
118       }
119       translate([plug2lhs+plugw/2, plug2bot+plugh/2, 0])
120         cylinder(r=(plugw+plugh)/2, h=model_outert);
121       for (x=[plug2lhs-plugstrutw, plug2lhs+plugw])
122         translate([x, 0.1, 0])
123           cube([plugstrutw, model_outerh-0.2, plugstrutt-0.10]);
124     }
125     GpsPlugPlug(0);
126     for (x=[0,model_outerw]) translate([x,0,0]) GpsBodyOuterBevel(model_outerh);
127     for (y=[0,model_outerh]) translate([0,y,0])
128       rotate([0,0,-90]) GpsBodyOuterBevel(model_outerw);
129   }
130 }
131
132 module GpsPlug() {
133   plugwireh = plug2bot + plugwiremoreh;
134   translate([-plugslop,0,0]) GpsPlugPlug(-plugslop);
135   mirror([0,0,1]) translate([plug2lhs, plug2bot, 0]) {
136     cube([plugw, plugh, plugtotald-0.05]);
137     translate([0, -plugwireh, pluggapd])
138       cube([plugw, plugwireh+0.05, plugtotald-pluggapd]);
139   }
140 }
141
142 lhsteethu = 2;
143
144 module GpsLHSMask(xslop=0){
145   translate([plug2lhs + plugw+plugh+plugstrutw,
146              0,
147              -50]) {
148     for (iter=[-100/lhsteethu : 100/lhsteethu]) {
149       translate([0, iter*lhsteethu*2, 0]) {
150         linear_extrude(height=100) {
151           polygon([[-300,     0],
152                    [   0,     0],
153                    [lhsteethu,lhsteethu],
154                    [   0,     lhsteethu*2],
155                    [-300,     lhsteethu*2+0.1]]);
156         }
157       }
158     }
159   }
160 }
161
162 module GpsAssembled(){ ////toplevel
163   GpsBody();
164   GpsPlug();
165 }
166
167 module GpsBodyLT(){
168   intersection(){
169     GpsBody();
170     GpsLHSMask();
171   }
172 }
173
174 module GpsBodyRT(){
175   difference(){
176     GpsBody();
177     GpsLHSMask(bodylhsrhsslop);
178   }
179 }
180
181 module GpsPlugT(){ ////toplevel
182   rotate([0,-90,0]) GpsPlug();
183 }
184
185 module NestleCubeCutout(ca,cb,d){
186   dist = cb - ca;
187   mirror([0,1,0]){
188     rotate([90,0,0]){
189       linear_extrude(height=d){
190         polygon([[ca, -nestleh-1],
191                  [ca, -dist/2],
192                  [(ca+cb)/2, 0],
193                  [cb, -dist/2],
194                  [cb, -nestleh-1]]);
195       }
196     }
197   }
198 }
199
200 module NestleCube(){ ////toplevel
201   midw = nestlew/2;
202   midd = min(nestledl,nestledr);
203   midddb = max(nestleddbl,nestleddbr);
204
205   based0 = nestleddf;
206   based1 = midd - midddb;
207   basew0 = -nestledwr;
208   basew1 = +nestledwl-nestlew;
209
210   cutd0 = based0 + nestlewallmin;
211   cutd1 = based1 - nestlewallmin;
212   cutw0 = basew0 - nestlewallmin;
213   cutw1 = basew1 + nestlewallmin;
214
215   translate([-(basew0+basew1)/2, -(based0+based1)/2, 0]) difference(){
216     polyhedron
217       (points=[[          +0      ,            +0,        0], // 0
218                [          +0      ,            +nestledr, 0], // 1
219                [          -midw   ,            +midd,     0], // 2
220                [          -nestlew,            +nestledl, 0], // 3
221                [          -nestlew,            +0,        0], // 4
222                [-nestledwr+0      , +nestleddf +0,        -nestleh], // 5
223                [-nestledwr+0      , -nestleddbr+nestledr, -nestleh], // 6
224                [          -midw   , -midddb    +midd,     -nestleh], // 7
225                [+nestledwl-nestlew, -nestleddbl+nestledl, -nestleh], // 8
226                [+nestledwl-nestlew, +nestleddf +0,        -nestleh]], // 9
227        triangles=[[0,1,6],[6,5,0],
228                   [1,2,7],[7,6,1],
229                   [2,3,8],[8,7,2],
230                   [3,4,9],[9,8,3],
231                   [4,0,5],[5,9,4],
232                   [4,3,2],[2,1,0],[0,4,2],
233                   [7,8,9],[5,6,7],[7,9,5]],
234        convexity=3);
235     intersection(){
236       NestleCubeCutout(cutw1, cutw0, max(nestledl,nestledr));
237       rotate([0,0,90]) NestleCubeCutout(cutd0, cutd1, nestlew);
238     }
239   }
240
241   translate([gpsrightwardoffset,-gpsrearwardoffset,0])
242     rotate([0,0,gpsazimuth])
243     translate([nestledoveclipw/2,0,DoveClip_depth()-0.5])
244     rotate([0,-90,0])
245     DoveClipPairSane(count=3, h=nestledoveclipw);
246 }
247
248 module NestleCubePin(){ ////toplevel
249   DoveClipPin(nestledoveclipw*0.4);
250 }
251
252 module HolderSideL(){ ////toplevel
253   minz = -(bezelw - holderbezelmore) - holderbackt;
254   holdert = holder_outert + holderwallt*2;
255   cylr = 0.5*sqrt(holderdcw*holderdcw + holderdoveclipl*holderdoveclipl);
256   difference(){
257     translate([-holderh,
258                -holderwallt,
259                minz]) {
260       cube([holderh + holderhgap + cylr,
261             holdert,
262             -minz]);
263       translate([holderh + holderhgap + cylr, holdert/2, 0]) {
264         cylinder(r=cylr, h=-minz);
265         rotate([0,0,gpselevation])
266           translate([0, -holderdoveclipl/2, -minz + DoveClip_depth()])
267           rotate([0,-90,-90])
268           DoveClipPairSane(count=holderdccount, h=holderdoveclipl);
269       }
270     }
271     translate([-holderh-1,
272                0,
273                minz + holderbackt])
274       cube([holderh+1,
275             holder_outert,
276             bezelw]);
277   }
278 }
279
280 module HolderSideR(){ ////toplevel
281   mirror([0,1,0]) HolderSideL();
282 }
283
284 //GpsPlugT();
285 //GpsAssembled();
286 //GpsBody();
287 //NestleCube();
288 //NestleCubePin();
289 //HolderSideL();
290 //HolderSideR();