forked from infused-kim/kb_keycaps_chicago_stenographer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Choc_Chicago_Steno.scad
434 lines (378 loc) · 20.4 KB
/
Choc_Chicago_Steno.scad
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
use <scad-utils/morphology.scad> //for cheaper minwoski
use <scad-utils/transformations.scad>
use <scad-utils/shapes.scad>
use <scad-utils/trajectory.scad>
use <scad-utils/trajectory_path.scad>
use <sweep.scad>
use <skin.scad>
//use <z-butt.scad>
//Choc Chord version Chicago Stenographer
/*Tester */
keycap_cs(
keyID = 6, //change profile refer to KeyParameters Struct
cutLen = 0, //Don't change. for chopped caps
Stem = true, //tusn on shell and stems
StemRot = 0, //change stem orientation by deg
Dish = true, //turn on dish cut
Stab = 0,
visualizeDish = false, // turn on debug visual of Dish
crossSection = false, // center cut to check internal
homeDot = false, //turn on homedots,
homeBar = true, //turn on homebar,
Legends = false
);
//-Parameters
wallthickness = 1.1; // 1.75 for mx size, 1.1
topthickness = 3.0; //2 for phat 3 for chicago
stepsize = 50; //resolution of Trajectory
step = 0.5; //resolution of ellipes
fn = 60; //resolution of Rounded Rectangles: 60 for output
layers = 50; //resolution of vertical Sweep: 50 for output
//---Stem param
slop = 0.3;
stemRot = 0;
stemWid = 8;
stemLen = 6;
stemCrossHeight = 1.8;
extra_vertical = 0.6;
stemLayers = 50; //resolution of stem to cap top transition
//#cube([18.16, 18.16, 10], center = true); // sanity check border
//injection param
draftAngle = 0; //degree note:Stem Only
//TODO: Add wall thickness transition?
keyParameters = //keyParameters[KeyID][ParameterID]
[
// BotWid, BotLen, TWDif, TLDif, keyh, WSft, LSft XSkew, YSkew, ZSkew, WEx, LEx, CapR0i, CapR0f, CapR1i, CapR1f, CapREx, StemEx
//Column 0
//Levee: Chicago in choc Dimension
[16.20, 16.20, 5.6, 5, 4.9, 0, .0, 5, -0, -0, 2, 2.5, .10, 2, .10, 3, 2, 2], //Chicago Steno R2/R4
[16.20, 16.20, 5.6, 5, 4.5, 0, .0, 0, -0, -0, 2, 2.5, .10, 3, .10, 3, 2, 2], //Chicago Steno R3 flat
[16.20, 16.20, 1.25, 1.25, 4.5, 0, .0, 0, -0, -0, 2, 2.5, .10, .5, .10, .5, 2, 2], //Chicago Steno R3 chord
//mods 3
[16.20, 16.20, 4.25, 3.25, 5.5, -.7, 0.7, 0, -4, -0, 2, 2, .10, 2, .10, 2, 2, 2], //Levee Corner R2
[16.20, 16.20, 4.25, 3.25, 5.2, -.8, 0.6, 0, -4, -0, 2, 3, .10, 2, .10, 2, 2, 2], //Levee Corner R2
//1.25: [5, 6]
[20.45, 15.60, 5.6, 5, 4.9, 0, .0, 5, -0, -0, 2, 2.5, .1, 2, .1, 3, 2, 2], //Chicago Steno R2/R4 1.25u
[20.45, 15.60, 5.6, 5, 4.5, 0, .0, 0, -0, -0, 2, 2.5, .1, 3, .1, 3, 2, 2], //Chicago Steno R3 1.25u
//1.5: [7, 8]
[24.70, 15.60, 5.6, 5, 4.9, 0, .0, 5, -0, -0, 2, 2.5, .1, 2, .1, 3, 2, 2], //Chicago Steno R2/R4 1.5
[24.70, 15.60, 5.6, 5, 4.5, 0, .0, 0, -0, -0, 2, 2.5, .1, 3, .1, 3, 2, 2], //Chicago Steno R3 1.5u
//1.75: [9, 10]
[28.95, 15.60, 5.6, 5, 4.9, 0, .0, 5, -0, -0, 2, 2.5, .1, 2, .1, 3, 2, 2], //Chicago Steno R2/R4 1.5
[28.95, 15.60, 5.6, 5, 4.5, 0, .0, 0, -0, -0, 2, 2.5, .1, 3, .1, 3, 2, 2], //Chicago Steno R3 1.5u
//2.00: [11, 12]
[33.20, 15.60, 5.6, 5, 4.9, 0, .0, 5, -0, -0, 2, 2.5, .1, 2, .1, 3, 2, 2], //Chicago Steno R2/R4 1.5
[33.20, 15.60, 5.6, 5, 4.5, 0, .0, 0, -0, -0, 2, 2.5, .1, 3, .1, 3, 2, 2], //Chicago Steno R3 1.5u
//2.25: [13, 14]
[37.45, 15.60, 5.6, 5, 4.9, 0, .0, 5, -0, -0, 2, 2.5, .1, 2, .1, 3, 2, 2], //Chicago Steno R2/R4 1.5
[37.45, 15.60, 5.6, 5, 4.5, 0, .0, 0, -0, -0, 2, 2.5, .1, 3, .1, 3, 2, 2], //Chicago Steno R3 1.5u
// Ergo shits
[18.75, 18.75, 5.6, 5, 8, 0, .25, 0, -0, -0, 2, 2.5, .10, 3, .10, 3, 2, 2], //highpro 19.05 R2|4
[17.20, 16.00, 5.6, 5, 4.7, 0, .0, 3, -0, -0, 2, 2.5, .10, 2, .10, 3, 2, 2], //Chicago Steno R2 ALT
[17.20, 16.00, 5.6, 5, 5.5, 0, .0, 7, -0, -0, 2, 2.5, .10, 2, .10, 3, 2, 2], //Chicago Steno R1 Steap
[17.20, 16.00, 5.6, 5, 7.0, 0, .0, 10, -0, -0, 2, 2.5, .10, 2, .10, 3, 2, 2] //Chicago Steno R1 mild with alt R2
];
dishParameters = //dishParameter[keyID][ParameterID]
[
//FFwd1 FFwd2 FPit1 FPit2 DshDep DshHDif FArcIn FArcFn FArcEx BFwd1 BFwd2 BPit1 BPit2 BArcIn BArcFn BArcEx
//Column 0
[ 4.5, 4, 7, -50, 7, 1.7, 11.5, 17.5, 2, 4.5, 4, 2, -35, 11.5, 15, 2], //Chicago Steno R2/R4
[ 4.5, 4, 5, -40, 7, 1.7, 11.5, 15, 2, 4.5, 4, 5, -40, 11.5, 15, 2], //Chicago Steno R3 flat
[ 4.5, 4, 5, -40, 7, 1.7, 11.5, 15, 2, 4.5, 4, 5, -40, 11.5, 15, 2], //Chicago Steno R3 chord
[ 6, 3.5, 7, -50, 5, 1.0, 16, 23, 2, 6, 3.5, 7, -50, 16, 23, 2], //Levee Steno R2/R4
[ 6, 3.5, 7, -50, 5, 1.0, 16, 23, 2, 6, 3.5, 7, -50, 16, 23, 2], //Levee Steno R2/R4
//1.25
[ 4.5, 4, 7, -40, 8, 1.7, 16.0, 22.5, 2, 4.5, 4, 2, -35, 16.0, 19.5, 2], //Chicago Steno R2/R4
[ 4.5, 4, 5, -40, 8, 1.7, 16.0, 19.5, 2, 4.5, 4, 5, -40, 16.0, 19.5, 2], //Chicago Steno R3
//1.5
[ 4.5, 4, 7, -40, 8, 1.7, 20.5, 26.5, 2, 4.5, 4, 2, -35, 20.5, 24.0, 2], //Chicago Steno R2/R4
[ 4.5, 4, 5, -40, 8, 1.7, 20.5, 24.0, 2, 4.5, 4, 5, -40, 20.5, 24.0, 2], //Chicago Steno R3
//1.75
[ 4.5, 4, 7, -40, 8, 1.7, 25.0, 31.0, 2, 4.5, 4, 2, -35, 25.0, 28.5, 2], //Chicago Steno R2/R4
[ 4.5, 4, 5, -40, 8, 1.7, 25.0, 28.5, 2, 4.5, 4, 5, -40, 25.0, 28.5, 2], //Chicago Steno R3
//2.00
[ 4.5, 4, 7, -40, 8, 1.7, 29.5, 35.5, 2, 4.5, 4, 2, -35, 29.5, 33.0, 2], //Chicago Steno R2/R4
[ 4.5, 4, 5, -40, 8, 1.7, 29.5, 33.0, 2, 4.5, 4, 5, -40, 29.5, 33.0, 2], //Chicago Steno R3
//2.25
[ 4.5, 4, 7, -40, 8, 1.7, 33.0, 39.0, 2, 4.5, 4, 2, -35, 33.0, 36.5, 2], //Chicago Steno R2/R4
[ 4.5, 4, 5, -40, 8, 1.7, 33.0, 36.5, 2, 4.5, 4, 5, -40, 33.0, 36.5, 2], //Chicago Steno R3
[ 5, 5, 5, -40, 7, 1.7, 11, 15, 2, 5, 5, 5, -40, 11, 15, 2], //Chicago Steno R3 flat
[ 4.5, 4, 7, -50, 7, 1.7, 11, 17, 2, 4.5, 4, 2, -35, 11, 15, 2], //Chicago Steno R1
[ 4.5, 4, 7, -50, 7, 1.7, 11, 17, 2, 4.5, 4, 2, -35, 11, 15, 2], //Chicago Steno R1
[ 4.5, 4, 7, -50, 7, 1.7, 11, 17, 2, 4.5, 4, 2, -35, 11, 15, 2] //Chicago Steno R1
];
function BottomWidth(keyID) = keyParameters[keyID][0]; //
function BottomLength(keyID) = keyParameters[keyID][1]; //
function TopWidthDiff(keyID) = keyParameters[keyID][2]; //
function TopLenDiff(keyID) = keyParameters[keyID][3]; //
function KeyHeight(keyID) = keyParameters[keyID][4]; //
function TopWidShift(keyID) = keyParameters[keyID][5];
function TopLenShift(keyID) = keyParameters[keyID][6];
function XAngleSkew(keyID) = keyParameters[keyID][7];
function YAngleSkew(keyID) = keyParameters[keyID][8];
function ZAngleSkew(keyID) = keyParameters[keyID][9];
function WidExponent(keyID) = keyParameters[keyID][10];
function LenExponent(keyID) = keyParameters[keyID][11];
function CapRound0i(keyID) = keyParameters[keyID][12];
function CapRound0f(keyID) = keyParameters[keyID][13];
function CapRound1i(keyID) = keyParameters[keyID][14];
function CapRound1f(keyID) = keyParameters[keyID][15];
function ChamExponent(keyID) = keyParameters[keyID][16];
function StemExponent(keyID) = keyParameters[keyID][17];
function FrontForward1(keyID) = dishParameters[keyID][0]; //
function FrontForward2(keyID) = dishParameters[keyID][1]; //
function FrontPitch1(keyID) = dishParameters[keyID][2]; //
function FrontPitch2(keyID) = dishParameters[keyID][3]; //
function DishDepth(keyID) = dishParameters[keyID][4]; //
function DishHeightDif(keyID) = dishParameters[keyID][5]; //
function FrontInitArc(keyID) = dishParameters[keyID][6];
function FrontFinArc(keyID) = dishParameters[keyID][7];
function FrontArcExpo(keyID) = dishParameters[keyID][8];
function BackForward1(keyID) = dishParameters[keyID][9]; //
function BackForward2(keyID) = dishParameters[keyID][10]; //
function BackPitch1(keyID) = dishParameters[keyID][11]; //
function BackPitch2(keyID) = dishParameters[keyID][12]; //
function BackInitArc(keyID) = dishParameters[keyID][13];
function BackFinArc(keyID) = dishParameters[keyID][14];
function BackArcExpo(keyID) = dishParameters[keyID][15];
function FrontTrajectory(keyID) =
[
trajectory(forward = FrontForward1(keyID), pitch = FrontPitch1(keyID)), //more param available: yaw, roll, scale
trajectory(forward = FrontForward2(keyID), pitch = FrontPitch2(keyID)) //You can add more traj if you wish
];
function BackTrajectory (keyID) =
[
trajectory(backward = BackForward1(keyID), pitch = -BackPitch1(keyID)),
trajectory(backward = BackForward2(keyID), pitch = -BackPitch2(keyID))
];
//------- function defining Dish Shapes
function ellipse(a, b, d = 0, rot1 = 0, rot2 = 360) = [for (t = [rot1:step:rot2]) [a*cos(t)+a, b*sin(t)*(1+d*cos(t))]]; //Centered at a apex to avoid inverted face
function DishShape (a,b,c,d) =
concat(
// [[c+a,b]],
ellipse(a, b, d = 0,rot1 = 90, rot2 = 270)
// [[c+a,-b]]
);
function DishShape2 (a,b, phi = 200, theta, r) =
concat(
// [[c+a,b]],
ellipse(a, b, d = 0,rot1 = 90, rot2 = phi),
[for (t = [-atan(-b*cos(phi)/a*sin(phi))+step:step:90])
[r*sin(t)+a*cos(phi)+r*sin(atan(b*cos(phi)/-a*sin(phi)))+a, r*cos(t)+b*sin(phi)-r*cos(atan(b*cos(phi)/-a*sin(phi)))]],
[[a,b*sin(270)+r*sin(theta)]] //bounday vertex to clear ends
);
function oval_path(theta, phi, a, b, c, deform = 0) = [
a*cos(theta)*cos(phi), //x
c*sin(theta)*(1+deform*cos(theta)) , //
b*sin(phi),
];
path_trans2 = [for (t=[0:step:180]) translation(oval_path(t,0,10,15,2,0))*rotation([0,90,0])];
//--------------Function definng Cap
function CapTranslation(t, keyID) =
[
((1-t)/layers*TopWidShift(keyID)), //X shift
((1-t)/layers*TopLenShift(keyID)), //Y shift
(t/layers*KeyHeight(keyID)) //Z shift
];
function InnerTranslation(t, keyID) =
[
((1-t)/layers*TopWidShift(keyID)), //X shift
((1-t)/layers*TopLenShift(keyID)), //Y shift
(t/layers*(KeyHeight(keyID)-topthickness)) //Z shift
];
function CapRotation(t, keyID) =
[
((1-t)/layers*XAngleSkew(keyID)), //X shift
((1-t)/layers*YAngleSkew(keyID)), //Y shift
((1-t)/layers*ZAngleSkew(keyID)) //Z shift
];
function CapTransform(t, keyID) =
[
pow(t/layers, WidExponent(keyID))*(BottomWidth(keyID) -TopWidthDiff(keyID)) + (1-pow(t/layers, WidExponent(keyID)))*BottomWidth(keyID) ,
pow(t/layers, LenExponent(keyID))*(BottomLength(keyID)-TopLenDiff(keyID)) + (1-pow(t/layers, LenExponent(keyID)))*BottomLength(keyID)
];
function CapRoundness(t, keyID) =
[
pow(t/layers, ChamExponent(keyID))*(CapRound0f(keyID)) + (1-pow(t/layers, ChamExponent(keyID)))*CapRound0i(keyID),
pow(t/layers, ChamExponent(keyID))*(CapRound1f(keyID)) + (1-pow(t/layers, ChamExponent(keyID)))*CapRound1i(keyID)
];
function CapRadius(t, keyID) = pow(t/layers, ChamExponent(keyID))*ChamfFinRad(keyID) + (1-pow(t/layers, ChamExponent(keyID)))*ChamfInitRad(keyID);
function InnerTransform(t, keyID) =
[
pow(t/layers, WidExponent(keyID))*(BottomWidth(keyID) -TopLenDiff(keyID)-wallthickness*2) + (1-pow(t/layers, WidExponent(keyID)))*(BottomWidth(keyID) -wallthickness*2),
pow(t/layers, LenExponent(keyID))*(BottomLength(keyID)-TopLenDiff(keyID)-wallthickness*2) + (1-pow(t/layers, LenExponent(keyID)))*(BottomLength(keyID)-wallthickness*2)
];
function StemTranslation(t, keyID) =
[
((1-t)/stemLayers*TopWidShift(keyID)), //X shift
((1-t)/stemLayers*TopLenShift(keyID)), //Y shift
stemCrossHeight+.1 + (t/stemLayers*(KeyHeight(keyID)- topthickness - stemCrossHeight-.1)) //Z shift
];
function StemRotation(t, keyID) =
[
((1-t)/stemLayers*XAngleSkew(keyID)), //X shift
((1-t)/stemLayers*YAngleSkew(keyID)), //Y shift
((1-t)/stemLayers*ZAngleSkew(keyID)) //Z shift
];
function StemTransform(t, keyID) =
[
pow(t/stemLayers, StemExponent(keyID))*(BottomWidth(keyID) -TopLenDiff(keyID)-wallthickness*2) + (1-pow(t/stemLayers, StemExponent(keyID)))*(stemWid - 2*slop),
pow(t/stemLayers, StemExponent(keyID))*(BottomLength(keyID)-TopLenDiff(keyID)-wallthickness*2) + (1-pow(t/stemLayers, StemExponent(keyID)))*(stemLen - 2*slop)
];
function StemRadius(t, keyID) = pow(t/stemLayers,3)*3 + (1-pow(t/stemLayers, 3))*1;
//Stem Exponent
///----- KEY Builder Module
module keycap_cs(keyID = 0, cutLen = 0, visualizeDish = false, crossSection = false, Dish = true, Stem = false, StemRot = 0, homeDot = false, homeBar = false, Stab = 0, Legends = false) {
$fn = fn;
//Set Parameters for dish shape
FrontPath = quantize_trajectories(FrontTrajectory(keyID), steps = stepsize, loop=false);
BackPath = quantize_trajectories(BackTrajectory(keyID), steps = stepsize, loop=false);
//Scaling initial and final dim tranformation by exponents
function FrontDishArc(t) = pow((t)/(len(FrontPath)),FrontArcExpo(keyID))*FrontFinArc(keyID) + (1-pow(t/(len(FrontPath)),FrontArcExpo(keyID)))*FrontInitArc(keyID);
function BackDishArc(t) = pow((t)/(len(FrontPath)),BackArcExpo(keyID))*BackFinArc(keyID) + (1-pow(t/(len(FrontPath)),BackArcExpo(keyID)))*BackInitArc(keyID);
FrontCurve = [ for(i=[0:len(FrontPath)-1]) transform(FrontPath[i], DishShape(DishDepth(keyID), FrontDishArc(i), 1, d = 0)) ];
BackCurve = [ for(i=[0:len(BackPath)-1]) transform(BackPath[i], DishShape(DishDepth(keyID), BackDishArc(i), 1, d = 0)) ];
//builds
difference(){
union(){
difference(){
skin([for (i=[0:layers-1]) transform(translation(CapTranslation(i, keyID)) * rotation(CapRotation(i, keyID)), elliptical_rectangle(CapTransform(i, keyID), b = CapRoundness(i,keyID),fn=fn))]); //outer shell
//Cut inner shell
if(Stem == true){
translate([0,0,-.001])skin([for (i=[0:layers-1]) transform(translation(InnerTranslation(i, keyID)) * rotation(CapRotation(i, keyID)), elliptical_rectangle(InnerTransform(i, keyID), b = CapRoundness(i,keyID),fn=fn))]);
}
}
if(Stem == true){
rotate([0,0,StemRot]){
choc_stem(draftAng = draftAngle);
if (Stab != 0){
// no need for stab
}
translate([0,0,-.001])skin([for (i=[0:stemLayers-1]) transform(translation(StemTranslation(i,keyID))*rotation(StemRotation(i, keyID)), rounded_rectangle_profile(StemTransform(i, keyID),fn=fn,r=StemRadius(i, keyID)))]); //outer shell
}
}
}
//Cuts
//Fonts
if(cutLen != 0){
translate([sign(cutLen)*(BottomLength(keyID)+CapRound0i(keyID)+abs(cutLen))/2,0,0])
cube([BottomWidth(keyID)+CapRound1i(keyID)+1,BottomLength(keyID)+CapRound0i(keyID),50], center = true);
}
if(Legends == true){
#rotate([-XAngleSkew(keyID),YAngleSkew(keyID),ZAngleSkew(keyID)])translate([-1,-5,KeyHeight(keyID)-2.5])linear_extrude(height = 1)text( text = "ver2", font = "Constantia:style=Bold", size = 3, valign = "center", halign = "center" );
}
//Dish Shape
if(Dish == true){
if(visualizeDish == false){
translate([-TopWidShift(keyID),.0001-TopLenShift(keyID),KeyHeight(keyID)-DishHeightDif(keyID)])rotate([0,-YAngleSkew(keyID),0])rotate([0,-90+XAngleSkew(keyID),90-ZAngleSkew(keyID)])skin(FrontCurve);
translate([-TopWidShift(keyID),-TopLenShift(keyID),KeyHeight(keyID)-DishHeightDif(keyID)])rotate([0,-YAngleSkew(keyID),0])rotate([0,-90+XAngleSkew(keyID),90-ZAngleSkew(keyID)])skin(BackCurve);
} else {
#translate([-TopWidShift(keyID),.0001-TopLenShift(keyID),KeyHeight(keyID)-DishHeightDif(keyID)]) rotate([0,-YAngleSkew(keyID),0])rotate([0,-90+XAngleSkew(keyID),90-ZAngleSkew(keyID)])skin(FrontCurve);
#translate([-TopWidShift(keyID),-TopLenShift(keyID),KeyHeight(keyID)-DishHeightDif(keyID)])rotate([0,-YAngleSkew(keyID),0])rotate([0,-90+XAngleSkew(keyID),90-ZAngleSkew(keyID)])skin(BackCurve);
}
}
if(crossSection == true) {
translate([0,-25,-.1])cube([15,50,15]);
}
}
if(homeDot == true){
r = 0.5;
x = 2;
y = -4.5;
z = KeyHeight(keyID)-DishHeightDif(keyID) + 0.3 * r;
translate([x, y, z])sphere(r);
translate([-x, y, z])sphere(r);
}
if(homeBar == true) {
homey = -4.5;
homez = KeyHeight(keyID)-DishHeightDif(keyID) + 0.15;
l = 5.5;
r = 0.5;
translate([0, homey, homez])
rotate([0,90,0])
translate([0, 0, -l / 2])
union () {
translate([0, 0, r]) sphere(r = r);
translate([0, 0, r])cylinder(h = l -r * 2, r= r);
translate([0, 0, l - r])sphere(r = r);
};
};
};
//------------------stems
$fn = fn;
module choc_stem(draftAng = 5) {
stemHeight = 3.1;
dia = .15;
wids = 1.2/2;
lens = 2.9/2;
module Stem() {
difference(){
translate([0,0,-stemHeight/2])linear_extrude(height = stemHeight)hull(){
translate([wids-dia,-3/2])circle(d=dia);
translate([-wids+dia,-3/2])circle(d=dia);
translate([wids-dia, 3/2])circle(d=dia);
translate([-wids+dia, 3/2])circle(d=dia);
}
//cuts
translate([3.9,0])cylinder(d1=7+sin(draftAng)*stemHeight, d2=7,3.5, center = true, $fn = 64);
translate([-3.9,0])cylinder(d1=7+sin(draftAng)*stemHeight,d2=7,3.5, center = true, $fn = 64);
}
}
translate([5.7/2,0,-stemHeight/2+2])Stem();
translate([-5.7/2,0,-stemHeight/2+2])Stem();
}
/// ----- helper functions
function rounded_rectangle_profile(size=[1,1],r=1,fn=32) = [
for (index = [0:fn-1])
let(a = index/fn*360)
r * [cos(a), sin(a)]
+ sign_x(index, fn) * [size[0]/2-r,0]
+ sign_y(index, fn) * [0,size[1]/2-r]
];
function elliptical_rectangle(a = [1,1], b =[1,1], fn=32) = [
for (index = [0:fn-1]) // section right
let(theta1 = -atan(a[1]/b[1])+ 2*atan(a[1]/b[1])*index/fn)
[b[1]*cos(theta1), a[1]*sin(theta1)]
+ [a[0]*cos(atan(b[0]/a[0])) , 0]
- [b[1]*cos(atan(a[1]/b[1])) , 0],
for(index = [0:fn-1]) // section Top
let(theta2 = atan(b[0]/a[0]) + (180 -2*atan(b[0]/a[0]))*index/fn)
[a[0]*cos(theta2), b[0]*sin(theta2)]
- [0, b[0]*sin(atan(b[0]/a[0]))]
+ [0, a[1]*sin(atan(a[1]/b[1]))],
for(index = [0:fn-1]) // section left
let(theta2 = -atan(a[1]/b[1])+180+ 2*atan(a[1]/b[1])*index/fn)
[b[1]*cos(theta2), a[1]*sin(theta2)]
- [a[0]*cos(atan(b[0]/a[0])) , 0]
+ [b[1]*cos(atan(a[1]/b[1])) , 0],
for(index = [0:fn-1]) // section Top
let(theta2 = atan(b[0]/a[0]) + 180 + (180 -2*atan(b[0]/a[0]))*index/fn)
[a[0]*cos(theta2), b[0]*sin(theta2)]
+ [0, b[0]*sin(atan(b[0]/a[0]))]
- [0, a[1]*sin(atan(a[1]/b[1]))]
]/2;
function sign_x(i,n) =
i < n/4 || i > n-n/4 ? 1 :
i > n/4 && i < n-n/4 ? -1 :
0;
function sign_y(i,n) =
i > 0 && i < n/2 ? 1 :
i > n/2 ? -1 :
0;
//lp_production_base();
//for(i = [0:3-1]){
// for(j = [0:2-1]){
// translate([(1-i)*21, (.5-j)*21,0]){
// keycap(keyID = 1, cutLen = 0, Stem =false, Dish = true, SecondaryDish = false ,Stab = 0 , visualizeDish =false , crossSection = false, homeDot = true, Legends = false);
//// import("R3X.stl");
// }
// }
// }
//for(i = [0:1-1]){
// for(j = [0:2-1]){
// translate([(1-i)*21, (.5-j)*21,0]){
// keycap(keyID = 1, cutLen = 0, Stem =false, Dish = true, SecondaryDish = false ,Stab = 0 , visualizeDish =false , crossSection = false, homeDot = true, Legends = false);
// }
// }
// }
//translate([(1-0)*21, (.5-0)*21,0])