polar_svd3x3.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738
  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/igl_inline.h>
  12. namespace igl
  13. {
  14. // Computes the closest rotation to input matrix A using specialized 3x3 SVD singular value decomposition (WunderSVD3x3)
  15. // Inputs:
  16. // A 3 by 3 matrix to be decomposed
  17. // Outputs:
  18. // R 3 by 3 closest element in SO(3) (closeness in terms of Frobenius metric)
  19. //
  20. // This means that det(R) = 1. Technically it's not polar decomposition which guarantees positive semidefinite
  21. // stretch factor (at the cost of having det(R) = -1).
  22. //
  23. template<typename Mat>
  24. IGL_INLINE void polar_svd3x3(const Mat& A, Mat& R);
  25. #ifdef __SSE__
  26. template<typename T>
  27. IGL_INLINE void polar_svd3x3_sse(const Eigen::Matrix<T, 3*4, 3>& A, Eigen::Matrix<T, 3*4, 3> &R);
  28. #endif
  29. #ifdef __AVX__
  30. template<typename T>
  31. IGL_INLINE void polar_svd3x3_avx(const Eigen::Matrix<T, 3*8, 3>& A, Eigen::Matrix<T, 3*8, 3> &R);
  32. #endif
  33. }
  34. #ifdef IGL_HEADER_ONLY
  35. # include "polar_svd3x3.cpp"
  36. #endif
  37. #endif