add new matrix mat3x2

Initial function being

glm_mat3x2_make

Signed-off-by: Vincent Davis Jr <vince@underview.tech>
This commit is contained in:
Vincent Davis Jr
2023-07-15 18:48:50 -04:00
parent f817c4cbb0
commit 4e44e74d48
24 changed files with 302 additions and 0 deletions

View File

@@ -256,6 +256,19 @@ test_assert_mat3_eq_zero(mat3 m3) {
TEST_SUCCESS
}
test_status_t
test_assert_mat3x2_eq_zero(mat3x2 m3x2) {
int i, j;
for (i = 0; i < 3; i++) {
for (j = 0; j < 2; j++) {
ASSERT(test_eq(m3x2[i][j], 0.0f))
}
}
TEST_SUCCESS
}
test_status_t
test_assert_mat4_eq_identity(mat4 m4) {
int i, j;

View File

@@ -74,6 +74,9 @@ test_assert_mat3_eq_identity(mat3 m3);
test_status_t
test_assert_mat3_eq_zero(mat3 m3);
test_status_t
test_assert_mat3x2_eq_zero(mat3x2 m3x2);
test_status_t
test_assert_vec3_eq(vec3 v1, vec3 v2);

53
test/src/test_mat3x2.h Normal file
View File

@@ -0,0 +1,53 @@
/*
* 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_MAT3X2_ONCE
#define CGLM_TEST_MAT3X2_ONCE
TEST_IMPL(MACRO_GLM_MAT3X2_ZERO_INIT) {
mat3x2 mat3x2_zero = GLM_MAT3X2_ZERO_INIT;
test_assert_mat3x2_eq_zero(mat3x2_zero);
TEST_SUCCESS
}
TEST_IMPL(MACRO_GLM_MAT3X2_ZERO) {
mat3x2 mat3x2_zero = GLM_MAT3X2_ZERO;
test_assert_mat3x2_eq_zero(mat3x2_zero);
TEST_SUCCESS
}
#endif /* CGLM_TEST_MAT3X2_ONCE */
TEST_IMPL(GLM_PREFIX, mat3x2_make) {
float src[18] = {
0.5f, 1.7f, 10.3f, 4.2f, 8.9f, 1.1f,
2.3f, 4.2f, 66.5f, 23.7f, 6.6f, 8.9f,
5.3f, 4.8f, 96.3f, 13.7f, 4.7f, 5.5f
};
mat3x2 dest[3];
float *srcp = src;
unsigned int i, j, k;
for (i = 0, j = 0, k = 0; i < sizeof(src) / sizeof(float); i+=6,j++) {
GLM(mat3x2_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]));
}
TEST_SUCCESS
}

View File

@@ -45,6 +45,18 @@ TEST_IMPL(mat3s_zero_init) {
TEST_SUCCESS
}
TEST_IMPL(mat3x2s_zero_init) {
mat3x2s mat3x2_zero = GLMS_MAT3X2_ZERO_INIT;
test_assert_mat3x2_eq_zero(mat3x2_zero.raw);
TEST_SUCCESS
}
TEST_IMPL(mat3x2s_zero) {
mat3x2s mat3x2_zero = GLMS_MAT3X2_ZERO;
test_assert_mat3x2_eq_zero(mat3x2_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

@@ -22,6 +22,7 @@
#include "test_mat2x3.h"
#include "test_mat2x4.h"
#include "test_mat3.h"
#include "test_mat3x2.h"
#include "test_mat4.h"
#include "test_quat.h"
#include "test_project.h"
@@ -55,6 +56,7 @@
#include "test_mat2x3.h"
#include "test_mat2x4.h"
#include "test_mat3.h"
#include "test_mat3x2.h"
#include "test_mat4.h"
#include "test_quat.h"
#include "test_project.h"