two_axis_valuator_fixed_up.cpp 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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 "two_axis_valuator_fixed_up.h"
  9. #include "PI.h"
  10. IGL_INLINE void igl::two_axis_valuator_fixed_up(
  11. const int w,
  12. const int h,
  13. const double speed,
  14. const Eigen::Quaterniond & down_quat,
  15. const int down_x,
  16. const int down_y,
  17. const int mouse_x,
  18. const int mouse_y,
  19. Eigen::Quaterniond & quat)
  20. {
  21. using namespace Eigen;
  22. Vector3d axis(0,1,0);
  23. quat = down_quat *
  24. Quaterniond(
  25. AngleAxisd(
  26. PI*((double)(mouse_x-down_x))/(double)w*speed/2.0,
  27. axis.normalized()));
  28. quat.normalize();
  29. {
  30. Vector3d axis(1,0,0);
  31. if(axis.norm() != 0)
  32. {
  33. quat =
  34. Quaterniond(
  35. AngleAxisd(
  36. PI*(mouse_y-down_y)/(double)h*speed/2.0,
  37. axis.normalized())) * quat;
  38. quat.normalize();
  39. }
  40. }
  41. }