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

add fibonacci_sphere

This commit is contained in:
Justin Lin
2020-10-25 11:43:48 +08:00
parent c749c48a9c
commit afaf8eaeb9

View File

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