All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Rand.hh
Go to the documentation of this file.
1 /*
2  * Copyright 2011 Nate Koenig
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16 */
17 /* Desc: Random number generator
18  * Author: Nate Koenig
19  * Date: 27 May 2009
20  */
21 
22 #ifndef RAND_HH
23 #define RAND_HH
24 
25 #include <boost/random.hpp>
26 
27 namespace gazebo
28 {
29  namespace math
30  {
31  typedef boost::mt19937 GeneratorType;
32  typedef boost::uniform_real<double> UniformRealDist;
33  typedef boost::normal_distribution<double> NormalRealDist;
34  typedef boost::uniform_int<int> UniformIntDist;
35 
36  typedef boost::variate_generator<GeneratorType&, UniformRealDist > URealGen;
37  typedef boost::variate_generator<GeneratorType&, NormalRealDist > NRealGen;
38  typedef boost::variate_generator<GeneratorType&, UniformIntDist > UIntGen;
39 
42 
44  class Rand
45  {
49  public: static double GetDblUniform(double _min = 0, double _max = 1);
50 
54  public: static double GetDblNormal(double _mean = 0, double _sigma = 1);
55 
59  public: static int GetIntUniform(int _min, int _max);
60 
64  public: static int GetIntNormal(int _mean, int _sigma);
65 
66  // The random number generator
67  private: static GeneratorType *randGenerator;
68  };
70  }
71 }
72 #endif
73