From 57914a82450da242ff0d264f7c983b0429dd01d2 Mon Sep 17 00:00:00 2001 From: Justin Lin Date: Sat, 12 Mar 2022 18:31:09 +0800 Subject: [PATCH] refactor --- src/fibonacci_lattice.scad | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/fibonacci_lattice.scad b/src/fibonacci_lattice.scad index 28e0ff74..c7ad3f4d 100644 --- a/src/fibonacci_lattice.scad +++ b/src/fibonacci_lattice.scad @@ -8,20 +8,20 @@ * **/ +use ; + 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 ]; \ No newline at end of file