10 template <
typename Arithmetic1,
typename Arithmetic2>
11 typename std::enable_if<std::is_integral<typename std::common_type<Arithmetic1, Arithmetic2>::type>
::value ,
bool>::type
12 is_equal(
const Arithmetic1 v_1,
const Arithmetic2 v_2)
14 typedef typename std::common_type<Arithmetic1, Arithmetic2>::type common_type;
15 return static_cast<common_type
>(v_1) == static_cast<common_type>(v_2);
22 template <
typename Arithmetic1,
typename Arithmetic2>
23 typename std::enable_if<std::is_floating_point<typename std::common_type<Arithmetic1, Arithmetic2>::type>
::value,
bool>::type
24 is_equal(
const Arithmetic1 v_1,
const Arithmetic2 v_2)
26 #ifdef ALLOW_DOUBLE_MATH_FUNCTIONS 27 typedef typename std::common_type<Arithmetic1, Arithmetic2>::type common_type;
28 typedef typename std::remove_cv<common_type>::type common_type_nonconst;
30 return fabs(v_1 - v_2) < std::numeric_limits<double>::epsilon();
33 return fabsf(v_1 - v_2) < std::numeric_limits<float>::epsilon();
45 const float f =
static_cast<const float>(
v);
50 return static_cast<float>(
M_PI_2);
53 return static_cast<float>(-
M_PI_2);
66 float ret = sqrtf(static_cast<float>(v));
83 float var_low,
float var_high)
85 if (var_value <= var_low) {
88 if (var_value >= var_high) {
91 float p = (var_value - var_low) / (var_high - var_low);
92 return low_output + p * (high_output - low_output);
98 auto res =
wrap_360(angle, unit_mod);
99 if (res > 180.
f * unit_mod) {
100 res -= 360.f * unit_mod;
105 template float wrap_180<int>(
const int angle,
float unit_mod);
110 template <
typename T>
122 template <
typename T>
125 const float ang_360 = 360.f * unit_mod;
126 float res = fmodf(static_cast<float>(angle), ang_360);
133 template float wrap_360<int>(
const int angle,
float unit_mod);
139 template <
typename T>
151 template <
typename T>
166 template <
typename T>
169 float res = fmodf(static_cast<float>(radian),
M_2PI);
181 template <
typename T>
188 return (low + high) / 2;
214 static uint32_t m_z = 1234;
215 static uint32_t m_w = 76542;
216 m_z = 36969 * (m_z & 0xFFFFu) + (m_z >> 16);
217 m_w = 18000 * (m_w & 0xFFFFu) + (m_w >> 16);
218 return ((m_z << 16) + m_w) & 0xFFFF;
222 #if CONFIG_HAL_BOARD == HAL_BOARD_SITL 226 return ((((
unsigned)random()) % 2000000) - 1.0e6) / 1.0e6;
246 }
else if (octal % 10 > 7) {
248 }
else if ((octal % 100)/10 > 7) {
250 }
else if ((octal % 1000)/100 > 7) {
252 }
else if ((octal % 10000)/1000 > 7) {
template double constrain_value< double >(const double amt, const double low, const double high)
template float wrap_2PI< float >(const float radian)
template float safe_sqrt< float >(const float v)
Vector3< float > Vector3f
float safe_sqrt(const T v)
template float safe_asin< double >(const double v)
template float safe_sqrt< short >(const short v)
template float wrap_PI< int >(const int radian)
template float wrap_180< short >(const short angle, float unit_mod)
auto wrap_360_cd(const T angle) -> decltype(wrap_360(angle, 100.f))
template auto wrap_180_cd< int >(const int angle) -> decltype(wrap_180(angle, 100.f))
template float safe_asin< int >(const int v)
template auto wrap_180_cd< double >(const double angle) -> decltype(wrap_360(angle, 100.f))
bool is_valid_octal(uint16_t octal)
template float wrap_2PI< short >(const short radian)
template float safe_asin< short >(const short v)
auto wrap_180_cd(const T angle) -> decltype(wrap_180(angle, 100.f))
template bool is_equal< double >(const double v_1, const double v_2)
template float constrain_value< float >(const float amt, const float low, const float high)
template float wrap_360< double >(const double angle, float unit_mod)
uint16_t get_random16(void)
template auto wrap_360_cd< double >(const double angle) -> decltype(wrap_360(angle, 100.f))
template float safe_sqrt< double >(const double v)
template float wrap_360< float >(const float angle, float unit_mod)
template auto wrap_360_cd< short >(const short angle) -> decltype(wrap_360(angle, 100.f))
template bool is_equal< float >(const float v_1, const float v_2)
float linear_interpolate(float low_output, float high_output, float var_value, float var_low, float var_high)
float wrap_180(const T angle, float unit_mod)
float wrap_360(const T angle, float unit_mod)
template long constrain_value< long >(const long amt, const long low, const long high)
float wrap_PI(const T radian)
template float safe_sqrt< int >(const int v)
template float wrap_360< int >(const int angle, float unit_mod)
template float wrap_180< float >(const float angle, float unit_mod)
template float wrap_PI< double >(const double radian)
template float safe_asin< float >(const float v)
template auto wrap_360_cd< int >(const int angle) -> decltype(wrap_360(angle, 100.f))
template float wrap_PI< short >(const short radian)
template float wrap_360< short >(const short angle, float unit_mod)
template float wrap_360< long >(const long angle, float unit_mod)
float safe_asin(const T v)
template auto wrap_180_cd< long >(const long angle) -> decltype(wrap_180(angle, 100.f))
template auto wrap_180_cd< short >(const short angle) -> decltype(wrap_180(angle, 100.f))
template auto wrap_360_cd< float >(const float angle) -> decltype(wrap_360(angle, 100.f))
template short constrain_value< short >(const short amt, const short low, const short high)
float wrap_2PI(const T radian)
template bool is_equal< short >(const short v_1, const short v_2)
template float wrap_2PI< int >(const int radian)
std::enable_if< std::is_integral< typename std::common_type< Arithmetic1, Arithmetic2 >::type >::value,bool >::type is_equal(const Arithmetic1 v_1, const Arithmetic2 v_2)
template auto wrap_360_cd< long >(const long angle) -> decltype(wrap_360(angle, 100.f))
template auto wrap_180_cd< float >(const float angle) -> decltype(wrap_180(angle, 100.f))
template float wrap_PI< float >(const float radian)
Vector3f rand_vec3f(void)
template float wrap_180< double >(const double angle, float unit_mod)
template float wrap_2PI< double >(const double radian)
template float wrap_180< int >(const int angle, float unit_mod)
template int constrain_value< int >(const int amt, const int low, const int high)
template bool is_equal< long >(const long v_1, const long v_2)
template bool is_equal< int >(const int v_1, const int v_2)
T constrain_value(const T amt, const T low, const T high)