6
$\begingroup$

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 Answers 1

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