Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 5664 in orxonox.OLD for trunk/src


Ignore:
Timestamp:
Nov 21, 2005, 3:59:12 AM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: finished my work for today… but i am on to something here… the solution is not far, i can almost see it in the distance… now wait, i think it is the sun rising…

Location:
trunk/src/lib/math
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lib/math/matrix.cc

    r5663 r5664  
    44#include "matrix.h"
    55
    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 };
    146
    157void Matrix::eigVl(const Matrix& mat)
     
    7971  }
    8072
    81   Matrix M = *this -  Matrix::identity() * eigValue[0];
    8273
    83   float u11, u12, u13, u22, u23, u33;
     74  // EigenVectors
     75  for (int i = 0; i < 3; ++i)
     76  {
     77    printf (":: i = %d\n", i);
     78    Matrix M = *this -  Matrix::identity() * eigValue[i];
     79    Vector m1, m2, m3;
     80
     81    M.getTransposed().toVectors(m1, m2, m3);
     82
     83    Vector u1, u2, u3;
     84
     85    u1 = m2.cross(m3); u1 /= u1.len();
     86    u2 = m3.cross(m1); u2 /= u2.len();
     87    u3 = m1.cross(m2); u3 /= u3.len();
     88
     89    printf("%f, %f, %f\n", u1.x, u1.y, u1.z);
     90    printf("%f, %f, %f\n", u2.x, u2.y, u2.z);
     91    printf("%f, %f, %f\n", u3.x, u3.y, u3.z);
     92
     93//     u1 = M*u1;
     94//     u2 = M*u2;
     95//     u3 = M*u3;
     96//
     97//     printf("%f, %f, %f\n", u1.x, u1.y, u1.z);
     98//     printf("%f, %f, %f\n", u2.x, u2.y, u2.z);
     99//     printf("%f, %f, %f\n", u3.x, u3.y, u3.z);
     100//     printf("\n\n");
     101  }
    84102
    85103  this->debug();
  • trunk/src/lib/math/matrix.h

    r5663 r5664  
     1#include <math.h>
     2
     3/// @todo TAKE THIS OUT
     4class Vector
     5{
     6  public:
     7    Vector() {this->x = this->y = this->z = 0; };
     8    Vector (float x, float y, float z) { this->x=x; this->y = y; this->z = z; };
     9    inline const Vector& operator/= (float f) {if ((f == 0.0)) {this->x=0;this->y=0;this->z=0;} else {this->x /= f; this->y /= f; this->z /= f;} return *this; };
     10
     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    inline float len() const { return sqrt (x*x+y*y+z*z); }
     14};
    115
    216
     
    1327      this->m21 = m21; this->m22 = m22; this->m23 = m23;
    1428      this->m31 = m31; this->m32 = m32; this->m33 = m33;
    15     }
     29    };
    1630
    17     Matrix operator+ (const Matrix& m)
    18     {
     31    Matrix operator+ (const Matrix& m) {
    1932      return Matrix (this->m11 + m.m11, this->m12 + m.m12, this->m13 + m.m13,
    2033                     this->m21 + m.m21, this->m22 + m.m22, this->m23 + m.m23,
     
    2235    }
    2336
    24     Matrix operator- (const Matrix& m)
    25     {
     37    Matrix operator- (const Matrix& m) {
    2638      return Matrix (this->m11 - m.m11, this->m12 - m.m12, this->m13 - m.m13,
    2739                     this->m21 - m.m21, this->m22 - m.m22, this->m23 - m.m23,
     
    2941    }
    3042
    31     Matrix operator* (float k)
    32     {
     43    Matrix operator* (float k) {
    3344      return Matrix(this->m11 - k, this->m12 - k, this->m13 - k,
    3445                    this->m21 - k, this->m22 - k, this->m23 - k,
     
    3647    }
    3748
    38     static Matrix identity() {  return Matrix (1,0,0, 0,1,0, 0,0,1);    }
     49    Vector operator* (const Vector& v) {
     50      return Vector (this->m11*v.x + this->m12*v.y + this->m13*v.z,
     51                     this->m21*v.x + this->m22*v.y + this->m23*v.z,
     52                     this->m31*v.x + this->m32*v.y + this->m33*v.z );
     53
     54    }
     55
     56
     57    Matrix getTransposed() {
     58      return Matrix( this->m11, this->m21, this->m31,
     59                     this->m12, this->m22, this->m32,
     60                     this->m13, this->m23, this->m33);
     61    }
     62
     63    void toVectors(Vector& m1, Vector& m2, Vector& m3) {
     64      m1 = Vector(this->m11, this->m12, this->m13);
     65      m2 = Vector(this->m21, this->m22, this->m23);
     66      m3 = Vector(this->m31, this->m32, this->m33);
     67    }
     68
     69
     70    /// @todo optimize
     71    static Matrix identity() { return Matrix (1,0,0, 0,1,0, 0,0,1); }
    3972
    4073    void eigVl(const Matrix& matrix);
Note: See TracChangeset for help on using the changeset viewer.