working of drand48()



I came across a code that calculates N uniformly distributed points on
the sphere. z is a random number between -1 and 1 and to calculate it
we use drand48 function which returns a uniformly distributed value
between 0 and 1. What I don't understand is how it actually works ?
What does he actually mean by "uniformly distributed values" ?



void SpherePoints(int n, double X[], double Y[], double Z[])
{
int i;
double x, y, z, w, t;

for( i=0; i< n; i++ ) {
z = 2.0 * drand48() - 1.0;
t = 2.0 * M_PI * drand48();
w = sqrt( 1 - z*z );
x = w * cos( t );
y = w * sin( t );
printf("i=%d: x,y,z=\t%10.5lf\t%10.5lf\t%10.5lf\n", i, x,y,z);
X[i] = x; Y[i] = y; Z[i] = z;
}
}
.



Relevant Pages

  • Re: partial derivatives of a sphere
    ... z = r sin v sin u ... Now when I take dp/dv, the tangent vector will be tilted in the -y direction ... p_u = (-r.sin v sin u, r cos v, r.sin v cos u) ... down the sphere so to speak. ...
    (sci.math)
  • partial derivatives of sphere
    ... x = r sin v cos u ... down the sphere so to speak. ... I need to do is negate dp/dv. ...
    (comp.graphics.algorithms)
  • partial derivatives of a sphere
    ... x = r sin v cos u ... down the sphere so to speak. ... I need to do is negate dp/dv. ...
    (sci.math)
  • Re: partial derivatives of sphere
    ... z = r sin v sin u ... I actually want the tangent vector to go the other way to be ... I need to do is negate dp/dv. ... A sphere can be parametrized in different ways. ...
    (comp.graphics.algorithms)
  • Re: Dead reckoning/points on a great circle
    ... Given a point on a sphere (ok, ... which lies on the desired great circle, ... -sin x cos x ... The other point will now lie on a line of longitude. ...
    (sci.math)