mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-30 04:33:34 +08:00
Merge pull request #73 from mcsauder/master
Conversion error correction and additional function overloads to allow standalone compilation.
This commit is contained in:
@@ -55,8 +55,8 @@
|
|||||||
#define CONSTANTS_RADIUS_OF_EARTH 6371000 /* meters (m) */
|
#define CONSTANTS_RADIUS_OF_EARTH 6371000 /* meters (m) */
|
||||||
#define M_TWOPI_F 6.28318530717958647692f
|
#define M_TWOPI_F 6.28318530717958647692f
|
||||||
#define M_PI_2_F 1.57079632679489661923f
|
#define M_PI_2_F 1.57079632679489661923f
|
||||||
#define M_RAD_TO_DEG 0.01745329251994329576f
|
#define M_RAD_TO_DEG 57.29577951308232087679f
|
||||||
#define M_DEG_TO_RAD 57.29577951308232087679f
|
#define M_DEG_TO_RAD 0.01745329251994329576f
|
||||||
#define OK 0
|
#define OK 0
|
||||||
#define ERROR -1
|
#define ERROR -1
|
||||||
// XXX remove
|
// XXX remove
|
||||||
|
|||||||
+22
-3
@@ -42,16 +42,35 @@
|
|||||||
|
|
||||||
#ifdef POSIX_SHARED
|
#ifdef POSIX_SHARED
|
||||||
|
|
||||||
float math::constrain(float &val, float min, float max)
|
|
||||||
|
namespace math
|
||||||
|
{
|
||||||
|
|
||||||
|
float min(float val1, float val2)
|
||||||
|
{
|
||||||
|
return (val1 < val2) ? val1 : val2;
|
||||||
|
}
|
||||||
|
|
||||||
|
float max(float val1, float val2)
|
||||||
|
{
|
||||||
|
return (val1 > val2) ? val1 : val2;
|
||||||
|
}
|
||||||
|
|
||||||
|
float constrain(float &val, float min, float max)
|
||||||
{
|
{
|
||||||
return (val < min) ? min : ((val > max) ? max : val);
|
return (val < min) ? min : ((val > max) ? max : val);
|
||||||
}
|
}
|
||||||
float math::radians(float degrees)
|
|
||||||
|
float radians(float degrees)
|
||||||
{
|
{
|
||||||
return (degrees / 180.0f) * M_PI_F;
|
return (degrees / 180.0f) * M_PI_F;
|
||||||
}
|
}
|
||||||
float math::degrees(float radians)
|
|
||||||
|
float degrees(float radians)
|
||||||
{
|
{
|
||||||
return (radians * 180.0f) / M_PI_F;
|
return (radians * 180.0f) / M_PI_F;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -50,9 +50,12 @@ namespace math
|
|||||||
using namespace Eigen;
|
using namespace Eigen;
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
float min(float val1, float val2);
|
||||||
|
float max(float val1, float val2);
|
||||||
float constrain(float &val, float min, float max);
|
float constrain(float &val, float min, float max);
|
||||||
float radians(float degrees);
|
float radians(float degrees);
|
||||||
float degrees(float radians);
|
float degrees(float radians);
|
||||||
|
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
#include <mathlib/mathlib.h>
|
#include <mathlib/mathlib.h>
|
||||||
|
|||||||
Reference in New Issue
Block a user