diff --git a/CMakeLists.txt b/CMakeLists.txt
index 3bafd43..8cdea53 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -82,6 +82,7 @@ add_library(${PROJECT_NAME}
src/mat2x3.c
src/mat2x4.c
src/mat3.c
+ src/mat3x2.c
src/mat4.c
src/plane.c
src/frustum.c
diff --git a/Makefile.am b/Makefile.am
index 461d4fc..a888f7a 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -43,6 +43,7 @@ cglm_HEADERS = include/cglm/version.h \
include/cglm/io.h \
include/cglm/mat4.h \
include/cglm/mat3.h \
+ include/cglm/mat3x2.h \
include/cglm/mat2.h \
include/cglm/mat2x3.h \
include/cglm/mat2x4.h \
@@ -97,6 +98,7 @@ cglm_clipspace_HEADERS = include/cglm/clipspace/persp.h \
cglm_calldir=$(includedir)/cglm/call
cglm_call_HEADERS = include/cglm/call/mat4.h \
include/cglm/call/mat3.h \
+ include/cglm/call/mat3x2.h \
include/cglm/call/mat2.h \
include/cglm/call/mat2x3.h \
include/cglm/call/mat2x4.h \
@@ -163,6 +165,7 @@ cglm_simd_neon_HEADERS = include/cglm/simd/neon/affine.h \
cglm_structdir=$(includedir)/cglm/struct
cglm_struct_HEADERS = include/cglm/struct/mat4.h \
include/cglm/struct/mat3.h \
+ include/cglm/struct/mat3x2.h \
include/cglm/struct/mat2.h \
include/cglm/struct/mat2x3.h \
include/cglm/struct/mat2x4.h \
@@ -221,6 +224,7 @@ libcglm_la_SOURCES=\
src/mat2x3.c \
src/mat2x4.c \
src/mat3.c \
+ src/mat3x2.c \
src/mat4.c \
src/plane.c \
src/frustum.c \
diff --git a/docs/source/api_inline_array.rst b/docs/source/api_inline_array.rst
index 3a92840..e24e774 100644
--- a/docs/source/api_inline_array.rst
+++ b/docs/source/api_inline_array.rst
@@ -49,6 +49,7 @@ Follow the :doc:`build` documentation for this
mat2x3
mat2x4
mat3
+ mat3x2
mat4
vec2
vec2-ext
diff --git a/docs/source/mat3x2.rst b/docs/source/mat3x2.rst
new file mode 100644
index 0000000..e86bfc0
--- /dev/null
+++ b/docs/source/mat3x2.rst
@@ -0,0 +1,30 @@
+.. default-domain:: C
+
+mat3x2
+======
+
+Header: cglm/mat3x2.h
+
+Table of contents (click to go):
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Macros:
+
+1. GLM_MAT3X2_ZERO_INIT
+#. GLM_MAT3x2_ZERO
+
+Functions:
+
+1. :c:func:`glm_mat3x2_make`
+
+Functions documentation
+~~~~~~~~~~~~~~~~~~~~~~~
+
+.. c:function:: void glm_mat3x2_make(float * __restrict src, mat3x2 dest)
+
+ Create mat3x2 matrix from pointer
+
+ | NOTE: **@src** must contain at least 6 elements.
+ Parameters:
+ | *[in]* **src** pointer to an array of floats
+ | *[out]* **dest** destination matrix3x2
diff --git a/include/cglm/call.h b/include/cglm/call.h
index 609de88..cfd79c1 100644
--- a/include/cglm/call.h
+++ b/include/cglm/call.h
@@ -22,6 +22,7 @@ extern "C" {
#include "call/mat2x3.h"
#include "call/mat2x4.h"
#include "call/mat3.h"
+#include "call/mat3x2.h"
#include "call/mat4.h"
#include "call/affine.h"
#include "call/cam.h"
diff --git a/include/cglm/call/mat3x2.h b/include/cglm/call/mat3x2.h
new file mode 100644
index 0000000..f2d0440
--- /dev/null
+++ b/include/cglm/call/mat3x2.h
@@ -0,0 +1,23 @@
+/*
+ * Copyright (c), Recep Aslantas.
+ *
+ * MIT License (MIT), http://opensource.org/licenses/MIT
+ * Full license can be found in the LICENSE file
+ */
+
+#ifndef cglmc_mat3x2_h
+#define cglmc_mat3x2_h
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include "../cglm.h"
+
+CGLM_EXPORT
+void
+glmc_mat3x2_make(float * __restrict src, mat3x2 dest);
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* cglmc_mat3x2_h */
diff --git a/include/cglm/cglm.h b/include/cglm/cglm.h
index 7b72af0..05566d5 100644
--- a/include/cglm/cglm.h
+++ b/include/cglm/cglm.h
@@ -17,6 +17,7 @@
#include "ivec4.h"
#include "mat4.h"
#include "mat3.h"
+#include "mat3x2.h"
#include "mat2.h"
#include "mat2x3.h"
#include "mat2x4.h"
diff --git a/include/cglm/mat3x2.h b/include/cglm/mat3x2.h
new file mode 100644
index 0000000..52f330c
--- /dev/null
+++ b/include/cglm/mat3x2.h
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c), Recep Aslantas.
+ *
+ * MIT License (MIT), http://opensource.org/licenses/MIT
+ * Full license can be found in the LICENSE file
+ */
+
+/*
+ Macros:
+ GLM_MAT3X2_ZERO_INIT
+ GLM_MAT3X2_ZERO
+
+ Functions:
+ CGLM_INLINE void glm_mat3x2_make(float * restrict src, mat3x2 dest)
+ */
+
+#ifndef cglm_mat3x2_h
+#define cglm_mat3x2_h
+
+#include "common.h"
+
+#define GLM_MAT3X2_ZERO_INIT {{0.0f, 0.0f}, {0.0f, 0.0f}, {0.0f, 0.0f}}
+
+/* for C only */
+#define GLM_MAT3X2_ZERO GLM_MAT3X2_ZERO_INIT
+
+/*!
+ * @brief Create mat3x2 matrix from pointer
+ *
+ * @param[in] src pointer to an array of floats
+ * @param[out] dest matrix
+ */
+CGLM_INLINE
+void
+glm_mat3x2_make(float * __restrict src, mat3x2 dest) {
+ dest[0][0] = src[0];
+ dest[0][1] = src[1];
+
+ dest[1][0] = src[2];
+ dest[1][1] = src[3];
+
+ dest[2][0] = src[4];
+ dest[2][1] = src[5];
+}
+
+#endif
diff --git a/include/cglm/struct.h b/include/cglm/struct.h
index 8c85005..ebb3010 100644
--- a/include/cglm/struct.h
+++ b/include/cglm/struct.h
@@ -20,6 +20,7 @@ extern "C" {
#include "struct/mat2x3.h"
#include "struct/mat2x4.h"
#include "struct/mat3.h"
+#include "struct/mat3x2.h"
#include "struct/mat4.h"
#include "struct/affine.h"
#include "struct/frustum.h"
diff --git a/include/cglm/struct/mat3x2.h b/include/cglm/struct/mat3x2.h
new file mode 100644
index 0000000..4c35291
--- /dev/null
+++ b/include/cglm/struct/mat3x2.h
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c), Recep Aslantas.
+ *
+ * MIT License (MIT), http://opensource.org/licenses/MIT
+ * Full license can be found in the LICENSE file
+ */
+
+/*
+ Macros:
+ GLMS_MAT3X2_ZERO_INIT
+ GLMS_MAT3X2_ZERO
+
+ Functions:
+ CGLM_INLINE mat3x2s glms_mat3x2_make(float * __restrict src);
+ */
+
+#ifndef cglms_mat3x2_h
+#define cglms_mat3x2_h
+
+#include "../common.h"
+#include "../types-struct.h"
+#include "../mat3x2.h"
+
+/* api definition */
+#define glms_mat3x2_(NAME) CGLM_STRUCTAPI(mat3x2, NAME)
+
+#define GLMS_MAT3X2_ZERO_INIT {GLM_MAT3X2_ZERO_INIT}
+
+/* for C only */
+#define GLMS_MAT3X2_ZERO ((mat3x2s)GLMS_MAT3X2_ZERO_INIT)
+
+/*!
+ * @brief Create mat3x2 matrix from pointer
+ *
+ * @param[in] src pointer to an array of floats
+ * @return constructed matrix from raw pointer
+ */
+CGLM_INLINE
+mat3x2s
+glms_mat3x2_(make)(float * __restrict src) {
+ mat3x2s r;
+ glm_mat3x2_make(src, r.raw);
+ return r;
+}
+
+#endif /* cglms_mat3x2_h */
diff --git a/include/cglm/types-struct.h b/include/cglm/types-struct.h
index 6a7f505..285ebac 100644
--- a/include/cglm/types-struct.h
+++ b/include/cglm/types-struct.h
@@ -231,6 +231,18 @@ typedef union mat3s {
#endif
} mat3s;
+typedef union mat3x2s {
+ mat3x2 raw;
+ vec2s col[3]; /* col -> row | [row (3), col (2)] */
+#if CGLM_USE_ANONYMOUS_STRUCT
+ struct {
+ float m00, m01;
+ float m10, m11;
+ float m20, m21;
+ };
+#endif
+} mat3x2s;
+
typedef union CGLM_ALIGN_MAT mat4s {
mat4 raw;
vec4s col[4];
diff --git a/include/cglm/types.h b/include/cglm/types.h
index 6cf3a1b..602b5a2 100644
--- a/include/cglm/types.h
+++ b/include/cglm/types.h
@@ -55,6 +55,7 @@ typedef float vec3[3];
typedef CGLM_ALIGN_IF(16) float vec4[4];
typedef vec4 versor; /* |x, y, z, w| -> w is the last */
typedef vec3 mat3[3];
+typedef vec2 mat3x2[3]; /* [row (3), col (2)] */
typedef CGLM_ALIGN_IF(16) vec2 mat2[2];
typedef vec3 mat2x3[2]; /* [row (2), col (3)] */
typedef vec4 mat2x4[2]; /* [row (2), col (4)] */
diff --git a/meson.build b/meson.build
index 3787046..78855fe 100644
--- a/meson.build
+++ b/meson.build
@@ -42,6 +42,7 @@ cglm_src = files(
'src/mat2x3.c',
'src/mat2x4.c',
'src/mat3.c',
+ 'src/mat3x2.c',
'src/mat4.c',
'src/plane.c',
'src/frustum.c',
diff --git a/src/mat3x2.c b/src/mat3x2.c
new file mode 100644
index 0000000..fd6546c
--- /dev/null
+++ b/src/mat3x2.c
@@ -0,0 +1,15 @@
+/*
+ * Copyright (c), Recep Aslantas.
+ *
+ * MIT License (MIT), http://opensource.org/licenses/MIT
+ * Full license can be found in the LICENSE file
+ */
+
+#include "../include/cglm/cglm.h"
+#include "../include/cglm/call.h"
+
+CGLM_EXPORT
+void
+glmc_mat3x2_make(float * __restrict src, mat3x2 dest) {
+ glm_mat3x2_make(src, dest);
+}
diff --git a/test/src/test_common.c b/test/src/test_common.c
index 81d2402..a78d4a6 100644
--- a/test/src/test_common.c
+++ b/test/src/test_common.c
@@ -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;
diff --git a/test/src/test_common.h b/test/src/test_common.h
index 1f332c3..6251cc5 100644
--- a/test/src/test_common.h
+++ b/test/src/test_common.h
@@ -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);
diff --git a/test/src/test_mat3x2.h b/test/src/test_mat3x2.h
new file mode 100644
index 0000000..cbf3be2
--- /dev/null
+++ b/test/src/test_mat3x2.h
@@ -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
+}
diff --git a/test/src/test_struct.c b/test/src/test_struct.c
index d4c0cd7..478b01d 100644
--- a/test/src/test_struct.c
+++ b/test/src/test_struct.c
@@ -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;
diff --git a/test/src/tests.c b/test/src/tests.c
index 1a80b84..a51c432 100644
--- a/test/src/tests.c
+++ b/test/src/tests.c
@@ -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"
diff --git a/test/tests.h b/test/tests.h
index 0ca5a92..f06eee2 100644
--- a/test/tests.h
+++ b/test/tests.h
@@ -190,6 +190,12 @@ TEST_DECLARE(glmc_mat3_swap_row)
TEST_DECLARE(glmc_mat3_rmc)
TEST_DECLARE(glmc_mat3_make)
+TEST_DECLARE(MACRO_GLM_MAT3X2_ZERO_INIT)
+TEST_DECLARE(MACRO_GLM_MAT3X2_ZERO)
+TEST_DECLARE(glm_mat3x2_make)
+
+TEST_DECLARE(glmc_mat3x2_make)
+
TEST_DECLARE(MACRO_GLM_MAT2_IDENTITY_INIT)
TEST_DECLARE(MACRO_GLM_MAT2_ZERO_INIT)
TEST_DECLARE(MACRO_GLM_MAT2_IDENTITY)
@@ -875,6 +881,8 @@ TEST_DECLARE(mat2x4s_zero_init)
TEST_DECLARE(mat2x4s_zero)
TEST_DECLARE(mat3s_identity_init)
TEST_DECLARE(mat3s_zero_init)
+TEST_DECLARE(mat3x2s_zero_init)
+TEST_DECLARE(mat3x2s_zero)
TEST_DECLARE(mat4s_identity_init)
TEST_DECLARE(mat4s_zero_init)
TEST_DECLARE(quats_zero_init)
@@ -1061,6 +1069,12 @@ TEST_LIST {
TEST_ENTRY(glmc_mat3_rmc)
TEST_ENTRY(glmc_mat3_make)
+ TEST_ENTRY(MACRO_GLM_MAT3X2_ZERO_INIT)
+ TEST_ENTRY(MACRO_GLM_MAT3X2_ZERO)
+ TEST_ENTRY(glm_mat3x2_make)
+
+ TEST_ENTRY(glmc_mat3x2_make)
+
TEST_ENTRY(MACRO_GLM_MAT2_IDENTITY_INIT)
TEST_ENTRY(MACRO_GLM_MAT2_ZERO_INIT)
TEST_ENTRY(MACRO_GLM_MAT2_IDENTITY)
@@ -1743,6 +1757,8 @@ TEST_LIST {
TEST_ENTRY(mat2x4s_zero)
TEST_ENTRY(mat3s_identity_init)
TEST_ENTRY(mat3s_zero_init)
+ TEST_ENTRY(mat3x2s_zero_init)
+ TEST_ENTRY(mat3x2s_zero)
TEST_ENTRY(mat4s_identity_init)
TEST_ENTRY(mat4s_zero_init)
TEST_ENTRY(quats_zero_init)
diff --git a/win/cglm-test.vcxproj b/win/cglm-test.vcxproj
index 6edf969..ed26aba 100644
--- a/win/cglm-test.vcxproj
+++ b/win/cglm-test.vcxproj
@@ -69,6 +69,7 @@
+
diff --git a/win/cglm-test.vcxproj.filters b/win/cglm-test.vcxproj.filters
index 08889ec..1fc858a 100644
--- a/win/cglm-test.vcxproj.filters
+++ b/win/cglm-test.vcxproj.filters
@@ -88,6 +88,9 @@
src
+
+ src
+
src
diff --git a/win/cglm.vcxproj b/win/cglm.vcxproj
index 95603d6..24e6b20 100644
--- a/win/cglm.vcxproj
+++ b/win/cglm.vcxproj
@@ -74,6 +74,7 @@
+
@@ -125,6 +126,7 @@
+
@@ -167,6 +169,7 @@
+
@@ -218,6 +221,7 @@
+
diff --git a/win/cglm.vcxproj.filters b/win/cglm.vcxproj.filters
index 4332c87..73aaaf1 100644
--- a/win/cglm.vcxproj.filters
+++ b/win/cglm.vcxproj.filters
@@ -58,6 +58,9 @@
src
+
+ src
+
src
@@ -183,6 +186,9 @@
include\cglm\call
+
+ include\cglm\call
+
include\cglm\call
@@ -249,6 +255,9 @@
include\cglm
+
+ include\cglm
+
include\cglm
@@ -366,6 +375,9 @@
include\cglm\struct
+
+ include\cglm\struct
+
include\cglm\struct