trackball.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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 identity
  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_mouse_x x position of mouse down
  12. // down_mouse_y y position of mouse down
  13. // mouse_x current x position of mouse
  14. // mouse_y current y position of mouse
  15. // Outputs:
  16. // quat the resulting rotation (as quaternion)
  17. template <typename Q_type>
  18. IGL_INLINE void trackball(
  19. const int w,
  20. const int h,
  21. const Q_type speed_factor,
  22. const int down_mouse_x,
  23. const int down_mouse_y,
  24. const int mouse_x,
  25. const int mouse_y,
  26. Q_type * quat);
  27. // Applies a trackball drag to a given rotation
  28. // Inputs:
  29. // w width of the trackball context
  30. // h height of the trackball context
  31. // speed_factor controls how fast the trackball feels, 1 is normal
  32. // down_quat rotation at mouse down, i.e. the rotation we're applying the
  33. // trackball motion to (as quaternion)
  34. // down_mouse_x x position of mouse down
  35. // down_mouse_y y position of mouse down
  36. // mouse_x current x position of mouse
  37. // mouse_y current y position of mouse
  38. // Outputs:
  39. // quat the resulting rotation (as quaternion)
  40. template <typename Q_type>
  41. IGL_INLINE void trackball(
  42. const int w,
  43. const int h,
  44. const Q_type speed_factor,
  45. const Q_type * down_quat,
  46. const int down_mouse_x,
  47. const int down_mouse_y,
  48. const int mouse_x,
  49. const int mouse_y,
  50. Q_type * quat);
  51. }
  52. #ifdef IGL_HEADER_ONLY
  53. # include "trackball.cpp"
  54. #endif
  55. #endif