affine-pre.rst 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  1. .. default-domain:: C
  2. 3D Affine Transforms (pre)
  3. ================================================================================
  4. Pre transfrom functions which are regular transfrom functions.
  5. Table of contents (click to go):
  6. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  7. Functions:
  8. 1. :c:func:`glm_translate_to`
  9. #. :c:func:`glm_translate`
  10. #. :c:func:`glm_translate_x`
  11. #. :c:func:`glm_translate_y`
  12. #. :c:func:`glm_translate_z`
  13. #. :c:func:`glm_translate_make`
  14. #. :c:func:`glm_scale_to`
  15. #. :c:func:`glm_scale_make`
  16. #. :c:func:`glm_scale`
  17. #. :c:func:`glm_scale_uni`
  18. #. :c:func:`glm_rotate_x`
  19. #. :c:func:`glm_rotate_y`
  20. #. :c:func:`glm_rotate_z`
  21. #. :c:func:`glm_rotate_make`
  22. #. :c:func:`glm_rotate`
  23. #. :c:func:`glm_rotate_at`
  24. #. :c:func:`glm_rotate_atm`
  25. #. :c:func:`glm_decompose_scalev`
  26. #. :c:func:`glm_uniscaled`
  27. #. :c:func:`glm_decompose_rs`
  28. #. :c:func:`glm_decompose`
  29. #. :c:func:`glm_spin`
  30. Functions documentation
  31. ~~~~~~~~~~~~~~~~~~~~~~~
  32. .. c:function:: void glm_translate_to(mat4 m, vec3 v, mat4 dest)
  33. translate existing transform matrix by *v* vector and store result in dest
  34. Parameters:
  35. | *[in]* **m** affine transfrom
  36. | *[in]* **v** translate vector [x, y, z]
  37. | *[out]* **dest** translated matrix
  38. .. c:function:: void glm_translate(mat4 m, vec3 v)
  39. translate existing transform matrix by *v* vector
  40. and stores result in same matrix
  41. Parameters:
  42. | *[in, out]* **m** affine transfrom
  43. | *[in]* **v** translate vector [x, y, z]
  44. .. c:function:: void glm_translate_x(mat4 m, float x)
  45. translate existing transform matrix by x factor
  46. Parameters:
  47. | *[in, out]* **m** affine transfrom
  48. | *[in]* **v** x factor
  49. .. c:function:: void glm_translate_y(mat4 m, float y)
  50. translate existing transform matrix by *y* factor
  51. Parameters:
  52. | *[in, out]* **m** affine transfrom
  53. | *[in]* **v** y factor
  54. .. c:function:: void glm_translate_z(mat4 m, float z)
  55. translate existing transform matrix by *z* factor
  56. Parameters:
  57. | *[in, out]* **m** affine transfrom
  58. | *[in]* **v** z factor
  59. .. c:function:: void glm_translate_make(mat4 m, vec3 v)
  60. creates NEW translate transform matrix by *v* vector.
  61. Parameters:
  62. | *[in, out]* **m** affine transfrom
  63. | *[in]* **v** translate vector [x, y, z]
  64. .. c:function:: void glm_scale_to(mat4 m, vec3 v, mat4 dest)
  65. scale existing transform matrix by *v* vector and store result in dest
  66. Parameters:
  67. | *[in]* **m** affine transfrom
  68. | *[in]* **v** scale vector [x, y, z]
  69. | *[out]* **dest** scaled matrix
  70. .. c:function:: void glm_scale_make(mat4 m, vec3 v)
  71. creates NEW scale matrix by v vector
  72. Parameters:
  73. | *[out]* **m** affine transfrom
  74. | *[in]* **v** scale vector [x, y, z]
  75. .. c:function:: void glm_scale(mat4 m, vec3 v)
  76. scales existing transform matrix by v vector
  77. and stores result in same matrix
  78. Parameters:
  79. | *[in, out]* **m** affine transfrom
  80. | *[in]* **v** scale vector [x, y, z]
  81. .. c:function:: void glm_scale_uni(mat4 m, float s)
  82. applies uniform scale to existing transform matrix v = [s, s, s]
  83. and stores result in same matrix
  84. Parameters:
  85. | *[in, out]* **m** affine transfrom
  86. | *[in]* **v** scale factor
  87. .. c:function:: void glm_rotate_x(mat4 m, float angle, mat4 dest)
  88. rotate existing transform matrix around X axis by angle
  89. and store result in dest
  90. Parameters:
  91. | *[in]* **m** affine transfrom
  92. | *[in]* **angle** angle (radians)
  93. | *[out]* **dest** rotated matrix
  94. .. c:function:: void glm_rotate_y(mat4 m, float angle, mat4 dest)
  95. rotate existing transform matrix around Y axis by angle
  96. and store result in dest
  97. Parameters:
  98. | *[in]* **m** affine transfrom
  99. | *[in]* **angle** angle (radians)
  100. | *[out]* **dest** rotated matrix
  101. .. c:function:: void glm_rotate_z(mat4 m, float angle, mat4 dest)
  102. rotate existing transform matrix around Z axis by angle
  103. and store result in dest
  104. Parameters:
  105. | *[in]* **m** affine transfrom
  106. | *[in]* **angle** angle (radians)
  107. | *[out]* **dest** rotated matrix
  108. .. c:function:: void glm_rotate_make(mat4 m, float angle, vec3 axis)
  109. creates NEW rotation matrix by angle and axis,
  110. axis will be normalized so you don't need to normalize it
  111. Parameters:
  112. | *[out]* **m** affine transfrom
  113. | *[in]* **axis** angle (radians)
  114. | *[in]* **axis** axis
  115. .. c:function:: void glm_rotate(mat4 m, float angle, vec3 axis)
  116. rotate existing transform matrix around Z axis by angle and axis
  117. Parameters:
  118. | *[in, out]* **m** affine transfrom
  119. | *[in]* **angle** angle (radians)
  120. | *[in]* **axis** axis
  121. .. c:function:: void glm_rotate_at(mat4 m, vec3 pivot, float angle, vec3 axis)
  122. rotate existing transform around given axis by angle at given pivot point (rotation center)
  123. Parameters:
  124. | *[in, out]* **m** affine transfrom
  125. | *[in]* **pivot** pivot, anchor point, rotation center
  126. | *[in]* **angle** angle (radians)
  127. | *[in]* **axis** axis
  128. .. c:function:: void glm_rotate_atm(mat4 m, vec3 pivot, float angle, vec3 axis)
  129. | creates NEW rotation matrix by angle and axis at given point
  130. | this creates rotation matrix, it assumes you don't have a matrix
  131. | this should work faster than glm_rotate_at because it reduces one glm_translate.
  132. Parameters:
  133. | *[in, out]* **m** affine transfrom
  134. | *[in]* **pivot** pivot, anchor point, rotation center
  135. | *[in]* **angle** angle (radians)
  136. | *[in]* **axis** axis
  137. .. c:function:: void glm_decompose_scalev(mat4 m, vec3 s)
  138. decompose scale vector
  139. Parameters:
  140. | *[in]* **m** affine transform
  141. | *[out]* **s** scale vector (Sx, Sy, Sz)
  142. .. c:function:: bool glm_uniscaled(mat4 m)
  143. returns true if matrix is uniform scaled.
  144. This is helpful for creating normal matrix.
  145. Parameters:
  146. | *[in]* **m** matrix
  147. .. c:function:: void glm_decompose_rs(mat4 m, mat4 r, vec3 s)
  148. decompose rotation matrix (mat4) and scale vector [Sx, Sy, Sz]
  149. DON'T pass projected matrix here
  150. Parameters:
  151. | *[in]* **m** affine transform
  152. | *[out]* **r** rotation matrix
  153. | *[out]* **s** scale matrix
  154. .. c:function:: void glm_decompose(mat4 m, vec4 t, mat4 r, vec3 s)
  155. decompose affine transform, TODO: extract shear factors.
  156. DON'T pass projected matrix here
  157. Parameters:
  158. | *[in]* **m** affine transfrom
  159. | *[out]* **t** translation vector
  160. | *[out]* **r** rotation matrix (mat4)
  161. | *[out]* **s** scaling vector [X, Y, Z]
  162. .. c:function:: void glm_spin(mat4 m, float angle, vec3 axis)
  163. | rotate existing transform matrix around given axis by angle around self (doesn't affected by position)
  164. Parameters:
  165. | *[in, out]* **m** affine transfrom
  166. | *[in]* **angle** angle (radians)
  167. | *[in]* **axis** axis