galaxy 1.0.0
Real-Time C++23 Game Programming Framework. Built on data-driven design principles and agile software engineering.
Loading...
Searching...
No Matches
galaxy::math::Random Class Referencefinal

Generates random numbers. More...

#include <Random.hpp>

+ Collaboration diagram for galaxy::math::Random:

Public Member Functions

 Random () noexcept
 Constructor.
 
 ~Random () noexcept
 Destructor.
 
template<meta::is_arithmetic T>
gen (const T min, const T max) noexcept
 Generate a random number of type T.
 
template<meta::is_arithmetic T>
sf::Vector2< T > gen_vec2 (const sf::Vector2< T > &min, const sf::Vector2< T > &max) noexcept
 Generate a random vec2.
 
template<meta::is_arithmetic T>
sf::Vector3< T > gen_vec3 (const sf::Vector3< T > &min, const sf::Vector3< T > &max) noexcept
 Generate a random vec3.
 

Private Attributes

std::random_device m_rd
 Randomizer device.
 
std::mt19937_64 m_mt
 Pseudo-random algorithm.
 

Detailed Description

Generates random numbers.

Different than the function in that it doesnt create a new device each call. Essentially faster when needing lots of random numbers.

Definition at line 36 of file Random.hpp.

Constructor & Destructor Documentation

◆ Random()

galaxy::math::Random::Random ( )
noexcept

Constructor.

Definition at line 14 of file Random.cpp.

◆ ~Random()

galaxy::math::Random::~Random ( )
noexcept

Destructor.

Definition at line 20 of file Random.cpp.

Member Function Documentation

◆ gen()

template<meta::is_arithmetic T>
T galaxy::math::Random::gen ( const T min,
const T max )
nodiscardnoexcept

Generate a random number of type T.

Template Parameters
TThe type of number to return. Must be arithmetic.
Parameters
minMinimum number inclusive.
maxMaximum number inclusive.
Returns
Returns number of the same type as inputs.

Definition at line 105 of file Random.hpp.

+ Here is the caller graph for this function:

◆ gen_vec2()

template<meta::is_arithmetic T>
sf::Vector2< T > galaxy::math::Random::gen_vec2 ( const sf::Vector2< T > & min,
const sf::Vector2< T > & max )
nodiscardnoexcept

Generate a random vec2.

Template Parameters
TThe type of number to return. Must be arithmetic.
Parameters
minMinimum vec2 inclusive.
maxMaximum vec2 inclusive.
Returns
Pseudo-randomized vec2.

Definition at line 112 of file Random.hpp.

+ Here is the caller graph for this function:

◆ gen_vec3()

template<meta::is_arithmetic T>
sf::Vector3< T > galaxy::math::Random::gen_vec3 ( const sf::Vector3< T > & min,
const sf::Vector3< T > & max )
nodiscardnoexcept

Generate a random vec3.

Template Parameters
TThe type of number to return. Must be arithmetic.
Parameters
minMinimum vec3 inclusive.
maxMaximum vec3 inclusive.
Returns
Pseudo-randomized vec3.

Definition at line 118 of file Random.hpp.

+ Here is the caller graph for this function:

Member Data Documentation

◆ m_rd

std::random_device galaxy::math::Random::m_rd
private

Randomizer device.

Definition at line 96 of file Random.hpp.

◆ m_mt

std::mt19937_64 galaxy::math::Random::m_mt
private

Pseudo-random algorithm.

Definition at line 101 of file Random.hpp.


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