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

Comparing ray/src/gen/gendaymtx.c (file contents):
Revision 2.4 by greg, Sun Jan 20 01:16:15 2013 UTC vs.
Revision 2.8 by greg, Tue Feb 5 06:00:19 2013 UTC

# Line 292 | Line 292 | int
292   main(int argc, char *argv[])
293   {
294          char    buf[256];
295 +        double  rotation = 0;           /* site rotation (degrees) */
296          double  elevation;              /* site elevation (meters) */
297          int     dir_is_horiz;           /* direct is meas. on horizontal? */
298          float   *mtx_data = NULL;       /* our matrix data */
# Line 344 | Line 345 | main(int argc, char *argv[])
345                          if (skycolor[1] <= 1e-4)
346                                  skycolor[0] = skycolor[1] = skycolor[2] = 1;
347                          break;
348 +                case 'r':                       /* rotate distribution */
349 +                        if (argv[i][2] && argv[i][2] != 'z')
350 +                                goto userr;
351 +                        rotation = atof(argv[++i]);
352 +                        break;
353                  default:
354                          goto userr;
355                  }
# Line 398 | Line 404 | main(int argc, char *argv[])
404                                  progname, s_latitude, s_longitude);
405                  fprintf(stderr, "%s: %d sky patches per time step\n",
406                                  progname, nskypatch);
407 +                if (rotation != 0)
408 +                        fprintf(stderr, "%s: rotating output %.0f degrees\n",
409 +                                        progname, rotation);
410          }
411                                          /* convert quantities to radians */
412          s_latitude = DegToRad(s_latitude);
# Line 421 | Line 430 | main(int argc, char *argv[])
430                  sda = sdec(julian_date);
431                  sta = stadj(julian_date);
432                  altitude = salt(sda, hr+sta);
433 <                azimuth = sazi(sda, hr+sta) + PI;
433 >                azimuth = sazi(sda, hr+sta) + PI - DegToRad(rotation);
434                                          /* convert measured values */
435                  if (dir_is_horiz && altitude > 0.)
436                          dir /= sin(altitude);
# Line 494 | Line 503 | main(int argc, char *argv[])
503                  fprintf(stderr, "%s: done.\n", progname);
504          exit(0);
505   userr:
506 <        fprintf(stderr, "Usage: %s [-v][-d|-s][-m N][-g refl][-c r g b][-o{f|d}] [tape.wea]\n",
506 >        fprintf(stderr, "Usage: %s [-v][-d|-s][-r deg][-m N][-g r g b][-c r g b][-o{f|d}] [tape.wea]\n",
507                          progname);
508          exit(1);
509   fmterr:
# Line 515 | Line 524 | ComputeSky(float *parr)
524   {
525          int index;                      /* Category index */
526          double norm_diff_illum;         /* Normalized diffuse illuimnance */
518        double zlumin;                  /* Zenith luminance */
527          int i;
528          
529          /* Calculate atmospheric precipitable water content */
530          apwc = CalcPrecipWater(dew_point);
531  
532 <        /* Limit solar altitude to keep circumsolar off zenith */
533 <        if (altitude > DegToRad(87.0))
534 <                altitude = DegToRad(87.0);
532 >        /* Calculate sun zenith angle (don't let it dip below horizon) */
533 >        /* Also limit minimum angle to keep circumsolar off zenith */
534 >        if (altitude <= 0.0)
535 >                sun_zenith = DegToRad(90.0);
536 >        else if (altitude >= DegToRad(87.0))
537 >                sun_zenith = DegToRad(3.0);
538 >        else
539 >                sun_zenith = DegToRad(90.0) - altitude;
540  
528        /* Calculate sun zenith angle */
529        sun_zenith = DegToRad(90.0) - altitude;
530
541          /* Compute the inputs for the calculation of the sky distribution */
542          
543          if (input == 0)                                 /* XXX never used */
# Line 580 | Line 590 | ComputeSky(float *parr)
590          /* Normalization coefficient */
591          norm_diff_illum = diff_illum / norm_diff_illum;
592  
583        /* Calculate relative zenith luminance */
584        zlumin = CalcRelLuminance(sun_zenith, 0.0);
585
586        /* Calculate absolute zenith illuminance */
587        zlumin *= norm_diff_illum;
588
593          /* Apply to sky patches to get absolute radiance values */
594          for (i = 1; i < nskypatch; i++) {
595 <                scalecolor(parr+3*i, zlumin*(1./WHTEFFICACY));
595 >                scalecolor(parr+3*i, norm_diff_illum*(1./WHTEFFICACY));
596                  multcolor(parr+3*i, skycolor);
597          }
598   }
# Line 943 | Line 947 | double CalcRelHorzIllum( float *parr )
947          double rh_illum = 0.0;  /* Relative horizontal illuminance */
948  
949          for (i = 1; i < nskypatch; i++)
950 <                rh_illum += parr[3*i+1] * rh_cos(i);
950 >                rh_illum += parr[3*i+1] * rh_cos(i) * rh_dom[i];
951  
952 <        return rh_illum * (2.0 * PI / (nskypatch-1));
952 >        return rh_illum;
953   }
954  
955   /* Calculate earth orbit eccentricity correction factor */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines