# 多條黃金螺線

spirals = 5;

function fibonacci(nth) =
nth == 0 || nth == 1 ? nth : (
fibonacci(nth - 1) + fibonacci(nth - 2)
);

module sector(radius, angles, fn = 24) {
r = radius / cos(180 / fn);
step = -360 / fn;

points = concat([[0, 0]],
[for(a = [angles[0] : step : angles[1] - 360])
[r * cos(a), r * sin(a)]
],
[[r * cos(angles[1]), r * sin(angles[1])]]
);

difference() {
polygon(points);
}
}

module arc(radius, angles, width = 1, fn = 24) {
difference() {
}
}

module golden_spiral(from, to, thickness) {
if(from <= to) {
f1 = fibonacci(from);
f2 = fibonacci(from + 1);

arc(f1, [0, 90], thickness, 48);

offset = f2 - f1;

translate([0, -offset, 0]) rotate(90)
golden_spiral(from + 1, to, thickness);
}
}

linear_extrude(1) for(a = [0 : 360 / spirals : 360 - 360 / spirals]) {
rotate(a) golden_spiral(1, 6, 0.5);
}

/*
mirror([0, 1, 0]) linear_extrude(1) for(a = [0 : 360 / spirals : 360 - 360 / spirals]) {
rotate(a) golden_spiral(1, 6, 0.5);
}
*/

# 擺上花瓣

// ...程式碼與之前相同...故略

module golden_spiral(from, to, thickness) {
if(from <= to) {
f1 = fibonacci(from);
f2 = fibonacci(from + 1);

offset = f2 - f1;

linear_extrude(thickness, center = true)
scale([2, 1, 1]) circle(offset / 5, \$fn = 4);

translate([0, -offset, 0]) rotate(90)
golden_spiral(from + 1, to, thickness);
}
}

golden_spiral(5, 10, 1);

circle 模組需要的半徑，是兩個費式數差的五分之一，這樣的話，就會有由小到大的花瓣，完成的圖案如下：

spirals = 4;

// ...程式碼與之前相同...故略

module golden_spiral(from, to, thickness) {
if(from <= to) {
f1 = fibonacci(from);
f2 = fibonacci(from + 1);

offset = f2 - f1;

linear_extrude(thickness, center = true)
scale([2, 1, 1]) circle(offset / 5, \$fn = 4);

translate([0, -offset, 0]) rotate(90)
golden_spiral(from + 1, to, thickness);
}
}

for(a = [0 : 360 / spirals : 360 - 360 / spirals]) {
rotate(a) golden_spiral(5, 10, 1);
}

// ...程式碼與之前相同...故略

module golden_spiral(from, to, thickness) {
if(from <= to) {
f1 = fibonacci(from);
f2 = fibonacci(from + 1);

offset = f2 - f1;

rotate([0, 30, 0]) linear_extrude(thickness, center = true)
scale([2, 1, 1]) circle(offset / 5, \$fn = 4);

translate([0, -offset, 0]) rotate(90)
golden_spiral(from + 1, to, thickness);
}
}

// ...程式碼與之前相同...故略

// ...程式碼與之前相同...故略

module golden_spiral(from, to, thickness) {
if(from <= to) {
f1 = fibonacci(from);
f2 = fibonacci(from + 1);

offset = f2 - f1;

translate([5, 0, 0]) rotate([10, 30, 0])
linear_extrude(thickness, center = true) scale([2, 1, 1]) circle(offset / 5, \$fn = 4); translate([0, -offset, 0]) rotate(90) golden_spiral(from + 1, to, thickness); } } // ...程式碼與之前相同...故略

spirals = 8;

function fibonacci(nth) =
nth == 0 || nth == 1 ? nth : (
fibonacci(nth - 1) + fibonacci(nth - 2)
);

module sector(radius, angles, fn = 24) {
r = radius / cos(180 / fn);
step = -360 / fn;

points = concat([[0, 0]],
[for(a = [angles[0] : step : angles[1] - 360])
[r * cos(a), r * sin(a)]
],
[[r * cos(angles[1]), r * sin(angles[1])]]
);

difference() {
polygon(points);
}
}

module arc(radius, angles, width = 1, fn = 24) {
difference() {
}
}

module golden_petals(from, to, thickness) {
if(from <= to) {
f1 = fibonacci(from);
f2 = fibonacci(from + 1);

offset = f2 - f1;

translate([5, 0, 0]) rotate([10, 30, 0])
linear_extrude(thickness, center = true) scale([2, 1, 1]) circle(offset / 5, \$fn = 4); translate([0, -offset, 0]) rotate(90) golden_petals(from + 1, to, thickness); } } for(a = [0 : 360 / spirals : 360 - 360 / spirals]) { rotate(a) golden_petals(5, 10, 1); }