add new matrix mat3x4

Initial function being

glm_mat3x4_make

Signed-off-by: Vincent Davis Jr <vince@underview.tech>
This commit is contained in:
Vincent Davis Jr
2023-07-16 12:36:15 -04:00
parent 8966f296ac
commit e09cf11f1c
24 changed files with 316 additions and 0 deletions

View File

@@ -269,6 +269,19 @@ test_assert_mat3x2_eq_zero(mat3x2 m3x2) {
TEST_SUCCESS
}
test_status_t
test_assert_mat3x4_eq_zero(mat3x4 m3x4) {
int i, j;
for (i = 0; i < 3; i++) {
for (j = 0; j < 4; j++) {
ASSERT(test_eq(m3x4[i][j], 0.0f))
}
}
TEST_SUCCESS
}
test_status_t
test_assert_mat4_eq_identity(mat4 m4) {
int i, j;

View File

@@ -77,6 +77,9 @@ test_assert_mat3_eq_zero(mat3 m3);
test_status_t
test_assert_mat3x2_eq_zero(mat3x2 m3x2);
test_status_t
test_assert_mat3x4_eq_zero(mat3x4 m3x4);
test_status_t
test_assert_vec3_eq(vec3 v1, vec3 v2);

59
test/src/test_mat3x4.h Normal file
View File

@@ -0,0 +1,59 @@
/*
* 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_MAT3X4_ONCE
#define CGLM_TEST_MAT3X4_ONCE
TEST_IMPL(MACRO_GLM_MAT3X4_ZERO_INIT) {
mat3x4 mat3x4_zero = GLM_MAT3X4_ZERO_INIT;
test_assert_mat3x4_eq_zero(mat3x4_zero);
TEST_SUCCESS
}
TEST_IMPL(MACRO_GLM_MAT3X4_ZERO) {
mat3x4 mat3x4_zero = GLM_MAT3X4_ZERO;
test_assert_mat3x4_eq_zero(mat3x4_zero);
TEST_SUCCESS
}
#endif /* CGLM_TEST_MAT3X4_ONCE */
TEST_IMPL(GLM_PREFIX, mat3x4_make) {
float src[36] = {
0.5f, 1.7f, 10.3f, 4.2f, 8.9f, 1.1f, 2.3f, 4.2f, 66.5f, 23.7f, 6.6f, 8.9f,
2.3f, 4.2f, 66.5f, 23.7f, 6.6f, 8.9f, 0.5f, 1.7f, 10.3f, 4.2f, 8.9f, 1.1f,
5.3f, 4.8f, 96.3f, 13.7f, 4.7f, 5.5f, 2.3f, 4.2f, 66.5f, 23.7f, 6.6f, 8.9f
};
mat3x4 dest[3];
float *srcp = src;
unsigned int i, j, k;
for (i = 0, j = 0, k = 0; i < sizeof(src) / sizeof(float); i+=12,j++) {
GLM(mat3x4_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]));
ASSERT(test_eq(src[i+8], dest[j][k+2][0]));
ASSERT(test_eq(src[i+9], dest[j][k+2][1]));
ASSERT(test_eq(src[i+10], dest[j][k+2][2]));
ASSERT(test_eq(src[i+11], dest[j][k+2][3]));
}
TEST_SUCCESS
}

View File

@@ -57,6 +57,18 @@ TEST_IMPL(mat3x2s_zero) {
TEST_SUCCESS
}
TEST_IMPL(mat3x4s_zero_init) {
mat3x4s mat3x4_zero = GLMS_MAT3X4_ZERO_INIT;
test_assert_mat3x4_eq_zero(mat3x4_zero.raw);
TEST_SUCCESS
}
TEST_IMPL(mat3x4s_zero) {
mat3x4s mat3x4_zero = GLMS_MAT3X4_ZERO;
test_assert_mat3x4_eq_zero(mat3x4_zero.raw);
TEST_SUCCESS
}
TEST_IMPL(mat4s_identity_init) {
mat4s mat4_identity = GLMS_MAT4_IDENTITY_INIT;
mat4 mat4_identity_a = GLM_MAT4_IDENTITY_INIT;

View File

@@ -23,6 +23,7 @@
#include "test_mat2x4.h"
#include "test_mat3.h"
#include "test_mat3x2.h"
#include "test_mat3x4.h"
#include "test_mat4.h"
#include "test_quat.h"
#include "test_project.h"
@@ -57,6 +58,7 @@
#include "test_mat2x4.h"
#include "test_mat3.h"
#include "test_mat3x2.h"
#include "test_mat3x4.h"
#include "test_mat4.h"
#include "test_quat.h"
#include "test_project.h"