mat3: add new function glm_mat3_make

Function takes in a 9 element float array
and converts it into a mat3 matrix.

Signed-off-by: Vincent Davis Jr <vince@underview.tech>
This commit is contained in:
Vincent Davis Jr
2023-05-14 20:56:25 -05:00
parent 9772948831
commit 0566a040c0
7 changed files with 79 additions and 0 deletions

View File

@@ -80,6 +80,10 @@ CGLM_EXPORT
float
glmc_mat3_rmc(vec3 r, mat3 m, vec3 c);
CGLM_EXPORT
void
glmc_mat3_make(float * __restrict src, mat3 dest);
#ifdef __cplusplus
}
#endif

View File

@@ -30,6 +30,7 @@
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);
CGLM_INLINE void glm_mat3_make(float * restrict src, mat3 dest);
*/
#ifndef cglm_mat3_h
@@ -427,4 +428,26 @@ glm_mat3_rmc(vec3 r, mat3 m, vec3 c) {
return glm_vec3_dot(r, tmp);
}
/*!
* @brief Create mat3 matrix from pointer
*
* @param[in] src pointer to an array of floats
* @param[out] dest matrix
*/
CGLM_INLINE
void
glm_mat3_make(float * __restrict src, mat3 dest) {
dest[0][0] = src[0];
dest[0][1] = src[1];
dest[0][2] = src[2];
dest[1][0] = src[3];
dest[1][1] = src[4];
dest[1][2] = src[5];
dest[2][0] = src[6];
dest[2][1] = src[7];
dest[2][2] = src[8];
}
#endif /* cglm_mat3_h */

View File

@@ -285,4 +285,17 @@ glms_mat3_(rmc)(vec3s r, mat3s m, vec3s c) {
return glm_mat3_rmc(r.raw, m.raw, c.raw);
}
/*!
* @brief Create mat3 matrix from pointer
*
* @param[in] src pointer to an array of floats
* @param[out] dest matrix
*/
CGLM_INLINE
mat3s
glms_mat3_(make)(float * __restrict src, mat3s dest) {
glm_mat3_make(src, dest.raw);
return dest;
}
#endif /* cglms_mat3s_h */