9
3

quaternion.hpp 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. /// @ref gtc_quaternion
  2. /// @file glm/gtc/quaternion.hpp
  3. ///
  4. /// @see core (dependence)
  5. /// @see gtc_constants (dependence)
  6. ///
  7. /// @defgroup gtc_quaternion GLM_GTC_quaternion
  8. /// @ingroup gtc
  9. ///
  10. /// Include <glm/gtc/quaternion.hpp> to use the features of this extension.
  11. ///
  12. /// Defines a templated quaternion type and several quaternion operations.
  13. #pragma once
  14. // Dependency:
  15. #include "../gtc/constants.hpp"
  16. #include "../gtc/matrix_transform.hpp"
  17. #include "../ext/vector_relational.hpp"
  18. #include "../ext/quaternion_common.hpp"
  19. #include "../ext/quaternion_float.hpp"
  20. #include "../ext/quaternion_float_precision.hpp"
  21. #include "../ext/quaternion_double.hpp"
  22. #include "../ext/quaternion_double_precision.hpp"
  23. #include "../ext/quaternion_relational.hpp"
  24. #include "../ext/quaternion_geometric.hpp"
  25. #include "../ext/quaternion_trigonometric.hpp"
  26. #include "../ext/quaternion_transform.hpp"
  27. #include "../detail/type_mat3x3.hpp"
  28. #include "../detail/type_mat4x4.hpp"
  29. #include "../detail/type_vec3.hpp"
  30. #include "../detail/type_vec4.hpp"
  31. #if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED)
  32. # pragma message("GLM: GLM_GTC_quaternion extension included")
  33. #endif
  34. namespace glm
  35. {
  36. /// @addtogroup gtc_quaternion
  37. /// @{
  38. /// Returns euler angles, pitch as x, yaw as y, roll as z.
  39. /// The result is expressed in radians.
  40. ///
  41. /// @tparam T Floating-point scalar types.
  42. ///
  43. /// @see gtc_quaternion
  44. template<typename T, qualifier Q>
  45. GLM_FUNC_DECL vec<3, T, Q> eulerAngles(qua<T, Q> const& x);
  46. /// Returns roll value of euler angles expressed in radians.
  47. ///
  48. /// @tparam T Floating-point scalar types.
  49. ///
  50. /// @see gtc_quaternion
  51. template<typename T, qualifier Q>
  52. GLM_FUNC_DECL T roll(qua<T, Q> const& x);
  53. /// Returns pitch value of euler angles expressed in radians.
  54. ///
  55. /// @tparam T Floating-point scalar types.
  56. ///
  57. /// @see gtc_quaternion
  58. template<typename T, qualifier Q>
  59. GLM_FUNC_DECL T pitch(qua<T, Q> const& x);
  60. /// Returns yaw value of euler angles expressed in radians.
  61. ///
  62. /// @tparam T Floating-point scalar types.
  63. ///
  64. /// @see gtc_quaternion
  65. template<typename T, qualifier Q>
  66. GLM_FUNC_DECL T yaw(qua<T, Q> const& x);
  67. /// Converts a quaternion to a 3 * 3 matrix.
  68. ///
  69. /// @tparam T Floating-point scalar types.
  70. ///
  71. /// @see gtc_quaternion
  72. template<typename T, qualifier Q>
  73. GLM_FUNC_DECL mat<3, 3, T, Q> mat3_cast(qua<T, Q> const& x);
  74. /// Converts a quaternion to a 4 * 4 matrix.
  75. ///
  76. /// @tparam T Floating-point scalar types.
  77. ///
  78. /// @see gtc_quaternion
  79. template<typename T, qualifier Q>
  80. GLM_FUNC_DECL mat<4, 4, T, Q> mat4_cast(qua<T, Q> const& x);
  81. /// Converts a pure rotation 3 * 3 matrix to a quaternion.
  82. ///
  83. /// @tparam T Floating-point scalar types.
  84. ///
  85. /// @see gtc_quaternion
  86. template<typename T, qualifier Q>
  87. GLM_FUNC_DECL qua<T, Q> quat_cast(mat<3, 3, T, Q> const& x);
  88. /// Converts a pure rotation 4 * 4 matrix to a quaternion.
  89. ///
  90. /// @tparam T Floating-point scalar types.
  91. ///
  92. /// @see gtc_quaternion
  93. template<typename T, qualifier Q>
  94. GLM_FUNC_DECL qua<T, Q> quat_cast(mat<4, 4, T, Q> const& x);
  95. /// Returns the component-wise comparison result of x < y.
  96. ///
  97. /// @tparam T Floating-point scalar types
  98. /// @tparam Q Value from qualifier enum
  99. ///
  100. /// @see ext_quaternion_relational
  101. template<typename T, qualifier Q>
  102. GLM_FUNC_DECL vec<4, bool, Q> lessThan(qua<T, Q> const& x, qua<T, Q> const& y);
  103. /// Returns the component-wise comparison of result x <= y.
  104. ///
  105. /// @tparam T Floating-point scalar types
  106. /// @tparam Q Value from qualifier enum
  107. ///
  108. /// @see ext_quaternion_relational
  109. template<typename T, qualifier Q>
  110. GLM_FUNC_DECL vec<4, bool, Q> lessThanEqual(qua<T, Q> const& x, qua<T, Q> const& y);
  111. /// Returns the component-wise comparison of result x > y.
  112. ///
  113. /// @tparam T Floating-point scalar types
  114. /// @tparam Q Value from qualifier enum
  115. ///
  116. /// @see ext_quaternion_relational
  117. template<typename T, qualifier Q>
  118. GLM_FUNC_DECL vec<4, bool, Q> greaterThan(qua<T, Q> const& x, qua<T, Q> const& y);
  119. /// Returns the component-wise comparison of result x >= y.
  120. ///
  121. /// @tparam T Floating-point scalar types
  122. /// @tparam Q Value from qualifier enum
  123. ///
  124. /// @see ext_quaternion_relational
  125. template<typename T, qualifier Q>
  126. GLM_FUNC_DECL vec<4, bool, Q> greaterThanEqual(qua<T, Q> const& x, qua<T, Q> const& y);
  127. /// Build a look at quaternion based on the default handedness.
  128. ///
  129. /// @param direction Desired forward direction. Needs to be normalized.
  130. /// @param up Up vector, how the camera is oriented. Typically (0, 1, 0).
  131. template<typename T, qualifier Q>
  132. GLM_FUNC_DECL qua<T, Q> quatLookAt(
  133. vec<3, T, Q> const& direction,
  134. vec<3, T, Q> const& up);
  135. /// Build a right-handed look at quaternion.
  136. ///
  137. /// @param direction Desired forward direction onto which the -z-axis gets mapped. Needs to be normalized.
  138. /// @param up Up vector, how the camera is oriented. Typically (0, 1, 0).
  139. template<typename T, qualifier Q>
  140. GLM_FUNC_DECL qua<T, Q> quatLookAtRH(
  141. vec<3, T, Q> const& direction,
  142. vec<3, T, Q> const& up);
  143. /// Build a left-handed look at quaternion.
  144. ///
  145. /// @param direction Desired forward direction onto which the +z-axis gets mapped. Needs to be normalized.
  146. /// @param up Up vector, how the camera is oriented. Typically (0, 1, 0).
  147. template<typename T, qualifier Q>
  148. GLM_FUNC_DECL qua<T, Q> quatLookAtLH(
  149. vec<3, T, Q> const& direction,
  150. vec<3, T, Q> const& up);
  151. /// @}
  152. } //namespace glm
  153. #include "quaternion.inl"