#ifndef GYROSCOPEDATA_H #define GYROSCOPEDATA_H #include #include /** * data received from a gyroscope sensor * IN RADIANS! */ struct GyroscopeData { float x; float y; float z; GyroscopeData() : x(0), y(0), z(0) {;} /** ctor from RADIANS */ GyroscopeData(const float x, const float y, const float z) : x(x), y(y), z(z) {;} float magnitude() const { return std::sqrt( x*x + y*y + z*z ); } std::string asString() const { std::stringstream ss; ss << "(" << x << "," << y << "," << z << ")"; return ss.str(); } bool isValid() const { return (x == x) && (y == y) && (z == z); } bool operator == (const GyroscopeData& o ) const { return EQ_OR_NAN(x, o.x) && EQ_OR_NAN(y, o.y) && EQ_OR_NAN(z, o.z); } private: static inline bool EQ_OR_NAN(const float a, const float b) {return (a==b) || ( (a!=a) && (b!=b) );} }; #endif // GYROSCOPEDATA_H