home *** CD-ROM | disk | FTP | other *** search
/ Encyclopedia of Graphics File Formats Companion / GFF_CD.ISO / formats / ttddd / code / chain.c < prev    next >
C/C++ Source or Header  |  1994-06-20  |  1KB  |  50 lines

  1. /* chain.c - generate chain - Glenn M. Lewis - 2/18/90 */
  2.  
  3. #include <stdio.h>
  4. #include <math.h>
  5.  
  6. #ifndef PI
  7. #define PI 3.14159265
  8. #endif
  9. #define RADIUS 200.0
  10.  
  11. main()
  12. {
  13.     int i;
  14.  
  15.     printf("%% TTDDD file, created by chain.c\n");
  16.     printf("%% Written by Glenn M. Lewis\n\n");
  17.  
  18.     printf("OBJ Begin\nDESC Begin\nNAME \"AXIS\"\nEND DESC\n\n");
  19.  
  20.     for (i=0; i<360; i+=36) {
  21.         do_up(i);
  22.         do_side(i+18);
  23.     }
  24.  
  25.     printf("TOBJ\nEnd OBJ\n");
  26. }
  27.  
  28. do_up(i)
  29. int i;
  30. {
  31.     double c, s;
  32.     c = cos((double)PI*i/180.0);
  33.     s = sin((double)PI*i/180.0);
  34.     printf("EXTR Begin\nMTRX Trans %0.4lf %0.4lf 0\n", s*RADIUS, -c*RADIUS);
  35.     printf("MTRX Rotate %0.4lf 0 %0.4lf %0.4lf 0 %0.4lf 0 1 0\n", c, s, s, -c);
  36.     printf("LOAD \"VD0:link_xy.tddd\"\nEnd EXTR\n\n");
  37. }
  38.  
  39. do_side(i)
  40. int i;
  41. {
  42.     double c, s;
  43.     c = cos((double)PI*i/180.0);
  44.     s = sin((double)PI*i/180.0);
  45.     printf("EXTR Begin\nMTRX Trans %0.4lf %0.4lf 0\n", s*RADIUS, -c*RADIUS);
  46.     printf("MTRX Rotate %0.4lf %0.4lf 0 %0.4lf %0.4lf 0 0 0 1\n", c, -s, s, c);
  47.     printf("LOAD \"VD0:link_xy.tddd\"\nEnd EXTR\n\n");
  48. }
  49.  
  50.