polar_svd.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2013 Alec Jacobson <alecjacobson@gmail.com>
  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. // Inputs:
  18. // A 3 by 3 matrix to be decomposed
  19. // Outputs:
  20. // R 3 by 3 rotation matrix part of decomposition (**always rotataion**)
  21. // T 3 by 3 stretch matrix part of decomposition
  22. // U 3 by 3 left-singular vectors
  23. // S 3 by 1 singular values
  24. // V 3 by 3 right-singular vectors
  25. //
  26. //
  27. template <
  28. typename DerivedA,
  29. typename DerivedR,
  30. typename DerivedT,
  31. typename DerivedU,
  32. typename DerivedS,
  33. typename DerivedV>
  34. IGL_INLINE void polar_svd(
  35. const Eigen::PlainObjectBase<DerivedA> & A,
  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. template <
  42. typename DerivedA,
  43. typename DerivedR,
  44. typename DerivedT>
  45. IGL_INLINE void polar_svd(
  46. const Eigen::PlainObjectBase<DerivedA> & A,
  47. Eigen::PlainObjectBase<DerivedR> & R,
  48. Eigen::PlainObjectBase<DerivedT> & T);
  49. }
  50. #ifndef IGL_STATIC_LIBRARY
  51. # include "polar_svd.cpp"
  52. #endif
  53. #endif