This commit is contained in:
pseudoku 2020-01-10 23:13:28 -06:00
parent 45d53ff213
commit bbdd8a5deb
7 changed files with 1528 additions and 21 deletions

View file

@ -15,7 +15,7 @@ use <z-butt.scad>
//}
difference(){
translate([0,0,-0])keycap(keyID = 27, cutLen = -ChocCut, Stem =true, Dish = true, Stab = 0 , visualizeDish = false, crossSection = false, homeDot = false, Legends = false);
translate([0,0,-0])keycap(keyID = 5, cutLen = -ChocCut, Stem =true, Dish = true, Stab = 0 , visualizeDish = false, crossSection = false, homeDot = false, Legends = false);
}
// #lp_master_base();

View file

@ -31,15 +31,15 @@ TODOs:
//#mirror([0,0,0])translate([0,0,1.95])keycap(keyID = capID, cutLen = 0, Stem =false, Dish = true, Stab = 0 , visualizeDish = false, crossSection = false, homeDot = false, Legends = false);
//bottom cast param
capID = 39;
capID = 1;
difference(){
mx_stem_cavity(name = "custom", xu=2, yu=1., sz = 10)translate([0,0,-.75])mirror([1,0,0])keycap(keyID = capID, cutLen = 0, Stem =true, Dish = true, Stab = 0 , visualizeDish = false, crossSection = false, homeDot = false, Legends = false);
mx_stem_cavity(name = "custom", xu=1, yu=1., sz = 10)translate([0,0,-.75])mirror([1,0,0])keycap(keyID = capID, cutLen = 0, Stem =true, Dish = true, Stab = 0 , visualizeDish = false, crossSection = false, homeDot = false, Legends = false);
// translate([0,-30,-25]) cube([60,60,50]); // cut check
}
#translate([0,-0,-1]) keycap(keyID = capID, cutLen = 0, Stem =false, Dish = true, Stab = 0 , visualizeDish = false, crossSection = false, homeDot = false, Legends = false);
//#translate([0,-0,-1]) keycap(keyID = capID, cutLen = 0, Stem =false, Dish = true, Stab = 0 , visualizeDish = false, crossSection = false, homeDot = false, Legends = false);
//Parameters
wallthickness = 2;

View file

@ -0,0 +1,454 @@
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>
// R3 1.25=5 1.75 13
// R4 1.25=6 1.75 14
// R5 1.50=8 2.25=20, 2.75=24
/*DES (Distorted Elliptical Saddle) Sculpted Profile for 6x3 and corne thumb
Version 2: Eliptical Rectangle
*/
//#square([18.16, 18.16], center = true);
//#square([41.3, 19.05], center = true);
mirror([0,0,0])rotate([22.94,0,0])keycap(keyID = 24, cutLen = 0, Stem =true, Dish = true, Stab = 0 , visualizeDish = false, crossSection = false, homeDot = false, Legends = false);
//mirror([0,0,0])translate([19*2.5,0,0])keycap(keyID = 24, cutLen = 0, Stem =true, Dish = true, Stab = 0 , visualizeDish = false, crossSection = false, homeDot = false, Legends = false);
//mirror([0,0,0])translate([-19.00*1.875,0,0])keycap(keyID = 8, cutLen = 0, Stem =true, Dish = true, Stab = 0 , visualizeDish = false, crossSection = false, homeDot = false, Legends = false);
//mirror([0,0,0])translate([19.00*4.625,0,0])keycap(keyID = 8, cutLen = 0, Stem =true, Dish = true, Stab = 0 , visualizeDish = false, crossSection = false, homeDot = false, Legends = false);
//
//translate([-19,0,0])keycap(keyID = 3, cutLen = 0, Stem =true, Dish = true, Stab = 0 , visualizeDish = false, crossSection = false, homeDot = false, Legends = false);
//translate([19,0,0])mirror([0,0,0])keycap(keyID = 5, cutLen = 0, Stem =true, Dish = true, Stab = 0 , visualizeDish = false, crossSection = false, homeDot = false, Legends = false);
//translate([19*.5,19,0])mirror([1,0,0])keycap(keyID = 6, cutLen = 0, Stem =true, Dish = true, Stab = 0 , visualizeDish = false, crossSection = false, homeDot = false, Legends = false);
//for(i=[0:2]){translate([0,(i+1)*19,0])keycap(keyID = i, cutLen = 0, Stem =true, Dish = true, visualizeDish = false, crossSection = false, homeDot = false, Legends = false);}
//n translate([0,19, 0])keycap(keyID = 3, cutLen = 0, Stem =true, Dish = true, visualizeDish = true, crossSection = true, homeDot = false, Legends = false);
// translate([0,38, 0])mirror([0,1,0])keycap(keyID = 2, cutLen = 0, Stem =true, Dish = true, visualizeDish = false, crossSection = true, homeDot = false, Legends = false);
//for(i=[0:11]){translate([i*19-19*6,(3)*19,0])keycap(keyID = 2, cutLen = 0, Stem =true, Dish = true, visualizeDish = false, crossSection = false, homeDot = false, Legends = false);}
//for(i=[0:8]){translate([i*19-19*4.75,(2)*19,0])keycap(keyID = 1, cutLen = 0, Stem =true, Dish = true, visualizeDish = false, crossSection = false, homeDot = false, Legends = false);}
//for(i=[0:8]){color("royalblue")translate([i*19-19*2.375,(1)*19,0])keycap(keyID = 0, cutLen = 0, Stem =true, Dish = true, visualizeDish = false, crossSection = false, homeDot = false, Legends = false);}
//for(i=[8:11]){translate([19,(i-8)*19,0])keycap(keyID = i, cutLen = 0, Stem =true, Dish = true, visualizeDish = false, crossSection = false, homeDot = false, Legends = false);}
//for(i=[12:15]){translate([25,(i-12)*19,0])keycap(keyID = i, cutLen = 0, Stem =true, Dish = true, visualizeDish = false, crossSection = false, homeDot = false, Legends = false);}
//for(i=[20:23]){translate([30,(i-20)*19,0])keycap(keyID = i, cutLen = 0, Stem =true, Dish = true, visualizeDish = false, crossSection = false, homeDot = false, Legends = false);}
//for(i=[24:27]){translate([25,(i-24)*19,0])keycap(keyID = i, cutLen = 0, Stem =true, Dish = true, visualizeDish = false, crossSection = false, homeDot = false, Legends = false);}
//#translate([0,38,13])cube([18-5.7, 18-5.7,1],center = true);
//echo(len(keyParameters));
//Parameters
wallthickness = 1.25; // 1.5 for norm, 1.25 for cast master
topthickness = 2.75; // 3 for norm, 2.5 for cast master
stepsize = 50; //resolution of Trajectory
step = 2; //resolution of ellipes
fn = 32; //resolution of Rounded Rectangles: 60 for output
layers = 40; //resolution of vertical Sweep: 50 for output
dotRadius = 0.55; //home dot size
//---Stem param
slop = 0.40;
stemRot = 0;
stemWid = 7.2;
stemLen = 5.5;
stemCrossHeight = 4;
extra_vertical = 0.6;
StemBrimDep = 0.25;
stemLayers = 50; //resolution of stem to cap top transition
keyParameters = //keyParameters[KeyID][ParameterID]
[
// BotWid, BotLen, TWDif, TLDif, keyh, WSft, LSft XSkew, YSkew, ZSkew, WEx, LEx, CapR0i, CapR0f, CapR1i, CapR1f, CapREx, StemEx
//Column high sculpt 3 row system
//0~3
[17.16, 17.16, 6.5, 6.5,10.55, 0, 0, 9, 0, 0, 2, 2, 1, 5, 1, 3.5, 2, 2], //R4 8
[17.16, 17.16, 6.5, 6.5, 8.75, 0, .5, 4, 0, 0, 2, 2, 1, 5, 1, 3.5, 2, 2], //R3 Home
[17.16, 17.16, 6.5, 6.5, 9.75, 0, 0, -13, 0, 0, 2, 2, 1, 5, 1, 3.5, 2, 2], //R2
[17.16, 17.16, 6.5, 6.5, 8.75, 0, 0, 4, 0, 0, 2, 2, 1, 5, 1, 3.5, 2, 2], //R3 deepdish
//1.25u 4~7
[21.86, 17.16, 6.5, 6.5, 11.5, 0, 0, -3, 0, 0, 2, 2, 1, 5, 1, 3.5, 2, 2], //R5
[21.86, 17.16, 6.5, 6.5,10.55, .5, 0, 9, 3, 0, 2, 2, 1, 5, 1, 3.5, 2, 2], //R4
[21.86, 17.16, 6.5, 6.5, 8.75, -.5, .5, 4, -3, 0, 2, 2, 1, 5, 1, 3.5, 2, 2], //R3 Home
[21.86, 17.16, 6.5, 6.5, 9.75, 0, 0, -13, 0, 0, 2, 2, 1, 5, 1, 3.5, 2, 2], //R2
//1.5u 8~11
[26.66, 17.16, 6.5, 6.5, 11.5, 0, 0, -3, 0, 0, 2, 2, 1, 5, 1, 3.5, 2, 2], //R5
[26.66, 17.16, 6.5, 6.5,10.55, 0, 0, 9, 0, 0, 2, 2, 1, 5, 1, 3.5, 2, 2], //R4
[26.66, 17.16, 6.5, 6.5, 8.75, 0, .5, 4, 0, 0, 2, 2, 1, 5, 1, 3.5, 2, 2], //R3 Home
[26.66, 17.16, 6.5, 6.5, 9.75, 0, 0, -13, 0, 0, 2, 2, 1, 5, 1, 3.5, 2, 2], //R2
//1.75u 12~15
[31.06, 17.16, 6.5, 6.5, 11.5, 0, 0, -3, 0, 0, 2, 2, 1, 5, 1, 3.5, 2, 2], //R5
[31.06, 17.16, 6.5, 6.5,10.55, 0, 0, 9, -3, 0, 2, 2, 1, 5, 1, 3.5, 2, 2], //R4
[31.06, 17.16, 6.5, 6.5, 8.75, 0, .5, 4, 3, 0, 2, 2, 1, 5, 1, 3.5, 2, 2], //R3 Home
[31.06, 17.16, 6.5, 6.5, 9.75, 0, 0, -13, 0, 0, 2, 2, 1, 5, 1, 3.5, 2, 2], //R2
//2.0u 16~19
[35.46, 17.16, 6.5, 6.5, 11.5, 0, 0, -3, 0, 0, 2, 2, 1, 5, 1, 3.5, 2, 2], //R5
[35.46, 17.16, 6.5, 6.5,10.55, 0, 0, 9, 0, 0, 2, 2, 1, 5, 1, 3.5, 2, 2], //R4
[35.46, 17.16, 6.5, 6.5, 8.75, 0, .5, 4, 0, 0, 2, 2, 1, 5, 1, 3.5, 2, 2], //R3 Home
[35.46, 17.16, 6.5, 6.5, 9.75, 0, 0, -13, 0, 0, 2, 2, 1, 5, 1, 3.5, 2, 2], //R2
//2.25u 20~23
[40.66, 17.16, 6.5, 6.5, 10.5, 0, 0, -3, -3, 0, 2, 2, 1, 5, 1, 3.5, 2, 2], //R5
[35.46, 17.16, 6.5, 6.5,10.55, 0, 0, 9, 0, 0, 2, 2, 1, 5, 1, 3.5, 2, 2], //R4
[35.46, 17.16, 6.5, 6.5, 8.75, 0, .5, 4, 0, 0, 2, 2, 1, 5, 1, 3.5, 2, 2], //R3 Home
[35.46, 17.16, 6.5, 6.5, 9.75, 0, 0, -13, 0, 0, 2, 2, 1, 5, 1, 3.5, 2, 2], //R2
//2.75u 24
[50.66, 17.16, 6.5, 6.5, 10.5, 0, 0, -3, 2, 0, 2, 2, 1, 5, 1, 3.5, 2, 2], //R5
[35.46, 17.16, 6.5, 6.5,10.55, 0, 0, 9, 0, 0, 2, 2, 1, 5, 1, 3.5, 2, 2], //R4
[35.46, 17.16, 6.5, 6.5, 8.75, 0, .5, -4, 0, 0, 2, 2, 1, 5, 1, 3.5, 2, 2], //R3 Home
[35.46, 17.16, 6.5, 6.5, 9.75, 0, 0, -13, 0, 0, 2, 2, 1, 5, 1, 3.5, 2, 2], //R2
];
dishParameters = //dishParameter[keyID][ParameterID]
[
//FFwd1 FFwd2 FPit1 FPit2 DshDep DshHDif FArcIn FArcFn FArcEx BFwd1 BFwd2 BPit1 BPit2 BArcIn BArcFn BArcEx
// low pro 3 row system
[ 6, 3, 18, -50, 5, 1.8, 8.8, 15, 2, 5, 4.4, 5, -55, 8.8, 15, 2], //R4
[ 5, 3.5, 10, -55, 5, 1.8, 8.5, 15, 2, 5, 3.7, 10, -55, 8.5, 15, 2], //R3
[ 6, 3, 10, -50, 5, 1.8, 8.8, 15, 2, 6, 4, 13, 30, 8.8, 16, 2], //R2
[ 4.8, 3.3, 18, -55, 5, 2.0, 8.5, 15, 2, 4.8, 3.3, 18, -55, 8.5, 15, 2], //R3 deep
//1.25
[ 6, 3, -5, -50, 5, 1.8, 12.4, 18, 2, 6, 3.5, 13, -50, 12.4, 19, 2], //R5
[ 6, 3, 18, -50, 5, 1.8, 12.4, 20, 2, 5, 4.4, 5, -55, 12.4, 19, 2], //R4
[ 5, 3.5, 10, -55, 5, 1.8, 12.4, 18, 2, 5, 3.7, 10, -55, 12.4, 19, 2], //R3
[ 6, 3, 10, -50, 5, 1.8, 12.4, 18, 2, 6, 4, 13, 30, 12.4, 19, 2], //R2
//1.5
[ 6, 3, -5, -50, 5, 1.8, 15.5, 22, 2, 6, 3.5, 13, -50, 15.5, 22, 2], //R5
[ 6, 3, 18, -50, 5, 1.8, 15.5, 27.2, 2, 5, 4.4, 5, -55, 15.5, 22, 2], //R4
[ 5, 3.5, 10, -55, 5, 1.8, 15.5, 22, 2, 5, 3.7, 10, -55, 15.5, 22, 2], //R3
[ 6, 3, 10, -50, 5, 1.8, 15.7, 22, 2, 6, 4, 13, 30, 15.7, 23, 2], //R2
//1.75
[ 6, 3, -5, -50, 5, 1.8, 18.7, 25, 2, 6, 3.5, 13, -50, 18.7, 25, 2], //R5
[ 6, 3, 17, -50, 5, 1.8, 18.7, 32, 2, 5, 4.4, 5, -55, 18.7, 25, 2], //R4
[ 5, 3.5, 10, -55, 5, 1.8, 18.7, 27, 2, 5, 3.8, 10, -55, 18.7, 25, 2], //R3
[ 6, 3, 10, -50, 5, 1.8, 18.7, 25, 2, 6, 4, 13, 30, 18.7, 28, 2], //R2
//2
[ 6, 3, -5, -50, 5, 1.8, 21.9, 30, 2, 6, 3.5, 13, -50, 21.9, 31, 2], //R5
[ 6, 3, 15, -50, 5, 1.8, 21.9, 34, 2, 5, 4.4, 5, -55, 21.9, 31, 2], //R4
[ 6, 3, 17, -55, 5, 1.8, 21.9, 32.5, 2, 5, 3.7, 8, -55, 21.9, 31, 2], //R3
[ 6, 3, 10, -50, 5, 1.8, 21.9, 30, 2, 5, 4, 11.5, -55, 21.9, 33, 2], //R2
//2.25
[ 6, 3, -5, -50, 5, 1.8, 25.6, 30, 2, 6, 3.5, 13, -50, 25.6, 40, 2], //R5
[ 6, 3, 15, -50, 5, 1.8, 21.9, 34, 2, 5, 4.4, 5, -55, 21.9, 31, 2], //R4
[ 6, 3, 17, -55, 5, 1.8, 21.9, 32.5, 2, 5, 3.7, 8, -55, 21.9, 31, 2], //R3
[ 6, 3, 10, -50, 5, 1.8, 21.9, 30, 2, 5, 4, 11.5, -55, 21.9, 33, 2], //R2
//2.75
[ 6, 3, -5, -50, 5, 1.8, 33.1, 38, 2, 6, 3.5, 13, -50, 33.1, 50, 2], //R5
[ 6, 3, 15, -50, 5, 1.8, 21.9, 34, 2, 5, 4.4, 5, -55, 21.9, 31, 2], //R4
[ 6, 3, 17, -55, 5, 1.8, 21.9, 32.5, 2, 5, 3.7, 8, -55, 21.9, 31, 2], //R3
[ 6, 3, 10, -50, 5, 1.8, 21.9, 30, 2, 5, 4, 11.5, -55, 21.9, 33, 2], //R2
];
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 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 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(forward = BackForward1(keyID), pitch = BackPitch1(keyID)),
trajectory(forward = 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 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+StemBrimDep + (t/stemLayers*(KeyHeight(keyID)- topthickness - stemCrossHeight-.1 -StemBrimDep)) //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) + (1-pow(t/stemLayers, StemExponent(keyID)))*(stemWid - 2*slop),
pow(t/stemLayers, StemExponent(keyID))*(BottomLength(keyID)-TopLenDiff(keyID)-wallthickness) + (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(keyID = 0, cutLen = 0, visualizeDish = false, rossSection = false, Dish = true, Stem = false, crossSection = true,Legends = false, homeDot = false, Stab = 0) {
//Set Parameters for dish shape
FrontPath = quantize_trajectories(FrontTrajectory(keyID), steps = stepsize, loop=false, start_position= $t*4);
BackPath = quantize_trajectories(BackTrajectory(keyID), steps = stepsize, loop=false, start_position= $t*4);
//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){
translate([0,0,StemBrimDep])cherry_stem(KeyHeight(keyID)-StemBrimDep, slop); // generate mx cherry stem, not compatible with box
if (Stab != 0){
translate([Stab/2,0,0])rotate([0,0,stemRot])cherry_stem(KeyHeight(keyID), slop);
translate([-Stab/2,0,0])rotate([0,0,stemRot])cherry_stem(KeyHeight(keyID), slop);
//TODO add binding support?
}
// 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)))]); //Transition Support for taller profile
}
//cut for fonts and extra pattern for light?
}
//Cuts
//Fonts
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" );
// #rotate([-XAngleSkew(keyID),YAngleSkew(keyID),ZAngleSkew(keyID)])translate([0,-3.5,0])linear_extrude(height = 0.5)text( text = "Me", font = "Constantia:style=Bold", size = 3, valign = "center", halign = "center" );
}
//Dish Shape
if(Dish == true){
if(visualizeDish == false){
translate([-TopWidShift(keyID),.00001-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),270-ZAngleSkew(keyID)])skin(BackCurve);
} else {
#translate([-TopWidShift(keyID),.00001-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),270-ZAngleSkew(keyID)])skin(BackCurve);
}
}
if(crossSection == true) {
translate([0,-15,-.1])cube([15,30,15]);
}
if(homeDot == true)#translate([0,0,KeyHeight(keyID)-DishHeightDif(keyID)-0.1])sphere(r = dotRadius);
}
//Homing dot
}
//------------------stems
$fn = fn;
function outer_cherry_stem(slop) = [ stemWid - slop * 2, stemLen - slop * 2];
function outer_cherry_stabilizer_stem(slop) = [4.85 - slop * 2, 6.05 - slop * 2];
function outer_box_cherry_stem(slop) = [6 - slop, 6 - slop];
// .005 purely for aesthetics, to get rid of that ugly crosshatch
function cherry_cross(slop, extra_vertical = 0) = [
// horizontal tine
[4.03 + slop, 1.15 + slop / 3],
// vertical tine
[1.25 + slop / 3, 4.23 + extra_vertical + slop / 3 + .005],
];
module inside_cherry_cross(slop) {
// inside cross
// translation purely for aesthetic purposes, to get rid of that awful lattice
translate([0,0,-0.005]) {
linear_extrude(height = stemCrossHeight) {
square(cherry_cross(slop, extra_vertical)[0], center=true);
square(cherry_cross(slop, extra_vertical)[1], center=true);
}
}
// Guides to assist insertion and mitigate first layer squishing
{
for (i = cherry_cross(slop, extra_vertical)) hull() {
linear_extrude(height = 0.01, center = false) offset(delta = 0.4) square(i, center=true);
translate([0, 0, 0.5]) linear_extrude(height = 0.01, center = false) square(i, center=true);
}
}
}
module cherry_stem(depth, slop) {
D1=.15;
D2=.05;
H1=3.5;
CrossDist = 1.75;
difference(){
// outside shape
linear_extrude(height = depth) {
offset(r=1){
square(outer_cherry_stem(slop) - [2,2], center=true);
}
}
rotate([0,0,stemRot])inside_cherry_cross(slop);
hull(){
translate([CrossDist,CrossDist-.1,0])cylinder(d1=D1, d2=D2, H1);
translate([-CrossDist,-CrossDist+.1,0])cylinder(d1=D1, d2=D2, H1);
}
hull(){
translate([-CrossDist,CrossDist-.1])cylinder(d1=D1, d2=D2, H1);
translate([CrossDist,-CrossDist+.1])cylinder(d1=D1, d2=D2, H1);
}
}
}
module choc_stem() {
translate([5.7/2,0,-3.4/2+2])difference(){
cube([1.25,3, 3.4], center= true);
translate([3.9,0,0])cylinder(d=7,3.4,center = true);
translate([-3.9,0,0])cylinder(d=7,3.4,center = true);
}
translate([-5.7/2,0,-3.4/2+2])difference(){
cube([1.25,3, 3.4], center= true);
translate([3.9,0,0])cylinder(d=7,3.4,center = true);
translate([-3.9,0,0])cylinder(d=7,3.4,center = true);
}
}
/// ----- 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;

View file

@ -5,7 +5,9 @@ use <scad-utils/trajectory.scad>
use <scad-utils/trajectory_path.scad>
use <sweep.scad>
use <skin.scad>
// R3 1.25x 1.75x
// R4 1.25x 1.75
// R5 1.50x 2.25, 2.75
/*DES (Distorted Elliptical Saddle) Sculpted Profile for 6x3 and corne thumb
Version 2: Eliptical Rectangle
@ -13,17 +15,18 @@ Version 2: Eliptical Rectangle
//#square([18.16, 18.16], center = true);
//#square([36.3, 19.05], center = true);
mirror([0,0,0])keycap(keyID = 4, cutLen = 0, Stem =true, Dish = true, Stab = 0 , veisualizeDish = false, crossSection = false, homeDot = false, Legends = false);
translate([-19,0,0])keycap(keyID = 3, cutLen = 0, Stem =true, Dish = true, Stab = 0 , visualizeDish = false, crossSection = false, homeDot = false, Legends = false);
translate([19,0,0])mirror([0,0,0])keycap(keyID = 5, cutLen = 0, Stem =true, Dish = true, Stab = 0 , visualizeDish = false, crossSection = false, homeDot = false, Legends = false);
mirror([0,0,0])keycap(keyID = 36, cutLen = 0, Stem =true, Dish = true, Stab = 0 , veisualizeDish = false, crossSection = false, homeDot = false, Legends = false);
//translate([-19,0,0])keycap(keyID = 3, cutLen = 0, Stem =true, Dish = true, Stab = 0 , visualizeDish = false, crossSection = false, homeDot = false, Legends = false);
//translate([19,0,0])mirror([0,0,0])keycap(keyID = 5, cutLen = 0, Stem =true, Dish = true, Stab = 0 , visualizeDish = false, crossSection = false, homeDot = false, Legends = false);
//translate([19*.5,19,0])mirror([1,0,0])keycap(keyID = 6, cutLen = 0, Stem =true, Dish = true, Stab = 0 , visualizeDish = false, crossSection = false, homeDot = false, Legends = false);
//n translate([0,19, 0])keycap(keyID = 3, cutLen = 0, Stem =true, Dish = true, visualizeDish = true, crossSection = true, homeDot = false, Legends = false);
// translate([0,38, 0])mirror([0,1,0])keycap(keyID = 2, cutLen = 0, Stem =true, Dish = true, visualizeDish = false, crossSection = true, homeDot = false, Legends = false);
//Low Pro rows
//for(cap = [6:8]){
//translate([-38, 19*(cap-6), 0])keycap(keyID = cap, cutLen = 0, Stem = false, Dish = true, visualizeDish = false, crossSection = true,Legends = false);
//for(cap = [8:10]){
//translate([-38, 19*(cap-8), 0])keycap(keyID = cap, cutLen = 0, Stem = false, Dish = true, visualizeDish = false, crossSection = true,Legends = false);
//}
//for(cap = [70:72]){
//translate([-19, 19*(cap-70), 0])keycap(keyID = cap, cutLen = 0, Stem = false, Dish = true, visualizeDish = false, crossSection = false,Legends = false);
@ -97,11 +100,11 @@ keyParameters = //keyParameters[KeyID][ParameterID]
[17.16, 17.16, 4, 5, 10., 0, 0, -12, 5, 0, 2, 2, 1, 5, 1, 3, 2, 2], //R5 corne thumb
[17.16, 17.16, 4, 6, 11, 0, 0, -12, 10, 15, 2, 2, 1, 5, 1, 2, 2, 2], //R5 corne thumb
//Column high sculpt 3 row system
[17.16, 17.16, 6.5, 6.5,10.25, 0, -.25, 10, 0, 0, 2, 2, 1, 5, 1, 3.5, 2, 2], //R4 6
[17.16, 17.16, 6.5, 6.5, 8.75, 0, .5, -5, 0, 0, 2, 2, 1, 5, 1, 3.5, 2, 2], //R3 Home
[17.16, 17.16, 6.5, 6.5,10.75, 0, -.25, -13, 0, 0, 2, 2, 1, 5, 1, 3.5, 2, 2], //R2
[17.16, 17.16, 6.5, 6.5, 8.75, 0, .5, -5, 0, 0, 2, 2, 1, 5, 1, 3.5, 2, 2], //R3 deepdish
//kyria Thumbs 10 ~ 16
[17.16, 17.16, 6.5, 6.5,10.55, 0, 0, 9, 0, 0, 2, 2, 1, 5, 1, 3.5, 2, 2], //R4 8
[17.16, 17.16, 6.5, 6.5, 8.75, 0, .5, 4, 0, 0, 2, 2, 1, 5, 1, 3.5, 2, 2], //R3 Home
[17.16, 17.16, 6.5, 6.5, 9.75, 0, 0, -13, 0, 0, 2, 2, 1, 5, 1, 3.5, 2, 2], //R2
[17.16, 17.16, 6.5, 6.5, 8.75, 0, 0, 4, 0, 0, 2, 2, 1, 5, 1, 3.5, 2, 2], //R3 deepdish
//kyria Thumbs 13 ~ 19
[17.16, 35.56, 6, 7, 11, 0, 0, -8, 10, -5, 2, 2, 1, 4.85, 1, 3.5, 2, 2], //T0R1 2u
[17.16, 17.16, 6, 5, 11, -.5, 0, -9, 7, 10, 2, 2, 1, 5, 1, 3, 2, 2], //T0R1 1u
[17.16, 17.16, 6, 5, 13, -.5, 0, -9, 7, 5, 2, 2, 1, 5, 1, 3.5, 2, 2], //T0R2 1u
@ -117,19 +120,19 @@ keyParameters = //keyParameters[KeyID][ParameterID]
[17.16, 17.16, 6.5, 6.5, 10, 0, 0, -11, 0, 0, 2, 2, 1, 5, 1, 3.5, 2, 2], //R2
[17.16, 17.16, 6.5, 6.5, 14.0, 0, -.25, -14, 0, 0, 2, 2, 1, 5, 1, 3.5, 2, 2], //R1
[17.16, 17.16, 6.5, 6.5, 9, 0, 0, -5, 0, 0, 2, 2, 1, 5, 1, 3.5, 2, 2], //R3 Home Deeper
//1.25u 18~23
//1.25u 25~30
[21.86, 17.16, 6.5, 6.5, 10.5, 0, 0, -3, 0, 0, 2, 2, 1, 5, 1, 3.5, 2, 2], //R5
[21.86, 17.16, 6.5, 6.5, 9.5, 0, 0, 9, 0, 0, 2, 2, 1, 5, 1, 3.5, 2, 2], //R4
[21.86, 17.16, 6.5, 6.5, 8.5, 0, .5, -5, 0, 0, 2, 2, 1, 5, 1, 3.5, 2, 2], //R3 Home
[21.86, 17.16, 6.5, 6.5, 10, 0, 0, -11, 0, 0, 2, 2, 1, 5, 1, 3.5, 2, 2], //R2
[21.86, 17.16, 6.5, 6.5, 14.0, 0, -.25, -14, 0, 0, 2, 2, 1, 5, 1, 3.5, 2, 2], //R1
//1.5u
//1.5u 31~36
[26.66, 17.16, 6.5, 6.5, 10.5, 0, 0, -3, 0, 0, 2, 2, 1, 5, 1, 3.5, 2, 2], //R5
[26.66, 17.16, 6.5, 6.5, 9.5, 0, 0, 9, 0, 0, 2, 2, 1, 5, 1, 3.5, 2, 2], //R4
[26.66, 17.16, 6.5, 6.5, 8.5, 0, .5, -5, 0, 0, 2, 2, 1, 5, 1, 3.5, 2, 2], //R3 Home
[26.66, 17.16, 6.5, 6.5, 10, 0, 0, -11, 0, 0, 2, 2, 1, 5, 1, 3.5, 2, 2], //R2
[26.66, 17.16, 6.5, 6.5, 14.0, 0, -.25, -14, 0, 0, 2, 2, 1, 5, 1, 3.5, 2, 2], //R1
//1.75u
//1.75u 37~42
[31.06, 17.16, 6.5, 6.5, 10.5, 0, 0, -3, 0, 0, 2, 2, 1, 5, 1, 3.5, 2, 2], //R5
[31.06, 17.16, 6.5, 6.5, 9.5, 0, 0, 9, 0, 0, 2, 2, 1, 5, 1, 3.5, 2, 2], //R4
[31.06, 17.16, 6.5, 6.5, 8.5, 0, .5, -5, 0, 0, 2, 2, 1, 5, 1, 3.5, 2, 2], //R3 Home
@ -196,7 +199,7 @@ dishParameters = //dishParameter[keyID][ParameterID]
// low pro 3 row system
[ 6, 3, 18, -50, 5, 1.8, 8.8, 15, 2, 5, 4.4, 5, -55, 8.8, 15, 2], //R4
[ 5, 3.5, 10, -55, 5, 1.8, 8.5, 15, 2, 5, 3.5, 10, -55, 8.5, 15, 2], //R3
[ 5, 3.5, 10, -55, 5, 1.8, 8.5, 15, 2, 5, 3.7, 10, -55, 8.5, 15, 2], //R3
[ 6, 3, 10, -50, 5, 1.8, 8.8, 15, 2, 6, 4, 13, 30, 8.8, 16, 2], //R2
[ 4.8, 3.3, 18, -55, 5, 2.0, 8.5, 15, 2, 4.8, 3.3, 18, -55, 8.5, 15, 2], //R3 deep
//kyria

456
DES_MX_Manuform.scad Normal file
View file

@ -0,0 +1,456 @@
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>
/*DES (Distorted Elliptical Saddle) Sculpted Profile for 6x3 and corne thumb
Version 2: Eliptical Rectangle
*/
//#square([18.16, 18.16], center = true);
//#square([36.3, 19.05], center = true);
mirror([1,0,0])keycap(keyID = 18, cutLen = 0, Stem =true, Dish = true, Stab = 0 , veisualizeDish = false, crossSection = false, homeDot = false, Legends = false);
//translate([-19,0,0])keycap(keyID = 3, cutLen = 0, Stem =true, Dish = true, Stab = 0 , visualizeDish = false, crossSection = false, homeDot = false, Legends = false);
//translate([19,0,0])mirror([0,0,0])keycap(keyID = 5, cutLen = 0, Stem =true, Dish = true, Stab = 0 , visualizeDish = false, crossSection = false, homeDot = false, Legends = false);
//translate([19*.5,19,0])mirror([1,0,0])keycap(keyID = 6, cutLen = 0, Stem =true, Dish = true, Stab = 0 , visualizeDish = false, crossSection = false, homeDot = false, Legends = false);
//n translate([0,19, 0])keycap(keyID = 3, cutLen = 0, Stem =true, Dish = true, visualizeDish = true, crossSection = true, homeDot = false, Legends = false);
// translate([0,38, 0])mirror([0,1,0])keycap(keyID = 2, cutLen = 0, Stem =true, Dish = true, visualizeDish = false, crossSection = true, homeDot = false, Legends = false);
//Low Pro rows
//for(cap = [8:10]){
////translate([19, 19*(cap-8), 0])keycap(keyID = cap, cutLen = 0, Stem = false, Dish = true, visualizeDish = false, crossSection = false,Legends = false);
//}
//for(cap = [12:15]){
//translate([-0, 19*(cap-12), 0])keycap(keyID = cap, cutLen = 0, Stem = false, Dish = true, visualizeDish = false, crossSection = false,Legends = false);
//}
//translate([-19, 19*(3), 0])keycap(keyID = 6, cutLen = 0, Stem = false, Dish = true, visualizeDish = false, crossSection = true,Legends = false);
//
//for(cap = [64:68]){
//translate([0, 19*(cap-64), 0])keycap(keyID = cap, cutLen = 0, Stem = false, Dish = true, visualizeDish = false, crossSection = false,Legends = false);
//}
//for(cap = [20:24]){
//translate([0, 19*(cap-20), 0])keycap(keyID = cap, cutLen = 0, Stem = false, Dish = true, visualizeDish = false, crossSection = true,Legends = false);
//}
//translate([19, 19*(2), 0])keycap(keyID = 25, cutLen = 0, Stem = false, Dish = true, visualizeDish = false, crossSection = true,Legends = false);
//////corne thumb
// translate([-15, -4, 0])rotate([0,0,30])keycap(keyID = 0, cutLen = 0, Stem =false, Dish = true, visualizeDish = false, crossSection = false);
// translate([6, 0, 0])rotate([0,0,15])keycap(keyID = 4, cutLen = 0, Stem =false, Dish = true, visualizeDish = false, crossSection = false);
// translate([26, 2.2, 0])rotate([0,0,0])keycap(keyID = 8, cutLen = 0, Stem =false, Dish = true, visualizeDish = false, crossSection = false);
//LOW pro
// translate([-15, -4, 0])rotate([0,0,30])keycap(keyID =3, cutLen = 0, Stem =true, Dish = true, visualizeDish = false, crossSection = false);
// translate([6, 0, 0])rotate([0,0,15])keycap(keyID = 4, cutLen = 0, Stem =true, Dish = true, visualizeDish = false, crossSection = false);
// translate([26, 2.2, 0])rotate([0,0,0])keycap(keyID = 5, cutLen = 0, Stem =true, Dish = true, visualizeDish = false, crossSection = false);
//DM Thumb
// top row
//mirror([1,0,0]){
//translate([-39, 0, 0])rotate([0,0,30])translate([0, -1, 0])mirror([1,0,0])keycap(keyID = 7, cutLen = 0, Stem =false, Dish = true, visualizeDish = false, crossSection = false);
//translate([-17, 0, 0])rotate([0,0,30])translate([0, 10, 0])mirror([0,0,0])keycap(keyID = 7, cutLen = 0, Stem =false, Dish = true, visualizeDish = false, crossSection = false);
//
////bottom row
//translate([-39, 0, 0])rotate([0,0,30])translate([0,-19.5, 0])keycap(keyID = 16, cutLen = 0, Stem =true, Dish = true, visualizeDish = false, crossSection = false);
//translate([-17, 0, 0])rotate([0,0,30])translate([0,-8.5, 0])mirror([0,0,0])keycap(keyID = 17, cutLen = 0, Stem =true, Dish = true, visualizeDish = false, crossSection = false);
//
////inner
// translate([-3, 16, 0])rotate([0,0,15])keycap(keyID = 18, cutLen = 0, Stem =false, Dish = true, visualizeDish = false, crossSection = false);
//}
//#translate([0,38,13])cube([18-5.7, 18-5.7,1],center = true);
//echo(len(keyParameters));
//Parameters
wallthickness = 1.25; // 1.5 for norm, 1.25 for cast master
topthickness = 2.75; // 3 for norm, 2.5 for cast master
stepsize = 50; //resolution of Trajectory
step = 2; //resolution of ellipes
fn = 32; //resolution of Rounded Rectangles: 60 for output
layers = 40; //resolution of vertical Sweep: 50 for output
dotRadius = 1.25; //home dot size
//---Stem param
slop = 0.40;
stemRot = 0;
stemWid = 7.2;
stemLen = 5.5;
stemCrossHeight = 4;
extra_vertical = 0.6;
StemBrimDep = 0.25;
stemLayers = 50; //resolution of stem to cap top transition
keyParameters = //keyParameters[KeyID][ParameterID]
[
// BotWid, BotLen, TWDif, TLDif, keyh, WSft, LSft XSkew, YSkew, ZSkew, WEx, LEx, CapR0i, CapR0f, CapR1i, CapR1f, CapREx, StemEx
//corne thumb high pro
[17.16, 26.66, 6, 7, 13, 0, 0, -13, 10, -5, 2, 2, 1, 4.85, 1, 3, 2, 2], //R5 0 Corne thumb
[17.16, 17.16, 4, 5, 14, 0, 0, -13, 5, 0, 2, 2, 1, 5, 1, 3, 2, 2], //R5 corne thumb
[17.16, 17.16, 4, 6, 15, 0, 0, -13, 10, 15, 2, 2, 1, 5, 1, 2, 2, 2], //R5 corne thumb
//Low profile corne 3
[17.16, 26.66, 6, 7, 9.0, 0, 0, -8, 10, -5, 2, 2, 1, 4.85, 1, 3, 2, 2], //T1R5 external rot 3
[17.16, 26.66, 6, 7, 9.0, 0, 0, -8, 10, -0, 2, 2, 1, 4.85, 1, 3, 2, 2], //T1R5 nuetral
[17.16, 26.66, 6, 7, 9.0, 0, 0, -8, 10, 5, 2, 2, 1, 4.85, 1, 3, 2, 2], //T1R5 internal rot Corne thumb
[17.16, 17.16, 4, 5, 10., 0, 0, -12, 5, 0, 2, 2, 1, 5, 1, 3, 2, 2], //R5 corne thumb
[17.16, 17.16, 4, 6, 11, 0, 0, -12, 10, 15, 2, 2, 1, 5, 1, 2, 2, 2], //R5 corne thumb
//Column high sculpt 3 row system 8
[17.16, 17.16, 6.5, 6.5,10.55, 0, 0, 9, 0, 0, 2, 2, 1, 5, 1, 3.5, 2, 2], //R4 8
[17.16, 17.16, 6.5, 6.5, 8.75, 0, .5, 4, 0, 0, 2, 2, 1, 5, 1, 3.5, 2, 2], //R3 Home
[17.16, 17.16, 6.5, 6.5, 9.75, 0, 0, -13, 0, 0, 2, 2, 1, 5, 1, 3.5, 2, 2], //R2
[17.16, 17.16, 6.5, 6.5, 8.75, 0, 0, 4, 0, 0, 2, 2, 1, 5, 1, 3.5, 2, 2], //R3 deepdish
//Column 0 high sculpt 3 row system 13
[17.16, 17.16, 6.5, 6.5,11.55, .5, 0, 9, -8, 5, 2, 2, 1, 5, 1, 3.5, 2, 2], //R4 8
[17.16, 17.16, 6.5, 6.5,11.55, .5, 0, 9, -8, -5, 2, 2, 1, 5, 1, 3.5, 2, 2], //R4 8
[17.16, 17.16, 6.5, 6.5, 9.75, .5, .5, 4, -9, -5, 2, 2, 1, 5, 1, 3.5, 2, 2], //R3 Home
[17.16, 17.16, 6.5, 6.5,10.75, .5, 0, -13, -8, -5, 2, 2, 1, 5, 1, 3.5, 2, 2], //R2
//DM 16 ~ 19
[17.16, 17.16, 6, 5, 7.5, -.0, 0, -3, 3, -15, 2, 2, 1, 5, 1, 3, 2, 2], //T0R1 1u
[17.16, 17.16, 6, 5, 8, -.0, 0, -5, 0, -10, 2, 2, 1, 5, 1, 3.5, 2, 2], //T0R2 1u
[17.16, 17.16, 4, 6, 12, .5, 0, -8, 18, 0, 2, 2, 1, 5, 1, 2, 2, 2], //T1R1 1u
];
dishParameters = //dishParameter[keyID][ParameterID]
[
//FFwd1 FFwd2 FPit1 FPit2 DshDep DshHDif FArcIn FArcFn FArcEx BFwd1 BFwd2 BPit1 BPit2 BArcIn BArcFn BArcEx
//higt corne thumb
[ 8, 4.5, 7, -39, 4, 1.8, 9.5, 15, 2, 10, 4, 8, -30, 9.5, 20, 2], //R5
[ 5, 4.3, 5, -48, 5, 2, 10.5, 10, 2, 6, 4, 13, -30, 10.5, 18, 2], //R5
[ 5, 4.3, 5, -48, 4, 1.9, 11, 12, 2, 6, 4, 13, -35, 11, 28, 2], //R5
[ 8.5, 5.0, 7, -39, 4, 1.9, 9.5, 15, 2, 10, 4, 8, -30, 9.5, 20, 2], //R5
[ 8.3, 5.0, 7, -39, 4, 1.9, 9.5, 15, 2, 10, 4, 8, -30, 9.5, 20, 2], //R5
[ 8.5, 5.0, 7, -39, 4, 1.9, 9.5, 15, 2, 10, 4, 8, -30, 9.5, 20, 2], //R5
[ 5, 4.8, 5, -48, 5, 2.2, 10.5, 10, 2, 6, 4, 13, -30, 10.5, 18, 2], //R5
[ 5, 4.8, 5, -48, 4, 2.0, 11, 12, 2, 6, 4, 13, -35, 11, 28, 2], //R5
// low pro 3 row system
[ 6, 3, 18, -50, 5, 1.8, 8.8, 15, 2, 5, 4.4, 5, -55, 8.8, 15, 2], //R4
[ 5, 3.5, 10, -55, 5, 1.8, 8.5, 15, 2, 5, 3.7, 10, -55, 8.5, 15, 2], //R3
[ 6, 3, 10, -50, 5, 1.8, 8.8, 15, 2, 6, 4, 13, 30, 8.8, 16, 2], //R2
[ 4.8, 3.3, 18, -55, 5, 2.0, 8.5, 15, 2, 4.8, 3.3, 18, -55, 8.5, 15, 2], //R3 deep
//C0
[ 6, 3, 18, -50, 5, 1.8, 9.1, 17, 2, 5, 4.4, 5, -55, 9.1, 15, 2], //R4
[ 6, 3, 18, -50, 5, 1.8, 9.1, 15, 2, 5, 4.4, 5, -55, 9.1, 15, 2], //R4
[ 5, 3.5, 10, -55, 5, 1.8, 9.0, 15, 2, 5, 3.7, 10, -55, 9.0, 15, 2], //R3
[ 6, 3, 10, -50, 5, 1.8, 9.1, 15, 2, 6, 4, 13, 30, 9.1, 16, 2], //R2
//kyria
[ 5, 4.4, 5, -48, 5, 2, 10.5, 10, 2, 6, 4, 2, -30, 10.5, 18, 2], //T0R1 1u
[ 5, 4.3, 5, -48, 5, 2, 10.5, 10, 2, 6, 4, 2, -30, 10.5, 18, 2], //T0R2 1u
[ 5, 4.4, 5, -48, 4, 1.9, 11, 12, 2, 5.5, 3.5, 8, -50, 11, 28, 2], //T1R1 1u
];
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 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 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(forward = BackForward1(keyID), pitch = BackPitch1(keyID)),
trajectory(forward = 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 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+StemBrimDep + (t/stemLayers*(KeyHeight(keyID)- topthickness - stemCrossHeight-.1 -StemBrimDep)) //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) + (1-pow(t/stemLayers, StemExponent(keyID)))*(stemWid - 2*slop),
pow(t/stemLayers, StemExponent(keyID))*(BottomLength(keyID)-TopLenDiff(keyID)-wallthickness) + (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(keyID = 0, cutLen = 0, visualizeDish = false, rossSection = false, Dish = true, Stem = false, crossSection = true,Legends = false, homeDot = false, Stab = 0) {
//Set Parameters for dish shape
FrontPath = quantize_trajectories(FrontTrajectory(keyID), steps = stepsize, loop=false, start_position= $t*4);
BackPath = quantize_trajectories(BackTrajectory(keyID), steps = stepsize, loop=false, start_position= $t*4);
//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){
translate([0,0,StemBrimDep])cherry_stem(KeyHeight(keyID)-StemBrimDep, slop); // generate mx cherry stem, not compatible with box
if (Stab != 0){
translate([Stab/2,0,0])rotate([0,0,stemRot])cherry_stem(KeyHeight(keyID), slop);
translate([-Stab/2,0,0])rotate([0,0,stemRot])cherry_stem(KeyHeight(keyID), slop);
//TODO add binding support?
}
// 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)))]); //Transition Support for taller profile
}
//cut for fonts and extra pattern for light?
}
//Cuts
//Fonts
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" );
// #rotate([-XAngleSkew(keyID),YAngleSkew(keyID),ZAngleSkew(keyID)])translate([0,-3.5,0])linear_extrude(height = 0.5)text( text = "Me", font = "Constantia:style=Bold", size = 3, valign = "center", halign = "center" );
}
//Dish Shape
if(Dish == true){
if(visualizeDish == false){
translate([-TopWidShift(keyID),.00001-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),270-ZAngleSkew(keyID)])skin(BackCurve);
} else {
#translate([-TopWidShift(keyID),.00001-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),270-ZAngleSkew(keyID)])skin(BackCurve);
}
}
if(crossSection == true) {
translate([0,-15,-.1])cube([15,30,15]);
}
}
//Homing dot
if(homeDot == true)translate([0,0,KeyHeight(keyID)-DishHeightDif(keyID)-.25])sphere(d = dotRadius);
}
//------------------stems
$fn = fn;
function outer_cherry_stem(slop) = [ stemWid - slop * 2, stemLen - slop * 2];
function outer_cherry_stabilizer_stem(slop) = [4.85 - slop * 2, 6.05 - slop * 2];
function outer_box_cherry_stem(slop) = [6 - slop, 6 - slop];
// .005 purely for aesthetics, to get rid of that ugly crosshatch
function cherry_cross(slop, extra_vertical = 0) = [
// horizontal tine
[4.03 + slop, 1.15 + slop / 3],
// vertical tine
[1.25 + slop / 3, 4.23 + extra_vertical + slop / 3 + .005],
];
module inside_cherry_cross(slop) {
// inside cross
// translation purely for aesthetic purposes, to get rid of that awful lattice
translate([0,0,-0.005]) {
linear_extrude(height = stemCrossHeight) {
square(cherry_cross(slop, extra_vertical)[0], center=true);
square(cherry_cross(slop, extra_vertical)[1], center=true);
}
}
// Guides to assist insertion and mitigate first layer squishing
{
for (i = cherry_cross(slop, extra_vertical)) hull() {
linear_extrude(height = 0.01, center = false) offset(delta = 0.4) square(i, center=true);
translate([0, 0, 0.5]) linear_extrude(height = 0.01, center = false) square(i, center=true);
}
}
}
module cherry_stem(depth, slop) {
D1=.15;
D2=.05;
H1=3.5;
CrossDist = 1.75;
difference(){
// outside shape
linear_extrude(height = depth) {
offset(r=1){
square(outer_cherry_stem(slop) - [2,2], center=true);
}
}
rotate([0,0,stemRot])inside_cherry_cross(slop);
hull(){
translate([CrossDist,CrossDist-.1,0])cylinder(d1=D1, d2=D2, H1);
translate([-CrossDist,-CrossDist+.1,0])cylinder(d1=D1, d2=D2, H1);
}
hull(){
translate([-CrossDist,CrossDist-.1])cylinder(d1=D1, d2=D2, H1);
translate([CrossDist,-CrossDist+.1])cylinder(d1=D1, d2=D2, H1);
}
}
}
module choc_stem() {
translate([5.7/2,0,-3.4/2+2])difference(){
cube([1.25,3, 3.4], center= true);
translate([3.9,0,0])cylinder(d=7,3.4,center = true);
translate([-3.9,0,0])cylinder(d=7,3.4,center = true);
}
translate([-5.7/2,0,-3.4/2+2])difference(){
cube([1.25,3, 3.4], center= true);
translate([3.9,0,0])cylinder(d=7,3.4,center = true);
translate([-3.9,0,0])cylinder(d=7,3.4,center = true);
}
}
/// ----- 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;

592
DES_MX_Mods.scad Normal file
View file

@ -0,0 +1,592 @@
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>
// R3 1.25x 1.75x
// R4 1.25x 1.75
// R5 1.50x 2.25, 2.75
/*DES (Distorted Elliptical Saddle) Sculpted Profile for 6x3 and corne thumb
Version 2: Eliptical Rectangle
*/
//#square([18.16, 18.16], center = true);
//#square([36.3, 19.05], center = true);
mirror([0,0,0])keycap(keyID = 36, cutLen = 0, Stem =true, Dish = true, Stab = 0 , veisualizeDish = false, crossSection = false, homeDot = false, Legends = false);
//translate([-19,0,0])keycap(keyID = 3, cutLen = 0, Stem =true, Dish = true, Stab = 0 , visualizeDish = false, crossSection = false, homeDot = false, Legends = false);
//translate([19,0,0])mirror([0,0,0])keycap(keyID = 5, cutLen = 0, Stem =true, Dish = true, Stab = 0 , visualizeDish = false, crossSection = false, homeDot = false, Legends = false);
//translate([19*.5,19,0])mirror([1,0,0])keycap(keyID = 6, cutLen = 0, Stem =true, Dish = true, Stab = 0 , visualizeDish = false, crossSection = false, homeDot = false, Legends = false);
//n translate([0,19, 0])keycap(keyID = 3, cutLen = 0, Stem =true, Dish = true, visualizeDish = true, crossSection = true, homeDot = false, Legends = false);
// translate([0,38, 0])mirror([0,1,0])keycap(keyID = 2, cutLen = 0, Stem =true, Dish = true, visualizeDish = false, crossSection = true, homeDot = false, Legends = false);
//Low Pro rows
//for(cap = [8:10]){
//translate([-38, 19*(cap-8), 0])keycap(keyID = cap, cutLen = 0, Stem = false, Dish = true, visualizeDish = false, crossSection = true,Legends = false);
//}
//for(cap = [70:72]){
//translate([-19, 19*(cap-70), 0])keycap(keyID = cap, cutLen = 0, Stem = false, Dish = true, visualizeDish = false, crossSection = false,Legends = false);
//}
//translate([-19, 19*(3), 0])keycap(keyID = 6, cutLen = 0, Stem = false, Dish = true, visualizeDish = false, crossSection = true,Legends = false);
//
//for(cap = [64:68]){
//translate([0, 19*(cap-64), 0])keycap(keyID = cap, cutLen = 0, Stem = false, Dish = true, visualizeDish = false, crossSection = false,Legends = false);
//}
//for(cap = [20:24]){
//translate([0, 19*(cap-20), 0])keycap(keyID = cap, cutLen = 0, Stem = false, Dish = true, visualizeDish = false, crossSection = true,Legends = false);
//}
//translate([19, 19*(2), 0])keycap(keyID = 25, cutLen = 0, Stem = false, Dish = true, visualizeDish = false, crossSection = true,Legends = false);
//////corne thumb
// translate([-15, -4, 0])rotate([0,0,30])keycap(keyID = 0, cutLen = 0, Stem =false, Dish = true, visualizeDish = false, crossSection = false);
// translate([6, 0, 0])rotate([0,0,15])keycap(keyID = 4, cutLen = 0, Stem =false, Dish = true, visualizeDish = false, crossSection = false);
// translate([26, 2.2, 0])rotate([0,0,0])keycap(keyID = 8, cutLen = 0, Stem =false, Dish = true, visualizeDish = false, crossSection = false);
//LOW pro
// translate([-15, -4, 0])rotate([0,0,30])keycap(keyID =3, cutLen = 0, Stem =true, Dish = true, visualizeDish = false, crossSection = false);
// translate([6, 0, 0])rotate([0,0,15])keycap(keyID = 4, cutLen = 0, Stem =true, Dish = true, visualizeDish = false, crossSection = false);
// translate([26, 2.2, 0])rotate([0,0,0])keycap(keyID = 5, cutLen = 0, Stem =true, Dish = true, visualizeDish = false, crossSection = false);
//kyria Thumb
// translate([-39, 0, 0])rotate([0,0,30])translate([0,-19.5, 0])keycap(keyID = 10, cutLen = 0, Stem =false, Dish = true, visualizeDish = false, crossSection = false);
//// translate([-39, 0, 0])rotate([0,0,30])translate([0,-19.5, 0])keycap(keyID = 11, cutLen = 0, Stem =false, Dish = true, visualizeDish = false, crossSection = false);
//// translate([-39, 0, 0])rotate([0,0,30])translate([0, -1, 0])keycap(keyID = 12, cutLen = 0, Stem =false, Dish = true, visualizeDish = false, crossSection = false);
//// translate([-17, 0, 0])rotate([0,0,30])translate([0, 0, 0])keycap(keyID = 13, cutLen = 0, Stem =false, Dish = true, visualizeDish = false, crossSection = false);
// translate([-17, 0, 0])rotate([0,0,30])translate([0,-8.5, 0])mirror([1,0,0])keycap(keyID = 14, cutLen = 0, Stem =false, Dish = true, visualizeDish = false, crossSection = false);
// translate([-17, 0, 0])rotate([0,0,30])translate([0, 10, 0])mirror([1,0,0])keycap(keyID = 15, cutLen = 0, Stem =false, Dish = true, visualizeDish = false, crossSection = false);
// translate([6, 0, 0])rotate([0,0,15])keycap(keyID = 16, cutLen = 0, Stem =false, Dish = true, visualizeDish = false, crossSection = false);
// translate([26, 2.2, 0])rotate([0,0,0])keycap(keyID = 17, cutLen = 0, Stem =false, Dish = true, visualizeDish = false, crossSection = false);
//normie hipro
// for(Row = [0:4]){
// translate([0, 19*Row, 0])keycap(keyID = 29+Row, cutLen = 0, Stem = false, Dish = true, visualizeDish = false, crossSection = false,Legends = false);
// }
//#translate([0,38,13])cube([18-5.7, 18-5.7,1],center = true);
//echo(len(keyParameters));
//Parameters
wallthickness = 1.25; // 1.5 for norm, 1.25 for cast master
topthickness = 2.75; // 3 for norm, 2.5 for cast master
stepsize = 50; //resolution of Trajectory
step = 2; //resolution of ellipes
fn = 32; //resolution of Rounded Rectangles: 60 for output
layers = 40; //resolution of vertical Sweep: 50 for output
dotRadius = 1.25; //home dot size
//---Stem param
slop = 0.40;
stemRot = 0;
stemWid = 7.2;
stemLen = 5.5;
stemCrossHeight = 4;
extra_vertical = 0.6;
StemBrimDep = 0.25;
stemLayers = 50; //resolution of stem to cap top transition
keyParameters = //keyParameters[KeyID][ParameterID]
[
// BotWid, BotLen, TWDif, TLDif, keyh, WSft, LSft XSkew, YSkew, ZSkew, WEx, LEx, CapR0i, CapR0f, CapR1i, CapR1f, CapREx, StemEx
//corne thumb high pro
[17.16, 26.66, 6, 7, 13, 0, 0, -13, 10, -5, 2, 2, 1, 4.85, 1, 3, 2, 2], //R5 0 Corne thumb
[17.16, 17.16, 4, 5, 14, 0, 0, -13, 5, 0, 2, 2, 1, 5, 1, 3, 2, 2], //R5 corne thumb
[17.16, 17.16, 4, 6, 15, 0, 0, -13, 10, 15, 2, 2, 1, 5, 1, 2, 2, 2], //R5 corne thumb
//Low profile corne thumb
[17.16, 26.66, 6, 7, 9.0, 0, 0, -8, 10, -5, 2, 2, 1, 4.85, 1, 3, 2, 2], //T1R5 external rot 3
[17.16, 26.66, 6, 7, 9.0, 0, 0, -8, 10, -0, 2, 2, 1, 4.85, 1, 3, 2, 2], //T1R5 nuetral
[17.16, 26.66, 6, 7, 9.0, 0, 0, -8, 10, 5, 2, 2, 1, 4.85, 1, 3, 2, 2], //T1R5 internal rot Corne thumb
[17.16, 17.16, 4, 5, 10., 0, 0, -12, 5, 0, 2, 2, 1, 5, 1, 3, 2, 2], //R5 corne thumb
[17.16, 17.16, 4, 6, 11, 0, 0, -12, 10, 15, 2, 2, 1, 5, 1, 2, 2, 2], //R5 corne thumb
//Column high sculpt 3 row system
[17.16, 17.16, 6.5, 6.5,10.55, 0, 0, 9, 0, 0, 2, 2, 1, 5, 1, 3.5, 2, 2], //R4 8
[17.16, 17.16, 6.5, 6.5, 8.75, 0, .5, 4, 0, 0, 2, 2, 1, 5, 1, 3.5, 2, 2], //R3 Home
[17.16, 17.16, 6.5, 6.5, 9.75, 0, 0, -13, 0, 0, 2, 2, 1, 5, 1, 3.5, 2, 2], //R2
[17.16, 17.16, 6.5, 6.5, 8.75, 0, 0, 4, 0, 0, 2, 2, 1, 5, 1, 3.5, 2, 2], //R3 deepdish
//kyria Thumbs 13 ~ 19
[17.16, 35.56, 6, 7, 11, 0, 0, -8, 10, -5, 2, 2, 1, 4.85, 1, 3.5, 2, 2], //T0R1 2u
[17.16, 17.16, 6, 5, 11, -.5, 0, -9, 7, 10, 2, 2, 1, 5, 1, 3, 2, 2], //T0R1 1u
[17.16, 17.16, 6, 5, 13, -.5, 0, -9, 7, 5, 2, 2, 1, 5, 1, 3.5, 2, 2], //T0R2 1u
[17.16, 35.56, 6, 7, 11, 0, 0, -8, 10, -5, 2, 2, 1, 4.85, 1, 3.5, 2, 2], //T1R1 2u
[17.16, 17.16, 4, 6, 12, .5, 0, -13, -7, 10, 2, 2, 1, 5, 1, 2, 2, 2], //T1R1 1u
[17.16, 17.16, 6, 5, 15, -.5, 0, -9, -7, 0, 2, 2, 1, 5, 1, 3.5, 2, 2], //T1R2 1u
[17.16, 17.16, 4, 6, 13, .5, 0, -13, 10, 15, 2, 2, 1, 5, 1, 2, 2, 2], //T2R1
[17.16, 17.16, 4, 6, 13, 0, 0, -8, 10, 20, 2, 2, 1, 5, 1, 2, 2, 2], //T3R1
//normie hi-sculpt 4 row system 17~23
[17.16, 17.16, 6.5, 6.5, 10.5, 0, 0, -3, 0, 0, 2, 2, 1, 5, 1, 3.5, 2, 2], //R5
[17.16, 17.16, 6.5, 6.5, 9.5, 0, 0, 9, 0, 0, 2, 2, 1, 5, 1, 3.5, 2, 2], //R4
[17.16, 17.16, 6.5, 6.5, 8.5, 0, .5, -5, 0, 0, 2, 2, 1, 5, 1, 3.5, 2, 2], //R3 Home
[17.16, 17.16, 6.5, 6.5, 10, 0, 0, -11, 0, 0, 2, 2, 1, 5, 1, 3.5, 2, 2], //R2
[17.16, 17.16, 6.5, 6.5, 14.0, 0, -.25, -14, 0, 0, 2, 2, 1, 5, 1, 3.5, 2, 2], //R1
[17.16, 17.16, 6.5, 6.5, 9, 0, 0, -5, 0, 0, 2, 2, 1, 5, 1, 3.5, 2, 2], //R3 Home Deeper
//1.25u 25~30
[21.86, 17.16, 6.5, 6.5, 10.5, 0, 0, -3, 0, 0, 2, 2, 1, 5, 1, 3.5, 2, 2], //R5
[21.86, 17.16, 6.5, 6.5, 9.5, 0, 0, 9, 0, 0, 2, 2, 1, 5, 1, 3.5, 2, 2], //R4
[21.86, 17.16, 6.5, 6.5, 8.5, 0, .5, -5, 0, 0, 2, 2, 1, 5, 1, 3.5, 2, 2], //R3 Home
[21.86, 17.16, 6.5, 6.5, 10, 0, 0, -11, 0, 0, 2, 2, 1, 5, 1, 3.5, 2, 2], //R2
[21.86, 17.16, 6.5, 6.5, 14.0, 0, -.25, -14, 0, 0, 2, 2, 1, 5, 1, 3.5, 2, 2], //R1
//1.5u 31~36
[26.66, 17.16, 6.5, 6.5, 10.5, 0, 0, -3, 0, 0, 2, 2, 1, 5, 1, 3.5, 2, 2], //R5
[26.66, 17.16, 6.5, 6.5, 9.5, 0, 0, 9, 0, 0, 2, 2, 1, 5, 1, 3.5, 2, 2], //R4
[26.66, 17.16, 6.5, 6.5, 8.5, 0, .5, -5, 0, 0, 2, 2, 1, 5, 1, 3.5, 2, 2], //R3 Home
[26.66, 17.16, 6.5, 6.5, 10, 0, 0, -11, 0, 0, 2, 2, 1, 5, 1, 3.5, 2, 2], //R2
[26.66, 17.16, 6.5, 6.5, 14.0, 0, -.25, -14, 0, 0, 2, 2, 1, 5, 1, 3.5, 2, 2], //R1
//1.75u 37~42
[31.06, 17.16, 6.5, 6.5, 10.5, 0, 0, -3, 0, 0, 2, 2, 1, 5, 1, 3.5, 2, 2], //R5
[31.06, 17.16, 6.5, 6.5, 9.5, 0, 0, 9, 0, 0, 2, 2, 1, 5, 1, 3.5, 2, 2], //R4
[31.06, 17.16, 6.5, 6.5, 8.5, 0, .5, -5, 0, 0, 2, 2, 1, 5, 1, 3.5, 2, 2], //R3 Home
[31.06, 17.16, 6.5, 6.5, 10, 0, 0, -11, 0, 0, 2, 2, 1, 5, 1, 3.5, 2, 2], //R2
[31.06, 17.16, 6.5, 6.5, 14.0, 0, -.25, -14, 0, 0, 2, 2, 1, 5, 1, 3.5, 2, 2], //R1
//2.0u
[35.46, 17.16, 6.5, 6.5, 10.5, 0, 0, -3, 0, 0, 2, 2, 1, 5, 1, 3.5, 2, 2], //R5
[35.46, 17.16, 6.5, 6.5, 9.5, 0, 0, 9, 0, 0, 2, 2, 1, 5, 1, 3.5, 2, 2], //R4
[35.46, 17.16, 6.5, 6.5, 8.5, 0, .5, -5, 0, 0, 2, 2, 1, 5, 1, 3.5, 2, 2], //R3 Home
[35.46, 17.16, 6.5, 6.5, 10, 0, 0, -11, 0, 0, 2, 2, 1, 5, 1, 3.5, 2, 2], //R2
[35.46, 17.16, 6.5, 6.5, 14.0, 0, -.25, -14, 0, 0, 2, 2, 1, 5, 1, 3.5, 2, 2], //R1
//normie mild 4 row system
[17.16, 17.16, 6.5, 6.5, 9.3, 0, 0, -3, 0, 0, 2, 2, 1, 5, 1, 3.5, 2, 2], //R5
[17.16, 17.16, 6.5, 6.5, 8.8, 0, 0, 7, 0, 0, 2, 2, 1, 5, 1, 3.5, 2, 2], //R4
[17.16, 17.16, 6.5, 6.5, 8.0, 0, .5, 0.01, 0, 0, 2, 2, 1, 5, 1, 3.5, 2, 2], //R3 Home
[17.16, 17.16, 6.5, 6.5, 8.8, 0, 0, -5, 0, 0, 2, 2, 1, 5, 1, 3.5, 2, 2], //R2
[17.16, 17.16, 6.5, 6.5, 11.0, 0, -.25, -11, 0, 0, 2, 2, 1, 5, 1, 3.5, 2, 2], //R1
[17.16, 17.16, 6.5, 6.5, 8.0, 0, .5, 0.01, 0, 0, 2, 2, 1, 5, 1, 3.5, 2, 2], //R3 Home Deeper
//1.25u
[21.86, 17.16, 6.5, 6.5, 9.3, 0, 0, -3, 0, 0, 2, 2, 1, 5, 1, 3.5, 2, 2], //R5
[21.86, 17.16, 6.5, 6.5, 8.8, 0, 0, 7, 0, 0, 2, 2, 1, 5, 1, 3.5, 2, 2], //R4
[21.86, 17.16, 6.5, 6.5, 8.0, 0, .5, 0.01, 0, 0, 2, 2, 1, 5, 1, 3.5, 2, 2], //R3 Home
[21.86, 17.16, 6.5, 6.5, 8.8, 0, 0, -5, 0, 0, 2, 2, 1, 5, 1, 3.5, 2, 2], //R2
[21.86, 17.16, 6.5, 6.5, 11.0, 0, -.25, -11, 0, 0, 2, 2, 1, 5, 1, 3.5, 2, 2], //R1
//1.5u
[26.66, 17.16, 6.5, 6.5, 9.3, 0, 0, -3, 0, 0, 2, 2, 1, 5, 1, 3.5, 2, 2], //R5
[26.66, 17.16, 6.5, 6.5, 8.8, 0, 0, 7, 0, 0, 2, 2, 1, 5, 1, 3.5, 2, 2], //R4
[26.66, 17.16, 6.5, 6.5, 8.0, 0, .5, 0.01, 0, 0, 2, 2, 1, 5, 1, 3.5, 2, 2], //R3 Home
[26.66, 17.16, 6.5, 6.5, 8.8, 0, 0, -5, 0, 0, 2, 2, 1, 5, 1, 3.5, 2, 2], //R2
[26.66, 17.16, 6.5, 6.5, 11.0, 0, -.25, -11, 0, 0, 2, 2, 1, 5, 1, 3.5, 2, 2], //R1
//1.75u
[31.06, 17.16, 6.5, 6.5, 9.3, 0, 0, -3, 0, 0, 2, 2, 1, 5, 1, 3.5, 2, 2], //R5
[31.06, 17.16, 6.5, 6.5, 8.8, 0, 0, 7, 0, 0, 2, 2, 1, 5, 1, 3.5, 2, 2], //R4
[31.06, 17.16, 6.5, 6.5, 8.0, 0, .5, 0.01, 0, 0, 2, 2, 1, 5, 1, 3.5, 2, 2], //R3 Home
[31.06, 17.16, 6.5, 6.5, 8.8, 0, 0, -5, 0, 0, 2, 2, 1, 5, 1, 3.5, 2, 2], //R2
[31.06, 17.16, 6.5, 6.5, 11.0, 0, -.25, -11, 0, 0, 2, 2, 1, 5, 1, 3.5, 2, 2], //R1
//2.0u
[35.56, 17.16, 6.5, 6.5, 9.3, 0, 0, -3, 0, 0, 2, 2, 1, 5, 1, 3.5, 2, 2], //R5
[35.56, 17.16, 6.5, 6.5, 8.8, 0, 0, 7, 0, 0, 2, 2, 1, 5, 1, 3.5, 2, 2], //R4
[35.56, 17.16, 6.5, 6.5, 8.0, 0, .5, 0.01, 0, 0, 2, 2, 1, 5, 1, 3.5, 2, 2], //R3 Home
[35.56, 17.16, 6.5, 6.5, 8.8, 0, 0, -5, 0, 0, 2, 2, 1, 5, 1, 3.5, 2, 2], //R2
[35.56, 17.16, 6.5, 6.5, 11.0, 0, -.25, -11, 0, 0, 2, 2, 1, 5, 1, 3.5, 2, 2], //R1
//lowest profile
[17.16, 17.16, 6.5, 6.5, 7.25, 0, 0, 3, 0, 0, 2, 2, 1, 5, 1, 3.5, 2, 2], //R4 6
[17.16, 17.16, 6.5, 6.5, 7, 0, .5, .001, 0, 0, 2, 2, 1, 5, 1, 3.5, 2, 2], //R3 Home
[17.16, 17.16, 6.5, 6.5, 7.25, 0, -.25, -5, 0, 0, 2, 2, 1, 5, 1, 3.5, 2, 2], //R2
[17.16, 17.16, 6.5, 6.5, 7, 0, .5, .001, 0, 0, 2, 2, 1, 5, 1, 3.5, 2, 2], //R3 deepdish
];
dishParameters = //dishParameter[keyID][ParameterID]
[
//FFwd1 FFwd2 FPit1 FPit2 DshDep DshHDif FArcIn FArcFn FArcEx BFwd1 BFwd2 BPit1 BPit2 BArcIn BArcFn BArcEx
//higt corne thumb
[ 8, 4.5, 7, -39, 4, 1.8, 9.5, 15, 2, 10, 4, 8, -30, 9.5, 20, 2], //R5
[ 5, 4.3, 5, -48, 5, 2, 10.5, 10, 2, 6, 4, 13, -30, 10.5, 18, 2], //R5
[ 5, 4.3, 5, -48, 4, 1.9, 11, 12, 2, 6, 4, 13, -35, 11, 28, 2], //R5
[ 8.5, 5.0, 7, -39, 4, 1.9, 9.5, 15, 2, 10, 4, 8, -30, 9.5, 20, 2], //R5
[ 8.3, 5.0, 7, -39, 4, 1.9, 9.5, 15, 2, 10, 4, 8, -30, 9.5, 20, 2], //R5
[ 8.5, 5.0, 7, -39, 4, 1.9, 9.5, 15, 2, 10, 4, 8, -30, 9.5, 20, 2], //R5
[ 5, 4.8, 5, -48, 5, 2.2, 10.5, 10, 2, 6, 4, 13, -30, 10.5, 18, 2], //R5
[ 5, 4.8, 5, -48, 4, 2.0, 11, 12, 2, 6, 4, 13, -35, 11, 28, 2], //R5
// low pro 3 row system
[ 6, 3, 18, -50, 5, 1.8, 8.8, 15, 2, 5, 4.4, 5, -55, 8.8, 15, 2], //R4
[ 5, 3.5, 10, -55, 5, 1.8, 8.5, 15, 2, 5, 3.7, 10, -55, 8.5, 15, 2], //R3
[ 6, 3, 10, -50, 5, 1.8, 8.8, 15, 2, 6, 4, 13, 30, 8.8, 16, 2], //R2
[ 4.8, 3.3, 18, -55, 5, 2.0, 8.5, 15, 2, 4.8, 3.3, 18, -55, 8.5, 15, 2], //R3 deep
//kyria
[ 13, 4.5, 7, -39, 4, 1.8, 9.5, 15, 2, 13, 4, 8, -30, 9.5, 20, 2], //T1R1 2u
[ 5, 4.4, 5, -48, 5, 2, 10.5, 10, 2, 6, 4, 2, -30, 10.5, 18, 2], //T0R1 1u
[ 5, 4.3, 5, -48, 5, 2, 10.5, 10, 2, 6, 4, 2, -30, 10.5, 18, 2], //T0R2 1u
[ 13, 4.5, 7, -39, 4, 1.8, 9.5, 15, 2, 13, 4, 8, -30, 9.5, 20, 2], //T1R1 2u
[ 5, 4.4, 5, -48, 4, 1.9, 11, 12, 2, 5.5, 3.5, 8, -50, 11, 28, 2], //T1R1 1u
[ 5, 4.3, 5, -48, 5, 2, 10.5, 10, 2, 6, 4, 2, -30, 10.5, 18, 2], //T1R2 1u
[ 5, 4.4, 5, -48, 4, 1.9, 11, 12, 2, 6, 4, 13, -35, 11, 28, 2], //T2R1
[ 5, 4.4, 5, -48, 4, 1.9, 11, 12, 2, 6, 4, 13, -35, 11, 28, 2], //T3R1
//heavy
[ 6, 3, -5, -50, 5, 1.8, 8.8, 15, 2, 6, 3.5, 13, -50, 8.8, 16, 2], //R5
[ 6, 3, 18, -50, 5, 1.8, 8.8, 15, 2, 5, 4.4, 5, -55, 8.8, 15, 2], //R4
[ 6, 3, 18, -55, 5, 1.8, 8.8, 15, 2, 5, 3.5, 8, -55, 8.8, 15, 2], //R3
[ 6, 3, 10, -50, 5, 1.8, 8.8, 15, 2, 5, 4, 12, -55, 8.8, 16, 2], //R2
[ 5, 3.5, 8, -50, 5, 1.9, 8.8, 15, 2, 6, 4, 13, 30, 8.8, 16, 2], //R1
[ 5.5, 2.8, 23, -50, 5, 1.8, 8.5, 15, 2, 5, 3.3, 13, -55, 8.5, 15, 2], //R3 deep
// 1.25
[ 6, 3, -5, -50, 5, 1.8, 12.4, 18, 2, 6, 3.5, 13, -50, 12.4, 19, 2], //R5
[ 6, 3, 18, -50, 5, 1.8, 12.4, 20, 2, 5, 4.4, 5, -55, 12.4, 19, 2], //R4
[ 6, 3, 18, -55, 5, 1.8, 12.4, 18, 2, 5, 3.7, 8, -55, 12.4, 19, 2], //R3
[ 6, 3, 10, -50, 5, 1.8, 12.4, 18, 2, 5, 4, 12, -55, 12.4, 19, 2], //R2
[ 5, 3.5, 8, -50, 5, 1.9, 12.5, 18, 2, 6, 4, 13, 30, 12.5, 19, 2], //R1
//1.5
[ 6, 3, -5, -50, 5, 1.8, 15.5, 22, 2, 6, 3.5, 13, -50, 15.5, 22, 2], //R5
[ 6, 3, 18, -50, 5, 1.8, 15.5, 27.2, 2, 5, 4.4, 5, -55, 15.5, 22, 2], //R4
[ 6, 3, 18, -55, 5, 1.8, 15.5, 22, 2, 5, 3.7, 8, -55, 15.5, 22, 2], //R3
[ 6, 3, 10, -50, 5, 1.8, 15.7, 22, 2, 5, 4, 12, -55, 15.7, 23, 2], //R2
[ 5, 3.5, 8, -50, 5, 1.9, 15.7, 22, 2, 6, 4, 13, 30, 15.7, 23.5, 2], //R1
//1.75
[ 6, 3, -5, -50, 5, 1.8, 18.7, 25, 2, 6, 3.5, 13, -50, 18.7, 25, 2], //R5
[ 6, 3, 17, -50, 5, 1.8, 18.7, 32, 2, 5, 4.4, 5, -55, 18.7, 25, 2], //R4
[ 6, 3, 17, -55, 5, 1.8, 18.7, 27, 2, 5, 3.8, 8, -55, 18.7, 25, 2], //R3
[ 6, 3, 10, -50, 5, 1.8, 18.7, 25, 2, 5, 4, 12, -55, 18.7, 28, 2], //R2
[ 5, 3.7, 8, -50, 5, 1.9, 18.8, 25, 2, 6, 4, 12, 30, 18.8, 28, 2], //R1
//2
[ 6, 3, -5, -50, 5, 1.8, 21.9, 30, 2, 6, 3.5, 13, -50, 21.9, 31, 2], //R5
[ 6, 3, 15, -50, 5, 1.8, 21.9, 34, 2, 5, 4.4, 5, -55, 21.9, 31, 2], //R4
[ 6, 3, 17, -55, 5, 1.8, 21.9, 32.5, 2, 5, 3.7, 8, -55, 21.9, 31, 2], //R3
[ 6, 3, 10, -50, 5, 1.8, 21.9, 30, 2, 5, 4, 11.5, -55, 21.9, 33, 2], //R2
[ 5, 3.7, 8, -50, 5, 1.9, 22.1, 30, 2, 6, 4, 12, 30, 22.1, 33.5, 2], //R1
//mild
[ 6, 3, -5, -35, 5, 1.8, 8.8, 15, 2, 6, 3.5, 13, -50, 8.8, 16, 2], //R5
[ 6, 3, 15, -55, 5, 1.8, 8.8, 15, 2, 5, 4.4, 5, -55, 8.8, 15, 2], //R4
[ 5, 3.5, 8, -55, 5, 1.8, 8.8, 15, 2, 5, 3.8, 8, -55, 8.8, 15, 2], //R3
[ 5, 4.4, 5, -55, 5, 1.8, 8.8, 15, 2, 6, 3, 15, -55, 8.8, 15, 2], //R2
[ 5, 3.5, 8, -50, 5, 1.8, 8.8, 15, 2, 6, 4, 13, 30, 8.8, 16, 2], //R1
[ 5, 3.3, 15, -55, 5, 1.8, 8.5, 15, 2, 5, 3.3, 15, -55, 8.5, 15, 2], //R3 deep
// 1.25
[ 6, 3, -5, -50, 5, 1.8, 12.4, 18, 2, 6, 3.5, 13, -50, 12.4, 19, 2], //R5
[ 6, 3, 18, -50, 5, 1.8, 12.4, 20, 2, 5, 4.6, 5, -55, 12.4, 19, 2], //R4
[ 6, 3, 18, -55, 5, 1.8, 12.4, 18, 2, 5, 3.9, 8, -55, 12.4, 19, 2], //R3
[ 6, 3, 10, -50, 5, 1.8, 12.4, 18, 2, 5, 4, 12, -55, 12.4, 19, 2], //R2
[ 5, 3.8, 8, -50, 5, 1.9, 12.5, 18, 2, 6, 4, 13, 30, 12.5, 19, 2], //R1
//1.5
[ 6, 3, -5, -50, 5, 1.8, 15.5, 22, 2, 6, 3.5, 13, -50, 15.5, 22, 2], //R5
[ 6, 3, 18, -50, 5, 1.8, 15.5, 27.2, 2, 5, 4.4, 5, -55, 15.5, 22, 2], //R4
[ 6, 3, 18, -55, 5, 1.8, 15.5, 22, 2, 5, 3.9, 8, -55, 15.5, 22, 2], //R3
[ 6, 3, 10, -50, 5, 1.8, 15.7, 22, 2, 5, 4, 12, -55, 15.7, 23, 2], //R2
[ 5, 3.9, 8, -50, 5, 1.9, 15.7, 22, 2, 6, 4, 13, 30, 15.7, 23.5, 2], //R1
//1.75
[ 6, 3.2, -5, -50, 5, 1.8, 18.7, 25, 2, 6, 3.5, 13, -50, 18.7, 25, 2], //R5
[ 6, 3, 17, -50, 5, 1.8, 18.7, 32, 2, 5, 4.4, 5, -55, 18.7, 25, 2], //R4
[ 6, 3, 17, -55, 5, 1.8, 18.7, 27, 2, 5, 3.9, 8, -55, 18.7, 25, 2], //R3
[ 6, 3, 10, -50, 5, 1.8, 18.7, 25, 2, 5, 4, 12, -55, 18.7, 28, 2], //R2
[ 5, 3.9, 8, -50, 5, 1.9, 18.8, 25, 2, 6, 4, 12, 30, 18.8, 28, 2], //R1
//2
[ 6, 3.1, -5, -50, 5, 1.8, 21.9, 30, 2, 6, 3.5, 13, -50, 21.9, 31, 2], //R5
[ 6, 3, 15, -50, 5, 1.8, 21.9, 34, 2, 5, 4.4, 5, -55, 21.9, 31, 2], //R4
[ 6, 3, 17, -55, 5, 1.8, 21.9, 32.5, 2, 5, 3.9, 8, -55, 21.9, 31, 2], //R3
[ 6, 3, 10, -50, 5, 1.8, 21.9, 30, 2, 5, 4, 11.5, -55, 21.9, 33, 2], //R2
[ 5, 3.9, 8, -50, 5, 1.9, 22.1, 30, 2, 6, 4, 12, 30, 22.1, 33.5, 2], //R1
// low pro mil sculpt 3 row system
[ 6, 3, 18, -50, 5, 1.8, 8.8, 15, 2, 5, 4.4, 5, -55, 8.8, 15, 2], //R4
[ 5, 3.8, 8, -55, 5, 1.8, 8.5, 15, 2, 5, 4.2, 8, -55, 8.5, 15, 2], //R3
[ 6, 3, 10, -50, 5, 1.8, 8.8, 15, 2, 6, 4, 13, 30, 8.8, 16, 2], //R2
[5.25, 3., 16, -55, 5, 1.8, 8.5, 15, 2, 5.25, 3.1, 16, -55, 8.5, 15, 2], //R3 deep
];
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 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 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(forward = BackForward1(keyID), pitch = BackPitch1(keyID)),
trajectory(forward = 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 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+StemBrimDep + (t/stemLayers*(KeyHeight(keyID)- topthickness - stemCrossHeight-.1 -StemBrimDep)) //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) + (1-pow(t/stemLayers, StemExponent(keyID)))*(stemWid - 2*slop),
pow(t/stemLayers, StemExponent(keyID))*(BottomLength(keyID)-TopLenDiff(keyID)-wallthickness) + (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(keyID = 0, cutLen = 0, visualizeDish = false, rossSection = false, Dish = true, Stem = false, crossSection = true,Legends = false, homeDot = false, Stab = 0) {
//Set Parameters for dish shape
FrontPath = quantize_trajectories(FrontTrajectory(keyID), steps = stepsize, loop=false, start_position= $t*4);
BackPath = quantize_trajectories(BackTrajectory(keyID), steps = stepsize, loop=false, start_position= $t*4);
//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){
translate([0,0,StemBrimDep])cherry_stem(KeyHeight(keyID)-StemBrimDep, slop); // generate mx cherry stem, not compatible with box
if (Stab != 0){
translate([Stab/2,0,0])rotate([0,0,stemRot])cherry_stem(KeyHeight(keyID), slop);
translate([-Stab/2,0,0])rotate([0,0,stemRot])cherry_stem(KeyHeight(keyID), slop);
//TODO add binding support?
}
// 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)))]); //Transition Support for taller profile
}
//cut for fonts and extra pattern for light?
}
//Cuts
//Fonts
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" );
// #rotate([-XAngleSkew(keyID),YAngleSkew(keyID),ZAngleSkew(keyID)])translate([0,-3.5,0])linear_extrude(height = 0.5)text( text = "Me", font = "Constantia:style=Bold", size = 3, valign = "center", halign = "center" );
}
//Dish Shape
if(Dish == true){
if(visualizeDish == false){
translate([-TopWidShift(keyID),.00001-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),270-ZAngleSkew(keyID)])skin(BackCurve);
} else {
#translate([-TopWidShift(keyID),.00001-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),270-ZAngleSkew(keyID)])skin(BackCurve);
}
}
if(crossSection == true) {
translate([0,-15,-.1])cube([15,30,15]);
}
}
//Homing dot
if(homeDot == true)translate([0,0,KeyHeight(keyID)-DishHeightDif(keyID)-.25])sphere(d = dotRadius);
}
//------------------stems
$fn = fn;
function outer_cherry_stem(slop) = [ stemWid - slop * 2, stemLen - slop * 2];
function outer_cherry_stabilizer_stem(slop) = [4.85 - slop * 2, 6.05 - slop * 2];
function outer_box_cherry_stem(slop) = [6 - slop, 6 - slop];
// .005 purely for aesthetics, to get rid of that ugly crosshatch
function cherry_cross(slop, extra_vertical = 0) = [
// horizontal tine
[4.03 + slop, 1.15 + slop / 3],
// vertical tine
[1.25 + slop / 3, 4.23 + extra_vertical + slop / 3 + .005],
];
module inside_cherry_cross(slop) {
// inside cross
// translation purely for aesthetic purposes, to get rid of that awful lattice
translate([0,0,-0.005]) {
linear_extrude(height = stemCrossHeight) {
square(cherry_cross(slop, extra_vertical)[0], center=true);
square(cherry_cross(slop, extra_vertical)[1], center=true);
}
}
// Guides to assist insertion and mitigate first layer squishing
{
for (i = cherry_cross(slop, extra_vertical)) hull() {
linear_extrude(height = 0.01, center = false) offset(delta = 0.4) square(i, center=true);
translate([0, 0, 0.5]) linear_extrude(height = 0.01, center = false) square(i, center=true);
}
}
}
module cherry_stem(depth, slop) {
D1=.15;
D2=.05;
H1=3.5;
CrossDist = 1.75;
difference(){
// outside shape
linear_extrude(height = depth) {
offset(r=1){
square(outer_cherry_stem(slop) - [2,2], center=true);
}
}
rotate([0,0,stemRot])inside_cherry_cross(slop);
hull(){
translate([CrossDist,CrossDist-.1,0])cylinder(d1=D1, d2=D2, H1);
translate([-CrossDist,-CrossDist+.1,0])cylinder(d1=D1, d2=D2, H1);
}
hull(){
translate([-CrossDist,CrossDist-.1])cylinder(d1=D1, d2=D2, H1);
translate([CrossDist,-CrossDist+.1])cylinder(d1=D1, d2=D2, H1);
}
}
}
module choc_stem() {
translate([5.7/2,0,-3.4/2+2])difference(){
cube([1.25,3, 3.4], center= true);
translate([3.9,0,0])cylinder(d=7,3.4,center = true);
translate([-3.9,0,0])cylinder(d=7,3.4,center = true);
}
translate([-5.7/2,0,-3.4/2+2])difference(){
cube([1.25,3, 3.4], center= true);
translate([3.9,0,0])cylinder(d=7,3.4,center = true);
translate([-3.9,0,0])cylinder(d=7,3.4,center = true);
}
}
/// ----- 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;

View file

@ -1,8 +1,10 @@
use <z-butt.scad>
//lp_master_base(xu = 1, yu = 1);
shiftx = 5.1;
shiftx = 0;//5.1;
rot = 0;
translate([-10,4,0])cube([20,10,10]);
//translate([0,0,20])lp_stem_cavity(xu = 2, yu = 1);
//difference(){
//
@ -51,7 +53,7 @@
//
difference(){
mx_stem_cavity(xu = 1.5, yu = 1);
mx_stem_cavity(xu = 1, yu = 1);
// translate([0,4,5.5])mirror([1,0,0])text( text = "pqp", font ="Wingdings3:style=Regular", size = 2, valign = "center", halign = "center" );
#rotate([0,0,rot]){
translate([3.5+shiftx,-3.65,5.45])hull(){