#include <random.h>
Public Methods | |
GltRandomSphere (R &random, const double radius=1.0) | |
Constructor. | |
GltRandomSphere (const double radius=1.0) | |
Constructor using default RNG. | |
GltRandomSphere (const GltRandomSphere< R > &gen) | |
Copy constructor. | |
~GltRandomSphere () | |
Destructor. | |
Vector | rand () const |
Random point on sphere surface. | |
R & | base () |
Base random number generator. | |
const R & | base () const |
Base random number generator. |
The trig method. This method works only in 3-space, but it is very fast. It depends on the slightly counterintuitive fact that each of the three coordinates of a uniformly distributed point on S^2 is uniformly distributed on [-1,1] (but the three are not independent, obviously). Therefore, it suffices to choose one axis (Z, say) and generate a uniformly distributed value on that axis. This constrains the chosen point to lie on a circle parallel to the X-Y plane, and the obvious trig method may be used to obtain the remaining coordinates.
Definition at line 294 of file random.h.