1
0
mirror of https://github.com/JustinSDK/dotSCAD.git synced 2025-01-18 06:38:14 +01:00
This commit is contained in:
Justin Lin 2022-03-12 18:31:09 +08:00
parent 987bc3be5b
commit 57914a8245

View File

@ -8,20 +8,20 @@
*
**/
use <util/degrees.scad>;
function fibonacci_lattice(n, radius = 1, dir = "CT_CLK") =
let(
toDegrees = 180 / PI,
phi = PI * (3 - sqrt(5)),
clk = dir == "CT_CLK" ? 1 : -1
)
[
for(i = [0:n - 1])
let(
z = 1 - (2* i + 1) / n,
r = sqrt(1 - z * z),
z = 1 - (2 * i + 1) / n,
r = sqrt(1 - z ^ 2),
theta = phi * i * clk,
x = cos(theta * toDegrees) * r,
y = sin(theta * toDegrees) * r
deg = degrees(theta)
)
[x, y, z] * radius
[cos(deg) * r, sin(deg) * r, z] * radius
];