mirror of
https://github.com/recp/cglm.git
synced 2026-02-17 03:39:05 +00:00
Compare commits
22 Commits
integratio
...
0356534c0c
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0356534c0c | ||
|
|
5ff0d80c85 | ||
|
|
1952042f2c | ||
|
|
3aad5823ca | ||
|
|
da957fa421 | ||
|
|
47e5d48749 | ||
|
|
a4602f2d5f | ||
|
|
6af4e0d565 | ||
|
|
a311dbfe4c | ||
|
|
a761088e15 | ||
|
|
a886d6e170 | ||
|
|
1a8b105ce6 | ||
|
|
ec5f8074c4 | ||
|
|
6f5fde8b52 | ||
|
|
9da4e78c2e | ||
|
|
27a3ddc928 | ||
|
|
5d530cd8e0 | ||
|
|
dde053a295 | ||
|
|
2128235d42 | ||
|
|
9fb418bcac | ||
|
|
5fde20d65c | ||
|
|
ebc65782f8 |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -82,3 +82,4 @@ cmake-build-debug
|
|||||||
xcode/*
|
xcode/*
|
||||||
.vscode
|
.vscode
|
||||||
.build
|
.build
|
||||||
|
*.swp
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ checkCFLAGS = $(AM_CFLAGS) \
|
|||||||
-std=gnu11 \
|
-std=gnu11 \
|
||||||
-O3 \
|
-O3 \
|
||||||
-DCGLM_DEFINE_PRINTS \
|
-DCGLM_DEFINE_PRINTS \
|
||||||
-I./include
|
-I$(srcdir)/include
|
||||||
|
|
||||||
check_PROGRAMS = test/tests
|
check_PROGRAMS = test/tests
|
||||||
TESTS = $(check_PROGRAMS)
|
TESTS = $(check_PROGRAMS)
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -63,7 +63,7 @@ Functions documentation
|
|||||||
Zero out the mat2x3 (m).
|
Zero out the mat2x3 (m).
|
||||||
|
|
||||||
Parameters:
|
Parameters:
|
||||||
| *[in, out]* **mat** mat2x3 (src, dest)
|
| *[in, out]* **m** mat2x3 (src, dest)
|
||||||
|
|
||||||
.. csv-table:: mat2x3 **(m)**
|
.. csv-table:: mat2x3 **(m)**
|
||||||
:header: "", "column 1", "column 2"
|
:header: "", "column 1", "column 2"
|
||||||
|
|||||||
1140
docs/source/mat3.rst
1140
docs/source/mat3.rst
File diff suppressed because it is too large
Load Diff
@@ -48,6 +48,7 @@ Functions:
|
|||||||
#. :c:func:`glm_mat4_swap_row`
|
#. :c:func:`glm_mat4_swap_row`
|
||||||
#. :c:func:`glm_mat4_rmc`
|
#. :c:func:`glm_mat4_rmc`
|
||||||
#. :c:func:`glm_mat4_make`
|
#. :c:func:`glm_mat4_make`
|
||||||
|
#. :c:func:`glm_mat4_textrans`
|
||||||
|
|
||||||
Functions documentation
|
Functions documentation
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
@@ -313,3 +314,15 @@ Functions documentation
|
|||||||
Parameters:
|
Parameters:
|
||||||
| *[in]* **src** pointer to an array of floats
|
| *[in]* **src** pointer to an array of floats
|
||||||
| *[out]* **dest** destination matrix4x4
|
| *[out]* **dest** destination matrix4x4
|
||||||
|
|
||||||
|
.. c:function:: void glm_mat4_textrans(float sx, float sy, float rot, float tx, float ty, mat4 dest)
|
||||||
|
|
||||||
|
Create texture transformation matrix, rotation is in radians CCW/RH
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
| *[in]* **sx** scale x
|
||||||
|
| *[in]* **sy** scale y
|
||||||
|
| *[in]* **rot** rotation in radians CCW/RH
|
||||||
|
| *[in]* **tx** translation x
|
||||||
|
| *[in]* **ty** translation y
|
||||||
|
| *[out]* **dest** destination matrix3x3
|
||||||
|
|||||||
@@ -28,6 +28,10 @@ glmc_perspective_lh_no(float fovy,
|
|||||||
float farVal,
|
float farVal,
|
||||||
mat4 dest);
|
mat4 dest);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_perspective_resize_lh_no(float aspect, mat4 proj);
|
||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
void
|
void
|
||||||
glmc_persp_move_far_lh_no(mat4 proj, float deltaFar);
|
glmc_persp_move_far_lh_no(mat4 proj, float deltaFar);
|
||||||
|
|||||||
@@ -28,6 +28,10 @@ glmc_perspective_lh_zo(float fovy,
|
|||||||
float farVal,
|
float farVal,
|
||||||
mat4 dest);
|
mat4 dest);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_perspective_resize_lh_zo(float aspect, mat4 proj);
|
||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
void
|
void
|
||||||
glmc_persp_move_far_lh_zo(mat4 proj, float deltaFar);
|
glmc_persp_move_far_lh_zo(mat4 proj, float deltaFar);
|
||||||
|
|||||||
@@ -28,6 +28,10 @@ glmc_perspective_rh_no(float fovy,
|
|||||||
float farVal,
|
float farVal,
|
||||||
mat4 dest);
|
mat4 dest);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_perspective_resize_rh_no(float aspect, mat4 proj);
|
||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
void
|
void
|
||||||
glmc_persp_move_far_rh_no(mat4 proj, float deltaFar);
|
glmc_persp_move_far_rh_no(mat4 proj, float deltaFar);
|
||||||
|
|||||||
@@ -28,6 +28,10 @@ glmc_perspective_rh_zo(float fovy,
|
|||||||
float farVal,
|
float farVal,
|
||||||
mat4 dest);
|
mat4 dest);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_perspective_resize_rh_zo(float aspect, mat4 proj);
|
||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
void
|
void
|
||||||
glmc_persp_move_far_rh_zo(mat4 proj, float deltaFar);
|
glmc_persp_move_far_rh_zo(mat4 proj, float deltaFar);
|
||||||
|
|||||||
@@ -13,21 +13,25 @@ extern "C" {
|
|||||||
|
|
||||||
#include "../cglm.h"
|
#include "../cglm.h"
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_mat2_make(const float * __restrict src, mat2 dest);
|
||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
void
|
void
|
||||||
glmc_mat2_copy(mat2 mat, mat2 dest);
|
glmc_mat2_copy(mat2 mat, mat2 dest);
|
||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
void
|
void
|
||||||
glmc_mat2_identity(mat2 mat);
|
glmc_mat2_identity(mat2 m);
|
||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
void
|
void
|
||||||
glmc_mat2_identity_array(mat2 * __restrict mat, size_t count);
|
glmc_mat2_identity_array(mat2 * __restrict mats, size_t count);
|
||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
void
|
void
|
||||||
glmc_mat2_zero(mat2 mat);
|
glmc_mat2_zero(mat2 m);
|
||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
void
|
void
|
||||||
@@ -35,28 +39,20 @@ glmc_mat2_mul(mat2 m1, mat2 m2, mat2 dest);
|
|||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
void
|
void
|
||||||
glmc_mat2_transpose_to(mat2 m, mat2 dest);
|
glmc_mat2_mulv(mat2 m, vec2 v, vec2 dest);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_mat2_transpose_to(mat2 mat, mat2 dest);
|
||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
void
|
void
|
||||||
glmc_mat2_transpose(mat2 m);
|
glmc_mat2_transpose(mat2 m);
|
||||||
|
|
||||||
CGLM_EXPORT
|
|
||||||
void
|
|
||||||
glmc_mat2_mulv(mat2 m, vec2 v, vec2 dest);
|
|
||||||
|
|
||||||
CGLM_EXPORT
|
|
||||||
float
|
|
||||||
glmc_mat2_trace(mat2 m);
|
|
||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
void
|
void
|
||||||
glmc_mat2_scale(mat2 m, float s);
|
glmc_mat2_scale(mat2 m, float s);
|
||||||
|
|
||||||
CGLM_EXPORT
|
|
||||||
float
|
|
||||||
glmc_mat2_det(mat2 mat);
|
|
||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
void
|
void
|
||||||
glmc_mat2_inv(mat2 mat, mat2 dest);
|
glmc_mat2_inv(mat2 mat, mat2 dest);
|
||||||
@@ -71,11 +67,15 @@ glmc_mat2_swap_row(mat2 mat, int row1, int row2);
|
|||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
float
|
float
|
||||||
glmc_mat2_rmc(vec2 r, mat2 m, vec2 c);
|
glmc_mat2_trace(mat2 m);
|
||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
void
|
float
|
||||||
glmc_mat2_make(const float * __restrict src, mat2 dest);
|
glmc_mat2_det(mat2 m);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
float
|
||||||
|
glmc_mat2_rmc(vec2 r, mat2 m, vec2 c);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -84,6 +84,10 @@ CGLM_EXPORT
|
|||||||
void
|
void
|
||||||
glmc_mat3_make(const float * __restrict src, mat3 dest);
|
glmc_mat3_make(const float * __restrict src, mat3 dest);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_mat3_textrans(float sx, float sy, float rot, float tx, float ty, mat3 dest);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -125,6 +125,10 @@ CGLM_EXPORT
|
|||||||
void
|
void
|
||||||
glmc_mat4_make(const float * __restrict src, mat4 dest);
|
glmc_mat4_make(const float * __restrict src, mat4 dest);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_mat4_textrans(float sx, float sy, float rot, float tx, float ty, mat4 dest);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -245,6 +245,10 @@ CGLM_EXPORT
|
|||||||
bool
|
bool
|
||||||
glmc_vec2_refract(vec2 v, vec2 n, float eta, vec2 dest);
|
glmc_vec2_refract(vec2 v, vec2 n, float eta, vec2 dest);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_vec2_swap(vec2 a, vec2 b);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -363,6 +363,10 @@ CGLM_EXPORT
|
|||||||
bool
|
bool
|
||||||
glmc_vec3_refract(vec3 v, vec3 n, float eta, vec3 dest);
|
glmc_vec3_refract(vec3 v, vec3 n, float eta, vec3 dest);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_vec3_swap(vec3 a, vec3 b);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -336,6 +336,10 @@ CGLM_EXPORT
|
|||||||
bool
|
bool
|
||||||
glmc_vec4_refract(vec4 v, vec4 n, float eta, vec4 dest);
|
glmc_vec4_refract(vec4 v, vec4 n, float eta, vec4 dest);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_vec4_swap(vec4 a, vec4 b);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -13,22 +13,22 @@
|
|||||||
GLM_MAT2_ZERO
|
GLM_MAT2_ZERO
|
||||||
|
|
||||||
Functions:
|
Functions:
|
||||||
|
CGLM_INLINE void glm_mat2_make(float * restrict src, mat2 dest)
|
||||||
CGLM_INLINE void glm_mat2_copy(mat2 mat, mat2 dest)
|
CGLM_INLINE void glm_mat2_copy(mat2 mat, mat2 dest)
|
||||||
CGLM_INLINE void glm_mat2_identity(mat2 mat)
|
CGLM_INLINE void glm_mat2_identity(mat2 m)
|
||||||
CGLM_INLINE void glm_mat2_identity_array(mat2 * restrict mat, size_t count)
|
CGLM_INLINE void glm_mat2_identity_array(mat2 * restrict mats, size_t count)
|
||||||
CGLM_INLINE void glm_mat2_zero(mat2 mat)
|
CGLM_INLINE void glm_mat2_zero(mat2 m)
|
||||||
CGLM_INLINE void glm_mat2_mul(mat2 m1, mat2 m2, mat2 dest)
|
CGLM_INLINE void glm_mat2_mul(mat2 m1, mat2 m2, mat2 dest)
|
||||||
CGLM_INLINE void glm_mat2_transpose_to(mat2 m, mat2 dest)
|
|
||||||
CGLM_INLINE void glm_mat2_transpose(mat2 m)
|
|
||||||
CGLM_INLINE void glm_mat2_mulv(mat2 m, vec2 v, vec2 dest)
|
CGLM_INLINE void glm_mat2_mulv(mat2 m, vec2 v, vec2 dest)
|
||||||
CGLM_INLINE float glm_mat2_trace(mat2 m)
|
CGLM_INLINE void glm_mat2_transpose_to(mat2 mat, mat2 dest)
|
||||||
|
CGLM_INLINE void glm_mat2_transpose(mat2 m)
|
||||||
CGLM_INLINE void glm_mat2_scale(mat2 m, float s)
|
CGLM_INLINE void glm_mat2_scale(mat2 m, float s)
|
||||||
CGLM_INLINE float glm_mat2_det(mat2 mat)
|
|
||||||
CGLM_INLINE void glm_mat2_inv(mat2 mat, mat2 dest)
|
CGLM_INLINE void glm_mat2_inv(mat2 mat, mat2 dest)
|
||||||
CGLM_INLINE void glm_mat2_swap_col(mat2 mat, int col1, int col2)
|
CGLM_INLINE void glm_mat2_swap_col(mat2 mat, int col1, int col2)
|
||||||
CGLM_INLINE void glm_mat2_swap_row(mat2 mat, int row1, int row2)
|
CGLM_INLINE void glm_mat2_swap_row(mat2 mat, int row1, int row2)
|
||||||
|
CGLM_INLINE float glm_mat2_det(mat2 m)
|
||||||
|
CGLM_INLINE float glm_mat2_trace(mat2 m)
|
||||||
CGLM_INLINE float glm_mat2_rmc(vec2 r, mat2 m, vec2 c)
|
CGLM_INLINE float glm_mat2_rmc(vec2 r, mat2 m, vec2 c)
|
||||||
CGLM_INLINE void glm_mat2_make(float * restrict src, mat2 dest)
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef cglm_mat2_h
|
#ifndef cglm_mat2_h
|
||||||
@@ -57,10 +57,25 @@
|
|||||||
#define GLM_MAT2_ZERO ((mat2)GLM_MAT2_ZERO_INIT)
|
#define GLM_MAT2_ZERO ((mat2)GLM_MAT2_ZERO_INIT)
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief copy all members of [mat] to [dest]
|
* @brief Create mat2 (dest) from pointer (src).
|
||||||
*
|
*
|
||||||
* @param[in] mat source
|
* @param[in] src pointer to an array of floats (left)
|
||||||
* @param[out] dest destination
|
* @param[out] dest destination (result, mat2)
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
void
|
||||||
|
glm_mat2_make(const float * __restrict src, mat2 dest) {
|
||||||
|
dest[0][0] = src[0];
|
||||||
|
dest[0][1] = src[1];
|
||||||
|
dest[1][0] = src[2];
|
||||||
|
dest[1][1] = src[3];
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Copy mat2 (mat) to mat2 (dest).
|
||||||
|
*
|
||||||
|
* @param[in] mat mat2 (left, src)
|
||||||
|
* @param[out] dest destination (result, mat2)
|
||||||
*/
|
*/
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
void
|
void
|
||||||
@@ -69,7 +84,9 @@ glm_mat2_copy(mat2 mat, mat2 dest) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief make given matrix identity. It is identical with below,
|
* @brief Copy a mat2 identity to mat2 (m), or makes mat2 (m) an identity.
|
||||||
|
*
|
||||||
|
* The same thing may be achieved with either of bellow methods,
|
||||||
* but it is more easy to do that with this func especially for members
|
* but it is more easy to do that with this func especially for members
|
||||||
* e.g. glm_mat2_identity(aStruct->aMatrix);
|
* e.g. glm_mat2_identity(aStruct->aMatrix);
|
||||||
*
|
*
|
||||||
@@ -80,48 +97,46 @@ glm_mat2_copy(mat2 mat, mat2 dest) {
|
|||||||
* mat2 mat = GLM_MAT2_IDENTITY_INIT;
|
* mat2 mat = GLM_MAT2_IDENTITY_INIT;
|
||||||
* @endcode
|
* @endcode
|
||||||
*
|
*
|
||||||
* @param[in, out] mat destination
|
* @param[in, out] m mat2 (src, dest)
|
||||||
*/
|
*/
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
void
|
void
|
||||||
glm_mat2_identity(mat2 mat) {
|
glm_mat2_identity(mat2 m) {
|
||||||
CGLM_ALIGN_MAT mat2 t = GLM_MAT2_IDENTITY_INIT;
|
CGLM_ALIGN_MAT mat2 t = GLM_MAT2_IDENTITY_INIT;
|
||||||
glm_mat2_copy(t, mat);
|
glm_mat2_copy(t, m);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief make given matrix array's each element identity matrix
|
* @brief Given an array of mat2’s (mats) make each matrix an identity matrix.
|
||||||
*
|
*
|
||||||
* @param[in, out] mat matrix array (must be aligned (16)
|
* @param[in, out] mats Array of mat2’s (must be aligned (16/32) if alignment is not disabled)
|
||||||
* if alignment is not disabled)
|
* @param[in] count Array size of mats or number of matrices
|
||||||
*
|
|
||||||
* @param[in] count count of matrices
|
|
||||||
*/
|
*/
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
void
|
void
|
||||||
glm_mat2_identity_array(mat2 * __restrict mat, size_t count) {
|
glm_mat2_identity_array(mat2 * __restrict mats, size_t count) {
|
||||||
CGLM_ALIGN_MAT mat2 t = GLM_MAT2_IDENTITY_INIT;
|
CGLM_ALIGN_MAT mat2 t = GLM_MAT2_IDENTITY_INIT;
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
for (i = 0; i < count; i++) {
|
for (i = 0; i < count; i++) {
|
||||||
glm_mat2_copy(t, mat[i]);
|
glm_mat2_copy(t, mats[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief make given matrix zero.
|
* @brief Zero out the mat2 (m).
|
||||||
*
|
*
|
||||||
* @param[in, out] mat matrix
|
* @param[in, out] m mat2 (src, dest)
|
||||||
*/
|
*/
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
void
|
void
|
||||||
glm_mat2_zero(mat2 mat) {
|
glm_mat2_zero(mat2 m) {
|
||||||
CGLM_ALIGN_MAT mat2 t = GLM_MAT2_ZERO_INIT;
|
CGLM_ALIGN_MAT mat2 t = GLM_MAT2_ZERO_INIT;
|
||||||
glm_mat2_copy(t, mat);
|
glm_mat2_copy(t, m);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief multiply m1 and m2 to dest
|
* @brief Multiply mat2 (m1) by mat2 (m2) and store in mat2 (dest).
|
||||||
*
|
*
|
||||||
* m1, m2 and dest matrices can be same matrix, it is possible to write this:
|
* m1, m2 and dest matrices can be same matrix, it is possible to write this:
|
||||||
*
|
*
|
||||||
@@ -130,9 +145,9 @@ glm_mat2_zero(mat2 mat) {
|
|||||||
* glm_mat2_mul(m, m, m);
|
* glm_mat2_mul(m, m, m);
|
||||||
* @endcode
|
* @endcode
|
||||||
*
|
*
|
||||||
* @param[in] m1 left matrix
|
* @param[in] m1 mat2 (left)
|
||||||
* @param[in] m2 right matrix
|
* @param[in] m2 mat2 (right)
|
||||||
* @param[out] dest destination matrix
|
* @param[out] dest destination (result, mat2)
|
||||||
*/
|
*/
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
void
|
void
|
||||||
@@ -157,32 +172,44 @@ glm_mat2_mul(mat2 m1, mat2 m2, mat2 dest) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief transpose mat2 and store in dest
|
* @brief Multiply mat2 (m) by vec2 (v) and store in vec2 (dest).
|
||||||
*
|
*
|
||||||
* source matrix will not be transposed unless dest is m
|
* @param[in] m mat2 (left)
|
||||||
*
|
* @param[in] v vec2 (right, column vector)
|
||||||
* @param[in] m matrix
|
* @param[out] dest destination (result, column vector)
|
||||||
* @param[out] dest result
|
|
||||||
*/
|
*/
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
void
|
void
|
||||||
glm_mat2_transpose_to(mat2 m, mat2 dest) {
|
glm_mat2_mulv(mat2 m, vec2 v, vec2 dest) {
|
||||||
|
dest[0] = m[0][0] * v[0] + m[1][0] * v[1];
|
||||||
|
dest[1] = m[0][1] * v[0] + m[1][1] * v[1];
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Transpose mat2 (mat) and store in mat2 (dest).
|
||||||
|
*
|
||||||
|
* @param[in] mat mat2 (left, src)
|
||||||
|
* @param[out] dest destination (result, mat2)
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
void
|
||||||
|
glm_mat2_transpose_to(mat2 mat, mat2 dest) {
|
||||||
#if defined(__wasm__) && defined(__wasm_simd128__)
|
#if defined(__wasm__) && defined(__wasm_simd128__)
|
||||||
glm_mat2_transp_wasm(m, dest);
|
glm_mat2_transp_wasm(mat, dest);
|
||||||
#elif defined( __SSE__ ) || defined( __SSE2__ )
|
#elif defined( __SSE__ ) || defined( __SSE2__ )
|
||||||
glm_mat2_transp_sse2(m, dest);
|
glm_mat2_transp_sse2(mat, dest);
|
||||||
#else
|
#else
|
||||||
dest[0][0] = m[0][0];
|
dest[0][0] = mat[0][0];
|
||||||
dest[0][1] = m[1][0];
|
dest[0][1] = mat[1][0];
|
||||||
dest[1][0] = m[0][1];
|
dest[1][0] = mat[0][1];
|
||||||
dest[1][1] = m[1][1];
|
dest[1][1] = mat[1][1];
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief transpose mat2 and store result in same matrix
|
* @brief Transpose mat2 (m) and store result in the same matrix.
|
||||||
*
|
*
|
||||||
* @param[in, out] m source and dest
|
* @param[in, out] m mat2 (src, dest)
|
||||||
*/
|
*/
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
void
|
void
|
||||||
@@ -194,39 +221,10 @@ glm_mat2_transpose(mat2 m) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief multiply mat2 with vec2 (column vector) and store in dest vector
|
* @brief Multiply mat2 (m) by scalar constant (s).
|
||||||
*
|
*
|
||||||
* @param[in] m mat2 (left)
|
* @param[in, out] m mat2 (src, dest)
|
||||||
* @param[in] v vec2 (right, column vector)
|
* @param[in] s float (scalar)
|
||||||
* @param[out] dest vec2 (result, column vector)
|
|
||||||
*/
|
|
||||||
CGLM_INLINE
|
|
||||||
void
|
|
||||||
glm_mat2_mulv(mat2 m, vec2 v, vec2 dest) {
|
|
||||||
dest[0] = m[0][0] * v[0] + m[1][0] * v[1];
|
|
||||||
dest[1] = m[0][1] * v[0] + m[1][1] * v[1];
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* @brief trace of matrix
|
|
||||||
*
|
|
||||||
* sum of the elements on the main diagonal from upper left to the lower right
|
|
||||||
*
|
|
||||||
* @param[in] m matrix
|
|
||||||
*/
|
|
||||||
CGLM_INLINE
|
|
||||||
float
|
|
||||||
glm_mat2_trace(mat2 m) {
|
|
||||||
return m[0][0] + m[1][1];
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* @brief scale (multiply with scalar) matrix
|
|
||||||
*
|
|
||||||
* multiply matrix with scalar
|
|
||||||
*
|
|
||||||
* @param[in, out] m matrix
|
|
||||||
* @param[in] s scalar
|
|
||||||
*/
|
*/
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
void
|
void
|
||||||
@@ -247,23 +245,10 @@ glm_mat2_scale(mat2 m, float s) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief mat2 determinant
|
* @brief Inverse mat2 (mat) and store in mat2 (dest).
|
||||||
*
|
*
|
||||||
* @param[in] mat matrix
|
* @param[in] mat mat2 (left, src)
|
||||||
*
|
* @param[out] dest destination (result, inverse mat2)
|
||||||
* @return determinant
|
|
||||||
*/
|
|
||||||
CGLM_INLINE
|
|
||||||
float
|
|
||||||
glm_mat2_det(mat2 mat) {
|
|
||||||
return mat[0][0] * mat[1][1] - mat[1][0] * mat[0][1];
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* @brief inverse mat2 and store in dest
|
|
||||||
*
|
|
||||||
* @param[in] mat matrix
|
|
||||||
* @param[out] dest inverse matrix
|
|
||||||
*/
|
*/
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
void
|
void
|
||||||
@@ -281,11 +266,11 @@ glm_mat2_inv(mat2 mat, mat2 dest) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief swap two matrix columns
|
* @brief Swap two columns in mat2 (mat) and store in same matrix.
|
||||||
*
|
*
|
||||||
* @param[in,out] mat matrix
|
* @param[in, out] mat mat2 (src, dest)
|
||||||
* @param[in] col1 col1
|
* @param[in] col1 Column 1 array index
|
||||||
* @param[in] col2 col2
|
* @param[in] col2 Column 2 array index
|
||||||
*/
|
*/
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
void
|
void
|
||||||
@@ -303,11 +288,11 @@ glm_mat2_swap_col(mat2 mat, int col1, int col2) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief swap two matrix rows
|
* @brief Swap two rows in mat2 (mat) and store in same matrix.
|
||||||
*
|
*
|
||||||
* @param[in,out] mat matrix
|
* @param[in, out] mat mat2 (src, dest)
|
||||||
* @param[in] row1 row1
|
* @param[in] row1 Row 1 array index
|
||||||
* @param[in] row2 row2
|
* @param[in] row2 Row 2 array index
|
||||||
*/
|
*/
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
void
|
void
|
||||||
@@ -325,18 +310,47 @@ glm_mat2_swap_row(mat2 mat, int row1, int row2) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief helper for R (row vector) * M (matrix) * C (column vector)
|
* @brief Returns mat2 determinant.
|
||||||
|
*
|
||||||
|
* @param[in] m mat2 (src)
|
||||||
|
*
|
||||||
|
* @return[out] mat2 determinant (float)
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
float
|
||||||
|
glm_mat2_det(mat2 m) {
|
||||||
|
return m[0][0] * m[1][1] - m[1][0] * m[0][1];
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Returns trace of matrix. Which is:
|
||||||
|
*
|
||||||
|
* The sum of the elements on the main diagonal from
|
||||||
|
* upper left corner to the bottom right corner.
|
||||||
|
*
|
||||||
|
* @param[in] m mat2 (src)
|
||||||
|
*
|
||||||
|
* @return[out] mat2 trace (float)
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
float
|
||||||
|
glm_mat2_trace(mat2 m) {
|
||||||
|
return m[0][0] + m[1][1];
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Helper for R (row vector) * M (matrix) * C (column vector)
|
||||||
*
|
*
|
||||||
* rmc stands for Row * Matrix * Column
|
* rmc stands for Row * Matrix * Column
|
||||||
*
|
*
|
||||||
* the result is scalar because R * M = Matrix1x2 (row vector),
|
* the result is scalar because M * C = ResC (1x2, column vector),
|
||||||
* then Matrix1x2 * Vec2 (column vector) = Matrix1x1 (Scalar)
|
* then if you take the dot_product(R (2x1), ResC (1x2)) = scalar value.
|
||||||
*
|
*
|
||||||
* @param[in] r row vector or matrix1x2
|
* @param[in] r vec2 (2x1, row vector)
|
||||||
* @param[in] m matrix2x2
|
* @param[in] m mat2 (2x2, matrix)
|
||||||
* @param[in] c column vector or matrix2x1
|
* @param[in] c vec2 (1x2, column vector)
|
||||||
*
|
*
|
||||||
* @return scalar value e.g. Matrix1x1
|
* @return[out] Scalar value (float, 1x1)
|
||||||
*/
|
*/
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
float
|
float
|
||||||
@@ -346,19 +360,4 @@ glm_mat2_rmc(vec2 r, mat2 m, vec2 c) {
|
|||||||
return glm_vec2_dot(r, tmp);
|
return glm_vec2_dot(r, tmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
|
||||||
* @brief Create mat2 matrix from pointer
|
|
||||||
*
|
|
||||||
* @param[in] src pointer to an array of floats
|
|
||||||
* @param[out] dest matrix
|
|
||||||
*/
|
|
||||||
CGLM_INLINE
|
|
||||||
void
|
|
||||||
glm_mat2_make(const float * __restrict src, mat2 dest) {
|
|
||||||
dest[0][0] = src[0];
|
|
||||||
dest[0][1] = src[1];
|
|
||||||
dest[1][0] = src[2];
|
|
||||||
dest[1][1] = src[3];
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif /* cglm_mat2_h */
|
#endif /* cglm_mat2_h */
|
||||||
|
|||||||
@@ -31,6 +31,7 @@
|
|||||||
CGLM_INLINE void glm_mat3_swap_row(mat3 mat, int row1, int row2);
|
CGLM_INLINE void glm_mat3_swap_row(mat3 mat, int row1, int row2);
|
||||||
CGLM_INLINE float glm_mat3_rmc(vec3 r, mat3 m, vec3 c);
|
CGLM_INLINE float glm_mat3_rmc(vec3 r, mat3 m, vec3 c);
|
||||||
CGLM_INLINE void glm_mat3_make(float * restrict src, mat3 dest);
|
CGLM_INLINE void glm_mat3_make(float * restrict src, mat3 dest);
|
||||||
|
CGLM_INLINE void glm_mat3_textrans(float sx, float sy, float rot, float tx, float ty, mat3 dest);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef cglm_mat3_h
|
#ifndef cglm_mat3_h
|
||||||
@@ -448,4 +449,32 @@ glm_mat3_make(const float * __restrict src, mat3 dest) {
|
|||||||
dest[2][2] = src[8];
|
dest[2][2] = src[8];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Create mat3 matrix from texture transform parameters
|
||||||
|
*
|
||||||
|
* @param[in] sx scale x
|
||||||
|
* @param[in] sy scale y
|
||||||
|
* @param[in] rot rotation in radians CCW/RH
|
||||||
|
* @param[in] tx translate x
|
||||||
|
* @param[in] ty translate y
|
||||||
|
* @param[out] dest texture transform matrix
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
void
|
||||||
|
glm_mat3_textrans(float sx, float sy, float rot, float tx, float ty, mat3 dest) {
|
||||||
|
float c, s;
|
||||||
|
|
||||||
|
c = cosf(rot);
|
||||||
|
s = sinf(rot);
|
||||||
|
|
||||||
|
glm_mat3_identity(dest);
|
||||||
|
|
||||||
|
dest[0][0] = c * sx;
|
||||||
|
dest[0][1] = -s * sy;
|
||||||
|
dest[1][0] = s * sx;
|
||||||
|
dest[1][1] = c * sy;
|
||||||
|
dest[2][0] = tx;
|
||||||
|
dest[2][1] = ty;
|
||||||
|
}
|
||||||
|
|
||||||
#endif /* cglm_mat3_h */
|
#endif /* cglm_mat3_h */
|
||||||
|
|||||||
@@ -44,6 +44,7 @@
|
|||||||
CGLM_INLINE void glm_mat4_swap_row(mat4 mat, int row1, int row2);
|
CGLM_INLINE void glm_mat4_swap_row(mat4 mat, int row1, int row2);
|
||||||
CGLM_INLINE float glm_mat4_rmc(vec4 r, mat4 m, vec4 c);
|
CGLM_INLINE float glm_mat4_rmc(vec4 r, mat4 m, vec4 c);
|
||||||
CGLM_INLINE void glm_mat4_make(float * restrict src, mat4 dest);
|
CGLM_INLINE void glm_mat4_make(float * restrict src, mat4 dest);
|
||||||
|
CGLM_INLINE void glm_mat4_textrans(float sx, float sy, float rot, float tx, float ty, mat4 dest);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef cglm_mat_h
|
#ifndef cglm_mat_h
|
||||||
@@ -799,4 +800,32 @@ glm_mat4_make(const float * __restrict src, mat4 dest) {
|
|||||||
dest[2][3] = src[11]; dest[3][3] = src[15];
|
dest[2][3] = src[11]; dest[3][3] = src[15];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Create mat4 matrix from texture transform parameters
|
||||||
|
*
|
||||||
|
* @param[in] sx scale x
|
||||||
|
* @param[in] sy scale y
|
||||||
|
* @param[in] rot rotation in radians CCW/RH
|
||||||
|
* @param[in] tx translate x
|
||||||
|
* @param[in] ty translate y
|
||||||
|
* @param[out] dest texture transform matrix
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
void
|
||||||
|
glm_mat4_textrans(float sx, float sy, float rot, float tx, float ty, mat4 dest) {
|
||||||
|
float c, s;
|
||||||
|
|
||||||
|
c = cosf(rot);
|
||||||
|
s = sinf(rot);
|
||||||
|
|
||||||
|
glm_mat4_identity(dest);
|
||||||
|
|
||||||
|
dest[0][0] = c * sx;
|
||||||
|
dest[0][1] = -s * sy;
|
||||||
|
dest[1][0] = s * sx;
|
||||||
|
dest[1][1] = c * sy;
|
||||||
|
dest[3][0] = tx;
|
||||||
|
dest[3][1] = ty;
|
||||||
|
}
|
||||||
|
|
||||||
#endif /* cglm_mat_h */
|
#endif /* cglm_mat_h */
|
||||||
|
|||||||
@@ -13,21 +13,20 @@
|
|||||||
GLM_MAT2_ZERO
|
GLM_MAT2_ZERO
|
||||||
|
|
||||||
Functions:
|
Functions:
|
||||||
CGLM_INLINE void glms_mat2_identity(mat2 mat)
|
|
||||||
CGLM_INLINE void glms_mat2_identity_array(mat2 * restrict mat, size_t count)
|
|
||||||
CGLM_INLINE void glms_mat2_zero(mat2 mat)
|
|
||||||
CGLM_INLINE void glms_mat2_mul(mat2 m1, mat2 m2, mat2 dest)
|
|
||||||
CGLM_INLINE void glms_mat2_transpose_to(mat2 m, mat2 dest)
|
|
||||||
CGLM_INLINE void glms_mat2_transpose(mat2 m)
|
|
||||||
CGLM_INLINE void glms_mat2_mulv(mat2 m, vec2 v, vec2 dest)
|
|
||||||
CGLM_INLINE float glms_mat2_trace(mat2 m)
|
|
||||||
CGLM_INLINE void glms_mat2_scale(mat2 m, float s)
|
|
||||||
CGLM_INLINE float glms_mat2_det(mat2 mat)
|
|
||||||
CGLM_INLINE void glms_mat2_inv(mat2 mat, mat2 dest)
|
|
||||||
CGLM_INLINE void glms_mat2_swap_col(mat2 mat, int col1, int col2)
|
|
||||||
CGLM_INLINE void glms_mat2_swap_row(mat2 mat, int row1, int row2)
|
|
||||||
CGLM_INLINE float glms_mat2_rmc(vec2 r, mat2 m, vec2 c)
|
|
||||||
CGLM_INLINE mat2s glms_mat2_make(const float * __restrict src);
|
CGLM_INLINE mat2s glms_mat2_make(const float * __restrict src);
|
||||||
|
CGLM_INLINE mat2s glms_mat2_identity(void)
|
||||||
|
CGLM_INLINE void glms_mat2_identity_array(mat2 * restrict mats, size_t count)
|
||||||
|
CGLM_INLINE mat2s glms_mat2_zero(void)
|
||||||
|
CGLM_INLINE mat2s glms_mat2_mul(mat2 m1, mat2 m2)
|
||||||
|
CGLM_INLINE vec2s glms_mat2_mulv(mat2 m, vec2 v)
|
||||||
|
CGLM_INLINE mat2s glms_mat2_transpose(mat2 m)
|
||||||
|
CGLM_INLINE mat2s glms_mat2_scale(mat2 m, float s)
|
||||||
|
CGLM_INLINE mat2s glms_mat2_inv(mat2 m)
|
||||||
|
CGLM_INLINE mat2s glms_mat2_swap_col(mat2 mat, int col1, int col2)
|
||||||
|
CGLM_INLINE mat2s glms_mat2_swap_row(mat2 mat, int row1, int row2)
|
||||||
|
CGLM_INLINE float glms_mat2_det(mat2 m)
|
||||||
|
CGLM_INLINE float glms_mat2_trace(mat2 m)
|
||||||
|
CGLM_INLINE float glms_mat2_rmc(vec2 r, mat2 m, vec2 c)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef cglms_mat2_h
|
#ifndef cglms_mat2_h
|
||||||
@@ -48,7 +47,23 @@
|
|||||||
#define GLMS_MAT2_ZERO ((mat2s)GLMS_MAT2_ZERO_INIT)
|
#define GLMS_MAT2_ZERO ((mat2s)GLMS_MAT2_ZERO_INIT)
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief make given matrix identity. It is identical with below,
|
* @brief Returns mat2s (r) from pointer (src).
|
||||||
|
*
|
||||||
|
* @param[in] src pointer to an array of floats
|
||||||
|
* @return[out] r constructed mat2s from raw pointer
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
mat2s
|
||||||
|
glms_mat2_(make)(const float * __restrict src) {
|
||||||
|
mat2s r;
|
||||||
|
glm_mat2_make(src, r.raw);
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Return a identity mat2s (r).
|
||||||
|
*
|
||||||
|
* The same thing may be achieved with either of bellow methods,
|
||||||
* but it is more easy to do that with this func especially for members
|
* but it is more easy to do that with this func especially for members
|
||||||
* e.g. glm_mat2_identity(aStruct->aMatrix);
|
* e.g. glm_mat2_identity(aStruct->aMatrix);
|
||||||
*
|
*
|
||||||
@@ -59,7 +74,7 @@
|
|||||||
* mat2 mat = GLM_MAT2_IDENTITY_INIT;
|
* mat2 mat = GLM_MAT2_IDENTITY_INIT;
|
||||||
* @endcode
|
* @endcode
|
||||||
*
|
*
|
||||||
* @returns identity matrix
|
* @return[out] r constructed mat2s from raw pointer
|
||||||
*/
|
*/
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
mat2s
|
mat2s
|
||||||
@@ -70,28 +85,26 @@ glms_mat2_(identity)(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief make given matrix array's each element identity matrix
|
* @brief Given an array of mat2s’s (mats) make each matrix an identity matrix.
|
||||||
*
|
*
|
||||||
* @param[in, out] mat matrix array (must be aligned (16)
|
* @param[in, out] mats Array of mat2s’s (must be aligned (16/32) if alignment is not disabled)
|
||||||
* if alignment is not disabled)
|
* @param[in] count Array size of mats or number of matrices
|
||||||
*
|
|
||||||
* @param[in] count count of matrices
|
|
||||||
*/
|
*/
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
void
|
void
|
||||||
glms_mat2_(identity_array)(mat2s * __restrict mat, size_t count) {
|
glms_mat2_(identity_array)(mat2s * __restrict mats, size_t count) {
|
||||||
CGLM_ALIGN_MAT mat2s t = GLMS_MAT2_IDENTITY_INIT;
|
CGLM_ALIGN_MAT mat2s t = GLMS_MAT2_IDENTITY_INIT;
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
for (i = 0; i < count; i++) {
|
for (i = 0; i < count; i++) {
|
||||||
glm_mat2_copy(t.raw, mat[i].raw);
|
glm_mat2_copy(t.raw, mats[i].raw);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief make given matrix zero.
|
* @brief Return zero'd out mat2 (r).
|
||||||
*
|
*
|
||||||
* @returns matrix
|
* @return[out] r constructed mat2s from raw pointer
|
||||||
*/
|
*/
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
mat2s
|
mat2s
|
||||||
@@ -102,19 +115,18 @@ glms_mat2_(zero)(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief multiply m1 and m2 to dest
|
* @brief Multiply mat2 (m1) by mat2 (m2) and return in mat2s (r)
|
||||||
*
|
*
|
||||||
* m1, m2 and dest matrices can be same matrix, it is possible to write this:
|
* m1 and m2 matrices can be the same matrix, it is possible to write this:
|
||||||
*
|
*
|
||||||
* @code
|
* @code
|
||||||
* mat2 m = GLM_MAT2_IDENTITY_INIT;
|
* mat2 m = GLM_MAT2_IDENTITY_INIT;
|
||||||
* r = glms_mat2_mul(m, m);
|
* mat2s r = glms_mat2_mul(m, m);
|
||||||
* @endcode
|
* @endcode
|
||||||
*
|
*
|
||||||
* @param[in] m1 left matrix
|
* @param[in] m1 mat2s (left)
|
||||||
* @param[in] m2 right matrix
|
* @param[in] m2 mat2s (right)
|
||||||
*
|
* @return[out] r constructed mat2s from raw pointers
|
||||||
* @returns destination matrix
|
|
||||||
*/
|
*/
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
mat2s
|
mat2s
|
||||||
@@ -124,26 +136,12 @@ glms_mat2_(mul)(mat2s m1, mat2s m2) {
|
|||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*
|
||||||
* @brief transpose mat2
|
* @brief Multiply mat2s (m) by vec2s (v) and return in vec2s (r).
|
||||||
*
|
*
|
||||||
* @param[in] m matrix to transpose
|
* @param[in] m mat2s (left)
|
||||||
*
|
* @param[in] v vec2s (right, column vector)
|
||||||
* @returns transposed matrix
|
* @return[out] r constructed vec2s from raw pointers
|
||||||
*/
|
|
||||||
CGLM_INLINE
|
|
||||||
mat2s
|
|
||||||
glms_mat2_(transpose)(mat2s m) {
|
|
||||||
glm_mat2_transpose(m.raw);
|
|
||||||
return m;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* @brief multiply mat2 with vec2 (column vector) and store in dest vector
|
|
||||||
*
|
|
||||||
* @param[in] m mat2 (left)
|
|
||||||
* @param[in] v vec2 (right, column vector)
|
|
||||||
* @returns vec2 (result, column vector)
|
|
||||||
*/
|
*/
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
vec2s
|
vec2s
|
||||||
@@ -154,26 +152,24 @@ glms_mat2_(mulv)(mat2s m, vec2s v) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief trace of matrix
|
* @brief Transpose mat2s (m) and store result in the same matrix.
|
||||||
*
|
*
|
||||||
* sum of the elements on the main diagonal from upper left to the lower right
|
* @param[in] m mat2s (src)
|
||||||
*
|
* @return[out] m constructed mat2s from raw pointers
|
||||||
* @param[in] m matrix
|
|
||||||
*/
|
*/
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
float
|
mat2s
|
||||||
glms_mat2_(trace)(mat2s m) {
|
glms_mat2_(transpose)(mat2s m) {
|
||||||
return glm_mat2_trace(m.raw);
|
glm_mat2_transpose(m.raw);
|
||||||
|
return m;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief scale (multiply with scalar) matrix
|
* @brief Multiply mat2s (m) by scalar constant (s)
|
||||||
*
|
*
|
||||||
* multiply matrix with scalar
|
* @param[in] m mat2s (src)
|
||||||
*
|
* @param[in] s scalar value
|
||||||
* @param[in, out] m matrix
|
* @return[out] m constructed mat2s from raw pointers
|
||||||
* @param[in] s scalar
|
|
||||||
* @returns matrix
|
|
||||||
*/
|
*/
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
mat2s
|
mat2s
|
||||||
@@ -183,39 +179,26 @@ glms_mat2_(scale)(mat2s m, float s) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief mat2 determinant
|
* @brief Inverse mat2s (m) and return in mat2s (r).
|
||||||
*
|
*
|
||||||
* @param[in] mat matrix
|
* @param[in] m mat2s (left, src)
|
||||||
*
|
* @return[out] r constructed mat2s from raw pointers
|
||||||
* @return determinant
|
|
||||||
*/
|
|
||||||
CGLM_INLINE
|
|
||||||
float
|
|
||||||
glms_mat2_(det)(mat2s mat) {
|
|
||||||
return glm_mat2_det(mat.raw);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* @brief inverse mat2 and store in dest
|
|
||||||
*
|
|
||||||
* @param[in] mat matrix
|
|
||||||
* @returns matrix
|
|
||||||
*/
|
*/
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
mat2s
|
mat2s
|
||||||
glms_mat2_(inv)(mat2s mat) {
|
glms_mat2_(inv)(mat2s m) {
|
||||||
mat2s r;
|
mat2s r;
|
||||||
glm_mat2_inv(mat.raw, r.raw);
|
glm_mat2_inv(m.raw, r.raw);
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief swap two matrix columns
|
* @brief Swap two columns in mat2s (mat) and store in same matrix.
|
||||||
*
|
*
|
||||||
* @param[in] mat matrix
|
* @param[in] mat mat2s
|
||||||
* @param[in] col1 col1
|
* @param[in] col1 column 1 array index
|
||||||
* @param[in] col2 col2
|
* @param[in] col2 column 2 array index
|
||||||
* @returns matrix
|
* @return[out] mat constructed mat2s from raw pointers columns swapped
|
||||||
*/
|
*/
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
mat2s
|
mat2s
|
||||||
@@ -225,12 +208,12 @@ glms_mat2_(swap_col)(mat2s mat, int col1, int col2) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief swap two matrix rows
|
* @brief Swap two rows in mat2s (mat) and store in same matrix.
|
||||||
*
|
*
|
||||||
* @param[in] mat matrix
|
* @param[in] mat mat2s
|
||||||
* @param[in] row1 row1
|
* @param[in] row1 row 1 array index
|
||||||
* @param[in] row2 row2
|
* @param[in] row2 row 2 array index
|
||||||
* @returns matrix
|
* @return[out] mat constructed mat2s from raw pointers rows swapped
|
||||||
*/
|
*/
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
mat2s
|
mat2s
|
||||||
@@ -240,18 +223,47 @@ glms_mat2_(swap_row)(mat2s mat, int row1, int row2) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief helper for R (row vector) * M (matrix) * C (column vector)
|
* @brief Returns mat2 determinant.
|
||||||
|
*
|
||||||
|
* @param[in] m mat2 (src)
|
||||||
|
*
|
||||||
|
* @return[out] mat2s raw pointers determinant (float)
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
float
|
||||||
|
glms_mat2_(det)(mat2s m) {
|
||||||
|
return glm_mat2_det(m.raw);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Returns trace of matrix. Which is:
|
||||||
|
*
|
||||||
|
* The sum of the elements on the main diagonal from
|
||||||
|
* upper left corner to the bottom right corner.
|
||||||
|
*
|
||||||
|
* @param[in] m mat2 (m)
|
||||||
|
*
|
||||||
|
* @return[out] mat2s raw pointers trace (float)
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
float
|
||||||
|
glms_mat2_(trace)(mat2s m) {
|
||||||
|
return glm_mat2_trace(m.raw);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Helper for R (row vector) * M (matrix) * C (column vector)
|
||||||
*
|
*
|
||||||
* rmc stands for Row * Matrix * Column
|
* rmc stands for Row * Matrix * Column
|
||||||
*
|
*
|
||||||
* the result is scalar because R * M = Matrix1x2 (row vector),
|
* the result is scalar because M * C = ResC (1x2, column vector),
|
||||||
* then Matrix1x2 * Vec2 (column vector) = Matrix1x1 (Scalar)
|
* then if you take the dot_product(R (2x1), ResC (1x2)) = scalar value.
|
||||||
*
|
*
|
||||||
* @param[in] r row vector or matrix1x2
|
* @param[in] r vec2s (2x1, row vector)
|
||||||
* @param[in] m matrix2x2
|
* @param[in] m mat2s (2x2, matrix)
|
||||||
* @param[in] c column vector or matrix2x1
|
* @param[in] c vec2s (1x2, column vector)
|
||||||
*
|
*
|
||||||
* @return scalar value e.g. Matrix1x1
|
* @return[out] Scalar value (float, 1x1)
|
||||||
*/
|
*/
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
float
|
float
|
||||||
@@ -259,18 +271,4 @@ glms_mat2_(rmc)(vec2s r, mat2s m, vec2s c) {
|
|||||||
return glm_mat2_rmc(r.raw, m.raw, c.raw);
|
return glm_mat2_rmc(r.raw, m.raw, c.raw);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
|
||||||
* @brief Create mat2 matrix from pointer
|
|
||||||
*
|
|
||||||
* @param[in] src pointer to an array of floats
|
|
||||||
* @return constructed matrix from raw pointer
|
|
||||||
*/
|
|
||||||
CGLM_INLINE
|
|
||||||
mat2s
|
|
||||||
glms_mat2_(make)(const float * __restrict src) {
|
|
||||||
mat2s r;
|
|
||||||
glm_mat2_make(src, r.raw);
|
|
||||||
return r;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif /* cglms_mat2_h */
|
#endif /* cglms_mat2_h */
|
||||||
|
|||||||
@@ -29,6 +29,7 @@
|
|||||||
CGLM_INLINE mat3s glms_mat3_swap_row(mat3s mat, int row1, int row2);
|
CGLM_INLINE mat3s glms_mat3_swap_row(mat3s mat, int row1, int row2);
|
||||||
CGLM_INLINE float glms_mat3_rmc(vec3s r, mat3s m, vec3s c);
|
CGLM_INLINE float glms_mat3_rmc(vec3s r, mat3s m, vec3s c);
|
||||||
CGLM_INLINE mat3s glms_mat3_make(const float * __restrict src);
|
CGLM_INLINE mat3s glms_mat3_make(const float * __restrict src);
|
||||||
|
CGLM_INLINE mat3s glms_mat3_textrans(float sx, float sy, float rot, float tx, float ty);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef cglms_mat3s_h
|
#ifndef cglms_mat3s_h
|
||||||
@@ -300,4 +301,22 @@ glms_mat3_(make)(const float * __restrict src) {
|
|||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Create mat3 matrix from texture transform parameters
|
||||||
|
*
|
||||||
|
* @param[in] sx scale x
|
||||||
|
* @param[in] sy scale y
|
||||||
|
* @param[in] rot rotation in radians CCW/RH
|
||||||
|
* @param[in] tx translate x
|
||||||
|
* @param[in] ty translate y
|
||||||
|
* @return texture transform matrix
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
mat3s
|
||||||
|
glms_mat3_(textrans)(float sx, float sy, float rot, float tx, float ty) {
|
||||||
|
mat3s r;
|
||||||
|
glm_mat3_textrans(sx, sy, rot, tx, ty, r.raw);
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
#endif /* cglms_mat3s_h */
|
#endif /* cglms_mat3s_h */
|
||||||
|
|||||||
@@ -43,6 +43,7 @@
|
|||||||
CGLM_INLINE mat4s glms_mat4_swap_row(mat4s mat, int row1, int row2);
|
CGLM_INLINE mat4s glms_mat4_swap_row(mat4s mat, int row1, int row2);
|
||||||
CGLM_INLINE float glms_mat4_rmc(vec4s r, mat4s m, vec4s c);
|
CGLM_INLINE float glms_mat4_rmc(vec4s r, mat4s m, vec4s c);
|
||||||
CGLM_INLINE mat4s glms_mat4_make(const float * __restrict src);
|
CGLM_INLINE mat4s glms_mat4_make(const float * __restrict src);
|
||||||
|
CGLM_INLINE mat4s glms_mat4_textrans(float sx, float sy, float rot, float tx, float ty);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef cglms_mat4s_h
|
#ifndef cglms_mat4s_h
|
||||||
@@ -474,4 +475,22 @@ glms_mat4_(make)(const float * __restrict src) {
|
|||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Create mat4 matrix from texture transform parameters
|
||||||
|
*
|
||||||
|
* @param[in] sx scale x
|
||||||
|
* @param[in] sy scale y
|
||||||
|
* @param[in] rot rotation in radians CCW/RH
|
||||||
|
* @param[in] tx translate x
|
||||||
|
* @param[in] ty translate y
|
||||||
|
* @return texture transform matrix
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
mat4s
|
||||||
|
glms_mat4_(textrans)(float sx, float sy, float rot, float tx, float ty) {
|
||||||
|
mat4s r;
|
||||||
|
glm_mat4_textrans(sx, sy, rot, tx, ty, r.raw);
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
#endif /* cglms_mat4s_h */
|
#endif /* cglms_mat4s_h */
|
||||||
|
|||||||
@@ -144,6 +144,7 @@ glm_vec2_isnan(vec2 v) {
|
|||||||
#ifndef CGLM_FAST_MATH
|
#ifndef CGLM_FAST_MATH
|
||||||
return isnan(v[0]) || isnan(v[1]);
|
return isnan(v[0]) || isnan(v[1]);
|
||||||
#else
|
#else
|
||||||
|
(void)v;
|
||||||
return false;
|
return false;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@@ -160,6 +161,7 @@ glm_vec2_isinf(vec2 v) {
|
|||||||
#ifndef CGLM_FAST_MATH
|
#ifndef CGLM_FAST_MATH
|
||||||
return isinf(v[0]) || isinf(v[1]);
|
return isinf(v[0]) || isinf(v[1]);
|
||||||
#else
|
#else
|
||||||
|
(void)v;
|
||||||
return false;
|
return false;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -59,6 +59,7 @@
|
|||||||
CGLM_INLINE void glm_vec2_make(float * restrict src, vec2 dest)
|
CGLM_INLINE void glm_vec2_make(float * restrict src, vec2 dest)
|
||||||
CGLM_INLINE void glm_vec2_reflect(vec2 v, vec2 n, vec2 dest)
|
CGLM_INLINE void glm_vec2_reflect(vec2 v, vec2 n, vec2 dest)
|
||||||
CGLM_INLINE void glm_vec2_refract(vec2 v, vec2 n, float eta, vec2 dest)
|
CGLM_INLINE void glm_vec2_refract(vec2 v, vec2 n, float eta, vec2 dest)
|
||||||
|
CGLM_INLINE void glm_vec2_swap(vec2 a, vec2 b)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef cglm_vec2_h
|
#ifndef cglm_vec2_h
|
||||||
@@ -795,4 +796,16 @@ glm_vec2_refract(vec2 v, vec2 n, float eta, vec2 dest) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief swap two vectors
|
||||||
|
* @param a the first vector to swap
|
||||||
|
* @param b the second vector to swap
|
||||||
|
*/
|
||||||
|
CGLM_INLINE void glm_vec2_swap(vec2 a, vec2 b) {
|
||||||
|
vec2 tmp;
|
||||||
|
glm_vec2_copy(a, tmp);
|
||||||
|
glm_vec2_copy(b, a);
|
||||||
|
glm_vec2_copy(tmp, b);
|
||||||
|
}
|
||||||
|
|
||||||
#endif /* cglm_vec2_h */
|
#endif /* cglm_vec2_h */
|
||||||
|
|||||||
@@ -179,6 +179,7 @@ glm_vec3_isnan(vec3 v) {
|
|||||||
#ifndef CGLM_FAST_MATH
|
#ifndef CGLM_FAST_MATH
|
||||||
return isnan(v[0]) || isnan(v[1]) || isnan(v[2]);
|
return isnan(v[0]) || isnan(v[1]) || isnan(v[2]);
|
||||||
#else
|
#else
|
||||||
|
(void)v;
|
||||||
return false;
|
return false;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@@ -195,6 +196,7 @@ glm_vec3_isinf(vec3 v) {
|
|||||||
#ifndef CGLM_FAST_MATH
|
#ifndef CGLM_FAST_MATH
|
||||||
return isinf(v[0]) || isinf(v[1]) || isinf(v[2]);
|
return isinf(v[0]) || isinf(v[1]) || isinf(v[2]);
|
||||||
#else
|
#else
|
||||||
|
(void)v;
|
||||||
return false;
|
return false;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -82,6 +82,7 @@
|
|||||||
CGLM_INLINE void glm_vec3_faceforward(vec3 n, vec3 v, vec3 nref, vec3 dest);
|
CGLM_INLINE void glm_vec3_faceforward(vec3 n, vec3 v, vec3 nref, vec3 dest);
|
||||||
CGLM_INLINE void glm_vec3_reflect(vec3 v, vec3 n, vec3 dest);
|
CGLM_INLINE void glm_vec3_reflect(vec3 v, vec3 n, vec3 dest);
|
||||||
CGLM_INLINE void glm_vec3_refract(vec3 v, vec3 n, float eta, vec3 dest);
|
CGLM_INLINE void glm_vec3_refract(vec3 v, vec3 n, float eta, vec3 dest);
|
||||||
|
CGLM_INLINE void glm_vec3_swap(vec3 a, vec3 b)
|
||||||
|
|
||||||
Convenient:
|
Convenient:
|
||||||
CGLM_INLINE void glm_cross(vec3 a, vec3 b, vec3 d);
|
CGLM_INLINE void glm_cross(vec3 a, vec3 b, vec3 d);
|
||||||
@@ -1261,4 +1262,16 @@ glm_vec3_refract(vec3 v, vec3 n, float eta, vec3 dest) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief swap two vectors
|
||||||
|
* @param a the first vector to swap
|
||||||
|
* @param b the second vector to swap
|
||||||
|
*/
|
||||||
|
CGLM_INLINE void glm_vec3_swap(vec3 a, vec3 b) {
|
||||||
|
vec3 tmp;
|
||||||
|
glm_vec3_copy(a, tmp);
|
||||||
|
glm_vec3_copy(b, a);
|
||||||
|
glm_vec3_copy(tmp, b);
|
||||||
|
}
|
||||||
|
|
||||||
#endif /* cglm_vec3_h */
|
#endif /* cglm_vec3_h */
|
||||||
|
|||||||
@@ -193,6 +193,7 @@ glm_vec4_isnan(vec4 v) {
|
|||||||
#ifndef CGLM_FAST_MATH
|
#ifndef CGLM_FAST_MATH
|
||||||
return isnan(v[0]) || isnan(v[1]) || isnan(v[2]) || isnan(v[3]);
|
return isnan(v[0]) || isnan(v[1]) || isnan(v[2]) || isnan(v[3]);
|
||||||
#else
|
#else
|
||||||
|
(void)v;
|
||||||
return false;
|
return false;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@@ -209,6 +210,7 @@ glm_vec4_isinf(vec4 v) {
|
|||||||
#ifndef CGLM_FAST_MATH
|
#ifndef CGLM_FAST_MATH
|
||||||
return isinf(v[0]) || isinf(v[1]) || isinf(v[2]) || isinf(v[3]);
|
return isinf(v[0]) || isinf(v[1]) || isinf(v[2]) || isinf(v[3]);
|
||||||
#else
|
#else
|
||||||
|
(void)v;
|
||||||
return false;
|
return false;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -66,6 +66,7 @@
|
|||||||
CGLM_INLINE void glm_vec4_make(float * restrict src, vec4 dest);
|
CGLM_INLINE void glm_vec4_make(float * restrict src, vec4 dest);
|
||||||
CGLM_INLINE void glm_vec4_reflect(vec4 v, vec4 n, vec4 dest);
|
CGLM_INLINE void glm_vec4_reflect(vec4 v, vec4 n, vec4 dest);
|
||||||
CGLM_INLINE void glm_vec4_refract(vec4 v, vec4 n, float eta, vec4 dest);
|
CGLM_INLINE void glm_vec4_refract(vec4 v, vec4 n, float eta, vec4 dest);
|
||||||
|
CGLM_INLINE void glm_vec4_swap(vec4 a, vec4 b)
|
||||||
|
|
||||||
DEPRECATED:
|
DEPRECATED:
|
||||||
glm_vec4_dup
|
glm_vec4_dup
|
||||||
@@ -1345,4 +1346,16 @@ glm_vec4_refract(vec4 v, vec4 n, float eta, vec4 dest) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief swap two vectors
|
||||||
|
* @param a the first vector to swap
|
||||||
|
* @param b the second vector to swap
|
||||||
|
*/
|
||||||
|
CGLM_INLINE void glm_vec4_swap(vec4 a, vec4 b) {
|
||||||
|
vec4 tmp;
|
||||||
|
glm_vec4_copy(a, tmp);
|
||||||
|
glm_vec4_copy(b, a);
|
||||||
|
glm_vec4_copy(tmp, b);
|
||||||
|
}
|
||||||
|
|
||||||
#endif /* cglm_vec4_h */
|
#endif /* cglm_vec4_h */
|
||||||
|
|||||||
@@ -34,6 +34,12 @@ glmc_perspective_lh_no(float fovy,
|
|||||||
dest);
|
dest);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_perspective_resize_lh_no(float aspect, mat4 proj) {
|
||||||
|
glm_perspective_resize_lh_no(aspect, proj);
|
||||||
|
}
|
||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
void
|
void
|
||||||
glmc_persp_move_far_lh_no(mat4 proj, float deltaFar) {
|
glmc_persp_move_far_lh_no(mat4 proj, float deltaFar) {
|
||||||
|
|||||||
@@ -34,6 +34,12 @@ glmc_perspective_lh_zo(float fovy,
|
|||||||
dest);
|
dest);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_perspective_resize_lh_zo(float aspect, mat4 proj) {
|
||||||
|
glm_perspective_resize_lh_zo(aspect, proj);
|
||||||
|
}
|
||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
void
|
void
|
||||||
glmc_persp_move_far_lh_zo(mat4 proj, float deltaFar) {
|
glmc_persp_move_far_lh_zo(mat4 proj, float deltaFar) {
|
||||||
|
|||||||
@@ -34,6 +34,12 @@ glmc_perspective_rh_no(float fovy,
|
|||||||
dest);
|
dest);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_perspective_resize_rh_no(float aspect, mat4 proj) {
|
||||||
|
glm_perspective_resize_rh_no(aspect, proj);
|
||||||
|
}
|
||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
void
|
void
|
||||||
glmc_persp_move_far_rh_no(mat4 proj, float deltaFar) {
|
glmc_persp_move_far_rh_no(mat4 proj, float deltaFar) {
|
||||||
|
|||||||
@@ -34,6 +34,12 @@ glmc_perspective_rh_zo(float fovy,
|
|||||||
dest);
|
dest);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_perspective_resize_rh_zo(float aspect, mat4 proj) {
|
||||||
|
glm_perspective_resize_rh_zo(aspect, proj);
|
||||||
|
}
|
||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
void
|
void
|
||||||
glmc_persp_move_far_rh_zo(mat4 proj, float deltaFar) {
|
glmc_persp_move_far_rh_zo(mat4 proj, float deltaFar) {
|
||||||
|
|||||||
62
src/mat2.c
62
src/mat2.c
@@ -8,6 +8,12 @@
|
|||||||
#include "../include/cglm/cglm.h"
|
#include "../include/cglm/cglm.h"
|
||||||
#include "../include/cglm/call.h"
|
#include "../include/cglm/call.h"
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_mat2_make(const float * __restrict src, mat2 dest) {
|
||||||
|
glm_mat2_make(src, dest);
|
||||||
|
}
|
||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
void
|
void
|
||||||
glmc_mat2_copy(mat2 mat, mat2 dest) {
|
glmc_mat2_copy(mat2 mat, mat2 dest) {
|
||||||
@@ -16,20 +22,20 @@ glmc_mat2_copy(mat2 mat, mat2 dest) {
|
|||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
void
|
void
|
||||||
glmc_mat2_identity(mat2 mat) {
|
glmc_mat2_identity(mat2 m) {
|
||||||
glm_mat2_identity(mat);
|
glm_mat2_identity(m);
|
||||||
}
|
}
|
||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
void
|
void
|
||||||
glmc_mat2_identity_array(mat2 * __restrict mat, size_t count) {
|
glmc_mat2_identity_array(mat2 * __restrict mats, size_t count) {
|
||||||
glm_mat2_identity_array(mat, count);
|
glm_mat2_identity_array(mats, count);
|
||||||
}
|
}
|
||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
void
|
void
|
||||||
glmc_mat2_zero(mat2 mat) {
|
glmc_mat2_zero(mat2 m) {
|
||||||
glm_mat2_zero(mat);
|
glm_mat2_zero(m);
|
||||||
}
|
}
|
||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
@@ -40,8 +46,14 @@ glmc_mat2_mul(mat2 m1, mat2 m2, mat2 dest) {
|
|||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
void
|
void
|
||||||
glmc_mat2_transpose_to(mat2 m, mat2 dest) {
|
glmc_mat2_mulv(mat2 m, vec2 v, vec2 dest) {
|
||||||
glm_mat2_transpose_to(m, dest);
|
glm_mat2_mulv(m, v, dest);
|
||||||
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_mat2_transpose_to(mat2 mat, mat2 dest) {
|
||||||
|
glm_mat2_transpose_to(mat, dest);
|
||||||
}
|
}
|
||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
@@ -50,30 +62,12 @@ glmc_mat2_transpose(mat2 m) {
|
|||||||
glm_mat2_transpose(m);
|
glm_mat2_transpose(m);
|
||||||
}
|
}
|
||||||
|
|
||||||
CGLM_EXPORT
|
|
||||||
void
|
|
||||||
glmc_mat2_mulv(mat2 m, vec2 v, vec2 dest) {
|
|
||||||
glm_mat2_mulv(m, v, dest);
|
|
||||||
}
|
|
||||||
|
|
||||||
CGLM_EXPORT
|
|
||||||
float
|
|
||||||
glmc_mat2_trace(mat2 m) {
|
|
||||||
return glm_mat2_trace(m);
|
|
||||||
}
|
|
||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
void
|
void
|
||||||
glmc_mat2_scale(mat2 m, float s) {
|
glmc_mat2_scale(mat2 m, float s) {
|
||||||
glm_mat2_scale(m, s);
|
glm_mat2_scale(m, s);
|
||||||
}
|
}
|
||||||
|
|
||||||
CGLM_EXPORT
|
|
||||||
float
|
|
||||||
glmc_mat2_det(mat2 mat) {
|
|
||||||
return glm_mat2_det(mat);
|
|
||||||
}
|
|
||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
void
|
void
|
||||||
glmc_mat2_inv(mat2 mat, mat2 dest) {
|
glmc_mat2_inv(mat2 mat, mat2 dest) {
|
||||||
@@ -94,12 +88,18 @@ glmc_mat2_swap_row(mat2 mat, int row1, int row2) {
|
|||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
float
|
float
|
||||||
glmc_mat2_rmc(vec2 r, mat2 m, vec2 c) {
|
glmc_mat2_det(mat2 m) {
|
||||||
return glm_mat2_rmc(r, m, c);
|
return glm_mat2_det(m);
|
||||||
}
|
}
|
||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
void
|
float
|
||||||
glmc_mat2_make(const float * __restrict src, mat2 dest) {
|
glmc_mat2_trace(mat2 m) {
|
||||||
glm_mat2_make(src, dest);
|
return glm_mat2_trace(m);
|
||||||
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
float
|
||||||
|
glmc_mat2_rmc(vec2 r, mat2 m, vec2 c) {
|
||||||
|
return glm_mat2_rmc(r, m, c);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -109,3 +109,9 @@ void
|
|||||||
glmc_mat3_make(const float * __restrict src, mat3 dest) {
|
glmc_mat3_make(const float * __restrict src, mat3 dest) {
|
||||||
glm_mat3_make(src, dest);
|
glm_mat3_make(src, dest);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_mat3_textrans(float sx, float sy, float rot, float tx, float ty, mat3 dest) {
|
||||||
|
glm_mat3_textrans(sx, sy, rot, tx, ty, dest);
|
||||||
|
}
|
||||||
|
|||||||
@@ -169,3 +169,9 @@ void
|
|||||||
glmc_mat4_make(const float * __restrict src, mat4 dest) {
|
glmc_mat4_make(const float * __restrict src, mat4 dest) {
|
||||||
glm_mat4_make(src, dest);
|
glm_mat4_make(src, dest);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_mat4_textrans(float sx, float sy, float rot, float tx, float ty, mat4 dest) {
|
||||||
|
glm_mat4_textrans(sx, sy, rot, tx, ty, dest);
|
||||||
|
}
|
||||||
|
|||||||
@@ -356,3 +356,9 @@ bool
|
|||||||
glmc_vec2_refract(vec2 v, vec2 n, float eta, vec2 dest) {
|
glmc_vec2_refract(vec2 v, vec2 n, float eta, vec2 dest) {
|
||||||
return glm_vec2_refract(v, n, eta, dest);
|
return glm_vec2_refract(v, n, eta, dest);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_vec2_swap(vec2 a, vec2 b) {
|
||||||
|
glm_vec2_swap(a, b);
|
||||||
|
}
|
||||||
|
|||||||
@@ -501,3 +501,9 @@ bool
|
|||||||
glmc_vec3_refract(vec3 v, vec3 n, float eta, vec3 dest) {
|
glmc_vec3_refract(vec3 v, vec3 n, float eta, vec3 dest) {
|
||||||
return glm_vec3_refract(v, n, eta, dest);
|
return glm_vec3_refract(v, n, eta, dest);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_vec3_swap(vec3 a, vec3 b) {
|
||||||
|
glm_vec3_swap(a, b);
|
||||||
|
}
|
||||||
|
|||||||
@@ -459,3 +459,9 @@ bool
|
|||||||
glmc_vec4_refract(vec4 v, vec4 n, float eta, vec4 dest) {
|
glmc_vec4_refract(vec4 v, vec4 n, float eta, vec4 dest) {
|
||||||
return glm_vec4_refract(v, n, eta, dest);
|
return glm_vec4_refract(v, n, eta, dest);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_vec4_swap(vec4 a, vec4 b) {
|
||||||
|
glm_vec4_swap(a, b);
|
||||||
|
}
|
||||||
|
|||||||
@@ -176,7 +176,7 @@ test_assert_mat4_eq(mat4 m1, mat4 m2) {
|
|||||||
|
|
||||||
for (i = 0; i < 4; i++) {
|
for (i = 0; i < 4; i++) {
|
||||||
for (j = 0; j < 4; j++) {
|
for (j = 0; j < 4; j++) {
|
||||||
ASSERT(fabsf(m1[i][j] - m2[i][j]) <= 0.0000009)
|
ASSERT(fabsf(m1[i][j] - m2[i][j]) <= 0.0000009f)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -189,7 +189,7 @@ test_assert_mat4_eqt(mat4 m1, mat4 m2) {
|
|||||||
|
|
||||||
for (i = 0; i < 4; i++) {
|
for (i = 0; i < 4; i++) {
|
||||||
for (j = 0; j < 4; j++) {
|
for (j = 0; j < 4; j++) {
|
||||||
ASSERT(fabsf(m1[j][i] - m2[i][j]) <= 0.0000009)
|
ASSERT(fabsf(m1[j][i] - m2[i][j]) <= 0.0000009f)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -215,7 +215,7 @@ test_assert_mat2_eqt(mat2 m1, mat2 m2) {
|
|||||||
|
|
||||||
for (i = 0; i < 2; i++) {
|
for (i = 0; i < 2; i++) {
|
||||||
for (j = 0; j < 2; j++) {
|
for (j = 0; j < 2; j++) {
|
||||||
ASSERT(fabsf(m1[j][i] - m2[i][j]) <= 0.0000009);
|
ASSERT(fabsf(m1[j][i] - m2[i][j]) <= 0.0000009f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -228,7 +228,7 @@ test_assert_mat2_eq(mat2 m1, mat2 m2) {
|
|||||||
|
|
||||||
for (i = 0; i < 2; i++) {
|
for (i = 0; i < 2; i++) {
|
||||||
for (j = 0; j < 2; j++) {
|
for (j = 0; j < 2; j++) {
|
||||||
ASSERT(fabsf(m1[i][j] - m2[i][j]) <= 0.0000009);
|
ASSERT(fabsf(m1[i][j] - m2[i][j]) <= 0.0000009f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -284,7 +284,7 @@ test_assert_mat2x3_eq(mat2x3 m1, mat2x3 m2) {
|
|||||||
|
|
||||||
for (i = 0; i < 2; i++) {
|
for (i = 0; i < 2; i++) {
|
||||||
for (j = 0; j < 3; j++) {
|
for (j = 0; j < 3; j++) {
|
||||||
ASSERT(fabsf(m1[i][j] - m2[i][j]) <= 0.0000009)
|
ASSERT(fabsf(m1[i][j] - m2[i][j]) <= 0.0000009f)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -310,7 +310,7 @@ test_assert_mat2x4_eq(mat2x4 m1, mat2x4 m2) {
|
|||||||
|
|
||||||
for (i = 0; i < 2; i++) {
|
for (i = 0; i < 2; i++) {
|
||||||
for (j = 0; j < 4; j++) {
|
for (j = 0; j < 4; j++) {
|
||||||
ASSERT(fabsf(m1[i][j] - m2[i][j]) <= 0.0000009)
|
ASSERT(fabsf(m1[i][j] - m2[i][j]) <= 0.0000009f)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -323,7 +323,7 @@ test_assert_mat3_eq(mat3 m1, mat3 m2) {
|
|||||||
|
|
||||||
for (i = 0; i < 3; i++) {
|
for (i = 0; i < 3; i++) {
|
||||||
for (j = 0; j < 3; j++) {
|
for (j = 0; j < 3; j++) {
|
||||||
ASSERT(fabsf(m1[i][j] - m2[i][j]) <= 0.0000009);
|
ASSERT(fabsf(m1[i][j] - m2[i][j]) <= 0.0000009f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -336,7 +336,7 @@ test_assert_mat3_eqt(mat3 m1, mat3 m2) {
|
|||||||
|
|
||||||
for (i = 0; i < 3; i++) {
|
for (i = 0; i < 3; i++) {
|
||||||
for (j = 0; j < 3; j++) {
|
for (j = 0; j < 3; j++) {
|
||||||
ASSERT(fabsf(m1[j][i] - m2[i][j]) <= 0.0000009);
|
ASSERT(fabsf(m1[j][i] - m2[i][j]) <= 0.0000009f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -392,7 +392,7 @@ test_assert_mat3x2_eq(mat3x2 m1, mat3x2 m2) {
|
|||||||
|
|
||||||
for (i = 0; i < 3; i++) {
|
for (i = 0; i < 3; i++) {
|
||||||
for (j = 0; j < 2; j++) {
|
for (j = 0; j < 2; j++) {
|
||||||
ASSERT(fabsf(m1[i][j] - m2[i][j]) <= 0.0000009)
|
ASSERT(fabsf(m1[i][j] - m2[i][j]) <= 0.0000009f)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -418,7 +418,7 @@ test_assert_mat3x4_eq(mat3x4 m1, mat3x4 m2) {
|
|||||||
|
|
||||||
for (i = 0; i < 3; i++) {
|
for (i = 0; i < 3; i++) {
|
||||||
for (j = 0; j < 4; j++) {
|
for (j = 0; j < 4; j++) {
|
||||||
ASSERT(fabsf(m1[i][j] - m2[i][j]) <= 0.0000009)
|
ASSERT(fabsf(m1[i][j] - m2[i][j]) <= 0.0000009f)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -474,7 +474,7 @@ test_assert_mat4x2_eq(mat4x2 m1, mat4x2 m2) {
|
|||||||
|
|
||||||
for (i = 0; i < 4; i++) {
|
for (i = 0; i < 4; i++) {
|
||||||
for (j = 0; j < 2; j++) {
|
for (j = 0; j < 2; j++) {
|
||||||
ASSERT(fabsf(m1[i][j] - m2[i][j]) <= 0.0000009)
|
ASSERT(fabsf(m1[i][j] - m2[i][j]) <= 0.0000009f)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -500,7 +500,7 @@ test_assert_mat4x3_eq(mat4x3 m1, mat4x3 m2) {
|
|||||||
|
|
||||||
for (i = 0; i < 4; i++) {
|
for (i = 0; i < 4; i++) {
|
||||||
for (j = 0; j < 3; j++) {
|
for (j = 0; j < 3; j++) {
|
||||||
ASSERT(fabsf(m1[i][j] - m2[i][j]) <= 0.0000009)
|
ASSERT(fabsf(m1[i][j] - m2[i][j]) <= 0.0000009f)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -509,24 +509,24 @@ test_assert_mat4x3_eq(mat4x3 m1, mat4x3 m2) {
|
|||||||
|
|
||||||
test_status_t
|
test_status_t
|
||||||
test_assert_eqf(float a, float b) {
|
test_assert_eqf(float a, float b) {
|
||||||
ASSERT(fabsf(a - b) <= 0.000009); /* rounding errors */
|
ASSERT(fabsf(a - b) <= 0.000009f); /* rounding errors */
|
||||||
|
|
||||||
TEST_SUCCESS
|
TEST_SUCCESS
|
||||||
}
|
}
|
||||||
|
|
||||||
test_status_t
|
test_status_t
|
||||||
test_assert_vec2_eq(vec2 v1, vec2 v2) {
|
test_assert_vec2_eq(vec2 v1, vec2 v2) {
|
||||||
ASSERT(fabsf(v1[0] - v2[0]) <= 0.000009); /* rounding errors */
|
ASSERT(fabsf(v1[0] - v2[0]) <= 0.000009f); /* rounding errors */
|
||||||
ASSERT(fabsf(v1[1] - v2[1]) <= 0.000009);
|
ASSERT(fabsf(v1[1] - v2[1]) <= 0.000009f);
|
||||||
|
|
||||||
TEST_SUCCESS
|
TEST_SUCCESS
|
||||||
}
|
}
|
||||||
|
|
||||||
test_status_t
|
test_status_t
|
||||||
test_assert_vec3_eq(vec3 v1, vec3 v2) {
|
test_assert_vec3_eq(vec3 v1, vec3 v2) {
|
||||||
ASSERT(fabsf(v1[0] - v2[0]) <= 0.000009); /* rounding errors */
|
ASSERT(fabsf(v1[0] - v2[0]) <= 0.000009f); /* rounding errors */
|
||||||
ASSERT(fabsf(v1[1] - v2[1]) <= 0.000009);
|
ASSERT(fabsf(v1[1] - v2[1]) <= 0.000009f);
|
||||||
ASSERT(fabsf(v1[2] - v2[2]) <= 0.000009);
|
ASSERT(fabsf(v1[2] - v2[2]) <= 0.000009f);
|
||||||
|
|
||||||
TEST_SUCCESS
|
TEST_SUCCESS
|
||||||
}
|
}
|
||||||
@@ -540,10 +540,10 @@ test_assert_vec3s_eq(vec3s v1, vec3s v2) {
|
|||||||
|
|
||||||
test_status_t
|
test_status_t
|
||||||
test_assert_vec4_eq(vec4 v1, vec4 v2) {
|
test_assert_vec4_eq(vec4 v1, vec4 v2) {
|
||||||
ASSERT(fabsf(v1[0] - v2[0]) <= 0.000009); /* rounding errors */
|
ASSERT(fabsf(v1[0] - v2[0]) <= 0.000009f); /* rounding errors */
|
||||||
ASSERT(fabsf(v1[1] - v2[1]) <= 0.000009);
|
ASSERT(fabsf(v1[1] - v2[1]) <= 0.000009f);
|
||||||
ASSERT(fabsf(v1[2] - v2[2]) <= 0.000009);
|
ASSERT(fabsf(v1[2] - v2[2]) <= 0.000009f);
|
||||||
ASSERT(fabsf(v1[3] - v2[3]) <= 0.000009);
|
ASSERT(fabsf(v1[3] - v2[3]) <= 0.000009f);
|
||||||
|
|
||||||
TEST_SUCCESS
|
TEST_SUCCESS
|
||||||
}
|
}
|
||||||
@@ -557,20 +557,20 @@ test_assert_vec4s_eq(vec4s v1, vec4s v2) {
|
|||||||
|
|
||||||
test_status_t
|
test_status_t
|
||||||
test_assert_quat_eq_abs(versor v1, versor v2) {
|
test_assert_quat_eq_abs(versor v1, versor v2) {
|
||||||
ASSERT(fabsf(fabsf(v1[0]) - fabsf(v2[0])) <= 0.0009); /* rounding errors */
|
ASSERT(fabsf(fabsf(v1[0]) - fabsf(v2[0])) <= 0.0009f); /* rounding errors */
|
||||||
ASSERT(fabsf(fabsf(v1[1]) - fabsf(v2[1])) <= 0.0009);
|
ASSERT(fabsf(fabsf(v1[1]) - fabsf(v2[1])) <= 0.0009f);
|
||||||
ASSERT(fabsf(fabsf(v1[2]) - fabsf(v2[2])) <= 0.0009);
|
ASSERT(fabsf(fabsf(v1[2]) - fabsf(v2[2])) <= 0.0009f);
|
||||||
ASSERT(fabsf(fabsf(v1[3]) - fabsf(v2[3])) <= 0.0009);
|
ASSERT(fabsf(fabsf(v1[3]) - fabsf(v2[3])) <= 0.0009f);
|
||||||
|
|
||||||
TEST_SUCCESS
|
TEST_SUCCESS
|
||||||
}
|
}
|
||||||
|
|
||||||
test_status_t
|
test_status_t
|
||||||
test_assert_quat_eq(versor v1, versor v2) {
|
test_assert_quat_eq(versor v1, versor v2) {
|
||||||
ASSERT(fabsf(v1[0] - v2[0]) <= 0.000009); /* rounding errors */
|
ASSERT(fabsf(v1[0] - v2[0]) <= 0.000009f); /* rounding errors */
|
||||||
ASSERT(fabsf(v1[1] - v2[1]) <= 0.000009);
|
ASSERT(fabsf(v1[1] - v2[1]) <= 0.000009f);
|
||||||
ASSERT(fabsf(v1[2] - v2[2]) <= 0.000009);
|
ASSERT(fabsf(v1[2] - v2[2]) <= 0.000009f);
|
||||||
ASSERT(fabsf(v1[3] - v2[3]) <= 0.000009);
|
ASSERT(fabsf(v1[3] - v2[3]) <= 0.000009f);
|
||||||
|
|
||||||
TEST_SUCCESS
|
TEST_SUCCESS
|
||||||
}
|
}
|
||||||
@@ -579,10 +579,10 @@ test_status_t
|
|||||||
test_assert_quat_eq_identity(versor q) {
|
test_assert_quat_eq_identity(versor q) {
|
||||||
versor p = GLM_QUAT_IDENTITY_INIT;
|
versor p = GLM_QUAT_IDENTITY_INIT;
|
||||||
|
|
||||||
ASSERT(fabsf(q[0] - p[0]) <= 0.000009); /* rounding errors */
|
ASSERT(fabsf(q[0] - p[0]) <= 0.000009f); /* rounding errors */
|
||||||
ASSERT(fabsf(q[1] - p[1]) <= 0.000009);
|
ASSERT(fabsf(q[1] - p[1]) <= 0.000009f);
|
||||||
ASSERT(fabsf(q[2] - p[2]) <= 0.000009);
|
ASSERT(fabsf(q[2] - p[2]) <= 0.000009f);
|
||||||
ASSERT(fabsf(q[3] - p[3]) <= 0.000009);
|
ASSERT(fabsf(q[3] - p[3]) <= 0.000009f);
|
||||||
|
|
||||||
TEST_SUCCESS
|
TEST_SUCCESS
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -327,4 +327,26 @@ TEST_IMPL(GLM_PREFIX, mat3_make) {
|
|||||||
TEST_SUCCESS
|
TEST_SUCCESS
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_IMPL(GLM_PREFIX, mat3_textrans) {
|
||||||
|
mat3 m, expected;
|
||||||
|
float sx = 2.0f, sy = 3.0f, rot = GLM_PI_4f;
|
||||||
|
float tx = 10.0f, ty = 20.0f;
|
||||||
|
|
||||||
|
GLM(mat3_textrans)(sx, sy, rot, tx, ty, m);
|
||||||
|
|
||||||
|
ASSERT(test_eq(m[0][0], cosf(rot) * sx))
|
||||||
|
ASSERT(test_eq(m[0][1],-sinf(rot) * sy))
|
||||||
|
ASSERT(test_eq(m[1][0], sinf(rot) * sx))
|
||||||
|
ASSERT(test_eq(m[1][1], cosf(rot) * sy))
|
||||||
|
ASSERT(test_eq(m[2][0], tx))
|
||||||
|
ASSERT(test_eq(m[2][1], ty))
|
||||||
|
|
||||||
|
GLM(mat3_textrans)(1.0f, 1.0f, 0.0f, 0.0f, 0.0f, m);
|
||||||
|
GLM(mat3_identity)(expected);
|
||||||
|
|
||||||
|
ASSERTIFY(test_assert_mat3_eq(m, expected))
|
||||||
|
|
||||||
|
TEST_SUCCESS
|
||||||
|
}
|
||||||
|
|
||||||
#undef A_MATRIX
|
#undef A_MATRIX
|
||||||
|
|||||||
@@ -504,5 +504,27 @@ TEST_IMPL(GLM_PREFIX, mat4_make) {
|
|||||||
TEST_SUCCESS
|
TEST_SUCCESS
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_IMPL(GLM_PREFIX, mat4_textrans) {
|
||||||
|
mat4 m, expected;
|
||||||
|
float sx = 2.0f, sy = 3.0f, rot = GLM_PI_4f;
|
||||||
|
float tx = 10.0f, ty = 20.0f;
|
||||||
|
|
||||||
|
GLM(mat4_textrans)(sx, sy, rot, tx, ty, m);
|
||||||
|
|
||||||
|
ASSERT(test_eq(m[0][0], cosf(rot) * sx))
|
||||||
|
ASSERT(test_eq(m[0][1],-sinf(rot) * sy))
|
||||||
|
ASSERT(test_eq(m[1][0], sinf(rot) * sx))
|
||||||
|
ASSERT(test_eq(m[1][1], cosf(rot) * sy))
|
||||||
|
ASSERT(test_eq(m[3][0], tx))
|
||||||
|
ASSERT(test_eq(m[3][1], ty))
|
||||||
|
|
||||||
|
GLM(mat4_textrans)(1.0f, 1.0f, 0.0f, 0.0f, 0.0f, m);
|
||||||
|
GLM(mat4_identity)(expected);
|
||||||
|
|
||||||
|
ASSERTIFY(test_assert_mat4_eq(m, expected))
|
||||||
|
|
||||||
|
TEST_SUCCESS
|
||||||
|
}
|
||||||
|
|
||||||
#undef A_MATRIX
|
#undef A_MATRIX
|
||||||
#undef A_MATRIX3
|
#undef A_MATRIX3
|
||||||
|
|||||||
@@ -27,13 +27,13 @@ TEST_IMPL(GLM_PREFIX, unprojecti) {
|
|||||||
/* unprojected of projected vector must be same as original one */
|
/* unprojected of projected vector must be same as original one */
|
||||||
/* we used 0.01 because of projection floating point errors */
|
/* we used 0.01 because of projection floating point errors */
|
||||||
#ifndef CGLM_FAST_MATH
|
#ifndef CGLM_FAST_MATH
|
||||||
ASSERT(fabsf(pos[0] - unprojected[0]) < 0.01)
|
ASSERT(fabsf(pos[0] - unprojected[0]) < 0.01f)
|
||||||
ASSERT(fabsf(pos[1] - unprojected[1]) < 0.01)
|
ASSERT(fabsf(pos[1] - unprojected[1]) < 0.01f)
|
||||||
ASSERT(fabsf(pos[2] - unprojected[2]) < 0.01)
|
ASSERT(fabsf(pos[2] - unprojected[2]) < 0.01f)
|
||||||
#else
|
#else
|
||||||
ASSERT(fabsf(pos[0] - unprojected[0]) < 0.1)
|
ASSERT(fabsf(pos[0] - unprojected[0]) < 0.1f)
|
||||||
ASSERT(fabsf(pos[1] - unprojected[1]) < 0.1)
|
ASSERT(fabsf(pos[1] - unprojected[1]) < 0.1f)
|
||||||
ASSERT(fabsf(pos[2] - unprojected[2]) < 0.1)
|
ASSERT(fabsf(pos[2] - unprojected[2]) < 0.1f)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
TEST_SUCCESS
|
TEST_SUCCESS
|
||||||
@@ -58,13 +58,13 @@ TEST_IMPL(GLM_PREFIX, unproject) {
|
|||||||
/* we used 0.01 because of projection floating point errors */
|
/* we used 0.01 because of projection floating point errors */
|
||||||
|
|
||||||
#ifndef CGLM_FAST_MATH
|
#ifndef CGLM_FAST_MATH
|
||||||
ASSERT(fabsf(pos[0] - unprojected[0]) < 0.01)
|
ASSERT(fabsf(pos[0] - unprojected[0]) < 0.01f)
|
||||||
ASSERT(fabsf(pos[1] - unprojected[1]) < 0.01)
|
ASSERT(fabsf(pos[1] - unprojected[1]) < 0.01f)
|
||||||
ASSERT(fabsf(pos[2] - unprojected[2]) < 0.01)
|
ASSERT(fabsf(pos[2] - unprojected[2]) < 0.01f)
|
||||||
#else
|
#else
|
||||||
ASSERT(fabsf(pos[0] - unprojected[0]) < 0.1)
|
ASSERT(fabsf(pos[0] - unprojected[0]) < 0.1f)
|
||||||
ASSERT(fabsf(pos[1] - unprojected[1]) < 0.1)
|
ASSERT(fabsf(pos[1] - unprojected[1]) < 0.1f)
|
||||||
ASSERT(fabsf(pos[2] - unprojected[2]) < 0.1)
|
ASSERT(fabsf(pos[2] - unprojected[2]) < 0.1f)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
TEST_SUCCESS
|
TEST_SUCCESS
|
||||||
@@ -89,13 +89,13 @@ TEST_IMPL(GLM_PREFIX, project) {
|
|||||||
/* we used 0.01 because of projection floating point errors */
|
/* we used 0.01 because of projection floating point errors */
|
||||||
|
|
||||||
#ifndef CGLM_FAST_MATH
|
#ifndef CGLM_FAST_MATH
|
||||||
ASSERT(fabsf(pos[0] - unprojected[0]) < 0.01)
|
ASSERT(fabsf(pos[0] - unprojected[0]) < 0.01f)
|
||||||
ASSERT(fabsf(pos[1] - unprojected[1]) < 0.01)
|
ASSERT(fabsf(pos[1] - unprojected[1]) < 0.01f)
|
||||||
ASSERT(fabsf(pos[2] - unprojected[2]) < 0.01)
|
ASSERT(fabsf(pos[2] - unprojected[2]) < 0.01f)
|
||||||
#else
|
#else
|
||||||
ASSERT(fabsf(pos[0] - unprojected[0]) < 0.1)
|
ASSERT(fabsf(pos[0] - unprojected[0]) < 0.1f)
|
||||||
ASSERT(fabsf(pos[1] - unprojected[1]) < 0.1)
|
ASSERT(fabsf(pos[1] - unprojected[1]) < 0.1f)
|
||||||
ASSERT(fabsf(pos[2] - unprojected[2]) < 0.1)
|
ASSERT(fabsf(pos[2] - unprojected[2]) < 0.1f)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* test with no projection */
|
/* test with no projection */
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ TEST_IMPL(GLM_PREFIX, ray_triangle) {
|
|||||||
|
|
||||||
hit = GLM(ray_triangle)(origin, direction, v0, v1, v2, &d);
|
hit = GLM(ray_triangle)(origin, direction, v0, v1, v2, &d);
|
||||||
ASSERT(hit);
|
ASSERT(hit);
|
||||||
ASSERT(fabsf(d - 5.0f) <= 0.0000009);
|
ASSERT(fabsf(d - 5.0f) <= 0.0000009f);
|
||||||
|
|
||||||
/* Check whether a simple miss works */
|
/* Check whether a simple miss works */
|
||||||
hit = GLM(ray_triangle)(origin, opposite, v0, v1, v2, &d);
|
hit = GLM(ray_triangle)(origin, opposite, v0, v1, v2, &d);
|
||||||
@@ -65,9 +65,9 @@ TEST_IMPL(GLM_PREFIX, ray_at) {
|
|||||||
glm_vec3_normalize(direction);
|
glm_vec3_normalize(direction);
|
||||||
|
|
||||||
GLM(ray_at)(origin, direction, distance, result);
|
GLM(ray_at)(origin, direction, distance, result);
|
||||||
ASSERT(fabsf(result[0] - 1.0f) <= 0.0000009); /* Expecting to be 1 unit along the x-axis */
|
ASSERT(fabsf(result[0] - 1.0f) <= 0.0000009f); /* Expecting to be 1 unit along the x-axis */
|
||||||
ASSERT(fabsf(result[1] - 1.0f) <= 0.0000009); /* Expecting to be 1 unit along the y-axis */
|
ASSERT(fabsf(result[1] - 1.0f) <= 0.0000009f); /* Expecting to be 1 unit along the y-axis */
|
||||||
ASSERT(fabsf(result[2] - 1.0f) <= 0.0000009); /* Expecting to be 1 unit along the z-axis */
|
ASSERT(fabsf(result[2] - 1.0f) <= 0.0000009f); /* Expecting to be 1 unit along the z-axis */
|
||||||
|
|
||||||
TEST_SUCCESS
|
TEST_SUCCESS
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -136,6 +136,7 @@ TEST_DECLARE(glm_mat4_swap_col)
|
|||||||
TEST_DECLARE(glm_mat4_swap_row)
|
TEST_DECLARE(glm_mat4_swap_row)
|
||||||
TEST_DECLARE(glm_mat4_rmc)
|
TEST_DECLARE(glm_mat4_rmc)
|
||||||
TEST_DECLARE(glm_mat4_make)
|
TEST_DECLARE(glm_mat4_make)
|
||||||
|
TEST_DECLARE(glm_mat4_textrans)
|
||||||
|
|
||||||
TEST_DECLARE(glmc_mat4_ucopy)
|
TEST_DECLARE(glmc_mat4_ucopy)
|
||||||
TEST_DECLARE(glmc_mat4_copy)
|
TEST_DECLARE(glmc_mat4_copy)
|
||||||
@@ -218,6 +219,7 @@ TEST_DECLARE(glm_mat3_swap_col)
|
|||||||
TEST_DECLARE(glm_mat3_swap_row)
|
TEST_DECLARE(glm_mat3_swap_row)
|
||||||
TEST_DECLARE(glm_mat3_rmc)
|
TEST_DECLARE(glm_mat3_rmc)
|
||||||
TEST_DECLARE(glm_mat3_make)
|
TEST_DECLARE(glm_mat3_make)
|
||||||
|
TEST_DECLARE(glm_mat3_textrans)
|
||||||
|
|
||||||
TEST_DECLARE(glmc_mat3_copy)
|
TEST_DECLARE(glmc_mat3_copy)
|
||||||
TEST_DECLARE(glmc_mat3_identity)
|
TEST_DECLARE(glmc_mat3_identity)
|
||||||
@@ -1355,6 +1357,7 @@ TEST_LIST {
|
|||||||
TEST_ENTRY(glm_mat4_swap_row)
|
TEST_ENTRY(glm_mat4_swap_row)
|
||||||
TEST_ENTRY(glm_mat4_rmc)
|
TEST_ENTRY(glm_mat4_rmc)
|
||||||
TEST_ENTRY(glm_mat4_make)
|
TEST_ENTRY(glm_mat4_make)
|
||||||
|
TEST_ENTRY(glm_mat4_textrans)
|
||||||
|
|
||||||
TEST_ENTRY(glmc_mat4_ucopy)
|
TEST_ENTRY(glmc_mat4_ucopy)
|
||||||
TEST_ENTRY(glmc_mat4_copy)
|
TEST_ENTRY(glmc_mat4_copy)
|
||||||
@@ -1437,6 +1440,7 @@ TEST_LIST {
|
|||||||
TEST_ENTRY(glm_mat3_swap_row)
|
TEST_ENTRY(glm_mat3_swap_row)
|
||||||
TEST_ENTRY(glm_mat3_rmc)
|
TEST_ENTRY(glm_mat3_rmc)
|
||||||
TEST_ENTRY(glm_mat3_make)
|
TEST_ENTRY(glm_mat3_make)
|
||||||
|
TEST_ENTRY(glm_mat3_textrans)
|
||||||
|
|
||||||
TEST_ENTRY(glmc_mat3_copy)
|
TEST_ENTRY(glmc_mat3_copy)
|
||||||
TEST_ENTRY(glmc_mat3_identity)
|
TEST_ENTRY(glmc_mat3_identity)
|
||||||
|
|||||||
Reference in New Issue
Block a user