Actin®  Version 5.2.0
Software for Robotics Simulation and Control
EcRandom Class Reference

A utility class to generate random numbers. More...

#include <ecRandom.h>

Static Public Member Functions

static EcRandomNumberGeneratorTyperandomNumberGenerator ()
 get the thread-local random number generator. Must be used with boost::thread, not with other third-library threads, to ensure thread safety
 
static void seed (EcU32 seedNumber=0)
 seed the thread-local random number generator.
 
static EcInt32 uniformIntRandom (EcInt32 lowerBound=0, EcInt32 upperBound=99)
 Convenience method to generate a uniformly-distributed random integer numbers between the lowerBound and upperBound, inclusive. Should not be called in a loop since there's overhead. Use uniformIntRandoms instead. More...
 
static EcInt32Vector uniformIntRandoms (EcInt32 lowerBound, EcInt32 upperBound, EcU32 count)
 Convenience method to generate a number of uniformly-distributed random integers between the lowerBound and upperBound, inclusive. More...
 
static EcReal uniformRealRandom (EcReal lowerBound=0.0, EcReal upperBound=1.0)
 Convenience method to generate a uniformly-distributed random real numbers between the lowerBound inclusive and upperBound exclusive. Should not be called in a loop since there's overhead. Use uniformRealRandoms instead. More...
 
static EcRealVector uniformRealRandoms (EcReal lowerBound, EcReal upperBound, EcU32 count)
 Convenience method to generate a number of uniformly-distributed random reals between the lowerBound inclusive and upperBound exclusive. More...
 
static EcReal normalRandom (EcReal mean=0.0, EcReal sigma=1.0)
 Convenience method to generate a normally-distributed random numbers with the specified mean and sigma. Should not be called in a loop since there's overhead. Use EcNormalRandoms instead. More...
 
static EcRealVector normalRandoms (EcReal mean, EcReal sigma, EcU32 count)
 Convenience method to generate a number of normally-distributed random numbers with the specified mean and sigma. More...
 
template<class VectorType >
static void normalRandoms (const VectorType &means, const VectorType &sigmas, VectorType &results, EcReal defaultSigma=1.0)
 Convenience method to generate a number of normally-distributed random numbers, each with a different mean and sigma. More...
 
static EcOrientation randomOrientation ()
 Convenience method to generate a random orientation.
 
static std::vector< EcOrientationrandomOrientations (EcU32 count)
 Convenience method to generate a number of random orientations. More...
 
static EcVector randomUnitVector ()
 Convenience method to generate a random 3D unit vector, i.e. a unit vector that points in a random direction in 3D space.
 
static std::vector< EcVectorrandomUnitVectors (EcU32 count)
 Convenience method to generate a number of random 3D unit vectors. More...
 

Static Protected Attributes

static boost::scoped_ptr< EcRandomNumberGeneratorTypem_theRandomNumberGenerator
 

Detailed Description

A utility class to generate random numbers.

Each random number generator is thread-specific, i.e. the sequence of the generated random numbers is unique for each thread.

Definition at line 34 of file ecRandom.h.

Member Function Documentation

static EcReal EcRandom::normalRandom ( EcReal  mean = 0.0,
EcReal  sigma = 1.0 
)
static

Convenience method to generate a normally-distributed random numbers with the specified mean and sigma. Should not be called in a loop since there's overhead. Use EcNormalRandoms instead.

Parameters
[in]meanThe mean of the normal distribution.
[in]sigmaThe sigma of the normal distribution.
Returns
A vector of size count contain the random numbers.
static EcRealVector EcRandom::normalRandoms ( EcReal  mean,
EcReal  sigma,
EcU32  count 
)
static

Convenience method to generate a number of normally-distributed random numbers with the specified mean and sigma.

Parameters
[in]meanThe mean of the normal distribution.
[in]sigmaThe sigma of the normal distribution.
[in]countThe number of random numbers to be generated.
Returns
A vector of size count contain the random numbers.
template<class VectorType >
static void EcRandom::normalRandoms ( const VectorType &  means,
const VectorType &  sigmas,
VectorType &  results,
EcReal  defaultSigma = 1.0 
)
inlinestatic

Convenience method to generate a number of normally-distributed random numbers, each with a different mean and sigma.

Parameters
[in]meansA vector of mean values.
[in]sigmasA vector of sigma values. If the number of sigmas is less than the number of mean values, then defaultSigma is used as the default sigma for the remaining mean values.
[out]resultsA vector of normally-distributed random numbers. Each element of this vector uses the corresponding mean and sigma from above.
[in]defaultSigmaThe default sigma used when the size of sigmas is smaller than the size of means.

Definition at line 135 of file ecRandom.h.

static std::vector< EcOrientation > EcRandom::randomOrientations ( EcU32  count)
static

Convenience method to generate a number of random orientations.

Parameters
[in]countThe number of random orientations to be generated.
Returns
A vector of size count contain the random orientations.
static std::vector< EcVector > EcRandom::randomUnitVectors ( EcU32  count)
static

Convenience method to generate a number of random 3D unit vectors.

Parameters
[in]countThe number of random unit vectors to be generated.
Returns
A vector of size count contain the random unit vectors.
static EcInt32 EcRandom::uniformIntRandom ( EcInt32  lowerBound = 0,
EcInt32  upperBound = 99 
)
static

Convenience method to generate a uniformly-distributed random integer numbers between the lowerBound and upperBound, inclusive. Should not be called in a loop since there's overhead. Use uniformIntRandoms instead.

Parameters
[in]lowerBoundThe lower bound (inclusive) of the uniform distribution.
[in]upperBoundThe upper bound (inclusive) of the uniform distribution.
Returns
A random integer number.
static EcInt32Vector EcRandom::uniformIntRandoms ( EcInt32  lowerBound,
EcInt32  upperBound,
EcU32  count 
)
static

Convenience method to generate a number of uniformly-distributed random integers between the lowerBound and upperBound, inclusive.

Parameters
[in]lowerBoundThe lower bound (inclusive) of the uniform distribution.
[in]upperBoundThe upper bound (inclusive) of the uniform distribution.
[in]countThe number of random integers to be generated.
Returns
A vector of size count contain the random numbers.
static EcReal EcRandom::uniformRealRandom ( EcReal  lowerBound = 0.0,
EcReal  upperBound = 1.0 
)
static

Convenience method to generate a uniformly-distributed random real numbers between the lowerBound inclusive and upperBound exclusive. Should not be called in a loop since there's overhead. Use uniformRealRandoms instead.

Parameters
[in]lowerBoundThe lower bound (inclusive) of the uniform distribution.
[in]upperBoundThe upper bound (inclusive) of the uniform distribution.
Returns
A random real number.
static EcRealVector EcRandom::uniformRealRandoms ( EcReal  lowerBound,
EcReal  upperBound,
EcU32  count 
)
static

Convenience method to generate a number of uniformly-distributed random reals between the lowerBound inclusive and upperBound exclusive.

Parameters
[in]lowerBoundThe lower bound (inclusive) of the uniform distribution.
[in]upperBoundThe upper bound (inclusive) of the uniform distribution.
[in]countThe number of random numbers to be generated.
Returns
A vector of size count contain the random numbers.

The documentation for this class was generated from the following file:
Created by Energid Technologies www.energid.com
Copyright © 2016 Energid. All trademarks mentioned in this document are property of their respective owners.