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

 Constructing a Sphere (Posted on 2012-02-25)
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.)
 More specific algorithm (spoiler) | Comment 2 of 16 |
I think I implied it with my last post, but let me be more explicit with one of many equivalent algorithms.

Label the spreadsheet rows and columns with 1, 2, 3, 4 ...

Then for a given Radius R and Layer L, color a cell if
(Row# - R - .5)^2 + (Column# - R - .5)^2 + (L - R -.5)^2 <= R^2

Cells will be colored for L between 1 and 2R.

As argued in the earlier post, I think it is important to have .5 in the formula, and an even number of levels.

 Posted by Steve Herman on 2012-02-26 01:24:50

 Search: Search body:
Forums (1)