diff --git a/src/experimental/fibonacci_sphere.scad b/src/experimental/fibonacci_sphere.scad index 88c52d20..6ea917d1 100644 --- a/src/experimental/fibonacci_sphere.scad +++ b/src/experimental/fibonacci_sphere.scad @@ -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] ]; \ No newline at end of file