-
Notifications
You must be signed in to change notification settings - Fork 41
/
Copy pathogive-2.scad
91 lines (76 loc) · 2.11 KB
/
ogive-2.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
function v_sum_r(v,n,k) =
k > n ? 0 : v[k] + v_sum_r(v,n,k+1);
function v_sum(v,n) = v_sum_r(v,n-1,0);
// compute the x,y and r parameters for an arch with a given width,height
// and sharpness
// messy code because function body is very restricted
// return array [x,y,r]
function ogive_r(w,h,s) =
(pow(w/2,2) + pow(w * s,2) )/ w;
function ogive(w,h,s) =
[ogive_r(w,h,s) - (w/2), h - w * s, ogive_r(w,h,s)];
// construct arch
module arch(x,y,r) {
union() {
intersection () {
translate([x,y,0]) circle(r);
translate([-x,y,0]) circle(r);
}
translate([0,y/2,0]) square(size=[2 *(r-x), y],center=true);
}
}
delta=1;
module archway_out(x,y,r,t,d) {
linear_extrude(height=d)
difference () {
arch(x,y,r+t,d);
translate([0,0,-delta]) arch(x,y,r,d+2*delta);
}
}
module archway_in(x,y,r,t,d) {
linear_extrude(height=d)
difference () {
arch(x,y,r,d);
translate([0,0,-delta]) arch(x,y,r-t,d+2*delta);
}
}
module nested_archway_xy_out (x,y,r,t,d,n) {
union() {
for (i=[1:n]) {
assign(dt = v_sum(t,i-1)) {
echo(t[i-1],dt);
archway_out(x,y,r+dt, t[i-1],d[i-1]);
}
}
}
}
module nested_archway_xy_in (x,y,r,t,d,n) {
union() {
for (i=[1:n]) {
assign(dt = v_sum(t,i-1)) {
echo(t[i-1],dt);
archway_in(x,y,r-dt,t[i-1],d[i-1]);
}
}
}
}
module nested_archway_out(width,height,sharpness,thickness,depth,n) {
assign(p = ogive(width,height,sharpness))
nested_archway_xy_out(p[0],p[1],p[2],thickness,depth,n);
}
module nested_archway_in(width,height,sharpness,thickness,depth,n) {
assign(p = ogive(width,height,sharpness))
nested_archway_xy_in(p[0],p[1],p[2],thickness,depth,n);
}
module remove_ground() {
difference() {
child(0);
translate([0,-49.98,0]) cube([100,100,100],center=true);
}
}
$fa = 0.01; $fs = 0.5;
remove_ground ()
nested_archway_out(15,30,0.8,[2,4,2,4],[1,3,5,7],4);
*translate([0,0,150])
remove_ground ()
nested_archway_in(20,40,0.8,[2,1,3,1],[4,3,2,1],4);