column_to_quats.cpp 782 B

1234567891011121314151617181920212223242526
  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. #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. if(Q.size() % 4 != 0)
  15. {
  16. return false;
  17. }
  18. const int nQ = Q.size()/4;
  19. vQ.resize(nQ);
  20. for(int q=0;q<nQ;q++)
  21. {
  22. // Constructor uses wxyz
  23. vQ[q] = Eigen::Quaterniond( Q(q*4+3), Q(q*4+0), Q(q*4+1), Q(q*4+2));
  24. }
  25. return true;
  26. }