polar_dec.h 2.5 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_DEC
  9. #define IGL_POLAR_DEC
  10. #include "igl_inline.h"
  11. #include <Eigen/Core>
  12. namespace igl
  13. {
  14. /// Computes the polar decomposition (R,T) of a matrix A
  15. ///
  16. /// @param[in] A 3 by 3 matrix to be decomposed
  17. /// @param[in] includeReflections Whether to force R to be a rotation, or allow it to be a reflection
  18. /// @param[out] R 3 by 3 orthonormal matrix part of decomposition
  19. /// @param[out] T 3 by 3 stretch matrix part of decomposition
  20. /// @param[out] U 3 by 3 left-singular vectors
  21. /// @param[out] S 3 by 1 singular values
  22. /// @param[out] V 3 by 3 right-singular vectors
  23. ///
  24. ///
  25. template <
  26. typename DerivedA,
  27. typename DerivedR,
  28. typename DerivedT,
  29. typename DerivedU,
  30. typename DerivedS,
  31. typename DerivedV>
  32. IGL_INLINE void polar_dec(
  33. const Eigen::PlainObjectBase<DerivedA> & A,
  34. bool includeReflections,
  35. Eigen::PlainObjectBase<DerivedR> & R,
  36. Eigen::PlainObjectBase<DerivedT> & T,
  37. Eigen::PlainObjectBase<DerivedU> & U,
  38. Eigen::PlainObjectBase<DerivedS> & S,
  39. Eigen::PlainObjectBase<DerivedV> & V);
  40. /// \overload
  41. template <
  42. typename DerivedA,
  43. typename DerivedR,
  44. typename DerivedT>
  45. IGL_INLINE void polar_dec(
  46. const Eigen::PlainObjectBase<DerivedA> & A,
  47. const bool includeReflections,
  48. Eigen::PlainObjectBase<DerivedR> & R,
  49. Eigen::PlainObjectBase<DerivedT> & T);
  50. /// \overload
  51. /// \brief For backward compatibility, these set includeReflections = false.
  52. template <
  53. typename DerivedA,
  54. typename DerivedR,
  55. typename DerivedT,
  56. typename DerivedU,
  57. typename DerivedS,
  58. typename DerivedV>
  59. IGL_INLINE void polar_dec(
  60. const Eigen::PlainObjectBase<DerivedA> & A,
  61. Eigen::PlainObjectBase<DerivedR> & R,
  62. Eigen::PlainObjectBase<DerivedT> & T,
  63. Eigen::PlainObjectBase<DerivedU> & U,
  64. Eigen::PlainObjectBase<DerivedS> & S,
  65. Eigen::PlainObjectBase<DerivedV> & V);
  66. /// \overload
  67. template <
  68. typename DerivedA,
  69. typename DerivedR,
  70. typename DerivedT>
  71. IGL_INLINE void polar_dec(
  72. const Eigen::PlainObjectBase<DerivedA> & A,
  73. Eigen::PlainObjectBase<DerivedR> & R,
  74. Eigen::PlainObjectBase<DerivedT> & T);
  75. }
  76. #ifndef IGL_STATIC_LIBRARY
  77. # include "polar_dec.cpp"
  78. #endif
  79. #endif