21 random_unit_vector() {
22 PN_stdfloat z, r, theta;
24 z = 1.0 - (2.0 * bounded_rand());
25 r = csqrt(1.0 - (z * z));
26 theta = 2.0 * MathNumbers::pi * bounded_rand();
28 return LVector3(r * ccos(theta), r * csin(theta), z);
This is a three-component vector distance (as opposed to a three-component point, which represents a ...