28#ifndef WIZARD_ENGINE_MATH_HPP
29#define WIZARD_ENGINE_MATH_HPP
47 [[nodiscard]]
static constexpr float epsilon() {
55 [[nodiscard]]
static constexpr float pi() {
65 [[nodiscard]]
static constexpr float to_radians(
float degrees) {
67 return degrees *
pi() / 180;
75 [[nodiscard]]
static constexpr float to_degrees(
float radians) {
77 return radians * 180 /
pi();
86 [[nodiscard]]
static constexpr std::pair<float, float>
normal(
float x,
97 [[nodiscard]]
static float length(
float x,
float y);
105 [[nodiscard]]
static float angle(
float x,
float y);
113 [[nodiscard]]
static std::pair<float, float>
normalize(
float x,
float y);
137 [[nodiscard]]
static std::array<float, 4>
147 [[nodiscard]]
static constexpr float
161 [[nodiscard]]
static constexpr float
175 template <
typename T>
176 [[nodiscard]]
static T
random(T minimum = std::numeric_limits<T>::lowest(),
177 T maximum = std::numeric_limits<T>::max()) {
178 static_assert(!std::is_same_v<T, bool>);
179 if constexpr (std::is_integral_v<T>) {
180 return std::uniform_int_distribution<T>{minimum,
181 maximum}(_mt19937_64);
182 }
else if constexpr (std::is_floating_point_v<T>) {
183 return std::uniform_real_distribution<T>{minimum,
184 maximum}(_mt19937_64);
194 template <
typename T>
195 [[nodiscard]]
static bool random(
float probability = (
float)
true / 2) {
196 static_assert(std::is_same_v<T, bool>);
197 return std::bernoulli_distribution{(double)probability}(_mt19937_64);
201 static std::mt19937_64 _mt19937_64;
static constexpr float to_radians(float degrees)
Converts degrees to radians.
static float angle(float x, float y)
Returns the angle of a vector.
static constexpr float transform_y(float x, float y, std::array< float, 4 > const &transformation_matrix)
Transforms the y component of a vector.
static bool random(float probability=(float) true/2)
Returns a random boolean value.
math()=delete
Deleted explicit constructor.
static constexpr std::pair< float, float > normal(float x, float y)
Returns the normal vector of a vector.
static std::array< float, 4 > transformation_matrix(float angle, float scale)
Creates a transformation matrix.
static float move_y(float length, float angle)
Moves the y component of a vector.
static constexpr float to_degrees(float radians)
Converts radians to degrees.
static std::pair< float, float > normalize(float x, float y)
Normalizes a vector.
static float move_x(float length, float angle)
Moves the x component of a vector.
static constexpr float pi()
Single precision PI.
static float length(float x, float y)
Returns the length of a vector.
static constexpr float epsilon()
Single precision epsilon.
static constexpr float transform_x(float x, float y, std::array< float, 4 > const &transformation_matrix)
Transforms the x component of a vector.
static T random(T minimum=std::numeric_limits< T >::lowest(), T maximum=std::numeric_limits< T >::max())
Returns a random numeric value from an interval.
Export header of the Wizard Engine.