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.8 by greg, Thu Jun 28 20:48:03 2012 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) {
17          if ("$ARGV[0]" eq "-c") {
18                  @skycolor = @ARGV[1..3];
# Line 19 | 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 {
30 +                die "Unexpected command-line argument: $ARGV[0]\n";
31          }
32          shift @ARGV;
33   }
# Line 121 | 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) {
131        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);
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 <        for my $i (0..2) {
162 <                my $wt = 1./($ang[$i]+.02)/$wtot * $somega / $dom[$i];
163 <                my @scolor = split(' ', $tregval[$ndx[$i]]);
164 <                for my $j (0..2) { $scolor[$j] += $wt * $sunval[$j]; }
165 <                $tregval[$ndx[$i]] = "$scolor[0]\t$scolor[1]\t$scolor[2]\n";
166 <        }
161 > }
162 > # Output header if requested
163 > if ($headout) {
164 >        print "#?RADIANCE\n";
165 >        print "genskyvec @origARGV\n";
166 >        print "NROWS=", $#tregval+1, "\n";
167 >        print "NCOLS=1\nNCOMP=3\n";
168 >        print "FORMAT=ascii\n";
169 >        print "\n";
170   }
171   # Output our final vector
172   print @tregval;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines