[dali_2.3.21] Merge branch 'devel/master'
[platform/core/uifw/dali-toolkit.git] / dali-physics / third-party / bullet3 / src / LinearMath / btPolarDecomposition.h
1 #ifndef POLARDECOMPOSITION_H
2 #define POLARDECOMPOSITION_H
3
4 #include "btMatrix3x3.h"
5
6 /**
7  * This class is used to compute the polar decomposition of a matrix. In
8  * general, the polar decomposition factorizes a matrix, A, into two parts: a
9  * unitary matrix (U) and a positive, semi-definite Hermitian matrix (H).
10  * However, in this particular implementation the original matrix, A, is
11  * required to be a square 3x3 matrix with real elements. This means that U will
12  * be an orthogonal matrix and H with be a positive-definite, symmetric matrix.
13  */
14 class btPolarDecomposition
15 {
16 public:
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 = btScalar(0.0001),
26                                                  unsigned int maxIterations = 16);
27
28         /**
29      * Decomposes a matrix into orthogonal and symmetric, positive-definite
30      * parts. If the number of iterations returned by this function is equal to
31      * the maximum number of iterations, the algorithm has failed to converge.
32      *
33      * @param a - the original matrix
34      * @param u - the resulting orthogonal matrix
35      * @param h - the resulting symmetric matrix
36      *
37      * @return the number of iterations performed by the algorithm.
38      */
39         unsigned int decompose(const btMatrix3x3& a, btMatrix3x3& u, btMatrix3x3& h) const;
40
41         /**
42      * Returns the maximum number of iterations that this algorithm will perform
43      * to achieve convergence.
44      *
45      * @return maximum number of iterations
46      */
47         unsigned int maxIterations() const;
48
49 private:
50         btScalar m_tolerance;
51         unsigned int m_maxIterations;
52 };
53
54 /**
55  * This functions decomposes the matrix 'a' into two parts: an orthogonal matrix
56  * 'u' and a symmetric, positive-definite matrix 'h'. If the number of
57  * iterations returned by this function is equal to
58  * btPolarDecomposition::DEFAULT_MAX_ITERATIONS, the algorithm has failed to
59  * converge.
60  *
61  * @param a - the original matrix
62  * @param u - the resulting orthogonal matrix
63  * @param h - the resulting symmetric matrix
64  *
65  * @return the number of iterations performed by the algorithm.
66  */
67 unsigned int polarDecompose(const btMatrix3x3& a, btMatrix3x3& u, btMatrix3x3& h);
68
69 #endif  // POLARDECOMPOSITION_H