chiark / gitweb /
2f5234ee4e29f9c88864ad92d5c4c696c8ee28c0
[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 eclip_ra_offset = r2 - 0.1;
42
43 $fn=70;
44
45 module EclipLPlanCore(alpha){
46   FArcSegment(0,0, r1,r2,
47               180-eclip_ult_angle, eclip_ult_angle-alpha +1);
48
49   difference(){
50     hull(){
51       intersection(){
52         circle(r2);
53         rotate(-alpha) mirror([1,1]) square([r2e, 50]);
54      }
55       rotate(-alpha) mirror([1,1]) square([r2e, r2]);
56     }
57     circle(r1);
58   }
59 }
60
61 module EclipRPlan(alpha, main_th){
62   intersection(){
63     rotate(alpha)
64       translate([ppxl + main_th + rgap, -r2*2])
65       square([eclip_prong_th, r2*(2 + 1/sqrt(2))]);
66     translate([-r2, -r2e])
67       square([r2*3, eclip_base_epsilon + r2*4]);
68   }
69 }
70
71 module EclipLPlan(alpha){
72   rotate(alpha) EclipLPlanCore(alpha);
73 }
74
75 module EclipPPlan(main_th){
76   intersection(){
77     hull(){
78       circle(r0);
79       rotate(90-eclip_ult_angle) square([r0,r0]);
80     }
81     translate([-(r0+.1), -(r0+.1)])
82       square([(r0+.1) + main_th + ppxl, r2*2]);
83   }
84   translate([ppxl, 0]) square([main_th, r2]);
85 }
86
87 module TestBase(){ ////toplevel
88   translate([0,0, eclip_base_offset]){
89     for (i=[0 : 2: test_eclips-1]) {
90       translate([0, i*eclip_each_every])
91         rotate([90,0,0])
92         linear_extrude(height=eclip_each_len)
93         EclipLPlan(test_alpha);
94     }
95     for (j=[1 : 2: test_eclips-2]) {
96       translate([0, j*eclip_each_every])
97         rotate([90,0,0])
98         linear_extrude(height=eclip_each_len)
99         EclipRPlan(test_alpha, test_main_th);
100     }
101   }
102   translate([-r2, -eclip_each_len, -test_base_th]){
103     difference(){
104       cube([r2*2,
105             test_len,
106             test_base_th]);
107       mirror([0,0,1]) Commitid_BestCount_M([r2*2, test_len]);
108     }
109   }
110 }
111
112 module TestProtr(){ ////toplevel
113   difference(){
114     translate([0,0, test_main_th - eclip_wall_offset])
115       rotate([0,90,0])
116       linear_extrude(height=test_len)
117       EclipPPlan(test_main_th);
118     mirror([0,0,1]) Commitid_BestCount_M([test_len, r2]);
119   }
120 }
121
122 module TestRAProtr(){ ////toplevel
123   rotate([-90,0,0]) TestProtr();
124   mirror([1,0,0])
125     translate([-test_len,
126                -r2,
127                -(eclip_ra_offset + test_base_th)])
128     cube([test_len,
129           r2*2,
130           test_base_th]);
131 }
132
133 module PlanDemo(){
134   color("red") EclipLPlan(test_alpha);
135   color("blue") rotate(test_alpha) EclipPPlan(test_main_th);
136   color("green") EclipRPlan(test_alpha, test_main_th);
137 }
138
139 //PlanDemo();
140 //TestBase();
141 //TestProtr();
142 //TestRAProtr();