chiark / gitweb /
commitid.scad.pl: Provide _M mirrored versions of everything (nfc for existing uses)
[reprap-play.git] / splitpin.scad
1 // -*- C -*-
2
3 include <cliphook.scad>
4
5 tau = 6.28318530718;
6 function deg2rad(deg) = deg/360 * tau;
7 function rad2deg(rad) = rad/tau * 360;
8
9 module SplitPin(w=1.5, holeminrad=2.50, thick=3, deviationrad=1.5,
10                 mainlen=15, handlerad=20, handlelen=12) {
11   spare = holeminrad*2 - deviationrad - w*2;
12   echo("splitpin spare",spare);
13   %translate([0,mainlen+handlelen,0]) cylinder(r=spare, h=thick);
14   %translate([0,mainlen,thick/2]) rotate([90,0,0])
15      cylinder(r=holeminrad, h=thick);
16
17   bent_dx = holeminrad;
18   unbent_dx = bent_dx + deviationrad;
19
20   unbent_subang = atan(unbent_dx / mainlen);
21   unbent_rad = mainlen / deg2rad(unbent_subang);
22
23   corner_x = unbent_rad * (1 - cos(unbent_subang));
24   corner_y = unbent_rad * sin(unbent_subang);
25
26   main_cx = unbent_rad;
27
28 //  translate([w*1.5, 0, 0]) {
29 //    translate([corner_x, corner_y, 10]) %cube([10,10,10]);
30 //    translate([bent_dx, 0, 10]) %cube([10,10,10]);
31 //    translate([unbent_dx, 5, 10]) %cube([10,10,10]);
32 //  }
33
34   linear_extrude(height=thick) {
35     for (xmir=[0,1]) mirror([xmir,0,0])
36       FlatArc(0,0, w*0.5, w*1.5, 270-1,360);
37     translate([w*1.5, 0, 0]) {
38       FlatArc($fa=1, main_cx,0, unbent_rad, unbent_rad+w,
39               180-unbent_subang, 180);
40       translate([corner_x, corner_y]) rotate([0,0,-unbent_subang]) {
41         rotate([0,0,10])
42           translate([w*0.2,0,0])
43           translate([-(w + deviationrad), -0.1])
44           square(size=[w + deviationrad, w+0.1]);
45         FlatArc(-deviationrad + handlerad, w,
46                 handlerad, handlerad+w,
47                 180-rad2deg(handlelen/handlerad), 180+rad2deg(w/handlerad),
48                 $fa=0.25, $fn=60);
49       }
50     }
51     mirror([1,0,0]) translate([w*1.5, 0, 0])
52       FlatArc($fa=1, main_cx,0, unbent_rad, unbent_rad+w,
53               180-(unbent_subang + rad2deg((handlelen+w)/unbent_rad)), 180);
54   }
55 }
56
57 module SplitPinCavity(w=1.5, holeminrad=2.50, thick=3, deviationrad=1.5,
58                       mainlen=15, slop=0.5, insertby = 5) {
59   smallgap2 = holeminrad;
60   biggap2 = smallgap2 + deviationrad + slop;
61   toegap2 = w*1.5 + slop;
62   toeend = -mainlen-insertby;
63
64   translate([0,thick/2,0]) rotate([90,0,0]) {
65     linear_extrude(height = thick + slop*2) {
66     for (xmir=[0,1]) mirror([xmir,0]) {
67         polygon([[-0.1, 1],
68                  [(smallgap2+biggap2)/2, 1],
69                  [smallgap2, -insertby],
70                  [biggap2, -insertby],
71                  [toegap2, toeend-1],
72                  [-0.1, toeend-1]]);
73       }
74     }
75   }
76 }
77
78 SplitPin();
79 translate([0,15+5,-10])
80   rotate([-90,0,0])
81   SplitPinCavity();