ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/cal/cal/tregenza.cal
Revision: 1.1
Committed: Fri Jun 3 04:12:32 2005 UTC (18 years, 11 months ago) by greg
Branch: MAIN
CVS Tags: rad3R7P2, rad3R7P1, rad3R8, rad3R9
Log Message:
Created calculation of Tregenza sky discretization

File Contents

# User Rev Content
1 greg 1.1 { RCSid $Id$ }
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(azi-(360-.5*inc), 0, floor((azi+.5*inc)/inc));
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     ) );