All about flooble | fun stuff | Get a free chatterbox | Free JavaScript | Avatars    
perplexus dot info

Home > Algorithms
Constructing a Sphere (Posted on 2012-02-25) Difficulty: 3 of 5
I would like to construct a sphere by gluing unit cubes together. I'm only attempting to approximate the shape of a sphere as closely as is possible with unit cubes.

Before I get out the glue, how would I go about creating a spreadsheet that would show me the quantity and placement of cubes in each cross-sectional layer? (think of an MRI scan cross-section)

For input, the spreadsheet should ask for the radius of the sphere to be built, as well as which layer of that sphere should be displayed.

There may be more than one way to accomplish this. Any spreadsheet that will allow me to build a sphere by displaying each layer of a sphere for a given radius is considered valid.

Here is an example of output:

Hint: The formula for distance in 3 dimensions is:

d=√[(x2-x1)2+(y2-y1)2+(z2-z1)2]

Bonus question! Adjust your algorithm to display a hollow sphere (think of a ping pong ball, or a beach ball). Note: All cubes must be connected into one contiguous piece.

No Solution Yet Submitted by Dustin    
Rating: 5.0000 (1 votes)

Comments: ( Back to comment list | You must be logged in to post comments.)
Bonus thoughts | Comment 9 of 16 |
Dustin:

I have amended my post to fix the small typo that you pointed out.

As for the bonus question, I have two thoughts

a) If you are not concerned about a maximally hollow sphere, you could just color the cell as white if the center of the cube is within a sphere of radius (R - 1.5).  In other words, 1.5 units less than the target radius.  This results, however, in a slightly over-engineered solid, in that there are a few more interior cubes than needed to make sure that each layer is created out of contiguous cubes.  The formula for cell E3 becomes: 
=IF(POWER($D3-$B$2-0.5,2)+POWER(E$2-$B$2-0.5,2)+POWER($B$3-$B$2-0.5,2)<=POWER($B$2,2),      IF(POWER($D3-$B$2-0.5,2)+POWER(E$2-$B$2-0.5,2)+POWER($B$3-$B$2-0.5,2)<=POWER($B$2-1.5,2),"","X"),"") 

b) If you want a maximally hollow square, I think that you need to use an iterative formula, filling in a cell if the cell that is 1 further out horizontally and vertically is filled in, but the cell that is 1 further out diagonally is not.  Just to simplify this, I would probably put math formulas into just 1/4 of the spreadsheet area, and populate the other 3/4 by setting the formulas to just be mirror images of the math-calculated area.  

  Posted by Steve Herman on 2012-02-26 19:06:11
Please log in:
Login:
Password:
Remember me:
Sign up! | Forgot password


Search:
Search body:
Forums (0)
Newest Problems
Random Problem
FAQ | About This Site
Site Statistics
New Comments (4)
Unsolved Problems
Top Rated Problems
This month's top
Most Commented On

Chatterbox:
Copyright © 2002 - 2017 by Animus Pactum Consulting. All rights reserved. Privacy Information