next up previous contents
Next: Main menu in Turbo Up: geom Previous: Random spheres   Contents

Sphere Lattices

Figure: A 4x4x4 lattice containing spheres of two sizes. Such lattices arise in crystallography, the evolution of cellular automata, and in many other places (like video games).
\begin{figure}\begin{picture}(300,300)(-40,0)
\epsffile{fig19.eps}\end{picture}\end{figure}

Just as molecules can be represented by collections of spheres, so also can crystal lattices. To avoid an endless proliferation of spheres, only a single unit cell would probably be drawn, although drawing a $3 \times
3 \times 3$ cluster would serve to illustrate the central environment better. Provided that the whole assemblage did not become too cluttered, that is.

Another interesting application of a sphere lattice is the representation of a three-dimensional cellular automaton; either the size or the color (or both) of the spheres would serve as an indicator of the state of the cell occupied by the sphere.

 
/* Fill a three dimensional lattice randomly */
/* p is probaility in mils                   */
/* n is lattice width (not number of points) */

void molla(s,p,n) double s[][7]; int p, n; {
int    i, j, k, ii;
double dx;
  dx=3.0/((double)(n-1));
for (i=0; i<n; i++) for (j=0; j<n; j++) for (k=0; k<n; k++) {
  ii=i+n*(j+n*k);
  s[ii][0]=-1.5+((double)i)*dx;
  s[ii][1]=-1.5+((double)j)*dx;
  s[ii][2]=-1.5+((double)k)*dx;
  s[ii][3]=(rand()%1024)<p?0.4*dx:0.166;
  s[ii][4]=(((double)(rand()%4096))/4096.0)*180.0;
  s[ii][5]=(((double)(rand()%4096))/4096.0)*180.0;
  s[ii][6]=(((double)(rand()%4096))/4096.0)*180.0;
  }
}



Pedro Hernandez 2004-05-13