mat2.rst 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  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. Functions documentation
  29. ~~~~~~~~~~~~~~~~~~~~~~~
  30. .. c:function:: void glm_mat2_copy(mat2 mat, mat2 dest)
  31. copy mat2 to another one (dest).
  32. Parameters:
  33. | *[in]* **mat** source
  34. | *[out]* **dest** destination
  35. .. c:function:: void glm_mat2_identity(mat2 mat)
  36. copy identity mat2 to mat, or makes mat to identiy
  37. Parameters:
  38. | *[out]* **mat** matrix
  39. .. c:function:: void glm_mat2_identity_array(mat2 * __restrict mat, size_t count)
  40. make given matrix array's each element identity matrix
  41. Parameters:
  42. | *[in,out]* **mat** matrix array (must be aligned (16/32) if alignment is not disabled)
  43. | *[in]* **count** count of matrices
  44. .. c:function:: void glm_mat2_zero(mat2 mat)
  45. make given matrix zero
  46. Parameters:
  47. | *[in,out]* **mat** matrix to
  48. .. c:function:: void glm_mat2_mul(mat2 m1, mat2 m2, mat2 dest)
  49. multiply m1 and m2 to dest
  50. m1, m2 and dest matrices can be same matrix, it is possible to write this:
  51. .. code-block:: c
  52. mat2 m = GLM_mat2_IDENTITY_INIT;
  53. glm_mat2_mul(m, m, m);
  54. Parameters:
  55. | *[in]* **m1** left matrix
  56. | *[in]* **m2** right matrix
  57. | *[out]* **dest** destination matrix
  58. .. c:function:: void glm_mat2_transpose_to(mat2 m, mat2 dest)
  59. transpose mat4 and store in dest
  60. source matrix will not be transposed unless dest is m
  61. Parameters:
  62. | *[in]* **mat** source
  63. | *[out]* **dest** destination
  64. .. c:function:: void glm_mat2_transpose(mat2 m)
  65. tranpose mat2 and store result in same matrix
  66. Parameters:
  67. | *[in]* **mat** source
  68. | *[out]* **dest** destination
  69. .. c:function:: void glm_mat2_mulv(mat2 m, vec2 v, vec2 dest)
  70. multiply mat4 with vec4 (column vector) and store in dest vector
  71. Parameters:
  72. | *[in]* **mat** mat2 (left)
  73. | *[in]* **v** vec2 (right, column vector)
  74. | *[out]* **dest** destination (result, column vector)
  75. .. c:function:: void glm_mat2_scale(mat2 m, float s)
  76. multiply matrix with scalar
  77. Parameters:
  78. | *[in, out]* **mat** matrix
  79. | *[in]* **dest** scalar
  80. .. c:function:: float glm_mat2_det(mat2 mat)
  81. returns mat2 determinant
  82. Parameters:
  83. | *[in]* **mat** matrix
  84. Returns:
  85. mat2 determinant
  86. .. c:function:: void glm_mat2_inv(mat2 mat, mat2 dest)
  87. inverse mat2 and store in dest
  88. Parameters:
  89. | *[in]* **mat** matrix
  90. | *[out]* **dest** destination (inverse matrix)
  91. .. c:function:: void glm_mat2_trace(mat2 m)
  92. | sum of the elements on the main diagonal from upper left to the lower right
  93. Parameters:
  94. | *[in]* **m** matrix
  95. Returns:
  96. trace of matrix
  97. .. c:function:: void glm_mat2_swap_col(mat2 mat, int col1, int col2)
  98. swap two matrix columns
  99. Parameters:
  100. | *[in, out]* **mat** matrix
  101. | *[in]* **col1** col1
  102. | *[in]* **col2** col2
  103. .. c:function:: void glm_mat2_swap_row(mat2 mat, int row1, int row2)
  104. swap two matrix rows
  105. Parameters:
  106. | *[in, out]* **mat** matrix
  107. | *[in]* **row1** row1
  108. | *[in]* **row2** row2
  109. .. c:function:: float glm_mat2_rmc(vec2 r, mat2 m, vec2 c)
  110. | **rmc** stands for **Row** * **Matrix** * **Column**
  111. | helper for R (row vector) * M (matrix) * C (column vector)
  112. | the result is scalar because R * M = Matrix1x2 (row vector),
  113. | then Matrix1x2 * Vec2 (column vector) = Matrix1x1 (Scalar)
  114. Parameters:
  115. | *[in]* **r** row vector or matrix1x2
  116. | *[in]* **m** matrix2x2
  117. | *[in]* **c** column vector or matrix2x1
  118. Returns:
  119. scalar value e.g. Matrix1x1