Added a license
[Model-M.git] / enter.scad
blob3070df4fd10683666106fd55bd2ffca9ca2d4bcf
1 //measures are in millimeters
2 //(feel free to cocnvert them to attoparsecs)
3 AY=22.5;
4 AX=41.0;
5 EXTRA_X=19.0;
6 EXTRA_Y=4.5;
7 EXTRA_Z=5.5;
8 BY=17.0;
9 BLX=33;
10 EZ=11.0;
11 FLZ=15.0;
12 H=12.75;
13 SLOPE_X=AX/2;
14 SLOPE_Z=2.0;
15 CYL_OFF_Z=40;
16 CYL_DEPTH=1;
17 CLIP_X=2;
18 CLIP_Y=0.75;
19 CLIP_H=3*CLIP_Y;
20 CORNER_RADIUS=2;
21 INNER_GUARD_RADIUS=6.5;
22 OUTER_GUARD_RADIUS=7.5;
23 BLIND_SHAFT_OUTER_DIAMETER=4.0;
24 BLIND_SHAFT_INNER_DIAMETER=2.0;
25 SHAFT_X=8.0;
26 SHAFT_Y=6.0;
27 SHAFT_LENGTH=9.0;
28 SHAFT_THICKNESS=1.0;
29 SHAFT_CLIP_WIDTH=3.0;
30 SHAFT_CLIP_THICKNESS=0.75;
31 SHAFT_CLIP_HEIGHT=2.0;
32 SHAFT_CLIP_SLOPE_DEPTH=1.0;
33 SHAFT_CLIP_ANGLE=45;
34 SHAFT_END_CUTOUT_HEIGHT=1.5;
35 SHAFT_LARGE_SLOT_TO_BASE=1.5;
36 SHAFT_SMALL_SLOT_LENGTH=7.25;
37 SHAFT_SMALL_SLOT_WIDTH=2.5;
38 SHAFT_SPRING_HOLDER_WIDTH=3.0;
39 SHAFT_SPRING_HOLDER_TO_BASE=4.0;
40 SHAFT_SPRING_GUIDE_WIDTH=1.0;
41 SHAFT_SPRING_GUIDE_SIDES_HEIGHT=3.5;
42 STRUT_THICKNESS=1;
43 STRUT_HEIGHT=3;
44 STRUT_SPACING=1;
45 SHAFT_SPRING_HOLDER_NIPPLE_HEIGHT=1;
46 SHAFT_SPRING_HOLDER_NIPPLE_RADIUS=0.75;
47 SHAFT_OFF_Y=AY/2;
48 SHAFT_OFF_X=28.5;
49 BLIND_SHAFT_OFF_Y=AY-13.0;
50 BLIND_SHAFT_OFF_X=8.0;
51 SHAFT_SMALL_SLOT_BEVEL=0.5;
53 WallThickness=0.75;
54 ClipWidth=2.2;
55 ClipDepth=0.75;
57 //ascfront=FLZ/sqrt(pow(FLZ,2)-pow(H,2));
58 //asctop=(H-EZ)/sqrt(pow(BLX,2)-pow((H-EZ),2));
60 alpha=asin((H-EZ)/BLX);
61 beta=asin(H/FLZ);
62 gamma=90-asin((0.5*(AY-BY))/EZ);
64 module keycap_inner(){
65         translate([WallThickness, WallThickness, 0]) scale(v=[1-2*WallThickness/EXTRA_X, 1-2*WallThickness/AY, 1-WallThickness/H]) keycap();
68 module keycap(){
69         scale([AX/(AX+2*CORNER_RADIUS),AY/(AY+2*CORNER_RADIUS),1])
70         translate([CORNER_RADIUS,CORNER_RADIUS,0.01])
71         minkowski(){
72                 union(){
73                         difference(){
74                                 cube([AX,AY,H]);
75                                 rotate(a=gamma,v=[1,0,0]) cube([100,100,100]);
76                                 translate([0,AY,0]) rotate(a=90-gamma,v=[1,0,0]) cube([100,100,100]);
77                                 translate([0,0,EZ]) rotate(a=-alpha,v=[0,1,0]) translate([-50,0,0]) cube([100,100,100]);
78                                 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);
79                                 translate([AX,0,0]) rotate(a=beta-90,v=[0,1,0]) cube([100,100,100]);
80                         }
81                         difference(){
82                                 translate([0,-EXTRA_Y,0]) cube([EXTRA_X,EXTRA_Y+(AY-BY)/2,EXTRA_Z]);
83                                 translate([0,-EXTRA_Y,0]) rotate(a=gamma,v=[1,0,0]) cube([100,100,100]);
84 //                              translate([0,0,EZ]) rotate(a=-alpha,v=[0,1,0]) translate([-50,0,0]) cube([100,100,100]);
85                                 translate([EXTRA_X,-50,0]) rotate(a=beta-90,v=[0,1,0]) cube([100,100,100]);
86                         }
87                 }
88                 cylinder(h=0.01,r=CORNER_RADIUS,$fs=0.6);
89                 //rotate(a=90,v=[1,0,0]) cylinder(h=0.01,r=1,$fs=0.3);
90         }
93 module blind_shaft(){
94         translate([0,0,-SHAFT_LENGTH]) difference(){
95                 cylinder(r=BLIND_SHAFT_OUTER_DIAMETER/2,h=100,$fs=0.3);
96                 cylinder(r=BLIND_SHAFT_INNER_DIAMETER/2,h=100,$fs=0.3);
97         }
100 module shaft(){
101         spring_guide_length = SHAFT_X-SHAFT_THICKNESS-SHAFT_SPRING_HOLDER_WIDTH;
102         spring_guide_height = SHAFT_SPRING_HOLDER_TO_BASE-SHAFT_LARGE_SLOT_TO_BASE;
103         translate([0,0,-SHAFT_LENGTH]) difference(){
104                 union(){
105                         difference(){
106                                 union(){
107                                         difference(){
108                                                 intersection(){
109                                                         cylinder(h=100,r=SHAFT_X/2,$fs=0.3);
110                                                         translate([-SHAFT_X/2,-SHAFT_Y/2,0]) cube([SHAFT_X,SHAFT_Y,100]);
111                                                 }
112                                                 intersection(){
113                                                         cylinder(h=100,r=SHAFT_X/2-SHAFT_THICKNESS,$fs=0.3);
114                                                         translate([-SHAFT_X/2+SHAFT_THICKNESS,-SHAFT_Y/2+SHAFT_THICKNESS,0]) cube([SHAFT_X-2*SHAFT_THICKNESS,SHAFT_Y-2*SHAFT_THICKNESS,100]);
115                                                 }
116                                         }
117                                         translate([-SHAFT_CLIP_WIDTH/2, -SHAFT_CLIP_THICKNESS-SHAFT_Y/2,0]) cube([SHAFT_CLIP_WIDTH/2, SHAFT_CLIP_THICKNESS,SHAFT_CLIP_HEIGHT]);
118                                         translate([-SHAFT_CLIP_WIDTH/2, SHAFT_Y/2,0]) cube([SHAFT_CLIP_WIDTH/2, SHAFT_CLIP_THICKNESS,SHAFT_CLIP_HEIGHT]);
119                                 }
120                                 translate([-SHAFT_CLIP_WIDTH/2, -SHAFT_CLIP_THICKNESS-SHAFT_Y/2+SHAFT_CLIP_SLOPE_DEPTH,0]) rotate(a=90+SHAFT_CLIP_ANGLE,v=[1,0,0]) cube([SHAFT_CLIP_WIDTH/2,100,100]);
121                                 translate([-SHAFT_CLIP_WIDTH/2, SHAFT_Y/2+SHAFT_CLIP_THICKNESS-SHAFT_CLIP_SLOPE_DEPTH,0]) mirror([0,1,0]) rotate(a=90+SHAFT_CLIP_ANGLE,v=[1,0,0]) cube([SHAFT_CLIP_WIDTH/2,100,100]);
122                                 translate([0,-50,0]) cube([100,100,SHAFT_END_CUTOUT_HEIGHT]);
123                                 translate([0,-SHAFT_Y/2+SHAFT_THICKNESS,0]) cube([100,SHAFT_Y-SHAFT_THICKNESS*2,SHAFT_LENGTH+SHAFT_LARGE_SLOT_TO_BASE]);
124                                 //small slot cutout
125                                 translate([0,-SHAFT_SMALL_SLOT_WIDTH/2,0]){
126                                         mirror([1,0,0]) cube([100,SHAFT_SMALL_SLOT_WIDTH,SHAFT_SMALL_SLOT_LENGTH-0.5*SHAFT_SMALL_SLOT_WIDTH]);
127                                 }
128                                 //small slot cutout
129                                 translate([0,0,SHAFT_SMALL_SLOT_LENGTH-0.5*SHAFT_SMALL_SLOT_WIDTH]) rotate(a=-90,v=[0,1,0]) cylinder(r=SHAFT_SMALL_SLOT_WIDTH/2,h=SHAFT_X/2,$fs=0.3);
130                         }
131                         //spring holder
132                         translate([-SHAFT_X/2+SHAFT_SPRING_HOLDER_WIDTH/2+SHAFT_THICKNESS,0,SHAFT_LENGTH+SHAFT_SPRING_HOLDER_TO_BASE]) cylinder(r=SHAFT_SPRING_HOLDER_WIDTH/2,h=100,$fs=0.3);
133                         intersection(){
134                                 translate([-SHAFT_X/2+SHAFT_SPRING_HOLDER_WIDTH/2+SHAFT_THICKNESS,0,SHAFT_LENGTH+SHAFT_SPRING_HOLDER_TO_BASE-SHAFT_SPRING_HOLDER_NIPPLE_HEIGHT]) cylinder(r=SHAFT_SPRING_HOLDER_NIPPLE_RADIUS,h=100,$fs=0.3);
135                                 translate([0,0,SHAFT_LENGTH+SHAFT_SPRING_HOLDER_TO_BASE-SHAFT_SPRING_HOLDER_NIPPLE_HEIGHT*1.5]) rotate(v=[0,1,0], a=atan(SHAFT_SPRING_HOLDER_NIPPLE_HEIGHT/(SHAFT_SPRING_HOLDER_NIPPLE_RADIUS*2))) translate([-50,-50,0]) cube(100,100,100);
136                         }
137                         intersection(){
138                                 difference(){
139                                         translate([SHAFT_X/2-SHAFT_THICKNESS,-0.5*SHAFT_SPRING_GUIDE_WIDTH,SHAFT_LENGTH+SHAFT_LARGE_SLOT_TO_BASE]) mirror([1,0,0]) cube([100,SHAFT_SPRING_GUIDE_WIDTH,100]);
140                                         translate([-SHAFT_X/2+SHAFT_SPRING_HOLDER_WIDTH+SHAFT_THICKNESS,-0.5*SHAFT_SPRING_GUIDE_WIDTH,SHAFT_LENGTH+SHAFT_SPRING_HOLDER_TO_BASE])
141                                         mirror([1,0,0]) rotate(a=90-asin(spring_guide_height/spring_guide_length),v=[0,1,0]) mirror([0,0,1]) translate([0,0,-50]) cube([100,SHAFT_SPRING_GUIDE_WIDTH,100]);
142                                 }
143                                 cube([SHAFT_X-SHAFT_THICKNESS,SHAFT_Y,100],center=true);
144                         }
145                         //side spring guides
146                         difference(){
147                                 translate([-SHAFT_X/2+SHAFT_THICKNESS+(SHAFT_SPRING_HOLDER_WIDTH-SHAFT_SPRING_GUIDE_WIDTH)/2,-SHAFT_Y/2+SHAFT_THICKNESS,SHAFT_LENGTH+SHAFT_SPRING_HOLDER_TO_BASE-SHAFT_SPRING_GUIDE_SIDES_HEIGHT]) cube([SHAFT_SPRING_GUIDE_WIDTH,SHAFT_Y-2*SHAFT_THICKNESS,EZ-SHAFT_SPRING_HOLDER_TO_BASE+SHAFT_SPRING_GUIDE_SIDES_HEIGHT]);
148                                 translate([-SHAFT_X/2+SHAFT_THICKNESS+(SHAFT_SPRING_HOLDER_WIDTH-SHAFT_SPRING_GUIDE_WIDTH)/2,-SHAFT_SPRING_HOLDER_WIDTH/2,SHAFT_LENGTH+SHAFT_SPRING_HOLDER_TO_BASE]) rotate(a=-asin(((SHAFT_Y-SHAFT_SPRING_HOLDER_WIDTH)/2-SHAFT_THICKNESS)/SHAFT_SPRING_GUIDE_SIDES_HEIGHT),v=[1,0,0]) translate([0,0,-50]) cube([SHAFT_SPRING_GUIDE_WIDTH,100,100]);
149                         }
150                         difference(){
151                                 translate([-SHAFT_X/2+SHAFT_THICKNESS+(SHAFT_SPRING_HOLDER_WIDTH-SHAFT_SPRING_GUIDE_WIDTH)/2,-SHAFT_Y/2+SHAFT_THICKNESS,SHAFT_LENGTH+SHAFT_SPRING_HOLDER_TO_BASE-SHAFT_SPRING_GUIDE_SIDES_HEIGHT]) cube([SHAFT_SPRING_GUIDE_WIDTH,SHAFT_Y-2*SHAFT_THICKNESS,EZ-SHAFT_SPRING_HOLDER_TO_BASE+SHAFT_SPRING_GUIDE_SIDES_HEIGHT]);
152                                 mirror([0,1,0]) translate([-SHAFT_X/2+SHAFT_THICKNESS+(SHAFT_SPRING_HOLDER_WIDTH-SHAFT_SPRING_GUIDE_WIDTH)/2,-SHAFT_SPRING_HOLDER_WIDTH/2,SHAFT_LENGTH+SHAFT_SPRING_HOLDER_TO_BASE]) rotate(a=-asin(((SHAFT_Y-SHAFT_SPRING_HOLDER_WIDTH)/2-SHAFT_THICKNESS)/SHAFT_SPRING_GUIDE_SIDES_HEIGHT),v=[1,0,0]) translate([0,0,-50]) cube([SHAFT_SPRING_GUIDE_WIDTH,100,100]);
153                         }
154                 }
155                 translate([-SHAFT_X/2+SHAFT_SPRING_HOLDER_WIDTH+SHAFT_THICKNESS,-SHAFT_Y/2+SHAFT_THICKNESS,SHAFT_LENGTH+SHAFT_SPRING_HOLDER_TO_BASE]) mirror([1,0,0]) rotate(a=90-asin(spring_guide_height/spring_guide_length),v=[0,1,0]) mirror([0,0,1]) cube([SHAFT_THICKNESS,SHAFT_Y-2*SHAFT_THICKNESS,100]);
156         }
159 module guard(){
160         difference(){
161                 union(){
162                         cube([STRUT_THICKNESS,100,100],center=true);
163                         cylinder(r=OUTER_GUARD_RADIUS,h=100);
164                 }
165                 difference(){
166                         cylinder(r=INNER_GUARD_RADIUS,h=100);
167                         translate([-STRUT_SPACING/2-STRUT_THICKNESS,-50,EZ-STRUT_HEIGHT]) cube([STRUT_THICKNESS,100,STRUT_HEIGHT]);
168                         translate([STRUT_SPACING/2,-50,EZ-STRUT_HEIGHT]) cube([STRUT_THICKNESS,100,STRUT_HEIGHT]);
169                         translate([-50,-STRUT_SPACING/2-STRUT_THICKNESS,EZ-STRUT_HEIGHT]) cube([100,STRUT_THICKNESS,STRUT_HEIGHT]);
170                         translate([-50,STRUT_SPACING/2,EZ-STRUT_HEIGHT]) cube([100,STRUT_THICKNESS,STRUT_HEIGHT]);
171                 }
172         }
175 difference(){
176         keycap();
177         difference(){
178                 keycap_inner();
179                 rotate(a=[0,-atan(SLOPE_Z/SLOPE_X),0]) translate([0,0,-SLOPE_Z]){
180                         translate([SHAFT_OFF_X,SHAFT_OFF_Y]) guard();
181                         difference(){
182                                 translate([BLIND_SHAFT_OFF_X,BLIND_SHAFT_OFF_Y]) guard();
183                                 translate([SHAFT_OFF_X-OUTER_GUARD_RADIUS-100,-50,SLOPE_Z-100]) cube(100,100,100);
184                         }
185                         difference(){
186                                 translate([0,SHAFT_OFF_Y]) cube([100,STRUT_THICKNESS,100],center=true);
187                                 translate([SHAFT_OFF_X,SHAFT_OFF_Y]) cube([2*OUTER_GUARD_RADIUS-WallThickness,100,100],center=true);
188                                 translate([BLIND_SHAFT_OFF_X,BLIND_SHAFT_OFF_Y]) cube([2*OUTER_GUARD_RADIUS-WallThickness,100,100],center=true);
189                                 translate([SHAFT_OFF_X-OUTER_GUARD_RADIUS-100,-50,SLOPE_Z-100]) cube(100,100,100);
190                         }
191                 }
192         }
193         translate([AX-SLOPE_X,0]) rotate(a=[0,-atan(SLOPE_Z/SLOPE_X),0]) translate([-50,-50,-99.9]) cube([100,100,100]);        
195 intersection(){
196         union(){
197                 keycap_inner();
198                 translate([-50,-50,-99.9]) cube([100,100,100]);
199         }
200         rotate(a=[0,-atan(SLOPE_Z/SLOPE_X),0]) translate([0,0,-SLOPE_Z]) union(){
201                 translate([SHAFT_OFF_X,SHAFT_OFF_Y]) shaft();
202                 translate([BLIND_SHAFT_OFF_X,BLIND_SHAFT_OFF_Y]) blind_shaft();
203         }