2017-08-01 14:30:58 +02:00
|
|
|
#ifndef POLARDECOMPOSITION_H
|
|
|
|
#define POLARDECOMPOSITION_H
|
|
|
|
|
|
|
|
#include "btMatrix3x3.h"
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This class is used to compute the polar decomposition of a matrix. In
|
|
|
|
* general, the polar decomposition factorizes a matrix, A, into two parts: a
|
|
|
|
* unitary matrix (U) and a positive, semi-definite Hermitian matrix (H).
|
|
|
|
* However, in this particular implementation the original matrix, A, is
|
|
|
|
* required to be a square 3x3 matrix with real elements. This means that U will
|
|
|
|
* be an orthogonal matrix and H with be a positive-definite, symmetric matrix.
|
|
|
|
*/
|
|
|
|
class btPolarDecomposition
|
|
|
|
{
|
2019-01-03 14:26:51 +01:00
|
|
|
public:
|
|
|
|
/**
|
2017-08-01 14:30:58 +02:00
|
|
|
* Creates an instance with optional parameters.
|
|
|
|
*
|
|
|
|
* @param tolerance - the tolerance used to determine convergence of the
|
|
|
|
* algorithm
|
|
|
|
* @param maxIterations - the maximum number of iterations used to achieve
|
|
|
|
* convergence
|
|
|
|
*/
|
2019-01-03 14:26:51 +01:00
|
|
|
btPolarDecomposition(btScalar tolerance = btScalar(0.0001),
|
|
|
|
unsigned int maxIterations = 16);
|
2017-08-01 14:30:58 +02:00
|
|
|
|
2019-01-03 14:26:51 +01:00
|
|
|
/**
|
2017-08-01 14:30:58 +02:00
|
|
|
* Decomposes a matrix into orthogonal and symmetric, positive-definite
|
|
|
|
* parts. If the number of iterations returned by this function is equal to
|
|
|
|
* the maximum number of iterations, the algorithm has failed to converge.
|
|
|
|
*
|
|
|
|
* @param a - the original matrix
|
|
|
|
* @param u - the resulting orthogonal matrix
|
|
|
|
* @param h - the resulting symmetric matrix
|
|
|
|
*
|
|
|
|
* @return the number of iterations performed by the algorithm.
|
|
|
|
*/
|
2019-01-03 14:26:51 +01:00
|
|
|
unsigned int decompose(const btMatrix3x3& a, btMatrix3x3& u, btMatrix3x3& h) const;
|
2017-08-01 14:30:58 +02:00
|
|
|
|
2019-01-03 14:26:51 +01:00
|
|
|
/**
|
2017-08-01 14:30:58 +02:00
|
|
|
* Returns the maximum number of iterations that this algorithm will perform
|
|
|
|
* to achieve convergence.
|
|
|
|
*
|
|
|
|
* @return maximum number of iterations
|
|
|
|
*/
|
2019-01-03 14:26:51 +01:00
|
|
|
unsigned int maxIterations() const;
|
2017-08-01 14:30:58 +02:00
|
|
|
|
2019-01-03 14:26:51 +01:00
|
|
|
private:
|
|
|
|
btScalar m_tolerance;
|
|
|
|
unsigned int m_maxIterations;
|
2017-08-01 14:30:58 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This functions decomposes the matrix 'a' into two parts: an orthogonal matrix
|
|
|
|
* 'u' and a symmetric, positive-definite matrix 'h'. If the number of
|
|
|
|
* iterations returned by this function is equal to
|
|
|
|
* btPolarDecomposition::DEFAULT_MAX_ITERATIONS, the algorithm has failed to
|
|
|
|
* converge.
|
|
|
|
*
|
|
|
|
* @param a - the original matrix
|
|
|
|
* @param u - the resulting orthogonal matrix
|
|
|
|
* @param h - the resulting symmetric matrix
|
|
|
|
*
|
|
|
|
* @return the number of iterations performed by the algorithm.
|
|
|
|
*/
|
2019-01-03 14:26:51 +01:00
|
|
|
unsigned int polarDecompose(const btMatrix3x3& a, btMatrix3x3& u, btMatrix3x3& h);
|
2017-08-01 14:30:58 +02:00
|
|
|
|
2019-01-03 14:26:51 +01:00
|
|
|
#endif // POLARDECOMPOSITION_H
|