chiark / gitweb /
earring-stand: adjust tighter (from v1)
[reprap-play.git] / earring-stand.scad
1 // -*- C -*-
2
3 include <commitid.scad>
4
5 front_height = 80;
6 front_width = 120;
7 front_setback = 30;
8
9 eclip_inner_rad = 2.5;
10 eclip_gap_rad = 0.1;
11 eclip_prong_th = 3;
12 eclip_outer_strt = 0.5;
13 eclip_inner_xstrt = 0.5;
14
15 eclip_ult_angle = 44;
16 eclip_base_epsilon = 0.5;
17
18 eclip_each_len = 6;
19 eclip_each_every = 15;
20
21 test_alpha = 10;
22 test_main_th = 1.5;
23 test_eclips = 5;
24 test_base_th = 2.5;
25 test_len = eclip_each_len + eclip_each_every*(test_eclips-1);
26
27 // calculated
28
29 include <utils.scad>
30
31 eclip_inner_strt = eclip_outer_strt + eclip_inner_xstrt;
32
33 r0 = eclip_inner_rad;
34 r1 = r0 + eclip_gap_rad;
35 r2 = r1 + eclip_prong_th;
36 r2e = r1 + eclip_base_epsilon;
37
38 ppxl = -(r0 / sqrt(2)) + (eclip_inner_strt / sqrt(2));
39
40 rgap = eclip_gap_rad;
41
42 eclip_base_offset = r1;
43 eclip_wall_offset = -ppxl;
44
45 eclip_ra_offset = r2 - 0.1;
46
47 $fn=70;
48
49 module EclipLPlanCore(alpha){
50   FArcSegment(0,0, r1,r2,
51               180-eclip_ult_angle, eclip_ult_angle-alpha +1);
52
53   difference(){
54     hull(){
55       intersection(){
56         circle(r2);
57         rotate(-alpha) mirror([1,1]) square([r2e, 50]);
58      }
59       rotate(-alpha) mirror([1,1]) square([r2e, r2]);
60     }
61     circle(r1);
62   }
63 }
64
65 module EclipRPlan(alpha, main_th){
66   intersection(){
67     rotate(alpha)
68       translate([ppxl + main_th + rgap, -r2*2])
69       square([eclip_prong_th, r2*(2 + 1/sqrt(2))]);
70     translate([-r2, -r2e])
71       square([r2*3, eclip_base_epsilon + r2*4]);
72   }
73 }
74
75 module EclipLPlan(alpha){
76   rotate(alpha) EclipLPlanCore(alpha);
77 }
78
79 module EclipPPlan(main_th){
80   intersection(){
81     hull(){
82       circle(r0);
83       rotate(90-eclip_ult_angle) square([r0,r0]);
84     }
85     translate([-(r0+.1), -(r0+.1)])
86       square([(r0+.1) + main_th + ppxl, r2*2]);
87   }
88   translate([ppxl, 0]) square([main_th, r2]);
89 }
90
91 module TestBase(){ ////toplevel
92   translate([0,0, eclip_base_offset]){
93     for (i=[0 : 2: test_eclips-1]) {
94       translate([0, i*eclip_each_every])
95         rotate([90,0,0])
96         linear_extrude(height=eclip_each_len)
97         EclipLPlan(test_alpha);
98     }
99     for (j=[1 : 2: test_eclips-2]) {
100       translate([0, j*eclip_each_every])
101         rotate([90,0,0])
102         linear_extrude(height=eclip_each_len)
103         EclipRPlan(test_alpha, test_main_th);
104     }
105   }
106   translate([-r2, -eclip_each_len, -test_base_th]){
107     difference(){
108       cube([r2*2,
109             test_len,
110             test_base_th]);
111       mirror([0,0,1]) Commitid_BestCount_M([r2*2, test_len]);
112     }
113   }
114 }
115
116 module TestProtr(){ ////toplevel
117   difference(){
118     translate([0,0, test_main_th - eclip_wall_offset])
119       rotate([0,90,0])
120       linear_extrude(height=test_len)
121       EclipPPlan(test_main_th);
122     mirror([0,0,1]) Commitid_BestCount_M([test_len, r2]);
123   }
124 }
125
126 module TestRAProtr(){ ////toplevel
127   rotate([-90,0,0]) TestProtr();
128   mirror([1,0,0])
129     translate([-test_len,
130                -r2,
131                -(eclip_ra_offset + test_base_th)])
132     cube([test_len,
133           r2*2,
134           test_base_th]);
135 }
136
137 module TestPlanDemo(){
138   color("red") EclipLPlan(test_alpha);
139   color("blue") rotate(test_alpha) EclipPPlan(test_main_th);
140   color("green") EclipRPlan(test_alpha, test_main_th);
141 }
142
143 beta = asin(front_setback / front_height);
144
145 uf = [-sin(beta), cos(beta)];
146 ur = [-uf[0], uf[1]];
147
148 pp = [0, 0];
149 pq = pp + uf*front_height + ur*eclip_ra_offset;
150 pr = [ pq[0] - eclip_base_offset + eclip_wall_offset, 0 ];
151
152 module Sketch(){
153   polygon([pq, pp, pr]);
154 }
155
156 thicks = [ 2, 2, 2 ];
157
158 //side_origins = [ pp, 
159
160 module Joins(alpha, objnum, objnum_f, objnum_m) {
161   echo("Joins",objnum, objnum_f, objnum_m);
162   thm = thicks[objnum_m];
163   if (objnum==objnum_f) {
164     EclipLPlan(alpha);
165     EclipRPlan(alpha, thm);
166   }
167   if (objnum==objnum_m)
168     rotate(alpha)
169       EclipPPlan(thm);
170 }
171
172 module Object(objnum){
173   echo("Object",objnum);
174   translate(pp)                   Joins(beta, objnum, 0,1);
175   translate(pr) mirror([1,0,0])   Joins(0,    objnum, 0,2);
176   translate(pq) rotate([0,0,-90]) Joins(beta, objnum, 2,1);
177 }
178
179 module Base(){ Object(0); }
180 module Front(){ Object(1); }
181 module Back(){ Object(2); }
182
183 module Demo(){
184   Base();
185   Front();
186   Back();
187 }
188
189 //PlanDemo();
190 //TestBase();
191 //TestProtr();
192 //TestRAProtr();
193 //Sketch();
194 //Demo();