now with a protruding shaft
[Model-M.git] / shift.scad
blobe6f331529940a4c43b014cc2054bd0d7fb217e06
1 //measures are in millimeters
2 AY=23.0;
3 AX=19.0;
4 BY=18.0;
5 BLX=14.5;
6 EZ=11.0;
7 FLZ=14.0;
8 H=12.75;
9 CYL_OFF_Z=70;
10 CYL_DEPTH=0.1;
11 CLIP_X=2;
12 CLIP_Y=0.75;
13 CLIP_H=3*CLIP_Y;
14 CORNER_RADIUS=2;
15 INNER_GUARD_RADIUS=6.5;
16 OUTER_GUARD_RADIUS=7.5;
17 SHAFT_X=8.0;
18 SHAFT_Y=6.0;
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 alpha=asin((H-EZ)/BLX);
27 beta=asin(H/FLZ);
28 gamma=90-asin((0.5*(AY-BY))/EZ);
30 module keycap(){
31         scale([AX/(AX+2*CORNER_RADIUS),AY/(AY+2*CORNER_RADIUS),1])
32         translate([CORNER_RADIUS,CORNER_RADIUS,0.01])
33         minkowski(){
34                 difference(){
35                         cube([AX,AY,H]);
36                         rotate(a=gamma,v=[1,0,0]) cube([100,100,100]);
37                         translate([0,AY,0]) rotate(a=90-gamma,v=[1,0,0]) cube([100,100,100]);
38                         translate([0,0,EZ]) rotate(a=-alpha,v=[0,1,0]) translate([-50,0,0]) cube([100,100,100]);
39                         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);
40                         translate([AX,0,0]) rotate(a=beta-90,v=[0,1,0]) cube([100,100,100]);
41                 }
42                 cylinder(h=0.01,r=CORNER_RADIUS,$fs=0.6);
43                 //rotate(a=90,v=[1,0,0]) cylinder(h=0.01,r=1,$fs=0.3);
44         }
47 module blind_shaft(){
51 module shaft(){
52         translate([0,0,-9]) difference(){
53                 intersection(){
54                         cylinder(h=100,r=SHAFT_X/2,$fs=0.3);
55                         translate([-SHAFT_X/2,-SHAFT_Y/2,0]) cube([SHAFT_X,SHAFT_Y,100]);
56                 }
57                 intersection(){
58                         cylinder(h=100,r=SHAFT_X/2-1,$fs=0.3);
59                         translate([-SHAFT_X/2+1,-SHAFT_Y/2+1,0]) cube([SHAFT_X-2,SHAFT_Y-2,100]);
60                 }
61         }
64 module guard(){
65         difference(){
66                 union(){
67                         cube([1,100,100],center=true);
68                         cube([100,1,100],center=true);
69                         cylinder(r=OUTER_GUARD_RADIUS,h=100);
70                 }
71                 cylinder(r=INNER_GUARD_RADIUS,h=100);
72         }
75 difference(){
76         keycap();
77         difference(){
78                 translate([WallThickness, WallThickness, 0]) scale(v=[1-2*WallThickness/AX, 1-2*WallThickness/AY, 1-WallThickness/H]) keycap();
79                 translate([OUTER_GUARD_RADIUS+WallThickness,AY/2]) guard();
80         }
82 intersection(){
83         union(){
84                 translate([WallThickness, WallThickness, 0]) scale(v=[1-2*WallThickness/AX, 1-2*WallThickness/AY, 1-WallThickness/H]) keycap();
85                 translate([-50,-50,-99.9]) cube([100,100,100]);
86         }
87         translate([OUTER_GUARD_RADIUS+WallThickness,AY/2]) union(){
88                 shaft();
89         }