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 crosssectional layer? (think of an MRI scan crosssection)
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=√[(x_{2}x_{1})^{2}+(y_{2}y_{1})^{2}+(z_{2}z_{1})^{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.
Firstly this comment does rely on the reader having some concept of spreadsheet 'mechanics'. Secondly, this uses the idea of 'slicing' the object into odd numbers of layers which are from 0 to twice the layer value submiitted.
My solution, based upon interactions with Dustin, amounted to a spreadsheet which looks rather like this:
Radius: "B1" 20 19 ......... 0 ......... 19 20
Layer: "B2" 20 Sum
19 Sum
.. Sum
.. Sum
0 XFormula Sum
.. Sum
.. Sum
19 Sum
20 Sum
Col Sum
XFormula:
=IF((((((X$1^2)+(($B$1$B$2)^2))+($C22^2))^0.5)<($B$1+0.5)),1," ")
Absolute cell recognition is essential for this to work (the '$' symbol does that).
The formula is pasted into X22 which on this sheet has 'coordinates' X1 and C22 equal to zero . That formula is then highlighted and "dragcopy" under the rules of the spreadsheet to fill the display grid; this does not take one operation. [
X22 is (0,0) which has been noted].
The sum column tallies the "1" values in each row while the Col Sum tallies all of those within that column.
Edited on March 2, 2012, 6:50 am

Posted by brianjn
on 20120302 06:06:33 