chiark / gitweb /
earring-stand: TestBase good
[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
20 // calculated
21
22 include <utils.scad>
23
24 eclip_inner_strt = eclip_outer_strt + eclip_inner_xstrt;
25
26 r0 = eclip_inner_rad;
27 r1 = r0 + eclip_gap_rad;
28 r2 = r1 + eclip_prong_th;
29 r2e = r1 + eclip_base_epsilon;
30
31 ppxl = -(r0 / sqrt(2)) + (eclip_inner_strt / sqrt(2));
32
33 rgap = eclip_gap_rad;
34
35 eclip_base_offset = r1;
36
37 $fn=70;
38
39 module EclipLPlanCore(alpha){
40   FArcSegment(0,0, r1,r2,
41               180-eclip_ult_angle, eclip_ult_angle-alpha +1);
42
43   difference(){
44     hull(){
45       intersection(){
46         circle(r2);
47         rotate(-alpha) mirror([1,1]) square([r2e, 50]);
48      }
49       rotate(-alpha) mirror([1,1]) square([r2e, r2]);
50     }
51     circle(r1);
52   }
53 }
54
55 module EclipRPlan(alpha, main_th){
56   intersection(){
57     rotate(alpha)
58       translate([ppxl + main_th + rgap, -r2*2])
59       square([eclip_prong_th, r2*(2 + 1/sqrt(2))]);
60     translate([-r2, -r2e])
61       square([r2*3, eclip_base_epsilon + r2*4]);
62   }
63 }
64
65 module EclipLPlan(alpha){
66   rotate(alpha) EclipLPlanCore(alpha);
67 }
68
69 module EclipPPlan(main_th){
70   intersection(){
71     hull(){
72       circle(r0);
73       rotate(90-eclip_ult_angle) square([r0,r0]);
74     }
75     translate([-(r0+.1), -(r0+.1)])
76       square([(r0+.1) + main_th + ppxl, r2*2]);
77   }
78   translate([ppxl, 0]) square([main_th, r2]);
79 }
80
81 module TestBase(){
82   translate([0,0, eclip_base_offset]){
83     for (i=[0 : 2: test_eclips-1]) {
84       translate([0, i*eclip_each_every])
85         rotate([90,0,0])
86         linear_extrude(height=eclip_each_len)
87         EclipLPlan(test_alpha);
88     }
89     for (j=[1 : 2: test_eclips-2]) {
90       translate([0, j*eclip_each_every])
91         rotate([90,0,0])
92         linear_extrude(height=eclip_each_len)
93         EclipRPlan(test_alpha, test_main_th);
94     }
95   }
96   translate([-r2, -eclip_each_len, -test_base_th])
97     cube([r2*2,
98           eclip_each_len + eclip_each_every*(test_eclips-1),
99           test_base_th]);
100 }
101
102 module PlanDemo(){
103   color("red") EclipLPlan(test_alpha);
104   color("blue") rotate(test_alpha) EclipPPlan(test_main_th);
105   color("green") EclipRPlan(test_alpha, test_main_th);
106 }
107
108 //PlanDemo();
109 TestBase();