/* chain.c - generate chain - Glenn M. Lewis - 2/18/90 */ #include #include #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"); }