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

Comparing ray/src/util/glarendx.c (file contents):
Revision 1.1 by greg, Tue Apr 16 16:40:22 1991 UTC vs.
Revision 1.4 by greg, Thu Apr 18 15:18:20 1991 UTC

# Line 7 | Line 7 | static char SCCSid[] = "$SunId$ LBL";
7   /*
8   * Compute Glare Index given by program name:
9   *
10 < *      gnuth_dgr -     Gnuth discomfort glare rating
11 < *      gnuth_vcp -     Gnuth visual comfort probability
10 > *      guth_dgr -      Guth discomfort glare rating
11 > *      guth_vcp -      Guth visual comfort probability
12   *
13   *              12 April 1991   Greg Ward       EPFL
14   */
# Line 21 | Line 21 | extern double  erfc();
21   double  posindex();
22   int     headline();
23  
24 < double  direct(), gnuth_dgr(), gnuth_vcp();
24 > double  direct(), guth_dgr(), guth_vcp();
25  
26   struct named_func {
27          char    *name;
28          double  (*func)();
29   } all_funcs[] = {
30          {"direct", direct},
31 <        {"gnuth_dgr", gnuth_dgr},
32 <        {"gnuth_vcp", gnuth_vcp},
31 >        {"guth_dgr", guth_dgr},
32 >        {"guth_vcp", guth_vcp},
33          {NULL}
34   };
35  
# Line 53 | Line 53 | int    print_header = 1;
53  
54   VIEW    midview = STDVIEW;
55  
56 + int     wrongformat = 0;
57  
58 +
59   main(argc, argv)
60   int     argc;
61   char    *argv[];
# Line 89 | Line 91 | char   *argv[];
91                          exit(1);
92                  }
93                                          /* read header */
94 <        getheader(stdin, headline);
94 >        getheader(stdin, headline, NULL);
95 >        if (wrongformat) {
96 >                fprintf(stderr, "%s: bad input format\n", progname);
97 >                exit(1);
98 >        }
99          if (print_header) {             /* add to header */
100                  printargs(i, argv, stdout);
101                  putchar('\n');
102          }
103                                          /* set view */
104          if (setview(&midview) != NULL) {
105 <                fprintf(stderr, "%s: bad view information in input\n");
105 >                fprintf(stderr, "%s: bad view information in input\n",
106 >                                progname);
107                  exit(1);
108          }
109                                          /* get findglare data */
# Line 119 | Line 126 | userr:
126   headline(s)                     /* get line from header */
127   char    *s;
128   {
129 +        char    fmt[32];
130 +
131          if (print_header)               /* copy to output */
132                  fputs(s, stdout);
133          if (!strncmp(s, VIEWSTR, VIEWSTRL))
134                  sscanview(&midview, s+VIEWSTRL);
135 +        else if (isformat(s)) {
136 +                formatval(fmt, s);
137 +                wrongformat = strcmp(fmt, "ASCII");
138 +        }
139   }
140  
141  
# Line 155 | Line 168 | read_input()                   /* read glare sources from stdin */
168                                          &gs->dir[0], &gs->dir[1], &gs->dir[2],
169                                          &gs->dom, &gs->lum) != 5)
170                                  goto readerr;
171 +                        normalize(gs->dir);
172                          gs->next = all_srcs;
173                          all_srcs = gs;
174                          break;
# Line 247 | Line 261 | FVECT  sd, vd, vu;
261  
262  
263   double
264 < gnuth_dgr(gd)           /* compute Gnuth discomfort glare rating */
264 > guth_dgr(gd)            /* compute Guth discomfort glare rating */
265   struct glare_dir        *gd;
266   {
267   #define q(w)    (20.4*w+1.52*pow(w,.2)-.075)
268          register struct glare_src       *gs;
269          double  p;
270          double  sum;
271 +        double  wtot, brsum;
272          int     n;
273  
274 <        sum = 0.0; n = 0;
274 >        sum = wtot = brsum = 0.0; n = 0;
275          for (gs = all_srcs; gs != NULL; gs = gs->next) {
276                  p = posindex(gs->dir, midview.vdir, midview.vup);
277                  if (p <= FTINY)
278                          continue;
279                  sum += gs->lum * q(gs->dom) / p;
280 +                brsum += gs->lum * gs->dom;
281 +                wtot += gs->dom;
282                  n++;
283          }
284          if (n == 0)
285                  return(0.0);
286          else
287                  return( pow(
288 <                        .5*sum/pow(direct(gd)+gd->indirect,.44),
288 >                        .5*sum/pow((brsum+(5.-wtot)*gd->indirect/PI)/5.,.44),
289                          pow((double)n, -.0914) ) );
290   #undef q
291   }
# Line 284 | Line 301 | extern double  erf(), erfc();
301  
302  
303   double
304 < gnuth_vcp(gd)           /* compute Gnuth visual comfort probability */
304 > guth_vcp(gd)            /* compute Guth visual comfort probability */
305   struct glare_dir        *gd;
306   {
307 <        return(100.*norm_integral(-6.374+1.3227*log(gnuth_dgr(gd))));
307 >        return(100.*norm_integral(6.374-1.3227*log(guth_dgr(gd))));
308   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines