home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Fish 'n' More 2
/
fishmore-publicdomainlibraryvol.ii1991xetec.iso
/
dirs
/
ttddd_420.lzh
/
TTDDD
/
Examples
/
chain.c
< prev
next >
Wrap
C/C++ Source or Header
|
1990-12-20
|
930b
|
47 lines
/* chain.c - generate chain - Glenn M. Lewis - 2/18/90 */
#include <stdio.h>
#include <math.h>
#ifndef PI
#define PI 3.14159265
#endif
#define RADIUS 200.0
main()
{
int i;
printf("OBJ Begin\nDESC Begin\nNAME \"AXIS\"\nEND DESC\n\n");
for (i=0; i<360; i+=36) {
do_up(i);
do_side(i+18);
}
printf("TOBJ\nEnd OBJ\n");
}
do_up(i)
int i;
{
double c, s;
c = cos((double)PI*i/180.0);
s = sin((double)PI*i/180.0);
printf("EXTR Begin\nMTRX Trans %0.4lf %0.4lf 0\n", s*RADIUS, -c*RADIUS);
printf("MTRX Rotate %0.4lf 0 %0.4lf %0.4lf 0 %0.4lf 0 1 0\n", c, s, s, -c);
printf("LOAD \"VD0:link_xy.tddd\"\nEnd EXTR\n\n");
}
do_side(i)
int i;
{
double c, s;
c = cos((double)PI*i/180.0);
s = sin((double)PI*i/180.0);
printf("EXTR Begin\nMTRX Trans %0.4lf %0.4lf 0\n", s*RADIUS, -c*RADIUS);
printf("MTRX Rotate %0.4lf %0.4lf 0 %0.4lf %0.4lf 0 0 0 1\n", c, -s, s, c);
printf("LOAD \"VD0:link_xy.tddd\"\nEnd EXTR\n\n");
}