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

Comparing ray/src/util/genklemsamp.pl (file contents):
Revision 2.4 by greg, Fri Jun 19 06:49:42 2009 UTC vs.
Revision 2.10 by greg, Sat Apr 16 00:39:07 2011 UTC

# Line 6 | Line 6
6   #       G. Ward
7   #
8   use strict;
9 + use File::Temp qw/ :mktemp  /;
10   if ($#ARGV < 0) {
11          print STDERR "Usage: genklemsamp [-c N ][-f{a|f|d}] [view opts] [geom.rad ..]\n";
12          exit 1;
13   }
14 < my $td = `mktemp -d /tmp/genklemsamp.XXXXXX`;
14 > my $td = mkdtemp("/tmp/genklemsamp.XXXXXX");
15   chomp $td;
16   my $nsamp = 1000;
17   my $fmt = "a";
# Line 63 | Line 64 | Kpol = DEGREE * (x1*Kpola(Krow) + (1-x1)*Kpola(Krow-1)
64   sin_kpol = sin(Kpol);
65   K0 = cos(Kazi)*sin_kpol;
66   K1 = sin(Kazi)*sin_kpol;
67 < K2 = cos(Kpol);
67 > K2 = sqrt(1 - sin_kpol*sin_kpol);
68   ';
69   my $ndiv = 145;
70   # Do we have any Radiance input files?
# Line 76 | Line 77 | if ($#ARGV >= 0) {
77          push @vd, $_;
78          $_ = $vwset; s/^.*Vdz://; s/;.*$//;
79          push @vd, $_;
80 <        my @bcube = split /\s+/, `getinfo -d < $td/surf.oct`;
80 >        my @bcube = split ' ', `getinfo -d < $td/surf.oct`;
81          $width = $bcube[3]*sqrt(3);
82          $height = $width;
83          push @vopts, ("-vp", $bcube[0]+$bcube[3]/2-$width/2*$vd[0],
84                          $bcube[1]+$bcube[3]/2-$width/2*$vd[1],
85                          $bcube[2]+$bcube[3]/2-$width/2*$vd[2]);
86 <        push @vopts, ("-vh", $width, "-vh", $height);
86 >        push @vopts, ("-vh", $width, "-vv", $height);
87          $vwset = `vwright @vopts V`;
88 +        $sca = sqrt($nsamp/($width*$height));
89          my $xres;
90          my $yres;
91          my $ntot = 0;
# Line 98 | Line 100 | if ($#ARGV >= 0) {
100                                  q{-e 'nOK=sq(Vdx*$5+Vdy*$6+Vdz*$7)-.999' } .
101                                  "-if7 -of > $td/origins.flt";
102                  $ntot = -s "$td/origins.flt";
103 <                $ntot /= 3*4;
103 >                $ntot /= 3*4;           # number of bytes per sample position
104                  if ($ntot == 0) {
105 <                        if ($sca < sqrt(199/($width*$height))) {
105 >                        if ($nsamp < 200) {
106                                  $sca = sqrt(200/($width*$height));
107                                  redo;
108                          }
# Line 118 | Line 120 | if ($#ARGV >= 0) {
120                          "-e 'cond=($nsamp-outno+1)/($ntot-recno+1)-rand($rn+recno)' " .
121                          "-e 'Kbin=$k;x1=rand($r1+recno);x2=rand($r2+recno)' " .
122                          q{-e '$1=$1+Vo*Vdx; $2=$2+Vo*Vdy; $3=$3+Vo*Vdz' } .
123 <                        q{-e '$4=K0*Vhx+K1*Vvx+K2*Vdx' } .
124 <                        q{-e '$5=K0*Vhy+K1*Vvy+K2*Vdy' } .
125 <                        q{-e '$6=K0*Vhz+K1*Vvz+K2*Vdz' } .
123 >                        q{-e '$4=-K0*Vhx-K1*Vvx+K2*Vdx' } .
124 >                        q{-e '$5=-K0*Vhy-K1*Vvy+K2*Vdy' } .
125 >                        q{-e '$6=-K0*Vhz-K1*Vvz+K2*Vdz' } .
126                          "-if3 $td/origins.flt";
127          }
128   } else {
# Line 142 | Line 144 | if ($#ARGV >= 0) {
144                          q{-e '$1=Vpx+Vo*Vdx+hpos*Vhx+vpos*Vvx' } .
145                          q{-e '$2=Vpy+Vo*Vdy+hpos*Vhy+vpos*Vvy' } .
146                          q{-e '$3=Vpz+Vo*Vdz+hpos*Vhz+vpos*Vvz' } .
147 <                        q{-e '$4=K0*Vhx+K1*Vvx+K2*Vdx' } .
148 <                        q{-e '$5=K0*Vhy+K1*Vvy+K2*Vdy' } .
149 <                        q{-e '$6=K0*Vhz+K1*Vvz+K2*Vdz' } ;
147 >                        q{-e '$4=-K0*Vhx-K1*Vvx+K2*Vdx' } .
148 >                        q{-e '$5=-K0*Vhy-K1*Vvy+K2*Vdy' } .
149 >                        q{-e '$6=-K0*Vhz-K1*Vvz+K2*Vdz' } ;
150          }
151   }
152   system "rm -rf $td";

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines