/******************************************************************* rotate.c -- Eric R. Weeks, started 4/4/97 v01: 4-04-97: taken from shell.c, rotate.gwk This program is public domain, although please leave my name, email, & web info attached. weeks@physics.emory.edu http://www.physics.emory.edu/~weeks/software/rotate.html *******************************************************************/ #include #include #include #define PI 3.14159265358979323846264338328 #define EE 2.71828182845904523536 #define MAX 222222 char *prgname; main(argc,argv) int argc; char **argv; { int c,numpts,t,r; double x,y,z,xx,yy,zz; double max[3],min[3],center[3]; FILE *fp; extern int optind; extern char *optarg; float data[MAX][3]; float theta,phi,eta; float ct,st,cp,sp,ce,se; int centerofmass,usebox,spacing; centerofmass = 1; /* rotate around center of mass */ usebox = 1; /* do use a box */ spacing = 40; /* number of points per box edge */ theta = 0.0; phi = 0.0; eta = 0.0; while ((c = getopt(argc, argv, "hp:t:CBs:r:")) != EOF) switch (c) { case 'h': fprintf(stderr,"Usage: %s [options] [<] [file]\n\n",argv[0]); fprintf(stderr," -h : this help message\n"); fprintf(stderr,"\nview from this angle (theta measured from z-axis):\n"); fprintf(stderr," -t # : read in theta value (degrees) [%.1f]\n",theta); fprintf(stderr," -p # : read in phi value (degrees) [%.1f]\n",phi); fprintf(stderr," -r # : third rotation angle (degrees) [%.1f]\n",eta); fprintf(stderr," -C : do NOT rotate around center of mass\n"); fprintf(stderr," -B : do NOT draw a box around data\n"); fprintf(stderr," -s # : change spacing of box points [%d]\n",spacing); exit(1); break; case 't': theta = atof(optarg); theta = theta * PI/180.0; break; case 'p': phi = atof(optarg); phi = phi * PI/180.0; break; case 'C': centerofmass = 0; break; case 'B': usebox = 0; break; case 's': spacing = atoi(optarg); break; case 'r': eta = atof(optarg); eta = eta * PI / 180.0; break; } argc -= (optind-1) ; argv += (optind-1) ; fp = (argc > 1) ? fopen(*++argv, "r") : stdin; numpts = 0; for (r=0;r<3;r++) { center[r] = 0.0; max[r] = -9e99; min[r] = 9e99; } while ((fscanf(fp,"%lf %lf %lf",&x,&y,&z)) == 3) { data[numpts][0] = x; data[numpts][1] = y; data[numpts][2] = z; for (r=0;r<3;r++) { center[r]+=data[numpts][r]; if (data[numpts][r]>max[r]) max[r] = data[numpts][r]; if (data[numpts][r]