#include #include int main(void){ int delta_x = 125; //half inch float sphere_radius = 3.0; //sphere radius in inches //start at largest radius and whittle down to smallest float start_radius = sphere_radius*250.0; float original_radius = start_radius; int cross_sections = start_radius/delta_x; float pi = 3.1415926535; for (int x = 0; x != cross_sections; x++){ //create hpgl files that represent a circle with a given radius //calculate local radius float local_radius = sqrt((original_radius*original_radius) - ((delta_x*(x+1))*(delta_x*(x+1)))); if(!local_radius) continue; FILE *fd = NULL; char filename[13]; sprintf(filename, "circle%d.plt",x); fd = fopen(filename, "w"); if (fd == NULL){ perror("open_port: Unable to open temp file - "); return 0; } fprintf(fd,"IN;SC0,2000,0,2000;SP1;PA;");//initialize printf("local_radius %f, ",local_radius); printf("delta_x*(x+1) %f\n", delta_x*(x+1)); fprintf(fd,"PU1000,1000;"); fprintf(fd,"CI%d;\n",(int)local_radius); fclose(fd); } return 0; }