Merge pull request #338 from EasyIP2023/feature/mat4x3

add new matrix mat4x3
This commit is contained in:
Recep Aslantas
2023-07-18 09:09:00 +03:00
committed by GitHub
24 changed files with 318 additions and 0 deletions

View File

@@ -26,6 +26,7 @@ extern "C" {
#include "call/mat3x4.h"
#include "call/mat4.h"
#include "call/mat4x2.h"
#include "call/mat4x3.h"
#include "call/affine.h"
#include "call/cam.h"
#include "call/quat.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_mat4x3_h
#define cglmc_mat4x3_h
#ifdef __cplusplus
extern "C" {
#endif
#include "../cglm.h"
CGLM_EXPORT
void
glmc_mat4x3_make(float * __restrict src, mat4x3 dest);
#ifdef __cplusplus
}
#endif
#endif /* cglmc_mat4x3_h */

View File

@@ -17,6 +17,7 @@
#include "ivec4.h"
#include "mat4.h"
#include "mat4x2.h"
#include "mat4x3.h"
#include "mat3.h"
#include "mat3x2.h"
#include "mat3x4.h"

54
include/cglm/mat4x3.h Normal file
View File

@@ -0,0 +1,54 @@
/*
* Copyright (c), Recep Aslantas.
*
* MIT License (MIT), http://opensource.org/licenses/MIT
* Full license can be found in the LICENSE file
*/
/*
Macros:
GLM_MAT4X3_ZERO_INIT
GLM_MAT4X3_ZERO
Functions:
CGLM_INLINE void glm_mat4x3_make(float * restrict src, mat4x3 dest)
*/
#ifndef cglm_mat4x3_h
#define cglm_mat4x3_h
#include "common.h"
#define GLM_MAT4X3_ZERO_INIT {{0.0f, 0.0f, 0.0f}, {0.0f, 0.0f, 0.0f}, \
{0.0f, 0.0f, 0.0f}, {0.0f, 0.0f, 0.0f}}
/* for C only */
#define GLM_MAT4X3_ZERO GLM_MAT4X3_ZERO_INIT
/*!
* @brief Create mat4x3 matrix from pointer
*
* @param[in] src pointer to an array of floats
* @param[out] dest matrix
*/
CGLM_INLINE
void
glm_mat4x3_make(float * __restrict src, mat4x3 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];
dest[2][0] = src[6];
dest[2][1] = src[7];
dest[2][2] = src[8];
dest[3][0] = src[9];
dest[3][1] = src[10];
dest[3][2] = src[11];
}
#endif

View File

@@ -24,6 +24,7 @@ extern "C" {
#include "struct/mat3x4.h"
#include "struct/mat4.h"
#include "struct/mat4x2.h"
#include "struct/mat4x3.h"
#include "struct/affine.h"
#include "struct/frustum.h"
#include "struct/plane.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_MAT4X3_ZERO_INIT
GLMS_MAT4X3_ZERO
Functions:
CGLM_INLINE mat4x3s glms_mat4x3_make(float * __restrict src);
*/
#ifndef cglms_mat4x3_h
#define cglms_mat4x3_h
#include "../common.h"
#include "../types-struct.h"
#include "../mat4x3.h"
/* api definition */
#define glms_mat4x3_(NAME) CGLM_STRUCTAPI(mat4x3, NAME)
#define GLMS_MAT4X3_ZERO_INIT {GLM_MAT4X3_ZERO_INIT}
/* for C only */
#define GLMS_MAT4X3_ZERO ((mat4x3s)GLMS_MAT4X3_ZERO_INIT)
/*!
* @brief Create mat4x3 matrix from pointer
*
* @param[in] src pointer to an array of floats
* @return constructed matrix from raw pointer
*/
CGLM_INLINE
mat4x3s
glms_mat4x3_(make)(float * __restrict src) {
mat4x3s r;
glm_mat4x3_make(src, r.raw);
return r;
}
#endif /* cglms_mat4x3_h */

View File

@@ -281,4 +281,17 @@ typedef union mat4x2s {
#endif
} mat4x2s;
typedef union mat4x3s {
mat4x3 raw;
vec3s col[4]; /* [col (4), row (3)] */
#if CGLM_USE_ANONYMOUS_STRUCT
struct {
float m00, m01, m02;
float m10, m11, m12;
float m20, m21, m22;
float m30, m31, m32;
};
#endif
} mat4x3s;
#endif /* cglm_types_struct_h */

View File

@@ -62,6 +62,7 @@ typedef vec3 mat2x3[2]; /* [col (2), row (3)] */
typedef vec4 mat2x4[2]; /* [col (2), row (4)] */
typedef CGLM_ALIGN_MAT vec4 mat4[4];
typedef vec2 mat4x2[4]; /* [col (4), row (2)] */
typedef vec3 mat4x3[4]; /* [col (4), row (3)] */
/*
Important: cglm stores quaternion as [x, y, z, w] in memory since v0.4.0