btPolarDecomposition.h 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. #ifndef POLARDECOMPOSITION_H
  2. #define POLARDECOMPOSITION_H
  3. #include "btMatrix3x3.h"
  4. /**
  5. * This class is used to compute the polar decomposition of a matrix. In
  6. * general, the polar decomposition factorizes a matrix, A, into two parts: a
  7. * unitary matrix (U) and a positive, semi-definite Hermitian matrix (H).
  8. * However, in this particular implementation the original matrix, A, is
  9. * required to be a square 3x3 matrix with real elements. This means that U will
  10. * be an orthogonal matrix and H with be a positive-definite, symmetric matrix.
  11. */
  12. class btPolarDecomposition
  13. {
  14. public:
  15. /**
  16. * Creates an instance with optional parameters.
  17. *
  18. * @param tolerance - the tolerance used to determine convergence of the
  19. * algorithm
  20. * @param maxIterations - the maximum number of iterations used to achieve
  21. * convergence
  22. */
  23. btPolarDecomposition(btScalar tolerance = btScalar(0.0001),
  24. unsigned int maxIterations = 16);
  25. /**
  26. * Decomposes a matrix into orthogonal and symmetric, positive-definite
  27. * parts. If the number of iterations returned by this function is equal to
  28. * the maximum number of iterations, the algorithm has failed to converge.
  29. *
  30. * @param a - the original matrix
  31. * @param u - the resulting orthogonal matrix
  32. * @param h - the resulting symmetric matrix
  33. *
  34. * @return the number of iterations performed by the algorithm.
  35. */
  36. unsigned int decompose(const btMatrix3x3& a, btMatrix3x3& u, btMatrix3x3& h) const;
  37. /**
  38. * Returns the maximum number of iterations that this algorithm will perform
  39. * to achieve convergence.
  40. *
  41. * @return maximum number of iterations
  42. */
  43. unsigned int maxIterations() const;
  44. private:
  45. btScalar m_tolerance;
  46. unsigned int m_maxIterations;
  47. };
  48. /**
  49. * This functions decomposes the matrix 'a' into two parts: an orthogonal matrix
  50. * 'u' and a symmetric, positive-definite matrix 'h'. If the number of
  51. * iterations returned by this function is equal to
  52. * btPolarDecomposition::DEFAULT_MAX_ITERATIONS, the algorithm has failed to
  53. * converge.
  54. *
  55. * @param a - the original matrix
  56. * @param u - the resulting orthogonal matrix
  57. * @param h - the resulting symmetric matrix
  58. *
  59. * @return the number of iterations performed by the algorithm.
  60. */
  61. unsigned int polarDecompose(const btMatrix3x3& a, btMatrix3x3& u, btMatrix3x3& h);
  62. #endif // POLARDECOMPOSITION_H