add new matrix mat2x3

Initial function being

glm_mat2x3_make

Signed-off-by: Vincent Davis Jr <vince@underview.tech>
This commit is contained in:
Vincent Davis Jr
2023-07-13 22:39:05 -04:00
parent 3b683cf28c
commit 6317ed90e7
24 changed files with 284 additions and 4 deletions

View File

@@ -19,6 +19,7 @@ extern "C" {
#include "call/ivec3.h"
#include "call/ivec4.h"
#include "call/mat2.h"
#include "call/mat2x3.h"
#include "call/mat3.h"
#include "call/mat4.h"
#include "call/affine.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_mat2x3_h
#define cglmc_mat2x3_h
#ifdef __cplusplus
extern "C" {
#endif
#include "../cglm.h"
CGLM_EXPORT
void
glmc_mat2x3_make(float * __restrict src, mat2x3 dest);
#ifdef __cplusplus
}
#endif
#endif /* cglmc_mat2x3_h */

View File

@@ -18,6 +18,7 @@
#include "mat4.h"
#include "mat3.h"
#include "mat2.h"
#include "mat2x3.h"
#include "affine.h"
#include "cam.h"
#include "frustum.h"

45
include/cglm/mat2x3.h Normal file
View File

@@ -0,0 +1,45 @@
/*
* Copyright (c), Recep Aslantas.
*
* MIT License (MIT), http://opensource.org/licenses/MIT
* Full license can be found in the LICENSE file
*/
/*
Macros:
GLM_MAT2X3_ZERO_INIT
GLM_MAT2X3_ZERO
Functions:
CGLM_INLINE void glm_mat2x3_make(float * restrict src, mat2x3 dest)
*/
#ifndef cglm_mat2x3_h
#define cglm_mat2x3_h
#include "common.h"
#define GLM_MAT2X3_ZERO_INIT {{0.0f, 0.0f, 0.0f}, {0.0f, 0.0f, 0.0f}}
/* for C only */
#define GLM_MAT2X3_ZERO ((mat2x3)GLM_MAT2X3_ZERO_INIT)
/*!
* @brief Create mat2x3 matrix from pointer
*
* @param[in] src pointer to an array of floats
* @param[out] dest matrix
*/
CGLM_INLINE
void
glm_mat2x3_make(float * __restrict src, mat2x3 dest) {
dest[0][0] = src[0];
dest[0][1] = src[1];
dest[0][2] = src[2];
dest[1][0] = src[3];
dest[1][1] = src[4];
dest[1][2] = src[5];
}
#endif

View File

@@ -17,6 +17,7 @@ extern "C" {
#include "struct/vec3.h"
#include "struct/vec4.h"
#include "struct/mat2.h"
#include "struct/mat2x3.h"
#include "struct/mat3.h"
#include "struct/mat4.h"
#include "struct/affine.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_MAT2X3_ZERO_INIT
GLMS_MAT2X3_ZERO
Functions:
CGLM_INLINE float glms_mat2x3_make(float * __restrict src);
*/
#ifndef cglms_mat2x3_h
#define cglms_mat2x3_h
#include "../common.h"
#include "../types-struct.h"
#include "../mat2x3.h"
/* api definition */
#define glms_mat2x3_(NAME) CGLM_STRUCTAPI(mat2x3, NAME)
#define GLMS_MAT2X3_ZERO_INIT {GLM_MAT2X3_ZERO_INIT}
/* for C only */
#define GLMS_MAT2X3_ZERO ((mat2x3s)GLMS_MAT2X3_ZERO_INIT)
/*!
* @brief Create mat2x3 matrix from pointer
*
* @param[in] src pointer to an array of floats
* @return constructed matrix from raw pointer
*/
CGLM_INLINE
mat2x3s
glms_mat2x3_(make)(float * __restrict src) {
mat2x3s r;
glm_mat2x3_make(src, r.raw);
return r;
}
#endif /* cglms_mat2x3_h */

View File

@@ -197,6 +197,17 @@ typedef union mat2s {
#endif
} mat2s;
typedef union mat2x3s {
mat2x3 raw;
vec3s col[2]; /* col -> row | [row (2), col (3)] */
#if CGLM_USE_ANONYMOUS_STRUCT
struct {
float m00, m01, m02;
float m10, m11, m12;
};
#endif
} mat2x3s;
typedef union mat3s {
mat3 raw;
vec3s col[3];

View File

@@ -56,6 +56,7 @@ typedef CGLM_ALIGN_IF(16) float vec4[4];
typedef vec4 versor; /* |x, y, z, w| -> w is the last */
typedef vec3 mat3[3];
typedef CGLM_ALIGN_IF(16) vec2 mat2[2];
typedef vec3 mat2x3[2]; /* [row (2), col (3)] */
typedef CGLM_ALIGN_MAT vec4 mat4[4];
/*