chiark / gitweb /
fb2821de1f37669d6ee97cc692c1469ecdb0b7ab
[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_xslop = 0.25;
12
13 pin_yadj_range = [ -0.5, +0.5 ];
14
15 // computed
16
17 sliceat = moebiuscore_sliceat * moebiuscore_nomsize;
18
19 module MainBody(){
20   intersection(){
21     MoebiusCore();
22     translate([0,0, 200-sliceat])
23       cube(center=true, 400);
24   }
25 }
26
27 module HalfPinHeadProfile(xslop, yadj, lenadj) {
28   sw = pin_stemwidth + xslop*2;
29   tw = pin_headwidth + xslop*2;
30   th = pin_headheight + lenadj - yadj;
31   hull(){
32     translate([ -tw/2,
33                 pin_stemlen/2 + yadj + (pin_headwidth - pin_stemwidth)/2 ])
34       square([ tw, th ]);
35     translate([ -sw/2,
36                 pin_stemlen/2 ])
37       square([ sw, th ]);
38   }
39 }
40
41 module PinStemProfile(xslop) {
42   square(center=true,
43          [ pin_stemwidth + xslop*2,
44            pin_stemlen + pin_headheight/2 ]);
45 }
46
47 module PinExtrudePortion(zi,zrange){
48   translate([0,0,zrange[zi]])
49     mirror([0,0,zi])
50     linear_extrude(height=0.1)
51     children(0);
52 }
53     
54 module PinExtrude(zrange,
55                   xslop=[0,0], yadj=[0,0], lenadj=[0,0], len1adj=[0,0]){
56   for (ml= [[0, lenadj], [1, len1adj]]) {
57     mirror([0,ml[0]]){
58       hull(){
59         for (zi=[0,1])
60           PinExtrudePortion(zi,zrange)
61             HalfPinHeadProfile(xslop[zi], yadj[zi], ml[1][zi]);
62       }
63     }
64   }
65   hull(){
66     for (zi=[0,1])
67       PinExtrudePortion(zi,zrange)
68         PinStemProfile(xslop[zi]);
69   }
70 }
71
72 module PinDemo(){
73   for (i=[0,1]) {
74     hull(){
75       translate( moebius_pin_locns[i] * moebiuscore_nomsize )
76         sphere(2 + i);
77       translate( moebius_pin_locns[i] * moebiuscore_nomsize +
78                  moebius_pin_normals[i] * moebiuscore_nomsize*0.5 )
79         sphere(2 + i);
80     }
81   }
82 }
83
84 //MainBody();
85 //%PinDemo();
86 PinExtrude([-2,10]);