diff --git a/docs/source/mat4.rst b/docs/source/mat4.rst index 30f48fe..294f8f4 100644 --- a/docs/source/mat4.rst +++ b/docs/source/mat4.rst @@ -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 diff --git a/docs/source/vec4.rst b/docs/source/vec4.rst index 5bb1ac7..f497868 100644 --- a/docs/source/vec4.rst +++ b/docs/source/vec4.rst @@ -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 diff --git a/include/cglm/call/mat4.h b/include/cglm/call/mat4.h index 7e76f73..54fbcbe 100644 --- a/include/cglm/call/mat4.h +++ b/include/cglm/call/mat4.h @@ -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 diff --git a/include/cglm/mat4.h b/include/cglm/mat4.h index 56c6de3..35d4117 100644 --- a/include/cglm/mat4.h +++ b/include/cglm/mat4.h @@ -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 */ diff --git a/src/mat4.c b/src/mat4.c index b62420e..c648a6e 100644 --- a/src/mat4.c +++ b/src/mat4.c @@ -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); +}