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

add px_sphere

This commit is contained in:
Justin Lin
2019-06-21 20:17:31 +08:00
parent 937b6a35bd
commit b9d88334c5

18
src/pixel/px_sphere.scad Normal file
View File

@@ -0,0 +1,18 @@
function px_sphere(radius, filled = true) =
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)
let(v = [x, y, z])
if(norm(v) < radius) v
] : [
for(x = -radius; x < radius; x = x + 1)
for(y = -radius; y < radius; y = y + 1)
for(z = -radius; z < radius; z = z + 1)
let(
v = [x, y, z],
leng = norm(v)
)
if(leng < radius && (leng * leng) > (radius * radius - 2 * radius) ) v
];