rotate_vector.hpp 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. ///////////////////////////////////////////////////////////////////////////////////
  2. /// OpenGL Mathematics (glm.g-truc.net)
  3. ///
  4. /// Copyright (c) 2005 - 2014 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_rotate_vector
  24. /// @file glm/gtx/rotate_vector.hpp
  25. /// @date 2006-11-02 / 2011-06-07
  26. /// @author Christophe Riccio
  27. ///
  28. /// @see core (dependence)
  29. /// @see gtx_transform (dependence)
  30. ///
  31. /// @defgroup gtx_rotate_vector GLM_GTX_rotate_vector
  32. /// @ingroup gtx
  33. ///
  34. /// @brief Function to directly rotate a vector
  35. ///
  36. /// <glm/gtx/rotate_vector.hpp> need to be included to use these functionalities.
  37. ///////////////////////////////////////////////////////////////////////////////////
  38. #pragma once
  39. // Dependency:
  40. #include "../glm.hpp"
  41. #include "../gtx/transform.hpp"
  42. #if(defined(GLM_MESSAGES) && !defined(GLM_EXT_INCLUDED))
  43. # pragma message("GLM: GLM_GTX_rotate_vector extension included")
  44. #endif
  45. namespace glm
  46. {
  47. /// @addtogroup gtx_rotate_vector
  48. /// @{
  49. /// Returns the length of the quaternion.
  50. ///
  51. /// @param x A first vector
  52. /// @param y A second vector
  53. /// @param a Interpolation factor. The interpolation is defined beyond the range [0, 1].
  54. ///
  55. /// @see gtc_quaternion
  56. template <typename T, precision P>
  57. GLM_FUNC_DECL detail::tvec3<T, P> slerp(
  58. detail::tvec3<T, P> const & x,
  59. detail::tvec3<T, P> const & y,
  60. T const & a);
  61. //! Rotate a two dimensional vector.
  62. //! From GLM_GTX_rotate_vector extension.
  63. template <typename T, precision P>
  64. GLM_FUNC_DECL detail::tvec2<T, P> rotate(
  65. detail::tvec2<T, P> const & v,
  66. T const & angle);
  67. //! Rotate a three dimensional vector around an axis.
  68. //! From GLM_GTX_rotate_vector extension.
  69. template <typename T, precision P>
  70. GLM_FUNC_DECL detail::tvec3<T, P> rotate(
  71. detail::tvec3<T, P> const & v,
  72. T const & angle,
  73. detail::tvec3<T, P> const & normal);
  74. //! Rotate a four dimensional vector around an axis.
  75. //! From GLM_GTX_rotate_vector extension.
  76. template <typename T, precision P>
  77. GLM_FUNC_DECL detail::tvec4<T, P> rotate(
  78. detail::tvec4<T, P> const & v,
  79. T const & angle,
  80. detail::tvec3<T, P> const & normal);
  81. //! Rotate a three dimensional vector around the X axis.
  82. //! From GLM_GTX_rotate_vector extension.
  83. template <typename T, precision P>
  84. GLM_FUNC_DECL detail::tvec3<T, P> rotateX(
  85. detail::tvec3<T, P> const & v,
  86. T const & angle);
  87. //! Rotate a three dimensional vector around the Y axis.
  88. //! From GLM_GTX_rotate_vector extension.
  89. template <typename T, precision P>
  90. GLM_FUNC_DECL detail::tvec3<T, P> rotateY(
  91. detail::tvec3<T, P> const & v,
  92. T const & angle);
  93. //! Rotate a three dimensional vector around the Z axis.
  94. //! From GLM_GTX_rotate_vector extension.
  95. template <typename T, precision P>
  96. GLM_FUNC_DECL detail::tvec3<T, P> rotateZ(
  97. detail::tvec3<T, P> const & v,
  98. T const & angle);
  99. //! Rotate a four dimentionnals vector around the X axis.
  100. //! From GLM_GTX_rotate_vector extension.
  101. template <typename T, precision P>
  102. GLM_FUNC_DECL detail::tvec4<T, P> rotateX(
  103. detail::tvec4<T, P> const & v,
  104. T const & angle);
  105. //! Rotate a four dimensional vector around the X axis.
  106. //! From GLM_GTX_rotate_vector extension.
  107. template <typename T, precision P>
  108. GLM_FUNC_DECL detail::tvec4<T, P> rotateY(
  109. detail::tvec4<T, P> const & v,
  110. T const & angle);
  111. //! Rotate a four dimensional vector around the X axis.
  112. //! From GLM_GTX_rotate_vector extension.
  113. template <typename T, precision P>
  114. GLM_FUNC_DECL detail::tvec4<T, P> rotateZ(
  115. detail::tvec4<T, P> const & v,
  116. T const & angle);
  117. //! Build a rotation matrix from a normal and a up vector.
  118. //! From GLM_GTX_rotate_vector extension.
  119. template <typename T, precision P>
  120. GLM_FUNC_DECL detail::tmat4x4<T, P> orientation(
  121. detail::tvec3<T, P> const & Normal,
  122. detail::tvec3<T, P> const & Up);
  123. /// @}
  124. }//namespace glm
  125. #include "rotate_vector.inl"