Leonetienne/Eule
Homemade math library, mainly targetted towards computer graphics
|
Go to the documentation of this file.
12 [[nodiscard]]
static constexpr
double Max(
const double a,
const double b);
15 [[nodiscard]]
static constexpr
double Min(
const double a,
const double b);
18 [[nodiscard]]
static constexpr
double Clamp(
const double v,
const double min,
const double max);
21 [[nodiscard]]
static constexpr
double Lerp(
double a,
double b,
double t);
24 [[nodiscard]]
static constexpr
double Abs(
const double a);
27 [[nodiscard]]
static constexpr
bool Similar(
const double a,
const double b,
const double epsilon = 0.00001);
40 static double RandomRange(
const double min,
const double max);
53 static double Oscillate(
const double a,
const double b,
const double counter,
const double speed);
57 static void InitRng();
59 static std::mt19937 rng;
60 static bool isRngInitialized;
71 constexpr
inline double Math::Max(
double a,
double b)
73 return (a > b) ? a : b;
76 constexpr
inline double Math::Min(
double a,
double b)
78 return (a < b) ? a : b;
81 constexpr
inline double Math::Clamp(
double v,
double min,
double max)
83 return Max(
Min(v, max), min);
86 constexpr
inline double Math::Lerp(
double a,
double b,
double t)
88 const double it = 1.0 - t;
89 return (a * it) + (b * t);
94 return (a > 0.0) ? a : -a;
97 inline constexpr
bool Math::Math::Similar(
const double a,
const double b,
const double epsilon)
99 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 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 double Random()
Will return a random double between 0 and 1
static constexpr bool Similar(const double a, const double b, const double epsilon=0.00001)
Compares two double values with a given accuracy.
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.