quat.rst 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. .. default-domain:: C
  2. quaternions
  3. ===========
  4. Header: cglm/quat.h
  5. **Important:** *cglm* stores quaternion as [w, x, y, z] in memory, don't
  6. forget that when changing quaternion items manually. For instance *quat[3]*
  7. is *quat.z* and *quat[0*] is *quat.w*. This may change in the future if *cglm*
  8. will got enough request to do that. Probably it will not be changed in near
  9. future
  10. There are some TODOs for quaternions check TODO list to see them.
  11. Also **versor** is identity quaternion so the type may change to **vec4** or
  12. something else. This will not affect existing functions for your engine because
  13. *versor* is alias of *vec4*
  14. Table of contents (click to go):
  15. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  16. Macros:
  17. 1. GLM_QUAT_IDENTITY_INIT
  18. #. GLM_QUAT_IDENTITY
  19. Functions:
  20. 1. :c:func:`glm_quat_identity`
  21. #. :c:func:`glm_quat`
  22. #. :c:func:`glm_quatv`
  23. #. :c:func:`glm_quat_norm`
  24. #. :c:func:`glm_quat_normalize`
  25. #. :c:func:`glm_quat_dot`
  26. #. :c:func:`glm_quat_mulv`
  27. #. :c:func:`glm_quat_mat4`
  28. #. :c:func:`glm_quat_slerp`
  29. Functions documentation
  30. ~~~~~~~~~~~~~~~~~~~~~~~
  31. .. c:function:: void glm_quat_identity(versor q)
  32. | makes given quat to identity
  33. Parameters:
  34. | *[in, out]* **q** quaternion
  35. .. c:function:: void glm_quat(versor q, float angle, float x, float y, float z)
  36. | creates NEW quaternion with individual axis components
  37. Parameters:
  38. | *[out]* **q** quaternion
  39. | *[in]* **angle** angle (radians)
  40. | *[in]* **x** axis.x
  41. | *[in]* **y** axis.y
  42. | *[in]* **z** axis.z
  43. .. c:function:: void glm_quatv(versor q, float angle, vec3 v)
  44. | creates NEW quaternion with axis vector
  45. Parameters:
  46. | *[out]* **q** quaternion
  47. | *[in]* **angle** angle (radians)
  48. | *[in]* **v** axis
  49. .. c:function:: float glm_quat_norm(versor q)
  50. | returns norm (magnitude) of quaternion
  51. Parameters:
  52. | *[in]* **a** quaternion
  53. Returns:
  54. norm (magnitude)
  55. .. c:function:: void glm_quat_normalize(versor q)
  56. | normalize quaternion
  57. Parameters:
  58. | *[in, out]* **q** quaternion
  59. .. c:function:: float glm_quat_dot(versor q, versor r)
  60. dot product of two quaternion
  61. Parameters:
  62. | *[in]* **q1** quaternion 1
  63. | *[in]* **q2** quaternion 2
  64. Returns:
  65. dot product
  66. .. c:function:: void glm_quat_mulv(versor q1, versor q2, versor dest)
  67. | multiplies two quaternion and stores result in dest
  68. Parameters:
  69. | *[in]* **q1** quaternion 1
  70. | *[in]* **q2** quaternion 2
  71. | *[out]* **dest** result quaternion
  72. .. c:function:: void glm_quat_mat4(versor q, mat4 dest)
  73. | convert quaternion to mat4
  74. Parameters:
  75. | *[in]* **q** quaternion
  76. | *[out]* **dest** result matrix
  77. .. c:function:: void glm_quat_slerp(versor q, versor r, float t, versor dest)
  78. | interpolates between two quaternions
  79. | using spherical linear interpolation (SLERP)
  80. Parameters:
  81. | *[in]* **q** from
  82. | *[in]* **r** to
  83. | *[in]* **t** amout
  84. | *[out]* **dest** result quaternion