chiark / gitweb /
work on norm matrix
[moebius3.git] / moebius-demo.scad
1 // -*- C -*-
2
3 include <moebius-core.scad>
4
5 // settings etc.
6
7 pin_stemwidth = 1.5;
8 pin_stemlen = 1.5;
9 pin_headwidth = 3.0;
10 pin_headheight = 1.0;
11 pin_slot_xslop = 0.25;
12
13 pin_yadj_range = [ -0.75, +0.5 ];
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
25 module MainBody(){
26   intersection(){
27     MoebiusCore();
28     translate([0,0, 200-sliceat])
29       cube(center=true, 400);
30   }
31 }
32
33 module HalfPinHeadProfile(xslop, yadj, lenadj) {
34   sw = pin_stemwidth + xslop*2;
35   tw = pin_headwidth + xslop*2;
36   th = pin_headheight + lenadj - yadj;
37   hull(){
38     translate([ -tw/2,
39                 pin_stemlen/2 + yadj + (pin_headwidth - pin_stemwidth)/2 ])
40       square([ tw, th ]);
41     translate([ -sw/2,
42                 pin_stemlen/2 + yadj ])
43       square([ sw, th ]);
44   }
45 }
46
47 module PinStemProfile(xslop, yadj) {
48   sl = pin_stemlen + pin_headheight/2 + max(yadj * 2, 0);
49   square(center=true,
50          [ pin_stemwidth + xslop*2,
51            sl ]);
52 }
53
54 module PinExtrudePortion(zi,zrange){
55   translate([0,0,zrange[zi]])
56     mirror([0,0,zi])
57     linear_extrude(height=0.1)
58     children(0);
59 }
60
61 module PinExtrude(zrange,
62                   xslop=0,
63                   yadjs=[[0,0], [0,0]], // [top[], bottom[]]
64                   lenadjs=[0,0]){ // in each case: zrange[0],zrange[1]
65   for (topboti=[0,1]) {
66     mirror([0,topboti,0]){
67       hull(){
68         for (zi=[0,1])
69           PinExtrudePortion(zi,zrange)
70             HalfPinHeadProfile(xslop, yadjs[topboti][zi], lenadjs[zi]);
71       }
72     }
73   }
74   hull(){
75     for (zi=[0,1])
76       PinExtrudePortion(zi,zrange)
77         PinStemProfile(xslop, max(yadjs[zi][0], yadjs[zi][1]));
78   }
79 }
80
81 module PinCutout(){
82   PinExtrude([-10,10],
83              xslop= pin_slot_xslop,
84              yadjs = [ [0,0],
85                        [1,1] * -pin_stemlen/2 ],
86              // bigger gap in -ve y direction
87              lenadjs = [1,1] * (pin_yslop + pin_yadj_range[1]) );
88 }
89
90 module Pin(){
91   PinExtrude([-0.5, 0.5] * pin_height,
92              xslop = pin_pin_xslop,
93              yadjs = [pin_pin_yadj_range, pin_pin_yadj_range],
94              lenadjs = [1,1] * pin_yadj_range[1]
95              );
96 }
97
98 module PinDemo(){
99   for (i=[0,1]) {
100     translate( moebius_pin_locns[i] * moebiuscore_nomsize ) {
101       multmatrix(moebius_pin_matrix[i])
102         cube(center=true, [1,4,9]);
103     }
104   }
105 }
106
107 MainBody();
108 %PinDemo();
109 //PinExtrude([-2,10]);
110 //PinCutout();
111 //Pin();
112 //%PinCutout();