Funtions in #include <mrpt/core/bits_math.h>¶
// global functions template <typename num_t, typename return_t = num_t> return_t mrpt::square(const num_t x); template <class T> T mrpt::hypot_fast(const T x, const T y); constexpr double mrpt::DEG2RAD(const double x); constexpr float mrpt::DEG2RAD(const float x); constexpr double mrpt::DEG2RAD(const int x); constexpr double mrpt::RAD2DEG(const double x); constexpr float mrpt::RAD2DEG(const float x); constexpr long double mrpt::DEG2RAD(const long double x); constexpr long double mrpt::RAD2DEG(const long double x); constexpr double mrpt::operator"" _deg (long double v); template <typename T> int mrpt::sign(T x); template <typename T> int mrpt::signWithZero(T x); template <typename T> T mrpt::lowestPositive(const T a, const T b); template <typename T> T mrpt::abs_diff(const T a, const T b); template <typename T> const T mrpt::min3( const T& A, const T& B, const T& C ); template <typename T> const T mrpt::max3( const T& A, const T& B, const T& C ); template <typename T> int mrpt::fix(T x); template <typename T, typename K> void mrpt::keep_min(T& var, const K test_val); template <typename T, typename K> void mrpt::keep_max(T& var, const K test_val); template <typename T> void mrpt::saturate(T& var, const T sat_min, const T sat_max); template <typename T> T mrpt::saturate_val(const T& value, const T sat_min, const T sat_max); template <class T> T mrpt::round2up(T val); float mrpt::d2f(const double d); uint8_t mrpt::f2u8(const float f); float mrpt::u8tof(const uint8_t v); // macros #define DEG2RAD #define M_2PIl #define M_PI #define M_PIl #define RAD2DEG
Global Functions¶
template <typename num_t, typename return_t = num_t> return_t mrpt::square(const num_t x)
Inline function for the square of a number.
template <class T> T mrpt::hypot_fast(const T x, const T y)
Faster version of std::hypot(), to use when overflow is not an issue and we prefer fast code.
constexpr double mrpt::DEG2RAD(const double x)
Degrees to radians.
constexpr float mrpt::DEG2RAD(const float x)
Degrees to radians.
constexpr double mrpt::DEG2RAD(const int x)
Degrees to radians.
constexpr double mrpt::RAD2DEG(const double x)
Radians to degrees.
constexpr float mrpt::RAD2DEG(const float x)
Radians to degrees.
constexpr long double mrpt::DEG2RAD(const long double x)
Degrees to radians.
constexpr long double mrpt::RAD2DEG(const long double x)
Radians to degrees.
constexpr double mrpt::operator"" _deg (long double v)
degrees to radian literal operator (e.g.
x=90.0_deg;
)
template <typename T> int mrpt::sign(T x)
Returns the sign of X as “1” or “-1”.
template <typename T> int mrpt::signWithZero(T x)
Returns the sign of X as “0”, “1” or “-1”.
template <typename T> T mrpt::lowestPositive(const T a, const T b)
Returns the smallest positive number among a and b.
template <typename T> T mrpt::abs_diff(const T a, const T b)
Efficient and portable evaluation of the absolute difference of two unsigned integer values (but will also work for signed and floating point types)
template <typename T> int mrpt::fix(T x)
Rounds toward zero.
template <typename T, typename K> void mrpt::keep_min(T& var, const K test_val)
If the second argument is below the first one, set the first argument to this lower value.
template <typename T, typename K> void mrpt::keep_max(T& var, const K test_val)
If the second argument is above the first one, set the first argument to this higher value.
template <typename T> void mrpt::saturate( T& var, const T sat_min, const T sat_max )
Saturate the value of var (the variable gets modified) so it does not get out of [min,max].
template <typename T> T mrpt::saturate_val( const T& value, const T sat_min, const T sat_max )
Like saturate() but it returns the value instead of modifying the variable.
template <class T> T mrpt::round2up(T val)
Round up to the nearest power of two of a given number.
float mrpt::d2f(const double d)
shortcut for static_cast<float>(double)
uint8_t mrpt::f2u8(const float f)
converts a float [0,1] into an uint8_t [0,255] (without checking for out of bounds)
See also:
float mrpt::u8tof(const uint8_t v)
converts a uint8_t [0,255] into a float [0,1]
See also: