Leonetienne/Eule
Homemade math library, mainly targetted towards computer graphics
|
Go to the documentation of this file.
13 [[nodiscard]]
static constexpr
double Max(
const double a,
const double b);
16 [[nodiscard]]
static constexpr
double Min(
const double a,
const double b);
19 [[nodiscard]]
static constexpr
double Clamp(
const double v,
const double min,
const double max);
22 [[nodiscard]]
static constexpr
double Lerp(
double a,
double b,
double t);
25 [[nodiscard]]
static constexpr
double Abs(
const double a);
28 [[nodiscard]]
static constexpr
bool Similar(
const double a,
const double b,
const double epsilon = 0.00001);
32 [[nodiscard]]
static int Mod(
const int numerator,
const int denominator);
45 static double RandomRange(
const double min,
const double max);
58 static double Oscillate(
const double a,
const double b,
const double counter,
const double speed);
62 static void InitRng();
64 static std::mt19937 rng;
65 static bool isRngInitialized;
76 constexpr
inline double Math::Max(
double a,
double b)
78 return (a > b) ? a : b;
81 constexpr
inline double Math::Min(
double a,
double b)
83 return (a < b) ? a : b;
86 constexpr
inline double Math::Clamp(
double v,
double min,
double max)
88 return Max(
Min(v, max), min);
91 constexpr
inline double Math::Lerp(
double a,
double b,
double t)
93 const double it = 1.0 - t;
94 return (a * it) + (b * t);
99 return (a > 0.0) ? a : -a;
102 constexpr
inline bool Math::Similar(
const double a,
const double b,
const double epsilon)
104 return Abs(a - b) <= epsilon;
static bool RandomChance(const double chance)
Will 'roll' a dice, returning true percent of the time.
static constexpr double Abs(const double a)
Will return the absolute value of a
static double RandomRange(const double min, const double max)
Will return a random double within a range These bounds are INCLUSIVE!
static constexpr double Lerp(double a, double b, double t)
Will return the linear interpolation between a and b by t
static int Mod(const int numerator, const int denominator)
Will compute the actual modulo of a fraction.
static unsigned int RandomInt()
Will return a random integer.
static constexpr double Max(const double a, const double b)
Will return the bigger of two values.
Math utility class containing basic functions.
static constexpr double Clamp(const double v, const double min, const double max)
Will return v, but at least min, and at most max
static constexpr double Min(const double a, const double b)
Will return the smaller of two values.
static int RandomIntRange(const int max, const int min)
Will return a random integer within a range.
static constexpr bool Similar(const double a, const double b, const double epsilon=0.00001)
Compares two double values with a given accuracy.
static double Random()
Will return a random double between 0 and 1
static unsigned int RandomUint()
Will return a random unsigned integer.
static double Oscillate(const double a, const double b, const double counter, const double speed)
Kind of like , but it oscillates over instead of , by a given speed.