-
Notifications
You must be signed in to change notification settings - Fork 0
/
2tri1quad.scad
138 lines (119 loc) · 2.12 KB
/
2tri1quad.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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
$fn=100;
e=.001;
r=100;
w=8;
h=6;
/*
* alpha: the regular spherical triangles' great-circle arc (edge-length)
* beta: the regular spherical squares' great-circle arc (edge-length)
*
* A: the triangles' corner arc
* B: the squares' corner arc
* A+B = tau/2
*
* alpha = 2*beta
* cos (alpha) = 1 / (1-cos(A)) - 1
* cos (beta) = 2 / (1-cos(B)) - 1
* cos (beta) = 2 / (1+cos(A)) - 1
*
* let x = cos(A)
*
* 1 / (1-x) -1 = 2 * ( 2/(1+x) - 1 )^2 - 1
*
*/
cuberoot=pow(24*sqrt(78)-181, 1/3);
cos_A=(1/6)*(5) -
(1/6)*(23)/cuberoot +
(1/6)*cuberoot;
A=acos(cos_A);
cos_alpha=1/(1-cos_A)-1;
alpha=acos(cos_alpha);
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 quad()
{
children();
step_x(){
children();
step_x(){
children();
step_x(){
children();
}
}
}
}
module extend()
{
children();
step_y()
{
children();
step_x()step_x()step_x()
{
children();
step_y()
{
children();
step_x()
{
children();
step_y()children();
}
}
}
}
}
module ball()
{
quad()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 */