quaternion_common.hpp 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  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. /// Returns the q conjugate.
  72. ///
  73. /// @tparam T A floating-point scalar type
  74. /// @tparam Q A value from qualifier enum
  75. template<typename T, qualifier Q>
  76. GLM_FUNC_DECL qua<T, Q> conjugate(qua<T, Q> const& q);
  77. /// Returns the q inverse.
  78. ///
  79. /// @tparam T A floating-point scalar type
  80. /// @tparam Q A value from qualifier enum
  81. template<typename T, qualifier Q>
  82. GLM_FUNC_DECL qua<T, Q> inverse(qua<T, Q> const& q);
  83. /// Returns true if x holds a NaN (not a number)
  84. /// representation in the underlying implementation's set of
  85. /// floating point representations. Returns false otherwise,
  86. /// including for implementations with no NaN
  87. /// representations.
  88. ///
  89. /// /!\ When using compiler fast math, this function may fail.
  90. ///
  91. /// @tparam T A floating-point scalar type
  92. /// @tparam Q A value from qualifier enum
  93. template<typename T, qualifier Q>
  94. GLM_FUNC_DECL vec<4, bool, Q> isnan(qua<T, Q> const& x);
  95. /// Returns true if x holds a positive infinity or negative
  96. /// infinity representation in the underlying implementation's
  97. /// set of floating point representations. Returns false
  98. /// otherwise, including for implementations with no infinity
  99. /// representations.
  100. ///
  101. /// @tparam T A floating-point scalar type
  102. /// @tparam Q A value from qualifier enum
  103. template<typename T, qualifier Q>
  104. GLM_FUNC_DECL vec<4, bool, Q> isinf(qua<T, Q> const& x);
  105. /// @}
  106. } //namespace glm
  107. #include "quaternion_common.inl"