done with the shaft.
[Model-M.git] / keycap-std.scad
blob64fbcfa340d0ddb7bd6f5aa8fe9698b704f87fbd
1 //measures are in millimeters
2 AY=18.5;
3 AX=19.0;
4 BY=12.5;
5 BLX=14.5;
6 EZ=11.0;
7 FLZ=14.0;
8 H=12.75;
9 CYL_OFF_Z=50;
10 CYL_DEPTH=0.1;
11 CLIP_X=2;
12 CLIP_Y=0.75;
13 CLIP_H=3*CLIP_Y;
14 CORNER_RADIUS=2;
16 WallThickness=0.75;
17 ClipWidth=2.2;
18 ClipDepth=0.75;
20 //ascfront=FLZ/sqrt(pow(FLZ,2)-pow(H,2));
21 //asctop=(H-EZ)/sqrt(pow(BLX,2)-pow((H-EZ),2));
23 alpha=asin((H-EZ)/BLX);
24 beta=asin(H/FLZ);
25 gamma=90-asin((0.5*(AY-BY))/EZ);
27 module keycap(){
28         scale([AX/(AX+2*CORNER_RADIUS),AY/(AY+2*CORNER_RADIUS),1])
29         translate([CORNER_RADIUS,CORNER_RADIUS,0.01])
30         minkowski(){
31                 difference(){
32                         cube([AX,AY,H]);
33                         rotate(a=gamma,v=[1,0,0]) cube([100,100,100]);
34                         translate([0,AY,0]) rotate(a=90-gamma,v=[1,0,0]) cube([100,100,100]);
35                         translate([0,0,EZ]) rotate(a=-alpha,v=[0,1,0]) translate([-50,0,0]) cube([100,100,100]);
36                         translate([0,AY/2,EZ+CYL_OFF_Z]) rotate(a=90-alpha,v=[0,1,0]) cylinder(h=100,center=true,r=CYL_OFF_Z+CYL_DEPTH,$fa=1);
37                         translate([AX,0,0]) rotate(a=beta-90,v=[0,1,0]) cube([100,100,100]);
38                 }
39                 cylinder(h=0.01,r=CORNER_RADIUS,$fs=0.6);
40                 //rotate(a=90,v=[1,0,0]) cylinder(h=0.01,r=1,$fs=0.3);
41         }
44 module clip(){
45         difference(){
46                 cube([CLIP_X,CLIP_Y,CLIP_H]);
47                 translate([0,CLIP_Y,0]) rotate(a=asin(CLIP_Y/CLIP_H),v=[1,0,0]) cube([100,100,100]);
48         }
51 translate([(AX-CLIP_X)/2,WallThickness,0]) clip();
52 translate([0,AY,0]) mirror([0,1,0]) translate([(AX-CLIP_X)/2,WallThickness,0]) clip();
54 difference(){
55         keycap();
56         translate([WallThickness, WallThickness, 0]) scale(v=[1-2*WallThickness/AX, 1-2*WallThickness/AY, 1-WallThickness/H]) keycap();