| 3 |
|
Compute CIE standard sky scanner bin (cbin) |
| 4 |
|
Different azimuth origin, alignment, and winding than Tregenza/Reinhart |
| 5 |
|
|
| 6 |
+ |
RHS - right-handed system? |
| 7 |
+ |
JTR - bin jitter/mixing amount |
| 8 |
|
Dx,Dy,Dz - Incident direction (normalized, towards surface face) |
| 9 |
|
rNx,rNy,rNz - Surface normal (normalized, away from surface) |
| 10 |
|
Ux,Uy,Uz - Up direction vector (does not need to be normalized) |
| 14 |
|
Feburary 2024 G. Ward |
| 15 |
|
} |
| 16 |
|
{ Useful factors and functions } |
| 17 |
< |
DEGREE : PI/180; |
| 17 |
> |
DEGREE` : PI/180; |
| 18 |
> |
mod`(n,d) : n - floor(n/d)*d; |
| 19 |
|
Asin(x) : if(x-1, PI/2, if(-1-x, -PI/2, asin(x))) / DEGREE; |
| 20 |
< |
posangle(a) : if(-a, a + 2*PI, a) / DEGREE; |
| 18 |
< |
Atan2(y,x) : posangle(atan2(y,x)); |
| 19 |
< |
|
| 20 |
> |
Atan2(y,x) : mod( atan2(y,x)/DEGREE, 360); |
| 21 |
|
{ Set to -1 for left-handed coordinate system } |
| 22 |
|
RHS = 1; |
| 23 |
+ |
{ Sharp bin boundaries by default } |
| 24 |
+ |
JTR = 0; |
| 25 |
|
{ Default axis orientation (+Y == north) } |
| 26 |
|
rNx = 0; rNy = 0; rNz = -1; |
| 27 |
|
Ux = 0; Uy = 1; Uz = 0; |
| 36 |
|
calpha : 90/7.5; { Separation between rows in degrees } |
| 37 |
|
{ Number of patches per row } |
| 38 |
|
cnaz(r) : select(r+1, 30, 30, 24, 24, 18, 12, 6, 1); |
| 39 |
+ |
CNR : cnaz(-1); |
| 40 |
|
|
| 41 |
|
caccum(r) : if(r-.5, cnaz(r-1) + caccum(r-1), 0); |
| 42 |
+ |
{ Random perturbation for final bin # } |
| 43 |
+ |
jtr1 = JTR*(.5 - rand(1.958*Dx - 5.386*Dy - 3.772*Dz)); |
| 44 |
+ |
jtr2 = JTR*(.5 - rand(-6.334*Dx - 2.165*Dy + 7.953*Dz)); |
| 45 |
|
|
| 46 |
< |
c_row = floor(r_alt/calpha); |
| 46 |
> |
c_row = if(JTR, min(max(0,floor(r_alt/calpha + jtr1)),CNR-1), |
| 47 |
> |
floor(r_alt/calpha)); |
| 48 |
|
|
| 49 |
|
c_inc = 360/cnaz(c_row); |
| 50 |
|
|
| 51 |
+ |
c_aznf = floor( mod(c_azi+if(JTR,jtr2*c_inc,0), 360) / c_inc ); |
| 52 |
+ |
|
| 53 |
|
fwd_row = floor(c_row/2+1.25) - c_row/2 - .75; |
| 54 |
|
|
| 55 |
< |
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); |
| 55 |
> |
c_azn = if(fwd_row, c_aznf, cnaz(c_row)-1 - c_aznf); |
| 56 |
|
|
| 57 |
|
{ Final bin value, -1 for "ground" } |
| 58 |
|
cbin = if (r_alt, caccum(c_row) + c_azn, -1); |
| 59 |
|
|
| 60 |
< |
Ncbins : caccum(8); { total number of bins } |
| 60 |
> |
Ncbins : caccum(CNR); { total number of bins } |