add new matrix mat4x2

Initial function being

glm_mat4x2_make

Signed-off-by: Vincent Davis Jr <vince@underview.tech>
This commit is contained in:
Vincent Davis Jr
2023-07-16 20:19:25 -04:00
parent 5193b50133
commit 2df26c0ecf
24 changed files with 310 additions and 1 deletions

View File

@@ -312,6 +312,19 @@ test_assert_mat4_eq_zero(mat4 m4) {
TEST_SUCCESS
}
test_status_t
test_assert_mat4x2_eq_zero(mat4x2 m4x2) {
int i, j;
for (i = 0; i < 4; i++) {
for (j = 0; j < 2; j++) {
ASSERT(test_eq(m4x2[i][j], 0.0f))
}
}
TEST_SUCCESS
}
test_status_t
test_assert_eqf(float a, float b) {
ASSERT(fabsf(a - b) <= 0.000009); /* rounding errors */

View File

@@ -41,6 +41,9 @@ test_assert_mat4_eq_identity(mat4 m4);
test_status_t
test_assert_mat4_eq_zero(mat4 m4);
test_status_t
test_assert_mat4x2_eq_zero(mat4x2 m4x2);
test_status_t
test_assert_mat2_eqt(mat2 m1, mat2 m2);

56
test/src/test_mat4x2.h Normal file
View File

@@ -0,0 +1,56 @@
/*
* 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_MAT4X2_ONCE
#define CGLM_TEST_MAT4X2_ONCE
TEST_IMPL(MACRO_GLM_MAT4X2_ZERO_INIT) {
mat4x2 mat4x2_zero = GLM_MAT4X2_ZERO_INIT;
test_assert_mat4x2_eq_zero(mat4x2_zero);
TEST_SUCCESS
}
TEST_IMPL(MACRO_GLM_MAT4X2_ZERO) {
mat4x2 mat4x2_zero = GLM_MAT4X2_ZERO;
test_assert_mat4x2_eq_zero(mat4x2_zero);
TEST_SUCCESS
}
#endif /* CGLM_TEST_MAT4X2_ONCE */
TEST_IMPL(GLM_PREFIX, mat4x2_make) {
float src[24] = {
0.5f, 1.7f, 10.3f, 4.2f, 8.9f, 1.1f, 2.3f, 4.2f,
2.3f, 4.2f, 66.5f, 23.7f, 6.6f, 8.9f, 0.5f, 1.7f,
5.3f, 4.8f, 96.3f, 13.7f, 4.7f, 5.5f, 2.3f, 4.2f
};
mat4x2 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(mat4x2_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+1][0]));
ASSERT(test_eq(src[i+3], dest[j][k+1][1]));
ASSERT(test_eq(src[i+4], dest[j][k+2][0]));
ASSERT(test_eq(src[i+5], dest[j][k+2][1]));
ASSERT(test_eq(src[i+6], dest[j][k+3][0]));
ASSERT(test_eq(src[i+7], dest[j][k+3][1]));
}
TEST_SUCCESS
}

View File

@@ -83,6 +83,18 @@ TEST_IMPL(mat4s_zero_init) {
TEST_SUCCESS
}
TEST_IMPL(mat4x2s_zero_init) {
mat4x2s mat4x2_zero = GLMS_MAT4X2_ZERO_INIT;
test_assert_mat4x2_eq_zero(mat4x2_zero.raw);
TEST_SUCCESS
}
TEST_IMPL(mat4x2s_zero) {
mat4x2s mat4x2_zero = GLMS_MAT4X2_ZERO;
test_assert_mat4x2_eq_zero(mat4x2_zero.raw);
TEST_SUCCESS
}
TEST_IMPL(quats_zero_init) {
versors quat_zero = GLMS_QUAT_IDENTITY_INIT;
versor quat_zero_a = GLM_QUAT_IDENTITY_INIT;

View File

@@ -25,6 +25,7 @@
#include "test_mat3x2.h"
#include "test_mat3x4.h"
#include "test_mat4.h"
#include "test_mat4x2.h"
#include "test_quat.h"
#include "test_project.h"
#include "test_plane.h"
@@ -60,6 +61,7 @@
#include "test_mat3x2.h"
#include "test_mat3x4.h"
#include "test_mat4.h"
#include "test_mat4x2.h"
#include "test_quat.h"
#include "test_project.h"
#include "test_plane.h"