chiark / gitweb /
curveopt: wip
[moebius3.git] / moebius.scad
1 // -*- C -*-
2
3 include <moebius-core.scad>
4
5 // settings etc.
6
7 pin_stemwidth = 1.5;
8 pin_stemlen = 1.0;
9 pin_headwidth = 3.0;
10 pin_headheight = 0.5;
11 pin_slot_xslop = 0.25;
12
13 pin_yadj_range = [ -0.50, +0.25 ];
14 pin_yslop = 0.25;
15
16 pin_pin_xslop = 0.00;
17 pin_pin_yadj_range = pin_yadj_range + [ 0.00, 0.00 ];
18
19 pin_height = 5;
20
21 // computed
22
23 sliceat = moebiuscore_sliceat * moebiuscore_nomsize;
24 pin_slopeheight = (pin_headwidth - pin_stemwidth)/2;
25
26 module TopSlice(){
27   translate([0,0, 200-sliceat])
28     cube(center=true, 400);
29 }
30
31 module MainBody(){
32   intersection(){
33     MoebiusCore();
34     TopSlice();
35   }
36 }
37
38 module HalfPinHeadProfile(xslop, yadj, lenadj) {
39   sw = pin_stemwidth + xslop*2;
40   tw = pin_headwidth + xslop*2;
41   th = pin_headheight + lenadj - yadj;
42   hull(){
43     translate([ -tw/2,
44                 pin_stemlen/2 + yadj + pin_slopeheight ])
45       square([ tw, th ]);
46     translate([ -sw/2,
47                 pin_stemlen/2 + yadj ])
48       square([ sw, th ]);
49   }
50 }
51
52 module PinStemProfile(xslop, yadj) {
53   sl = pin_stemlen + pin_headheight/2 + max(yadj * 2, 0);
54   square(center=true,
55          [ pin_stemwidth + xslop*2,
56            sl ]);
57 }
58
59 module PinExtrudePortion(zi,zrange){
60   translate([0,0,zrange[zi]])
61     mirror([0,0,zi])
62     linear_extrude(height=0.1)
63     children(0);
64 }
65
66 module PinExtrude(zrange,
67                   xslop=0,
68                   yadjs=[[0,0], [0,0]], // [top[], bottom[]]
69                   lenadjs=[0,0]){ // in each case: zrange[0],zrange[1]
70   for (topboti=[0,1]) {
71     mirror([0,topboti,0]){
72       hull(){
73         for (zi=[0,1])
74           PinExtrudePortion(zi,zrange)
75             HalfPinHeadProfile(xslop, yadjs[topboti][zi], lenadjs[zi]);
76       }
77     }
78   }
79   hull(){
80     for (zi=[0,1])
81       PinExtrudePortion(zi,zrange)
82         PinStemProfile(xslop, max(yadjs[zi][0], yadjs[zi][1]));
83   }
84 }
85
86 module PinCutout(){
87   PinExtrude([-10,10],
88              xslop= pin_slot_xslop,
89              yadjs = [ [0,0],
90                        [1,1] * -pin_stemlen/2 ],
91              // bigger gap in -ve y direction
92              lenadjs = [1,1] * (pin_yslop + pin_yadj_range[1]) );
93 }
94
95 module Pin(){
96   PinExtrude([-0.5, 0.5] * pin_height,
97              xslop = -pin_pin_xslop,
98              yadjs = [pin_pin_yadj_range, pin_pin_yadj_range],
99              lenadjs = [1,1] * pin_yadj_range[1]
100              );
101 }
102
103 module PlacePins(pins=[0,1]){
104   for (i=pins) {
105     translate( moebius_pin_locns[i] * moebiuscore_nomsize ) {
106       multmatrix(moebius_pin_matrix[i])
107         children(0);
108     }
109   }
110 }
111
112 module PinDemo(){
113   PlacePins()
114     cube([1,4,9]);
115 }
116
117 module Top(){ ////toplevel
118   difference(){
119     intersection(){
120       MoebiusCore();
121       TopSlice();
122     }
123     PlacePins(){
124       PinCutout();
125     }
126   }
127 }
128
129 module Bottom(){ ////toplevel
130   difference(){
131     MoebiusCore();
132     TopSlice();
133     PlacePins()
134       mirror([0,1,0]) PinCutout();
135   }
136 }
137
138 module Demo(){ ////toplevel
139   Bottom();
140   %Top();
141   color("blue") PlacePins([0]) Pin();
142 }
143
144 module Kit(){ ////toplevel
145   off = moebiuscore_nomsize*2.5;
146   pt = pin_stemlen/2 + pin_headheight
147     + pin_pin_yadj_range[1] + pin_slopeheight;
148
149   translate([0,0,sliceat])
150     Top();
151   translate([ 0, -off, 0 ])
152     rotate([0,180,0])
153     translate([0,0,sliceat])
154     Bottom();
155   for (d = [0,1] * pin_height * 2)
156     translate([ off, d, pt ])
157     rotate([90,0,0])
158     Pin();
159 }
160
161 module TestKit(){ ////toplevel
162   intersection(){
163     Kit();
164     cube([500,500,15], center=true);
165   }
166 }
167
168 //MainBody();
169 //%PinDemo();
170 //PinExtrude([-2,10]);
171 //PinCutout();
172 //Pin();
173 //%PinCutout();
174 //Top();
175 //Bottom();
176 //Kit();
177 //Demo();
178 //TestKit();