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.1 by greg, Mon Mar 18 12:15:38 1991 UTC vs.
Revision 1.7 by greg, Tue Mar 19 17:06:21 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 + int     sampdens = SAMPDENS;            /* sample density */
33   ANGLE   glarang[180] = {AEND};          /* glare calculation angles */
34   int     nglarangs = 0;
35 + double  maxtheta;                       /* maximum angle (in radians) */
36   int     hsize;                          /* horizontal size */
37   int     hlim;                           /* central limit of horizontal */
38  
# Line 55 | Line 57 | char   *argv[];
57                          continue;
58                  }
59                  switch (argv[i][1]) {
60 +                case 'r':
61 +                        sampdens = atoi(argv[++i])/2;
62 +                        break;
63                  case 'v':
64                          if (argv[i][2] == '\0') {
65                                  verbose++;
# Line 193 | Line 198 | init()                         /* initialize global variables */
198                                                  /* set direction vectors */
199          for (i = 0; glarang[i] != AEND; i++)
200                  ;
201 <        if (glarang[0] <= 0 || glarang[i-1] >= 180) {
201 >        if (i > 0 && glarang[0] <= 0 || glarang[i-1] >= 180) {
202                  fprintf(stderr, "%s: glare angles must be between 1 and 179\n",
203                                  progname);
204                  exit(1);
205          }
206          nglarangs = i;
207          /* nglardirs = 2*nglarangs + 1; */
208 <        /* maxtheta = (PI/180.)*glarang[nglarangs-1]; */
209 <        /* vsize = SAMPDENS; */
210 <        hlim = SAMPDENS*maxtheta;
211 <        hsize = SAMPDENS + hlim;
212 <        if (hsize > (int)(PI*SAMPDENS))
213 <                hsize = PI*SAMPDENS;
208 >        /* vsize = sampdens - 1; */
209 >        if (nglarangs > 0)
210 >                maxtheta = (PI/180.)*glarang[nglarangs-1];
211 >        else
212 >                maxtheta = 0.0;
213 >        hlim = sampdens*maxtheta;
214 >        hsize = hlim + sampdens - 1;
215 >        if (hsize > (int)(PI*sampdens))
216 >                hsize = PI*sampdens;
217          indirect = (struct illum *)calloc(nglardirs, sizeof(struct illum));
218          if (indirect == NULL)
219                  memerr("indirect illuminances");
220          copystruct(&leftview, &ourview);
221          copystruct(&rightview, &ourview);
222 <        spinvector(leftview.vdir, ourview.vdir, ourview.vup, -maxtheta);
223 <        spinvector(rightview.vdir, ourview.vdir, ourview.vup, maxtheta);
222 >        spinvector(leftview.vdir, ourview.vdir, ourview.vup, maxtheta);
223 >        spinvector(rightview.vdir, ourview.vdir, ourview.vup, -maxtheta);
224          setview(&leftview);
225          setview(&rightview);
226          indirect[nglarangs].lcos =
# Line 273 | Line 281 | int    x, y;
281  
282          if (x <= -hlim)                 /* left region */
283                  return(viewray(org, vd, &leftview,
284 <                                (x+hlim)/(2.*SAMPDENS)+.5,
285 <                                y/(2.*SAMPDENS)+.5));
284 >                                (x+hlim)/(2.*sampdens)+.5,
285 >                                y/(2.*sampdens)+.5));
286          if (x >= hlim)                  /* right region */
287                  return(viewray(org, vd, &rightview,
288 <                                (x-hlim)/(2.*SAMPDENS)+.5,
289 <                                y/(2.*SAMPDENS)+.5));
288 >                                (x-hlim)/(2.*sampdens)+.5,
289 >                                y/(2.*sampdens)+.5));
290                                                  /* central region */
291 <        if (viewray(org, vd, &ourview, .5, y/(2.*SAMPDENS)+.5) < 0)
291 >        if (viewray(org, vd, &ourview, .5, y/(2.*sampdens)+.5) < 0)
292                  return(-1);
293          spinvector(vd, vd, ourview.vup, h_theta(x));
294          return(0);
295   }
296  
297  
290 spinvector(vres, vorig, vnorm, theta)   /* rotate vector around normal */
291 FVECT  vres, vorig, vnorm;
292 double  theta;
293 {
294        extern double  sin(), cos();
295        double  sint, cost, dotp;
296        FVECT  vperp;
297        register int  i;
298        
299        sint = sin(theta);
300        cost = cos(theta);
301        dotp = DOT(vorig, vnorm);
302        fcross(vperp, vnorm, vorig);
303        for (i = 0; i < 3; i++)
304                vres[i] = vnorm[i]*dotp*(1.-cost) +
305                                vorig[i]*cost + vperp[i]*sint;
306 }
307
308
298   memerr(s)                       /* malloc failure */
299   char    *s;
300   {
301 <        fprintf(stderr, "%s: out of memory for %s\n", s);
301 >        fprintf(stderr, "%s: out of memory for %s\n", progname, s);
302          exit(1);
303   }
304  
# Line 333 | Line 322 | printillum()                   /* print out indirect illuminances */
322  
323          printf("BEGIN indirect illuminance\n");
324          for (i = 0; i < nglardirs; i++)
325 <                printf("\t%f\t%f\n", (180.0/PI)*indirect[i].theta,
325 >                printf("\t%.0f\t%f\n", (180.0/PI)*indirect[i].theta,
326                                  PI * indirect[i].sum / (double)indirect[i].n);
327 <        printf("END indirect illuminances\n");
327 >        printf("END indirect illuminance\n");
328   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines