ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
cloudViewer::utility::random::UniformRealGenerator< T > Class Template Reference

#include <Random.h>

Public Member Functions

 UniformRealGenerator (const T low=0.0, const T high=1.0)
 
operator() ()
 Call this to generate a uniformly distributed floating point value. More...
 

Protected Attributes

std::uniform_real_distribution< T > distribution_
 

Detailed Description

template<typename T>
class cloudViewer::utility::random::UniformRealGenerator< T >

Generate uniformly distributed floating point values in [low, high). This class is globally seeded by utility::random::Seed(). This class is a wrapper around std::uniform_real_distribution.

Example:

// Globally seed cloudViewer. This will affect all random functions.
// Generate a random double in [0, 1).
utility::random::UniformRealGenerator<double> gen(0, 1);
for (size_t i = 0; i < 10; i++) {
std::cout << gen() << std::endl;
}
QTextStream & endl(QTextStream &stream)
Definition: QtCompat.h:718
void Seed(const int seed)
Set CloudViewer global random seed.
Definition: Random.cpp:53

Definition at line 112 of file Random.h.

Constructor & Destructor Documentation

◆ UniformRealGenerator()

template<typename T >
cloudViewer::utility::random::UniformRealGenerator< T >::UniformRealGenerator ( const T  low = 0.0,
const T  high = 1.0 
)
inline

Generate uniformly distributed floating point values in [low, high).

Parameters
lowThe lower bound (inclusive).
highThe upper bound (exclusive).

Definition at line 118 of file Random.h.

References LogError.

Member Function Documentation

◆ operator()()

template<typename T >
T cloudViewer::utility::random::UniformRealGenerator< T >::operator() ( )
inline

Call this to generate a uniformly distributed floating point value.

Definition at line 127 of file Random.h.

References cloudViewer::utility::random::UniformRealGenerator< T >::distribution_, cloudViewer::utility::random::GetEngine(), and cloudViewer::utility::random::GetMutex().

Member Data Documentation

◆ distribution_

template<typename T >
std::uniform_real_distribution<T> cloudViewer::utility::random::UniformRealGenerator< T >::distribution_
protected

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