ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/cal/cal/sphsamp.cal
(Generate patch)

Comparing ray/src/cal/cal/sphsamp.cal (file contents):
Revision 1.1 by greg, Sat Feb 22 02:07:21 2003 UTC vs.
Revision 1.2 by greg, Tue Feb 15 23:36:10 2005 UTC

# Line 1 | Line 1
1 + { RCSid $Id$ }
2   {
3          Uniform sampling of sphere
4 +        2/15/2005       G. Ward
5  
6 <        Define:
7 <                N       - total number of samples
8 <                i       - sample number
9 <
6 >        Constant:
7 >                N -             total number of samples on sphere
8 >        Input:
9 >                i -             sample number [0,N-1]
10          Output:
11 <                theta   - polar angle (degrees)
12 <                phi     - azimuthal angle (degrees)
11 >                theta   - polar angle (radians)
12 >                phi     - azimuthal angle (radians)
13                  Dx      - X-component of direction vector
14                  Dy      - Y-component of direction vector
15                  Dz      - Z-component of direction vector
16   }
17 + S : .7;                 { jitter amount (0-1) }
18  
19 < DEGREE : PI/180;
17 < bound(a,x,b) : if(a-x, a, if(x-b, b, x));
18 < Acos(x) : acos(bound(-1,x,1));
19 < Sqrt(x) : if(x, sqrt(x), 0);
19 > k : 2*sqrt(PI/N);       { k^2 is solid angle of each sample }
20  
21 < nalt = floor(sqrt(2/PI*N) + .5);
22 < nazi = floor(PI/2*nalt + .5);
21 > alpha0 = asin(2/N*(i+.5) - 1);
22  
23 < cond = nalt*nazi-.9999 - i;
23 > theta = alpha0 + PI/2 + k*S*(rand(.35*i+10.3) - .5);
24 > phi = sqrt(PI*N)*alpha0 + k*S*(rand(-.83*i-17.9) - .5);
25  
26 < ialt = floor(i/nazi);
27 < iazi = i - ialt*nazi;
28 <
29 < ralt = (ialt + rand(i*.328+.112))/nalt;
30 < razi = (iazi + rand(i*-.731+.318))/nazi;
31 <
32 < rtheta = Acos(Dz);
33 < rphi = 2*PI*razi;
34 < Dxy = Sqrt(1 - Dz*Dz);
35 < theta = rtheta/DEGREE;
36 < phi = rphi/DEGREE;
37 < Dx = Dxy*cos(rphi);
38 < Dy = Dxy*sin(rphi);
39 < Dz = 1 - 2*ralt;
26 > sint = sin(theta);
27 > Dx = cos(phi)*sint;
28 > Dy = sin(phi)*sint;
29 > Dz = cos(theta);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines