ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/util/findglare.c
(Generate patch)

Comparing ray/src/util/findglare.c (file contents):
Revision 1.2 by greg, Mon Mar 18 14:32:12 1991 UTC vs.
Revision 1.8 by greg, Tue Mar 19 17:21:34 1991 UTC

# Line 19 | Line 19 | static char SCCSid[] = "$SunId$ LBL";
19   char    *rtargv[32] = {"rtrace", "-h", "-ov", "-fff"};
20   int     rtargc = 4;
21  
22 < VIEW    ourview;                        /* our view */
22 > VIEW    ourview = STDVIEW;              /* our view */
23   VIEW    pictview = STDVIEW;             /* picture view */
24   VIEW    leftview, rightview;            /* leftmost and rightmost views */
25  
# Line 29 | Line 29 | char   *octree = NULL;                 /* octree file name */
29   int     verbose = 0;                    /* verbose reporting */
30   char    *progname;                      /* global argv[0] */
31  
32 + double  threshold = 0.;                 /* glare threshold */
33 +
34 + int     sampdens = SAMPDENS;            /* sample density */
35   ANGLE   glarang[180] = {AEND};          /* glare calculation angles */
36   int     nglarangs = 0;
37   double  maxtheta;                       /* maximum angle (in radians) */
# Line 56 | Line 59 | char   *argv[];
59                          continue;
60                  }
61                  switch (argv[i][1]) {
62 +                case 't':
63 +                        threshold = atof(argv[++i]);
64 +                        break;
65 +                case 'r':
66 +                        sampdens = atoi(argv[++i])/2;
67 +                        break;
68                  case 'v':
69                          if (argv[i][2] == '\0') {
70                                  verbose++;
# Line 164 | Line 173 | char   *argv[];
173                  exit(1);
174          }
175          init();                                 /* initialize program */
176 <        comp_thresh();                          /* compute glare threshold */
176 >        if (threshold <= FTINY)
177 >                comp_thresh();                  /* compute glare threshold */
178          analyze();                              /* analyze view */
179          cleanup();                              /* tidy up */
180                                                  /* print header */
# Line 201 | Line 211 | init()                         /* initialize global variables */
211          }
212          nglarangs = i;
213          /* nglardirs = 2*nglarangs + 1; */
214 <        /* vsize = SAMPDENS; */
214 >        /* vsize = sampdens - 1; */
215          if (nglarangs > 0)
216                  maxtheta = (PI/180.)*glarang[nglarangs-1];
217          else
218                  maxtheta = 0.0;
219 <        hlim = SAMPDENS*maxtheta;
220 <        hsize = SAMPDENS + hlim;
221 <        if (hsize > (int)(PI*SAMPDENS))
222 <                hsize = PI*SAMPDENS;
219 >        hlim = sampdens*maxtheta;
220 >        hsize = hlim + sampdens - 1;
221 >        if (hsize > (int)(PI*sampdens))
222 >                hsize = PI*sampdens;
223          indirect = (struct illum *)calloc(nglardirs, sizeof(struct illum));
224          if (indirect == NULL)
225                  memerr("indirect illuminances");
226          copystruct(&leftview, &ourview);
227          copystruct(&rightview, &ourview);
228 <        spinvector(leftview.vdir, ourview.vdir, ourview.vup, -maxtheta);
229 <        spinvector(rightview.vdir, ourview.vdir, ourview.vup, maxtheta);
228 >        spinvector(leftview.vdir, ourview.vdir, ourview.vup, maxtheta);
229 >        spinvector(rightview.vdir, ourview.vdir, ourview.vup, -maxtheta);
230          setview(&leftview);
231          setview(&rightview);
232          indirect[nglarangs].lcos =
# Line 277 | Line 287 | int    x, y;
287  
288          if (x <= -hlim)                 /* left region */
289                  return(viewray(org, vd, &leftview,
290 <                                (x+hlim)/(2.*SAMPDENS)+.5,
291 <                                y/(2.*SAMPDENS)+.5));
290 >                                (x+hlim)/(2.*sampdens)+.5,
291 >                                y/(2.*sampdens)+.5));
292          if (x >= hlim)                  /* right region */
293                  return(viewray(org, vd, &rightview,
294 <                                (x-hlim)/(2.*SAMPDENS)+.5,
295 <                                y/(2.*SAMPDENS)+.5));
294 >                                (x-hlim)/(2.*sampdens)+.5,
295 >                                y/(2.*sampdens)+.5));
296                                                  /* central region */
297 <        if (viewray(org, vd, &ourview, .5, y/(2.*SAMPDENS)+.5) < 0)
297 >        if (viewray(org, vd, &ourview, .5, y/(2.*sampdens)+.5) < 0)
298                  return(-1);
299          spinvector(vd, vd, ourview.vup, h_theta(x));
300          return(0);
301   }
302  
303  
294 spinvector(vres, vorig, vnorm, theta)   /* rotate vector around normal */
295 FVECT  vres, vorig, vnorm;
296 double  theta;
297 {
298        extern double  sin(), cos();
299        double  sint, cost, dotp;
300        FVECT  vperp;
301        register int  i;
302        
303        sint = sin(theta);
304        cost = cos(theta);
305        dotp = DOT(vorig, vnorm);
306        fcross(vperp, vnorm, vorig);
307        for (i = 0; i < 3; i++)
308                vres[i] = vnorm[i]*dotp*(1.-cost) +
309                                vorig[i]*cost + vperp[i]*sint;
310 }
311
312
304   memerr(s)                       /* malloc failure */
305   char    *s;
306   {
307 <        fprintf(stderr, "%s: out of memory for %s\n", s);
307 >        fprintf(stderr, "%s: out of memory for %s\n", progname, s);
308          exit(1);
309   }
310  
# Line 337 | Line 328 | printillum()                   /* print out indirect illuminances */
328  
329          printf("BEGIN indirect illuminance\n");
330          for (i = 0; i < nglardirs; i++)
331 <                printf("\t%f\t%f\n", (180.0/PI)*indirect[i].theta,
331 >                printf("\t%.0f\t%f\n", (180.0/PI)*indirect[i].theta,
332                                  PI * indirect[i].sum / (double)indirect[i].n);
333          printf("END indirect illuminance\n");
334   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines