diff --git a/libraries/AP_Math/AP_Math.cpp b/libraries/AP_Math/AP_Math.cpp index 646fab728f..04476a3b96 100644 --- a/libraries/AP_Math/AP_Math.cpp +++ b/libraries/AP_Math/AP_Math.cpp @@ -25,7 +25,7 @@ template typename std::enable_if::type>::value, bool>::type is_equal(const Arithmetic1 v_1, const Arithmetic2 v_2) { -#ifdef ALLOW_DOUBLE_MATH_FUNCTIONS +#if AP_MATH_ALLOW_DOUBLE_FUNCTIONS typedef typename std::common_type::type common_type; typedef typename std::remove_cv::type common_type_nonconst; if (std::is_same::value) { @@ -169,7 +169,7 @@ T wrap_180_cd(const T angle) template int wrap_180(const int angle); template short wrap_180(const short angle); template float wrap_180(const float angle); -#ifdef ALLOW_DOUBLE_MATH_FUNCTIONS +#if AP_MATH_ALLOW_DOUBLE_FUNCTIONS template double wrap_180(const double angle); #endif @@ -177,7 +177,7 @@ template int wrap_180_cd(const int angle); template long wrap_180_cd(const long angle); template short wrap_180_cd(const short angle); template float wrap_180_cd(const float angle); -#ifdef ALLOW_DOUBLE_MATH_FUNCTIONS +#if AP_MATH_ALLOW_DOUBLE_FUNCTIONS template double wrap_180_cd(const double angle); #endif @@ -190,7 +190,7 @@ float wrap_360(const float angle) return res; } -#ifdef ALLOW_DOUBLE_MATH_FUNCTIONS +#if AP_MATH_ALLOW_DOUBLE_FUNCTIONS double wrap_360(const double angle) { double res = fmod(angle, 360.0); @@ -219,7 +219,7 @@ float wrap_360_cd(const float angle) return res; } -#ifdef ALLOW_DOUBLE_MATH_FUNCTIONS +#if AP_MATH_ALLOW_DOUBLE_FUNCTIONS double wrap_360_cd(const double angle) { double res = fmod(angle, 36000.0); diff --git a/libraries/AP_Math/AP_Math.h b/libraries/AP_Math/AP_Math.h index 2a1984b0d7..fa54d18bb2 100644 --- a/libraries/AP_Math/AP_Math.h +++ b/libraries/AP_Math/AP_Math.h @@ -141,7 +141,7 @@ T wrap_180_cd(const T angle); * 100 == centi. */ float wrap_360(const float angle); -#ifdef ALLOW_DOUBLE_MATH_FUNCTIONS +#if AP_MATH_ALLOW_DOUBLE_FUNCTIONS double wrap_360(const double angle); #endif int wrap_360(const int angle); @@ -149,7 +149,7 @@ int wrap_360(const int angle); int wrap_360_cd(const int angle); long wrap_360_cd(const long angle); float wrap_360_cd(const float angle); -#ifdef ALLOW_DOUBLE_MATH_FUNCTIONS +#if AP_MATH_ALLOW_DOUBLE_FUNCTIONS double wrap_360_cd(const double angle); #endif diff --git a/libraries/AP_Math/definitions.h b/libraries/AP_Math/definitions.h index 5f2b8bc75d..f8a4a5c4f8 100644 --- a/libraries/AP_Math/definitions.h +++ b/libraries/AP_Math/definitions.h @@ -3,6 +3,7 @@ #include #include +#include // sets AP_MATH_ALLOW_DOUBLE_FUNCTIONS #ifdef M_PI # undef M_PI @@ -35,7 +36,7 @@ // GPS Specific double precision conversions // The precision here does matter when using the wsg* functions for converting // between LLH and ECEF coordinates. -#ifdef ALLOW_DOUBLE_MATH_FUNCTIONS +#if AP_MATH_ALLOW_DOUBLE_FUNCTIONS static const double DEG_TO_RAD_DOUBLE = asin(1) / 90; static const double RAD_TO_DEG_DOUBLE = 1 / DEG_TO_RAD_DOUBLE; #endif @@ -65,7 +66,7 @@ static const double WGS84_F = ((double)1.0 / WGS84_IF); static const double WGS84_B = (WGS84_A * (1 - WGS84_F)); // Eccentricity of the Earth -#ifdef ALLOW_DOUBLE_MATH_FUNCTIONS +#if AP_MATH_ALLOW_DOUBLE_FUNCTIONS static const double WGS84_E = (sqrt(2 * WGS84_F - WGS84_F * WGS84_F)); #endif diff --git a/libraries/AP_Math/examples/location/location.cpp b/libraries/AP_Math/examples/location/location.cpp index 414bece40f..c485626270 100644 --- a/libraries/AP_Math/examples/location/location.cpp +++ b/libraries/AP_Math/examples/location/location.cpp @@ -2,7 +2,7 @@ // Unit tests for the AP_Math polygon code // -#define ALLOW_DOUBLE_MATH_FUNCTIONS +#define AP_MATH_ALLOW_DOUBLE_FUNCTIONS 1 #include #include diff --git a/libraries/AP_Math/ftype.h b/libraries/AP_Math/ftype.h index 4f5f436a3b..0fac8cad3e 100644 --- a/libraries/AP_Math/ftype.h +++ b/libraries/AP_Math/ftype.h @@ -68,7 +68,7 @@ inline bool is_zero(const float x) { * @brief: Check whether a double is zero */ inline bool is_zero(const double x) { -#ifdef ALLOW_DOUBLE_MATH_FUNCTIONS +#if AP_MATH_ALLOW_DOUBLE_FUNCTIONS return fabs(x) < FLT_EPSILON; #else return fabsf(static_cast(x)) < FLT_EPSILON; diff --git a/libraries/AP_Math/location_double.cpp b/libraries/AP_Math/location_double.cpp index a6d24dc1b8..e894435c03 100644 --- a/libraries/AP_Math/location_double.cpp +++ b/libraries/AP_Math/location_double.cpp @@ -19,7 +19,7 @@ this is for double precision functions related to the location structure */ -#define ALLOW_DOUBLE_MATH_FUNCTIONS +#define AP_MATH_ALLOW_DOUBLE_FUNCTIONS 1 #include #include