ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/cal/cal/tregenza.cal
Revision: 1.4
Committed: Tue Sep 15 00:17:36 2009 UTC (14 years, 7 months ago) by greg
Branch: MAIN
CVS Tags: rad5R4, rad5R2, rad4R2P2, rad5R0, rad5R1, rad4R2, rad4R1, rad4R0, rad4R2P1, rad5R3, HEAD
Changes since 1.3: +2 -2 lines
Log Message:
Better fix to over-range condition

File Contents

# User Rev Content
1 greg 1.4 { RCSid $Id: tregenza.cal,v 1.3 2009/07/02 21:44:33 greg Exp $ }
2 greg 1.1 {
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 greg 1.4 tazi(inc) = if(359.9999-.5*inc - azi, floor((azi+.5*inc)/inc), 0);
30 greg 1.1
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 greg 1.2
43     Ntbins : 146; { total number of bins }