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

File Contents

# User Rev Content
1 greg 1.5 { RCSid $Id: klems_half.cal,v 1.4 2018/08/26 05:33:46 greg Exp $ }
2 greg 1.1 {
3     Compute interior bin for half Klems BSDF basis (0-72)
4     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.5 khpola(r) : select(r, 6.5, 19.5, 32.5, 45.5, 58.5, 71.5, 90);
16     khnaz(r) : select(r, 1, 8, 12, 16, 20, 12, 8);
17 greg 1.1 khaccum(r) : if(r-.5, khnaz(r) + khaccum(r-1), 0);
18     khfindrow(r, pol) : if(r-khpola(0)+.5, r,
19     if(pol-khpola(r), khfindrow(r+1, pol), r) );
20    
21     khazn(azi,inc) : if((360-.5*inc)-azi, floor((azi+.5*inc)/inc), 0);
22    
23     khbin2(pol,azi) = if(pol-90, -1,
24     select(khfindrow(1, pol),
25     khazn(azi,360/khnaz(1)),
26     khaccum(1) + khazn(azi,360/khnaz(2)),
27     khaccum(2) + khazn(azi,360/khnaz(3)),
28     khaccum(3) + khazn(azi,360/khnaz(4)),
29     khaccum(4) + khazn(azi,360/khnaz(5)),
30     khaccum(5) + khazn(azi,360/khnaz(6)),
31 greg 1.4 khaccum(6) + khazn(azi,360/khnaz(7))
32 greg 1.1 ) );
33    
34 greg 1.3 RHS = 1; { set to -1 for left-handed system }
35    
36 greg 1.1 khbin(Nx,Ny,Nz,Ux,Uy,Uz) = khbin2(Acos(-Dx*Nx-Dy*Ny-Dz*Nz),
37 greg 1.2 Atan2(-Dx*Ux-Dy*Uy-Dz*Uz + (Nx*Dx+Ny*Dy+Nz*Dz)*(Nx*Ux+Ny*Uy+Nz*Uz),
38 greg 1.3 -RHS*(Dx*(Uy*Nz-Uz*Ny) + Dy*(Uz*Nx-Ux*Nz) + Dz*(Ux*Ny-Uy*Nx))));
39 greg 1.1
40     Nkhbins : khaccum(khnaz(0)); { Number of bins for one elevation }