/* Program : Coil Purpose : Create coil objects for PoV Ray v1.0 raytracer Created : 7/25/92 By : Bill Kirby CIS [70711,2407] File : Coil.c Compiler: Borland C++ v3.1 Model : Small Comments: Used to create twisted coil object made with spheres */ #include #include #include #include #ifndef PI #define PI 3.1415926535897932384626 #endif #ifndef TRUE #define TRUE 1 #define FALSE 0 #endif void show_title(void); void get_inputs(void); void write_header(char *filename, char *union_name); void write_piece(double xpos, double ypos, double zpos, double radius); void write_end(void); void err_exit(char *message); FILE *outfile; char filename[80],union_name[80],buff[256]; double x1,y1,x2,y2,z2,xpos,ypos,zpos,Rad1,rad2,radius; double angle1,angle2,k; long i,j,Ntwist,Ntube,steps; double xmax = -1e300, xmin = 1e300, ymax = -1e300, ymin = 1e300, zmax = -1e300, zmin = 1e300; main(argc,argv) int argc; char *argv[]; { show_title(); /* Get coil values from user */ get_inputs(); /* Open file for output and write header */ printf("\n\nCreating data file %s\n",filename); if ((outfile = fopen(filename,"w")) == NULL) err_exit("Opening file."); write_header(filename,union_name); /* Compute twisted coil object */ for(i=0;i %f }\n",xpos,ypos,zpos,radius); } void write_end(void) { fprintf(outfile," }\n\n"); xmax = 1.01 * (xmax + radius); xmin = 1.01 * (xmin - radius); ymax = 1.01 * (ymax + radius); ymin = 1.01 * (ymin - radius); zmax = 1.01 * (zmax + radius); zmin = 1.01 * (zmin - radius); fprintf(outfile,"bounded_by {\n"); fprintf(outfile," box { < %f %f %f > < %f %f %f> }\n",xmin,ymin,zmin,xmax,ymax,zmax); fprintf(outfile,"}\n"); fprintf(outfile," texture {\n"); fprintf(outfile," ambient 0.3\n"); fprintf(outfile," diffuse 0.7\n"); fprintf(outfile," phong 1.0\n"); fprintf(outfile," phong_size 20.0\n"); fprintf(outfile," color red 1.0 green 0.0 blue 0.0 \n"); fprintf(outfile," }\n\n"); fprintf(outfile," }\n\n"); } void err_exit(char *message) { puts("\n\nERROR! \a"); puts(message); puts("- Exiting \n"); exit(1); }