sensorfw
magcoordinatealignfilter.h
Go to the documentation of this file.
1 
27 #ifndef MAGCOORDINATEALIGNFILTER_H
28 #define MAGCOORDINATEALIGNFILTER_H
29 
31 #include "filter.h"
32 
36 class TMagMatrix {
37 private:
38  static const int DIM = 3;
39 
40 public:
42  setMatrix((const double[DIM][DIM]){{1,0,0},{0,1,0},{0,0,1}});
43  }
44  TMagMatrix(const TMagMatrix& other) {
45  setMatrix(other.data_);
46  }
47  TMagMatrix(double m[][DIM]) {
48  setMatrix(m);
49  }
50 
51  double get(int i, int j) const {
52  if (i >= DIM || j >= DIM || i < 0 || j < 0) {
53  qWarning("Index out of bounds");
54  return 0;
55  }
56  return data_[i][j];
57  };
58 
59  void setMatrix(const double m[DIM][DIM]) {
60  memcpy(data_, m, sizeof(double[DIM][DIM]));
61  }
62 
63  double data_[DIM][DIM];
64 };
66 
67 
76 {
77  Q_OBJECT
78  Q_PROPERTY(TMagMatrix transMatrix READ matrix WRITE setMatrix)
79 public:
80 
85  static FilterBase* factoryMethod() {
86  return new MagCoordinateAlignFilter;
87  }
88 
89  const TMagMatrix& matrix() const { return matrix_; }
90 
91  void setMatrix(const TMagMatrix& matrix) { matrix_ = matrix; }
92 
93 protected:
98 
99 private:
100  void filter(unsigned, const CalibratedMagneticFieldData*);
101 
102  TMagMatrix matrix_;
103 };
104 
105 #endif // MagCoordinateAlignFilter_H
Datatype for calibrated magnetometer measurements.
Coordinate alignment filter.
const TMagMatrix & matrix() const
MagCoordinateAlignFilter()
Constructor.
void setMatrix(const TMagMatrix &matrix)
static FilterBase * factoryMethod()
Factory method.
TMagMatrix holds a transformation matrix.
double get(int i, int j) const
TMagMatrix(const TMagMatrix &other)
double data_[DIM][DIM]
void setMatrix(const double m[DIM][DIM])
TMagMatrix(double m[][DIM])
Q_DECLARE_METATYPE(TMatrix)
Datatypes for different filters.