ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/util/cieskyscan.cal
Revision: 2.1
Committed: Thu Feb 8 02:26:01 2024 UTC (3 months ago) by greg
Branch: MAIN
CVS Tags: HEAD
Log Message:
feat(rfluxmtx): Added new hemisphere samplying type, "h=cie" for CIE sky scanner subdivision

File Contents

# User Rev Content
1 greg 2.1 { RCSid $Id: reinhartb.cal,v 2.6 2015/03/27 18:58:06 greg Exp $ }
2     {
3     Compute CIE standard sky scanner bin (cbin)
4     Different azimuth origin, alignment, and winding than Tregenza/Reinhart
5    
6     Dx,Dy,Dz - Incident direction (normalized, towards surface face)
7     rNx,rNy,rNz - Surface normal (normalized, away from surface)
8     Ux,Uy,Uz - Up direction vector (does not need to be normalized)
9    
10     Modified from reinhartb.cal
11    
12     Feburary 2024 G. Ward
13     }
14     { Useful factors and functions }
15     DEGREE : PI/180;
16     Asin(x) : if(x-1, PI/2, if(-1-x, -PI/2, asin(x))) / DEGREE;
17     posangle(a) : if(-a, a + 2*PI, a) / DEGREE;
18     Atan2(y,x) : posangle(atan2(y,x));
19    
20     { Set to -1 for left-handed coordinate system }
21     RHS = 1;
22     { Default axis orientation (+Y == north) }
23     rNx = 0; rNy = 0; rNz = -1;
24     Ux = 0; Uy = 1; Uz = 0;
25     { Compute oriented axis angles }
26     inc_dz = -Dx*rNx-Dy*rNy-Dz*rNz;
27     inc_rx = -RHS*(Dx*(Uy*rNz-Uz*rNy) + Dy*(Uz*rNx-Ux*rNz) + Dz*(Ux*rNy-Uy*rNx));
28     inc_ry = Dx*Ux+Dy*Uy+Dz*Uz + inc_dz*(rNx*Ux+rNy*Uy+rNz*Uz);
29    
30     r_alt = Asin(inc_dz);
31     c_azi = Atan2(-inc_rx,-inc_ry);
32    
33     calpha : 90/7.5; { Separation between rows in degrees }
34     { Number of patches per row }
35     cnaz(r) : select(r+1, 30, 30, 24, 24, 18, 12, 6, 1);
36    
37     caccum(r) : if(r-.5, cnaz(r-1) + caccum(r-1), 0);
38    
39     c_row = floor(r_alt/calpha);
40    
41     c_inc = 360/cnaz(c_row);
42    
43     fwd_row = floor(c_row/2+1.25) - c_row/2 - .75;
44    
45     c_azn = if(359.9999 - c_azi,
46     if(fwd_row, floor(c_azi/c_inc),
47     cnaz(c_row)-1 - floor(c_azi/c_inc)),
48     0);
49    
50     { Final bin value, -1 for "ground" }
51     cbin = if (r_alt, caccum(c_row) + c_azn, -1);
52    
53     Ncbins : caccum(8); { total number of bins }