|
static constexpr double | Max (const double a, const double b) |
| Will return the bigger of two values. More...
|
|
static constexpr double | Min (const double a, const double b) |
| Will return the smaller of two values. More...
|
|
static constexpr double | Clamp (const double v, const double min, const double max) |
| Will return v , but at least min , and at most max More...
|
|
static constexpr double | Lerp (double a, double b, double t) |
| Will return the linear interpolation between a and b by t More...
|
|
static constexpr double | Abs (const double a) |
| Will return the absolute value of a More...
|
|
static constexpr bool | Similar (const double a, const double b, const double epsilon=0.00001) |
| Compares two double values with a given accuracy. More...
|
|
static int | Mod (const int numerator, const int denominator) |
| Will compute the actual modulo of a fraction. More...
|
|
static double | Random () |
| Will return a random double between 0 and 1 More...
|
|
static unsigned int | RandomUint () |
| Will return a random unsigned integer. More...
|
|
static unsigned int | RandomInt () |
| Will return a random integer. More...
|
|
static double | RandomRange (const double min, const double max) |
| Will return a random double within a range
These bounds are INCLUSIVE! More...
|
|
static int | RandomIntRange (const int max, const int min) |
| Will return a random integer within a range. More...
|
|
static bool | RandomChance (const double chance) |
| Will 'roll' a dice, returning true \(100 * chance\) percent of the time. More...
|
|
static double | Oscillate (const double a, const double b, const double counter, const double speed) |
| Kind of like \(sin(counter)\), but it oscillates over \([a,b]\) instead of \([-1,1]\), by a given speed. More...
|
|
Math utility class containing basic functions.
Definition at line 9 of file Math.h.
double Math::Oscillate |
( |
const double |
a, |
|
|
const double |
b, |
|
|
const double |
counter, |
|
|
const double |
speed |
|
) |
| |
|
static |
Kind of like \(sin(counter)\), but it oscillates over \([a,b]\) instead of \([-1,1]\), by a given speed.
Given that \(speed = 1\), the result will always be a
if counter
is even, and b
if counter
is uneven.
If counter
is a rational, the result will oscillate between a
and b
, like sin()
does.
If you increase speed
, the oscillation frequency will increase. Meaning \(speed = 2\) would result in \(counter=0.5\) returning b
.
Definition at line 68 of file Math.cpp.
70 return (sin(counter * speed *
PI -
HALF_PI) * 0.5 + 0.5) * (b-a) + a;