rotate_vector.hpp 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  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. #ifndef GLM_ENABLE_EXPERIMENTAL
  20. # error "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."
  21. #endif
  22. #if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED)
  23. # pragma message("GLM: GLM_GTX_rotate_vector extension included")
  24. #endif
  25. namespace glm
  26. {
  27. /// @addtogroup gtx_rotate_vector
  28. /// @{
  29. /// Returns Spherical interpolation between two vectors
  30. ///
  31. /// @param x A first vector
  32. /// @param y A second vector
  33. /// @param a Interpolation factor. The interpolation is defined beyond the range [0, 1].
  34. ///
  35. /// @see gtx_rotate_vector
  36. template<typename T, qualifier Q>
  37. GLM_FUNC_DECL vec<3, T, Q> slerp(
  38. vec<3, T, Q> const& x,
  39. vec<3, T, Q> const& y,
  40. T const& a);
  41. //! Rotate a two dimensional vector.
  42. //! From GLM_GTX_rotate_vector extension.
  43. template<typename T, qualifier Q>
  44. GLM_FUNC_DECL vec<2, T, Q> rotate(
  45. vec<2, T, Q> const& v,
  46. T const& angle);
  47. //! Rotate a three dimensional vector around an axis.
  48. //! From GLM_GTX_rotate_vector extension.
  49. template<typename T, qualifier Q>
  50. GLM_FUNC_DECL vec<3, T, Q> rotate(
  51. vec<3, T, Q> const& v,
  52. T const& angle,
  53. vec<3, T, Q> const& normal);
  54. //! Rotate a four dimensional vector around an axis.
  55. //! From GLM_GTX_rotate_vector extension.
  56. template<typename T, qualifier Q>
  57. GLM_FUNC_DECL vec<4, T, Q> rotate(
  58. vec<4, T, Q> const& v,
  59. T const& angle,
  60. vec<3, T, Q> const& normal);
  61. //! Rotate a three dimensional vector around the X axis.
  62. //! From GLM_GTX_rotate_vector extension.
  63. template<typename T, qualifier Q>
  64. GLM_FUNC_DECL vec<3, T, Q> rotateX(
  65. vec<3, T, Q> const& v,
  66. T const& angle);
  67. //! Rotate a three dimensional vector around the Y axis.
  68. //! From GLM_GTX_rotate_vector extension.
  69. template<typename T, qualifier Q>
  70. GLM_FUNC_DECL vec<3, T, Q> rotateY(
  71. vec<3, T, Q> const& v,
  72. T const& angle);
  73. //! Rotate a three dimensional vector around the Z axis.
  74. //! From GLM_GTX_rotate_vector extension.
  75. template<typename T, qualifier Q>
  76. GLM_FUNC_DECL vec<3, T, Q> rotateZ(
  77. vec<3, T, Q> const& v,
  78. T const& angle);
  79. //! Rotate a four dimensional vector around the X axis.
  80. //! From GLM_GTX_rotate_vector extension.
  81. template<typename T, qualifier Q>
  82. GLM_FUNC_DECL vec<4, T, Q> rotateX(
  83. vec<4, T, Q> const& v,
  84. T const& angle);
  85. //! Rotate a four dimensional vector around the Y axis.
  86. //! From GLM_GTX_rotate_vector extension.
  87. template<typename T, qualifier Q>
  88. GLM_FUNC_DECL vec<4, T, Q> rotateY(
  89. vec<4, T, Q> const& v,
  90. T const& angle);
  91. //! Rotate a four dimensional vector around the Z axis.
  92. //! From GLM_GTX_rotate_vector extension.
  93. template<typename T, qualifier Q>
  94. GLM_FUNC_DECL vec<4, T, Q> rotateZ(
  95. vec<4, T, Q> const& v,
  96. T const& angle);
  97. //! Build a rotation matrix from a normal and a up vector.
  98. //! From GLM_GTX_rotate_vector extension.
  99. template<typename T, qualifier Q>
  100. GLM_FUNC_DECL mat<4, 4, T, Q> orientation(
  101. vec<3, T, Q> const& Normal,
  102. vec<3, T, Q> const& Up);
  103. /// @}
  104. }//namespace glm
  105. #include "rotate_vector.inl"