mat4: helper for row * matrix * column

This commit is contained in:
Recep Aslantas
2019-01-26 18:05:05 +03:00
parent 807d5589b4
commit 32ddf49756
5 changed files with 59 additions and 5 deletions

View File

@@ -45,6 +45,7 @@ Functions:
#. :c:func:`glm_mat4_inv_fast`
#. :c:func:`glm_mat4_swap_col`
#. :c:func:`glm_mat4_swap_row`
#. :c:func:`glm_mat4_rmc`
Functions documentation
~~~~~~~~~~~~~~~~~~~~~~~
@@ -270,3 +271,20 @@ Functions documentation
| *[in, out]* **mat** matrix
| *[in]* **row1** row1
| *[in]* **row2** row2
.. c:function:: float glm_mat4_rmc(vec4 r, mat4 m, vec4 c)
| **rmc** stands for **Row** * **Matrix** * **Column**
| helper for R (row vector) * M (matrix) * C (column vector)
| the result is scalar because S * M = Matrix1x4 (row vector),
| then Matrix1x4 * Vec4 (column vector) = Matrix1x1 (Scalar)
Parameters:
| *[in]* **r** row vector or matrix1x4
| *[in]* **m** matrix4x4
| *[in]* **c** column vector or matrix4x1
Returns:
scalar value e.g. Matrix1x1

View File

@@ -58,11 +58,7 @@ Functions:
#. :c:func:`glm_vec4_minv`
#. :c:func:`glm_vec4_clamp`
#. :c:func:`glm_vec4_lerp`
#. :c:func:`glm_vec4_isnan`
#. :c:func:`glm_vec4_isinf`
#. :c:func:`glm_vec4_isvalid`
#. :c:func:`glm_vec4_sign`
#. :c:func:`glm_vec4_sqrt`
#. :c:func:`glm_vec4_cubic`
Functions documentation
~~~~~~~~~~~~~~~~~~~~~~~
@@ -401,3 +397,11 @@ Functions documentation
| *[in]* **to** to value
| *[in]* **t** interpolant (amount) clamped between 0 and 1
| *[out]* **dest** destination
.. c:function:: void glm_vec4_cubic(float s, vec4 dest)
helper to fill vec4 as [S^3, S^2, S, 1]
Parameters:
| *[in]* **s** parameter
| *[out]* **dest** destination

View File

@@ -113,6 +113,10 @@ CGLM_EXPORT
void
glmc_mat4_swap_row(mat4 mat, int row1, int row2);
CGLM_EXPORT
float
glmc_mat4_rmc(vec4 r, mat4 m, vec4 c);
#ifdef __cplusplus
}
#endif

View File

@@ -677,4 +677,26 @@ glm_mat4_swap_row(mat4 mat, int row1, int row2) {
mat[3][row2] = tmp[3];
}
/*!
* @brief helper for R (row vector) * M (matrix) * C (column vector)
*
* rmc stands for Row * Matrix * Column
*
* the result is scalar because S * M = Matrix1x4 (row vector),
* then Matrix1x4 * Vec4 (column vector) = Matrix1x1 (Scalar)
*
* @param[in] r row vector or matrix1x4
* @param[in] m matrix4x4
* @param[in] c column vector or matrix4x1
*
* @return scalar value e.g. B(s)
*/
CGLM_INLINE
float
glm_mat4_rmc(vec4 r, mat4 m, vec4 c) {
vec4 tmp;
glm_mat4_mulv(m, r, tmp);
return glm_vec4_dot(c, tmp);
}
#endif /* cglm_mat_h */

View File

@@ -151,3 +151,9 @@ void
glmc_mat4_swap_row(mat4 mat, int row1, int row2) {
glm_mat4_swap_row(mat, row1, row2);
}
CGLM_EXPORT
float
glmc_mat4_rmc(vec4 r, mat4 m, vec4 c) {
return glm_mat4_rmc(r, m, c);
}