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

@@ -8,6 +8,7 @@
#include "test_common.h"
#define A_MATRIX2x2 {{1,2},{5,6}}
#define MAT2_ARRAY {1, 5, 2, 7}
#ifndef CGLM_TEST_MAT2_ONCE
#define CGLM_TEST_MAT2_ONCE
@@ -283,4 +284,19 @@ TEST_IMPL(GLM_PREFIX, mat2_rmc) {
TEST_SUCCESS
}
TEST_IMPL(GLM_PREFIX, mat2_make) {
mat2 dest;
unsigned int i, j;
float src[4] = MAT2_ARRAY;
GLM(mat2_make)(src, dest);
for (i = 0, j = 0; i < sizeof(src) / sizeof(float); i+=2, j++) {
ASSERT(test_eq(dest[j][0], src[i]))
ASSERT(test_eq(dest[j][1], src[i+1]))
}
TEST_SUCCESS
}
#undef A_MATRIX2x2