column_to_quats.cpp 800 B

123456789101112131415161718192021222324252627
  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. #include "column_to_quats.h"
  9. IGL_INLINE bool igl::column_to_quats(
  10. const Eigen::VectorXd & Q,
  11. std::vector<
  12. Eigen::Quaterniond,Eigen::aligned_allocator<Eigen::Quaterniond> > & vQ)
  13. {
  14. using namespace Eigen;
  15. if(Q.size() % 4 != 0)
  16. {
  17. return false;
  18. }
  19. const int nQ = Q.size()/4;
  20. vQ.resize(nQ);
  21. for(int q=0;q<nQ;q++)
  22. {
  23. // Constructor uses wxyz
  24. vQ[q] = Quaterniond( Q(q*4+3), Q(q*4+0), Q(q*4+1), Q(q*4+2));
  25. }
  26. return true;
  27. }