9
3

rotate_vector.hpp 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. /// @ref gtx_rotate_vector
  2. /// @file glm/gtx/rotate_vector.hpp
  3. ///
  4. /// @see core (dependence)
  5. /// @see gtx_transform (dependence)
  6. ///
  7. /// @defgroup gtx_rotate_vector GLM_GTX_rotate_vector
  8. /// @ingroup gtx
  9. ///
  10. /// Include <glm/gtx/rotate_vector.hpp> to use the features of this extension.
  11. ///
  12. /// Function to directly rotate a vector
  13. #pragma once
  14. // Dependency:
  15. #include "../gtx/transform.hpp"
  16. #include "../gtc/epsilon.hpp"
  17. #include "../ext/vector_relational.hpp"
  18. #include "../glm.hpp"
  19. #if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED)
  20. # ifndef GLM_ENABLE_EXPERIMENTAL
  21. # pragma message("GLM: GLM_GTX_rotate_vector is an experimental extension and may change in the future. Use #define GLM_ENABLE_EXPERIMENTAL before including it, if you really want to use it.")
  22. # else
  23. # pragma message("GLM: GLM_GTX_rotate_vector extension included")
  24. # endif
  25. #endif
  26. namespace glm
  27. {
  28. /// @addtogroup gtx_rotate_vector
  29. /// @{
  30. /// Returns Spherical interpolation between two vectors
  31. ///
  32. /// @param x A first vector
  33. /// @param y A second vector
  34. /// @param a Interpolation factor. The interpolation is defined beyond the range [0, 1].
  35. ///
  36. /// @see gtx_rotate_vector
  37. template<typename T, qualifier Q>
  38. GLM_FUNC_DECL vec<3, T, Q> slerp(
  39. vec<3, T, Q> const& x,
  40. vec<3, T, Q> const& y,
  41. T const& a);
  42. //! Rotate a two dimensional vector.
  43. //! From GLM_GTX_rotate_vector extension.
  44. template<typename T, qualifier Q>
  45. GLM_FUNC_DECL vec<2, T, Q> rotate(
  46. vec<2, T, Q> const& v,
  47. T const& angle);
  48. //! Rotate a three dimensional vector around an axis.
  49. //! From GLM_GTX_rotate_vector extension.
  50. template<typename T, qualifier Q>
  51. GLM_FUNC_DECL vec<3, T, Q> rotate(
  52. vec<3, T, Q> const& v,
  53. T const& angle,
  54. vec<3, T, Q> const& normal);
  55. //! Rotate a four dimensional vector around an axis.
  56. //! From GLM_GTX_rotate_vector extension.
  57. template<typename T, qualifier Q>
  58. GLM_FUNC_DECL vec<4, T, Q> rotate(
  59. vec<4, T, Q> const& v,
  60. T const& angle,
  61. vec<3, T, Q> const& normal);
  62. //! Rotate a three dimensional vector around the X axis.
  63. //! From GLM_GTX_rotate_vector extension.
  64. template<typename T, qualifier Q>
  65. GLM_FUNC_DECL vec<3, T, Q> rotateX(
  66. vec<3, T, Q> const& v,
  67. T const& angle);
  68. //! Rotate a three dimensional vector around the Y axis.
  69. //! From GLM_GTX_rotate_vector extension.
  70. template<typename T, qualifier Q>
  71. GLM_FUNC_DECL vec<3, T, Q> rotateY(
  72. vec<3, T, Q> const& v,
  73. T const& angle);
  74. //! Rotate a three dimensional vector around the Z axis.
  75. //! From GLM_GTX_rotate_vector extension.
  76. template<typename T, qualifier Q>
  77. GLM_FUNC_DECL vec<3, T, Q> rotateZ(
  78. vec<3, T, Q> const& v,
  79. T const& angle);
  80. //! Rotate a four dimensional vector around the X axis.
  81. //! From GLM_GTX_rotate_vector extension.
  82. template<typename T, qualifier Q>
  83. GLM_FUNC_DECL vec<4, T, Q> rotateX(
  84. vec<4, T, Q> const& v,
  85. T const& angle);
  86. //! Rotate a four dimensional vector around the Y axis.
  87. //! From GLM_GTX_rotate_vector extension.
  88. template<typename T, qualifier Q>
  89. GLM_FUNC_DECL vec<4, T, Q> rotateY(
  90. vec<4, T, Q> const& v,
  91. T const& angle);
  92. //! Rotate a four dimensional vector around the Z axis.
  93. //! From GLM_GTX_rotate_vector extension.
  94. template<typename T, qualifier Q>
  95. GLM_FUNC_DECL vec<4, T, Q> rotateZ(
  96. vec<4, T, Q> const& v,
  97. T const& angle);
  98. //! Build a rotation matrix from a normal and a up vector.
  99. //! From GLM_GTX_rotate_vector extension.
  100. template<typename T, qualifier Q>
  101. GLM_FUNC_DECL mat<4, 4, T, Q> orientation(
  102. vec<3, T, Q> const& Normal,
  103. vec<3, T, Q> const& Up);
  104. /// @}
  105. }//namespace glm
  106. #include "rotate_vector.inl"