NGL
6.5
The NCCA Graphics Library
|
wrapper for std random and distribution functions, it will generate two basic random functions for RandPositiveFloat (0-1) and RandFloat() +/- 1 these are also overloaded to have a param for range added to this are functions for Random Colours and Vectors and Points and also the ability to add other distributions random library. More...
#include <Random.h>
Public Member Functions | |
void | setSeed () |
set the seed using std::time(NULL) More... | |
void | setSeed (unsigned int _value) |
set the seed using a param value More... | |
Real | getFloatFromGeneratorName (const std::string &_name) |
gets a pre-generated Real value for a genetator More... | |
Colour | getRandomColour () |
return a random colour with rgb components clamped between 0-1 More... | |
Colour | getRandomColourAndAlpha () |
return a random colour with rgba components clamped between 0-1 More... | |
Vec4 | getRandomVec4 () |
get a random vector with componets ranged from +/- 1 More... | |
Vec4 | getRandomNormalizedVec4 () |
get a random vector with componets ranged from +/- 1 and Normalized More... | |
Vec3 | getRandomVec3 () |
get a random vector with componets ranged from +/- 1 More... | |
Vec3 | getRandomNormalizedVec3 () |
get a random vector with componets ranged from +/- 1 and Normalized More... | |
Vec2 | getRandomVec2 () |
get a random vector with componets ranged from +/- 1 More... | |
Vec2 | getRandomNormalizedVec2 () |
get a random vector with componets ranged from +/- 1 and Normalized More... | |
Vec3 | getRandomPoint (Real _xRange=1.0, Real _yRange=1.0, Real _zRange=1.0) |
get a random point in 3D space defaults to +/- 1 else user defined range More... | |
Real | randomNumber (Real _mult=1) |
a replacement for the old RandomNumber func this is basically a convinience function More... | |
Real | randomPositiveNumber (Real _mult=1) |
a replacement for the old ReandomPosNum this is basically a convinience function More... | |
Public Member Functions inherited from ngl::Singleton< Random > | |
Singleton (const Singleton &)=delete | |
Singleton & | operator= (const Singleton &)=delete |
Protected Member Functions | |
Random () | |
ctor hidden in protected as we are a singleton class More... | |
Protected Member Functions inherited from ngl::Singleton< Random > | |
Singleton () | |
Constructor. More... | |
virtual | ~Singleton () |
Destructor. More... | |
Protected Attributes | |
std::mt19937 | m_generator |
the generator for rng class where all funcs and distribs are added. all we need to do is replace this one define to use any of the other boost rng engines. More... | |
std::unordered_map< std::string, std::uniform_real_distribution< Real > > | m_floatGenerators |
our map to hold the generator data basically we are going to hold a name / function pair, and this function will be called returning a Real value More... | |
Friends | |
class | Singleton< Random > |
we are a friend with singelton so we can assess the template methods More... | |
class | Colour |
class | Vec4 |
Additional Inherited Members | |
Static Public Member Functions inherited from ngl::Singleton< Random > | |
static Random * | instance () |
Get the instance. More... | |
Static Protected Member Functions inherited from ngl::Singleton< Random > | |
static void | killSingleton () |
Static Protected Attributes inherited from ngl::Singleton< Random > | |
static Random * | s_instance |
unique instance of the singleton More... | |
wrapper for std random and distribution functions, it will generate two basic random functions for RandPositiveFloat (0-1) and RandFloat() +/- 1 these are also overloaded to have a param for range added to this are functions for Random Colours and Vectors and Points and also the ability to add other distributions random library.
|
protected |
ctor hidden in protected as we are a singleton class
Definition at line 46 of file Random.cpp.
References m_floatGenerators, ngl::RandomFloat, and ngl::RandomPositiveFloat.
Real ngl::Random::getFloatFromGeneratorName | ( | const std::string & | _name | ) |
gets a pre-generated Real value for a genetator
_name | the name of the generator to use for the number returns a random number created by the generator or 0 if the generator is not found |
Definition at line 60 of file Random.cpp.
References m_floatGenerators, and m_generator.
Colour ngl::Random::getRandomColour | ( | ) |
return a random colour with rgb components clamped between 0-1
Definition at line 80 of file Random.cpp.
References Colour, m_floatGenerators, m_generator, and ngl::RandomPositiveFloat.
Colour ngl::Random::getRandomColourAndAlpha | ( | ) |
return a random colour with rgba components clamped between 0-1
Definition at line 88 of file Random.cpp.
References Colour, m_floatGenerators, m_generator, and ngl::RandomPositiveFloat.
Vec2 ngl::Random::getRandomNormalizedVec2 | ( | ) |
get a random vector with componets ranged from +/- 1 and Normalized
Definition at line 137 of file Random.cpp.
References m_floatGenerators, m_generator, ngl::Vec2::normalize(), and ngl::RandomFloat.
Vec3 ngl::Random::getRandomNormalizedVec3 | ( | ) |
get a random vector with componets ranged from +/- 1 and Normalized
Definition at line 121 of file Random.cpp.
References m_floatGenerators, m_generator, ngl::Vec3::normalize(), and ngl::RandomFloat.
Vec4 ngl::Random::getRandomNormalizedVec4 | ( | ) |
get a random vector with componets ranged from +/- 1 and Normalized
Definition at line 104 of file Random.cpp.
References m_floatGenerators, m_generator, ngl::Vec4::normalize(), and ngl::RandomFloat.
get a random point in 3D space defaults to +/- 1 else user defined range
_xRange | the +/-x range |
_yRange | the +/-y range |
_zRange | the +/-z range |
Definition at line 148 of file Random.cpp.
References m_floatGenerators, m_generator, and ngl::RandomFloat.
Vec2 ngl::Random::getRandomVec2 | ( | ) |
get a random vector with componets ranged from +/- 1
Definition at line 130 of file Random.cpp.
References m_floatGenerators, m_generator, and ngl::RandomFloat.
Vec3 ngl::Random::getRandomVec3 | ( | ) |
get a random vector with componets ranged from +/- 1
Definition at line 114 of file Random.cpp.
References m_floatGenerators, m_generator, and ngl::RandomFloat.
Vec4 ngl::Random::getRandomVec4 | ( | ) |
get a random vector with componets ranged from +/- 1
Definition at line 97 of file Random.cpp.
References m_floatGenerators, m_generator, ngl::RandomFloat, and Vec4.
a replacement for the old RandomNumber func this is basically a convinience function
_mult | an optional multiplyer for the output |
Definition at line 157 of file Random.cpp.
References m_floatGenerators, m_generator, and ngl::RandomFloat.
a replacement for the old ReandomPosNum this is basically a convinience function
_mult | an optional multiplyer for the output |
Definition at line 164 of file Random.cpp.
References m_floatGenerators, m_generator, and ngl::RandomPositiveFloat.
void ngl::Random::setSeed | ( | ) |
set the seed using std::time(NULL)
Definition at line 32 of file Random.cpp.
References m_generator.
set the seed using a param value
_value | the seed value |
Definition at line 39 of file Random.cpp.
References m_generator.
|
protected |
|
protected |