--- ray/src/util/findglare.c 1991/03/18 16:21:09 1.4 +++ ray/src/util/findglare.c 1991/03/19 17:21:34 1.8 @@ -19,7 +19,7 @@ static char SCCSid[] = "$SunId$ LBL"; char *rtargv[32] = {"rtrace", "-h", "-ov", "-fff"}; int rtargc = 4; -VIEW ourview; /* our view */ +VIEW ourview = STDVIEW; /* our view */ VIEW pictview = STDVIEW; /* picture view */ VIEW leftview, rightview; /* leftmost and rightmost views */ @@ -29,6 +29,8 @@ char *octree = NULL; /* octree file name */ int verbose = 0; /* verbose reporting */ char *progname; /* global argv[0] */ +double threshold = 0.; /* glare threshold */ + int sampdens = SAMPDENS; /* sample density */ ANGLE glarang[180] = {AEND}; /* glare calculation angles */ int nglarangs = 0; @@ -57,6 +59,9 @@ char *argv[]; continue; } switch (argv[i][1]) { + case 't': + threshold = atof(argv[++i]); + break; case 'r': sampdens = atoi(argv[++i])/2; break; @@ -168,7 +173,8 @@ char *argv[]; exit(1); } init(); /* initialize program */ - comp_thresh(); /* compute glare threshold */ + if (threshold <= FTINY) + comp_thresh(); /* compute glare threshold */ analyze(); /* analyze view */ cleanup(); /* tidy up */ /* print header */ @@ -205,13 +211,13 @@ init() /* initialize global variables */ } nglarangs = i; /* nglardirs = 2*nglarangs + 1; */ - /* vsize = sampdens; */ + /* vsize = sampdens - 1; */ if (nglarangs > 0) maxtheta = (PI/180.)*glarang[nglarangs-1]; else maxtheta = 0.0; hlim = sampdens*maxtheta; - hsize = sampdens + hlim; + hsize = hlim + sampdens - 1; if (hsize > (int)(PI*sampdens)) hsize = PI*sampdens; indirect = (struct illum *)calloc(nglardirs, sizeof(struct illum)); @@ -295,29 +301,10 @@ int x, y; } -spinvector(vres, vorig, vnorm, theta) /* rotate vector around normal */ -FVECT vres, vorig, vnorm; -double theta; -{ - extern double sin(), cos(); - double sint, cost, dotp; - FVECT vperp; - register int i; - - sint = sin(theta); - cost = cos(theta); - dotp = DOT(vorig, vnorm); - fcross(vperp, vnorm, vorig); - for (i = 0; i < 3; i++) - vres[i] = vnorm[i]*dotp*(1.-cost) + - vorig[i]*cost + vperp[i]*sint; -} - - memerr(s) /* malloc failure */ char *s; { - fprintf(stderr, "%s: out of memory for %s\n", s); + fprintf(stderr, "%s: out of memory for %s\n", progname, s); exit(1); }