20template<
typename TEngine>
21Random<TEngine>::Random() :
22 g_engine(std::chrono::system_clock::now().time_since_epoch().count())
24template<
typename TEngine>
25Random<TEngine>::Random(uint64_t seed) :
29template<
typename TEngine>
32 std::scoped_lock<std::mutex>
const lck(this->g_mutex);
33 this->g_engine.seed(seed);
36template<
typename TEngine>
39 return this->g_engine;
41template<
typename TEngine>
44 return this->g_engine;
47template<
typename TEngine>
51 static_assert(std::is_arithmetic<T>::value,
"T must be arithmetic !");
52 std::scoped_lock<std::mutex>
const lck(this->g_mutex);
54 if constexpr (std::is_floating_point<T>::value)
56 std::uniform_real_distribution<T> uniform_dist(min, max);
57 return uniform_dist(this->g_engine);
61 std::uniform_int_distribution<T> uniform_dist(min, max);
62 return uniform_dist(this->g_engine);
66template<
typename TEngine>
70 static_assert(std::is_arithmetic<T>::value,
"T must be arithmetic !");
71 std::scoped_lock<std::mutex>
const lck(this->g_mutex);
73 if constexpr (std::is_floating_point<T>::value)
75 std::uniform_real_distribution<T> uniform_dist(-1, 1);
76 return uniform_dist(this->g_engine);
80 std::uniform_int_distribution<T> uniform_dist(std::numeric_limits<T>::min(), std::numeric_limits<T>::max());
81 return uniform_dist(this->g_engine);
85template<
typename TEngine>
89 return fge::Vector2<T>(this->
range<T>(min_x, max_x), this->
range<T>(min_y, max_y));
92template<
typename TEngine>
99template<
typename TEngine>
104template<
typename TEngine>
118template<
typename TEngine>
125template<
typename TEngine>
132template<
typename TEngine>
138template<
typename TEngine>
141 if ((length == 0) || bucket.empty())
147 result.resize(length);
149 for (std::size_t i = 0; i < length; ++i)
Definition C_color.hpp:35
fge::Vector2< T > rangeVec2(T min_x, T max_x, T min_y, T max_y)
Generate a random vector2 within a range.
Definition C_random.inl:87
fge::Vector2< T > randVec2()
Generate a random vector2.
Definition C_random.inl:120
fge::Vector3< T > randVec3()
Generate a random vector3.
Definition C_random.inl:127
fge::Color rangeColor(uint32_t min, uint32_t max)
Generate a random color.
Definition C_random.inl:100
fge::Color randColor()
Generate a random color.
Definition C_random.inl:133
TEngine const & getEngine() const
Get the random engine.
Definition C_random.inl:37
void setSeed(uint64_t seed)
Set the 64-bit seed of the random number generator.
Definition C_random.inl:30
fge::Vector3< T > rangeVec3(T min_x, T max_x, T min_y, T max_y, T min_z, T max_z)
Generate a random vector3 within a range.
Definition C_random.inl:94
T range(T min, T max)
Generate a random number within a range.
Definition C_random.inl:49
T rand()
Generate a random value.
Definition C_random.inl:68
std::string randStr(std::size_t length, std::string const &bucket="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxy0123456789")
Generate a random character sequence.
Definition C_random.inl:139