chiark / gitweb /
anke-gps-bracket: NestleCube has a hollow
[reprap-play.git] / anke-gps-bracket.scad
1 // -*- C -*-
2
3 // Dimensions of the main GPS body
4 outerw = 120 + 2.5;
5 outerh =  75 - 0.2;
6 outert =  15 - 1.0;
7 outerbackbevel = 3;
8
9 // Dimensions of the bezel area round the edges
10 bezelw =    11 - 0.5;
11 bezelboth = 11 - 0.5;
12 bezeltoph =  7 - 0.5;
13
14 // Dimensions of the speaker at the back
15 spkrdia =  22;
16 spkr2bot = 19;
17 spkr2rhs = 25;
18
19 // Dimensions of the plug and wire
20 plugw =      12;
21 plugh =       9;
22 plug2bot =   11;
23 plug2lhs =   11;
24 plugtotald = 15;
25 pluggapd =    5;
26
27 // Dimensions of the hole in the tray
28 //   width and height (vertical) at the top
29 nestleh = 53;
30 nestlew = 55.4 - 0.5;
31 //   depths (back to front distance):
32 nestledl = 38.8 - 0.5;
33 nestledr = 42.7 - 0.5;
34 //   differences in width, depth, at bottom:
35 nestledwl = 3.0;
36 nestledwr = 2.4;
37 nestleddf = 4.0;
38 nestleddbl = 3.3;
39 nestleddbr = 3.6;
40
41 nestlewallmin = 4;
42 nestleceilmin = 4;
43
44 // Amount of wire protrusion to allow for
45 plugwiremoreh = 25;
46
47 // Slops and steps etc.
48 plugslop = 0.5;
49 plughstep = 1.5;
50 bodylhsrhsslop = 0.5;
51
52 // Dimensions for strength only
53 screent = 1.0;
54 plugstrutw = 4;
55 plugstrutt = min(outert, 5);
56
57 module GpsPlugPlug(slop){
58   effhslop = slop - plughstep;
59   effplugw = plugw + slop*2;
60   effplugh = plugh + effhslop*2;
61   translate([plug2lhs-slop, plug2bot-effhslop, -1])
62     cube([effplugw, effplugh, outert+2]);
63 }
64
65 module GpsBodyOuterBevel(len){
66   translate([0,-1,0]) {
67     rotate([-90,0,0]) {
68       linear_extrude(height=len+2) {
69         polygon([[-outerbackbevel, 0],
70                  [ 0, outerbackbevel],
71                  [outerbackbevel, 0],
72                  [ 0, -outerbackbevel]]);
73       }
74     }
75   }
76 }
77
78 module GpsBody() { ////toplevel
79   difference(){
80     union(){
81       difference(){
82         cube([outerw, outerh, outert]);
83         translate([bezelw, bezelboth, screent])
84           cube([outerw-bezelw*2, outerh-bezelboth-bezeltoph, outert]);
85         translate([outerw-spkr2rhs, spkr2bot, -1])
86           cylinder(r=spkrdia/2, h=outert+2);
87       }
88       translate([plug2lhs+plugw/2, plug2bot+plugh/2, 0])
89         cylinder(r=(plugw+plugh)/2, h=outert);
90       for (x=[plug2lhs-plugstrutw, plug2lhs+plugw])
91         translate([x, 0.1, 0])
92           cube([plugstrutw, outerh-0.2, plugstrutt-0.10]);
93     }
94     GpsPlugPlug(0);
95     for (x=[0,outerw]) translate([x,0,0]) GpsBodyOuterBevel(outerh);
96     for (y=[0,outerh]) translate([0,y,0])
97       rotate([0,0,-90]) GpsBodyOuterBevel(outerw);
98   }
99 }
100
101 module GpsPlug() {
102   plugwireh = plug2bot + plugwiremoreh;
103   translate([-plugslop,0,0]) GpsPlugPlug(-plugslop);
104   mirror([0,0,1]) translate([plug2lhs, plug2bot, 0]) {
105     cube([plugw, plugh, plugtotald-0.05]);
106     translate([0, -plugwireh, pluggapd])
107       cube([plugw, plugwireh+0.05, plugtotald-pluggapd]);
108   }
109 }
110
111 lhsteethu = 2;
112
113 module GpsLHSMask(xslop=0){
114   translate([plug2lhs + plugw+plugh+plugstrutw,
115              0,
116              -50]) {
117     for (iter=[-100/lhsteethu : 100/lhsteethu]) {
118       translate([0, iter*lhsteethu*2, 0]) {
119         linear_extrude(height=100) {
120           polygon([[-300,     0],
121                    [   0,     0],
122                    [lhsteethu,lhsteethu],
123                    [   0,     lhsteethu*2],
124                    [-300,     lhsteethu*2+0.1]]);
125         }
126       }
127     }
128   }
129 }
130
131 module GpsAssembled(){ ////toplevel
132   GpsBody();
133   GpsPlug();
134 }
135
136 module GpsBodyLT(){
137   intersection(){
138     GpsBody();
139     GpsLHSMask();
140   }
141 }
142
143 module GpsBodyRT(){
144   difference(){
145     GpsBody();
146     GpsLHSMask(bodylhsrhsslop);
147   }
148 }
149
150 module GpsPlugT(){ ////toplevel
151   rotate([0,-90,0]) GpsPlug();
152 }
153
154 module NestleCubeCutout(ca,cb,d){
155   dist = cb - ca;
156   mirror([0,1,0]){
157     rotate([90,0,0]){
158       linear_extrude(height=d){
159         polygon([[ca, -nestleh-1],
160                  [ca, -dist/2],
161                  [(ca+cb)/2, 0],
162                  [cb, -dist/2],
163                  [cb, -nestleh-1]]);
164       }
165     }
166   }
167 }
168
169 module NestleCube(){
170   midw = nestlew/2;
171   midd = min(nestledl,nestledr);
172   midddb = max(nestleddbl,nestleddbr);
173
174   based0 = nestleddf;
175   based1 = midd - midddb;
176   basew0 = -nestledwr;
177   basew1 = +nestledwl-nestlew;
178
179   cutd0 = based0 + nestlewallmin;
180   cutd1 = based1 - nestlewallmin;
181   cutw0 = basew0 - nestlewallmin;
182   cutw1 = basew1 + nestlewallmin;
183
184   translate([-(basew0+basew1)/2, -(based0+based1)/2, 0]) difference(){
185     polyhedron
186       (points=[[          +0      ,            +0,        0], // 0
187                [          +0      ,            +nestledr, 0], // 1
188                [          -midw   ,            +midd,     0], // 2
189                [          -nestlew,            +nestledl, 0], // 3
190                [          -nestlew,            +0,        0], // 4
191                [-nestledwr+0      , +nestleddf +0,        -nestleh], // 5
192                [-nestledwr+0      , -nestleddbr+nestledr, -nestleh], // 6
193                [          -midw   , -midddb    +midd,     -nestleh], // 7
194                [+nestledwl-nestlew, -nestleddbl+nestledl, -nestleh], // 8
195                [+nestledwl-nestlew, +nestleddf +0,        -nestleh]], // 9
196        triangles=[[0,1,6],[6,5,0],
197                   [1,2,7],[7,6,1],
198                   [2,3,8],[8,7,2],
199                   [3,4,9],[9,8,3],
200                   [4,0,5],[5,9,4],
201                   [4,3,2],[2,1,0],[0,4,2],
202                   [7,8,9],[5,6,7],[7,9,5]],
203        convexity=3);
204     intersection(){
205       NestleCubeCutout(cutw1, cutw0, max(nestledl,nestledr));
206       rotate([0,0,90]) NestleCubeCutout(cutd0, cutd1, nestlew);
207     }
208   }
209 }
210
211 //GpsPlugT();
212 //GpsAssembled();
213 //GpsBody();
214
215 NestleCube();