home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / misc / volume9 / draw_jt / part01 / kiero.c < prev    next >
Encoding:
C/C++ Source or Header  |  1989-12-12  |  1.9 KB  |  77 lines

  1. /*
  2.  
  3. Copyright (C) 1988, 1989 by Juha Takala, jta@sah.vtt.fi
  4.  
  5.      This program is free software; you can redistribute it and/or modify
  6.      it under the terms of the GNU General Public License as published by
  7.      the Free Software Foundation; version 1.
  8.  
  9.      This program is distributed in the hope that it will be useful,
  10.      but WITHOUT ANY WARRANTY; without even the implied warranty of
  11.      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12.      the file "License for more details
  13.  
  14.      You should have received a copy of the GNU General Public License
  15.      along with this program; if not, write to the Free Software
  16.      Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  17.  
  18.  
  19.  */
  20.  
  21. /* Description:
  22.  * Screwed demo to tie your cpu for a while.  Pipe the output of this
  23.  * program to the "draw" that you just made, and "draw"'s output to the
  24.  * device you like.
  25.  */
  26.  
  27. #include <math.h>
  28. #include <stdio.h>
  29.  
  30. static char *rcsid =
  31.   "$Id: kiero.c,v 1.3 89/12/08 14:00:54 jta Exp Locker: jta $";
  32.  
  33. double param[8] = {0.99, -0.7, 3.01, 1.01, 0.1, 15.03, 0.01};
  34. static char *ttbl[] = {
  35.     "#$xrange -2,1,2",
  36.     "#$yrange -2,1,2",
  37.     "#$noaxes",
  38.     "#$init",
  39.     "#$size 2",
  40.     "#$text -2,1.9,See: Computer Recreations",
  41.     "#$text -2,1.7,Scientific American, May -88, p.95",
  42.     "#$size 1.4",
  43.     "#$text -2,-1.75,Hit your interrupt character to stop.",
  44.     NULL
  45. };
  46.  
  47. int maxn = 100000;
  48.  
  49. main (argc, argv, envp)
  50. int argc;
  51. char *argv[], *envp[];
  52. {
  53.     double t, *p;
  54.     char **cp;
  55.     int i;
  56.     
  57.     if (argc > 1) {
  58.     maxn = atoi(*(++argv));
  59.     argc--;
  60.     }
  61.     
  62.     p = param;
  63.     while (--argc > 0)
  64.       *(p++) = atof(*(++argv));
  65.  
  66.     for (cp=ttbl; *cp; cp++)
  67.       printf ("%s\n", *cp);
  68.  
  69.     t = 0.0;
  70.     for (i=0; i<maxn; i++) {
  71.     printf ("%8.4f %8.4f\n",
  72.         sin(param[0]*t) + param[1] * cos(param[2]*t),
  73.         cos(param[3]*t) + param[4] * sin(param[5]*t));
  74.     t += param[6];
  75.     }
  76. }
  77.