mirror of
https://github.com/recp/cglm.git
synced 2025-10-04 01:00:46 +00:00
add new matrix mat4x3
Initial function being glm_mat4x3_make Signed-off-by: Vincent Davis Jr <vince@underview.tech>
This commit is contained in:
@@ -325,6 +325,19 @@ test_assert_mat4x2_eq_zero(mat4x2 m4x2) {
|
||||
TEST_SUCCESS
|
||||
}
|
||||
|
||||
test_status_t
|
||||
test_assert_mat4x3_eq_zero(mat4x3 m4x3) {
|
||||
int i, j;
|
||||
|
||||
for (i = 0; i < 4; i++) {
|
||||
for (j = 0; j < 3; j++) {
|
||||
ASSERT(test_eq(m4x3[i][j], 0.0f))
|
||||
}
|
||||
}
|
||||
|
||||
TEST_SUCCESS
|
||||
}
|
||||
|
||||
test_status_t
|
||||
test_assert_eqf(float a, float b) {
|
||||
ASSERT(fabsf(a - b) <= 0.000009); /* rounding errors */
|
||||
|
@@ -44,6 +44,9 @@ test_assert_mat4_eq_zero(mat4 m4);
|
||||
test_status_t
|
||||
test_assert_mat4x2_eq_zero(mat4x2 m4x2);
|
||||
|
||||
test_status_t
|
||||
test_assert_mat4x3_eq_zero(mat4x3 m4x3);
|
||||
|
||||
test_status_t
|
||||
test_assert_mat2_eqt(mat2 m1, mat2 m2);
|
||||
|
||||
|
60
test/src/test_mat4x3.h
Normal file
60
test/src/test_mat4x3.h
Normal file
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* 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_MAT4X3_ONCE
|
||||
#define CGLM_TEST_MAT4X3_ONCE
|
||||
|
||||
TEST_IMPL(MACRO_GLM_MAT4X3_ZERO_INIT) {
|
||||
mat4x3 mat4x3_zero = GLM_MAT4X3_ZERO_INIT;
|
||||
test_assert_mat4x3_eq_zero(mat4x3_zero);
|
||||
TEST_SUCCESS
|
||||
}
|
||||
|
||||
TEST_IMPL(MACRO_GLM_MAT4X3_ZERO) {
|
||||
mat4x3 mat4x3_zero = GLM_MAT4X3_ZERO;
|
||||
test_assert_mat4x3_eq_zero(mat4x3_zero);
|
||||
TEST_SUCCESS
|
||||
}
|
||||
|
||||
#endif /* CGLM_TEST_MAT4X3_ONCE */
|
||||
|
||||
TEST_IMPL(GLM_PREFIX, mat4x3_make) {
|
||||
float src[36] = {
|
||||
0.5f, 1.7f, 10.3f, 4.2f, 8.9f, 1.1f, 2.3f, 4.2f, 5.3f, 4.8f, 96.3f, 13.7f,
|
||||
4.7f, 5.5f, 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, 0.5f, 1.7f, 10.3f, 4.2f
|
||||
};
|
||||
|
||||
mat4x3 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(mat4x3_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+1][0]));
|
||||
ASSERT(test_eq(src[i+4], dest[j][k+1][1]));
|
||||
ASSERT(test_eq(src[i+5], dest[j][k+1][2]));
|
||||
|
||||
ASSERT(test_eq(src[i+6], dest[j][k+2][0]));
|
||||
ASSERT(test_eq(src[i+7], dest[j][k+2][1]));
|
||||
ASSERT(test_eq(src[i+8], dest[j][k+2][2]));
|
||||
|
||||
ASSERT(test_eq(src[i+9], dest[j][k+3][0]));
|
||||
ASSERT(test_eq(src[i+10], dest[j][k+3][1]));
|
||||
ASSERT(test_eq(src[i+11], dest[j][k+3][2]));
|
||||
}
|
||||
|
||||
TEST_SUCCESS
|
||||
}
|
@@ -95,6 +95,18 @@ TEST_IMPL(mat4x2s_zero) {
|
||||
TEST_SUCCESS
|
||||
}
|
||||
|
||||
TEST_IMPL(mat4x3s_zero_init) {
|
||||
mat4x3s mat4x3_zero = GLMS_MAT4X3_ZERO_INIT;
|
||||
test_assert_mat4x3_eq_zero(mat4x3_zero.raw);
|
||||
TEST_SUCCESS
|
||||
}
|
||||
|
||||
TEST_IMPL(mat4x3s_zero) {
|
||||
mat4x3s mat4x3_zero = GLMS_MAT4X3_ZERO;
|
||||
test_assert_mat4x3_eq_zero(mat4x3_zero.raw);
|
||||
TEST_SUCCESS
|
||||
}
|
||||
|
||||
TEST_IMPL(quats_zero_init) {
|
||||
versors quat_zero = GLMS_QUAT_IDENTITY_INIT;
|
||||
versor quat_zero_a = GLM_QUAT_IDENTITY_INIT;
|
||||
|
@@ -26,6 +26,7 @@
|
||||
#include "test_mat3x4.h"
|
||||
#include "test_mat4.h"
|
||||
#include "test_mat4x2.h"
|
||||
#include "test_mat4x3.h"
|
||||
#include "test_quat.h"
|
||||
#include "test_project.h"
|
||||
#include "test_plane.h"
|
||||
@@ -62,6 +63,7 @@
|
||||
#include "test_mat3x4.h"
|
||||
#include "test_mat4.h"
|
||||
#include "test_mat4x2.h"
|
||||
#include "test_mat4x3.h"
|
||||
#include "test_quat.h"
|
||||
#include "test_project.h"
|
||||
#include "test_plane.h"
|
||||
|
16
test/tests.h
16
test/tests.h
@@ -159,6 +159,12 @@ TEST_DECLARE(glm_mat4x2_make)
|
||||
|
||||
TEST_DECLARE(glmc_mat4x2_make)
|
||||
|
||||
TEST_DECLARE(MACRO_GLM_MAT4X3_ZERO_INIT)
|
||||
TEST_DECLARE(MACRO_GLM_MAT4X3_ZERO)
|
||||
TEST_DECLARE(glm_mat4x3_make)
|
||||
|
||||
TEST_DECLARE(glmc_mat4x3_make)
|
||||
|
||||
/* mat3 */
|
||||
TEST_DECLARE(glm_mat3_copy)
|
||||
TEST_DECLARE(glm_mat3_identity)
|
||||
@@ -901,6 +907,8 @@ TEST_DECLARE(mat4s_identity_init)
|
||||
TEST_DECLARE(mat4s_zero_init)
|
||||
TEST_DECLARE(mat4x2s_zero_init)
|
||||
TEST_DECLARE(mat4x2s_zero)
|
||||
TEST_DECLARE(mat4x3s_zero_init)
|
||||
TEST_DECLARE(mat4x3s_zero)
|
||||
TEST_DECLARE(quats_zero_init)
|
||||
TEST_DECLARE(vec3s_one_init)
|
||||
TEST_DECLARE(vec3s_zero_init)
|
||||
@@ -1054,6 +1062,12 @@ TEST_LIST {
|
||||
|
||||
TEST_ENTRY(glmc_mat4x2_make)
|
||||
|
||||
TEST_ENTRY(MACRO_GLM_MAT4X3_ZERO_INIT)
|
||||
TEST_ENTRY(MACRO_GLM_MAT4X3_ZERO)
|
||||
TEST_ENTRY(glm_mat4x3_make)
|
||||
|
||||
TEST_ENTRY(glmc_mat4x3_make)
|
||||
|
||||
/* mat3 */
|
||||
TEST_ENTRY(glm_mat3_copy)
|
||||
TEST_ENTRY(glm_mat3_identity)
|
||||
@@ -1793,6 +1807,8 @@ TEST_LIST {
|
||||
TEST_ENTRY(mat4s_zero_init)
|
||||
TEST_ENTRY(mat4x2s_zero_init)
|
||||
TEST_ENTRY(mat4x2s_zero)
|
||||
TEST_ENTRY(mat4x3s_zero_init)
|
||||
TEST_ENTRY(mat4x3s_zero)
|
||||
TEST_ENTRY(quats_zero_init)
|
||||
TEST_ENTRY(vec3s_one_init)
|
||||
TEST_ENTRY(vec3s_zero_init)
|
||||
|
Reference in New Issue
Block a user