chiark / gitweb /
cable-hole-trunking-cover: BaseCBot too
[reprap-play.git] / doveclip.scad
1 // -*- C -*-
2
3 toothheight = 1.2;
4 webthick = 1.8;
5 height = 7;
6 pinlengthfact = 1.2;
7 nomrad = height/2 - toothheight;
8 minrad = nomrad - 0.75;
9 maxrad = nomrad + 0.25;
10 jawthick = 1.5;
11
12 webgap = 0.4;
13 basepinclear = 1.0;
14
15 toothgap = webthick + webgap*2;
16 basethick = toothheight;
17
18 module DoveClipPin(h=height) {
19   pinh = h * pinlengthfact;
20   pinheight = nomrad*2 + jawthick*2;
21   translate([0,0, pinheight/2]) intersection(){
22     union(){
23       for (m=[0,1]) {
24         mirror([0,0,m]) translate([0,0,pinheight/2]) rotate([90,0,0])
25           cylinder($fn=20, r1=minrad, r2=maxrad, h=pinh);
26       }
27       translate([-webthick/2, -pinh, -pinheight/2-1])
28         cube([webthick, pinh, pinheight+2]);
29     }
30     translate([-maxrad-1, -pinh-1, -pinheight/2])
31       cube([maxrad*2+2, pinh+2, pinheight]);
32   }
33 }
34
35 function DoveClip_depth() =
36   basethick + nomrad*2 + toothheight;
37
38 module DoveClipEnd(baseextend=1, h=7) {
39   cubex = nomrad*2 + jawthick*2;
40   cube0y = -basethick-nomrad*2-toothheight;
41   centrey = -basethick-nomrad;
42   difference(){
43     translate([-cubex/2, cube0y, 0])
44       cube([cubex, -cube0y+baseextend, h]);
45     translate([0, centrey, -1])
46       cylinder($fn=20, r=nomrad, h=h+2);
47     translate([-toothgap/2, cube0y-1, -1])
48       cube([toothgap, toothheight+nomrad+1, h+2]);
49   }
50 }
51
52 module DoveClipPair(baseextend=1, h=7) {
53   delta =  nomrad*2 + jawthick*2 + toothgap;
54   for (x=[-delta/2,delta/2])
55     translate([x,0,0])
56       DoveClipEnd(baseextend=baseextend, h=h);
57 }
58
59 module DoveClipPairBase(baseextend=0.1, h=7, count=2) {
60   delta = nomrad*2 + jawthick;
61   intrude = nomrad + basethick - basepinclear;
62   for (i=[0:count-1]) {
63     translate([(i - (count-1)/2) * delta, 0, 0])
64       DoveClipEnd(baseextend=baseextend, h=h);
65   }
66   translate([-delta * count/2, -intrude, 0])
67     cube([delta * count, intrude+0.1, h]);
68 }
69
70 module DoveClipPairSane(baseextend=0, h=7, count=2) {
71   rotate([0,0,90])
72     translate([0, DoveClip_depth(), 0])
73     DoveClipPairBase(baseextend=baseextend, h=h, count=count);
74 }
75
76 function DoveClipPairSane_width(count=2) =
77   2 * (nomrad + jawthick + ((nomrad*2 + jawthick) * (count-1)/2));
78
79 module ExtenderPillar(length, height,
80                       pillarw=3.5, pillarslope=0.75, webthick=1) {
81   pillarr=pillarw/2;
82   d = 0.25;
83
84   intangle = atan(pillarslope);
85   polyjx = sin(intangle)*pillarr;
86   polyjy = cos(intangle)*pillarr;
87   polyex = -tan(intangle+90)*pillarr;
88   webmidy = height/2+d;
89
90   for (xmir=[0,1])
91     translate([0,0,height/2]) mirror([0,0,xmir])
92       translate([0,0,-height/2]) {
93       intersection() {
94         translate([-1, -pillarr-5, 0.01])
95           cube([length+2, height+pillarr*2+10, height]);
96         mirror([1,0,0]) rotate([0,-90,0])
97           linear_extrude(height=length) union(){
98           circle(r=pillarr, $fn=20);
99           polygon([[polyjx,polyjy-0.1], [polyex, 0],
100                    [polyjx,-(polyjy-0.1)]]);
101           polygon([[0,-webthick/2], [0,webthick/2],
102                    [webmidy,webthick/2], [webmidy,-webthick/2]]);
103         }
104       }
105     }
106 }
107
108 module ExtenderPillars(length, width, height,
109                        pillarw=3.5, pillarslope=0.75, webthick=1,
110                        baseweb=false, basewebthick=1) {
111   pilesw = width - pillarw;
112
113   for (ymir=[0,1]) mirror([0,ymir,0]) translate([0,-pilesw/2,0]) {
114       ExtenderPillar(length, height, pillarw, pillarslope, webthick);
115     }
116
117   if (baseweb) {
118     translate([0, -pilesw/2, 0])
119       cube([length, pilesw, basewebthick]);
120   }
121 }
122
123 module DoveClipExtender(length, ha=7, hb=7, counta=2, countb=2,
124                         pillarw=3.5, pillarslope=0.75, webthick=1) {
125
126   mirror([1,0,0])
127     DoveClipPairSane(h=ha, count=counta);
128   translate([length,0,0])
129     DoveClipPairSane(h=hb, count=countb);
130   pillarlen = length - DoveClip_depth() * 2 + 2;
131
132   pilesw = min(DoveClipPairSane_width(counta), DoveClipPairSane_width(countb))
133     - 0.5;
134   pilesh = min(ha, hb) - 0.5;
135
136   translate([DoveClip_depth() - 1, 0, 0])
137     ExtenderPillars(pillarlen, pilesw, pilesh,
138                     pillarw=pillarw, pillarslope=pillarslope,
139                     webthick=webthick);
140 }
141
142 //DoveClipExtender(length=100, ha=16, hb=20, counta=3, countb=4);