Cubes Within A Bigger Cube

Name- Diana M. Echeverri
E-mail- lafla1115@yahoo.com

What I wanted mathematica to help me with was to see how many little cubes of different sizes would I be able to fit in a big cube. The file takes you through the steps which I took to get to the final result. The result was to show smaller cubes changing sizes inside a bigger cube, and knowing how many cubes of that particular size fit inside it.

In the section below I started to work with mathematicas code; Graphics3D and Cuboid. Cuboid and graphics3D work together to give a cube in 3D, where you can manipulate the size of the cube. Since I needed to show the smaller cubes inside this bigger cube I needed to use Opacity. Opacity made the bigger cube transparent, so you are able to see what is going on inside. Then I worked with the cuboid code to get the smaller cubes positioned correctly, and get a pattern so I would be able to create a code where mathematica would do everything for me.

Graphics3D[{{Opacity[0.2],Cuboid[{0,0,0}]},Cuboid[{0,0,0},{0.2,0.2,0.2}],Cuboid[{0,0,.2},{0.2,0.2,0.4}],Cuboid[{0,0,.4},{.2,.2,.6}],Cuboid[{0,0,.6},{.2,.2,.8}],Cuboid[{0,0,.8},{.2,.2,1}],Cuboid[{0,.2,0},{.2,.4,.2}],Cuboid[{0,.2,.2},{.2,.4,.4}],Cuboid[{0,.2,.4},{.2,.4,.6}],Cuboid[{0,.2,.6},{.2,.4,.8}],Cuboid[{0,.2,.8},{.2,.4,1}],Cuboid[{0,.4,0},{.2,.6,.2}],Cuboid[{0,.4,.2},{.2,.6,.4}],Cuboid[{0,.4,.4},{.2,.6,.6}],Cuboid[{0,.4,.6},{.2,.6,.8}],Cuboid[{0,.4,.8},{.2,.6,1}],Cuboid[{0,.6,0},{.2,.8,.2}],Cuboid[{0,.6,.2},{.2,.8,.4}],Cuboid[{0,.6,.4},{.2,.8,.6}],Cuboid[{0,.6,.6},{.2,.8,.8}],Cuboid[{0,.6,.8},{.2,.8,1}],Cuboid[{0,.8,0},{.2,1,.2}],Cuboid[{0,.8,.2},{.2,1,.4}],Cuboid[{0,.8,.4},{.2,1,.6}],Cuboid[{0,.8,.6},{.2,1,.8}],Cuboid[{0,.8,.8},{.2,1,1}],Cuboid[{.2,0,0},{.4,.2,.2}],Cuboid[{.2,0,.2},{.4,.2,.4}],Cuboid[{.2,0,.4},{.4,.2,.6}],Cuboid[{.2,0,.6},{.4,.2,.8}],Cuboid[{.2,0,.8},{.4,.2,1}],Cuboid[{.2,.2,0},{.4,.4,.2}],Cuboid[{.2,.2,.2},{.4,.4,.4}],Cuboid[{.2,.2,.4},{.4,.4,.6}]}]

I was able to see a pattern after some cubes. I then created a code with mathematica, where mathematica would create the smaller cubes in the bigger cube all by itself, to do this I used the table code. I was able to fill up the big cube with smaller cubes of size {.2}, by manipulating the table code. After I figured that out I was then able to keep manipulating the table code to keep changing the sizes of the inner cubes. That is exactly what is happening in the following cells, only the sizes of the smaller cubes are being manipulated. I also changed the larger cube in order for everyone to see that there was indeed a bigger cube. I changed the center of the bigger cube because if I left it where it was you would not be able to see the big cube.

Graphics3D[{{Opacity[0.2],Cuboid[{.1,.1,.1}]},Table[Cuboid[{x,y,z},{x+.2,y+.2,z+.2}],{x,0,.8,.2},{y,0,.8,.2},{z,0,.8,.2}]}]

Graphics3D[{{Opacity[0.2],Cuboid[{.1,.1,.1}]},Table[Cuboid[{x,y,z},{x+.1,y+.1,z+.1}],{x,0,.9,.1},{y,0,.9,.1},{z,0,.9,.1}]}]

Graphics3D[{{Opacity[0.2],Cuboid[{.1,.1,.1}]},Table[Cuboid[{x,y,z},{x+.3,y+.3,z+.3}],{x,0,.6,.3},{y,0,.6,.3},{z,0,.6,.3}]}]

Graphics3D[{{Opacity[0.2],Cuboid[{.1,.1,.1}]},Table[Cuboid[{x,y,z},{x+.4,y+.4,z+.4}],{x,0,.4,.4},{y,0,.4,.4},{z,0,.4,.4}]}]

Graphics3D[{{Opacity[0.2],Cuboid[{.1,.1,.1}]},Table[Cuboid[{x,y,z},{x+.5,y+.5,z+.5}],{x,0,.5,.5},{y,0,.5,.5},{z,0,.5,.5}]}]

This last cell does exactly what I wanted mathemamatica to help me with. It changes the sizes of the cubes within the big cube and tells you how many little cubes there are. After manipulating the table code a couple of times I was able to get a more defined pattern, which would be easier for the manipulate code in mathematica to deal with. The manipulate code was able to change the sizes of smaller cubes inside the bigger cube on its own as long as you press play. The Floor code brings the answer of {1/d} to the smaller of the two numbers its between. In order to see all the smaller cubes, you need to slow down the manipulation.

Manipulate[{Graphics3D[{{Opacity[.2],Cuboid[{0,0,0}]},Table[Cuboid[{x,y,z},{x+d,y+d,z+d}],{x,0,1-d,d},{y,0,1-d,d},{z,0,1-d,d}]}],Floor[1/d]^3},{d,.06,.51,.01}]