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
    $\begingroup$ Decompose it into cross sections; each segment should allow an explicit summation involving square roots and floor/ceiling functions. $\endgroup$ – anon Nov 10 '11 at 3:03
  • 1
    $\begingroup$ 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. $\endgroup$ – Ross Millikan Apr 19 at 0:58

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)  





Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.