chiark / gitweb /
6ef5bb3bd9993fe00536f81ea15772f80e48c17f
[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=3.5, thick=3, deviationrad=1.0,
10                 mainlen=20, handlerad=10, handlelen=7) {
11   spare = holeminrad - deviationrad - w;
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   for (xmir=[0,1]) mirror([xmir,0,0]) {
35     linear_extrude(height=thick) {
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])
41           rotate([0,0,-unbent_subang]) {
42           translate([-(w + deviationrad), -0.1])
43             square(size=[w + deviationrad, w+0.1]);
44           FlatArc(-deviationrad + handlerad, w,
45                   handlerad, handlerad+w,
46                   180-rad2deg(handlelen/handlerad), 180,
47                   $fa=0.25, $fn=60);
48         }
49       }
50     }
51   }
52 }
53
54 module SplitPinCavity(w=1.5, holeminrad=3.5, thick=3, deviationrad=1.0,
55                       mainlen=20) {
56   
57 }
58
59 SplitPin();