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