Rand.hh
00001 /* 00002 * Copyright 2011 Nate Koenig & Andrew Howard 00003 * 00004 * Licensed under the Apache License, Version 2.0 (the "License"); 00005 * you may not use this file except in compliance with the License. 00006 * You may obtain a copy of the License at 00007 * 00008 * http://www.apache.org/licenses/LICENSE-2.0 00009 * 00010 * Unless required by applicable law or agreed to in writing, software 00011 * distributed under the License is distributed on an "AS IS" BASIS, 00012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00013 * See the License for the specific language governing permissions and 00014 * limitations under the License. 00015 * 00016 */ 00017 /* Desc: Random number generator 00018 * Author: Nate Koenig 00019 * Date: 27 May 2009 00020 * SVN: $Id:$ 00021 */ 00022 00023 #ifndef RAND_HH 00024 #define RAND_HH 00025 00026 #include <boost/random.hpp> 00027 00028 namespace gazebo 00029 { 00030 namespace math 00031 { 00032 00033 typedef boost::mt19937 GeneratorType; 00034 typedef boost::uniform_real<double> UniformRealDist; 00035 typedef boost::normal_distribution<double> NormalRealDist; 00036 typedef boost::uniform_int<int> UniformIntDist; 00037 00038 typedef boost::variate_generator<GeneratorType&, UniformRealDist > URealGen; 00039 typedef boost::variate_generator<GeneratorType&, NormalRealDist > NRealGen; 00040 typedef boost::variate_generator<GeneratorType&, UniformIntDist > UIntGen; 00041 00044 00046 class Rand 00047 { 00049 private: Rand(); 00050 00052 private: virtual ~Rand(); 00053 00057 public: static double GetDblUniform(double min=0, double max=1); 00058 00062 public: static double GetDblNormal(double mean=0, double sigma=1); 00063 00067 public: static int GetIntUniform(int min, int max); 00068 00072 public: static int GetIntNormal(int mean, int sigma); 00073 00074 // The random number generator 00075 private: static GeneratorType *randGenerator; 00076 }; 00078 00079 } 00080 00081 } 00082 #endif

1.7.5.1