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.11 by greg, Thu Mar 21 17:11:46 1991 UTC vs.
Revision 1.14 by greg, Tue Apr 2 16:47:03 1991 UTC

# Line 12 | Line 12 | static char SCCSid[] = "$SunId$ LBL";
12  
13   #include "glare.h"
14  
15 + #include "random.h"
16 +
17   #define FEQ(a,b)        ((a)-(b)<=FTINY&&(a)-(b)<=FTINY)
18   #define VEQ(v1,v2)      (FEQ((v1)[0],(v2)[0])&&FEQ((v1)[1],(v2)[1]) \
19                                  &&FEQ((v1)[2],(v2)[2]))
# Line 40 | Line 42 | int    hlim;                           /* central limit of horizontal */
42  
43   struct illum    *indirect;              /* array of indirect illuminances */
44  
45 + long    npixinvw;                       /* number of pixels in view */
46 + long    npixmiss;                       /* number of pixels missed */
47  
48 +
49   main(argc, argv)
50   int     argc;
51   char    *argv[];
# Line 223 | Line 228 | init()                         /* initialize global variables */
228          indirect = (struct illum *)calloc(nglardirs, sizeof(struct illum));
229          if (indirect == NULL)
230                  memerr("indirect illuminances");
231 +        npixinvw = npixmiss = 0L;
232          copystruct(&leftview, &ourview);
233          copystruct(&rightview, &ourview);
234          spinvector(leftview.vdir, ourview.vdir, ourview.vup, maxtheta);
# Line 276 | Line 282 | cleanup()                              /* close files, wait for children */
282                  close_pict();
283          if (octree != NULL)
284                  done_rtrace();
285 +        if (npixinvw < 100*npixmiss)
286 +                fprintf(stderr, "%s: warning -- missing %ld%% of samples\n",
287 +                                progname, 100L*npixmiss/npixinvw);
288   }
289  
290  
# Line 283 | Line 292 | compdir(vd, x, y)                      /* compute direction for x,y */
292   FVECT   vd;
293   int     x, y;
294   {
295 +        long    t;
296          FVECT   org;                    /* dummy variable */
297  
298          if (x <= -hlim)                 /* left region */
299                  return(viewray(org, vd, &leftview,
300 <                                (x+hlim)/(2.*sampdens)+.5,
301 <                                y/(2.*sampdens)+.5));
300 >                                (double)(x+hlim)/(2*sampdens)+.5,
301 >                                (double)y/(2*sampdens)+.5));
302          if (x >= hlim)                  /* right region */
303                  return(viewray(org, vd, &rightview,
304 <                                (x-hlim)/(2.*sampdens)+.5,
305 <                                y/(2.*sampdens)+.5));
306 <                                                /* central region */
307 <        if (viewray(org, vd, &ourview, .5, y/(2.*sampdens)+.5) < 0)
304 >                                (double)(x-hlim)/(2*sampdens)+.5,
305 >                                (double)y/(2*sampdens)+.5));
306 >                                        /* central region */
307 >                                /* avoid over-counting of poles */
308 >        t = random() % vsize;
309 >        if (t*t >= (long)vsize*vsize - (long)y*y)
310                  return(-1);
311 +        if (viewray(org, vd, &ourview, .5, (double)y/(2*sampdens)+.5) < 0)
312 +                return(-1);
313          spinvector(vd, vd, ourview.vup, h_theta(x));
314          return(0);
315   }
# Line 328 | Line 342 | printillum()                   /* print out indirect illuminances */
342  
343          printf("BEGIN indirect illuminance\n");
344          for (i = 0; i < nglardirs; i++)
345 <                printf("\t%.0f\t%f\n", (180.0/PI)*indirect[i].theta,
346 <                                PI * indirect[i].sum / indirect[i].n);
345 >                if (indirect[i].n > FTINY)
346 >                        printf("\t%.0f\t%f\n", (180.0/PI)*indirect[i].theta,
347 >                                        PI * indirect[i].sum / indirect[i].n);
348          printf("END indirect illuminance\n");
349   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines