template<typename T>
Math class
| Template parameters | |
|---|---|
| T | type of number to perform operations on |
Contents
Core math functions
Public static variables
Public static functions
- static auto Abs(T val) -> T
- static auto Lerp(const T a, const T b, const T alpha) -> T
- static auto Map(const T val, const T srcmin, const T srcmax, const T dstmin, const T dstmax) -> T
- static auto Clamp(const T val, const T min, const T max) -> T
- static auto Round(const T val, const fsize prec = 0) -> T
- static auto Sqrt(const T val) -> T
- static auto Exp(const T val) -> T
- static auto Log(const T val) -> T
- static auto Log10(const T val) -> T
- static auto Log(const T base, const T val) -> T
- static auto Cos(const T val) -> T
- static auto Sin(const T val) -> T
- static auto Tan(const T val) -> T
- static auto ArcCos(const T val) -> T
- static auto ArcSin(const T val) -> T
- static auto ArcTan(const T val) -> T
- static auto ArcTan2(const T y, const T x) -> T
Public functions
-
template<>auto Sqrt(const float val) -> float
-
template<>auto Sqrt(const long double val) -> long double
-
template<>auto Exp(const float val) -> float
-
template<>auto Exp(const long double val) -> long double
-
template<>auto Log(const float val) -> float
-
template<>auto Log(const long double val) -> long double
-
template<>auto Log10(const float val) -> float
-
template<>auto Log10(const long double val) -> long double
-
template<>auto Cos(const float val) -> float
-
template<>auto Cos(const long double val) -> long double
-
template<>auto Sin(const float val) -> float
-
template<>auto Sin(const long double val) -> long double
-
template<>auto Tan(const float val) -> float
-
template<>auto Tan(const long double val) -> long double
-
template<>auto ArcCos(const float val) -> float
-
template<>auto ArcCos(const long double val) -> long double
-
template<>auto ArcSin(const float val) -> float
-
template<>auto ArcSin(const long double val) -> long double
-
template<>auto ArcTan(const float val) -> float
-
template<>auto ArcTan(const long double val) -> long double
-
template<>auto ArcTan2(const float y, const float x) -> float
-
template<>auto ArcTan2(const long double y, const long double x) -> long double
Function documentation
template<typename T>
static T bpf:: math:: Math<T>:: Abs(T val)
| Parameters | |
|---|---|
| val | value to convert to absolute value |
| Returns | the absolute value of val |
Absolute value
template<typename T>
static T bpf:: math:: Math<T>:: Lerp(const T a,
const T b,
const T alpha)
| Parameters | |
|---|---|
| a | the initial value |
| b | the target value |
| alpha | interpolation float |
| Returns | interpolated value |
Performs a linear interpolation
template<typename T>
static T bpf:: math:: Math<T>:: Map(const T val,
const T srcmin,
const T srcmax,
const T dstmin,
const T dstmax)
| Parameters | |
|---|---|
| val | the value to map |
| srcmin | the source minimum |
| srcmax | the source maximum |
| dstmin | the target minimum |
| dstmax | the target maximum |
| Returns | mapped value |
Maps a value between a min and a max value
template<typename T>
static T bpf:: math:: Math<T>:: Clamp(const T val,
const T min,
const T max)
| Parameters | |
|---|---|
| val | the value to map |
| min | the minimum |
| max | the maximum |
| Returns | clamped value |
Clamps a value between a min and a max value
template<typename T>
static T bpf:: math:: Math<T>:: Sqrt(const T val)
| Parameters | |
|---|---|
| val | number to calculate square root of |
| Returns | square root of val |
Shortcut to the system's square root function
template<typename T>
static T bpf:: math:: Math<T>:: Exp(const T val)
| Parameters | |
|---|---|
| val | number for e power val |
| Returns | exponential of val |
Shortcut to the system's exponential function
template<typename T>
static T bpf:: math:: Math<T>:: Log(const T val)
| Parameters | |
|---|---|
| val | number for Ln(val) |
| Returns | natural logarithm of val |
Shortcut to the system's natural logarithm function
template<typename T>
static T bpf:: math:: Math<T>:: Log10(const T val)
| Parameters | |
|---|---|
| val | number for Log(val) |
| Returns | logarithm base 10 of val |
Shortcut to the system's logarithm base 10 function
template<typename T>
static T bpf:: math:: Math<T>:: Log(const T base,
const T val)
| Parameters | |
|---|---|
| base | the logarythm base to use |
| val | number for Log(val) |
| Returns | logarithm of val in any base |
Shortcut to calculate log base n
template<typename T>
static T bpf:: math:: Math<T>:: Cos(const T val)
| Parameters | |
|---|---|
| val | number for cos(val) |
| Returns | T the cosine of val |
Shortcut to the system's cos function
template<typename T>
static T bpf:: math:: Math<T>:: Sin(const T val)
| Parameters | |
|---|---|
| val | number for sin(val) |
| Returns | T the sine of val |
Shortcut to the system's sin function
template<typename T>
static T bpf:: math:: Math<T>:: Tan(const T val)
| Parameters | |
|---|---|
| val | number for tan(val) |
| Returns | T the tangent of val |
Shortcut to the system's tan function
template<typename T>
static T bpf:: math:: Math<T>:: ArcCos(const T val)
| Parameters | |
|---|---|
| val | number for acos(val) |
| Returns | T the arc-cosine of val |
Shortcut to the system's acos function
template<typename T>
static T bpf:: math:: Math<T>:: ArcSin(const T val)
| Parameters | |
|---|---|
| val | number for asin(val) |
| Returns | T the arc-sine of val |
Shortcut to the system's asin function
template<typename T>
static T bpf:: math:: Math<T>:: ArcTan(const T val)
| Parameters | |
|---|---|
| val | number for atan(val) |
| Returns | T the arc-tangent of val |
Shortcut to the system's atan function
template<typename T>
static T bpf:: math:: Math<T>:: ArcTan2(const T y,
const T x)
| Parameters | |
|---|---|
| y | y value for atan2(x, y) |
| x | x value for atan2(x, y) |
| Returns | T the arc-tangent of (x, y) |
Shortcut to the system's atan2 function
Variable documentation
template<typename T>
static T bpf:: math:: Math<T>:: RadToDeg constexpr
Radians to degrees multiplier constant
template<typename T>
static T bpf:: math:: Math<T>:: DegToRad constexpr
Degrees to radians multiplier constant
template<typename T>
static T bpf:: math:: Math<T>:: Pi constexpr
Pi constant
template<typename T>
static T bpf:: math:: Math<T>:: TwoPi constexpr
2 * Pi constant
template<typename T>
static T bpf:: math:: Math<T>:: Epsilon constexpr
Very small value to represent acceptable rounding errors for type T