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

Comparing ray/src/util/genskyvec.pl (file contents):
Revision 2.10 by greg, Mon Dec 12 17:40:07 2016 UTC vs.
Revision 2.11 by greg, Tue Jun 5 01:25:11 2018 UTC

# Line 10 | Line 10 | my $windoz = ($^O eq "MSWin32" or $^O eq "MSWin64");
10   my @skycolor = (0.960, 1.004, 1.118);
11   my $mf = 4;
12   my $dosky = 1;
13 + my $dofive = 0;
14   my $headout = 1;
15   my @origARGV = @ARGV;
16   while ($#ARGV >= 0) {
# Line 21 | Line 22 | while ($#ARGV >= 0) {
22                  shift @ARGV;
23          } elsif ("$ARGV[0]" eq "-d") {
24                  $dosky = 0;
25 +        } elsif ("$ARGV[0]" eq "-5") {
26 +                $dofive = 1;
27          } elsif ("$ARGV[0]" eq "-h") {
28                  $headout = 0;
29          } else {
# Line 127 | Line 130 | if ($dosky) {
130   } else {
131          push @tregval, "0\t0\t0\n" for (1..$nbins);
132   }
133 < # Find closest 3 patches to sun and divvy up direct solar contribution
133 > # Find closest patch(es) to sun and divvy up direct solar contribution
134   sub numSort1 {
135          my @a1 = split("\t", $a);
136          my @b1 = split("\t", $b);
137          return ($a1[0] <=> $b1[0]);
138   }
139   if (@sundir) {
137        my $somega = ($sundir[3]/360)**2 * 3.141592654**3;
140          my @bestdir = `$suncmd`;
141          @bestdir = sort numSort1 @bestdir;
142 <        my (@ang, @dom, @ndx);
143 <        my $wtot = 0;
144 <        for my $i (0..2) {
145 <                ($ang[$i], $dom[$i], $ndx[$i]) = split(' ', $bestdir[$i]);
146 <                $wtot += 1./($ang[$i]+.02);
147 <        }
148 <        for my $i (0..2) {
149 <                my $wt = 1./($ang[$i]+.02)/$wtot * $somega / $dom[$i];
150 <                my @scolor = split(' ', $tregval[$ndx[$i]]);
151 <                for my $j (0..2) { $scolor[$j] += $wt * $sunval[$j]; }
152 <                $tregval[$ndx[$i]] = "$scolor[0]\t$scolor[1]\t$scolor[2]\n";
142 >        if ($dofive) {
143 >                my ($ang, $dom, $ndx);
144 >                ($ang, $dom, $ndx) = split(' ', $bestdir[0]);
145 >                $tregval[$ndx] = "$sunval[0]\t$sunval[1]\t$sunval[2]\n";
146 >        } else {
147 >                my (@ang, @dom, @ndx);
148 >                my $somega = ($sundir[3]/360)**2 * 3.141592654**3;
149 >                my $wtot = 0;
150 >                for my $i (0..2) {
151 >                        ($ang[$i], $dom[$i], $ndx[$i]) = split(' ', $bestdir[$i]);
152 >                        $wtot += 1./($ang[$i]+.02);
153 >                }
154 >                for my $i (0..2) {
155 >                        my $wt = 1./($ang[$i]+.02)/$wtot * $somega / $dom[$i];
156 >                        my @scolor = split(' ', $tregval[$ndx[$i]]);
157 >                        for my $j (0..2) { $scolor[$j] += $wt * $sunval[$j]; }
158 >                        $tregval[$ndx[$i]] = "$scolor[0]\t$scolor[1]\t$scolor[2]\n";
159 >                }
160          }
161   }
162   # Output header if requested

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines