8#ifndef GALAXY_MATH_RANDOM_HPP_
9#define GALAXY_MATH_RANDOM_HPP_
13#include <SFML/System/Vector2.hpp>
14#include <SFML/System/Vector3.hpp>
25 template<
typename Type>
27 std::is_integral<Type>::value,
28 std::uniform_int_distribution<Type>,
29 std::conditional_t<std::is_floating_point<Type>::value, std::uniform_real_distribution<Type>,
void>>;
59 template<meta::is_arithmetic T>
61 T
gen(
const T min,
const T max)
noexcept;
74 template<meta::is_arithmetic T>
76 sf::Vector2<T>
gen_vec2(
const sf::Vector2<T>& min,
const sf::Vector2<T>& max)
noexcept;
88 template<meta::is_arithmetic T>
90 sf::Vector3<T>
gen_vec3(
const sf::Vector3<T>& min,
const sf::Vector3<T>& max)
noexcept;
104 template<meta::is_arithmetic T>
111 template<meta::is_arithmetic T>
112 sf::Vector2<T>
Random::gen_vec2(
const sf::Vector2<T>& min,
const sf::Vector2<T>& max)
noexcept
114 return sf::Vector2<T> {gen<T>(min.x, max.x), gen<T>(min.y, max.y)};
117 template<meta::is_arithmetic T>
118 sf::Vector3<T>
Random::gen_vec3(
const sf::Vector3<T>& min,
const sf::Vector3<T>& max)
noexcept
120 return sf::Vector3<T> {gen<T>(min.x, max.x), gen<T>(min.y, max.y), gen<T>(min.z, max.z)};
Generates random numbers.
std::random_device m_rd
Randomizer device.
~Random() noexcept
Destructor.
T gen(const T min, const T max) noexcept
Generate a random number of type T.
sf::Vector2< T > gen_vec2(const sf::Vector2< T > &min, const sf::Vector2< T > &max) noexcept
Generate a random vec2.
sf::Vector3< T > gen_vec3(const sf::Vector3< T > &min, const sf::Vector3< T > &max) noexcept
Generate a random vec3.
Random() noexcept
Constructor.
std::mt19937_64 m_mt
Pseudo-random algorithm.
std::conditional_t< std::is_integral< Type >::value, std::uniform_int_distribution< Type >, std::conditional_t< std::is_floating_point< Type >::value, std::uniform_real_distribution< Type >, void > > conditional_distribution
Source: http://stackoverflow.com/a/32907541.