mat2: add new function glm_mat2_make

Function takes in a 4 element float array
and converts it into a mat2 matrix.

Signed-off-by: Vincent Davis Jr <vince@underview.tech>
This commit is contained in:
Vincent Davis Jr
2023-05-14 20:08:51 -05:00
parent 9772948831
commit e6681e78c8
7 changed files with 70 additions and 0 deletions

View File

@@ -73,6 +73,10 @@ CGLM_EXPORT
float
glmc_mat2_rmc(vec2 r, mat2 m, vec2 c);
CGLM_EXPORT
void
glmc_mat2_make(float * __restrict src, mat2 dest);
#ifdef __cplusplus
}
#endif

View File

@@ -28,6 +28,7 @@
CGLM_INLINE void glm_mat2_swap_col(mat2 mat, int col1, int col2)
CGLM_INLINE void glm_mat2_swap_row(mat2 mat, int row1, int row2)
CGLM_INLINE float glm_mat2_rmc(vec2 r, mat2 m, vec2 c)
CGLM_INLINE void glm_mat2_make(float * restrict src, mat2 dest)
*/
#ifndef cglm_mat2_h
@@ -345,4 +346,19 @@ glm_mat2_rmc(vec2 r, mat2 m, vec2 c) {
return glm_vec2_dot(r, tmp);
}
/*!
* @brief Create mat2 matrix from pointer
*
* @param[in] src pointer to an array of floats
* @param[out] dest matrix
*/
CGLM_INLINE
void
glm_mat2_make(float * __restrict src, mat2 dest) {
dest[0][0] = src[0];
dest[0][1] = src[1];
dest[1][0] = src[2];
dest[1][1] = src[3];
}
#endif /* cglm_mat2_h */

View File

@@ -258,4 +258,17 @@ glms_mat2_(rmc)(vec2s r, mat2s m, vec2s c) {
return glm_mat2_rmc(r.raw, m.raw, c.raw);
}
/*!
* @brief Create mat2 matrix from pointer
*
* @param[in] src pointer to an array of floats
* @param[out] dest matrix
*/
CGLM_INLINE
mat2s
glms_mat2_(make)(float * __restrict src, mat2s dest) {
glm_mat2_make(src, dest.raw);
return dest;
}
#endif /* cglms_mat2_h */