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.7 by greg, Sat Jan 26 00:59:08 2013 UTC vs.
Revision 2.10 by greg, Sat Apr 6 00:44:59 2013 UTC

# Line 247 | Line 247 | static const ModelCoeff DirectLumEff[8] =
247   };
248  
249   #ifndef NSUNPATCH
250 < #define NSUNPATCH       4               /* # patches to spread sun into */
250 > #define NSUNPATCH       4               /* max. # patches to spread sun into */
251   #endif
252  
253   extern int jdate(int month, int day);
# Line 260 | Line 260 | extern double  s_latitude;
260   extern double  s_longitude;
261   extern double  s_meridian;
262  
263 + int             nsuns = NSUNPATCH;      /* number of sun patches to use */
264 + double          fixed_sun_sa = -1;      /* fixed solid angle per sun? */
265 +
266   int             verbose = 0;            /* progress reports to stderr? */
267  
268   int             outfmt = 'a';           /* output format */
# Line 292 | Line 295 | int
295   main(int argc, char *argv[])
296   {
297          char    buf[256];
298 +        double  rotation = 0;           /* site rotation (degrees) */
299          double  elevation;              /* site elevation (meters) */
300          int     dir_is_horiz;           /* direct is meas. on horizontal? */
301          float   *mtx_data = NULL;       /* our matrix data */
# Line 344 | Line 348 | main(int argc, char *argv[])
348                          if (skycolor[1] <= 1e-4)
349                                  skycolor[0] = skycolor[1] = skycolor[2] = 1;
350                          break;
351 +                case 'r':                       /* rotate distribution */
352 +                        if (argv[i][2] && argv[i][2] != 'z')
353 +                                goto userr;
354 +                        rotation = atof(argv[++i]);
355 +                        break;
356 +                case '5':                       /* 5-phase calculation */
357 +                        nsuns = 1;
358 +                        fixed_sun_sa = 6.797e-05;
359 +                        break;
360                  default:
361                          goto userr;
362                  }
# Line 398 | Line 411 | main(int argc, char *argv[])
411                                  progname, s_latitude, s_longitude);
412                  fprintf(stderr, "%s: %d sky patches per time step\n",
413                                  progname, nskypatch);
414 +                if (rotation != 0)
415 +                        fprintf(stderr, "%s: rotating output %.0f degrees\n",
416 +                                        progname, rotation);
417          }
418                                          /* convert quantities to radians */
419          s_latitude = DegToRad(s_latitude);
# Line 421 | Line 437 | main(int argc, char *argv[])
437                  sda = sdec(julian_date);
438                  sta = stadj(julian_date);
439                  altitude = salt(sda, hr+sta);
440 <                azimuth = sazi(sda, hr+sta) + PI;
440 >                azimuth = sazi(sda, hr+sta) + PI - DegToRad(rotation);
441                                          /* convert measured values */
442                  if (dir_is_horiz && altitude > 0.)
443                          dir /= sin(altitude);
# Line 494 | Line 510 | main(int argc, char *argv[])
510                  fprintf(stderr, "%s: done.\n", progname);
511          exit(0);
512   userr:
513 <        fprintf(stderr, "Usage: %s [-v][-d|-s][-m N][-g r g b][-c r g b][-o{f|d}] [tape.wea]\n",
513 >        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",
514                          progname);
515          exit(1);
516   fmterr:
# Line 547 | Line 563 | ComputeSky(float *parr)
563                  sky_brightness = CalcSkyBrightness();
564                  sky_clearness =  CalcSkyClearness();
565  
566 +                /* Limit sky clearness */
567 +                if (sky_clearness > 11.9)
568 +                        sky_clearness = 11.9;
569 +
570 +                /* Limit sky brightness */
571 +                if (sky_brightness < 0.01)
572 +                        sky_brightness = 0.01;
573 +
574                  /* Calculate illuminance */
575                  index = GetCategoryIndex();
576                  diff_illum = diff_irrad * CalcDiffuseIllumRatio(index);
# Line 600 | Line 624 | AddDirect(float *parr)
624  
625          if (dir_illum <= 1e-4 || bright(suncolor) <= 1e-4)
626                  return;
627 <                                        /* identify NSUNPATCH closest patches */
628 <        for (i = NSUNPATCH; i--; )
627 >                                        /* identify nsuns closest patches */
628 >        if (nsuns > NSUNPATCH)
629 >                nsuns = NSUNPATCH;
630 >        else if (nsuns <= 0)
631 >                nsuns = 1;
632 >        for (i = nsuns; i--; )
633                  near_dprod[i] = -1.;
634          vector(svec, altitude, azimuth);
635          for (p = 1; p < nskypatch; p++) {
# Line 609 | Line 637 | AddDirect(float *parr)
637                  double  dprod;
638                  rh_vector(pvec, p);
639                  dprod = DOT(pvec, svec);
640 <                for (i = 0; i < NSUNPATCH; i++)
640 >                for (i = 0; i < nsuns; i++)
641                          if (dprod > near_dprod[i]) {
642 <                                for (j = NSUNPATCH; --j > i; ) {
642 >                                for (j = nsuns; --j > i; ) {
643                                          near_dprod[j] = near_dprod[j-1];
644                                          near_patch[j] = near_patch[j-1];
645                                  }
# Line 621 | Line 649 | AddDirect(float *parr)
649                          }
650          }
651          wtot = 0;                       /* weight by proximity */
652 <        for (i = NSUNPATCH; i--; )
652 >        for (i = nsuns; i--; )
653                  wtot += wta[i] = 1./(1.002 - near_dprod[i]);
654                                          /* add to nearest patch radiances */
655 <        for (i = NSUNPATCH; i--; ) {
655 >        for (i = nsuns; i--; ) {
656                  float   *pdest = parr + 3*near_patch[i];
657 <                float   val_add = wta[i] * dir_illum /
658 <                                (WHTEFFICACY * wtot * rh_dom[near_patch[i]]);
657 >                float   val_add = wta[i] * dir_illum / (WHTEFFICACY * wtot);
658 >
659 >                val_add /= (fixed_sun_sa > 0)   ? fixed_sun_sa
660 >                                                : rh_dom[near_patch[i]] ;
661                  *pdest++ += val_add*suncolor[0];
662                  *pdest++ += val_add*suncolor[1];
663                  *pdest++ += val_add*suncolor[2];
# Line 828 | Line 858 | int CalcSkyParamFromIllum()
858                  sky_clearness = 12.0;
859  
860          /* Limit sky brightness */
861 <        if (sky_brightness < 0.05)
861 >        if (sky_brightness < 0.01)
862                          sky_brightness = 0.01;
863  
864          while (((fabs(diff_irrad - test1) > 10.0) ||
# Line 852 | Line 882 | int CalcSkyParamFromIllum()
882                          sky_clearness = 12.0;
883          
884                  /* Limit sky brightness */
885 <                if (sky_brightness < 0.05)
885 >                if (sky_brightness < 0.01)
886                          sky_brightness = 0.01;
887          }
888  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines