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 <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_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. // Inputs:
  18. // A 3 by 3 matrix to be decomposed
  19. // Outputs:
  20. // R 3 by 3 closest element in SO(3) (closeness in terms of Frobenius
  21. // metric)
  22. //
  23. // This means that det(R) = 1. Technically it's not polar decomposition
  24. // which guarantees positive semidefinite stretch factor (at the cost of
  25. // having det(R) = -1). "• The orthogonal factors U and V will be true
  26. // rotation matrices..." [McAdams, Selle, Tamstorf, Teran, Sefakis 2011]
  27. //
  28. template<typename Mat>
  29. IGL_INLINE void polar_svd3x3(const Mat& A, Mat& R);
  30. #ifdef __SSE__
  31. template<typename T>
  32. IGL_INLINE void polar_svd3x3_sse(const Eigen::Matrix<T, 3*4, 3>& A, Eigen::Matrix<T, 3*4, 3> &R);
  33. #endif
  34. #ifdef __AVX__
  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