chiark / gitweb /
ecb1b12b66cb572fdee4cb0e126a41b1e9384251
[reprap-play.git] / wardrobe-hook.scad
1 // -*- C -*-
2
3 include <funcs.scad>
4
5 module FArcSegment_mask(beta) {
6   for (i=[0 : 0.75 : 3]) {
7     rotate(i*beta/4)
8       polygon([[0, 0],
9                [1, 0],
10                [cos(beta/4), sin(beta/4)]]);
11   }
12 }
13
14 module FArcSegment(xc,yc,inrad,outrad,alpha,delta) {
15   translate([xc,yc]) {
16     intersection() {
17       difference() {
18         circle(r=outrad);
19         circle(r=inrad);
20       }
21       rotate(alpha) scale(outrad*2) {
22         FArcSegment_mask(delta);
23       }
24     }
25   }
26 }
27
28 tubeheight = 30;
29 tubewidth = 15;
30 mainthick = 4;
31
32 clipthick = 2;
33 clipang = 120;
34
35 stemlen = 50;
36
37 topwidth = 30;
38
39 hookinrad = 7.5;
40 hookcurl = 60;
41 hookwidth = 4;
42
43 tuberad = tubewidth/2;
44 bend = atan(tuberad/stemlen);
45 mainoutrad = tuberad + mainthick;
46 hookoutrad = hookinrad + hookwidth;
47 hookcy = -(stemlen - hookoutrad);
48
49 eltop = [topwidth/2, -tuberad + tubeheight + mainthick + 1];
50 elmid = [topwidth/2, -tuberad];
51 ellow = tangent_intersect_b([0,hookcy], hookinrad, elmid);
52 ellowextra = 180 - tangent_intersect_beta([0,hookcy], hookinrad, elmid);
53
54 module Plan(){
55   dy = tubeheight - tuberad*2;
56   FArcSegment(0, dy, tuberad, mainoutrad, -1, 181);
57   FArcSegment(0, 0,  tuberad, mainoutrad, -bend, bend+1);
58   translate([tuberad, 0]) square(center=false, size=[mainthick,dy]);
59   FArcSegment(0, 0, tuberad, tuberad + clipthick, 360-clipang, clipang+1);
60   rotate(-bend) translate([tuberad, 0]) mirror([0,1])
61     square(center=false, size=[mainthick, stemlen/cos(bend)]);
62 }
63
64 module ElevationCore(){
65   FArcSegment(0, hookcy, hookinrad, hookoutrad,
66               180 - ellowextra,
67               90 + hookcurl);
68   translate([-hookoutrad*sqrt(0.5), -(stemlen+10)]) mirror([1,0])
69     square(center=false, size=[topwidth, stemlen + tubeheight + 20]);
70   polygon([[-hookoutrad, ellow[1]],
71            reflect_in_y(eltop),
72            eltop,
73            elmid,
74            ellow]);
75 }
76
77 Plan();
78 translate([50,0])
79   ElevationCore();