New in Wolfram Mathematica 7: New Graphics Primitives  previous | next 
Efficiently Specify Large Numbers of Spheres
Compactly and efficiently describe a collection of spheres with different radii.
In[1]:=

Click for copyable input
Graphics3D[Sphere[

  Flatten[Table[{i, j, k}, {i, -2, 2}, {j, -2, 2}, {k, -2, 2}], 2], 

  Flatten[Table[

    Mod[i + j, 2]*(1 - (k + 2)/4), {i, -2, 2}, {j, -2, 2}, {k, -2, 

     2}], 2]]]
Out[1]=