source: cpp/frams/util/rndutil.h @ 109

Last change on this file since 109 was 109, checked in by sz, 10 years ago

source reorganization (see README)
new feature added: part/joint shapes (see frams/_demos/part_shapes.cpp)

  • Property svn:eol-style set to native
File size: 891 bytes
Line 
1#ifndef _RNDUTIL_H_
2#define _RNDUTIL_H_
3
4#include <common/nonstd.h>
5#include "math.h"
6
7/** @file rndutil.h various functions */
8
9/** @param x change seed if x<=0
10    @return random value [0..x-1] if x>0 */
11unsigned short pseudornd(short x);
12
13double CustomRnd(double*);
14// the parameter is a table which describes the random distribution:
15// e.g.
16// double x[]={ 3,     // 3 intervals
17//  -10,-1,            // (each of them has always uniform distribution and equal probability of being selected)
18//  -1, 1,
19//   1,10, };
20
21class RandomGener
22{
23   public:
24      RandomGener() {isNextGauss=0;}
25      static double Uni(double begin, double end); ///< uniform excluding 'end' boundary
26      double GaussStd();
27      double Gauss(double m,double s); ///< usually will not return further than 5*stdd
28   private:
29      int isNextGauss;
30      double nextGauss;
31};
32
33extern RandomGener RndGen;
34
35#endif
Note: See TracBrowser for help on using the repository browser.