1 |
{ RCSid $Id: tregenza.cal,v 1.3 2009/07/02 21:44:33 greg Exp $ } |
2 |
{ |
3 |
Compute bin numbers corresponding to Tregenza sky discretization |
4 |
|
5 |
The Tregenza sky uses 145 patches, with patch 1 pointing due |
6 |
North at the horizon, and continuing around to the East to |
7 |
patch 30, which comprises the first altitude row (alt = 6 degrees). |
8 |
Each successive row increases altitude by 12 degrees, with the |
9 |
final altitude at the zenith (90 degrees). Azimuth is evenly |
10 |
divided among 30, 30, 24, 24, 18, 12, 6, and 1 divisions per row. |
11 |
|
12 |
In addition to the bin numbers 1-145 corresponding to this |
13 |
standard, bin 0 is used for the ground plane (altitude < 0). |
14 |
|
15 |
Input is normalized ray direction (Dx,Dy,Dz). The Y-axis is |
16 |
assumed to point North, and the X-axis East, matching the |
17 |
convention set by gensky(1). |
18 |
|
19 |
Greg Ward May 2005 |
20 |
} |
21 |
DEGREE : PI/180; |
22 |
Asin(x) : if(x-1, PI/2, if(-1-x, -PI/2, asin(x))); |
23 |
posangle(a) : if(-a, a + 2*PI, a); |
24 |
Atan2(y,x) : posangle(atan2(y,x)); |
25 |
|
26 |
alt = Asin(Dz)/DEGREE; |
27 |
azi = Atan2(Dx,Dy)/DEGREE; |
28 |
|
29 |
tazi(inc) = if(359.9999-.5*inc - azi, floor((azi+.5*inc)/inc), 0); |
30 |
|
31 |
tbin = if(-alt, 0, |
32 |
select(floor(alt/12) + 1, |
33 |
1 + tazi(12), |
34 |
31 + tazi(12), |
35 |
61 + tazi(15), |
36 |
85 + tazi(15), |
37 |
109 + tazi(20), |
38 |
127 + tazi(30), |
39 |
139 + tazi(60), |
40 |
145 |
41 |
) ); |
42 |
|
43 |
Ntbins : 146; { total number of bins } |