mat2.rst 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. .. default-domain:: C
  2. mat2
  3. ====
  4. Header: cglm/mat2.h
  5. Table of contents (click to go):
  6. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  7. Macros:
  8. 1. GLM_mat2_IDENTITY_INIT
  9. #. GLM_mat2_ZERO_INIT
  10. #. GLM_mat2_IDENTITY
  11. #. GLM_mat2_ZERO
  12. Functions:
  13. 1. :c:func:`glm_mat2_copy`
  14. #. :c:func:`glm_mat2_identity`
  15. #. :c:func:`glm_mat2_identity_array`
  16. #. :c:func:`glm_mat2_zero`
  17. #. :c:func:`glm_mat2_mul`
  18. #. :c:func:`glm_mat2_transpose_to`
  19. #. :c:func:`glm_mat2_transpose`
  20. #. :c:func:`glm_mat2_mulv`
  21. #. :c:func:`glm_mat2_scale`
  22. #. :c:func:`glm_mat2_det`
  23. #. :c:func:`glm_mat2_inv`
  24. #. :c:func:`glm_mat2_trace`
  25. #. :c:func:`glm_mat2_swap_col`
  26. #. :c:func:`glm_mat2_swap_row`
  27. #. :c:func:`glm_mat2_rmc`
  28. #. :c:func:`glm_mat2_make`
  29. Functions documentation
  30. ~~~~~~~~~~~~~~~~~~~~~~~
  31. .. c:function:: void glm_mat2_copy(mat2 mat, mat2 dest)
  32. copy mat2 to another one (dest).
  33. Parameters:
  34. | *[in]* **mat** source
  35. | *[out]* **dest** destination
  36. .. c:function:: void glm_mat2_identity(mat2 mat)
  37. copy identity mat2 to mat, or makes mat to identity
  38. Parameters:
  39. | *[out]* **mat** matrix
  40. .. c:function:: void glm_mat2_identity_array(mat2 * __restrict mat, size_t count)
  41. make given matrix array's each element identity matrix
  42. Parameters:
  43. | *[in,out]* **mat** matrix array (must be aligned (16/32) if alignment is not disabled)
  44. | *[in]* **count** count of matrices
  45. .. c:function:: void glm_mat2_zero(mat2 mat)
  46. make given matrix zero
  47. Parameters:
  48. | *[in,out]* **mat** matrix
  49. .. c:function:: void glm_mat2_mul(mat2 m1, mat2 m2, mat2 dest)
  50. multiply m1 and m2 to dest
  51. m1, m2 and dest matrices can be same matrix, it is possible to write this:
  52. .. code-block:: c
  53. mat2 m = GLM_mat2_IDENTITY_INIT;
  54. glm_mat2_mul(m, m, m);
  55. Parameters:
  56. | *[in]* **m1** left matrix
  57. | *[in]* **m2** right matrix
  58. | *[out]* **dest** destination matrix
  59. .. c:function:: void glm_mat2_transpose_to(mat2 m, mat2 dest)
  60. transpose mat4 and store in dest
  61. source matrix will not be transposed unless dest is m
  62. Parameters:
  63. | *[in]* **mat** source
  64. | *[out]* **dest** destination
  65. .. c:function:: void glm_mat2_transpose(mat2 m)
  66. transpose mat2 and store result in same matrix
  67. Parameters:
  68. | *[in]* **mat** source
  69. | *[out]* **dest** destination
  70. .. c:function:: void glm_mat2_mulv(mat2 m, vec2 v, vec2 dest)
  71. multiply mat2 with vec2 (column vector) and store in dest vector
  72. Parameters:
  73. | *[in]* **mat** mat2 (left)
  74. | *[in]* **v** vec2 (right, column vector)
  75. | *[out]* **dest** destination (result, column vector)
  76. .. c:function:: void glm_mat2_scale(mat2 m, float s)
  77. multiply matrix with scalar
  78. Parameters:
  79. | *[in, out]* **m** matrix
  80. | *[in]* **s** scalar
  81. .. c:function:: float glm_mat2_det(mat2 mat)
  82. returns mat2 determinant
  83. Parameters:
  84. | *[in]* **mat** matrix
  85. Returns:
  86. mat2 determinant
  87. .. c:function:: void glm_mat2_inv(mat2 mat, mat2 dest)
  88. inverse mat2 and store in dest
  89. Parameters:
  90. | *[in]* **mat** matrix
  91. | *[out]* **dest** destination (inverse matrix)
  92. .. c:function:: void glm_mat2_trace(mat2 m)
  93. | sum of the elements on the main diagonal from upper left to the lower right
  94. Parameters:
  95. | *[in]* **m** matrix
  96. Returns:
  97. trace of matrix
  98. .. c:function:: void glm_mat2_swap_col(mat2 mat, int col1, int col2)
  99. swap two matrix columns
  100. Parameters:
  101. | *[in, out]* **mat** matrix
  102. | *[in]* **col1** col1
  103. | *[in]* **col2** col2
  104. .. c:function:: void glm_mat2_swap_row(mat2 mat, int row1, int row2)
  105. swap two matrix rows
  106. Parameters:
  107. | *[in, out]* **mat** matrix
  108. | *[in]* **row1** row1
  109. | *[in]* **row2** row2
  110. .. c:function:: float glm_mat2_rmc(vec2 r, mat2 m, vec2 c)
  111. | **rmc** stands for **Row** * **Matrix** * **Column**
  112. | helper for R (row vector) * M (matrix) * C (column vector)
  113. | the result is scalar because R * M = Matrix1x2 (row vector),
  114. | then Matrix1x2 * Vec2 (column vector) = Matrix1x1 (Scalar)
  115. Parameters:
  116. | *[in]* **r** row vector or matrix1x2
  117. | *[in]* **m** matrix2x2
  118. | *[in]* **c** column vector or matrix2x1
  119. Returns:
  120. scalar value e.g. Matrix1x1
  121. .. c:function:: void glm_mat2_make(float * __restrict src, mat2 dest)
  122. Create mat2 matrix from pointer
  123. .. note:: **@src** must contain at least 4 elements.
  124. Parameters:
  125. | *[in]* **src** pointer to an array of floats
  126. | *[out]* **dest** destination matrix2x2