mat3.rst 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. .. default-domain:: C
  2. mat3
  3. ====
  4. Header: cglm/mat3.h
  5. Table of contents (click to go):
  6. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  7. Macros:
  8. 1. GLM_MAT3_IDENTITY_INIT
  9. #. GLM_MAT3_ZERO_INIT
  10. #. GLM_MAT3_IDENTITY
  11. #. GLM_MAT3_ZERO
  12. #. glm_mat3_dup(mat, dest)
  13. Functions:
  14. 1. :c:func:`glm_mat3_copy`
  15. #. :c:func:`glm_mat3_identity`
  16. #. :c:func:`glm_mat3_identity_array`
  17. #. :c:func:`glm_mat3_zero`
  18. #. :c:func:`glm_mat3_mul`
  19. #. :c:func:`glm_mat3_transpose_to`
  20. #. :c:func:`glm_mat3_transpose`
  21. #. :c:func:`glm_mat3_mulv`
  22. #. :c:func:`glm_mat3_quat`
  23. #. :c:func:`glm_mat3_scale`
  24. #. :c:func:`glm_mat3_det`
  25. #. :c:func:`glm_mat3_inv`
  26. #. :c:func:`glm_mat3_trace`
  27. #. :c:func:`glm_mat3_swap_col`
  28. #. :c:func:`glm_mat3_swap_row`
  29. #. :c:func:`glm_mat3_rmc`
  30. #. :c:func:`glm_mat3_make`
  31. #. :c:func:`glm_mat3_textrans`
  32. Functions documentation
  33. ~~~~~~~~~~~~~~~~~~~~~~~
  34. .. c:function:: void glm_mat3_copy(mat3 mat, mat3 dest)
  35. copy mat3 to another one (dest).
  36. Parameters:
  37. | *[in]* **mat** source
  38. | *[out]* **dest** destination
  39. .. c:function:: void glm_mat3_identity(mat3 mat)
  40. copy identity mat3 to mat, or makes mat to identity
  41. Parameters:
  42. | *[out]* **mat** matrix
  43. .. c:function:: void glm_mat3_identity_array(mat3 * __restrict mat, size_t count)
  44. make given matrix array's each element identity matrix
  45. Parameters:
  46. | *[in,out]* **mat** matrix array (must be aligned (16/32) if alignment is not disabled)
  47. | *[in]* **count** count of matrices
  48. .. c:function:: void glm_mat3_zero(mat3 mat)
  49. make given matrix zero
  50. Parameters:
  51. | *[in,out]* **mat** matrix to
  52. .. c:function:: void glm_mat3_mul(mat3 m1, mat3 m2, mat3 dest)
  53. multiply m1 and m2 to dest
  54. m1, m2 and dest matrices can be same matrix, it is possible to write this:
  55. .. code-block:: c
  56. mat3 m = GLM_MAT3_IDENTITY_INIT;
  57. glm_mat3_mul(m, m, m);
  58. Parameters:
  59. | *[in]* **m1** left matrix
  60. | *[in]* **m2** right matrix
  61. | *[out]* **dest** destination matrix
  62. .. c:function:: void glm_mat3_transpose_to(mat3 m, mat3 dest)
  63. transpose mat4 and store in dest
  64. source matrix will not be transposed unless dest is m
  65. Parameters:
  66. | *[in]* **mat** source
  67. | *[out]* **dest** destination
  68. .. c:function:: void glm_mat3_transpose(mat3 m)
  69. transpose mat3 and store result in same matrix
  70. Parameters:
  71. | *[in]* **mat** source
  72. | *[out]* **dest** destination
  73. .. c:function:: void glm_mat3_mulv(mat3 m, vec3 v, vec3 dest)
  74. multiply mat3 with vec3 (column vector) and store in dest vector
  75. Parameters:
  76. | *[in]* **m** mat3 (left)
  77. | *[in]* **v** vec3 (right, column vector)
  78. | *[out]* **dest** destination (result, column vector)
  79. .. c:function:: void glm_mat3_quat(mat3 m, versor dest)
  80. convert mat3 to quaternion
  81. Parameters:
  82. | *[in]* **m** rotation matrix
  83. | *[out]* **dest** destination quaternion
  84. .. c:function:: void glm_mat3_scale(mat3 m, float s)
  85. multiply matrix with scalar
  86. Parameters:
  87. | *[in, out]* **m** matrix
  88. | *[in]* **s** scalar
  89. .. c:function:: float glm_mat3_det(mat3 mat)
  90. returns mat3 determinant
  91. Parameters:
  92. | *[in]* **mat** matrix
  93. Returns:
  94. mat3 determinant
  95. .. c:function:: void glm_mat3_inv(mat3 mat, mat3 dest)
  96. inverse mat3 and store in dest
  97. Parameters:
  98. | *[in]* **mat** matrix
  99. | *[out]* **dest** destination (inverse matrix)
  100. .. c:function:: void glm_mat3_trace(mat3 m)
  101. | sum of the elements on the main diagonal from upper left to the lower right
  102. Parameters:
  103. | *[in]* **m** matrix
  104. Returns:
  105. trace of matrix
  106. .. c:function:: void glm_mat3_swap_col(mat3 mat, int col1, int col2)
  107. swap two matrix columns
  108. Parameters:
  109. | *[in, out]* **mat** matrix
  110. | *[in]* **col1** col1
  111. | *[in]* **col2** col2
  112. .. c:function:: void glm_mat3_swap_row(mat3 mat, int row1, int row2)
  113. swap two matrix rows
  114. Parameters:
  115. | *[in, out]* **mat** matrix
  116. | *[in]* **row1** row1
  117. | *[in]* **row2** row2
  118. .. c:function:: float glm_mat3_rmc(vec3 r, mat3 m, vec3 c)
  119. | **rmc** stands for **Row** * **Matrix** * **Column**
  120. | helper for R (row vector) * M (matrix) * C (column vector)
  121. | the result is scalar because R * M = Matrix1x3 (row vector),
  122. | then Matrix1x3 * Vec3 (column vector) = Matrix1x1 (Scalar)
  123. Parameters:
  124. | *[in]* **r** row vector or matrix1x3
  125. | *[in]* **m** matrix3x3
  126. | *[in]* **c** column vector or matrix3x1
  127. Returns:
  128. scalar value e.g. Matrix1x1
  129. .. c:function:: void glm_mat3_make(const float * __restrict src, mat3 dest)
  130. Create mat3 matrix from pointer
  131. .. note:: **@src** must contain at least 9 elements.
  132. Parameters:
  133. | *[in]* **src** pointer to an array of floats
  134. | *[out]* **dest** destination matrix3x3
  135. .. c:function:: void glm_mat3_textrans(float sx, float sy, float rot, float tx, float ty, mat3 dest)
  136. Create texture transformation matrix, rotation is in radians CCW/RH
  137. Parameters:
  138. | *[in]* **sx** scale x
  139. | *[in]* **sy** scale y
  140. | *[in]* **rot** rotation in radians CCW/RH
  141. | *[in]* **tx** translation x
  142. | *[in]* **ty** translation y
  143. | *[out]* **dest** destination matrix3x3