From afaf8eaeb9a7cf0ec87a98c4bc600e4ed149612e Mon Sep 17 00:00:00 2001 From: Justin Lin Date: Sun, 25 Oct 2020 11:43:48 +0800 Subject: [PATCH] add fibonacci_sphere --- src/experimental/fibonacci_sphere.scad | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 src/experimental/fibonacci_sphere.scad diff --git a/src/experimental/fibonacci_sphere.scad b/src/experimental/fibonacci_sphere.scad new file mode 100644 index 00000000..9c9b4520 --- /dev/null +++ b/src/experimental/fibonacci_sphere.scad @@ -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] + ]; \ No newline at end of file