sensorfw: filters/magcoordinatealignfilter/magcoordinatealignfilter.h Source File

sensorfw

magcoordinatealignfilter.h
Go to the documentation of this file.
1
27#ifndef MAGCOORDINATEALIGNFILTER_H
28#define MAGCOORDINATEALIGNFILTER_H
29
30#include "datatypes/orientationdata.h"
31#include "filter.h"
32
36 class TMagMatrix {
37private:
38 static const int DIM = 3;
39
40public:
41 TMagMatrix() {
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};
65 Q_DECLARE_METATYPE(TMagMatrix)
66
67
75class MagCoordinateAlignFilter : public QObject, public Filter<CalibratedMagneticFieldData, MagCoordinateAlignFilter, CalibratedMagneticFieldData>
76{
77 Q_OBJECT
78 Q_PROPERTY(TMagMatrix transMatrix READ matrix WRITE setMatrix)
79public:
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
93protected:
97 MagCoordinateAlignFilter();
98
99private:
100 void filter(unsigned, const CalibratedMagneticFieldData*);
101
102 TMagMatrix matrix_;
103};
104
105#endif // MagCoordinateAlignFilter_H
CalibratedMagneticFieldData
Datatype for calibrated magnetometer measurements.
Definition orientationdata.h:59
MagCoordinateAlignFilter
Coordinate alignment filter.
Definition magcoordinatealignfilter.h:76
MagCoordinateAlignFilter::MagCoordinateAlignFilter
MagCoordinateAlignFilter()
Constructor.
MagCoordinateAlignFilter::matrix
const TMagMatrix & matrix() const
Definition magcoordinatealignfilter.h:89
MagCoordinateAlignFilter::setMatrix
void setMatrix(const TMagMatrix &matrix)
Definition magcoordinatealignfilter.h:91
MagCoordinateAlignFilter::factoryMethod
static FilterBase * factoryMethod()
Factory method.
Definition magcoordinatealignfilter.h:85
TMagMatrix
TMagMatrix holds a transformation matrix.
Definition magcoordinatealignfilter.h:36
TMagMatrix::get
double get(int i, int j) const
Definition magcoordinatealignfilter.h:51
TMagMatrix::TMagMatrix
TMagMatrix(const TMagMatrix &other)
Definition magcoordinatealignfilter.h:44
TMagMatrix::data_
double data_[DIM][DIM]
Definition magcoordinatealignfilter.h:63
TMagMatrix::setMatrix
void setMatrix(const double m[DIM][DIM])
Definition magcoordinatealignfilter.h:59
TMagMatrix::TMagMatrix
TMagMatrix(double m[][DIM])
Definition magcoordinatealignfilter.h:47
TMagMatrix::TMagMatrix
TMagMatrix()
Definition magcoordinatealignfilter.h:41
Q_DECLARE_METATYPE
Q_DECLARE_METATYPE(TMatrix)
orientationdata.h
Datatypes for different filters.