rotate_vector.hpp 3.5 KB

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