From d9199bf9ed4416adfccfa6fe089d2744b3483309 Mon Sep 17 00:00:00 2001 From: Justin Lin Date: Fri, 28 Jun 2019 06:38:15 +0800 Subject: [PATCH] use range --- src/pixel/px_sphere.scad | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/pixel/px_sphere.scad b/src/pixel/px_sphere.scad index c95709c5..3893630c 100644 --- a/src/pixel/px_sphere.scad +++ b/src/pixel/px_sphere.scad @@ -1,16 +1,17 @@ function px_sphere(radius, filled = true) = + let(range = [-radius: radius - 1]) filled ? [ - for(x = -radius; x < radius; x = x + 1) - for(y = -radius; y < radius; y = y + 1) - for(z = -radius; z < radius; z = z + 1) + for(x = range) + for(y = range) + for(z = range) let(v = [x, y, z]) if(norm(v) < radius) v ] : let(ishell = radius * radius - 2 * radius) [ - for(z = -radius; z < radius; z = z + 1) - for(y = -radius; y < radius; y = y + 1) - for(x = -radius; x < radius; x = x + 1) + for(z = range) + for(y = range) + for(x = range) let( v = [x, y, z], leng = norm(v)