From e9b1e7f61fcd5a2196ccce52db005945c1742121 Mon Sep 17 00:00:00 2001 From: Justin Lin Date: Sat, 22 Jun 2019 09:17:45 +0800 Subject: [PATCH] don't cal repeatly --- src/pixel/px_sphere.scad | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/pixel/px_sphere.scad b/src/pixel/px_sphere.scad index a9e789eb..de12597b 100644 --- a/src/pixel/px_sphere.scad +++ b/src/pixel/px_sphere.scad @@ -5,7 +5,9 @@ function px_sphere(radius, filled = true) = for(z = -radius; z < radius; z = z + 1) let(v = [x, y, z]) if(norm(v) < radius) v - ] : [ + ] : + let(ishell = radius * radius - 2 * radius) + [ for(x = -radius; x < radius; x = x + 1) for(y = -radius; y < radius; y = y + 1) for(z = -radius; z < radius; z = z + 1) @@ -13,6 +15,6 @@ function px_sphere(radius, filled = true) = v = [x, y, z], leng = norm(v) ) - if(leng < radius && (leng * leng) > (radius * radius - 2 * radius) ) v + if(leng < radius && (leng * leng) > ishell) v ]; \ No newline at end of file