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

@@ -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"

View File

@@ -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 */

View File

@@ -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"

46
include/cglm/mat3x2.h Normal file
View File

@@ -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

View File

@@ -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"

View File

@@ -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 */

View File

@@ -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];

View File

@@ -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)] */