foo
[Model-M.git] / keycap-wide.scad
blob6c809d2b851fbb1301078e1ecd04bb3d40b3abb7
1 //measures are in millimeters
2 AY=27.0;
3 AX=19.0;
4 INNER_AY=18.5;
5 INNER_BY=12.5;
6 BY=22.0;
7 BLX=14.5;
8 EZ=11.0;
9 FLZ=14.0;
10 H=12.75;
11 CYL_OFF_Z=100;
12 CYL_DEPTH=0.05;
13 CLIP_X=2;
14 CLIP_Y=0.75;
15 CLIP_H=3*CLIP_Y;
16 CLIP_DISTANCE=17.0;
17 CORNER_RADIUS=2;
19 WallThickness=0.75;
20 ClipWidth=2.2;
21 ClipDepth=0.75;
23 //ascfront=FLZ/sqrt(pow(FLZ,2)-pow(H,2));
24 //asctop=(H-EZ)/sqrt(pow(BLX,2)-pow((H-EZ),2));
26 //curve control rod
27 //translate([14,4,0]) cube([1,1,H]);
29 alpha=asin((H-EZ)/BLX);
30 beta=asin(H/FLZ);
31 gamma=90-asin((0.5*(AY-BY))/EZ);
33 module keycap(){
34         scale([AX/(AX+2*CORNER_RADIUS),AY/(AY+2*CORNER_RADIUS),1])
35         translate([CORNER_RADIUS,CORNER_RADIUS,0.01])
36         minkowski(){
37                 difference(){
38                         cube([AX,AY,H]);
39                         rotate(a=gamma,v=[1,0,0]) cube([100,100,100]);
40                         translate([0,AY,0]) rotate(a=90-gamma,v=[1,0,0]) cube([100,100,100]);
41                         translate([0,0,EZ]) rotate(a=-alpha,v=[0,1,0]) translate([-50,0,0]) cube([100,100,100]);
42                         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=2);
43                         translate([AX,0,0]) rotate(a=beta-90,v=[0,1,0]) cube([100,100,100]);
44                 }
45                 cylinder(h=0.01,r=CORNER_RADIUS,$fs=0.6);
46                 //rotate(a=90,v=[1,0,0]) cylinder(h=0.01,r=1,$fs=0.3);
47         }
50 module struts(){
51         difference(){
52                 cube([AX,INNER_AY,H]);
53                 rotate(a=gamma,v=[1,0,0]) cube([100,100,100]);
54                 translate([0,INNER_AY,0]) rotate(a=90-gamma,v=[1,0,0]) cube([100,100,100]);
55                 translate([0,0,EZ]) rotate(a=-alpha,v=[0,1,0]) translate([-50,0,0]) cube([100,100,100]);
56                 translate([0,INNER_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=2);
57                 translate([AX,0,0]) rotate(a=beta-90,v=[0,1,0]) cube([100,100,100]);
58         }
61 module clip(){
62         difference(){
63                 cube([CLIP_X,CLIP_Y,CLIP_H]);
64                 translate([0,CLIP_Y,0]) rotate(a=asin(CLIP_Y/CLIP_H),v=[1,0,0]) cube([100,100,100]);
65         }
68 //clip distance control rod
69 //translate([(AX-CLIP_X)/2,(AY-CLIP_DISTANCE)/2,0]) cube([1,CLIP_DISTANCE,1]);
70 translate([(AX-CLIP_X)/2,(AY-CLIP_DISTANCE)/2,0]) clip();
71 translate([(AX-CLIP_X)/2,(AY+CLIP_DISTANCE)/2,0]) mirror([0,1,0]) clip();
73 difference(){
74         keycap();
75         difference(){
76                 translate([WallThickness, WallThickness, 0]) scale(v=[1-2*WallThickness/AX, 1-2*WallThickness/AY, 1-WallThickness/H]) keycap();
77                 translate([0,(AY-INNER_AY)/2,0]) difference(){
78                         struts();
79                         translate([WallThickness, WallThickness, 0]) scale(v=[1-2*WallThickness/AX, 1-2*WallThickness/INNER_AY, 1-WallThickness/H]) struts();
80                 }
81                 //translate([0,(AY-CLIP_DISTANCE)/2-WallThickness,0]) cube([100,WallThickness, 100]);
82                 //translate([0,(AY+CLIP_DISTANCE)/2,0]) cube([100,WallThickness, 100]);
83         }