8

By "voxel-based sphere" I mean a sphere made up of cubes. Sorry if that is not the correct terminology. Imagine a sphere made out of legos. Except each voxel is a cube (unlike most legos). Determining the voxel distribution to make the sphere I suppose would involve calculating the x/y/z of a position on the sphere and then 'snapping' it to the nearest multiple of the voxel width/height.

Here's a calculator that can generate one: http://neil.fraser.name/news/2006/11/17/

And here is an image of one (cross sectioned):

enter image description here

Given the diameter of this voxel sphere (in number of voxels, e.g. '20 voxels in diameter'), how can I calculate:

  1. The number of voxels in the sphere if it were hollow (kind of a 'surface area')
  2. The number of voxels in the sphere if it were solid (kind of a 'volume')

Is there a formula possible here? :)

  • 1
    Decompose it into cross sections; each segment should allow an explicit summation involving square roots and floor/ceiling functions. – anon Nov 10 '11 at 03:03
  • 3
    You need to specify explicitly which voxels are part of your "sphere". You could include any voxels that the sphere passes through. Does that include ones that it is just tangent to? You could include any voxels that extend more than $1/10$ of a side into and out of the sphere. You could do a number of things. Unless you specify this, there is no answer. – Ross Millikan Apr 19 '19 at 00:58
  • Looking at the circular cross section in your image and focusing just on the portion in the positive $x$ direction (down-left, say) it looks like there's one voxel per row for a fair portion. By changing which axis you take the cross sections through, perhaps most voxels can be accounted for as the only voxel in their half of a row/column/pier? Either way, it's clear that one needs to answer this question for circles first. – TomKern Dec 31 '21 at 01:34
  • I believe the proper terminology is Minecraft sphere. (Joking) – Akiva Weinberger Sep 10 '23 at 19:09

1 Answers1

0

That's very easy, it's a function of an XYZ loop....

You would be actually doing a marching cubes kind of logic, and an ISOsurface logic for a spherical volume.

The first result is this programming query (in metacode):

var cubecount: ForLoop(x,y,z){ If space(x,y,z) corresponds to DistanceFunction(x,y,z) == 1; Then cubecount +=1:

question 2 is the same using >=1

For a sphere on zero of radius 1. (distancefunction is xposvectormagnitude, same thing if the sphere is origin is 0; otherwise the sphere pos equation is for the xyz loop is:

This code makes a 3d printable off axis voxel ball if you want:

num = 45.9874;

for (x =[-num-5:num+5]) 
{
    for (y =[-num-5:num+5]) 
    {    
        for (z =[-num-5:num+5]) 
        {    
              if ((x+1.24)*(x+1.24)+(y+1.66)*(y+1.66)+(z+1.88)*(z+1.88)<=num)  
                translate([x,y,z])    
                cube(1);


        }


    }
}

https://www.thingiverse.com/thing:3075040