affine-pre.rst 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. .. default-domain:: C
  2. 3D Affine Transforms (pre)
  3. ================================================================================
  4. Pre transform functions which are regular transform 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 transform
  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 transform
  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 transform
  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 transform
  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 transform
  58. | *[in]* **v** z factor
  59. .. c:function:: void glm_rotate_x(mat4 m, float angle, mat4 dest)
  60. rotate existing transform matrix around X axis by angle
  61. and store result in dest
  62. Parameters:
  63. | *[in]* **m** affine transform
  64. | *[in]* **angle** angle (radians)
  65. | *[out]* **dest** rotated matrix
  66. .. c:function:: void glm_rotate_y(mat4 m, float angle, mat4 dest)
  67. rotate existing transform matrix around Y axis by angle
  68. and store result in dest
  69. Parameters:
  70. | *[in]* **m** affine transform
  71. | *[in]* **angle** angle (radians)
  72. | *[out]* **dest** rotated matrix
  73. .. c:function:: void glm_rotate_z(mat4 m, float angle, mat4 dest)
  74. rotate existing transform matrix around Z axis by angle
  75. and store result in dest
  76. Parameters:
  77. | *[in]* **m** affine transform
  78. | *[in]* **angle** angle (radians)
  79. | *[out]* **dest** rotated matrix
  80. .. c:function:: void glm_rotate(mat4 m, float angle, vec3 axis)
  81. rotate existing transform matrix around given axis by angle at ORIGIN (0,0,0)
  82. **❗️IMPORTANT ❗️**
  83. If you need to rotate object around itself e.g. center of object or at
  84. some point [of object] then `glm_rotate_at()` would be better choice to do so.
  85. Even if object's model transform is identiy, rotation may not be around
  86. center of object if object does not lay out at ORIGIN perfectly.
  87. Using `glm_rotate_at()` with center of bounding shape ( AABB, Sphere ... )
  88. would be an easy option to rotate around object if object is not at origin.
  89. One another option to rotate around itself at any point is `glm_spin()`
  90. which is perfect if only rotating around model position is desired e.g. not
  91. specific point on model for instance center of geometry or center of mass,
  92. again if geometry is not perfectly centered at origin at identity transform,
  93. rotation may not be around geometry.
  94. Parameters:
  95. | *[in, out]* **m** affine transform
  96. | *[in]* **angle** angle (radians)
  97. | *[in]* **axis** axis
  98. .. c:function:: void glm_rotate_at(mat4 m, vec3 pivot, float angle, vec3 axis)
  99. rotate existing transform around given axis by angle at given pivot point (rotation center)
  100. Parameters:
  101. | *[in, out]* **m** affine transform
  102. | *[in]* **pivot** pivot, anchor point, rotation center
  103. | *[in]* **angle** angle (radians)
  104. | *[in]* **axis** axis
  105. .. c:function:: void glm_spin(mat4 m, float angle, vec3 axis)
  106. | rotate existing transform matrix around given axis by angle around self (doesn't affected by position)
  107. Parameters:
  108. | *[in, out]* **m** affine transform
  109. | *[in]* **angle** angle (radians)
  110. | *[in]* **axis** axis