mirror of
https://github.com/ArduPilot/ardupilot.git
synced 2026-02-06 14:32:14 +08:00
AP_Math: replace ALLOW_DOUBLE_MATH_FUNCTIONS with AP_MATH_ALLOW_DOUBLE_FUNCTIONS
.... and this one is always defined, so check for truth!
This commit is contained in:
committed by
Andrew Tridgell
parent
796aba44a7
commit
6a95df2f4e
@@ -25,7 +25,7 @@ template <typename Arithmetic1, typename Arithmetic2>
|
||||
typename std::enable_if<std::is_floating_point<typename std::common_type<Arithmetic1, Arithmetic2>::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<Arithmetic1, Arithmetic2>::type common_type;
|
||||
typedef typename std::remove_cv<common_type>::type common_type_nonconst;
|
||||
if (std::is_same<double, common_type_nonconst>::value) {
|
||||
@@ -169,7 +169,7 @@ T wrap_180_cd(const T angle)
|
||||
template int wrap_180<int>(const int angle);
|
||||
template short wrap_180<short>(const short angle);
|
||||
template float wrap_180<float>(const float angle);
|
||||
#ifdef ALLOW_DOUBLE_MATH_FUNCTIONS
|
||||
#if AP_MATH_ALLOW_DOUBLE_FUNCTIONS
|
||||
template double wrap_180<double>(const double angle);
|
||||
#endif
|
||||
|
||||
@@ -177,7 +177,7 @@ template int wrap_180_cd<int>(const int angle);
|
||||
template long wrap_180_cd<long>(const long angle);
|
||||
template short wrap_180_cd<short>(const short angle);
|
||||
template float wrap_180_cd<float>(const float angle);
|
||||
#ifdef ALLOW_DOUBLE_MATH_FUNCTIONS
|
||||
#if AP_MATH_ALLOW_DOUBLE_FUNCTIONS
|
||||
template double wrap_180_cd<double>(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);
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include <cmath>
|
||||
|
||||
#include <AP_HAL/AP_HAL_Boards.h>
|
||||
#include <AP_HAL/AP_HAL_Macros.h> // 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
|
||||
|
||||
|
||||
@@ -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 <AP_HAL/AP_HAL.h>
|
||||
#include <AP_Math/AP_Math.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<float>(x)) < FLT_EPSILON;
|
||||
|
||||
@@ -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 <AP_HAL/AP_HAL.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
Reference in New Issue
Block a user