polar_svd.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2013 Alec Jacobson <[email protected]>
  4. //
  5. // This Source Code Form is subject to the terms of the Mozilla Public License
  6. // v. 2.0. If a copy of the MPL was not distributed with this file, You can
  7. // obtain one at http://mozilla.org/MPL/2.0/.
  8. #ifndef IGL_POLAR_SVD
  9. #define IGL_POLAR_SVD
  10. #include "igl_inline.h"
  11. #include <Eigen/Core>
  12. namespace igl
  13. {
  14. /// Computes the polar decomposition (R,T) of a matrix A using SVD singular
  15. /// value decomposition
  16. ///
  17. /// @param[in] A 3 by 3 matrix to be decomposed
  18. /// @param[in] includeReflections Whether to force R to be a rotation, or allow it to be a reflection
  19. /// @param[out] R 3 by 3 rotation matrix part of decomposition (**always rotataion**)
  20. /// @param[out] T 3 by 3 stretch matrix part of decomposition
  21. /// @param[out] U 3 by 3 left-singular vectors
  22. /// @param[out] S 3 by 1 singular values
  23. /// @param[out] V 3 by 3 right-singular vectors
  24. ///
  25. ///
  26. template <
  27. typename DerivedA,
  28. typename DerivedR,
  29. typename DerivedT,
  30. typename DerivedU,
  31. typename DerivedS,
  32. typename DerivedV>
  33. IGL_INLINE void polar_svd(
  34. const Eigen::MatrixBase<DerivedA> & A,
  35. bool includeReflections,
  36. Eigen::PlainObjectBase<DerivedR> & R,
  37. Eigen::PlainObjectBase<DerivedT> & T,
  38. Eigen::PlainObjectBase<DerivedU> & U,
  39. Eigen::PlainObjectBase<DerivedS> & S,
  40. Eigen::PlainObjectBase<DerivedV> & V);
  41. /// \overload
  42. template <
  43. typename DerivedA,
  44. typename DerivedR,
  45. typename DerivedT>
  46. IGL_INLINE void polar_svd(
  47. const Eigen::MatrixBase<DerivedA> & A,
  48. const bool includeReflections,
  49. Eigen::PlainObjectBase<DerivedR> & R,
  50. Eigen::PlainObjectBase<DerivedT> & T);
  51. /// \overload
  52. /// \brief For backward compatibility, these set includeReflections = false.
  53. template <
  54. typename DerivedA,
  55. typename DerivedR,
  56. typename DerivedT,
  57. typename DerivedU,
  58. typename DerivedS,
  59. typename DerivedV>
  60. IGL_INLINE void polar_svd(
  61. const Eigen::MatrixBase<DerivedA> & A,
  62. Eigen::PlainObjectBase<DerivedR> & R,
  63. Eigen::PlainObjectBase<DerivedT> & T,
  64. Eigen::PlainObjectBase<DerivedU> & U,
  65. Eigen::PlainObjectBase<DerivedS> & S,
  66. Eigen::PlainObjectBase<DerivedV> & V);
  67. /// \overload
  68. template <
  69. typename DerivedA,
  70. typename DerivedR,
  71. typename DerivedT>
  72. IGL_INLINE void polar_svd(
  73. const Eigen::MatrixBase<DerivedA> & A,
  74. Eigen::PlainObjectBase<DerivedR> & R,
  75. Eigen::PlainObjectBase<DerivedT> & T);
  76. }
  77. #ifndef IGL_STATIC_LIBRARY
  78. # include "polar_svd.cpp"
  79. #endif
  80. #endif