Magnum/Math/Functions.h file

Functions usable with scalar and vector types.

Namespaces

namespace Magnum
Root namespace.
namespace Magnum::Math
Math library.

Functions

auto log(UnsignedInt base, UnsignedInt number) -> UnsignedInt
Integral logarithm.
auto log2(UnsignedInt number) -> UnsignedInt
Base-2 integral logarithm.
template<class T>
auto log(T number) -> T
Natural logarithm.
template<class T>
auto exp(T exponent) -> T
Natural exponential.
template<class Integral>
auto div(Integral x, Integral y) -> std::pair<Integral, Integral>
Integer division with remainder.
template<class T>
auto isInf(T value) -> std::enable_if<std::is_arithmetic<T>::value, bool>::type
If given number is a positive or negative infinity.
template<class T>
auto isNan(T value) -> std::enable_if<std::is_arithmetic<T>::value, bool>::type
If given number is a NaN.
template<class T>
auto sin(Rad<T> angle) -> T
Sine.
template<class T>
auto cos(Rad<T> angle) -> T
Cosine.
template<class T>
auto sincos(Rad<T> angle) -> std::pair<T, T>
Sine and cosine.
template<class T>
auto tan(Rad<T> angle) -> T
Tangent.
template<class T>
auto asin(T value) -> Rad<T>
Arc sine.
template<class T>
auto acos(T value) -> Rad<T>
Arc cosine.
template<class T>
auto atan(T value) -> Rad<T>
Arc tangent.

Scalar/vector functions

These functions are overloaded for both scalar and vector types. Scalar versions function exactly as their possible STL equivalents, vector overloads perform the operations component-wise.

template<UnsignedInt exponent, class T>
auto pow(T base) -> T constexpr
Integral power.
template<class T>
auto pow(T base, T exponent) -> T
Power.
template<class T>
auto min(T value, T min) -> T
Minimum.
template<class T>
auto min(Corrade::Containers::ArrayView<const T> range) -> T
Minimum of a range.
template<class T>
auto max(T value, T max) -> T
Maximum.
template<class T>
auto max(Corrade::Containers::ArrayView<const T> range) -> T
Maximum of a range.
template<class T>
auto minmax(const T& a, const T& b) -> std::pair<T, T>
Minimum and maximum of two values.
template<class T>
auto minmax(Corrade::Containers::ArrayView<const T> range) -> std::pair<T, T>
Minimum and maximum of a range.
template<class T, class U>
auto clamp(const T& value, const T& min, const T& max) -> T
Clamp value.
template<class T>
auto sign(const T scalar) -> T
Sign.
template<class T>
auto abs(const T& a) -> T
Absolute value.
template<class T>
auto floor(const T& a) -> T
Nearest not larger integer.
template<class T>
auto round(const T& a) -> T
Round value to nearest integer.
template<class T>
auto ceil(const T& a) -> T
Nearest not smaller integer.
template<class T>
auto sqrt(const T& a) -> T
Square root.
template<class T>
auto sqrtInverted(const T& a) -> T
Inverse square root.
template<class T, class U>
auto lerp(const T& a, const T& b, U t) -> T
Linear interpolation of two values.
template<class T>
auto lerpInverted(const T& a, const T& b, const T& lerp) -> T
Inverse linear interpolation of two values.
template<class T, class U>
auto select(const T& a, const T& b, U t) -> T constexpr
Constant interpolation of two values.
template<class T>
auto fma(const T& a, const T& b, const T& c) -> T
Fused multiply-add.