-
Notifications
You must be signed in to change notification settings - Fork 0
/
2tri1tri.scad
112 lines (94 loc) · 1.54 KB
/
2tri1tri.scad
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
$fn=100;
e=.001;
r=100;
w=1;
h=20;
/*
* alpha = 2*beta
* cos (alpha) = 1 / (1-cos(A)) - 1
* cos (beta) = 1 / (1+cos(A)) - 1
*
* let x = cos(A)
*
* 1 / (1-x) -1 = 2 * ( 1/(1+x) - 1 )^2 - 1
*
* 2x^3 - x^2 + 2x + 1 = 0
*/
cuberoot=pow(6*sqrt(177)-71,1/3);
cos_A=(1/6)*(1) -
(1/6)*(11)/cuberoot +
(1/6)*cuberoot;
A=acos(cos_A);
cos_alpha=1/(1-cos_A)-1;
alpha=acos(cos_alpha);
echo (A, alpha*3/2);
module arc(r, w, h)
{
rotate_extrude(angle=alpha*3/4)
translate([r-h/2,0])square([h,w],center=true);
}
module chopped_arc(r,w,h)
{
difference(){
arc(r,w,h);
rotate([-A,0,0])
translate([r,0,0])
cube([w+h,w+h,w-e],center=true);
}
}
module spherical_arc(r,w,h)
{
intersection()
{
chopped_arc(r+h,w,h+r);
difference()
{
sphere(r);
sphere(r-h);
}
}
}
module step_x()
{
rotate([0,0,alpha/2])rotate([A,0,0])
children();
}
module step_y()
{
rotate([0,0,3*alpha/2])rotate([180,0,0])
children();
}
module tri()
{
children();
step_x(){
children();
step_x(){
children();
}
}
}
module extend()
{
children();
step_y()tri()children();
}
module ball()
{
tri()extend()children();
}
module smooth_ball_alt(r,w,h)
{
intersection()
{
ball()arc(r+h,w,h+r);
difference()
{
sphere(r);
sphere(r-h);
}
}
}
ball()chopped_arc(r,w,h);
//ball()spherical_arc(r,w,h); /* slow */
//smooth_ball_alt(r,w,h); /* slow */