home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-385-Vol-1of3.iso / x / xcu16.zip / clients / xcell / Perturb / mkgrid.c < prev    next >
C/C++ Source or Header  |  1991-10-03  |  2KB  |  54 lines

  1. /*
  2.  * Copyright 1991 Cornell University
  3.  *
  4.  * Permission to use, copy, modify, and distribute this software and its
  5.  * documentation for any purpose and without fee is hereby granted, provided
  6.  * that the above copyright notice appear in all copies and that both that
  7.  * copyright notice and this permission notice appear in supporting
  8.  * documentation, and that the name of Cornell U. not be used in advertising
  9.  * or publicity pertaining to distribution of the software without specific,
  10.  * written prior permission.  Cornell U. makes no representations about the
  11.  * suitability of this software for any purpose.  It is provided "as is"
  12.  * without express or implied warranty.
  13.  *
  14.  * CORNELL UNIVERSITY DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  15.  * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  16.  * EVENT SHALL CORNELL UNIVERSITY BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  17.  * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
  18.  * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
  19.  * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  20.  * PERFORMANCE OF THIS SOFTWARE.
  21.  *
  22.  * Author:  Gene W. Dykes, Program of Computer Graphics
  23.  *          580 Theory Center, Cornell University, Ithaca, NY 14853
  24.  *          (607) 255-6713   gwd@graphics.cornell.edu
  25.  */
  26.  
  27.  
  28. /*
  29.  * This is the program used to generate the grid file.
  30.  * Probably never needed again
  31.  */
  32.  
  33. #include <math.h>
  34. main (argc, argv)
  35. int argc ;
  36. char **argv ;
  37. {
  38. int i; 
  39. int n = atoi (argv[1]) ;
  40. for (i=1;  i <= n;  i++)
  41.     {
  42.     int  w = (int) (sqrt ((float)i) + 0.5) ;
  43.     int  h = i/w ;
  44.     if (h*w == i)
  45.     printf ("g%dg %d %d\n", i, w, h) ;
  46.     else
  47.     {
  48.     if (w < h) w++ ; else h++ ;
  49.     printf ("g%dg %d %d\n", i, w, h) ;
  50.     }
  51.     }
  52. }
  53.  
  54.