Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 5668 in orxonox.OLD for trunk/src


Ignore:
Timestamp:
Nov 21, 2005, 11:51:29 AM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: two of 3 eigenvectors

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

Legend:

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

    r5667 r5668  
    55
    66
    7 Vector Matrix::eigenValues() const
     7Vector Matrix::getEigenValues() const
    88{
    99  Vector eigVl;
     
    6565  else if (Q > 0)
    6666  {
    67     printf("A is multiple of Identity matrix (lambda * I3))\n");
     67    printf("This Matrix is a multiple of the Identity matrix (lambda * I3))\n");
    6868    eigVl.x = eigVl.y = eigVl.z = 1;
    6969  }
     
    7373}
    7474
    75 void Matrix::eigenVectors(Vector& a, Vector& b, Vector& c) const
     75void Matrix::getEigenVectors(Vector& a, Vector& b, Vector& c) const
    7676{
    77   Vector eigVl = this->eigenValues();
     77  Vector eigVl = this->getEigenValues();
    7878
    79   float eigVc[9];
     79  float eigVal[3] = { eigVl.x, eigVl.y, eigVl.z };
     80
     81  Vector eigVc[3];
     82  /* eigenvec test */
     83  for(int i = 0; i < 3; i++)
     84  {
     85    eigVc[i].x = -1/this->m13*(this->m33 - eigVal[i]) + (this->m32*(-this->m31*this->m32 + this->m12*this->m33 - this->m12*eigVal[i])) /
     86        this->m13*(-this->m13*this->m22 - this->m12*this->m23 + this->m13*eigVal[i]);
     87
     88    eigVc[i].y = -( -this->m13*this->m23 + this->m12*this->m33 - this->m12*eigVal[i]) /
     89        (-this->m31*this->m22 + this->m12*this->m23 + this->m13*eigVal[i]);
     90
     91    eigVc[i].z = 1.0f;
     92
     93
     94    printf("home brew: %f, %f, %f\n", eigVc[i].x, eigVc[i].y, eigVc[i].z);
     95  }
     96
     97
    8098  // EigenVectors
    81   for (int i = 0; i < 3; ++i)
    82   {
    83     printf (":: i = %d\n", i);
    84     Matrix M = *this -  Matrix::identity() * eigVl.x;
    85     Vector m1, m2, m3;
     99//   for (int i = 0; i < 3; ++i)
     100//   {
     101//     printf (":: i = %d\n", i);
     102//     Matrix M = *this -  Matrix::identity() * eigVal[i];
     103//     Vector m1, m2, m3;
     104//
     105//     M.getTransposed().toVectors(m1, m2, m3);
     106//     Matrix U ( M.m22*M.m33 - M.m23*M.m23, M.m13*M.m23 - M.m12*M.m33, M.m12*M.m23 - M.m13*M.m22,
     107//                M.m13*M.m23 - M.m12*M.m33, M.m11*M.m33 - M.m13*M.m13, M.m12*M.m13 - M.m23*M.m11,
     108//                M.m12*M.m23 - M.m13*M.m22, M.m13*M.m12 - M.m23*M.m11, M.m11*M.m22 - M.m12*M.m12);
     109//     U.debug();
     110//
     111//     Vector u1, u2, u3;
     112//     U.toVectors(u1, u2, u3);
     113//
     114// /*
     115//     u1 = m2.cross(m3);
     116//     u2 = m3.cross(m1);
     117//     u3 = m1.cross(m2);
     118// */
     119//
     120//     u1 /= u1.len();
     121//     u2 /= u2.len();
     122//     u3 /= u3.len();
     123//
     124//
     125//     printf("%f, %f, %f\n", u1.x, u1.y, u1.z);
     126//     printf("%f, %f, %f\n", u2.x, u2.y, u2.z);
     127//     printf("%f, %f, %f\n", u3.x, u3.y, u3.z);
    86128
    87     M.getTransposed().toVectors(m1, m2, m3);
    88129
    89     Vector u1, u2, u3;
    90 
    91     u1 = m2.cross(m3); u1 /= u1.len();
    92     u2 = m3.cross(m1); u2 /= u2.len();
    93     u3 = m1.cross(m2); u3 /= u3.len();
    94 
    95     printf("%f, %f, %f\n", u1.x, u1.y, u1.z);
    96     printf("%f, %f, %f\n", u2.x, u2.y, u2.z);
    97     printf("%f, %f, %f\n", u3.x, u3.y, u3.z);
    98130
    99131//     u1 = M*u1;
     
    105137//     printf("%f, %f, %f\n", u3.x, u3.y, u3.z);
    106138//     printf("\n\n");
    107   }
    108 
    109   //Vector eigVc[3];
    110   /* eigenvec test */
    111   /*
    112   for(int i = 0; i < 3; i++)
    113   {
    114     eigVc[i].x =-1/this->m13*(this->m33 - eigValue[i]) + (this->m32*(-this->m31*this->m32 + this->m12*this->m33 - this->m12*eigVl[i])) /
    115         this->m13*(-this->m13*this->m22 - this->m12*this->m23 + this->m13*eigVl[i]);
    116     eigVc[i].y = -( -this->m13*this->m23 + this->m12*this->m33 - this->m12*eigVl[i]) /
    117         (-this->m31*this->m22 + this->m12*this->m23 + this->m13*eigVl[i]);
    118     eigVc[i].z = 1.0f;
    119 
    120 
    121     printf("home brewn: %f, %f, %f\n", eigVc[i].x, eigVc[i].y, eigVc[i].z);
    122 
    123 }*/
     139//  }
    124140
    125141
     
    128144}
    129145
    130 
    131146void Matrix::debug() const
    132147{
    133   printf("input: | %f | %f | %f |\n", this->m11, this->m12, this->m13 );
    134   printf("       | %f | %f | %f |\n", this->m21, this->m22, this->m23 );
    135   printf("       | %f | %f | %f |\n", this->m31, this->m32, this->m33 );
     148  printf("| %f | %f | %f |\n", this->m11, this->m12, this->m13 );
     149  printf("| %f | %f | %f |\n", this->m21, this->m22, this->m23 );
     150  printf("| %f | %f | %f |\n", this->m31, this->m32, this->m33 );
    136151
    137152}
  • trunk/src/lib/math/matrix.h

    r5665 r5668  
    5151                     this->m21*v.x + this->m22*v.y + this->m23*v.z,
    5252                     this->m31*v.x + this->m32*v.y + this->m33*v.z );
    53 
    5453    }
    5554
     
    6766    }
    6867
    69     Vector eigenValues() const;
    70     void eigenVectors(Vector& a, Vector& b, Vector& c) const;
     68    Vector getEigenValues() const;
     69    void getEigenVectors(Vector& a, Vector& b, Vector& c) const;
    7170
    7271    /// @todo optimize
  • trunk/src/lib/math/test.cc

    r5666 r5668  
    44int main (int argc, char** argv)
    55{
    6        
    7         Matrix matrix( 0,  1, -1,
    8                        1,  1,  0,
    9                       -1,  0,  1);
    106
    11         matrix.eigVl(matrix);
     7        Matrix matrix( 0,  1, -1,
     8                       1,  1,  0,
     9                      -1,  0,  1);
     10
     11        Vector eigVc[3];
     12
     13//        matrix.getEigenValues();
     14        matrix.getEigenVectors(eigVc[0], eigVc[1], eigVc[2]);
    1215}
    1316
Note: See TracChangeset for help on using the changeset viewer.