7 tubeheight = 30 + tubeslop;
8 tubewidth = 15 + tubeslop;
22 tuberad = tubewidth/2;
23 bend = atan(tuberad/stemlen);
24 mainoutrad = tuberad + mainthick;
25 hookoutrad = hookinrad + hookwidth;
26 hookcy = -(stemlen - hookoutrad);
28 eltop = [topwidth/2, -tuberad + tubeheight + mainthick + 0.1];
29 elmid = [topwidth/2, -tuberad];
30 ellow = tangent_intersect_b([0,hookcy], hookinrad, elmid);
31 ellowextra = 180 - tangent_intersect_beta([0,hookcy], hookinrad, elmid);
33 module ClipPlan(qbend, qstemleny){
34 dy = tubeheight - tuberad*2;
35 FArcSegment(0, dy, tuberad, mainoutrad, -1, 181);
36 FArcSegment(0, 0, tuberad, mainoutrad, -qbend, qbend+1);
37 translate([tuberad, 0]) square(center=false, size=[mainthick,dy]);
38 FArcSegment(0, 0, tuberad, tuberad + clipthick, 360-clipang, clipang+1);
39 rotate(-qbend) translate([tuberad, 0]) mirror([0,1])
40 square(center=false, size=[mainthick, qstemleny/cos(qbend)]);
44 ClipPlan(bend,stemlen);
47 module ElevationCore(){
48 FArcSegment(0, hookcy, hookinrad, hookoutrad,
50 90 + hookcurl + ellowextra);
51 translate([-hookoutrad*sqrt(0.5),
52 hookcy - hookoutrad*sqrt(0.5) + 0.1])
54 square(center=false, size=[topwidth, stemlen + tubeheight + 20]);
55 polygon([[-hookoutrad, ellow[1]],
62 // after here is all 3D
66 translate([0,0, -(topwidth+10)/2])
67 linear_extrude(height=topwidth+10) Plan();
70 linear_extrude(height=100)
76 translate([-100,-100,0]) cube(center=false,size=[200,200,200]);
79 taperangle = -270 + tangent_intersect_beta([-hookcy, 0],
81 [-eltop[1], -eltop[0]]);
82 module HookL(){ ////toplevel
84 rotate([taperangle,0,0])
85 translate([0,-eltop[1],0])
87 translate([0,0,topwidth/2])
88 rotate([taperangle*2,0,0])
90 translate([0,0,-topwidth/2])
91 mirror([0,0,1]) PlaneAbove(0);
95 // straight-on version, everything prefixed with s or S
97 shookcy = -(stemlen-hookoutrad);
99 sbend_raw = tangents_intersect_beta([0,0],tuberad,
100 [0,shookcy],hookinrad);
101 sbend = angle_map_range(360-sbend_raw, -180);
104 ClipPlan(sbend, sstemleny);
105 FArcSegment(0,shookcy, hookinrad,hookoutrad,
107 hookcurl + 90 - sbend);
111 boty = shookcy - hookoutrad - 1;
112 polygon([[-1, tubeheight],
113 [topwidth, tubeheight],
114 [topwidth, elmid[1]],
115 [hookwidth, shookcy],
120 module SElevationPlaced(){
121 rotate([0,-90,0]) translate([0,0,-100]) linear_extrude(height=200)
125 module SHookL(){ ///toplevel
127 linear_extrude(height=topwidth) SPlan();
132 // straight-on version, reversed, everything prefixed with t or T
134 tjoinrad = mainoutrad * 0.7;
135 tstem0leny = tuberad - tjoinrad*0.5;
136 tjoinoutrad = tjoinrad + mainthick;
140 tjoin0c = [tuberad - tjoinrad, -tstem0leny];
141 tjoin1c = [0, thookcy];
143 tbend_raw = tangents_intersect_beta(tjoin0c, tjoinrad,
144 tjoin1c, -hookoutrad);
145 tbend0 = angle_map_range(tbend_raw, 0);
146 tbend1 = angle_map_range(tbend_raw + 180, -180);
148 tbend0p = circle_point(tjoin0c, tjoinrad, tbend_raw);
149 tbend1p = circle_point(tjoin1c, -hookoutrad, tbend_raw);
152 ClipPlan(0, tstem0leny);
153 FArcSegment(tjoin0c[0],tjoin0c[1], tjoinrad,tjoinoutrad,
155 FArcSegment(0,shookcy, hookinrad,hookoutrad,
156 tbend1, 270+hookcurl - tbend1);
158 rotate(tbend_raw+180) mirror([1,0]) {
159 translate([0,-0.1]) square(size=[mainthick, dist2d(tbend0p,tbend1p)+0.2]);
164 module THookR(){ ///toplevel
166 linear_extrude(height=topwidth) TPlan();
171 // other toplevels etc.
173 module HookR(){ ////toplevel
174 mirror([1,0,0]) HookL();
177 module SHookR(){ ////toplevel
178 mirror([1,0,0]) SHookL();
181 module THookL(){ ////toplevel
182 mirror([1,0,0]) THookR();
185 module Demo(){ ////toplevel
186 translate([-30,tubeheight,0]) HookL();
187 translate([ 0,tubeheight,0]) HookR();
188 translate([ 30, 0,0]) SHookL();
189 translate([ 60, 0,0]) SHookR();
190 translate([ 90, 0,0]) THookL();
191 translate([120, 0,0]) THookR();