mathlib: get rid of now duplicate sign() function

Instead use the one that was copied to the matrix library in
https://github.com/PX4/Matrix/pull/116/
This commit is contained in:
Matthias Grob
2020-03-17 10:01:42 +01:00
parent d313b0417a
commit eb3b0f6b55
9 changed files with 20 additions and 22 deletions
+3 -8
View File
@@ -41,16 +41,11 @@
#include "Limits.hpp"
#include <matrix/matrix/math.hpp>
namespace math
{
// Type-safe signum function
template<typename T>
int sign(T val)
{
return (T(FLT_EPSILON) < val) - (val < T(FLT_EPSILON));
}
// Type-safe signum function with zero treated as positive
template<typename T>
int signNoZero(T val)
@@ -114,7 +109,7 @@ const T deadzone(const T &value, const T &dz)
T x = constrain(value, (T) - 1, (T) 1);
T dzc = constrain(dz, (T) 0, (T) 0.99);
// Rescale the input such that we get a piecewise linear function that will be continuous with applied deadzone
T out = (x - sign(x) * dzc) / (1 - dzc);
T out = (x - matrix::sign(x) * dzc) / (1 - dzc);
// apply the deadzone (values zero around the middle)
return out * (fabsf(x) > dzc);
}