diff --git a/libraries/AP_Math/AP_Math.h b/libraries/AP_Math/AP_Math.h index dad56acd3f..1580c5228d 100644 --- a/libraries/AP_Math/AP_Math.h +++ b/libraries/AP_Math/AP_Math.h @@ -78,6 +78,27 @@ inline bool is_negative(const T fVal1) { } +/* + * @brief: Check whether a double is zero + */ +inline bool is_zero(const double fVal1) { + return (fabsf(fVal1) < static_cast(FLT_EPSILON)); +} + +/* + * @brief: Check whether a double is greater than zero + */ +inline bool is_positive(const double fVal1) { + return (fVal1 >= static_cast(FLT_EPSILON)); +} + +/* + * @brief: Check whether a double is less than zero + */ +inline bool is_negative(const double fVal1) { + return (fVal1 <= static_cast((-1.0 * FLT_EPSILON))); +} + /* * A variant of asin() that checks the input ranges and ensures a valid angle * as output. If nan is given as input then zero is returned.