[GLT Math]

`#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. |

class GltRandomSphere< R >

**Author:**- Nigel Stewart, RMIT (nigels.com@gmail.com)

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.

- Choose z uniformly distributed in [-1,1].
- Choose t uniformly distributed on [0, 2*pi).
- Let r = sqrt(1-z^2).
- Let x = r * cos(t).
- Let y = r * sin(t).

Definition at line 294 of file random.h.

The documentation for this class was generated from the following file:

- math/random.h

Generated on Tue Nov 5 11:11:45 2002 for GLT by 1.2.18