1 |
{ RCSid $Id$ } |
2 |
{ |
3 |
Compute Reinhart sky directions from bin number |
4 |
|
5 |
Actual density controlled by MF constant |
6 |
|
7 |
Modified from genskyvec.pl |
8 |
|
9 |
Need to specify MF constant before loading (usu. power of two) |
10 |
|
11 |
Rbin is bin number from 0 (ground) to Rmax. |
12 |
|
13 |
x1, x2 may be used as random variables to subsample direction. |
14 |
|
15 |
June 2013 G. Ward |
16 |
} |
17 |
DEGREE : PI/180; |
18 |
x1 = .5; x2 = .5; |
19 |
alpha : 90/(MF*7 + .5); |
20 |
tnaz(r) : select(r, 30, 30, 24, 24, 18, 12, 6); |
21 |
rnaz(r) : if(r-(7*MF-.5), 1, MF*tnaz(floor((r+.5)/MF) + 1)); |
22 |
raccum(r) : if(r-.5, rnaz(r-1) + raccum(r-1), 0); |
23 |
RowMax : 7*MF + 1; |
24 |
Rmax : raccum(RowMax); |
25 |
Rfindrow(r, rem) : if(rem-rnaz(r)-.5, Rfindrow(r+1, rem-rnaz(r)), r); |
26 |
Rrow = if(Rbin-(Rmax-.5), RowMax-1, Rfindrow(0, Rbin)); |
27 |
Rcol = Rbin - raccum(Rrow) - 1; |
28 |
Razi_width = 2*PI / rnaz(Rrow); |
29 |
RAH : alpha*DEGREE; |
30 |
Razi = if(Rbin-.5, (Rcol + x2 - .5)*Razi_width, 2*PI*x2); |
31 |
Ralt = if(Rbin-.5, (Rrow + x1)*RAH, asin(-x1)); |
32 |
Romega = if(.5-Rbin, 2*PI, if(Rmax-.5-Rbin, |
33 |
Razi_width*(sin(RAH*(Rrow+1)) - sin(RAH*Rrow)), |
34 |
2*PI*(1 - cos(RAH/2)) ) ); |
35 |
cos_ralt = cos(Ralt); |
36 |
Dx = sin(Razi)*cos_ralt; |
37 |
Dy = cos(Razi)*cos_ralt; |
38 |
Dz = sin(Ralt); |