18#ifndef __FPSDK_COMMON_MATH_HPP__
19#define __FPSDK_COMMON_MATH_HPP__
49 static_assert(::std::is_floating_point<T>::value,
"Value must be float or double");
50 return degrees * M_PI / 180.0;
63 static_assert(::std::is_floating_point<T>::value,
"Value must be float or double");
64 return radians * 180.0 / M_PI;
110constexpr T
Bit(
const std::size_t bit)
112 return static_cast<T
>(
static_cast<uint64_t
>(1) << bit);
127 return (mask & bits) == bits;
142 return (mask & bits) != 0;
155constexpr T
GetBits(
const T value,
const T mask)
157 return (value & mask);
double RoundToFracDigits(const double value, const int digits)
Round to desired number of fractional digits (of precision)
double ClipToFracDigits(const double value, const int digits)
Clip to desired number of fractional digits (of precision)
constexpr T DegToRad(T degrees)
Convert degrees to radians.
constexpr T Bit(const std::size_t bit)
Return a number with the given bit set to 1 (i.e. 2^bit)
constexpr bool CheckBitsAny(const T mask, const T bits)
Checks if any bits are set.
void SetBits(T &mask, const T bits)
Sets the bits.
void ToggleBits(T &mask, const T bits)
Toggles the bits.
constexpr bool CheckBitsAll(const T mask, const T bits)
Checks if all bits are set.
constexpr T RadToDeg(T radians)
Convert radians to degrees.
void ClearBits(T &mask, const T bits)
Clears the bits.
constexpr T GetBits(const T value, const T mask)
Extracts bits.