file
Functions.hFunctions usable with scalar and vector types.
Namespaces
- namespace Magnum
- Root namespace.
- namespace Magnum::Math
- Math library.
Functions
-
template<class Integral>auto div(Integral x, Integral y) -> Containers::Pair<Integral, Integral>
- Integer division with remainder.
- auto binomialCoefficient(UnsignedInt n, UnsignedInt k) -> UnsignedLong new in Git master
- Binomial coefficient.
- auto popcount(UnsignedInt number) -> UnsignedInt new in Git master
- Count of bits set in a number.
- auto popcount(UnsignedLong number) -> UnsignedInt new in Git master
-
template<std::auto reflect(const Vector<size, T>& vector, const Vector<size, T>& normal) -> Vector<size, T> new in 2020.06
size_t size, class T> - Reflect a vector.
-
template<std::auto refract(const Vector<size, T>& vector, const Vector<size, T>& normal, T eta) -> Vector<size, T> new in 2020.06
size_t size, class T> - Refract a vector.
Trigonometric functions
Unlike std::
-
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) -> Containers::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, including Deg and Rad. Scalar versions function exactly as their possible STL equivalents, vector overloads perform the operations component-wise.
-
template<class T>auto isInf(T value) -> std::
enable_if<IsScalar<T>::value, bool>::type new in 2019.10 - If given number is a positive or negative infinity.
-
template<std::auto isInf(const Vector<size, T>& value) -> BitVector<size> new in 2019.10
size_t size, class T> -
template<class T>auto isNan(T value) -> std::
enable_if<IsScalar<T>::value, bool>::type new in 2019.10 - If given number is a NaN.
-
template<std::auto isNan(const Vector<size, T>& value) -> BitVector<size> new in 2019.10
size_t size, class T> -
template<class T>auto min(T value, T min) -> std::
enable_if<IsScalar<T>::value, T>::type constexpr - Minimum.
-
template<std::auto min(const Vector<size, T>& value, const Vector<size, T>& min) -> Vector<size, T>
size_t size, class T> -
template<std::auto min(const Vector<size, T>& value, T min) -> Vector<size, T>
size_t size, class T> -
template<class T>auto max(T a, T b) -> std::
enable_if<IsScalar<T>::value, T>::type constexpr - Maximum.
-
template<std::auto max(const Vector<size, T>& value, const Vector<size, T>& max) -> Vector<size, T>
size_t size, class T> -
template<std::auto max(const Vector<size, T>& value, T max) -> Vector<size, T>
size_t size, class T> -
template<class T>auto minmax(T a, T b) -> std::
enable_if<IsScalar<T>::value, Containers::Pair<T, T>>::type - Minimum and maximum of two values.
-
template<std::auto minmax(const Vector<size, T>& a, const Vector<size, T>& b) -> Containers::Pair<Vector<size, T>, Vector<size, T>>
size_t size, class T> -
template<class T>auto clamp(T value, T min, T max) -> std::
enable_if<IsScalar<T>::value, T>::type constexpr - Clamp value.
-
template<std::auto clamp(const Vector<size, T>& value, const Vector<size, T>& min, const Vector<size, T>& max) -> Vector<size, T>
size_t size, class T> -
template<std::auto clamp(const Vector<size, T>& value, T min, T max) -> Vector<size, T>
size_t size, class T> -
template<class T>auto sign(T scalar) -> std::
enable_if<IsScalar<T>::value, UnderlyingTypeOf<T>>::type - Sign.
-
template<std::auto sign(const Vector<size, T>& a) -> Vector<size, UnderlyingTypeOf<T>>
size_t size, class T> -
template<class T>auto abs(T a) -> std::
enable_if<IsScalar<T>::value, T>::type - Absolute value.
-
template<std::auto abs(const Vector<size, T>& a) -> Vector<size, T>
size_t size, class T> -
template<class T>auto floor(T a) -> std::
enable_if<IsScalar<T>::value, T>::type - Nearest not larger integer.
-
template<std::auto floor(const Vector<size, T>& a) -> Vector<size, T>
size_t size, class T> -
template<class T>auto round(T a) -> std::
enable_if<IsScalar<T>::value, T>::type - Round value to nearest integer.
-
template<std::auto round(const Vector<size, T>& a) -> Vector<size, T>
size_t size, class T> -
template<class T>auto ceil(T a) -> std::
enable_if<IsScalar<T>::value, T>::type - Nearest not smaller integer.
-
template<std::auto ceil(const Vector<size, T>& a) -> Vector<size, T>
size_t size, class T> -
template<class T>auto fmod(T a, T b) -> std::
enable_if<IsScalar<T>::value, T>::type new in Git master - Floating point division remainder.
-
template<std::auto fmod(const Vector<size, T>& a, const Vector<size, T>& b) -> Vector<size, T> new in Git master
size_t size, class T> -
template<std::auto fmod(const Vector<size, T>& a, T b) -> Vector<size, T> new in Git master
size_t size, class T> -
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 lerp(const T& a, const T& b, bool t) -> T
-
template<std::auto lerp(const Vector<size, T>& a, const Vector<size, T>& b, const BitVector<size>& t) -> Vector<size, T>
size_t size, class T> -
template<std::auto lerp(const BitVector<size>& a, const BitVector<size>& b, const BitVector<size>& t) -> BitVector<size>
size_t size> -
template<class T>auto lerpInverted(T a, T b, T lerp) -> UnderlyingTypeOf<typename std::
enable_if<IsScalar<T>::value, T>::type> - Inverse linear interpolation of two values.
-
template<std::auto lerpInverted(const Vector<size, T>& a, const Vector<size, T>& b, const Vector<size, T>& lerp) -> Vector<size, UnderlyingTypeOf<T>>
size_t size, class T> -
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(T a, T b, T c) -> std::
enable_if<IsScalar<T>::value, T>::type - Fused multiply-add.
-
template<std::auto fma(const Vector<size, T>& a, const Vector<size, T>& b, const Vector<size, T>& c) -> Vector<size, T>
size_t size, class T>
Exponential and power functions
Unlike scalar/vector functions these don't work on Deg / Rad as the resulting unit can't be easily expressed.
- 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<UnsignedInt exponent, class T>auto pow(T base) -> std::
enable_if<IsScalar<T>::value, T>::type constexpr - Integral power.
-
template<UnsignedInt exponent, std::auto pow(const Vector<size, T>& base) -> Vector<size, T>
size_t size, class T> -
template<class T>auto pow(T base, T exponent) -> std::
enable_if<IsScalar<T>::value, T>::type - Power.
-
template<std::auto pow(const Vector<size, T>& base, T exponent) -> Vector<size, T>
size_t size, class T> -
template<class T>auto sqrt(T a) -> std::
enable_if<IsScalar<T>::value, T>::type - Square root.
-
template<std::auto sqrt(const Vector<size, T>& a) -> Vector<size, T>
size_t size, class T> -
template<class T>auto sqrtInverted(T a) -> std::
enable_if<IsScalar<T>::value, T>::type - Inverse square root.
-
template<std::auto sqrtInverted(const Vector<size, T>& a) -> Vector<size, T>
size_t size, class T>