trackball.h 1020 B

12345678910111213141516171819202122232425262728293031323334353637
  1. #ifndef IGL_TRACKBALL_H
  2. #define IGL_TRACKBALL_H
  3. #include "igl_inline.h"
  4. namespace igl
  5. {
  6. // Applies a trackball drag to a given rotation
  7. // Inputs:
  8. // w width of the trackball context
  9. // h height of the trackball context
  10. // speed_factor controls how fast the trackball feels, 1 is normal
  11. // down_quat rotation at mouse down, i.e. the rotation we're applying the
  12. // trackball motion to (as quaternion)
  13. // down_mouse_x x position of mouse down
  14. // down_mouse_y y position of mouse down
  15. // mouse_x current x position of mouse
  16. // mouse_y current y position of mouse
  17. // Outputs:
  18. // quat the resulting rotation (as quaternion)
  19. template <typename Q_type>
  20. IGL_INLINE void trackball(
  21. const int w,
  22. const int h,
  23. const Q_type speed_factor,
  24. const Q_type * down_quat,
  25. const int down_mouse_x,
  26. const int down_mouse_y,
  27. const int mouse_x,
  28. const int mouse_y,
  29. Q_type * quat);
  30. }
  31. #ifdef IGL_HEADER_ONLY
  32. # include "trackball.cpp"
  33. #endif
  34. #endif