Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jun 14, 2005, 1:39:31 AM (19 years ago)
Author:
patrick
Message:

orxonox/trunk: trying to implement my own jacobi decomposition alg since the other once didn't work… shit

File:
1 edited

Legend:

Unmodified
Added
Removed
  • orxonox/trunk/src/lib/collision_detection/obb_tree_node.cc

    r4626 r4627  
    3636#include "newmatio.h"
    3737
     38#include "lin_alg.h"
     39
    3840
    3941
     
    101103  Vector    p, q, r;                                 //!< holder of the polygon data, much more conveniant to work with Vector than sVec3d
    102104  Vector    t1, t2;                                  //!< temporary values
    103   float     covariance[3][3];                        //!< the covariance matrix
     105  double    covariance[3][3];                        //!< the covariance matrix
    104106
    105107  this->numOfVertices = length;
     
    191193  Vector**              axis = new Vector*[3];                //!< the references to the obb axis
    192194
    193   C(1,1) = covariance[0][0];
    194   C(1,2) = covariance[0][1];
    195   C(1,3) = covariance[0][2];
    196   C(2,1) = covariance[1][0];
    197   C(2,2) = covariance[1][1];
    198   C(2,3) = covariance[1][2];
    199   C(3,1) = covariance[2][0];
    200   C(3,2) = covariance[2][1];
    201   C(3,3) = covariance[2][2];
     195
     196  double a[4][4];
     197
     198  a[0][0] = C(1,1) = covariance[0][0];
     199  a[0][1] = C(1,2) = covariance[0][1];
     200  a[0][2] = C(1,3) = covariance[0][2];
     201  a[1][0] = C(2,1) = covariance[1][0];
     202  a[1][1] = C(2,2) = covariance[1][1];
     203  a[1][2] = C(2,3) = covariance[1][2];
     204  a[2][0] = C(3,1) = covariance[2][0];
     205  a[2][1] = C(3,2) = covariance[2][1];
     206  a[2][2] = C(3,3) = covariance[2][2];
    202207
    203208  Jacobi(C, D, V);                                            /* do the jacobi decomposition */
    204209  PRINTF(0)("-- Done Jacobi Decomposition\n");
    205210
    206 //   printf("\nwe got a result! YES: \n");
    207 //
    208 //   for(int j = 1; j < 4; ++j)
    209 //   {
    210 //     printf(" |");
    211 //     for(int k = 1; k < 4; ++k)
    212 //     {
    213 //       printf(" \b%f ", V(j, k));
    214 //     }
    215 //     printf(" |\n");
    216 //   }
     211
     212  /* new jacobi tests */
     213  double eigenvectors[3][3];
     214  double eigval[3];
     215
     216  EVJacobi jac;
     217  jac.setMatrix(2, covariance, 0, 0);
     218  jac.getEigenVector(eigenvectors);
     219
     220
     221  printf("Old Jacobi\n");
     222  for(int j = 1; j < 4; ++j)
     223  {
     224    printf(" |");
     225    for(int k = 1; k < 4; ++k)
     226    {
     227      printf(" \b%f ", V(j, k));
     228    }
     229    printf(" |\n");
     230  }
     231
     232  printf("New Jacobi\n");
     233  for(int j = 0; j < 3; ++j)
     234  {
     235    printf(" |");
     236    for(int k = 0; k < 3; ++k)
     237    {
     238      printf(" \b%f ", eigenvectors[j][k]);
     239    }
     240    printf(" |\n");
     241  }
    217242
    218243  axis[0] = new Vector(V(1, 1), V(2, 1), V(3, 1));
Note: See TracChangeset for help on using the changeset viewer.