btPolarDecomposition.h 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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. static const btScalar DEFAULT_TOLERANCE;
  16. static const unsigned int DEFAULT_MAX_ITERATIONS;
  17. /**
  18. * Creates an instance with optional parameters.
  19. *
  20. * @param tolerance - the tolerance used to determine convergence of the
  21. * algorithm
  22. * @param maxIterations - the maximum number of iterations used to achieve
  23. * convergence
  24. */
  25. btPolarDecomposition(btScalar tolerance = DEFAULT_TOLERANCE,
  26. unsigned int maxIterations = DEFAULT_MAX_ITERATIONS);
  27. /**
  28. * Decomposes a matrix into orthogonal and symmetric, positive-definite
  29. * parts. If the number of iterations returned by this function is equal to
  30. * the maximum number of iterations, the algorithm has failed to converge.
  31. *
  32. * @param a - the original matrix
  33. * @param u - the resulting orthogonal matrix
  34. * @param h - the resulting symmetric matrix
  35. *
  36. * @return the number of iterations performed by the algorithm.
  37. */
  38. unsigned int decompose(const btMatrix3x3& a, btMatrix3x3& u, btMatrix3x3& h) const;
  39. /**
  40. * Returns the maximum number of iterations that this algorithm will perform
  41. * to achieve convergence.
  42. *
  43. * @return maximum number of iterations
  44. */
  45. unsigned int maxIterations() const;
  46. private:
  47. btScalar m_tolerance;
  48. unsigned int m_maxIterations;
  49. };
  50. /**
  51. * This functions decomposes the matrix 'a' into two parts: an orthogonal matrix
  52. * 'u' and a symmetric, positive-definite matrix 'h'. If the number of
  53. * iterations returned by this function is equal to
  54. * btPolarDecomposition::DEFAULT_MAX_ITERATIONS, the algorithm has failed to
  55. * converge.
  56. *
  57. * @param a - the original matrix
  58. * @param u - the resulting orthogonal matrix
  59. * @param h - the resulting symmetric matrix
  60. *
  61. * @return the number of iterations performed by the algorithm.
  62. */
  63. unsigned int polarDecompose(const btMatrix3x3& a, btMatrix3x3& u, btMatrix3x3& h);
  64. #endif // POLARDECOMPOSITION_H