MathDefs.h
Go to the documentation of this file.
1 
15 #ifndef _SPLINEMATH
16 #define _SPLINEMATH
17 
18 #include <Eigen/Dense>
19 #include <Eigen/SVD>
20 
21 #include <vector>
22 #include <utility>
23 namespace curves {
25 template <typename _Matrix_Type_>
26 void PseudoInverse(_Matrix_Type_& pinvmat) {
27  Eigen::JacobiSVD<_Matrix_Type_> svd(pinvmat, Eigen::ComputeFullU | Eigen::ComputeFullV);
28  _Matrix_Type_ m_sigma = svd.singularValues();
29  double pinvtoler = 1.e-6; // choose your tolerance widely!
30  _Matrix_Type_ m_sigma_inv = _Matrix_Type_::Zero(pinvmat.cols(), pinvmat.rows());
31  for (long i = 0; i < m_sigma.rows(); ++i) {
32  if (m_sigma(i) > pinvtoler) {
33  m_sigma_inv(i, i) = 1.0 / m_sigma(i);
34  }
35  }
36  pinvmat = (svd.matrixV() * m_sigma_inv * svd.matrixU().transpose());
37 }
38 } // namespace curves
39 #endif //_SPLINEMATH
Definition: bernstein.h:20
void PseudoInverse(_Matrix_Type_ &pinvmat)
An inverse kinematics architecture enforcing an arbitrary number of strict priority levels (Reference...
Definition: MathDefs.h:26