Panda3D
randomizer.h
Go to the documentation of this file.
1 /**
2  * PANDA 3D SOFTWARE
3  * Copyright (c) Carnegie Mellon University. All rights reserved.
4  *
5  * All use of this software is subject to the terms of the revised BSD
6  * license. You should have received a copy of this license along
7  * with this source code in a file named "LICENSE."
8  *
9  * @file randomizer.h
10  * @author drose
11  * @date 2007-01-18
12  */
13 
14 #ifndef RANDOMIZER_H
15 #define RANDOMIZER_H
16 
17 #include "pandabase.h"
18 #include "mersenne.h"
19 
20 #include <time.h>
21 #include <math.h>
22 
23 /**
24  * A handy class to return random numbers.
25  */
26 class EXPCL_PANDA_MATHUTIL Randomizer {
27 PUBLISHED:
28  INLINE explicit Randomizer(unsigned long seed = 0);
29  INLINE Randomizer(const Randomizer &copy);
30  INLINE void operator = (const Randomizer &copy);
31 
32  INLINE int random_int(int range);
33  INLINE double random_real(double range);
34  INLINE double random_real_unit();
35 
36  INLINE static unsigned long get_next_seed();
37  INLINE unsigned long get_seed();
38 
39 private:
40  Mersenne _mersenne;
41  static Mersenne _next_seed;
42  static bool _got_first_seed;
43 };
44 
45 #include "randomizer.I"
46 
47 #endif
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
A handy class to return random numbers.
Definition: randomizer.h:26