chiark / gitweb /
bike-lipo-box: TestWall: replace ad-hoc with S1930_Negative (nfc)
[reprap-play.git] / doveclip.scad
1 // -*- C -*-
2 //
3 // doveclip.scad
4 //
5 // 3D design for a fastener suitable for Reprapss
6 // Copyright 2012,2016 Ian Jackson
7 //
8 // This work is free software: you can redistribute it and/or modify
9 // it under the terms of the GNU General Public License as published by
10 // the Free Software Foundation, either version 3 of the License, or
11 // (at your option) any later version.
12 //
13 // This work is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 // GNU General Public License for more details.
17 //
18 // You should have received a copy of the GNU General Public License
19 // along with this work.  If not, see <http://www.gnu.org/licenses/>.
20
21
22 toothheight = 1.2;
23 webthick = 1.8;
24 height = 7;
25 pinlengthfact = 1.2;
26 nomrad = height/2 - toothheight;
27 minrad = nomrad - 0.75;
28 maxrad = nomrad + 0.25;
29 jawthick = 1.5;
30
31 webgap = 0.4;
32 basepinclear = 1.0;
33
34 toothgap = webthick + webgap*2;
35 basethick = toothheight;
36
37 module DoveClipPin(h=height) {
38   pinh = h * pinlengthfact;
39   pinheight = nomrad*2 + jawthick*2;
40   translate([0,0, pinheight/2]) intersection(){
41     union(){
42       for (m=[0,1]) {
43         mirror([0,0,m]) translate([0,0,pinheight/2]) rotate([90,0,0])
44           cylinder($fn=20, r1=minrad, r2=maxrad, h=pinh);
45       }
46       translate([-webthick/2, -pinh, -pinheight/2-1])
47         cube([webthick, pinh, pinheight+2]);
48     }
49     translate([-maxrad-1, -pinh-1, -pinheight/2])
50       cube([maxrad*2+2, pinh+2, pinheight]);
51   }
52 }
53
54 function DoveClip_depth() =
55   basethick + nomrad*2 + toothheight;
56
57 module DoveClipEnd(baseextend=1, h=7) {
58   cubex = nomrad*2 + jawthick*2;
59   cube0y = -basethick-nomrad*2-toothheight;
60   centrey = -basethick-nomrad;
61   difference(){
62     translate([-cubex/2, cube0y, 0])
63       cube([cubex, -cube0y+baseextend, h]);
64     translate([0, centrey, -1])
65       cylinder($fn=20, r=nomrad, h=h+2);
66     translate([-toothgap/2, cube0y-1, -1])
67       cube([toothgap, toothheight+nomrad+1, h+2]);
68   }
69 }
70
71 module DoveClipPair(baseextend=1, h=7) {
72   delta =  nomrad*2 + jawthick*2 + toothgap;
73   for (x=[-delta/2,delta/2])
74     translate([x,0,0])
75       DoveClipEnd(baseextend=baseextend, h=h);
76 }
77
78 module DoveClipPairBase(baseextend=0.1, h=7, count=2) {
79   delta = nomrad*2 + jawthick;
80   intrude = nomrad + basethick - basepinclear;
81   for (i=[0:count-1]) {
82     translate([(i - (count-1)/2) * delta, 0, 0])
83       DoveClipEnd(baseextend=baseextend, h=h);
84   }
85   translate([-delta * count/2, -intrude, 0])
86     cube([delta * count, intrude+0.1, h]);
87 }
88
89 module DoveClipPairSane(baseextend=0, h=7, count=2) {
90   rotate([0,0,90])
91     translate([0, DoveClip_depth(), 0])
92     DoveClipPairBase(baseextend=baseextend, h=h, count=count);
93 }
94
95 function DoveClipPairSane_width(count=2) =
96   2 * (nomrad + jawthick + ((nomrad*2 + jawthick) * (count-1)/2));
97
98 module ExtenderPillar(length, height,
99                       pillarw=3.5, pillarslope=0.75, webthick=1) {
100   pillarr=pillarw/2;
101   d = 0.25;
102
103   intangle = atan(pillarslope);
104   polyjx = sin(intangle)*pillarr;
105   polyjy = cos(intangle)*pillarr;
106   polyex = -tan(intangle+90)*pillarr;
107   webmidy = height/2+d;
108
109   for (xmir=[0,1])
110     translate([0,0,height/2]) mirror([0,0,xmir])
111       translate([0,0,-height/2]) {
112       intersection() {
113         translate([-1, -pillarr-5, 0.01])
114           cube([length+2, height+pillarr*2+10, height]);
115         mirror([1,0,0]) rotate([0,-90,0])
116           linear_extrude(height=length) union(){
117           circle(r=pillarr, $fn=20);
118           polygon([[polyjx,polyjy-0.1], [polyex, 0],
119                    [polyjx,-(polyjy-0.1)]]);
120           polygon([[0,-webthick/2], [0,webthick/2],
121                    [webmidy,webthick/2], [webmidy,-webthick/2]]);
122         }
123       }
124     }
125 }
126
127 module ExtenderPillars(length, width, height,
128                        pillarw=3.5, pillarslope=0.75, webthick=1,
129                        baseweb=false, basewebthick=1) {
130   pilesw = width - pillarw;
131
132   for (ymir=[0,1]) mirror([0,ymir,0]) translate([0,-pilesw/2,0]) {
133       ExtenderPillar(length, height, pillarw, pillarslope, webthick);
134     }
135
136   if (baseweb) {
137     translate([0, -pilesw/2, 0])
138       cube([length, pilesw, basewebthick]);
139   }
140 }
141
142 module DoveClipExtender(length, ha=7, hb=7, counta=2, countb=2,
143                         pillarw=3.5, pillarslope=0.75, webthick=1) {
144
145   mirror([1,0,0])
146     DoveClipPairSane(h=ha, count=counta);
147   translate([length,0,0])
148     DoveClipPairSane(h=hb, count=countb);
149   pillarlen = length - DoveClip_depth() * 2 + 2;
150
151   pilesw = min(DoveClipPairSane_width(counta), DoveClipPairSane_width(countb))
152     - 0.5;
153   pilesh = min(ha, hb) - 0.5;
154
155   translate([DoveClip_depth() - 1, 0, 0])
156     ExtenderPillars(pillarlen, pilesw, pilesh,
157                     pillarw=pillarw, pillarslope=pillarslope,
158                     webthick=webthick);
159 }
160
161 //DoveClipExtender(length=100, ha=16, hb=20, counta=3, countb=4);