chiark / gitweb /
earring-stand: toplevels
[reprap-play.git] / earring-stand.scad
1 // -*- C -*-
2
3 eclip_inner_rad = 2.5;
4 eclip_gap_rad = 0.5;
5 eclip_prong_th = 3;
6 eclip_outer_strt = 0.5;
7 eclip_inner_xstrt = 0.5;
8
9 eclip_ult_angle = 44;
10 eclip_base_epsilon = 0.5;
11
12 eclip_each_len = 6;
13 eclip_each_every = 15;
14
15 test_alpha = 10;
16 test_main_th = 1.5;
17 test_eclips = 5;
18 test_base_th = 2.5;
19 test_len = eclip_each_len + eclip_each_every*(test_eclips-1);
20
21 // calculated
22
23 include <utils.scad>
24
25 eclip_inner_strt = eclip_outer_strt + eclip_inner_xstrt;
26
27 r0 = eclip_inner_rad;
28 r1 = r0 + eclip_gap_rad;
29 r2 = r1 + eclip_prong_th;
30 r2e = r1 + eclip_base_epsilon;
31
32 ppxl = -(r0 / sqrt(2)) + (eclip_inner_strt / sqrt(2));
33
34 rgap = eclip_gap_rad;
35
36 eclip_base_offset = r1;
37 eclip_wall_offset = -ppxl;
38
39 $fn=70;
40
41 module EclipLPlanCore(alpha){
42   FArcSegment(0,0, r1,r2,
43               180-eclip_ult_angle, eclip_ult_angle-alpha +1);
44
45   difference(){
46     hull(){
47       intersection(){
48         circle(r2);
49         rotate(-alpha) mirror([1,1]) square([r2e, 50]);
50      }
51       rotate(-alpha) mirror([1,1]) square([r2e, r2]);
52     }
53     circle(r1);
54   }
55 }
56
57 module EclipRPlan(alpha, main_th){
58   intersection(){
59     rotate(alpha)
60       translate([ppxl + main_th + rgap, -r2*2])
61       square([eclip_prong_th, r2*(2 + 1/sqrt(2))]);
62     translate([-r2, -r2e])
63       square([r2*3, eclip_base_epsilon + r2*4]);
64   }
65 }
66
67 module EclipLPlan(alpha){
68   rotate(alpha) EclipLPlanCore(alpha);
69 }
70
71 module EclipPPlan(main_th){
72   intersection(){
73     hull(){
74       circle(r0);
75       rotate(90-eclip_ult_angle) square([r0,r0]);
76     }
77     translate([-(r0+.1), -(r0+.1)])
78       square([(r0+.1) + main_th + ppxl, r2*2]);
79   }
80   translate([ppxl, 0]) square([main_th, r2]);
81 }
82
83 module TestBase(){ ////toplevel
84   translate([0,0, eclip_base_offset]){
85     for (i=[0 : 2: test_eclips-1]) {
86       translate([0, i*eclip_each_every])
87         rotate([90,0,0])
88         linear_extrude(height=eclip_each_len)
89         EclipLPlan(test_alpha);
90     }
91     for (j=[1 : 2: test_eclips-2]) {
92       translate([0, j*eclip_each_every])
93         rotate([90,0,0])
94         linear_extrude(height=eclip_each_len)
95         EclipRPlan(test_alpha, test_main_th);
96     }
97   }
98   translate([-r2, -eclip_each_len, -test_base_th])
99     cube([r2*2,
100           test_len,
101           test_base_th]);
102 }
103
104 module TestProtr(){ ////toplevel
105   translate([0,0, test_main_th - eclip_wall_offset])
106     rotate([0,90,0])
107     linear_extrude(height=test_len)
108     EclipPPlan(test_main_th);
109 }
110
111 module TestRAProtr(){ ////toplevel
112   rotate([-90,0,0]) TestProtr();
113   mirror([1,0,0])
114     translate([-test_len,
115                -r2,
116                -(r2 + test_base_th) + 0.1])
117     cube([test_len,
118           r2*2,
119           test_base_th]);
120 }
121
122 module PlanDemo(){
123   color("red") EclipLPlan(test_alpha);
124   color("blue") rotate(test_alpha) EclipPPlan(test_main_th);
125   color("green") EclipRPlan(test_alpha, test_main_th);
126 }
127
128 //PlanDemo();
129 //TestBase();
130 //TestProtr();
131 //TestRAProtr();