ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/cal/cal/sphsamp.cal
Revision: 1.3
Committed: Tue Feb 15 23:45:14 2005 UTC (19 years, 2 months ago) by greg
Branch: MAIN
CVS Tags: rad5R4, rad5R2, rad4R2P2, rad5R0, rad5R1, rad3R7P2, rad3R7P1, rad4R2, rad4R1, rad4R0, rad3R8, rad3R9, rad4R2P1, rad5R3, HEAD
Changes since 1.2: +10 -5 lines
Log Message:
Added normalization of azimuthal angle to (0-2*PI) range

File Contents

# User Rev Content
1 greg 1.3 { RCSid $Id: sphsamp.cal,v 1.2 2005/02/15 23:36:10 greg Exp $ }
2 greg 1.1 {
3 greg 1.3 Jittered sampling of a sphere
4    
5 greg 1.2 2/15/2005 G. Ward
6 greg 1.1
7 greg 1.2 Constant:
8     N - total number of samples on sphere
9     Input:
10     i - sample number [0,N-1]
11 greg 1.1 Output:
12 greg 1.3 theta - polar angle (0-PI)
13     phi_un - azimuthal angle (unnormalized)
14     phi - azimuthal angle (0-2*PI)
15 greg 1.1 Dx - X-component of direction vector
16     Dy - Y-component of direction vector
17     Dz - Z-component of direction vector
18     }
19 greg 1.2 S : .7; { jitter amount (0-1) }
20 greg 1.1
21 greg 1.2 k : 2*sqrt(PI/N); { k^2 is solid angle of each sample }
22 greg 1.1
23 greg 1.3 mod(n,d) : n - floor(n/d)*d;
24    
25 greg 1.2 alpha0 = asin(2/N*(i+.5) - 1);
26 greg 1.1
27 greg 1.2 theta = alpha0 + PI/2 + k*S*(rand(.35*i+10.3) - .5);
28 greg 1.3 phi_un = sqrt(PI*N)*alpha0 + k*S*(rand(-.83*i-17.9) - .5);
29     phi = mod(phi_un, 2*PI);
30 greg 1.1
31 greg 1.2 sint = sin(theta);
32     Dx = cos(phi)*sint;
33     Dy = sin(phi)*sint;
34     Dz = cos(theta);