euler_angles.hpp 11 KB

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