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