/* Module: Circle.def * Purpose: Define the coordinates for evenly spaced points on 1/8th of * a unit circle centered at 0,0. * Note: Used to draw circles and ellipses by scaling and symmetrically * adding or subtracting on each axis (circles have 8 fold * symmetry, ellipse code used has only 4 way symmetry). * Note: Sizes must be multiples of 8 * Note: 48 is an adequate number for decent looking circles, 64 may * be desired for ellipses as the far ends get jaggy with 48. * Note: Code to generate these lists is at end of this file */ static double Circle12X[12] = { -0.00000000000000, -0.50000000000000, -0.86602540378444, -1.00000000000000, -0.86602540378444, -0.50000000000000, -0.00000000000000, 0.50000000000000, 0.86602540378444, 1.00000000000000, 0.86602540378444, 0.50000000000000 }; static double Circle12Y[12] = { -1.00000000000000, -0.86602540378444, -0.50000000000000, -0.00000000000000, 0.50000000000000, 0.86602540378444, 1.00000000000000, 0.86602540378444, 0.50000000000000, 0.00000000000000, -0.50000000000000, -0.86602540378444 }; static double Circle48X[12] = { -0.06540312923014, -0.19509032201613, -0.32143946530316, -0.44228869021900, -0.55557023301960, -0.65934581510007, -0.75183980747898, -0.83146961230255, -0.89687274153269, -0.94693012949511, -0.98078528040323, -0.99785892323860 }; static double Circle48Y[12] = { -0.99785892323860, -0.98078528040323, -0.94693012949511, -0.89687274153269, -0.83146961230255, -0.75183980747898, -0.65934581510007, -0.55557023301960, -0.44228869021900, -0.32143946530316, -0.19509032201613, -0.06540312923014 }; static double Circle64X[16] = { -0.04906767432742, -0.14673047445536, -0.24298017990326, -0.33688985339222, -0.42755509343028, -0.51410274419322, -0.59569930449243, -0.67155895484702, -0.74095112535496, -0.80320753148064, -0.85772861000027, -0.90398929312344, -0.94154406518302, -0.97003125319454, -0.98917650996478, -0.99879545620517 }; static double Circle64Y[16] = { -0.99879545620517, -0.98917650996478, -0.97003125319454, -0.94154406518302, -0.90398929312344, -0.85772861000027, -0.80320753148064, -0.74095112535496, -0.67155895484702, -0.59569930449243, -0.51410274419322, -0.42755509343028, -0.33688985339222, -0.24298017990326, -0.14673047445536, -0.04906767432742 }; #ifdef NOTNEEDED /* %% not yet needed */ static double Circle80X[20] = { -0.03925981575907, -0.11753739745784, -0.19509032201613, -0.27144044986507, -0.34611705707749, -0.41865973753743, -0.48862124149695, -0.55557023301960, -0.61909394930983, -0.67880074553294, -0.73432250943569, -0.78531693088074, -0.83146961230255, -0.87249600707280, -0.90814317382508, -0.93819133592248, -0.96245523645365, -0.98078528040323, -0.99306845695493, -0.99922903624072 }; static double Circle80Y[20] = { -0.99922903624072, -0.99306845695493, -0.98078528040323, -0.96245523645365, -0.93819133592248, -0.90814317382508, -0.87249600707280, -0.83146961230255, -0.78531693088074, -0.73432250943569, -0.67880074553294, -0.61909394930983, -0.55557023301960, -0.48862124149695, -0.41865973753743, -0.34611705707749, -0.27144044986507, -0.19509032201613, -0.11753739745784, -0.03925981575907 }; #endif #ifdef GENERATING_CODE /* Module: makecirc.c * Purpose: Define the coordinates for evenly spaced points on * a unit circle centered at 0.0 for circle.def */ #include static void init_circle(); static void disp_array(); main(argc, argv) int argc; char **argv; { double circleX[64], circleY[64]; int circle_pts, cnt; int i, j; if( argc >= 2 ) circle_pts = atoi(argv[1]); init_circle(circle_pts, circleX, circleY); if (circle_pts > 16) cnt = circle_pts / 4; else cnt = circle_pts; (void)printf("static double Circle%dX[%d] = {\n", circle_pts, cnt); disp_array(circleX, cnt); (void)printf("static double Circle%dY[%d] = {\n", circle_pts, cnt); disp_array(circleY, cnt); } /* * Subroutine: disp_array * Purpose: print out an array in four columns, and with " };" */ static void disp_array ( arr, cnt ) double *arr; int cnt; { int i, j; i=0; while( i < cnt ) { (void)printf(" %.14f", arr[i]); i++; for( j=1; (i 16) { /* SET COORDS FOR 1/8 OF A UNIT CIRCLE (MULTIPLIES GIVE ALL ELSE) */ subsample = pts / 4; inc = (2.0 * M_PI) / pts; angle = inc/2.0; } else { subsample = pts; inc = (2.0 * M_PI) / pts; angle = 0.0; } for (i=0; i <= subsample; i++) { circleX[i] = -sin (angle); circleY[i] = -cos (angle); angle += inc; } } #endif