{ RCSid $Id: sphsamp.cal,v 1.2 2005/02/15 23:36:10 greg Exp $ } { Uniform sampling of sphere 2/15/2005 G. Ward Constant: N - total number of samples on sphere Input: i - sample number [0,N-1] Output: theta - polar angle (radians) phi - azimuthal angle (radians) Dx - X-component of direction vector Dy - Y-component of direction vector Dz - Z-component of direction vector } S : .7; { jitter amount (0-1) } k : 2*sqrt(PI/N); { k^2 is solid angle of each sample } alpha0 = asin(2/N*(i+.5) - 1); theta = alpha0 + PI/2 + k*S*(rand(.35*i+10.3) - .5); phi = sqrt(PI*N)*alpha0 + k*S*(rand(-.83*i-17.9) - .5); sint = sin(theta); Dx = cos(phi)*sint; Dy = sin(phi)*sint; Dz = cos(theta);