1
0

euler.h 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601
  1. /*
  2. * Copyright (c), Recep Aslantas.
  3. *
  4. * MIT License (MIT), http://opensource.org/licenses/MIT
  5. * Full license can be found in the LICENSE file
  6. */
  7. /*
  8. NOTE:
  9. angles must be passed as [X-Angle, Y-Angle, Z-angle] order
  10. For instance you don't pass angles as [Z-Angle, X-Angle, Y-angle] to
  11. glm_euler_zxy function, All RELATED functions accept angles same order
  12. which is [X, Y, Z].
  13. */
  14. /*
  15. Types:
  16. enum glm_euler_seq
  17. Functions:
  18. CGLM_INLINE glm_euler_seq glm_euler_order(int newOrder[3]);
  19. CGLM_INLINE void glm_euler_angles(mat4 m, vec3 dest);
  20. CGLM_INLINE void glm_euler(vec3 angles, mat4 dest);
  21. CGLM_INLINE void glm_euler_xyz(vec3 angles, mat4 dest);
  22. CGLM_INLINE void glm_euler_zyx(vec3 angles, mat4 dest);
  23. CGLM_INLINE void glm_euler_zxy(vec3 angles, mat4 dest);
  24. CGLM_INLINE void glm_euler_xzy(vec3 angles, mat4 dest);
  25. CGLM_INLINE void glm_euler_yzx(vec3 angles, mat4 dest);
  26. CGLM_INLINE void glm_euler_yxz(vec3 angles, mat4 dest);
  27. CGLM_INLINE void glm_euler_by_order(vec3 angles,
  28. glm_euler_seq ord,
  29. mat4 dest);
  30. CGLM_INLINE void glm_euler_xyz_quat(vec3 angles, versor dest);
  31. CGLM_INLINE void glm_euler_xzy_quat(vec3 angles, versor dest);
  32. CGLM_INLINE void glm_euler_yxz_quat(vec3 angles, versor dest);
  33. CGLM_INLINE void glm_euler_yzx_quat(vec3 angles, versor dest);
  34. CGLM_INLINE void glm_euler_zxy_quat(vec3 angles, versor dest);
  35. CGLM_INLINE void glm_euler_zyx_quat(vec3 angles, versor dest);
  36. */
  37. #ifndef cglm_euler_h
  38. #define cglm_euler_h
  39. #include "common.h"
  40. #ifdef CGLM_FORCE_LEFT_HANDED
  41. # include "handed/euler_to_quat_lh.h"
  42. #else
  43. # include "handed/euler_to_quat_rh.h"
  44. #endif
  45. #ifndef CGLM_CLIPSPACE_INCLUDE_ALL
  46. # if CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_LH_ZO
  47. # include "clipspace/ortho_lh_zo.h"
  48. # include "clipspace/persp_lh_zo.h"
  49. # include "clipspace/view_lh_zo.h"
  50. # elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_LH_NO
  51. # include "clipspace/ortho_lh_no.h"
  52. # include "clipspace/persp_lh_no.h"
  53. # include "clipspace/view_lh_no.h"
  54. # elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_RH_ZO
  55. # include "clipspace/ortho_rh_zo.h"
  56. # include "clipspace/persp_rh_zo.h"
  57. # include "clipspace/view_rh_zo.h"
  58. # elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_RH_NO
  59. # include "clipspace/ortho_rh_no.h"
  60. # include "clipspace/persp_rh_no.h"
  61. # include "clipspace/view_rh_no.h"
  62. # endif
  63. #else
  64. # include "clipspace/ortho_lh_zo.h"
  65. # include "clipspace/persp_lh_zo.h"
  66. # include "clipspace/ortho_lh_no.h"
  67. # include "clipspace/persp_lh_no.h"
  68. # include "clipspace/ortho_rh_zo.h"
  69. # include "clipspace/persp_rh_zo.h"
  70. # include "clipspace/ortho_rh_no.h"
  71. # include "clipspace/persp_rh_no.h"
  72. # include "clipspace/view_lh_zo.h"
  73. # include "clipspace/view_lh_no.h"
  74. # include "clipspace/view_rh_zo.h"
  75. # include "clipspace/view_rh_no.h"
  76. #endif
  77. /*!
  78. * if you have axis order like vec3 orderVec = [0, 1, 2] or [0, 2, 1]...
  79. * vector then you can convert it to this enum by doing this:
  80. * @code
  81. * glm_euler_seq order;
  82. * order = orderVec[0] | orderVec[1] << 2 | orderVec[2] << 4;
  83. * @endcode
  84. * you may need to explicit cast if required
  85. */
  86. typedef enum glm_euler_seq {
  87. GLM_EULER_XYZ = 0 << 0 | 1 << 2 | 2 << 4,
  88. GLM_EULER_XZY = 0 << 0 | 2 << 2 | 1 << 4,
  89. GLM_EULER_YZX = 1 << 0 | 2 << 2 | 0 << 4,
  90. GLM_EULER_YXZ = 1 << 0 | 0 << 2 | 2 << 4,
  91. GLM_EULER_ZXY = 2 << 0 | 0 << 2 | 1 << 4,
  92. GLM_EULER_ZYX = 2 << 0 | 1 << 2 | 0 << 4
  93. } glm_euler_seq;
  94. CGLM_INLINE
  95. glm_euler_seq
  96. glm_euler_order(int ord[3]) {
  97. return (glm_euler_seq)(ord[0] << 0 | ord[1] << 2 | ord[2] << 4);
  98. }
  99. /*!
  100. * @brief extract euler angles (in radians) using xyz order
  101. *
  102. * @param[in] m affine transform
  103. * @param[out] dest angles vector [x, y, z]
  104. */
  105. CGLM_INLINE
  106. void
  107. glm_euler_angles(mat4 m, vec3 dest) {
  108. float m00, m01, m10, m11, m20, m21, m22;
  109. float thetaX, thetaY, thetaZ;
  110. m00 = m[0][0]; m10 = m[1][0]; m20 = m[2][0];
  111. m01 = m[0][1]; m11 = m[1][1]; m21 = m[2][1];
  112. m22 = m[2][2];
  113. if (m20 < 1.0f) {
  114. if (m20 > -1.0f) {
  115. thetaY = asinf(m20);
  116. thetaX = atan2f(-m21, m22);
  117. thetaZ = atan2f(-m10, m00);
  118. } else { /* m20 == -1 */
  119. /* Not a unique solution */
  120. thetaY = -GLM_PI_2f;
  121. thetaX = -atan2f(m01, m11);
  122. thetaZ = 0.0f;
  123. }
  124. } else { /* m20 == +1 */
  125. thetaY = GLM_PI_2f;
  126. thetaX = atan2f(m01, m11);
  127. thetaZ = 0.0f;
  128. }
  129. dest[0] = thetaX;
  130. dest[1] = thetaY;
  131. dest[2] = thetaZ;
  132. }
  133. /*!
  134. * @brief build rotation matrix from euler angles
  135. *
  136. * @param[in] angles angles as vector [Xangle, Yangle, Zangle]
  137. * @param[out] dest rotation matrix
  138. */
  139. CGLM_INLINE
  140. void
  141. glm_euler_xyz(vec3 angles, mat4 dest) {
  142. float cx, cy, cz,
  143. sx, sy, sz, czsx, cxcz, sysz;
  144. sx = sinf(angles[0]); cx = cosf(angles[0]);
  145. sy = sinf(angles[1]); cy = cosf(angles[1]);
  146. sz = sinf(angles[2]); cz = cosf(angles[2]);
  147. czsx = cz * sx;
  148. cxcz = cx * cz;
  149. sysz = sy * sz;
  150. dest[0][0] = cy * cz;
  151. dest[0][1] = czsx * sy + cx * sz;
  152. dest[0][2] = -cxcz * sy + sx * sz;
  153. dest[1][0] = -cy * sz;
  154. dest[1][1] = cxcz - sx * sysz;
  155. dest[1][2] = czsx + cx * sysz;
  156. dest[2][0] = sy;
  157. dest[2][1] = -cy * sx;
  158. dest[2][2] = cx * cy;
  159. dest[0][3] = 0.0f;
  160. dest[1][3] = 0.0f;
  161. dest[2][3] = 0.0f;
  162. dest[3][0] = 0.0f;
  163. dest[3][1] = 0.0f;
  164. dest[3][2] = 0.0f;
  165. dest[3][3] = 1.0f;
  166. }
  167. /*!
  168. * @brief build rotation matrix from euler angles
  169. *
  170. * @param[in] angles angles as vector [Xangle, Yangle, Zangle]
  171. * @param[out] dest rotation matrix
  172. */
  173. CGLM_INLINE
  174. void
  175. glm_euler(vec3 angles, mat4 dest) {
  176. glm_euler_xyz(angles, dest);
  177. }
  178. /*!
  179. * @brief build rotation matrix from euler angles
  180. *
  181. * @param[in] angles angles as vector [Xangle, Yangle, Zangle]
  182. * @param[out] dest rotation matrix
  183. */
  184. CGLM_INLINE
  185. void
  186. glm_euler_xzy(vec3 angles, mat4 dest) {
  187. float cx, cy, cz,
  188. sx, sy, sz, sxsy, cysx, cxsy, cxcy;
  189. sx = sinf(angles[0]); cx = cosf(angles[0]);
  190. sy = sinf(angles[1]); cy = cosf(angles[1]);
  191. sz = sinf(angles[2]); cz = cosf(angles[2]);
  192. sxsy = sx * sy;
  193. cysx = cy * sx;
  194. cxsy = cx * sy;
  195. cxcy = cx * cy;
  196. dest[0][0] = cy * cz;
  197. dest[0][1] = sxsy + cxcy * sz;
  198. dest[0][2] = -cxsy + cysx * sz;
  199. dest[1][0] = -sz;
  200. dest[1][1] = cx * cz;
  201. dest[1][2] = cz * sx;
  202. dest[2][0] = cz * sy;
  203. dest[2][1] = -cysx + cxsy * sz;
  204. dest[2][2] = cxcy + sxsy * sz;
  205. dest[0][3] = 0.0f;
  206. dest[1][3] = 0.0f;
  207. dest[2][3] = 0.0f;
  208. dest[3][0] = 0.0f;
  209. dest[3][1] = 0.0f;
  210. dest[3][2] = 0.0f;
  211. dest[3][3] = 1.0f;
  212. }
  213. /*!
  214. * @brief build rotation matrix from euler angles
  215. *
  216. * @param[in] angles angles as vector [Xangle, Yangle, Zangle]
  217. * @param[out] dest rotation matrix
  218. */
  219. CGLM_INLINE
  220. void
  221. glm_euler_yxz(vec3 angles, mat4 dest) {
  222. float cx, cy, cz,
  223. sx, sy, sz, cycz, sysz, czsy, cysz;
  224. sx = sinf(angles[0]); cx = cosf(angles[0]);
  225. sy = sinf(angles[1]); cy = cosf(angles[1]);
  226. sz = sinf(angles[2]); cz = cosf(angles[2]);
  227. cycz = cy * cz;
  228. sysz = sy * sz;
  229. czsy = cz * sy;
  230. cysz = cy * sz;
  231. dest[0][0] = cycz + sx * sysz;
  232. dest[0][1] = cx * sz;
  233. dest[0][2] = -czsy + cysz * sx;
  234. dest[1][0] = -cysz + czsy * sx;
  235. dest[1][1] = cx * cz;
  236. dest[1][2] = cycz * sx + sysz;
  237. dest[2][0] = cx * sy;
  238. dest[2][1] = -sx;
  239. dest[2][2] = cx * cy;
  240. dest[0][3] = 0.0f;
  241. dest[1][3] = 0.0f;
  242. dest[2][3] = 0.0f;
  243. dest[3][0] = 0.0f;
  244. dest[3][1] = 0.0f;
  245. dest[3][2] = 0.0f;
  246. dest[3][3] = 1.0f;
  247. }
  248. /*!
  249. * @brief build rotation matrix from euler angles
  250. *
  251. * @param[in] angles angles as vector [Xangle, Yangle, Zangle]
  252. * @param[out] dest rotation matrix
  253. */
  254. CGLM_INLINE
  255. void
  256. glm_euler_yzx(vec3 angles, mat4 dest) {
  257. float cx, cy, cz,
  258. sx, sy, sz, sxsy, cxcy, cysx, cxsy;
  259. sx = sinf(angles[0]); cx = cosf(angles[0]);
  260. sy = sinf(angles[1]); cy = cosf(angles[1]);
  261. sz = sinf(angles[2]); cz = cosf(angles[2]);
  262. sxsy = sx * sy;
  263. cxcy = cx * cy;
  264. cysx = cy * sx;
  265. cxsy = cx * sy;
  266. dest[0][0] = cy * cz;
  267. dest[0][1] = sz;
  268. dest[0][2] = -cz * sy;
  269. dest[1][0] = sxsy - cxcy * sz;
  270. dest[1][1] = cx * cz;
  271. dest[1][2] = cysx + cxsy * sz;
  272. dest[2][0] = cxsy + cysx * sz;
  273. dest[2][1] = -cz * sx;
  274. dest[2][2] = cxcy - sxsy * sz;
  275. dest[0][3] = 0.0f;
  276. dest[1][3] = 0.0f;
  277. dest[2][3] = 0.0f;
  278. dest[3][0] = 0.0f;
  279. dest[3][1] = 0.0f;
  280. dest[3][2] = 0.0f;
  281. dest[3][3] = 1.0f;
  282. }
  283. /*!
  284. * @brief build rotation matrix from euler angles
  285. *
  286. * @param[in] angles angles as vector [Xangle, Yangle, Zangle]
  287. * @param[out] dest rotation matrix
  288. */
  289. CGLM_INLINE
  290. void
  291. glm_euler_zxy(vec3 angles, mat4 dest) {
  292. float cx, cy, cz,
  293. sx, sy, sz, cycz, sxsy, cysz;
  294. sx = sinf(angles[0]); cx = cosf(angles[0]);
  295. sy = sinf(angles[1]); cy = cosf(angles[1]);
  296. sz = sinf(angles[2]); cz = cosf(angles[2]);
  297. cycz = cy * cz;
  298. sxsy = sx * sy;
  299. cysz = cy * sz;
  300. dest[0][0] = cycz - sxsy * sz;
  301. dest[0][1] = cz * sxsy + cysz;
  302. dest[0][2] = -cx * sy;
  303. dest[1][0] = -cx * sz;
  304. dest[1][1] = cx * cz;
  305. dest[1][2] = sx;
  306. dest[2][0] = cz * sy + cysz * sx;
  307. dest[2][1] = -cycz * sx + sy * sz;
  308. dest[2][2] = cx * cy;
  309. dest[0][3] = 0.0f;
  310. dest[1][3] = 0.0f;
  311. dest[2][3] = 0.0f;
  312. dest[3][0] = 0.0f;
  313. dest[3][1] = 0.0f;
  314. dest[3][2] = 0.0f;
  315. dest[3][3] = 1.0f;
  316. }
  317. /*!
  318. * @brief build rotation matrix from euler angles
  319. *
  320. * @param[in] angles angles as vector [Xangle, Yangle, Zangle]
  321. * @param[out] dest rotation matrix
  322. */
  323. CGLM_INLINE
  324. void
  325. glm_euler_zyx(vec3 angles, mat4 dest) {
  326. float cx, cy, cz,
  327. sx, sy, sz, czsx, cxcz, sysz;
  328. sx = sinf(angles[0]); cx = cosf(angles[0]);
  329. sy = sinf(angles[1]); cy = cosf(angles[1]);
  330. sz = sinf(angles[2]); cz = cosf(angles[2]);
  331. czsx = cz * sx;
  332. cxcz = cx * cz;
  333. sysz = sy * sz;
  334. dest[0][0] = cy * cz;
  335. dest[0][1] = cy * sz;
  336. dest[0][2] = -sy;
  337. dest[1][0] = czsx * sy - cx * sz;
  338. dest[1][1] = cxcz + sx * sysz;
  339. dest[1][2] = cy * sx;
  340. dest[2][0] = cxcz * sy + sx * sz;
  341. dest[2][1] = -czsx + cx * sysz;
  342. dest[2][2] = cx * cy;
  343. dest[0][3] = 0.0f;
  344. dest[1][3] = 0.0f;
  345. dest[2][3] = 0.0f;
  346. dest[3][0] = 0.0f;
  347. dest[3][1] = 0.0f;
  348. dest[3][2] = 0.0f;
  349. dest[3][3] = 1.0f;
  350. }
  351. /*!
  352. * @brief build rotation matrix from euler angles
  353. *
  354. * @param[in] angles angles as vector [Xangle, Yangle, Zangle]
  355. * @param[in] ord euler order
  356. * @param[out] dest rotation matrix
  357. */
  358. CGLM_INLINE
  359. void
  360. glm_euler_by_order(vec3 angles, glm_euler_seq ord, mat4 dest) {
  361. float cx, cy, cz,
  362. sx, sy, sz;
  363. float cycz, cysz, cysx, cxcy,
  364. czsy, cxcz, czsx, cxsz,
  365. sysz;
  366. sx = sinf(angles[0]); cx = cosf(angles[0]);
  367. sy = sinf(angles[1]); cy = cosf(angles[1]);
  368. sz = sinf(angles[2]); cz = cosf(angles[2]);
  369. cycz = cy * cz; cysz = cy * sz;
  370. cysx = cy * sx; cxcy = cx * cy;
  371. czsy = cz * sy; cxcz = cx * cz;
  372. czsx = cz * sx; cxsz = cx * sz;
  373. sysz = sy * sz;
  374. switch (ord) {
  375. case GLM_EULER_XZY:
  376. dest[0][0] = cycz;
  377. dest[0][1] = sx * sy + cx * cysz;
  378. dest[0][2] = -cx * sy + cysx * sz;
  379. dest[1][0] = -sz;
  380. dest[1][1] = cxcz;
  381. dest[1][2] = czsx;
  382. dest[2][0] = czsy;
  383. dest[2][1] = -cysx + cx * sysz;
  384. dest[2][2] = cxcy + sx * sysz;
  385. break;
  386. case GLM_EULER_XYZ:
  387. dest[0][0] = cycz;
  388. dest[0][1] = czsx * sy + cxsz;
  389. dest[0][2] = -cx * czsy + sx * sz;
  390. dest[1][0] = -cysz;
  391. dest[1][1] = cxcz - sx * sysz;
  392. dest[1][2] = czsx + cx * sysz;
  393. dest[2][0] = sy;
  394. dest[2][1] = -cysx;
  395. dest[2][2] = cxcy;
  396. break;
  397. case GLM_EULER_YXZ:
  398. dest[0][0] = cycz + sx * sysz;
  399. dest[0][1] = cxsz;
  400. dest[0][2] = -czsy + cysx * sz;
  401. dest[1][0] = czsx * sy - cysz;
  402. dest[1][1] = cxcz;
  403. dest[1][2] = cycz * sx + sysz;
  404. dest[2][0] = cx * sy;
  405. dest[2][1] = -sx;
  406. dest[2][2] = cxcy;
  407. break;
  408. case GLM_EULER_YZX:
  409. dest[0][0] = cycz;
  410. dest[0][1] = sz;
  411. dest[0][2] = -czsy;
  412. dest[1][0] = sx * sy - cx * cysz;
  413. dest[1][1] = cxcz;
  414. dest[1][2] = cysx + cx * sysz;
  415. dest[2][0] = cx * sy + cysx * sz;
  416. dest[2][1] = -czsx;
  417. dest[2][2] = cxcy - sx * sysz;
  418. break;
  419. case GLM_EULER_ZXY:
  420. dest[0][0] = cycz - sx * sysz;
  421. dest[0][1] = czsx * sy + cysz;
  422. dest[0][2] = -cx * sy;
  423. dest[1][0] = -cxsz;
  424. dest[1][1] = cxcz;
  425. dest[1][2] = sx;
  426. dest[2][0] = czsy + cysx * sz;
  427. dest[2][1] = -cycz * sx + sysz;
  428. dest[2][2] = cxcy;
  429. break;
  430. case GLM_EULER_ZYX:
  431. dest[0][0] = cycz;
  432. dest[0][1] = cysz;
  433. dest[0][2] = -sy;
  434. dest[1][0] = czsx * sy - cxsz;
  435. dest[1][1] = cxcz + sx * sysz;
  436. dest[1][2] = cysx;
  437. dest[2][0] = cx * czsy + sx * sz;
  438. dest[2][1] = -czsx + cx * sysz;
  439. dest[2][2] = cxcy;
  440. break;
  441. }
  442. dest[0][3] = 0.0f;
  443. dest[1][3] = 0.0f;
  444. dest[2][3] = 0.0f;
  445. dest[3][0] = 0.0f;
  446. dest[3][1] = 0.0f;
  447. dest[3][2] = 0.0f;
  448. dest[3][3] = 1.0f;
  449. }
  450. /*!
  451. * @brief creates NEW quaternion using rotation angles and does
  452. * rotations in x y z order (roll pitch yaw)
  453. *
  454. * @param[in] angles angles x y z (radians)
  455. * @param[out] dest quaternion
  456. */
  457. CGLM_INLINE
  458. void
  459. glm_euler_xyz_quat(vec3 angles, versor dest) {
  460. #ifdef CGLM_FORCE_LEFT_HANDED
  461. glm_euler_xyz_quat_lh(angles, dest);
  462. #else
  463. glm_euler_xyz_quat_rh(angles, dest);
  464. #endif
  465. }
  466. /*!
  467. * @brief creates NEW quaternion using rotation angles and does
  468. * rotations in x z y order (roll yaw pitch)
  469. *
  470. * @param[in] angles angles x y z (radians)
  471. * @param[out] dest quaternion
  472. */
  473. CGLM_INLINE
  474. void
  475. glm_euler_xzy_quat(vec3 angles, versor dest) {
  476. #ifdef CGLM_FORCE_LEFT_HANDED
  477. glm_euler_xzy_quat_lh(angles, dest);
  478. #else
  479. glm_euler_xzy_quat_rh(angles, dest);
  480. #endif
  481. }
  482. /*!
  483. * @brief creates NEW quaternion using rotation angles and does
  484. * rotations in y x z order (pitch roll yaw)
  485. *
  486. * @param[in] angles angles x y z (radians)
  487. * @param[out] dest quaternion
  488. */
  489. CGLM_INLINE
  490. void
  491. glm_euler_yxz_quat(vec3 angles, versor dest) {
  492. #ifdef CGLM_FORCE_LEFT_HANDED
  493. glm_euler_yxz_quat_lh(angles, dest);
  494. #else
  495. glm_euler_yxz_quat_rh(angles, dest);
  496. #endif
  497. }
  498. /*!
  499. * @brief creates NEW quaternion using rotation angles and does
  500. * rotations in y z x order (pitch yaw roll)
  501. *
  502. * @param[in] angles angles x y z (radians)
  503. * @param[out] dest quaternion
  504. */
  505. CGLM_INLINE
  506. void
  507. glm_euler_yzx_quat(vec3 angles, versor dest) {
  508. #ifdef CGLM_FORCE_LEFT_HANDED
  509. glm_euler_yzx_quat_lh(angles, dest);
  510. #else
  511. glm_euler_yzx_quat_rh(angles, dest);
  512. #endif
  513. }
  514. /*!
  515. * @brief creates NEW quaternion using rotation angles and does
  516. * rotations in z x y order (yaw roll pitch)
  517. *
  518. * @param[in] angles angles x y z (radians)
  519. * @param[out] dest quaternion
  520. */
  521. CGLM_INLINE
  522. void
  523. glm_euler_zxy_quat(vec3 angles, versor dest) {
  524. #ifdef CGLM_FORCE_LEFT_HANDED
  525. glm_euler_zxy_quat_lh(angles, dest);
  526. #else
  527. glm_euler_zxy_quat_rh(angles, dest);
  528. #endif
  529. }
  530. /*!
  531. * @brief creates NEW quaternion using rotation angles and does
  532. * rotations in z y x order (yaw pitch roll)
  533. *
  534. * @param[in] angles angles x y z (radians)
  535. * @param[out] dest quaternion
  536. */
  537. CGLM_INLINE
  538. void
  539. glm_euler_zyx_quat(vec3 angles, versor dest) {
  540. #ifdef CGLM_FORCE_LEFT_HANDED
  541. glm_euler_zyx_quat_lh(angles, dest);
  542. #else
  543. glm_euler_zyx_quat_rh(angles, dest);
  544. #endif
  545. }
  546. #endif /* cglm_euler_h */