mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-06-24 22:00:36 +08:00
Correct deg to rad conversion inversion. Add additional functionality to mathlib to allow standalone compile without Limits.cpp and Limits.hpp files from PX4.
This commit is contained in:
+22
-3
@@ -42,16 +42,35 @@
|
||||
|
||||
#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);
|
||||
}
|
||||
float math::radians(float degrees)
|
||||
|
||||
float radians(float degrees)
|
||||
{
|
||||
return (degrees / 180.0f) * M_PI_F;
|
||||
}
|
||||
float math::degrees(float radians)
|
||||
|
||||
float degrees(float radians)
|
||||
{
|
||||
return (radians * 180.0f) / M_PI_F;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user