You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

195 lines
5.7 KiB

4 years ago
  1. ///////////////////////////////////////////////////////////////////////////////////
  2. /// OpenGL Mathematics (glm.g-truc.net)
  3. ///
  4. /// Copyright (c) 2005 - 2013 G-Truc Creation (www.g-truc.net)
  5. /// Permission is hereby granted, free of charge, to any person obtaining a copy
  6. /// of this software and associated documentation files (the "Software"), to deal
  7. /// in the Software without restriction, including without limitation the rights
  8. /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  9. /// copies of the Software, and to permit persons to whom the Software is
  10. /// furnished to do so, subject to the following conditions:
  11. ///
  12. /// The above copyright notice and this permission notice shall be included in
  13. /// all copies or substantial portions of the Software.
  14. ///
  15. /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16. /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17. /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  18. /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  19. /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  20. /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  21. /// THE SOFTWARE.
  22. ///
  23. /// @ref gtx_quaternion
  24. /// @file glm/gtx/quaternion.hpp
  25. /// @date 2005-12-21 / 2011-06-07
  26. /// @author Christophe Riccio
  27. ///
  28. /// @see core (dependence)
  29. /// @see gtx_extented_min_max (dependence)
  30. ///
  31. /// @defgroup gtx_quaternion GLM_GTX_quaternion
  32. /// @ingroup gtx
  33. ///
  34. /// @brief Extented quaternion types and functions
  35. ///
  36. /// <glm/gtx/quaternion.hpp> need to be included to use these functionalities.
  37. ///////////////////////////////////////////////////////////////////////////////////
  38. #ifndef GLM_GTX_quaternion
  39. #define GLM_GTX_quaternion GLM_VERSION
  40. // Dependency:
  41. #include "../glm.hpp"
  42. #include "../gtc/quaternion.hpp"
  43. #if(defined(GLM_MESSAGES) && !defined(glm_ext))
  44. # pragma message("GLM: GLM_GTX_quaternion extension included")
  45. #endif
  46. namespace glm
  47. {
  48. /// @addtogroup gtx_quaternion
  49. /// @{
  50. //! Compute a cross product between a quaternion and a vector.
  51. ///
  52. /// @see gtx_quaternion
  53. template <typename valType>
  54. detail::tvec3<valType> cross(
  55. detail::tquat<valType> const & q,
  56. detail::tvec3<valType> const & v);
  57. //! Compute a cross product between a vector and a quaternion.
  58. ///
  59. /// @see gtx_quaternion
  60. template <typename valType>
  61. detail::tvec3<valType> cross(
  62. detail::tvec3<valType> const & v,
  63. detail::tquat<valType> const & q);
  64. //! Compute a point on a path according squad equation.
  65. //! q1 and q2 are control points; s1 and s2 are intermediate control points.
  66. ///
  67. /// @see gtx_quaternion
  68. template <typename valType>
  69. detail::tquat<valType> squad(
  70. detail::tquat<valType> const & q1,
  71. detail::tquat<valType> const & q2,
  72. detail::tquat<valType> const & s1,
  73. detail::tquat<valType> const & s2,
  74. valType const & h);
  75. //! Returns an intermediate control point for squad interpolation.
  76. ///
  77. /// @see gtx_quaternion
  78. template <typename valType>
  79. detail::tquat<valType> intermediate(
  80. detail::tquat<valType> const & prev,
  81. detail::tquat<valType> const & curr,
  82. detail::tquat<valType> const & next);
  83. //! Returns a exp of a quaternion.
  84. ///
  85. /// @see gtx_quaternion
  86. template <typename valType>
  87. detail::tquat<valType> exp(
  88. detail::tquat<valType> const & q);
  89. //! Returns a log of a quaternion.
  90. ///
  91. /// @see gtx_quaternion
  92. template <typename valType>
  93. detail::tquat<valType> log(
  94. detail::tquat<valType> const & q);
  95. /// Returns x raised to the y power.
  96. ///
  97. /// @see gtx_quaternion
  98. template <typename valType>
  99. detail::tquat<valType> pow(
  100. detail::tquat<valType> const & x,
  101. valType const & y);
  102. //! Returns quarternion square root.
  103. ///
  104. /// @see gtx_quaternion
  105. //template <typename valType>
  106. //detail::tquat<valType> sqrt(
  107. // detail::tquat<valType> const & q);
  108. //! Rotates a 3 components vector by a quaternion.
  109. ///
  110. /// @see gtx_quaternion
  111. template <typename valType>
  112. detail::tvec3<valType> rotate(
  113. detail::tquat<valType> const & q,
  114. detail::tvec3<valType> const & v);
  115. /// Rotates a 4 components vector by a quaternion.
  116. ///
  117. /// @see gtx_quaternion
  118. template <typename valType>
  119. detail::tvec4<valType> rotate(
  120. detail::tquat<valType> const & q,
  121. detail::tvec4<valType> const & v);
  122. /// Extract the real component of a quaternion.
  123. ///
  124. /// @see gtx_quaternion
  125. template <typename valType>
  126. valType extractRealComponent(
  127. detail::tquat<valType> const & q);
  128. /// Converts a quaternion to a 3 * 3 matrix.
  129. ///
  130. /// @see gtx_quaternion
  131. template <typename valType>
  132. detail::tmat3x3<valType> toMat3(
  133. detail::tquat<valType> const & x){return mat3_cast(x);}
  134. /// Converts a quaternion to a 4 * 4 matrix.
  135. ///
  136. /// @see gtx_quaternion
  137. template <typename valType>
  138. detail::tmat4x4<valType> toMat4(
  139. detail::tquat<valType> const & x){return mat4_cast(x);}
  140. /// Converts a 3 * 3 matrix to a quaternion.
  141. ///
  142. /// @see gtx_quaternion
  143. template <typename valType>
  144. detail::tquat<valType> toQuat(
  145. detail::tmat3x3<valType> const & x){return quat_cast(x);}
  146. /// Converts a 4 * 4 matrix to a quaternion.
  147. ///
  148. /// @see gtx_quaternion
  149. template <typename valType>
  150. detail::tquat<valType> toQuat(
  151. detail::tmat4x4<valType> const & x){return quat_cast(x);}
  152. /// Quaternion interpolation using the rotation short path.
  153. ///
  154. /// @see gtx_quaternion
  155. template <typename T>
  156. detail::tquat<T> shortMix(
  157. detail::tquat<T> const & x,
  158. detail::tquat<T> const & y,
  159. T const & a);
  160. /// Quaternion normalized linear interpolation.
  161. ///
  162. /// @see gtx_quaternion
  163. template <typename T>
  164. detail::tquat<T> fastMix(
  165. detail::tquat<T> const & x,
  166. detail::tquat<T> const & y,
  167. T const & a);
  168. /// @}
  169. }//namespace glm
  170. #include "quaternion.inl"
  171. #endif//GLM_GTX_quaternion