mat3: add rmc for mat3

This commit is contained in:
Recep Aslantas
2019-02-13 10:12:49 +03:00
parent c8b8f4f6f0
commit 2b1eece9ac
5 changed files with 53 additions and 1 deletions

View File

@@ -32,6 +32,7 @@ Functions:
#. :c:func:`glm_mat3_trace`
#. :c:func:`glm_mat3_swap_col`
#. :c:func:`glm_mat3_swap_row`
#. :c:func:`glm_mat3_rmc`
Functions documentation
~~~~~~~~~~~~~~~~~~~~~~~
@@ -161,3 +162,20 @@ Functions documentation
| *[in, out]* **mat** matrix
| *[in]* **row1** row1
| *[in]* **row2** row2
.. c:function:: float glm_mat3_rmc(vec3 r, mat3 m, vec3 c)
| **rmc** stands for **Row** * **Matrix** * **Column**
| helper for R (row vector) * M (matrix) * C (column vector)
| the result is scalar because R * M = Matrix1x3 (row vector),
| then Matrix1x3 * Vec3 (column vector) = Matrix1x1 (Scalar)
Parameters:
| *[in]* **r** row vector or matrix1x3
| *[in]* **m** matrix3x3
| *[in]* **c** column vector or matrix3x1
Returns:
scalar value e.g. Matrix1x1

View File

@@ -278,7 +278,7 @@ Functions documentation
| helper for R (row vector) * M (matrix) * C (column vector)
| the result is scalar because S * M = Matrix1x4 (row vector),
| the result is scalar because R * M = Matrix1x4 (row vector),
| then Matrix1x4 * Vec4 (column vector) = Matrix1x1 (Scalar)
Parameters:

View File

@@ -72,6 +72,10 @@ CGLM_EXPORT
void
glmc_mat3_swap_row(mat3 mat, int row1, int row2);
CGLM_EXPORT
float
glmc_mat3_rmc(vec3 r, mat3 m, vec3 c);
#ifdef __cplusplus
}
#endif

View File

@@ -22,11 +22,13 @@
CGLM_INLINE void glm_mat3_transpose(mat3 m);
CGLM_INLINE void glm_mat3_mulv(mat3 m, vec3 v, vec3 dest);
CGLM_INLINE float glm_mat3_trace(mat3 m);
CGLM_INLINE void glm_mat3_quat(mat3 m, versor dest);
CGLM_INLINE void glm_mat3_scale(mat3 m, float s);
CGLM_INLINE float glm_mat3_det(mat3 mat);
CGLM_INLINE void glm_mat3_inv(mat3 mat, mat3 dest);
CGLM_INLINE void glm_mat3_swap_col(mat3 mat, int col1, int col2);
CGLM_INLINE void glm_mat3_swap_row(mat3 mat, int row1, int row2);
CGLM_INLINE float glm_mat3_rmc(vec3 r, mat3 m, vec3 c);
*/
#ifndef cglm_mat3_h
@@ -372,4 +374,26 @@ glm_mat3_swap_row(mat3 mat, int row1, int row2) {
mat[2][row2] = tmp[2];
}
/*!
* @brief helper for R (row vector) * M (matrix) * C (column vector)
*
* rmc stands for Row * Matrix * Column
*
* the result is scalar because R * M = Matrix1x3 (row vector),
* then Matrix1x3 * Vec3 (column vector) = Matrix1x1 (Scalar)
*
* @param[in] r row vector or matrix1x3
* @param[in] m matrix3x3
* @param[in] c column vector or matrix3x1
*
* @return scalar value e.g. Matrix1x1
*/
CGLM_INLINE
float
glm_mat3_rmc(vec3 r, mat3 m, vec3 c) {
vec3 tmp;
glm_mat3_mulv(m, c, tmp);
return glm_vec3_dot(r, tmp);
}
#endif /* cglm_mat3_h */

View File

@@ -91,3 +91,9 @@ void
glmc_mat3_swap_row(mat3 mat, int row1, int row2) {
glm_mat3_swap_row(mat, row1, row2);
}
CGLM_EXPORT
float
glmc_mat3_rmc(vec3 r, mat3 m, vec3 c) {
return glm_mat3_rmc(r, m, c);
}