1
0
mirror of https://github.com/JustinSDK/dotSCAD.git synced 2025-08-19 04:51:26 +02:00

adjust poles

This commit is contained in:
Justin Lin
2020-10-25 14:52:51 +08:00
parent f2052b09d3
commit b742ff3454

View File

@@ -1,16 +1,17 @@
function fibonacci_sphere(n) =
function fibonacci_sphere(n, dir = "CT_CLK") =
let(
toDegrees = 180 / PI,
phi = PI * (3 - sqrt(5))
phi = PI * (3 - sqrt(5)),
clk = dir == "CT_CLK" ? 1 : -1
)
[
for(i = [0:n - 1])
let(
y = 1 - (i / (n - 1)) * 2,
radius = sqrt(1 - y * y),
theta = phi * i,
x = cos(theta * toDegrees) * radius,
z = sin(theta * toDegrees) * radius
z = 1 - (2* i + 1) / n,
r = sqrt(1 - z * z),
theta = phi * i * clk,
x = cos(theta * toDegrees) * r,
y = sin(theta * toDegrees) * r
)
[x, y, z]
];