-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfast_dome.scad
54 lines (44 loc) · 1.28 KB
/
fast_dome.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
// https://github.com/Sembiance/openscad-modules
module dome_old(d=5, h=2, hollow=false, wallWidth=0.5, $fn=128)
{
sphereRadius = (pow(h, 2) + pow((d/2), 2) ) / (2*h);
translate([0, 0, (sphereRadius-h)*-1])
{
difference()
{
sphere(sphereRadius);
translate([0, 0, -h])
{
cube([2*sphereRadius, 2*sphereRadius, 2*sphereRadius], center=true);
}
if(hollow)
sphere(sphereRadius-wallWidth);
}
}
}
module dome(d=5, h=2, hollow=false, wallWidth=0.5, $fn=$fn)
{
sphereRadius = (pow(h, 2) + pow((d/2), 2) ) / (2*h);
start_x = acos(d / 2 / sphereRadius);
start_y = asin((sphereRadius - h) / sphereRadius);
end = 90;
difference() {
rotate_extrude() {
polygon([
[0,0],
for( i = [0 : $fn - 1])
[sphereRadius * cos(start_x + i / ($fn - 1) * (end - start_x)), sphereRadius * sin(start_y + i / ($fn - 1) * (end - start_y)) - sphereRadius * sin(start_y)]]);
}
if(hollow) { // Could also be done in 2d but this is easier
dome(d-2*wallWidth, h-wallWidth, false);
}
}
}
/*
d = 5;
h = 1;
fn = 128;
dome(d, h, $fn = fn, hollow=true);
translate([d, 0, 0])
dome_old(d, h, $fn = fn, hollow=true);
*/