Ocean
Ocean::RandomT< T > Class Template Reference

This class provides several random functions for different data types using a floating point type for its elements that is specified by T. More...

Inheritance diagram for Ocean::RandomT< T >:

Static Public Member Functions

static T sign ()
 Returns a random sign (either +1 or -1). More...
 
static T sign (RandomGenerator &randomGenerator)
 Returns a random sign (either +1 or -1). More...
 
static T scalar (const T lower, const T upper)
 Returns a random number between two borders. More...
 
static T scalar (RandomGenerator &randomGenerator, const T lower, const T upper)
 Returns a random number between two borders using an explicit random generator. More...
 
static T gaussianNoise (const T sigma)
 Returns a random number with Gaussian distribution. More...
 
static T gaussianNoise (RandomGenerator &randomGenerator, const T sigma)
 Returns a random number with Gaussian distribution using an explicit random generator. More...
 
static VectorT2< T > gaussianNoiseVector2 (const T sigmaX, const T sigmaY)
 Returns a random 2D vector with Gaussian distribution. More...
 
static VectorT2< T > gaussianNoiseVector2 (RandomGenerator &randomGenerator, const T sigmaX, const T sigmaY)
 Returns a random 2D vector with Gaussian distribution using an explicit random generator. More...
 
static VectorT2< T > vector2 ()
 Returns a random 2D vector with length 1 which is equal distributed within a circle. More...
 
static VectorT2< T > vector2 (RandomGenerator &randomGenerator)
 Returns a random 2D vector with length 1 which is equal distributed within a circle using an explicit random generator. More...
 
static VectorT2< T > vector2 (const T min, const T max)
 Returns a random 2D vector with coordinates in a given range. More...
 
static VectorT2< T > vector2 (RandomGenerator &randomGenerator, const T min, const T max)
 Returns a random 2D vector with coordinates in a given range using an explicit random generator. More...
 
static VectorT2< T > vector2 (const T xMin, const T xMax, const T yMin, const T yMax)
 Returns a random 2D vector with coordinates in a given range. More...
 
static VectorT2< T > vector2 (RandomGenerator &randomGenerator, const T xMin, const T xMax, const T yMin, const T yMax)
 Returns a random 2D vector with coordinates in a given range using an explicit random generator. More...
 
static VectorT3< T > vector3 ()
 Returns a random 3D vector with length 1 which is equal distributed within a sphere. More...
 
static VectorT3< T > vector3 (RandomGenerator &randomGenerator)
 Returns a random 3D vector with length 1 which is equal distributed within a sphere using an explicit random generator. More...
 
static VectorT3< T > vector3 (const T min, const T max)
 Returns a random 3D vector with coordinates in a given range. More...
 
static VectorT3< T > vector3 (const VectorT3< T > &range)
 Returns a random 3D vector with coordinates in a given range. More...
 
static VectorT3< T > vector3 (RandomGenerator &randomGenerator, const T min, const T max)
 Returns a random 3D vector with coordinates in a given range using an explicit random generator. More...
 
static VectorT3< T > vector3 (RandomGenerator &randomGenerator, const VectorT3< T > &range)
 Returns a random 3D vector with coordinates in a given range using an explicit random generator. More...
 
static VectorT3< T > vector3 (RandomGenerator &randomGenerator, const T xMin, const T xMax, const T yMin, const T yMax, const T zMin, const T zMax)
 Returns a random 3D vector with coordinates in a given range using an explicit random generator. More...
 
static VectorT4< T > vector4 ()
 Returns a random 4D vector with length 1 which is equal distributed within a hyper sphere. More...
 
static VectorT4< T > vector4 (RandomGenerator &randomGenerator)
 Returns a random 4D vector with length 1 which is equal distributed within a hyper sphere using an explicit random generator. More...
 
static VectorT4< T > vector4 (const T min, const T max)
 Returns a random 4D vector with coordinates in a given range. More...
 
static VectorT4< T > vector4 (RandomGenerator &randomGenerator, const T min, const T max)
 Returns a random 4D vector with coordinates in a given range using an explicit random generator. More...
 
static QuaternionT< T > quaternion ()
 Returns a random rotation as unit quaternion. More...
 
static QuaternionT< T > quaternion (RandomGenerator &randomGenerator)
 Returns a random rotation as unit quaternion using an explicit random generator. More...
 
static RotationT< T > rotation ()
 Returns a random rotation. More...
 
static RotationT< T > rotation (RandomGenerator &randomGenerator)
 Returns a random rotation using an explicit random generator. More...
 
static EulerT< T > euler ()
 Returns a random euler. More...
 
static EulerT< T > euler (const T range)
 Returns a random euler with angles in a given range. More...
 
static EulerT< T > euler (const T minRange, const T maxRange)
 Returns a random euler with angles in a given range. More...
 
static EulerT< T > euler (RandomGenerator &randomGenerator)
 Returns a random euler using an explicit random generator using an explicit random generator. More...
 
static EulerT< T > euler (RandomGenerator &randomGenerator, const T range)
 Returns a random euler with angles in a given range using an explicit random generator using an explicit random generator. More...
 
static EulerT< T > euler (RandomGenerator &randomGenerator, const T minRange, const T maxRange)
 Returns a random euler with angles in a given range using an explicit random generator using an explicit random generator. More...
 
- Static Public Member Functions inherited from Ocean::RandomI
static void initialize ()
 Initializes the standard random generator for this thread with a time-based seed value. More...
 
static void initialize (const unsigned int value)
 Initializes the standard random generator for this thread with a user-defined seed value. More...
 
static uint32_t random32 ()
 Returns one random integer number with range [0x00000000, 0xFFFFFFFF]. More...
 
static uint32_t random32 (RandomGenerator &randomGenerator)
 Returns one random integer number with range [0x00000000, 0xFFFFFFFF] using an explicit random generator. More...
 
static uint64_t random64 ()
 Returns one random integer number with range [0x00000000 00000000, 0xFFFFFFFF FFFFFFFF]. More...
 
static uint64_t random64 (RandomGenerator &randomGenerator)
 Returns one random integer number with range [0x00000000 00000000, 0xFFFFFFFF FFFFFFFF] using an explicit random generator. More...
 
static unsigned int random (const unsigned int maxValue)
 Returns one random integer value with specified maximum value. More...
 
static unsigned int random (RandomGenerator &randomGenerator, const unsigned int maxValue)
 Returns one random integer value with specified maximum value using an explicit random generator. More...
 
static int random (const int lower, const int upper)
 Returns one random integer value within a specific range. More...
 
static unsigned int random (const unsigned int lower, const unsigned int upper)
 Returns one random integer value within a specific range. More...
 
static int random (RandomGenerator &randomGenerator, const int lower, const int upper)
 Returns one random integer value within a specific range using an explicit random generator. More...
 
static unsigned int random (RandomGenerator &randomGenerator, const unsigned int lower, const unsigned int upper)
 Returns one random integer value within a specific range using an explicit random generator. More...
 
static void random (const unsigned int maxValue, unsigned int &first, unsigned int &second)
 Returns two different random integer values with specified maximum value. More...
 
static void random (RandomGenerator &randomGenerator, const unsigned int maxValue, unsigned int &first, unsigned int &second)
 Returns two different random integer values with specified maximum value using an explicit random generator. More...
 
static void random (const unsigned int maxValue, unsigned int &first, unsigned int &second, unsigned int &third)
 Returns three different random integer values with specified maximum value. More...
 
static void random (RandomGenerator &randomGenerator, const unsigned int maxValue, unsigned int &first, unsigned int &second, unsigned int &third)
 Returns three different random integer values with specified maximum value using an explicit random generator. More...
 
static bool boolean ()
 Returns a random bool value. More...
 
static bool boolean (RandomGenerator &randomGenerator)
 Returns a random bool value. More...
 
template<typename T >
static T random (const std::vector< T > &elements)
 Randomly returns one element from a given vector. More...
 
template<typename T >
static T random (const std::initializer_list< T > &elements)
 Randomly returns one element from a given initializer list. More...
 
template<typename T >
static T random (RandomGenerator &randomGenerator, const std::vector< T > &elements)
 Randomly returns one element from a given vector. More...
 
template<typename T >
static T random (RandomGenerator &randomGenerator, const std::initializer_list< T > &elements)
 Randomly returns one element from a given initializer list. More...
 
static unsigned int timeBasedSeed ()
 Returns a seed value based on the current time. More...
 

Static Protected Member Functions

static constexpr T inverseMaxRand ()
 Returns the inverse of MAX_RAND. More...
 
static constexpr T inverseMaxRandomGenerator ()
 Returns the inverse of RandomGenerator::randMax(). More...
 
- Static Protected Member Functions inherited from Ocean::RandomI
static constexpr unsigned int randMax ()
 Returns the maximal random value of the default random number generator. More...
 

Detailed Description

template<typename T>
class Ocean::RandomT< T >

This class provides several random functions for different data types using a floating point type for its elements that is specified by T.

Beware: All function must not be used without a initialize() call for each thread!

Template Parameters
TData type of passed and generated values
See also
Random, RandomF, RandomD.

Member Function Documentation

◆ euler() [1/6]

template<typename T >
EulerT< T > Ocean::RandomT< T >::euler
static

Returns a random euler.

Returns
Random euler

◆ euler() [2/6]

template<typename T >
EulerT< T > Ocean::RandomT< T >::euler ( const T  minRange,
const T  maxRange 
)
static

Returns a random euler with angles in a given range.

This function allows to specified an angle range so that a minimal and maximal rotation is guaranteed.
First, three individual random angles are determined lying inside the specified range.
Second, the signs of the three angles are determined randomly (as the range is specified with positive values).

Parameters
minRangeScalar defining the minimal range for each angle axis (in negative and positive direction) in radian, with range [0, PI/2)
maxRangeScalar defining the minimal range for each angle axis (in negative and positive direction) in radian, with range [minRange, PI/2)
Returns
Random euler

◆ euler() [3/6]

template<typename T >
EulerT< T > Ocean::RandomT< T >::euler ( const T  range)
static

Returns a random euler with angles in a given range.

Parameters
rangeScalar defining the +/- range for each angle axis in radian, with range [0, PI/2)
Returns
Random euler

◆ euler() [4/6]

template<typename T >
EulerT< T > Ocean::RandomT< T >::euler ( RandomGenerator randomGenerator)
static

Returns a random euler using an explicit random generator using an explicit random generator.

Parameters
randomGeneratorThe random generator to be used
Returns
Random euler

◆ euler() [5/6]

template<typename T >
EulerT< T > Ocean::RandomT< T >::euler ( RandomGenerator randomGenerator,
const T  minRange,
const T  maxRange 
)
static

Returns a random euler with angles in a given range using an explicit random generator using an explicit random generator.

This function allows to specified an angle range so that a minimal and maximal rotation is guaranteed.
First, three individual random angles are determined lying inside the specified range.
Second, the signs of the three angles are determined randomly (as the range is specified with positive values).

Parameters
randomGeneratorThe random generator to be used
minRangeScalar defining the minimal range for each angle axis in radian, with range [0, PI/2)
maxRangeScalar defining the minimal range for each angle axis in radian, with range [minRange, PI/2)
Returns
Random euler

◆ euler() [6/6]

template<typename T >
EulerT< T > Ocean::RandomT< T >::euler ( RandomGenerator randomGenerator,
const T  range 
)
static

Returns a random euler with angles in a given range using an explicit random generator using an explicit random generator.

Parameters
randomGeneratorThe random generator to be used
rangeScalar defining the +/- range for each angle axis in radian, with range [0, PI/2)
Returns
Random euler

◆ gaussianNoise() [1/2]

template<typename T >
T Ocean::RandomT< T >::gaussianNoise ( const T  sigma)
static

Returns a random number with Gaussian distribution.

The returned value lies inside the range [-5 * sigma, 5 * sigma].

Parameters
sigmaThe sigma parameter defining the standard deviation of the Gaussian distribution, with range (0, infinity)
Returns
Gaussian distributed random value

◆ gaussianNoise() [2/2]

template<typename T >
T Ocean::RandomT< T >::gaussianNoise ( RandomGenerator randomGenerator,
const T  sigma 
)
static

Returns a random number with Gaussian distribution using an explicit random generator.

Parameters
randomGeneratorThe random generator to be used The returned value lies inside the range [-5 * sigma, 5 * sigma].
sigmaThe sigma parameter defining the standard deviation of the Gaussian distribution, with range (0, infinity)
Returns
Gaussian distributed random value

◆ gaussianNoiseVector2() [1/2]

template<typename T >
VectorT2< T > Ocean::RandomT< T >::gaussianNoiseVector2 ( const T  sigmaX,
const T  sigmaY 
)
static

Returns a random 2D vector with Gaussian distribution.

The returned value lies inside the range [-5 * sigma, 5 * sigma]x[-5 * sigma, 5 * sigma].

Parameters
sigmaXThe sigma parameter defining the standard deviation of the Gaussian distribution for the x value, with range (0, infinity)
sigmaYThe sigma parameter defining the standard deviation of the Gaussian distribution for the y value, with range (0, infinity)
Returns
Gaussian distributed random 2D vector

◆ gaussianNoiseVector2() [2/2]

template<typename T >
VectorT2< T > Ocean::RandomT< T >::gaussianNoiseVector2 ( RandomGenerator randomGenerator,
const T  sigmaX,
const T  sigmaY 
)
static

Returns a random 2D vector with Gaussian distribution using an explicit random generator.

The returned value lies inside the range [-5 * sigma, 5 * sigma]x[-5 * sigma, 5 * sigma].

Parameters
randomGeneratorThe random generator to be used
sigmaXThe sigma parameter defining the standard deviation of the Gaussian distribution for the x value, with range (0, infinity)
sigmaYThe sigma parameter defining the standard deviation of the Gaussian distribution for the y value, with range (0, infinity)
Returns
Gaussian distributed random 2D vector

◆ inverseMaxRand()

template<typename T >
constexpr T Ocean::RandomT< T >::inverseMaxRand
staticconstexprprotected

Returns the inverse of MAX_RAND.

Returns
1 / MAX_RAND

◆ inverseMaxRandomGenerator()

template<typename T >
constexpr T Ocean::RandomT< T >::inverseMaxRandomGenerator
staticconstexprprotected

Returns the inverse of RandomGenerator::randMax().

Returns
1 / RandomGenerator::randMax()

◆ quaternion() [1/2]

template<typename T >
QuaternionT< T > Ocean::RandomT< T >::quaternion
static

Returns a random rotation as unit quaternion.

Returns
Random rotation

◆ quaternion() [2/2]

template<typename T >
QuaternionT< T > Ocean::RandomT< T >::quaternion ( RandomGenerator randomGenerator)
static

Returns a random rotation as unit quaternion using an explicit random generator.

Parameters
randomGeneratorThe random generator to be used
Returns
Random rotation

◆ rotation() [1/2]

template<typename T >
RotationT< T > Ocean::RandomT< T >::rotation
static

Returns a random rotation.

Returns
Random rotation

◆ rotation() [2/2]

template<typename T >
RotationT< T > Ocean::RandomT< T >::rotation ( RandomGenerator randomGenerator)
static

Returns a random rotation using an explicit random generator.

Parameters
randomGeneratorThe random generator to be used
Returns
Random rotation

◆ scalar() [1/2]

template<typename T >
T Ocean::RandomT< T >::scalar ( const T  lower,
const T  upper 
)
static

Returns a random number between two borders.

Parameters
lowerThe lower border, with range (-infinity, infinity)
upperThe upper border, with range [lower, infinity)
Returns
Random number, with range [lower, upper]

◆ scalar() [2/2]

template<typename T >
T Ocean::RandomT< T >::scalar ( RandomGenerator randomGenerator,
const T  lower,
const T  upper 
)
static

Returns a random number between two borders using an explicit random generator.

Parameters
randomGeneratorThe random generator to be used
lowerThe lower border, with range (-infinity, infinity)
upperThe upper border, with range [lower, infinity)
Returns
Random number, with range [lower, upper]

◆ sign() [1/2]

template<typename T >
T Ocean::RandomT< T >::sign
inlinestatic

Returns a random sign (either +1 or -1).

Returns
The random sign

◆ sign() [2/2]

template<typename T >
T Ocean::RandomT< T >::sign ( RandomGenerator randomGenerator)
inlinestatic

Returns a random sign (either +1 or -1).

Parameters
randomGeneratorThe random generator to be used
Returns
The random sign

◆ vector2() [1/6]

template<typename T >
VectorT2< T > Ocean::RandomT< T >::vector2
static

Returns a random 2D vector with length 1 which is equal distributed within a circle.

Returns
The resulting random 2D vector, with vector2().length() == 1

◆ vector2() [2/6]

template<typename T >
VectorT2< T > Ocean::RandomT< T >::vector2 ( const T  min,
const T  max 
)
static

Returns a random 2D vector with coordinates in a given range.

Parameters
minMinimum coordinate value for each axis, with range (-infinity, infinity)
maxMaximum coordinate value for each axis, with range [min, infinity)
Returns
Random 2D vector with random length

◆ vector2() [3/6]

template<typename T >
VectorT2< T > Ocean::RandomT< T >::vector2 ( const T  xMin,
const T  xMax,
const T  yMin,
const T  yMax 
)
static

Returns a random 2D vector with coordinates in a given range.

Parameters
xMinMinimum x coordinate value for each axis, with range (-infinity, infinity)
xMaxMaximum x coordinate value for each axis, with range [xMin, infinity)
yMinMinimum x coordinate value for each axis, with range (-infinity, infinity)
yMaxMaximum x coordinate value for each axis, with range [yMin, infinity)
Returns
Random 2D vector with random length

◆ vector2() [4/6]

template<typename T >
VectorT2< T > Ocean::RandomT< T >::vector2 ( RandomGenerator randomGenerator)
static

Returns a random 2D vector with length 1 which is equal distributed within a circle using an explicit random generator.

Parameters
randomGeneratorThe random generator to be used
Returns
The resulting random 2D vector, with vector2().length() == 1

◆ vector2() [5/6]

template<typename T >
VectorT2< T > Ocean::RandomT< T >::vector2 ( RandomGenerator randomGenerator,
const T  min,
const T  max 
)
static

Returns a random 2D vector with coordinates in a given range using an explicit random generator.

Parameters
randomGeneratorThe random generator to be used
minMinimum coordinate value for each axis, with range (-infinity, infinity)
maxMaximum coordinate value for each axis, with range [min, infinity)
Returns
Random 2D vector with random length

◆ vector2() [6/6]

template<typename T >
VectorT2< T > Ocean::RandomT< T >::vector2 ( RandomGenerator randomGenerator,
const T  xMin,
const T  xMax,
const T  yMin,
const T  yMax 
)
static

Returns a random 2D vector with coordinates in a given range using an explicit random generator.

Parameters
randomGeneratorThe random generator to be used
xMinMinimum x coordinate value for each axis, with range (-infinity, infinity)
xMaxMaximum x coordinate value for each axis, with range [xMin, infinity)
yMinMinimum x coordinate value for each axis, with range (-infinity, infinity)
yMaxMaximum x coordinate value for each axis, with range [yMin, infinity)
Returns
Random 2D vector with random length

◆ vector3() [1/7]

template<typename T >
VectorT3< T > Ocean::RandomT< T >::vector3
static

Returns a random 3D vector with length 1 which is equal distributed within a sphere.

Returns
The resulting random 3D vector, with vector3().length() == 1

◆ vector3() [2/7]

template<typename T >
VectorT3< T > Ocean::RandomT< T >::vector3 ( const T  min,
const T  max 
)
static

Returns a random 3D vector with coordinates in a given range.

Parameters
minMinimum coordinate value for each axis, with range (-infinity, infinity)
maxMaximum coordinate value for each axis, with range [min, infinity)
Returns
Random 3D vector with random length

◆ vector3() [3/7]

template<typename T >
VectorT3< T > Ocean::RandomT< T >::vector3 ( const VectorT3< T > &  range)
static

Returns a random 3D vector with coordinates in a given range.

Parameters
range3D vector defining the +/- ranges separately for each axis, with range [0, infinity] x [0, infinity] x [0, infinity]
Returns
Random 3D vector with random length

◆ vector3() [4/7]

template<typename T >
VectorT3< T > Ocean::RandomT< T >::vector3 ( RandomGenerator randomGenerator)
static

Returns a random 3D vector with length 1 which is equal distributed within a sphere using an explicit random generator.

Parameters
randomGeneratorThe random generator to be used
Returns
The resulting random 3D vector, with vector3().length() == 1

◆ vector3() [5/7]

template<typename T >
VectorT3< T > Ocean::RandomT< T >::vector3 ( RandomGenerator randomGenerator,
const T  min,
const T  max 
)
static

Returns a random 3D vector with coordinates in a given range using an explicit random generator.

Parameters
randomGeneratorThe random generator to be used
minMinimum coordinate value for each axis, with range (-infinity, infinity)
maxMaximum coordinate value for each axis, with range [min, infinity)
Returns
Random 3D vector with random length

◆ vector3() [6/7]

template<typename T >
VectorT3< T > Ocean::RandomT< T >::vector3 ( RandomGenerator randomGenerator,
const T  xMin,
const T  xMax,
const T  yMin,
const T  yMax,
const T  zMin,
const T  zMax 
)
static

Returns a random 3D vector with coordinates in a given range using an explicit random generator.

Parameters
randomGeneratorThe random generator to be used
xMinMinimum coordinate value for x-axis, with range (-infinity, infinity)
xMaxMaximum coordinate value for x-axis, with range [xMin, infinity)
yMinMinimum coordinate value for y-axis, with range (-infinity, infinity)
yMaxMaximum coordinate value for y-axis, with range [yMin, infinity)
zMinMinimum coordinate value for z-axis, with range (-infinity, infinity)
zMaxMaximum coordinate value for z-axis, with range [zMin, infinity)
Returns
Random 3D vector with random length

◆ vector3() [7/7]

template<typename T >
VectorT3< T > Ocean::RandomT< T >::vector3 ( RandomGenerator randomGenerator,
const VectorT3< T > &  range 
)
static

Returns a random 3D vector with coordinates in a given range using an explicit random generator.

Parameters
randomGeneratorThe random generator to be used
range3D vector defining the +/- ranges separately for each axis, with range [0, infinity] x [0, infinity] x [0, infinity]
Returns
Random 3D vector with random length

◆ vector4() [1/4]

template<typename T >
VectorT4< T > Ocean::RandomT< T >::vector4
static

Returns a random 4D vector with length 1 which is equal distributed within a hyper sphere.

Returns
The resulting random 4D vector, with vector4().length() == 1

◆ vector4() [2/4]

template<typename T >
VectorT4< T > Ocean::RandomT< T >::vector4 ( const T  min,
const T  max 
)
static

Returns a random 4D vector with coordinates in a given range.

Parameters
minMinimum coordinate value for each axis, with range (-infinity, infinity)
maxMaximum coordinate value for each axis, with range [min, infinity)
Returns
Random 4D vector with random length

◆ vector4() [3/4]

template<typename T >
VectorT4< T > Ocean::RandomT< T >::vector4 ( RandomGenerator randomGenerator)
static

Returns a random 4D vector with length 1 which is equal distributed within a hyper sphere using an explicit random generator.

Parameters
randomGeneratorThe random generator to be used
Returns
The resulting random 4D vector, with vector4().length() == 1

◆ vector4() [4/4]

template<typename T >
VectorT4< T > Ocean::RandomT< T >::vector4 ( RandomGenerator randomGenerator,
const T  min,
const T  max 
)
static

Returns a random 4D vector with coordinates in a given range using an explicit random generator.

Parameters
randomGeneratorThe random generator to be used
minMinimum coordinate value for each axis, with range (-infinity, infinity)
maxMaximum coordinate value for each axis, with range [min, infinity)
Returns
Random 4D vector with random length

The documentation for this class was generated from the following file: