diff --git a/src/pixel/px_sphere.scad b/src/pixel/px_sphere.scad new file mode 100644 index 00000000..a9e789eb --- /dev/null +++ b/src/pixel/px_sphere.scad @@ -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 + ]; + \ No newline at end of file