quaternion_common.hpp 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. /// @ref ext_quaternion_common
  2. /// @file glm/ext/quaternion_common.hpp
  3. ///
  4. /// @defgroup ext_quaternion_common GLM_EXT_quaternion_common
  5. /// @ingroup ext
  6. ///
  7. /// Provides common functions for quaternion types
  8. ///
  9. /// Include <glm/ext/quaternion_common.hpp> to use the features of this extension.
  10. ///
  11. /// @see ext_scalar_common
  12. /// @see ext_vector_common
  13. /// @see ext_quaternion_float
  14. /// @see ext_quaternion_double
  15. /// @see ext_quaternion_exponential
  16. /// @see ext_quaternion_geometric
  17. /// @see ext_quaternion_relational
  18. /// @see ext_quaternion_trigonometric
  19. /// @see ext_quaternion_transform
  20. #pragma once
  21. // Dependency:
  22. #include "../ext/scalar_constants.hpp"
  23. #include "../ext/quaternion_geometric.hpp"
  24. #include "../common.hpp"
  25. #include "../trigonometric.hpp"
  26. #include "../exponential.hpp"
  27. #include <limits>
  28. #if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED)
  29. # pragma message("GLM: GLM_EXT_quaternion_common extension included")
  30. #endif
  31. namespace glm
  32. {
  33. /// @addtogroup ext_quaternion_common
  34. /// @{
  35. /// Spherical linear interpolation of two quaternions.
  36. /// The interpolation is oriented and the rotation is performed at constant speed.
  37. /// For short path spherical linear interpolation, use the slerp function.
  38. ///
  39. /// @param x A quaternion
  40. /// @param y A quaternion
  41. /// @param a Interpolation factor. The interpolation is defined beyond the range [0, 1].
  42. ///
  43. /// @tparam T A floating-point scalar type
  44. /// @tparam Q A value from qualifier enum
  45. ///
  46. /// @see - slerp(qua<T, Q> const& x, qua<T, Q> const& y, T const& a)
  47. template<typename T, qualifier Q>
  48. GLM_FUNC_DECL qua<T, Q> mix(qua<T, Q> const& x, qua<T, Q> const& y, T a);
  49. /// Linear interpolation of two quaternions.
  50. /// The interpolation is oriented.
  51. ///
  52. /// @param x A quaternion
  53. /// @param y A quaternion
  54. /// @param a Interpolation factor. The interpolation is defined in the range [0, 1].
  55. ///
  56. /// @tparam T A floating-point scalar type
  57. /// @tparam Q A value from qualifier enum
  58. template<typename T, qualifier Q>
  59. GLM_FUNC_DECL qua<T, Q> lerp(qua<T, Q> const& x, qua<T, Q> const& y, T a);
  60. /// Spherical linear interpolation of two quaternions.
  61. /// The interpolation always take the short path and the rotation is performed at constant speed.
  62. ///
  63. /// @param x A quaternion
  64. /// @param y A quaternion
  65. /// @param a Interpolation factor. The interpolation is defined beyond the range [0, 1].
  66. ///
  67. /// @tparam T A floating-point scalar type
  68. /// @tparam Q A value from qualifier enum
  69. template<typename T, qualifier Q>
  70. GLM_FUNC_DECL qua<T, Q> slerp(qua<T, Q> const& x, qua<T, Q> const& y, T a);
  71. /// Spherical linear interpolation of two quaternions with multiple spins over rotation axis.
  72. /// The interpolation always take the short path when the spin count is positive and long path
  73. /// when count is negative. Rotation is performed at constant speed.
  74. ///
  75. /// @param x A quaternion
  76. /// @param y A quaternion
  77. /// @param a Interpolation factor. The interpolation is defined beyond the range [0, 1].
  78. /// @param k Additional spin count. If Value is negative interpolation will be on "long" path.
  79. ///
  80. /// @tparam T A floating-point scalar type
  81. /// @tparam S An integer scalar type
  82. /// @tparam Q A value from qualifier enum
  83. template<typename T, typename S, qualifier Q>
  84. GLM_FUNC_DECL qua<T, Q> slerp(qua<T, Q> const& x, qua<T, Q> const& y, T a, S k);
  85. /// Returns the q conjugate.
  86. ///
  87. /// @tparam T A floating-point scalar type
  88. /// @tparam Q A value from qualifier enum
  89. template<typename T, qualifier Q>
  90. GLM_FUNC_DECL qua<T, Q> conjugate(qua<T, Q> const& q);
  91. /// Returns the q inverse.
  92. ///
  93. /// @tparam T A floating-point scalar type
  94. /// @tparam Q A value from qualifier enum
  95. template<typename T, qualifier Q>
  96. GLM_FUNC_DECL qua<T, Q> inverse(qua<T, Q> const& q);
  97. /// Returns true if x holds a NaN (not a number)
  98. /// representation in the underlying implementation's set of
  99. /// floating point representations. Returns false otherwise,
  100. /// including for implementations with no NaN
  101. /// representations.
  102. ///
  103. /// /!\ When using compiler fast math, this function may fail.
  104. ///
  105. /// @tparam T A floating-point scalar type
  106. /// @tparam Q A value from qualifier enum
  107. template<typename T, qualifier Q>
  108. GLM_FUNC_DECL vec<4, bool, Q> isnan(qua<T, Q> const& x);
  109. /// Returns true if x holds a positive infinity or negative
  110. /// infinity representation in the underlying implementation's
  111. /// set of floating point representations. Returns false
  112. /// otherwise, including for implementations with no infinity
  113. /// representations.
  114. ///
  115. /// @tparam T A floating-point scalar type
  116. /// @tparam Q A value from qualifier enum
  117. template<typename T, qualifier Q>
  118. GLM_FUNC_DECL vec<4, bool, Q> isinf(qua<T, Q> const& x);
  119. /// @}
  120. } //namespace glm
  121. #include "quaternion_common.inl"