affine-mat.rst 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. .. default-domain:: C
  2. 3D Affine Transform Matrix (specialized functions)
  3. ================================================================================
  4. Header: cglm/affine-mat.h
  5. We mostly use glm_mat4_* for 4x4 general and transform matrices. **cglm**
  6. provides optimized version of some functions. Because affine transform matrix is
  7. a known format, for instance all last item of first three columns is zero.
  8. You should be careful when using these functions. For instance :c:func:`glm_mul`
  9. assumes matrix will be this format:
  10. .. code-block:: text
  11. R R R X
  12. R R R Y
  13. R R R Z
  14. 0 0 0 W
  15. if you override zero values here then use :c:func:`glm_mat4_mul` version.
  16. You cannot use :c:func:`glm_mul` anymore.
  17. Same is also true for :c:func:`glm_inv_tr` if you only have rotation and
  18. translation then it will work as expected, otherwise you cannot use that.
  19. In the future it may accept scale factors too but currectly it does not.
  20. Table of contents (click func go):
  21. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  22. Functions:
  23. 1. :c:func:`glm_mul`
  24. #. :c:func:`glm_mul_rot`
  25. #. :c:func:`glm_inv_tr`
  26. Functions documentation
  27. ~~~~~~~~~~~~~~~~~~~~~~~
  28. .. c:function:: void glm_mul(mat4 m1, mat4 m2, mat4 dest)
  29. | this is similar to glm_mat4_mul but specialized to affine transform
  30. Matrix format should be:
  31. .. code-block:: text
  32. R R R X
  33. R R R Y
  34. R R R Z
  35. 0 0 0 W
  36. this reduces some multiplications. It should be faster than mat4_mul.
  37. if you are not sure about matrix format then DON'T use this! use mat4_mul
  38. Parameters:
  39. | *[in]* **m1** affine matrix 1
  40. | *[in]* **m2** affine matrix 2
  41. | *[out]* **dest** result matrix
  42. .. c:function:: void glm_mul_rot(mat4 m1, mat4 m2, mat4 dest)
  43. | this is similar to glm_mat4_mul but specialized to rotation matrix
  44. Right Matrix format should be (left is free):
  45. .. code-block:: text
  46. R R R 0
  47. R R R 0
  48. R R R 0
  49. 0 0 0 1
  50. this reduces some multiplications. It should be faster than mat4_mul.
  51. if you are not sure about matrix format then DON'T use this! use mat4_mul
  52. Parameters:
  53. | *[in]* **m1** affine matrix 1
  54. | *[in]* **m2** affine matrix 2
  55. | *[out]* **dest** result matrix
  56. .. c:function:: void glm_inv_tr(mat4 mat)
  57. | inverse orthonormal rotation + translation matrix (ridig-body)
  58. .. code-block:: text
  59. X = | R T | X' = | R' -R'T |
  60. | 0 1 | | 0 1 |
  61. use this if you only have rotation + translation, this should work faster
  62. than :c:func:`glm_mat4_inv`
  63. Don't use this if your matrix includes other things e.g. scale, shear...
  64. Parameters:
  65. | *[in,out]* **mat** affine matrix