All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Pages
Nimble::RandomUniform Class Reference

Random number generator with uniform distribution. More...

#include <Nimble/Random.hpp>

Public Member Functions

uint32_t rand ()
 A random number in range 0:2^32-1. More...
 
float rand01 ()
 Random numbers between 0 and 1.
 
float rand0X (float x)
 Random numbers between 0 and x.
 
double rand0X (double x)
 Random numbers between 0 and x.
 
uint32_t rand0X (uint32_t x)
 Random numbers between 0 and x-1.
 
uint64_t rand0X64 (uint64_t x)
 64-bit random numbers between 0 and x-1
 
float rand11 ()
 Random numbers between -1 and 1.
 
uint32_t rand24 ()
 A random number in range 0:2^24-1. More...
 
uint32_t rand32 ()
 A random number in range 0:2^32-1. More...
 
bool randBool ()
 Random boolean. More...
 
float randMinMax (float min, float max)
 Random numbers between min and max.
 
uint32_t randN24 (uint32_t range)
 Get random numbers between 0 and range-1. More...
 
 RandomUniform (unsigned long val=std::mt19937::default_seed)
 Constructs a new random number generator with the given seed value.
 
float randRange (float a, float b)
 Random number from range [a, b) if a < b, else [b, a)
 
Nimble::Vector2f randVec2InRect (const Nimble::Rectf &r)
 Random 2d vector inside a rectangle.
 
Nimble::Vector2f randVecInCircle (float radius=1.0f)
 Random 2d vector on or inside a circle. More...
 
Nimble::Vector3f randVecInSphere (float radius=1.0f)
 Random 3d vector inside or on a sphere. More...
 
Nimble::Vector2f randVecOnCircle (float radius=1.0f)
 Random 2d vector on a circle. More...
 
Nimble::Vector3f randVecOnSphere (float radius=1.0f)
 Random 3d vector on a sphere. More...
 
float randXX (float x)
 Random numbers between -x and x.
 

Static Public Member Functions

static RandomUniforminstance ()
 Returns a reference to an instance.
 

Detailed Description

Random number generator with uniform distribution.

This class generates random numbers with uniform distribution.

It uses STL's Mersenne Twister implementation for random number generation.

The random number sequence is identical on all platforms, given the same seed value.

Examples:
AnimatorExample.cpp, and EventsExample.cpp.

Member Function Documentation

uint32_t Nimble::RandomUniform::rand ( )
inline

A random number in range 0:2^32-1.

Returns
Generated random number
uint32_t Nimble::RandomUniform::rand24 ( )
inline

A random number in range 0:2^24-1.

Returns
Generated random number
uint32_t Nimble::RandomUniform::rand32 ( )
inline

A random number in range 0:2^32-1.

Returns
Generated random number
bool Nimble::RandomUniform::randBool ( )
inline

Random boolean.

Returns
True or false.
uint32_t Nimble::RandomUniform::randN24 ( uint32_t  range)
inline

Get random numbers between 0 and range-1.

Parameters
rangeThe maximum output value. This value must not exceed 2^24-1.
Returns
Generated random number
Nimble::Vector2f Nimble::RandomUniform::randVecInCircle ( float  radius = 1.0f)
inline

Random 2d vector on or inside a circle.

Parameters
radiusThe radius of the circle
Nimble::Vector3f Nimble::RandomUniform::randVecInSphere ( float  radius = 1.0f)
inline

Random 3d vector inside or on a sphere.

Parameters
radiusThe radius of the sphere
Nimble::Vector2f Nimble::RandomUniform::randVecOnCircle ( float  radius = 1.0f)
inline

Random 2d vector on a circle.

Parameters
radiusThe radius of the circle
Nimble::Vector3f Nimble::RandomUniform::randVecOnSphere ( float  radius = 1.0f)
inline

Random 3d vector on a sphere.

Parameters
radiusThe radius of the sphere