OpenIndy-Core  0.2.0.43
oimat.h
Go to the documentation of this file.
1 #ifndef OIMAT_H
2 #define OIMAT_H
3 
4 #include <vector>
5 #include <stdexcept>
6 
7 #include "global.h"
8 
9 namespace oi{
10 namespace math{
11 
12 class LinearAlgebra;
13 class OiVec;
14 
15 using namespace std;
16 
22 
26  Z_AXIS
27  };
28 
29  Rotation(double angle, RotationAxis axis){
30  this->angle = angle;
31  this->axis = axis;
32  }
33 
35  double angle;
36 
37 };
38 
43 
44 public:
45  void clear(){ this->myRotations.clear(); }
46  void appendRotation(Rotation r){ this->myRotations.push_back(r); }
47  int getRotationCount(){ return this->myRotations.size(); }
48  Rotation getRotationAt(int index){ return this->myRotations.at(index); }
49 
50 private:
51  vector<Rotation> myRotations;
52 
53 };
54 
59 {
60 public:
61  OiMat();
62  OiMat(const int &rows, const int &cols);
63 
65 
66 private:
67  vector<double> values;
68  int rows, cols;
69 
70 public:
71 
72  double getAt(const int &row, const int &col) const;
73  unsigned int getRowCount() const;
74  unsigned int getColCount() const;
75  void getRow(OiVec &result, const int &row) const;
76  void getCol(OiVec &result, const int &col) const;
77 
78  void replace(const OiMat &m);
79  void setAt(const int &row, const int &col, const double &value);
80  void diag(vector<double> diagVec);
81  void setRow(const int &index, const OiVec &row);
82  void setCol(const int &index, const OiVec &col);
83 
84  OiMat& operator=(const OiMat &m);
85  OiMat operator+(const OiMat &m) const;
86  OiMat operator-(const OiMat &m) const;
87  OiMat& operator+=(const OiMat &m);
88  OiMat& operator-=(const OiMat &m);
89  OiMat operator*(const OiMat &m) const;
90  OiMat operator*(const double &value) const;
91  OiVec operator*(const OiVec &v) const;
92  friend OiMat operator*(const double &value, const OiMat &m){
93  OiMat result(m.getRowCount(), m.getColCount());
94  OiMat::mult(result, value, m);
95  return result;
96  }
97  friend OiMat operator/(const OiMat &m, const double &value){
98  OiMat result(m.getRowCount(), m.getColCount());
99  OiMat::mult(result, (1.0 / value), m);
100  return result;
101  }
102 
103  OiMat t() const;
104  OiMat inv() const;
105 
106  double det() const;
107 
108  void svd(OiMat &u, OiVec &d, OiMat &v) const;
109 
110  static bool solve(OiVec &x, const OiMat &A, const OiVec &b);
111  static bool solve(OiMat &X, const OiMat &A, const OiMat &B);
112 
113  static OiMat getRotationMatrix(double angle, OiVec axis);
114  static OiMat getRotationMatrix(double angle, Rotation::RotationAxis axis);
115  static OiMat getRotationMatrix(RotationChain rotationChain);
116 
117 private:
118  static void mult(OiMat &result, const double &value, const OiMat &m);
119 
120 };
121 
122 }
123 }
124 
125 #endif // OIMAT_H
unsigned int getColCount() const
OiMat::getColCount.
Definition: oimat.cpp:51
void appendRotation(Rotation r)
Definition: oimat.h:46
RotationAxis
Definition: oimat.h:23
The OiVec class.
Definition: oivec.h:22
Definition: coordinatesystem.h:15
void clear()
Definition: oimat.h:45
The RotationChain class.
Definition: oimat.h:42
int getRotationCount()
Definition: oimat.h:47
The OiMat class.
Definition: oimat.h:58
The Rotation struct Struct that represents a rotation around one of the three coordinate axes...
Definition: oimat.h:21
Rotation getRotationAt(int index)
Definition: oimat.h:48
friend OiMat operator/(const OiMat &m, const double &value)
Definition: oimat.h:97
The LinearAlgebra class.
Definition: linearalgebra.h:15
unsigned int getRowCount() const
OiMat::getRowCount.
Definition: oimat.cpp:43
Rotation(double angle, RotationAxis axis)
Definition: oimat.h:29
RotationAxis axis
Definition: oimat.h:34
double angle
Definition: oimat.h:35
Definition: oimat.h:25
#define OI_MATH_EXPORT
Definition: global.h:9
static LinearAlgebra * myLinearAlgebra
Definition: oimat.h:64
Definition: oimat.h:24
friend OiMat operator*(const double &value, const OiMat &m)
Definition: oimat.h:92