515 |
|
{ |
516 |
|
int index; /* Category index */ |
517 |
|
double norm_diff_illum; /* Normalized diffuse illuimnance */ |
518 |
– |
double zlumin; /* Zenith luminance */ |
518 |
|
int i; |
519 |
|
|
520 |
|
/* Calculate atmospheric precipitable water content */ |
521 |
|
apwc = CalcPrecipWater(dew_point); |
522 |
|
|
523 |
< |
/* Limit solar altitude to keep circumsolar off zenith */ |
524 |
< |
if (altitude > DegToRad(87.0)) |
525 |
< |
altitude = DegToRad(87.0); |
523 |
> |
/* Calculate sun zenith angle (don't let it dip below horizon) */ |
524 |
> |
/* Also limit minimum angle to keep circumsolar off zenith */ |
525 |
> |
if (altitude <= 0.0) |
526 |
> |
sun_zenith = DegToRad(90.0); |
527 |
> |
else if (altitude >= DegToRad(87.0)) |
528 |
> |
sun_zenith = DegToRad(3.0); |
529 |
> |
else |
530 |
> |
sun_zenith = DegToRad(90.0) - altitude; |
531 |
|
|
528 |
– |
/* Calculate sun zenith angle */ |
529 |
– |
sun_zenith = DegToRad(90.0) - altitude; |
530 |
– |
|
532 |
|
/* Compute the inputs for the calculation of the sky distribution */ |
533 |
|
|
534 |
|
if (input == 0) /* XXX never used */ |
581 |
|
/* Normalization coefficient */ |
582 |
|
norm_diff_illum = diff_illum / norm_diff_illum; |
583 |
|
|
583 |
– |
/* Calculate relative zenith luminance */ |
584 |
– |
zlumin = CalcRelLuminance(sun_zenith, 0.0); |
585 |
– |
|
586 |
– |
/* Calculate absolute zenith illuminance */ |
587 |
– |
zlumin *= norm_diff_illum; |
588 |
– |
|
584 |
|
/* Apply to sky patches to get absolute radiance values */ |
585 |
|
for (i = 1; i < nskypatch; i++) { |
586 |
< |
scalecolor(parr+3*i, zlumin*(1./WHTEFFICACY)); |
586 |
> |
scalecolor(parr+3*i, norm_diff_illum*(1./WHTEFFICACY)); |
587 |
|
multcolor(parr+3*i, skycolor); |
588 |
|
} |
589 |
|
} |
938 |
|
double rh_illum = 0.0; /* Relative horizontal illuminance */ |
939 |
|
|
940 |
|
for (i = 1; i < nskypatch; i++) |
941 |
< |
rh_illum += parr[3*i+1] * rh_cos(i); |
941 |
> |
rh_illum += parr[3*i+1] * rh_cos(i) * rh_dom[i]; |
942 |
|
|
943 |
< |
return rh_illum * (2.0 * PI / (nskypatch-1)); |
943 |
> |
return rh_illum; |
944 |
|
} |
945 |
|
|
946 |
|
/* Calculate earth orbit eccentricity correction factor */ |