diff options
author | dan miller | 2007-10-19 05:20:48 +0000 |
---|---|---|
committer | dan miller | 2007-10-19 05:20:48 +0000 |
commit | d48ea5bb797037069d641da41da0f195f0124491 (patch) | |
tree | 40ff433d94859d629aac933d5ec73b382f62ba1a /libraries/ode-0.9/OPCODE/Ice/IceRandom.h | |
parent | dont ask (diff) | |
download | opensim-SC-d48ea5bb797037069d641da41da0f195f0124491.zip opensim-SC-d48ea5bb797037069d641da41da0f195f0124491.tar.gz opensim-SC-d48ea5bb797037069d641da41da0f195f0124491.tar.bz2 opensim-SC-d48ea5bb797037069d641da41da0f195f0124491.tar.xz |
one more for the gipper
Diffstat (limited to 'libraries/ode-0.9/OPCODE/Ice/IceRandom.h')
-rw-r--r-- | libraries/ode-0.9/OPCODE/Ice/IceRandom.h | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/libraries/ode-0.9/OPCODE/Ice/IceRandom.h b/libraries/ode-0.9/OPCODE/Ice/IceRandom.h new file mode 100644 index 0000000..3170b33 --- /dev/null +++ b/libraries/ode-0.9/OPCODE/Ice/IceRandom.h | |||
@@ -0,0 +1,42 @@ | |||
1 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | ||
2 | /** | ||
3 | * Contains code for random generators. | ||
4 | * \file IceRandom.h | ||
5 | * \author Pierre Terdiman | ||
6 | * \date August, 9, 2001 | ||
7 | */ | ||
8 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | ||
9 | |||
10 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | ||
11 | // Include Guard | ||
12 | #ifndef __ICERANDOM_H__ | ||
13 | #define __ICERANDOM_H__ | ||
14 | |||
15 | FUNCTION ICECORE_API void SRand(udword seed); | ||
16 | FUNCTION ICECORE_API udword Rand(); | ||
17 | |||
18 | //! Returns a unit random floating-point value | ||
19 | inline_ float UnitRandomFloat() { return float(Rand()) * ONE_OVER_RAND_MAX; } | ||
20 | |||
21 | //! Returns a random index so that 0<= index < max_index | ||
22 | ICECORE_API udword GetRandomIndex(udword max_index); | ||
23 | |||
24 | class ICECORE_API BasicRandom | ||
25 | { | ||
26 | public: | ||
27 | |||
28 | //! Constructor | ||
29 | inline_ BasicRandom(udword seed=0) : mRnd(seed) {} | ||
30 | //! Destructor | ||
31 | inline_ ~BasicRandom() {} | ||
32 | |||
33 | inline_ void SetSeed(udword seed) { mRnd = seed; } | ||
34 | inline_ udword GetCurrentValue() const { return mRnd; } | ||
35 | inline_ udword Randomize() { mRnd = mRnd * 2147001325 + 715136305; return mRnd; } | ||
36 | |||
37 | private: | ||
38 | udword mRnd; | ||
39 | }; | ||
40 | |||
41 | #endif // __ICERANDOM_H__ | ||
42 | |||