Now with round corners and a hollow inside
[Model-M.git] / keycap-std.scad
blobb4b63ca61ec9ff8c2c3db96893f2e51e28b475be
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.75;
13 WallThickness=0.75;
14 ClipWidth=2.2;
15 ClipDepth=0.75;
17 //ascfront=FLZ/sqrt(pow(FLZ,2)-pow(H,2));
18 //asctop=(H-EZ)/sqrt(pow(BLX,2)-pow((H-EZ),2));
20 alpha=asin((H-EZ)/BLX);
21 beta=asin(H/FLZ);
22 gamma=90-asin((0.5*(AY-BY))/EZ);
24 module keycap(){
25         scale([AX/(AX+1+2),AY/(AY+2+0.01),H/(H+0.01+1)])
26         minkowski(){
27                 difference(){
28                         cube([AX,AY,H]);
29                         rotate(a=gamma,v=[1,0,0]) cube([100,100,100]);
30                         translate([0,AY,0]) rotate(a=90-gamma,v=[1,0,0]) cube([100,100,100]);
31                         translate([0,0,EZ]) rotate(a=-alpha,v=[0,1,0]) translate([-50,0,0]) cube([100,100,100]);
32                         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);
33                         translate([AX,0,0]) rotate(a=beta-90,v=[0,1,0]) cube([100,100,100]);
34                 }
35                 cylinder(h=0.01,r=2,$fs=0.6);
36                 //rotate(a=90,v=[1,0,0]) cylinder(h=0.01,r=1,$fs=0.3);
37         }
40 difference(){
41         keycap();
42         translate([WallThickness, WallThickness, 0]) scale(v=[1-2*WallThickness/AX, 1-2*WallThickness/AY, 1-WallThickness/H]) keycap();