vrecko
virtual reality framework
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
randomizer.h
Go to the documentation of this file.
1
#ifndef RANDOMIZER_H_
2
#define RANDOMIZER_H_
3
4
#include <vector>
5
#include <cstdlib>
6
#include <ctime>
7
#include "
configuration.h
"
8
9
using namespace
boost::program_options;
10
11
namespace
AP_LSystem {
15
class
Randomizer
16
{
17
public
:
21
static
void
init
()
22
{
23
const
variable_value * seed = Configuration::get()->getProperty(
"RandomSeed"
);
24
if
( seed )
25
{
26
srand( seed->as<
unsigned
int
>() );
27
}
28
else
29
{
30
srand( time( NULL ) );
31
}
32
}
33
39
static
double
get
(
unsigned
int
maxPercents )
40
{
41
return
1 + (((rand()%2)?(-1):(1)) * (
static_cast<
double
>
(rand() % (maxPercents*10)) / 1000.0f));
42
}
43
50
static
double
get
(
const
double
* max )
51
{
52
return
get
(
static_cast<
unsigned
>
(abs(*max)) );
53
}
54
};
55
}
56
57
#endif
include
vreckoAP
Garden
randomizer.h
Generated on Tue Feb 19 2013 10:23:44 for vrecko by
1.8.3.1