ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/util/klems_quarter.cal
Revision: 1.6
Committed: Thu Jul 14 02:52:02 2022 UTC (21 months, 1 week ago) by greg
Branch: MAIN
CVS Tags: rad5R4, HEAD
Changes since 1.5: +2 -2 lines
Log Message:
fix: updated and corrected Klems half and quarter bases to match WINDOW

File Contents

# User Rev Content
1 greg 1.6 { RCSid $Id: klems_quarter.cal,v 1.5 2015/03/27 18:58:06 greg Exp $ }
2 greg 1.1 {
3 greg 1.2 Compute interior bin for quarter Klems BSDF basis (0-40)
4 greg 1.1 Returns -1 for wrong-side rays
5    
6     Modified from klems_full.cal
7    
8     7/18/2014 G. Ward
9     }
10     DEGREE : PI/180;
11     Acos(x) : if(x-1, 0, if(-1-x, PI, acos(x))) / DEGREE;
12     posangle(a) : if(-a, a + 2*PI, a) / DEGREE;
13     Atan2(y,x) : posangle(atan2(y,x));
14    
15 greg 1.6 kqpola(r) : select(r, 9, 27, 45, 63, 90);
16 greg 1.3 kqnaz(r) : select(r, 1, 8, 12, 12, 8);
17 greg 1.1 kqaccum(r) : if(r-.5, kqnaz(r) + kqaccum(r-1), 0);
18     kqfindrow(r, pol) : if(r-kqpola(0)+.5, r,
19     if(pol-kqpola(r), kqfindrow(r+1, pol), r) );
20    
21     kqazn(azi,inc) : if((360-.5*inc)-azi, floor((azi+.5*inc)/inc), 0);
22    
23     kqbin2(pol,azi) = if(pol-90, -1,
24     select(kqfindrow(1, pol),
25     kqazn(azi,360/kqnaz(1)),
26     kqaccum(1) + kqazn(azi,360/kqnaz(2)),
27     kqaccum(2) + kqazn(azi,360/kqnaz(3)),
28     kqaccum(3) + kqazn(azi,360/kqnaz(4)),
29     kqaccum(4) + kqazn(azi,360/kqnaz(5))
30     ) );
31    
32 greg 1.5 RHS = 1; { set to -1 for left-handed system }
33    
34 greg 1.1 kqbin(Nx,Ny,Nz,Ux,Uy,Uz) = kqbin2(Acos(-Dx*Nx-Dy*Ny-Dz*Nz),
35 greg 1.4 Atan2(-Dx*Ux-Dy*Uy-Dz*Uz + (Nx*Dx+Ny*Dy+Nz*Dz)*(Nx*Ux+Ny*Uy+Nz*Uz),
36 greg 1.5 -RHS*(Dx*(Uy*Nz-Uz*Ny) + Dy*(Uz*Nx-Ux*Nz) + Dz*(Ux*Ny-Uy*Nx))));
37 greg 1.1
38     Nkqbins : kqaccum(kqnaz(0)); { Number of bins for one elevation }