Changeset 5662 in orxonox.OLD for trunk/src/lib/math
- Timestamp:
- Nov 21, 2005, 3:10:20 AM (19 years ago)
- Location:
- trunk/src/lib/math
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/math/matrix.cc
r5661 r5662 2 2 #include <stdio.h> 3 3 #include <math.h> 4 #include "matrix.h" 4 5 5 void eigVl(float mat[3][3]) 6 7 class Vector 8 { 9 public: 10 Vector (float x, float y, float z) { this->x=x; this->y = y; this->z = z; }; 11 float x, y, z; 12 inline Vector cross (const Vector& v) const { return Vector(y * v.z - z * v.y, z * v.x - x * v.z, x * v.y - y * v.x ); } 13 }; 14 15 void Matrix::eigVl(const Matrix& mat) 6 16 { 7 17 … … 15 25 16 26 // c[0] is the determinante of mat 17 c[0] = mat[0][0] * mat[1][1] * mat[2][2]+18 2* mat[0][1] * mat[0][2] * mat[1][2]-19 mat[0][0] * mat[1][2] * mat[1][2]-20 mat[1][1] * mat[0][2] * mat[0][2]-21 mat[2][2] * mat[0][1] * mat[0][1];27 c[0] = this->m11 * this->m22 * this->m33 + 28 2* this->m12 * this->m13 * this->m23 - 29 this->m11 * this->m23 * this->m23 - 30 this->m22 * this->m13 * this->m13 - 31 this->m33 * this->m12 * this->m12; 22 32 23 33 // c[1] is the trace of a 24 c[1] = mat[0][0] * mat[1][1]-25 mat[0][1] * mat[0][1]+26 mat[0][0] * mat[2][2]-27 mat[0][2] * mat[0][2]+28 mat[1][1] * mat[2][2]-29 mat[1][2] * mat[1][2];34 c[1] = this->m11 * this->m22 - 35 this->m12 * this->m12 + 36 this->m11 * this->m33 - 37 this->m13 * this->m13 + 38 this->m22 * this->m33 - 39 this->m23 * this->m23; 30 40 31 41 // c[2] is the sum of the diagonal elements 32 c[2] = mat[0][0]+33 mat[1][1]+34 mat[2][2];42 c[2] = this->m11 + 43 this->m22 + 44 this->m33; 35 45 36 46 … … 41 51 float Q = b*b/4.0 + a*a*a/27.0; 42 52 53 // 3 distinct Roots 43 54 if (Q < 0) 44 55 { … … 54 65 55 66 } 67 // 2 Distinct Roots 56 68 else if (Q == 0) 57 69 { … … 60 72 eigValue[2] = c[2]/3.0 + 2* pow(b/2.0, 1.0/3.0); 61 73 } 74 // 1 Root (not calculating anything.) 62 75 else if (Q > 0) 63 76 { … … 66 79 } 67 80 68 printf("input: | %f | %f | %f |\n", mat[0][0], mat[0][1], mat[0][2] ); 69 printf(" | %f | %f | %f |\n", mat[1][0], mat[1][1], mat[1][2] ); 70 printf(" | %f | %f | %f |\n", mat[2][0], mat[2][1], mat[2][2] ); 81 Matrix M; 82 83 float u11, u12, u13, u22, u23, u33; 84 85 this->debug(); 71 86 72 87 printf("%f %f %f\n", eigValue[0], eigValue[1], eigValue[2]); 73 88 89 } 74 90 75 91 92 void Matrix::debug() const 93 { 94 printf("input: | %f | %f | %f |\n", this->m11, this->m12, this->m13 ); 95 printf(" | %f | %f | %f |\n", this->m21, this->m22, this->m23 ); 96 printf(" | %f | %f | %f |\n", this->m31, this->m32, this->m33 ); 76 97 77 98 } 99 -
trunk/src/lib/math/matrix.h
r5661 r5662 1 void eigVl(float mat[3][3]); 1 2 3 4 class Matrix 5 { 6 public: 7 float m11; float m12; float m13; 8 float m21; float m22; float m23; 9 float m31; float m32; float m33; 10 11 void eigVl(const Matrix& matrix); 12 void debug() const; 13 }; -
trunk/src/lib/math/vector.cc
r5420 r5662 22 22 23 23 #include "vector.h" 24 #ifdef DEBUG 24 25 #include "debug.h" 26 #else 27 #define PRINT(x) printf 28 #endif 25 29 26 30 using namespace std;
Note: See TracChangeset
for help on using the changeset viewer.