|
osgEarth 2.1.1
|
Public Types | |
| enum | Method { METHOD_FAST } |
Public Member Functions | |
| Random (Method method=METHOD_FAST) | |
| Random (unsigned seed, Method method=METHOD_FAST) | |
| Random (const Random &rhs) | |
| void | reset () |
| unsigned | next (unsigned mod) |
| double | next () |
Private Attributes | |
| Method | _method |
| unsigned | _seed |
| unsigned | _next |
Psuedo random number generator. Results are guaranteed to be consistent across machines given the same seed value.
Definition at line 33 of file Random.
{
METHOD_FAST // not great, but super-fast and cheap.
};
| Random::Random | ( | Random::Method | method = METHOD_FAST | ) |
| Random::Random | ( | unsigned | seed, |
| Random::Method | method = METHOD_FAST |
||
| ) |
Constucts a new random number generator with a user-specified seed. The results are guaranteed to be globally consistent.
| seed | RNG seed value |
| method | RNG method to use |
Definition at line 48 of file Random.cpp.
| Random::Random | ( | const Random & | rhs | ) |
| unsigned Random::next | ( | unsigned | mod | ) |
Gets the next random number as an unsigned int.
| mod | Modulus value. The result will fall within the range [0..mod) |
Definition at line 70 of file Random.cpp.
{
if ( _method == METHOD_FAST )
{
fast_rand( _next );
}
return mod == UINT_MAX ? _next : _next % mod;
}
Here is the call graph for this function:
Here is the caller graph for this function:| double Random::next | ( | ) |
Gets the next random number as a double in the range [0..1].
Definition at line 80 of file Random.cpp.
{
return (double)next(UINT_MAX) / (double)UINT_MAX;
}
| void Random::reset | ( | ) |
Resets the PRNG to its initial state (initial seed).
Definition at line 64 of file Random.cpp.
Method osgEarth::Random::_method [private] |
unsigned osgEarth::Random::_next [private] |
unsigned osgEarth::Random::_seed [private] |
1.7.3