chiark / gitweb /
wardrobe-hook: prototype
[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 + 0.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),
69               hookcy - hookoutrad*sqrt(0.5) + 0.1])
70     mirror([1,0])
71     square(center=false, size=[topwidth, stemlen + tubeheight + 20]);
72   polygon([[-hookoutrad, ellow[1]],
73            reflect_in_y(eltop),
74            eltop,
75            elmid,
76            ellow]);
77 }
78
79 // after here is all 3D
80
81 module Primary(){
82   intersection(){
83     translate([0,0, -(topwidth+10)/2])
84       linear_extrude(height=topwidth+10) Plan();
85     translate([50,0])
86       rotate([0,-90,0])
87       linear_extrude(height=100)
88       ElevationCore();
89   }
90 }
91
92 module PlaneAbove(){
93   translate([-100,-100,0]) cube(center=false,size=[200,200,200]);
94 }
95
96 taperangle = -270 + tangent_intersect_beta([-hookcy, 0],
97                                           hookoutrad,
98                                           [-eltop[1], -eltop[0]]);
99 module Hook(){ ////toplevel
100   difference(){
101     rotate([taperangle,0,0])
102       translate([0,-eltop[1],0])
103       Primary();
104     translate([0,0,topwidth/2])
105       rotate([taperangle*2,0,0])
106       PlaneAbove();
107     translate([0,0,-topwidth/2])
108       mirror([0,0,1]) PlaneAbove(0);
109   }
110 }
111
112 //ElevationCore();
113 Hook();