Calculate “Volume” and “Surface Area” of a voxel-based sphere












5












$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? :)










share|cite|improve this question









$endgroup$








  • 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
















5












$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? :)










share|cite|improve this question









$endgroup$








  • 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














5












5








5





$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? :)










share|cite|improve this question









$endgroup$




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? :)







geometry






share|cite|improve this question













share|cite|improve this question











share|cite|improve this question




share|cite|improve this question










asked Nov 10 '11 at 2:56









InfinitiesLoopInfinitiesLoop

12614




12614








  • 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$
    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




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




$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 Answer
1






active

oldest

votes


















0












$begingroup$

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






share|cite|improve this answer









$endgroup$













    Your Answer





    StackExchange.ifUsing("editor", function () {
    return StackExchange.using("mathjaxEditing", function () {
    StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
    StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
    });
    });
    }, "mathjax-editing");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "69"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    noCode: true, onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f80726%2fcalculate-volume-and-surface-area-of-a-voxel-based-sphere%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0












    $begingroup$

    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






    share|cite|improve this answer









    $endgroup$


















      0












      $begingroup$

      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






      share|cite|improve this answer









      $endgroup$
















        0












        0








        0





        $begingroup$

        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






        share|cite|improve this answer









        $endgroup$



        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







        share|cite|improve this answer












        share|cite|improve this answer



        share|cite|improve this answer










        answered Oct 5 '18 at 15:40









        com.prehensiblecom.prehensible

        18511




        18511






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Mathematics Stack Exchange!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            Use MathJax to format equations. MathJax reference.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f80726%2fcalculate-volume-and-surface-area-of-a-voxel-based-sphere%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            mysqli_query(): Empty query in /home/lucindabrummitt/public_html/blog/wp-includes/wp-db.php on line 1924

            How to change which sound is reproduced for terminal bell?

            Can I use Tabulator js library in my java Spring + Thymeleaf project?