polar_svd3x3.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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_SVD3X3_H
  9. #define IGL_POLAR_SVD3X3_H
  10. #include <Eigen/Core>
  11. #include "igl_inline.h"
  12. namespace igl
  13. {
  14. /// Computes the closest rotation to input matrix A using specialized 3x3 SVD
  15. /// singular value decomposition (WunderSVD3x3)
  16. ///
  17. /// @param[in] A 3 by 3 matrix to be decomposed
  18. /// @param[out] R 3 by 3 closest element in SO(3) (closeness in terms of Frobenius
  19. /// metric)
  20. ///
  21. /// This means that det(R) = 1. Technically it's not polar decomposition
  22. /// which guarantees positive semidefinite stretch factor (at the cost of
  23. /// having det(R) = -1). "• The orthogonal factors U and V will be true
  24. /// rotation matrices..." [McAdams, Selle, Tamstorf, Teran, Sefakis 2011]
  25. ///
  26. template<typename Mat>
  27. IGL_INLINE void polar_svd3x3(const Mat& A, Mat& R);
  28. #ifdef __SSE__
  29. /// \overload
  30. template<typename T>
  31. IGL_INLINE void polar_svd3x3_sse(const Eigen::Matrix<T, 3*4, 3>& A, Eigen::Matrix<T, 3*4, 3> &R);
  32. #endif
  33. #ifdef __AVX__
  34. /// \overload
  35. template<typename T>
  36. IGL_INLINE void polar_svd3x3_avx(const Eigen::Matrix<T, 3*8, 3>& A, Eigen::Matrix<T, 3*8, 3> &R);
  37. #endif
  38. }
  39. #ifndef IGL_STATIC_LIBRARY
  40. # include "polar_svd3x3.cpp"
  41. #endif
  42. #endif