add new matrix mat2x4

Initial function being

glm_mat2x4_make

Signed-off-by: Vincent Davis Jr <vince@underview.tech>
This commit is contained in:
Vincent Davis Jr
2023-07-15 13:51:19 -04:00
parent 1ca261b118
commit fe7471e8f8
24 changed files with 295 additions and 0 deletions

View File

@@ -187,6 +187,19 @@ test_assert_mat2x3_eq_zero(mat2x3 m2x3) {
TEST_SUCCESS
}
test_status_t
test_assert_mat2x4_eq_zero(mat2x4 m2x4) {
int i, j;
for (i = 0; i < 2; i++) {
for (j = 0; j < 4; j++) {
ASSERT(test_eq(m2x4[i][j], 0.0f))
}
}
TEST_SUCCESS
}
test_status_t
test_assert_mat3_eq(mat3 m1, mat3 m2) {
int i, j;

View File

@@ -56,6 +56,9 @@ test_assert_mat2_eq_zero(mat2 m2);
test_status_t
test_assert_mat2x3_eq_zero(mat2x3 m2x3);
test_status_t
test_assert_mat2x4_eq_zero(mat2x4 m2x4);
test_status_t
test_assert_mat3_eq(mat3 m1, mat3 m2);

55
test/src/test_mat2x4.h Normal file
View File

@@ -0,0 +1,55 @@
/*
* Copyright (c), Recep Aslantas.
*
* MIT License (MIT), http://opensource.org/licenses/MIT
* Full license can be found in the LICENSE file
*/
#include "test_common.h"
#ifndef CGLM_TEST_MAT2X4_ONCE
#define CGLM_TEST_MAT2X4_ONCE
TEST_IMPL(MACRO_GLM_MAT2X4_ZERO_INIT) {
mat2x4 mat2x4_zero = GLM_MAT2X4_ZERO_INIT;
test_assert_mat2x4_eq_zero(mat2x4_zero);
TEST_SUCCESS
}
TEST_IMPL(MACRO_GLM_MAT2X4_ZERO) {
mat2x4 mat2x4_zero = GLM_MAT2X4_ZERO;
test_assert_mat2x4_eq_zero(mat2x4_zero);
TEST_SUCCESS
}
#endif /* CGLM_TEST_MAT2X4_ONCE */
TEST_IMPL(GLM_PREFIX, mat2x4_make) {
float src[24] = {
0.5f, 1.7f, 10.3f, 4.2f, 8.9f, 1.1f, 77.3f, 88.4f,
2.3f, 4.2f, 66.5f, 23.7f, 6.6f, 8.9f, 90.3f, 34.2f,
5.3f, 4.8f, 96.3f, 13.7f, 4.7f, 5.5f, 22.9f, 5.5f
};
mat2x4 dest[3];
float *srcp = src;
unsigned int i, j, k;
for (i = 0, j = 0, k = 0; i < sizeof(src) / sizeof(float); i+=8,j++) {
GLM(mat2x4_make)(srcp + i, dest[j]);
ASSERT(test_eq(src[ i ], dest[j][k][0]));
ASSERT(test_eq(src[i+1], dest[j][k][1]));
ASSERT(test_eq(src[i+2], dest[j][k][2]));
ASSERT(test_eq(src[i+3], dest[j][k][3]));
ASSERT(test_eq(src[i+4], dest[j][k+1][0]));
ASSERT(test_eq(src[i+5], dest[j][k+1][1]));
ASSERT(test_eq(src[i+6], dest[j][k+1][2]));
ASSERT(test_eq(src[i+7], dest[j][k+1][3]));
}
TEST_SUCCESS
}

View File

@@ -15,6 +15,12 @@ TEST_IMPL(mat2x3s_zero_init) {
TEST_SUCCESS
}
TEST_IMPL(mat2x4s_zero_init) {
mat2x4s mat2x4_zero = GLMS_MAT2X4_ZERO_INIT;
test_assert_mat2x4_eq_zero(mat2x4_zero.raw);
TEST_SUCCESS
}
TEST_IMPL(mat3s_identity_init) {
mat3s mat3_identity = GLMS_MAT3_IDENTITY_INIT;
mat3 mat3_identity_a = GLM_MAT3_IDENTITY_INIT;

View File

@@ -20,6 +20,7 @@
#include "test_ivec4.h"
#include "test_mat2.h"
#include "test_mat2x3.h"
#include "test_mat2x4.h"
#include "test_mat3.h"
#include "test_mat4.h"
#include "test_quat.h"
@@ -52,6 +53,7 @@
#include "test_ivec4.h"
#include "test_mat2.h"
#include "test_mat2x3.h"
#include "test_mat2x4.h"
#include "test_mat3.h"
#include "test_mat4.h"
#include "test_quat.h"

View File

@@ -232,6 +232,12 @@ TEST_DECLARE(glm_mat2x3_make)
TEST_DECLARE(glmc_mat2x3_make)
TEST_DECLARE(MACRO_GLM_MAT2X4_ZERO_INIT)
TEST_DECLARE(MACRO_GLM_MAT2X4_ZERO)
TEST_DECLARE(glm_mat2x4_make)
TEST_DECLARE(glmc_mat2x4_make)
/* camera (incl [LR]H cross [NZ]O) */
TEST_DECLARE(glm_perspective_lh_zo)
TEST_DECLARE(glm_perspective_rh_zo)
@@ -1091,6 +1097,12 @@ TEST_LIST {
TEST_ENTRY(glmc_mat2x3_make)
TEST_ENTRY(MACRO_GLM_MAT2X4_ZERO_INIT)
TEST_ENTRY(MACRO_GLM_MAT2X4_ZERO)
TEST_ENTRY(glm_mat2x4_make)
TEST_ENTRY(glmc_mat2x4_make)
/* camera (incl [LR]H cross [NZ]O) */
TEST_ENTRY(glm_perspective_lh_zo)
TEST_ENTRY(glm_perspective_rh_zo)