1
0
mirror of https://github.com/JustinSDK/dotSCAD.git synced 2025-08-21 14:04:53 +02:00

don't cal repeatly

This commit is contained in:
Justin Lin
2019-06-22 09:17:45 +08:00
parent 9ed4e1c42b
commit e9b1e7f61f

View File

@@ -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
];