two_axis_valuator_fixed_up.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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_TWO_AXIS_VALUATOR_FIXED_AXIS_UP_H
  9. #define IGL_TWO_AXIS_VALUATOR_FIXED_AXIS_UP_H
  10. #include "igl_inline.h"
  11. #include <Eigen/Core>
  12. #include <Eigen/Geometry>
  13. namespace igl
  14. {
  15. // Applies a two-axis valuator drag rotation (as seen in Maya/Studio max) to a given rotation.
  16. // Inputs:
  17. // w width of the trackball context
  18. // h height of the trackball context
  19. // speed controls how fast the trackball feels, 1 is normal
  20. // down_quat rotation at mouse down, i.e. the rotation we're applying the
  21. // trackball motion to (as quaternion). **Note:** Up-vector that is fixed
  22. // is with respect to this rotation.
  23. // down_x position of mouse down
  24. // down_y position of mouse down
  25. // mouse_x current x position of mouse
  26. // mouse_y current y position of mouse
  27. // Outputs:
  28. // quat the resulting rotation (as quaternion)
  29. //
  30. // See also: snap_to_fixed_up
  31. template <typename Scalardown_quat, typename Scalarquat>
  32. IGL_INLINE void two_axis_valuator_fixed_up(
  33. const int w,
  34. const int h,
  35. const double speed,
  36. const Eigen::Quaternion<Scalardown_quat> & down_quat,
  37. const int down_x,
  38. const int down_y,
  39. const int mouse_x,
  40. const int mouse_y,
  41. Eigen::Quaternion<Scalarquat> & quat);
  42. }
  43. #ifndef IGL_STATIC_LIBRARY
  44. # include "two_axis_valuator_fixed_up.cpp"
  45. #endif
  46. #endif