sensorfw
|
00001 00027 #ifndef COORDINATEALIGNFILTER_H 00028 #define COORDINATEALIGNFILTER_H 00029 00030 #include "datatypes/orientationdata.h" 00031 #include "filter.h" 00032 00036 class TMatrix { 00037 private: 00038 static const int DIM = 3; 00039 00040 public: 00041 TMatrix() { 00042 setMatrix((const double[DIM][DIM]){{1,0,0},{0,1,0},{0,0,1}}); 00043 } 00044 TMatrix(const TMatrix& other) { 00045 setMatrix(other.data_); 00046 } 00047 TMatrix(double m[][DIM]) { 00048 setMatrix(m); 00049 } 00050 00051 double get(int i, int j) const { 00052 if (i >= DIM || j >= DIM || i < 0 || j < 0) { 00053 qWarning("Index out of bounds"); 00054 return 0; 00055 } 00056 return data_[i][j]; 00057 }; 00058 00059 void setMatrix(const double m[DIM][DIM]) { 00060 memcpy(data_, m, sizeof(double[DIM][DIM])); 00061 } 00062 00063 double data_[DIM][DIM]; 00064 }; 00065 Q_DECLARE_METATYPE(TMatrix); 00066 00075 class CoordinateAlignFilter : public QObject, public Filter<TimedXyzData, CoordinateAlignFilter, TimedXyzData> 00076 { 00077 Q_OBJECT; 00078 Q_PROPERTY(TMatrix transMatrix READ matrix WRITE setMatrix); 00079 public: 00080 00085 static FilterBase* factoryMethod() { 00086 return new CoordinateAlignFilter; 00087 } 00088 00089 const TMatrix& matrix() const { return matrix_; } 00090 00091 void setMatrix(const TMatrix& matrix) { matrix_ = matrix; } 00092 00093 protected: 00097 CoordinateAlignFilter(); 00098 00099 private: 00100 void filter(unsigned, const TimedXyzData*); 00101 00102 TMatrix matrix_; 00103 }; 00104 00105 #endif // COORDINATEALIGNFILTER_H