Added a license
[Model-M.git] / space.scad
blob51a42fcf3029004a64d6d1487f1ac5e2dc1811f7
1 //measures are in millimeters
2 //(feel free to cocnvert them to attoparsecs)
3 AY=132.5;
4 AX=19.0;
5 BY=127.5;
6 BLX=14.5;
7 EZ=11.0;
8 FLZ=14.0;
9 H=12.75;
10 SHAFT_OFF_Y=AY/2;
11 SHAFT_OFF_X=8.0; //???
12 CLIP_X=2;
13 CLIP_Y=0.75;
14 CLIP_H=3*CLIP_Y;
15 CORNER_RADIUS=2;
16 SHAFT_X=8.0;
17 SHAFT_Y=6.0;
18 SHAFT_LENGTH=9.0;
19 SHAFT_THICKNESS=1.0;
20 SHAFT_CLIP_WIDTH=3.0;
21 SHAFT_CLIP_THICKNESS=0.75;
22 SHAFT_CLIP_HEIGHT=2.0;
23 SHAFT_CLIP_SLOPE_DEPTH=1.0;
24 SHAFT_CLIP_ANGLE=45;
25 SHAFT_END_CUTOUT_HEIGHT=1.5;
26 SHAFT_LARGE_SLOT_TO_BASE=1.5;
27 SHAFT_SMALL_SLOT_LENGTH=7.25;
28 SHAFT_SMALL_SLOT_WIDTH=2.5;
29 SHAFT_SPRING_HOLDER_WIDTH=3.0;
30 SHAFT_SPRING_HOLDER_TO_BASE=4.0;
31 SHAFT_SPRING_GUIDE_WIDTH=1.0;
32 SHAFT_SPRING_GUIDE_SIDES_HEIGHT=3.5;
33 STRUT_THICKNESS=1;
34 STRUT_HEIGHT=3;
35 STRUT_SPACING=1;
36 SHAFT_SPRING_HOLDER_NIPPLE_HEIGHT=1;
37 SHAFT_SPRING_HOLDER_NIPPLE_RADIUS=0.75;
39 WIRE_HOLDER_HEIGHT=4.0;
40 WIRE_HOLDER_WIDTH=4.5;
41 WIRE_DIAMETER=2.0;
42 WIRE_HOLE_OFF_Z=0.5;
44 MYSTERIOUS_TAB_WIDTH=6.5;
45 MYSTERIOUS_TAB_HEIGHT=5.5;
47 SHAFT_SMALL_SLOT_BEVEL=0.5;
49 WallThickness=2.0;
50 ClipWidth=2.2;
51 ClipDepth=0.75;
53 //ascfront=FLZ/sqrt(pow(FLZ,2)-pow(H,2));
54 //asctop=(H-EZ)/sqrt(pow(BLX,2)-pow((H-EZ),2));
56 alpha=asin((H-EZ)/BLX);
57 beta=asin(H/FLZ);
58 gamma=90-asin((0.5*(AY-BY))/EZ);
60 module keycap(){
61         scale([AX/(AX+2*CORNER_RADIUS),AY/(AY+2*CORNER_RADIUS),1])
62         translate([CORNER_RADIUS,CORNER_RADIUS,0.01])
63         minkowski(){
64                 difference(){
65                         cube([AX,AY,H]);
66                         rotate(a=gamma,v=[1,0,0]) cube([200,200,200]);
67                         translate([0,AY,0]) rotate(a=90-gamma,v=[1,0,0]) cube([200,200,200]);
68                         translate([0,0,EZ]) rotate(a=-alpha,v=[0,1,0]) translate([-100,0,0]) cube([200,200,200]);
69                         translate([AX,0,0]) rotate(a=beta-90,v=[0,1,0]) cube([200,200,200]);
70                 }
71                 cylinder(h=0.01,r=CORNER_RADIUS,$fs=0.6);
72                 //rotate(a=90,v=[1,0,0]) cylinder(h=0.01,r=1,$fs=0.3);
73         }
76 module shaft(){
77         spring_guide_length = SHAFT_X-SHAFT_THICKNESS-SHAFT_SPRING_HOLDER_WIDTH;
78         spring_guide_height = SHAFT_SPRING_HOLDER_TO_BASE-SHAFT_LARGE_SLOT_TO_BASE;
79         translate([0,0,-SHAFT_LENGTH]) difference(){
80                 union(){
81                         difference(){
82                                 union(){
83                                         difference(){
84                                                 intersection(){
85                                                         cylinder(h=200,r=SHAFT_X/2,$fs=0.3);
86                                                         translate([-SHAFT_X/2,-SHAFT_Y/2,0]) cube([SHAFT_X,SHAFT_Y,200]);
87                                                 }
88                                                 intersection(){
89                                                         cylinder(h=200,r=SHAFT_X/2-SHAFT_THICKNESS,$fs=0.3);
90                                                         translate([-SHAFT_X/2+SHAFT_THICKNESS,-SHAFT_Y/2+SHAFT_THICKNESS,0]) cube([SHAFT_X-2*SHAFT_THICKNESS,SHAFT_Y-2*SHAFT_THICKNESS,200]);
91                                                 }
92                                         }
93                                         translate([-SHAFT_CLIP_WIDTH/2, -SHAFT_CLIP_THICKNESS-SHAFT_Y/2,0]) cube([SHAFT_CLIP_WIDTH/2, SHAFT_CLIP_THICKNESS,SHAFT_CLIP_HEIGHT]);
94                                         translate([-SHAFT_CLIP_WIDTH/2, SHAFT_Y/2,0]) cube([SHAFT_CLIP_WIDTH/2, SHAFT_CLIP_THICKNESS,SHAFT_CLIP_HEIGHT]);
95                                 }
96                                 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,200,200]);
97                                 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,200,200]);
98                                 translate([0,-100,0]) cube([200,200,SHAFT_END_CUTOUT_HEIGHT]);
99                                 translate([0,-SHAFT_Y/2+SHAFT_THICKNESS,0]) cube([200,SHAFT_Y-SHAFT_THICKNESS*2,SHAFT_LENGTH+SHAFT_LARGE_SLOT_TO_BASE]);
100                                 //small slot cutout
101                                 translate([0,-SHAFT_SMALL_SLOT_WIDTH/2,0]){
102                                         mirror([1,0,0]) cube([200,SHAFT_SMALL_SLOT_WIDTH,SHAFT_SMALL_SLOT_LENGTH-0.5*SHAFT_SMALL_SLOT_WIDTH]);
103                                 }
104                                 //small slot cutout
105                                 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);
106                         }
107                         //spring holder
108                         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=200,$fs=0.3);
109                         intersection(){
110                                 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=200,$fs=0.3);
111                                 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([-100,-100,0]) cube(200,200,200);
112                         }
113                         intersection(){
114                                 difference(){
115                                         translate([SHAFT_X/2-SHAFT_THICKNESS,-0.5*SHAFT_SPRING_GUIDE_WIDTH,SHAFT_LENGTH+SHAFT_LARGE_SLOT_TO_BASE]) mirror([1,0,0]) cube([200,SHAFT_SPRING_GUIDE_WIDTH,200]);
116                                         translate([-SHAFT_X/2+SHAFT_SPRING_HOLDER_WIDTH+SHAFT_THICKNESS,-0.5*SHAFT_SPRING_GUIDE_WIDTH,SHAFT_LENGTH+SHAFT_SPRING_HOLDER_TO_BASE])
117                                         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,-100]) cube([200,SHAFT_SPRING_GUIDE_WIDTH,200]);
118                                 }
119                                 cube([SHAFT_X-SHAFT_THICKNESS,SHAFT_Y,200],center=true);
120                         }
121                         //side spring guides
122                         difference(){
123                                 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]);
124                                 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,-100]) cube([SHAFT_SPRING_GUIDE_WIDTH,200,200]);
125                         }
126                         difference(){
127                                 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]);
128                                 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,-100]) cube([SHAFT_SPRING_GUIDE_WIDTH,200,200]);
129                         }
130                 }
131                 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,200]);
132         }
135 difference(){
136         keycap();
137         difference(){
138                 translate([WallThickness, WallThickness, 0]) scale(v=[1-2*WallThickness/AX, 1-2*WallThickness/AY, 1-WallThickness/H]) keycap();
139                 translate([0,AY/3,0]) cube([200,STRUT_THICKNESS,200],center=true);
140                 translate([0,2*AY/3,0]) cube([200,STRUT_THICKNESS,200],center=true);
141         }
143 intersection(){
144         union(){
145                 translate([WallThickness, WallThickness, 0]) scale(v=[1-2*WallThickness/AX, 1-2*WallThickness/AY, 1-WallThickness/H]) keycap();
146                 translate([-200,-200,-399.9]) cube([400,400,400]);
147         }
148         union(){
149                 translate([SHAFT_OFF_X,SHAFT_OFF_Y]) shaft();
150                 translate([AX-WIRE_HOLDER_WIDTH-WallThickness, WallThickness, -WIRE_HOLDER_HEIGHT]) difference(){
151                         cube([WIRE_HOLDER_WIDTH,WallThickness,WIRE_HOLDER_HEIGHT+H]);
152                         translate([WIRE_HOLDER_WIDTH/2,WallThickness*1.5,WIRE_HOLDER_HEIGHT-WIRE_DIAMETER/2-WIRE_HOLE_OFF_Z]) rotate([90,0,0]) cylinder(r=WIRE_DIAMETER/2,h=WallThickness*2,$fs=0.3);
153                 }
154                 translate([AX-WIRE_HOLDER_WIDTH-WallThickness, AY-2*WallThickness, -WIRE_HOLDER_HEIGHT]) difference(){
155                         cube([WIRE_HOLDER_WIDTH,WallThickness,WIRE_HOLDER_HEIGHT+H]);
156                         translate([WIRE_HOLDER_WIDTH/2,WallThickness*1.5,WIRE_HOLDER_HEIGHT-WIRE_DIAMETER/2-WIRE_HOLE_OFF_Z]) rotate([90,0,0]) cylinder(r=WIRE_DIAMETER/2,h=WallThickness*2,$fs=0.3);
157                 }
158                 translate([WallThickness, AY-2*WallThickness, -WIRE_HOLDER_HEIGHT]) cube([MYSTERIOUS_TAB_WIDTH,WallThickness,H+MYSTERIOUS_TAB_HEIGHT]);
159         }