Ocean
|
This class provides several random functions for different data types using a floating point type for its elements that is specified by T. More...
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... | |
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!
T | Data type of passed and generated values |
|
static |
Returns a random euler.
|
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).
minRange | Scalar defining the minimal range for each angle axis (in negative and positive direction) in radian, with range [0, PI/2) |
maxRange | Scalar defining the minimal range for each angle axis (in negative and positive direction) in radian, with range [minRange, PI/2) |
|
static |
Returns a random euler with angles in a given range.
range | Scalar defining the +/- range for each angle axis in radian, with range [0, PI/2) |
|
static |
Returns a random euler using an explicit random generator using an explicit random generator.
randomGenerator | The random generator to be used |
|
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).
randomGenerator | The random generator to be used |
minRange | Scalar defining the minimal range for each angle axis in radian, with range [0, PI/2) |
maxRange | Scalar defining the minimal range for each angle axis in radian, with range [minRange, PI/2) |
|
static |
Returns a random euler with angles in a given range using an explicit random generator using an explicit random generator.
randomGenerator | The random generator to be used |
range | Scalar defining the +/- range for each angle axis in radian, with range [0, PI/2) |
|
static |
Returns a random number with Gaussian distribution.
The returned value lies inside the range [-5 * sigma, 5 * sigma].
sigma | The sigma parameter defining the standard deviation of the Gaussian distribution, with range (0, infinity) |
|
static |
Returns a random number with Gaussian distribution using an explicit random generator.
randomGenerator | The random generator to be used The returned value lies inside the range [-5 * sigma, 5 * sigma]. |
sigma | The sigma parameter defining the standard deviation of the Gaussian distribution, with range (0, infinity) |
|
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].
sigmaX | The sigma parameter defining the standard deviation of the Gaussian distribution for the x value, with range (0, infinity) |
sigmaY | The sigma parameter defining the standard deviation of the Gaussian distribution for the y value, with range (0, infinity) |
|
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].
randomGenerator | The random generator to be used |
sigmaX | The sigma parameter defining the standard deviation of the Gaussian distribution for the x value, with range (0, infinity) |
sigmaY | The sigma parameter defining the standard deviation of the Gaussian distribution for the y value, with range (0, infinity) |
|
staticconstexprprotected |
Returns the inverse of MAX_RAND.
|
staticconstexprprotected |
Returns the inverse of RandomGenerator::randMax().
|
static |
Returns a random rotation as unit quaternion.
|
static |
Returns a random rotation as unit quaternion using an explicit random generator.
randomGenerator | The random generator to be used |
|
static |
Returns a random rotation.
|
static |
Returns a random rotation using an explicit random generator.
randomGenerator | The random generator to be used |
|
static |
Returns a random number between two borders.
lower | The lower border, with range (-infinity, infinity) |
upper | The upper border, with range [lower, infinity) |
|
static |
Returns a random number between two borders using an explicit random generator.
randomGenerator | The random generator to be used |
lower | The lower border, with range (-infinity, infinity) |
upper | The upper border, with range [lower, infinity) |
|
inlinestatic |
Returns a random sign (either +1 or -1).
|
inlinestatic |
Returns a random sign (either +1 or -1).
randomGenerator | The random generator to be used |
|
static |
Returns a random 2D vector with length 1 which is equal distributed within a circle.
|
static |
Returns a random 2D vector with coordinates in a given range.
min | Minimum coordinate value for each axis, with range (-infinity, infinity) |
max | Maximum coordinate value for each axis, with range [min, infinity) |
|
static |
Returns a random 2D vector with coordinates in a given range.
xMin | Minimum x coordinate value for each axis, with range (-infinity, infinity) |
xMax | Maximum x coordinate value for each axis, with range [xMin, infinity) |
yMin | Minimum x coordinate value for each axis, with range (-infinity, infinity) |
yMax | Maximum x coordinate value for each axis, with range [yMin, infinity) |
|
static |
Returns a random 2D vector with length 1 which is equal distributed within a circle using an explicit random generator.
randomGenerator | The random generator to be used |
|
static |
Returns a random 2D vector with coordinates in a given range using an explicit random generator.
randomGenerator | The random generator to be used |
min | Minimum coordinate value for each axis, with range (-infinity, infinity) |
max | Maximum coordinate value for each axis, with range [min, infinity) |
|
static |
Returns a random 2D vector with coordinates in a given range using an explicit random generator.
randomGenerator | The random generator to be used |
xMin | Minimum x coordinate value for each axis, with range (-infinity, infinity) |
xMax | Maximum x coordinate value for each axis, with range [xMin, infinity) |
yMin | Minimum x coordinate value for each axis, with range (-infinity, infinity) |
yMax | Maximum x coordinate value for each axis, with range [yMin, infinity) |
|
static |
Returns a random 3D vector with length 1 which is equal distributed within a sphere.
|
static |
Returns a random 3D vector with coordinates in a given range.
min | Minimum coordinate value for each axis, with range (-infinity, infinity) |
max | Maximum coordinate value for each axis, with range [min, infinity) |
|
static |
Returns a random 3D vector with coordinates in a given range.
range | 3D vector defining the +/- ranges separately for each axis, with range [0, infinity] x [0, infinity] x [0, infinity] |
|
static |
Returns a random 3D vector with length 1 which is equal distributed within a sphere using an explicit random generator.
randomGenerator | The random generator to be used |
|
static |
Returns a random 3D vector with coordinates in a given range using an explicit random generator.
randomGenerator | The random generator to be used |
min | Minimum coordinate value for each axis, with range (-infinity, infinity) |
max | Maximum coordinate value for each axis, with range [min, infinity) |
|
static |
Returns a random 3D vector with coordinates in a given range using an explicit random generator.
randomGenerator | The random generator to be used |
xMin | Minimum coordinate value for x-axis, with range (-infinity, infinity) |
xMax | Maximum coordinate value for x-axis, with range [xMin, infinity) |
yMin | Minimum coordinate value for y-axis, with range (-infinity, infinity) |
yMax | Maximum coordinate value for y-axis, with range [yMin, infinity) |
zMin | Minimum coordinate value for z-axis, with range (-infinity, infinity) |
zMax | Maximum coordinate value for z-axis, with range [zMin, infinity) |
|
static |
Returns a random 3D vector with coordinates in a given range using an explicit random generator.
randomGenerator | The random generator to be used |
range | 3D vector defining the +/- ranges separately for each axis, with range [0, infinity] x [0, infinity] x [0, infinity] |
|
static |
Returns a random 4D vector with length 1 which is equal distributed within a hyper sphere.
|
static |
Returns a random 4D vector with coordinates in a given range.
min | Minimum coordinate value for each axis, with range (-infinity, infinity) |
max | Maximum coordinate value for each axis, with range [min, infinity) |
|
static |
Returns a random 4D vector with length 1 which is equal distributed within a hyper sphere using an explicit random generator.
randomGenerator | The random generator to be used |
|
static |
Returns a random 4D vector with coordinates in a given range using an explicit random generator.
randomGenerator | The random generator to be used |
min | Minimum coordinate value for each axis, with range (-infinity, infinity) |
max | Maximum coordinate value for each axis, with range [min, infinity) |