| [5673] | 1 | /*! | 
|---|
 | 2 |  * @file matrix.h | 
|---|
 | 3 |  * @brief Definition of a 3x3 matrix. | 
|---|
 | 4 |  */ | 
|---|
 | 5 |  | 
|---|
| [5664] | 6 | #include <math.h> | 
|---|
| [5673] | 7 | #include "vector.h" | 
|---|
| [5662] | 8 |  | 
|---|
 | 9 |  | 
|---|
 | 10 | class Matrix | 
|---|
 | 11 | { | 
|---|
| [5663] | 12 |  | 
|---|
| [5662] | 13 |   public: | 
|---|
| [5663] | 14 |     Matrix ( float m11, float m12, float m13, | 
|---|
 | 15 |              float m21, float m22, float m23, | 
|---|
 | 16 |              float m31, float m32, float m33 ) | 
|---|
 | 17 |     { | 
|---|
 | 18 |       this->m11 = m11; this->m12 = m12; this->m13 = m13; | 
|---|
 | 19 |       this->m21 = m21; this->m22 = m22; this->m23 = m23; | 
|---|
 | 20 |       this->m31 = m31; this->m32 = m32; this->m33 = m33; | 
|---|
| [5664] | 21 |     }; | 
|---|
| [5663] | 22 |  | 
|---|
| [5665] | 23 |     Matrix operator+ (const Matrix& m) const { | 
|---|
| [5663] | 24 |       return Matrix (this->m11 + m.m11, this->m12 + m.m12, this->m13 + m.m13, | 
|---|
 | 25 |                      this->m21 + m.m21, this->m22 + m.m22, this->m23 + m.m23, | 
|---|
 | 26 |                      this->m31 + m.m31, this->m32 + m.m32, this->m33 + m.m33); | 
|---|
 | 27 |     } | 
|---|
 | 28 |  | 
|---|
| [5665] | 29 |     Matrix operator- (const Matrix& m) const { | 
|---|
| [5663] | 30 |       return Matrix (this->m11 - m.m11, this->m12 - m.m12, this->m13 - m.m13, | 
|---|
 | 31 |                      this->m21 - m.m21, this->m22 - m.m22, this->m23 - m.m23, | 
|---|
 | 32 |                      this->m31 - m.m31, this->m32 - m.m32, this->m33 - m.m33); | 
|---|
 | 33 |     } | 
|---|
 | 34 |  | 
|---|
| [5665] | 35 |     Matrix operator* (float k) const { | 
|---|
| [5663] | 36 |       return Matrix(this->m11 - k, this->m12 - k, this->m13 - k, | 
|---|
 | 37 |                     this->m21 - k, this->m22 - k, this->m23 - k, | 
|---|
 | 38 |                     this->m31 - k, this->m32 - k, this->m33 - k); | 
|---|
 | 39 |     } | 
|---|
 | 40 |  | 
|---|
| [5665] | 41 |     Vector operator* (const Vector& v) const { | 
|---|
| [5664] | 42 |       return Vector (this->m11*v.x + this->m12*v.y + this->m13*v.z, | 
|---|
 | 43 |                      this->m21*v.x + this->m22*v.y + this->m23*v.z, | 
|---|
 | 44 |                      this->m31*v.x + this->m32*v.y + this->m33*v.z ); | 
|---|
 | 45 |     } | 
|---|
 | 46 |  | 
|---|
 | 47 |  | 
|---|
| [5665] | 48 |     Matrix getTransposed() const { | 
|---|
| [5664] | 49 |       return Matrix( this->m11, this->m21, this->m31, | 
|---|
 | 50 |                      this->m12, this->m22, this->m32, | 
|---|
 | 51 |                      this->m13, this->m23, this->m33); | 
|---|
 | 52 |     } | 
|---|
 | 53 |  | 
|---|
| [5665] | 54 |     void toVectors(Vector& m1, Vector& m2, Vector& m3) const { | 
|---|
| [5664] | 55 |       m1 = Vector(this->m11, this->m12, this->m13); | 
|---|
 | 56 |       m2 = Vector(this->m21, this->m22, this->m23); | 
|---|
 | 57 |       m3 = Vector(this->m31, this->m32, this->m33); | 
|---|
 | 58 |     } | 
|---|
 | 59 |  | 
|---|
| [5675] | 60 |     int getEigenValues(Vector& eigenVectors) const; | 
|---|
| [5668] | 61 |     void getEigenVectors(Vector& a, Vector& b, Vector& c) const; | 
|---|
| [5664] | 62 |  | 
|---|
 | 63 |     /// @todo optimize | 
|---|
 | 64 |     static Matrix identity() { return Matrix (1,0,0, 0,1,0, 0,0,1); } | 
|---|
 | 65 |  | 
|---|
| [5663] | 66 |     void debug() const; | 
|---|
 | 67 |  | 
|---|
 | 68 |  | 
|---|
 | 69 |   public: | 
|---|
| [5662] | 70 |     float m11;    float m12;     float m13; | 
|---|
 | 71 |     float m21;    float m22;     float m23; | 
|---|
 | 72 |     float m31;    float m32;     float m33; | 
|---|
 | 73 |  | 
|---|
 | 74 | }; | 
|---|