polar_svd3x3.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  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
  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).
  26. //
  27. template<typename Mat>
  28. IGL_INLINE void polar_svd3x3(const Mat& A, Mat& R);
  29. #ifdef __SSE__
  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. template<typename T>
  35. IGL_INLINE void polar_svd3x3_avx(const Eigen::Matrix<T, 3*8, 3>& A, Eigen::Matrix<T, 3*8, 3> &R);
  36. #endif
  37. }
  38. #ifdef IGL_HEADER_ONLY
  39. # include "polar_svd3x3.cpp"
  40. #endif
  41. #endif