euler_angles.hpp 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335
  1. /// @ref gtx_euler_angles
  2. /// @file glm/gtx/euler_angles.hpp
  3. ///
  4. /// @see core (dependence)
  5. ///
  6. /// @defgroup gtx_euler_angles GLM_GTX_euler_angles
  7. /// @ingroup gtx
  8. ///
  9. /// Include <glm/gtx/euler_angles.hpp> to use the features of this extension.
  10. ///
  11. /// Build matrices from Euler angles.
  12. ///
  13. /// Extraction of Euler angles from rotation matrix.
  14. /// Based on the original paper 2014 Mike Day - Extracting Euler Angles from a Rotation Matrix.
  15. #pragma once
  16. // Dependency:
  17. #include "../glm.hpp"
  18. #if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED)
  19. # ifndef GLM_ENABLE_EXPERIMENTAL
  20. # pragma message("GLM: GLM_GTX_euler_angles 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. # else
  22. # pragma message("GLM: GLM_GTX_euler_angles extension included")
  23. # endif
  24. #endif
  25. namespace glm
  26. {
  27. /// @addtogroup gtx_euler_angles
  28. /// @{
  29. /// Creates a 3D 4 * 4 homogeneous rotation matrix from an euler angle X.
  30. /// @see gtx_euler_angles
  31. template<typename T>
  32. GLM_FUNC_DECL mat<4, 4, T, defaultp> eulerAngleX(
  33. T const& angleX);
  34. /// Creates a 3D 4 * 4 homogeneous rotation matrix from an euler angle Y.
  35. /// @see gtx_euler_angles
  36. template<typename T>
  37. GLM_FUNC_DECL mat<4, 4, T, defaultp> eulerAngleY(
  38. T const& angleY);
  39. /// Creates a 3D 4 * 4 homogeneous rotation matrix from an euler angle Z.
  40. /// @see gtx_euler_angles
  41. template<typename T>
  42. GLM_FUNC_DECL mat<4, 4, T, defaultp> eulerAngleZ(
  43. T const& angleZ);
  44. /// Creates a 3D 4 * 4 homogeneous derived matrix from the rotation matrix about X-axis.
  45. /// @see gtx_euler_angles
  46. template <typename T>
  47. GLM_FUNC_DECL mat<4, 4, T, defaultp> derivedEulerAngleX(
  48. T const & angleX, T const & angularVelocityX);
  49. /// Creates a 3D 4 * 4 homogeneous derived matrix from the rotation matrix about Y-axis.
  50. /// @see gtx_euler_angles
  51. template <typename T>
  52. GLM_FUNC_DECL mat<4, 4, T, defaultp> derivedEulerAngleY(
  53. T const & angleY, T const & angularVelocityY);
  54. /// Creates a 3D 4 * 4 homogeneous derived matrix from the rotation matrix about Z-axis.
  55. /// @see gtx_euler_angles
  56. template <typename T>
  57. GLM_FUNC_DECL mat<4, 4, T, defaultp> derivedEulerAngleZ(
  58. T const & angleZ, T const & angularVelocityZ);
  59. /// Creates a 3D 4 * 4 homogeneous rotation matrix from euler angles (X * Y).
  60. /// @see gtx_euler_angles
  61. template<typename T>
  62. GLM_FUNC_DECL mat<4, 4, T, defaultp> eulerAngleXY(
  63. T const& angleX,
  64. T const& angleY);
  65. /// Creates a 3D 4 * 4 homogeneous rotation matrix from euler angles (Y * X).
  66. /// @see gtx_euler_angles
  67. template<typename T>
  68. GLM_FUNC_DECL mat<4, 4, T, defaultp> eulerAngleYX(
  69. T const& angleY,
  70. T const& angleX);
  71. /// Creates a 3D 4 * 4 homogeneous rotation matrix from euler angles (X * Z).
  72. /// @see gtx_euler_angles
  73. template<typename T>
  74. GLM_FUNC_DECL mat<4, 4, T, defaultp> eulerAngleXZ(
  75. T const& angleX,
  76. T const& angleZ);
  77. /// Creates a 3D 4 * 4 homogeneous rotation matrix from euler angles (Z * X).
  78. /// @see gtx_euler_angles
  79. template<typename T>
  80. GLM_FUNC_DECL mat<4, 4, T, defaultp> eulerAngleZX(
  81. T const& angle,
  82. T const& angleX);
  83. /// Creates a 3D 4 * 4 homogeneous rotation matrix from euler angles (Y * Z).
  84. /// @see gtx_euler_angles
  85. template<typename T>
  86. GLM_FUNC_DECL mat<4, 4, T, defaultp> eulerAngleYZ(
  87. T const& angleY,
  88. T const& angleZ);
  89. /// Creates a 3D 4 * 4 homogeneous rotation matrix from euler angles (Z * Y).
  90. /// @see gtx_euler_angles
  91. template<typename T>
  92. GLM_FUNC_DECL mat<4, 4, T, defaultp> eulerAngleZY(
  93. T const& angleZ,
  94. T const& angleY);
  95. /// Creates a 3D 4 * 4 homogeneous rotation matrix from euler angles (X * Y * Z).
  96. /// @see gtx_euler_angles
  97. template<typename T>
  98. GLM_FUNC_DECL mat<4, 4, T, defaultp> eulerAngleXYZ(
  99. T const& t1,
  100. T const& t2,
  101. T const& t3);
  102. /// Creates a 3D 4 * 4 homogeneous rotation matrix from euler angles (Y * X * Z).
  103. /// @see gtx_euler_angles
  104. template<typename T>
  105. GLM_FUNC_DECL mat<4, 4, T, defaultp> eulerAngleYXZ(
  106. T const& yaw,
  107. T const& pitch,
  108. T const& roll);
  109. /// Creates a 3D 4 * 4 homogeneous rotation matrix from euler angles (X * Z * X).
  110. /// @see gtx_euler_angles
  111. template <typename T>
  112. GLM_FUNC_DECL mat<4, 4, T, defaultp> eulerAngleXZX(
  113. T const & t1,
  114. T const & t2,
  115. T const & t3);
  116. /// Creates a 3D 4 * 4 homogeneous rotation matrix from euler angles (X * Y * X).
  117. /// @see gtx_euler_angles
  118. template <typename T>
  119. GLM_FUNC_DECL mat<4, 4, T, defaultp> eulerAngleXYX(
  120. T const & t1,
  121. T const & t2,
  122. T const & t3);
  123. /// Creates a 3D 4 * 4 homogeneous rotation matrix from euler angles (Y * X * Y).
  124. /// @see gtx_euler_angles
  125. template <typename T>
  126. GLM_FUNC_DECL mat<4, 4, T, defaultp> eulerAngleYXY(
  127. T const & t1,
  128. T const & t2,
  129. T const & t3);
  130. /// Creates a 3D 4 * 4 homogeneous rotation matrix from euler angles (Y * Z * Y).
  131. /// @see gtx_euler_angles
  132. template <typename T>
  133. GLM_FUNC_DECL mat<4, 4, T, defaultp> eulerAngleYZY(
  134. T const & t1,
  135. T const & t2,
  136. T const & t3);
  137. /// Creates a 3D 4 * 4 homogeneous rotation matrix from euler angles (Z * Y * Z).
  138. /// @see gtx_euler_angles
  139. template <typename T>
  140. GLM_FUNC_DECL mat<4, 4, T, defaultp> eulerAngleZYZ(
  141. T const & t1,
  142. T const & t2,
  143. T const & t3);
  144. /// Creates a 3D 4 * 4 homogeneous rotation matrix from euler angles (Z * X * Z).
  145. /// @see gtx_euler_angles
  146. template <typename T>
  147. GLM_FUNC_DECL mat<4, 4, T, defaultp> eulerAngleZXZ(
  148. T const & t1,
  149. T const & t2,
  150. T const & t3);
  151. /// Creates a 3D 4 * 4 homogeneous rotation matrix from euler angles (X * Z * Y).
  152. /// @see gtx_euler_angles
  153. template <typename T>
  154. GLM_FUNC_DECL mat<4, 4, T, defaultp> eulerAngleXZY(
  155. T const & t1,
  156. T const & t2,
  157. T const & t3);
  158. /// Creates a 3D 4 * 4 homogeneous rotation matrix from euler angles (Y * Z * X).
  159. /// @see gtx_euler_angles
  160. template <typename T>
  161. GLM_FUNC_DECL mat<4, 4, T, defaultp> eulerAngleYZX(
  162. T const & t1,
  163. T const & t2,
  164. T const & t3);
  165. /// Creates a 3D 4 * 4 homogeneous rotation matrix from euler angles (Z * Y * X).
  166. /// @see gtx_euler_angles
  167. template <typename T>
  168. GLM_FUNC_DECL mat<4, 4, T, defaultp> eulerAngleZYX(
  169. T const & t1,
  170. T const & t2,
  171. T const & t3);
  172. /// Creates a 3D 4 * 4 homogeneous rotation matrix from euler angles (Z * X * Y).
  173. /// @see gtx_euler_angles
  174. template <typename T>
  175. GLM_FUNC_DECL mat<4, 4, T, defaultp> eulerAngleZXY(
  176. T const & t1,
  177. T const & t2,
  178. T const & t3);
  179. /// Creates a 3D 4 * 4 homogeneous rotation matrix from euler angles (Y * X * Z).
  180. /// @see gtx_euler_angles
  181. template<typename T>
  182. GLM_FUNC_DECL mat<4, 4, T, defaultp> yawPitchRoll(
  183. T const& yaw,
  184. T const& pitch,
  185. T const& roll);
  186. /// Creates a 2D 2 * 2 rotation matrix from an euler angle.
  187. /// @see gtx_euler_angles
  188. template<typename T>
  189. GLM_FUNC_DECL mat<2, 2, T, defaultp> orientate2(T const& angle);
  190. /// Creates a 2D 4 * 4 homogeneous rotation matrix from an euler angle.
  191. /// @see gtx_euler_angles
  192. template<typename T>
  193. GLM_FUNC_DECL mat<3, 3, T, defaultp> orientate3(T const& angle);
  194. /// Creates a 3D 3 * 3 rotation matrix from euler angles (Y * X * Z).
  195. /// @see gtx_euler_angles
  196. template<typename T, qualifier Q>
  197. GLM_FUNC_DECL mat<3, 3, T, Q> orientate3(vec<3, T, Q> const& angles);
  198. /// Creates a 3D 4 * 4 homogeneous rotation matrix from euler angles (Y * X * Z).
  199. /// @see gtx_euler_angles
  200. template<typename T, qualifier Q>
  201. GLM_FUNC_DECL mat<4, 4, T, Q> orientate4(vec<3, T, Q> const& angles);
  202. /// Extracts the (X * Y * Z) Euler angles from the rotation matrix M
  203. /// @see gtx_euler_angles
  204. template<typename T>
  205. GLM_FUNC_DECL void extractEulerAngleXYZ(mat<4, 4, T, defaultp> const& M,
  206. T & t1,
  207. T & t2,
  208. T & t3);
  209. /// Extracts the (Y * X * Z) Euler angles from the rotation matrix M
  210. /// @see gtx_euler_angles
  211. template <typename T>
  212. GLM_FUNC_DECL void extractEulerAngleYXZ(mat<4, 4, T, defaultp> const & M,
  213. T & t1,
  214. T & t2,
  215. T & t3);
  216. /// Extracts the (X * Z * X) Euler angles from the rotation matrix M
  217. /// @see gtx_euler_angles
  218. template <typename T>
  219. GLM_FUNC_DECL void extractEulerAngleXZX(mat<4, 4, T, defaultp> const & M,
  220. T & t1,
  221. T & t2,
  222. T & t3);
  223. /// Extracts the (X * Y * X) Euler angles from the rotation matrix M
  224. /// @see gtx_euler_angles
  225. template <typename T>
  226. GLM_FUNC_DECL void extractEulerAngleXYX(mat<4, 4, T, defaultp> const & M,
  227. T & t1,
  228. T & t2,
  229. T & t3);
  230. /// Extracts the (Y * X * Y) Euler angles from the rotation matrix M
  231. /// @see gtx_euler_angles
  232. template <typename T>
  233. GLM_FUNC_DECL void extractEulerAngleYXY(mat<4, 4, T, defaultp> const & M,
  234. T & t1,
  235. T & t2,
  236. T & t3);
  237. /// Extracts the (Y * Z * Y) Euler angles from the rotation matrix M
  238. /// @see gtx_euler_angles
  239. template <typename T>
  240. GLM_FUNC_DECL void extractEulerAngleYZY(mat<4, 4, T, defaultp> const & M,
  241. T & t1,
  242. T & t2,
  243. T & t3);
  244. /// Extracts the (Z * Y * Z) Euler angles from the rotation matrix M
  245. /// @see gtx_euler_angles
  246. template <typename T>
  247. GLM_FUNC_DECL void extractEulerAngleZYZ(mat<4, 4, T, defaultp> const & M,
  248. T & t1,
  249. T & t2,
  250. T & t3);
  251. /// Extracts the (Z * X * Z) Euler angles from the rotation matrix M
  252. /// @see gtx_euler_angles
  253. template <typename T>
  254. GLM_FUNC_DECL void extractEulerAngleZXZ(mat<4, 4, T, defaultp> const & M,
  255. T & t1,
  256. T & t2,
  257. T & t3);
  258. /// Extracts the (X * Z * Y) Euler angles from the rotation matrix M
  259. /// @see gtx_euler_angles
  260. template <typename T>
  261. GLM_FUNC_DECL void extractEulerAngleXZY(mat<4, 4, T, defaultp> const & M,
  262. T & t1,
  263. T & t2,
  264. T & t3);
  265. /// Extracts the (Y * Z * X) Euler angles from the rotation matrix M
  266. /// @see gtx_euler_angles
  267. template <typename T>
  268. GLM_FUNC_DECL void extractEulerAngleYZX(mat<4, 4, T, defaultp> const & M,
  269. T & t1,
  270. T & t2,
  271. T & t3);
  272. /// Extracts the (Z * Y * X) Euler angles from the rotation matrix M
  273. /// @see gtx_euler_angles
  274. template <typename T>
  275. GLM_FUNC_DECL void extractEulerAngleZYX(mat<4, 4, T, defaultp> const & M,
  276. T & t1,
  277. T & t2,
  278. T & t3);
  279. /// Extracts the (Z * X * Y) Euler angles from the rotation matrix M
  280. /// @see gtx_euler_angles
  281. template <typename T>
  282. GLM_FUNC_DECL void extractEulerAngleZXY(mat<4, 4, T, defaultp> const & M,
  283. T & t1,
  284. T & t2,
  285. T & t3);
  286. /// @}
  287. }//namespace glm
  288. #include "euler_angles.inl"