/*  Make Matriz v1.0                                                  */
/*  Bulla -  March 97                                                 */

/*  Any  suggestions, comments or blames try:                         */
/*  ggonzale@toqui.usach.cl                                           */
/*  chasan@dcc.uchile.cl                                              */
/*  comp.sys.hp48                                                     */
/*  /dev/null                                                         */



#include<stdio.h>
#include<math.h>


#define radius 20      /*  Here change sphere radius  (1,32) */
#define xs radius*2
#define ys radius*2
#define step 0.035


typedef int xside[xs+1];
xside mlen[ys+1];


int init()
{
  float alpha,beta;
  int   x,y,z;


  alpha=3.141592654;
  while (alpha>0)
  {
    beta=3.141592654;
    while (beta>0)
    {
      x=radius+ceil(radius*cos(alpha)*sin(beta)-0.5);
      y=radius+ceil(0.833*radius*cos(beta)-0.5);
      z=ceil(radius*sin(alpha)*sin(beta)-0.5);
      if ((x<=xs-1) || (y<=ys-1)) mlen[++x][++y]=(radius-z) >> 1;

      beta -= step;
    }
    alpha -= step;
  }
}

main()
{
  int g2,g1;


  init();

   printf("{\n");

   for (g2=1;g2<=ys;g2++)
   {
     printf(" { ");

     for (g1=1;g1<=xs;g1++)
       printf("%d  ",mlen[g1][g2]);

     printf("}\n");
   }

   printf("}\n");
}
