rotate_vectors.cpp 1.0 KB

1234567891011121314151617181920212223242526272829303132333435
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2014 Daniele Panozzo <daniele.panozzo@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 "rotate_vectors.h"
  9. IGL_INLINE Eigen::MatrixXd igl::rotate_vectors(
  10. const Eigen::MatrixXd& V,
  11. const Eigen::VectorXd& A,
  12. const Eigen::MatrixXd& B1,
  13. const Eigen::MatrixXd& B2)
  14. {
  15. Eigen::MatrixXd RV(V.rows(),V.cols());
  16. for (unsigned i=0; i<V.rows();++i)
  17. {
  18. // project onto the tangent plane and convert to angle
  19. double a = atan2(B2.row(i).dot(V.row(i)),B1.row(i).dot(V.row(i)));
  20. // rotate
  21. a += (A.size() == 1) ? A(0) : A(i);
  22. // move it back to global coordinates
  23. RV.row(i) = cos(a) * B1.row(i) + sin(a) * B2.row(i);
  24. }
  25. return RV;
  26. }
  27. #ifdef IGL_STATIC_LIBRARY
  28. // Explicit template specialization
  29. #endif