From 639737a2077678cd50ff56f6fa660991a837c925 Mon Sep 17 00:00:00 2001 From: Justin Lin Date: Mon, 18 Apr 2022 22:37:26 +0800 Subject: [PATCH] refactor: extact dir cond --- src/sphere_spiral.scad | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/sphere_spiral.scad b/src/sphere_spiral.scad index f774bae6..a72cd91e 100644 --- a/src/sphere_spiral.scad +++ b/src/sphere_spiral.scad @@ -13,14 +13,12 @@ use ; function sphere_spiral(radius, za_step, z_circles = 1, begin_angle = 0, end_angle = 0, vt_dir = "SPI_DOWN", rt_dir = "CT_CLK") = let( a_end = 90 * z_circles - end_angle, - p = [radius, 0, 0] + p = [radius, 0, 0], + ya_base = vt_dir == "SPI_DOWN" ? -90 : 90, + za_sign = rt_dir == "CT_CLK" ? 1 : -1 ) [ for(a = begin_angle; a <= a_end; a = a + za_step) - let( - ya = vt_dir == "SPI_DOWN" ? (-90 + 2 * a / z_circles) : (90 + 2 * a / z_circles), - za = (rt_dir == "CT_CLK" ? 1 : -1) * a, - ra = [0, ya, za] - ) - [ptf_rotate(p, ra), ra] + let(ra = [0, ya_base + 2 * a / z_circles, za_sign * a]) + [ptf_rotate(p, ra), ra] ]; \ No newline at end of file