mirror of
https://github.com/recp/cglm.git
synced 2026-02-17 03:39:05 +00:00
Compare commits
57 Commits
v0.9.6
...
83d5b2c973
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
83d5b2c973 | ||
|
|
7e1bdd0676 | ||
|
|
0dc17e5d47 | ||
|
|
d6c6b4c542 | ||
|
|
0356534c0c | ||
|
|
5ff0d80c85 | ||
|
|
1952042f2c | ||
|
|
3aad5823ca | ||
|
|
da957fa421 | ||
|
|
47e5d48749 | ||
|
|
a4602f2d5f | ||
|
|
6af4e0d565 | ||
|
|
a311dbfe4c | ||
|
|
a761088e15 | ||
|
|
a886d6e170 | ||
|
|
1a8b105ce6 | ||
|
|
ec5f8074c4 | ||
|
|
6f5fde8b52 | ||
|
|
9da4e78c2e | ||
|
|
27a3ddc928 | ||
|
|
5d530cd8e0 | ||
|
|
dde053a295 | ||
|
|
2128235d42 | ||
|
|
9fb418bcac | ||
|
|
5fde20d65c | ||
|
|
ebc65782f8 | ||
|
|
1bd04c819b | ||
|
|
8560da0e70 | ||
|
|
ed7a658637 | ||
|
|
bcc475e2b7 | ||
|
|
bdca98ba48 | ||
|
|
b33e29d50f | ||
|
|
4b3e9bb779 | ||
|
|
214842db27 | ||
|
|
60e4d6c188 | ||
|
|
5063d4b2b0 | ||
|
|
a16bc2ae4a | ||
|
|
b694c97204 | ||
|
|
4791fe3f24 | ||
|
|
b64067a94d | ||
|
|
43363e8c43 | ||
|
|
f3094cdc65 | ||
|
|
a7bd64952e | ||
|
|
4141298161 | ||
|
|
05979281ac | ||
|
|
4b3dcceb9d | ||
|
|
cfb8cd9447 | ||
|
|
8d01d1d135 | ||
|
|
c6caddc75e | ||
|
|
8b810c2280 | ||
|
|
fd3b21f5d7 | ||
|
|
c1ea9e7a69 | ||
|
|
44b5952ec3 | ||
|
|
6e2976d415 | ||
|
|
9a7f52202d | ||
|
|
e96b6a382d | ||
|
|
091c475422 |
2
.gitignore
vendored
2
.gitignore
vendored
@@ -81,3 +81,5 @@ cmake-build-debug
|
|||||||
*.o.tmp
|
*.o.tmp
|
||||||
xcode/*
|
xcode/*
|
||||||
.vscode
|
.vscode
|
||||||
|
.build
|
||||||
|
*.swp
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ if(MSVC)
|
|||||||
endforeach(flag_var)
|
endforeach(flag_var)
|
||||||
endif()
|
endif()
|
||||||
else()
|
else()
|
||||||
add_compile_options(-Wall)
|
add_compile_options(-Wall -Wextra -Wpedantic -Wconversion)
|
||||||
|
|
||||||
if(NOT CMAKE_BUILD_TYPE MATCHES Debug)
|
if(NOT CMAKE_BUILD_TYPE MATCHES Debug)
|
||||||
add_compile_options(-O3)
|
add_compile_options(-O3)
|
||||||
|
|||||||
@@ -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)
|
||||||
|
|||||||
@@ -36,8 +36,10 @@ Functions:
|
|||||||
#. :c:func:`glm_ortho_default`
|
#. :c:func:`glm_ortho_default`
|
||||||
#. :c:func:`glm_ortho_default_s`
|
#. :c:func:`glm_ortho_default_s`
|
||||||
#. :c:func:`glm_perspective`
|
#. :c:func:`glm_perspective`
|
||||||
|
#. :c:func:`glm_perspective_infinite`
|
||||||
#. :c:func:`glm_persp_move_far`
|
#. :c:func:`glm_persp_move_far`
|
||||||
#. :c:func:`glm_perspective_default`
|
#. :c:func:`glm_perspective_default`
|
||||||
|
#. :c:func:`glm_perspective_default_infinite`
|
||||||
#. :c:func:`glm_perspective_resize`
|
#. :c:func:`glm_perspective_resize`
|
||||||
#. :c:func:`glm_lookat`
|
#. :c:func:`glm_lookat`
|
||||||
#. :c:func:`glm_look`
|
#. :c:func:`glm_look`
|
||||||
@@ -146,6 +148,21 @@ Functions documentation
|
|||||||
| *[in]* **farVal** far clipping planes
|
| *[in]* **farVal** far clipping planes
|
||||||
| *[out]* **dest** result matrix
|
| *[out]* **dest** result matrix
|
||||||
|
|
||||||
|
.. c:function:: void glm_perspective_infinite(float fovy, float aspect, float nearZ, mat4 dest)
|
||||||
|
|
||||||
|
| set up perspective projection matrix with infinite far plane
|
||||||
|
|
||||||
|
The far clipping plane is pushed to infinity. This can improve depth
|
||||||
|
precision for distant objects and is required by some rendering techniques
|
||||||
|
such as shadow volumes. Dispatches to the appropriate clipspace variant
|
||||||
|
based on compile-time configuration (LH/RH, NO/ZO).
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
| *[in]* **fovy** field of view angle (in radians)
|
||||||
|
| *[in]* **aspect** aspect ratio ( width / height )
|
||||||
|
| *[in]* **nearZ** near clipping plane
|
||||||
|
| *[out]* **dest** result matrix
|
||||||
|
|
||||||
.. c:function:: void glm_persp_move_far(mat4 proj, float deltaFar)
|
.. c:function:: void glm_persp_move_far(mat4 proj, float deltaFar)
|
||||||
|
|
||||||
| extend perspective projection matrix's far distance
|
| extend perspective projection matrix's far distance
|
||||||
@@ -165,6 +182,20 @@ Functions documentation
|
|||||||
| *[in]* **aspect** aspect aspect ratio ( width / height )
|
| *[in]* **aspect** aspect aspect ratio ( width / height )
|
||||||
| *[out]* **dest** result matrix
|
| *[out]* **dest** result matrix
|
||||||
|
|
||||||
|
.. c:function:: void glm_perspective_default_infinite(float aspect, mat4 dest)
|
||||||
|
|
||||||
|
| set up infinite perspective projection matrix with default near
|
||||||
|
and angle values
|
||||||
|
|
||||||
|
Equivalent to calling :c:func:`glm_perspective_infinite` with
|
||||||
|
``fovy = GLM_PI_4`` (45°) and ``nearZ = 0.01``. Useful as a
|
||||||
|
quick drop-in when you need an infinite projection without tuning
|
||||||
|
the individual parameters.
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
| *[in]* **aspect** aspect ratio ( width / height )
|
||||||
|
| *[out]* **dest** result matrix
|
||||||
|
|
||||||
.. c:function:: void glm_perspective_resize(float aspect, mat4 proj)
|
.. c:function:: void glm_perspective_resize(float aspect, mat4 proj)
|
||||||
|
|
||||||
| resize perspective matrix by aspect ratio ( width / height )
|
| resize perspective matrix by aspect ratio ( width / height )
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -36,58 +36,103 @@ Represented
|
|||||||
Functions documentation
|
Functions documentation
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
.. c:function:: void glm_mat2x3_copy(mat2x3 mat, mat2x3 dest)
|
.. c:function:: void glm_mat2x3_copy(mat2x3 src, mat2x3 dest)
|
||||||
|
|
||||||
copy mat2x3 to another one (dest).
|
Copy mat2x3 (src) to mat2x3 (dest).
|
||||||
|
|
||||||
Parameters:
|
Parameters:
|
||||||
| *[in]* **mat** source
|
| *[in]* **src** mat2x3 (left)
|
||||||
| *[out]* **dest** destination
|
| *[out]* **dest** destination (result, mat2x3)
|
||||||
|
|
||||||
.. c:function:: void glm_mat2x3_zero(mat2x3 mat)
|
.. csv-table:: mat2x3 **(src)**
|
||||||
|
|
||||||
make given matrix zero
|
|
||||||
|
|
||||||
Parameters:
|
|
||||||
| *[in,out]* **mat** matrix
|
|
||||||
|
|
||||||
.. c:function:: void glm_mat2x3_make(const float * __restrict src, mat2x3 dest)
|
|
||||||
|
|
||||||
Create mat2x3 matrix from pointer
|
|
||||||
|
|
||||||
.. note:: **@src** must contain at least 6 elements.
|
|
||||||
|
|
||||||
Parameters:
|
|
||||||
| *[in]* **src** pointer to an array of floats
|
|
||||||
| *[out]* **dest** destination matrix2x3
|
|
||||||
|
|
||||||
.. c:function:: void glm_mat2x3_mul(mat2x3 m1, mat3x2 m2, mat3 dest)
|
|
||||||
|
|
||||||
multiply m1 and m2 to dest
|
|
||||||
|
|
||||||
.. code-block:: c
|
|
||||||
|
|
||||||
glm_mat2x3_mul(mat2x3, mat3x2, mat3);
|
|
||||||
|
|
||||||
Parameters:
|
|
||||||
| *[in]* **m1** left matrix (mat2x3)
|
|
||||||
| *[in]* **m2** right matrix (mat3x2)
|
|
||||||
| *[out]* **dest** destination matrix (mat3)
|
|
||||||
|
|
||||||
.. csv-table:: mat2x3
|
|
||||||
:header: "", "column 1", "column 2"
|
:header: "", "column 1", "column 2"
|
||||||
|
|
||||||
"row 1", "a00", "a10"
|
"row 1", "a00", "a10"
|
||||||
"row 2", "a01", "a11"
|
"row 2", "a01", "a11"
|
||||||
"row 3", "a02", "a12"
|
"row 3", "a02", "a12"
|
||||||
|
|
||||||
.. csv-table:: mat3x2
|
.. csv-table:: mat2x3 **(dest)**
|
||||||
|
:header: "", "column 1", "column 2"
|
||||||
|
|
||||||
|
"row 1", "b00 = a00", "b10 = a10"
|
||||||
|
"row 2", "b01 = a01", "b11 = a11"
|
||||||
|
"row 3", "b02 = a02", "b12 = a12"
|
||||||
|
|
||||||
|
.. c:function:: void glm_mat2x3_zero(mat2x3 m)
|
||||||
|
|
||||||
|
Zero out the mat2x3 (m).
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
| *[in, out]* **m** mat2x3 (src, dest)
|
||||||
|
|
||||||
|
.. csv-table:: mat2x3 **(m)**
|
||||||
|
:header: "", "column 1", "column 2"
|
||||||
|
|
||||||
|
"row 1", "0.00", "2.00"
|
||||||
|
"row 2", "5.00", "4.00"
|
||||||
|
"row 3", "7.00", "6.00"
|
||||||
|
|
||||||
|
.. csv-table:: mat2x3 **(m)**
|
||||||
|
:header: "", "column 1", "column 2"
|
||||||
|
|
||||||
|
"row 1", "0.00", "0.00"
|
||||||
|
"row 2", "0.00", "0.00"
|
||||||
|
"row 3", "0.00", "0.00"
|
||||||
|
|
||||||
|
.. c:function:: void glm_mat2x3_make(const float * __restrict src, mat2x3 dest)
|
||||||
|
|
||||||
|
Create mat2x3 (dest) from pointer (src).
|
||||||
|
|
||||||
|
.. note:: **@src** must contain at least 6 elements.
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
| *[in]* **src** pointer to an array of floats (left)
|
||||||
|
| *[out]* **dest** destination (result, mat2x3)
|
||||||
|
|
||||||
|
.. csv-table:: float array (1x6) **(src)**
|
||||||
|
:header: "", "column 1"
|
||||||
|
|
||||||
|
"row 1", "v0"
|
||||||
|
"row 2", "v1"
|
||||||
|
"row 3", "v2"
|
||||||
|
"row 4", "v3"
|
||||||
|
"row 5", "v4"
|
||||||
|
"row 6", "v5"
|
||||||
|
|
||||||
|
.. csv-table:: mat2x3 **(dest)**
|
||||||
|
:header: "", "column 1", "column 2"
|
||||||
|
|
||||||
|
"row 1", "v0", "v3"
|
||||||
|
"row 2", "v1", "v4"
|
||||||
|
"row 3", "v2", "v5"
|
||||||
|
|
||||||
|
.. c:function:: void glm_mat2x3_mul(mat2x3 m1, mat3x2 m2, mat3 dest)
|
||||||
|
|
||||||
|
Multiply mat2x3 (m1) by mat3x2 (m2) and store in mat3 (dest).
|
||||||
|
|
||||||
|
.. code-block:: c
|
||||||
|
|
||||||
|
glm_mat2x3_mul(mat2x3, mat3x2, mat3);
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
| *[in]* **m1** mat2x3 (left)
|
||||||
|
| *[in]* **m2** mat3x2 (right)
|
||||||
|
| *[out]* **dest** destination (result, mat3)
|
||||||
|
|
||||||
|
.. csv-table:: mat2x3 **(m1)**
|
||||||
|
:header: "", "column 1", "column 2"
|
||||||
|
|
||||||
|
"row 1", "a00", "a10"
|
||||||
|
"row 2", "a01", "a11"
|
||||||
|
"row 3", "a02", "a12"
|
||||||
|
|
||||||
|
.. csv-table:: mat3x2 **(m2)**
|
||||||
:header: "", "column 1", "column 2", "column 3"
|
:header: "", "column 1", "column 2", "column 3"
|
||||||
|
|
||||||
"row 1", "b00", "b10", "b20"
|
"row 1", "b00", "b10", "b20"
|
||||||
"row 2", "b01", "b11", "b21"
|
"row 2", "b01", "b11", "b21"
|
||||||
|
|
||||||
.. csv-table:: mat3x3
|
.. csv-table:: mat3 **(dest)**
|
||||||
:header: "", "column 1", "column 2", "column 3"
|
:header: "", "column 1", "column 2", "column 3"
|
||||||
|
|
||||||
"row 1", "a00 * b00 + a10 * b01", "a00 * b10 + a10 * b11", "a00 * b20 + a10 * b21"
|
"row 1", "a00 * b00 + a10 * b01", "a00 * b10 + a10 * b11", "a00 * b20 + a10 * b21"
|
||||||
@@ -96,45 +141,65 @@ Functions documentation
|
|||||||
|
|
||||||
.. c:function:: void glm_mat2x3_mulv(mat2x3 m, vec2 v, vec3 dest)
|
.. c:function:: void glm_mat2x3_mulv(mat2x3 m, vec2 v, vec3 dest)
|
||||||
|
|
||||||
multiply mat2x3 with vec2 (column vector) and store in dest column vector
|
Multiply mat2x3 (m) by vec2 (v) and store in vec3 (dest).
|
||||||
|
|
||||||
Parameters:
|
Parameters:
|
||||||
| *[in]* **m** mat2x3 (left)
|
| *[in]* **m** mat2x3 (left)
|
||||||
| *[in]* **v** vec3 (right, column vector)
|
| *[in]* **v** vec2 (right, column vector)
|
||||||
| *[out]* **dest** destination (result, column vector)
|
| *[out]* **dest** destination (result, column vector)
|
||||||
|
|
||||||
.. csv-table:: mat2x3
|
.. csv-table:: mat2x3 **(m)**
|
||||||
:header: "", "column 1", "column 2"
|
:header: "", "column 1", "column 2"
|
||||||
|
|
||||||
"row 1", "m00", "m10"
|
"row 1", "m00", "m10"
|
||||||
"row 2", "m01", "m11"
|
"row 2", "m01", "m11"
|
||||||
"row 3", "m02", "m12"
|
"row 3", "m02", "m12"
|
||||||
|
|
||||||
.. csv-table:: column vec2 (1x2)
|
.. csv-table:: column vec2 (1x2) **(v)**
|
||||||
:header: "", "column 1"
|
:header: "", "column 1"
|
||||||
|
|
||||||
"row 1", "v0"
|
"row 1", "v0"
|
||||||
"row 2", "v1"
|
"row 2", "v1"
|
||||||
|
|
||||||
.. csv-table:: column vec3 (1x3)
|
.. csv-table:: column vec3 (1x3) **(dest)**
|
||||||
:header: "", "column 1"
|
:header: "", "column 1"
|
||||||
|
|
||||||
"row 1", "m00 * v0 + m10 * v1"
|
"row 1", "m00 * v0 + m10 * v1"
|
||||||
"row 2", "m01 * v0 + m11 * v1"
|
"row 2", "m01 * v0 + m11 * v1"
|
||||||
"row 3", "m02 * v0 + m12 * v1"
|
"row 3", "m02 * v0 + m12 * v1"
|
||||||
|
|
||||||
.. c:function:: void glm_mat2x3_transpose(mat2x3 m, mat3x2 dest)
|
.. c:function:: void glm_mat2x3_transpose(mat2x3 src, mat3x2 dest)
|
||||||
|
|
||||||
transpose matrix and store in dest
|
Transpose mat2x3 (src) and store in mat3x2 (dest).
|
||||||
|
|
||||||
Parameters:
|
Parameters:
|
||||||
| *[in]* **m** matrix
|
| *[in]* **src** mat2x3 (left)
|
||||||
| *[out]* **dest** destination
|
| *[out]* **dest** destination (result, mat3x2)
|
||||||
|
|
||||||
.. c:function:: void glm_mat2x3_scale(mat2x3 m, float s)
|
.. csv-table:: mat2x3 **(src)**
|
||||||
|
:header: "", "column 1", "column 2"
|
||||||
|
|
||||||
multiply matrix with scalar
|
"row 1", "a00", "a10"
|
||||||
|
"row 2", "a01", "a11"
|
||||||
|
"row 3", "a02", "a12"
|
||||||
|
|
||||||
|
.. csv-table:: mat3x2 **(dest)**
|
||||||
|
:header: "", "column 1", "column 2", "column 3"
|
||||||
|
|
||||||
|
"row 1", "b00 = a00", "b10 = a01", "b20 = a02"
|
||||||
|
"row 2", "b01 = a10", "b11 = a11", "b21 = a12"
|
||||||
|
|
||||||
|
.. c:function:: void glm_mat2x3_scale(mat2x3 m, float s)
|
||||||
|
|
||||||
|
Multiply mat2x3 (m) by scalar constant (s).
|
||||||
|
|
||||||
Parameters:
|
Parameters:
|
||||||
| *[in, out]* **m** matrix
|
| *[in, out]* **m** mat2x3 (src, dest)
|
||||||
| *[in]* **s** scalar
|
| *[in]* **s** float (scalar)
|
||||||
|
|
||||||
|
.. csv-table:: mat2x3 **(m)**
|
||||||
|
:header: "", "column 1", "column 2"
|
||||||
|
|
||||||
|
"row 1", "m00 = m00 * s", "m10 = m10 * s"
|
||||||
|
"row 2", "m01 = m01 * s", "m11 = m11 * s"
|
||||||
|
"row 3", "m02 = m02 * s", "m12 = m12 * s"
|
||||||
|
|||||||
@@ -37,45 +37,15 @@ Represented
|
|||||||
Functions documentation
|
Functions documentation
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
.. c:function:: void glm_mat2x4_copy(mat2x4 mat, mat2x4 dest)
|
.. c:function:: void glm_mat2x4_copy(mat2x4 src, mat2x4 dest)
|
||||||
|
|
||||||
copy mat2x4 to another one (dest).
|
Copy mat2x4 (src) to mat2x4 (dest).
|
||||||
|
|
||||||
Parameters:
|
Parameters:
|
||||||
| *[in]* **mat** source
|
| *[in]* **src** mat2x4 (left)
|
||||||
| *[out]* **dest** destination
|
| *[out]* **dest** destination (result, mat2x4)
|
||||||
|
|
||||||
.. c:function:: void glm_mat2x4_zero(mat2x4 mat)
|
.. csv-table:: mat2x4 **(src)**
|
||||||
|
|
||||||
make given matrix zero
|
|
||||||
|
|
||||||
Parameters:
|
|
||||||
| *[in,out]* **mat** matrix
|
|
||||||
|
|
||||||
.. c:function:: void glm_mat2x4_make(const float * __restrict src, mat2x4 dest)
|
|
||||||
|
|
||||||
Create mat2x4 matrix from pointer
|
|
||||||
|
|
||||||
.. note:: **@src** must contain at least 8 elements.
|
|
||||||
|
|
||||||
Parameters:
|
|
||||||
| *[in]* **src** pointer to an array of floats
|
|
||||||
| *[out]* **dest** destination matrix2x4
|
|
||||||
|
|
||||||
.. c:function:: void glm_mat2x4_mul(mat2x4 m1, mat4x2 m2, mat4 dest)
|
|
||||||
|
|
||||||
multiply m1 and m2 to dest
|
|
||||||
|
|
||||||
.. code-block:: c
|
|
||||||
|
|
||||||
glm_mat2x4_mul(mat2x4, mat4x2, mat4);
|
|
||||||
|
|
||||||
Parameters:
|
|
||||||
| *[in]* **m1** left matrix (mat2x4)
|
|
||||||
| *[in]* **m2** right matrix (mat4x2)
|
|
||||||
| *[out]* **dest** destination matrix (mat4)
|
|
||||||
|
|
||||||
.. csv-table:: mat2x4
|
|
||||||
:header: "", "column 1", "column 2"
|
:header: "", "column 1", "column 2"
|
||||||
|
|
||||||
"row 1", "a00", "a10"
|
"row 1", "a00", "a10"
|
||||||
@@ -83,13 +53,95 @@ Functions documentation
|
|||||||
"row 3", "a02", "a12"
|
"row 3", "a02", "a12"
|
||||||
"row 4", "a03", "a13"
|
"row 4", "a03", "a13"
|
||||||
|
|
||||||
.. csv-table:: mat4x2
|
.. csv-table:: mat2x4 **(dest)**
|
||||||
|
:header: "", "column 1", "column 2"
|
||||||
|
|
||||||
|
"row 1", "b00 = a00", "b10 = a10"
|
||||||
|
"row 2", "b01 = a01", "b11 = a11"
|
||||||
|
"row 3", "b02 = a02", "b12 = a12"
|
||||||
|
"row 4", "b03 = a03", "b13 = a13"
|
||||||
|
|
||||||
|
.. c:function:: void glm_mat2x4_zero(mat2x4 m)
|
||||||
|
|
||||||
|
Zero out the mat2x4 (m).
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
| *[in, out]* **m** mat2x4 (src, dest)
|
||||||
|
|
||||||
|
.. csv-table:: mat2x4 **(m)**
|
||||||
|
:header: "", "column 1", "column 2"
|
||||||
|
|
||||||
|
"row 1", "0.00", "2.00"
|
||||||
|
"row 2", "5.00", "4.00"
|
||||||
|
"row 3", "7.00", "6.00"
|
||||||
|
"row 4", "23.00", "1.00"
|
||||||
|
|
||||||
|
.. csv-table:: mat2x4 **(m)**
|
||||||
|
:header: "", "column 1", "column 2"
|
||||||
|
|
||||||
|
"row 1", "0.00", "0.00"
|
||||||
|
"row 2", "0.00", "0.00"
|
||||||
|
"row 3", "0.00", "0.00"
|
||||||
|
"row 4", "0.00", "0.00"
|
||||||
|
|
||||||
|
.. c:function:: void glm_mat2x4_make(const float * __restrict src, mat2x4 dest)
|
||||||
|
|
||||||
|
Create mat2x4 (dest) from pointer (src).
|
||||||
|
|
||||||
|
.. note:: **@src** must contain at least 8 elements.
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
| *[in]* **src** pointer to an array of floats (left)
|
||||||
|
| *[out]* **dest** destination (result, mat2x4)
|
||||||
|
|
||||||
|
.. csv-table:: float array (1x8) **(src)**
|
||||||
|
:header: "", "column 1"
|
||||||
|
|
||||||
|
"row 1", "v0"
|
||||||
|
"row 2", "v1"
|
||||||
|
"row 3", "v2"
|
||||||
|
"row 4", "v3"
|
||||||
|
"row 5", "v4"
|
||||||
|
"row 6", "v5"
|
||||||
|
"row 7", "v6"
|
||||||
|
"row 8", "v7"
|
||||||
|
|
||||||
|
.. csv-table:: mat2x4 **(dest)**
|
||||||
|
:header: "", "column 1", "column 2"
|
||||||
|
|
||||||
|
"row 1", "v0", "v4"
|
||||||
|
"row 2", "v1", "v5"
|
||||||
|
"row 3", "v2", "v6"
|
||||||
|
"row 4", "v3", "v7"
|
||||||
|
|
||||||
|
.. c:function:: void glm_mat2x4_mul(mat2x4 m1, mat4x2 m2, mat4 dest)
|
||||||
|
|
||||||
|
Multiply mat2x4 (m1) by mat4x2 (m2) and store in mat4 (dest).
|
||||||
|
|
||||||
|
.. code-block:: c
|
||||||
|
|
||||||
|
glm_mat2x4_mul(mat2x4, mat4x2, mat4);
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
| *[in]* **m1** mat2x4 (left)
|
||||||
|
| *[in]* **m2** mat4x2 (right)
|
||||||
|
| *[out]* **dest** destination (result, mat4)
|
||||||
|
|
||||||
|
.. csv-table:: mat2x4 **(m1)**
|
||||||
|
:header: "", "column 1", "column 2"
|
||||||
|
|
||||||
|
"row 1", "a00", "a10"
|
||||||
|
"row 2", "a01", "a11"
|
||||||
|
"row 3", "a02", "a12"
|
||||||
|
"row 4", "a03", "a13"
|
||||||
|
|
||||||
|
.. csv-table:: mat4x2 **(m2)**
|
||||||
:header: "", "column 1", "column 2", "column 3", "column 4"
|
:header: "", "column 1", "column 2", "column 3", "column 4"
|
||||||
|
|
||||||
"row 1", "b00", "b10", "b20", "b30"
|
"row 1", "b00", "b10", "b20", "b30"
|
||||||
"row 2", "b01", "b11", "b21", "b31"
|
"row 2", "b01", "b11", "b21", "b31"
|
||||||
|
|
||||||
.. csv-table:: mat4x4
|
.. csv-table:: mat4x4 **(dest)**
|
||||||
:header: "", "column 1", "column 2", "column 3", "column 4"
|
:header: "", "column 1", "column 2", "column 3", "column 4"
|
||||||
|
|
||||||
"row 1", "a00 * b00 + a10 * b01", "a00 * b10 + a10 * b11", "a00 * b20 + a10 * b21", "a00 * b30 + a10 * b31"
|
"row 1", "a00 * b00 + a10 * b01", "a00 * b10 + a10 * b11", "a00 * b20 + a10 * b21", "a00 * b30 + a10 * b31"
|
||||||
@@ -99,14 +151,14 @@ Functions documentation
|
|||||||
|
|
||||||
.. c:function:: void glm_mat2x4_mulv(mat2x4 m, vec2 v, vec4 dest)
|
.. c:function:: void glm_mat2x4_mulv(mat2x4 m, vec2 v, vec4 dest)
|
||||||
|
|
||||||
multiply mat2x4 with vec2 (column vector) and store in dest column vector
|
Multiply mat2x4 (m) by vec2 (v) and store in vec4 (dest).
|
||||||
|
|
||||||
Parameters:
|
Parameters:
|
||||||
| *[in]* **m** mat2x4 (left)
|
| *[in]* **m** mat2x4 (left)
|
||||||
| *[in]* **v** vec2 (right, column vector)
|
| *[in]* **v** vec2 (right, column vector)
|
||||||
| *[out]* **dest** destination (result, column vector)
|
| *[out]* **dest** destination (result, column vector)
|
||||||
|
|
||||||
.. csv-table:: mat2x4
|
.. csv-table:: mat2x4 **(m)**
|
||||||
:header: "", "column 1", "column 2"
|
:header: "", "column 1", "column 2"
|
||||||
|
|
||||||
"row 1", "m00", "m10"
|
"row 1", "m00", "m10"
|
||||||
@@ -114,13 +166,13 @@ Functions documentation
|
|||||||
"row 3", "m02", "m12"
|
"row 3", "m02", "m12"
|
||||||
"row 4", "m03", "m13"
|
"row 4", "m03", "m13"
|
||||||
|
|
||||||
.. csv-table:: column vec2 (1x2)
|
.. csv-table:: column vec2 (1x2) **(v)**
|
||||||
:header: "", "column 1"
|
:header: "", "column 1"
|
||||||
|
|
||||||
"row 1", "v0"
|
"row 1", "v0"
|
||||||
"row 2", "v1"
|
"row 2", "v1"
|
||||||
|
|
||||||
.. csv-table:: column vec4 (1x4)
|
.. csv-table:: column vec4 (1x4) **(dest)**
|
||||||
:header: "", "column 1"
|
:header: "", "column 1"
|
||||||
|
|
||||||
"row 1", "m00 * v0 + m10 * v1"
|
"row 1", "m00 * v0 + m10 * v1"
|
||||||
@@ -128,18 +180,40 @@ Functions documentation
|
|||||||
"row 3", "m02 * v0 + m12 * v1"
|
"row 3", "m02 * v0 + m12 * v1"
|
||||||
"row 4", "m03 * v0 + m13 * v1"
|
"row 4", "m03 * v0 + m13 * v1"
|
||||||
|
|
||||||
.. c:function:: void glm_mat2x4_transpose(mat2x4 m, mat4x2 dest)
|
.. c:function:: void glm_mat2x4_transpose(mat2x4 src, mat4x2 dest)
|
||||||
|
|
||||||
transpose matrix and store in dest
|
Transpose mat2x4 (src) and store in mat4x2 (dest).
|
||||||
|
|
||||||
Parameters:
|
Parameters:
|
||||||
| *[in]* **m** matrix
|
| *[in]* **src** mat2x4 (left)
|
||||||
| *[out]* **dest** destination
|
| *[out]* **dest** destination (result, mat4x2)
|
||||||
|
|
||||||
|
.. csv-table:: mat2x4 **(src)**
|
||||||
|
:header: "", "column 1", "column 2"
|
||||||
|
|
||||||
|
"row 1", "a00", "a10"
|
||||||
|
"row 2", "a01", "a11"
|
||||||
|
"row 3", "a02", "a12"
|
||||||
|
"row 4", "a03", "a13"
|
||||||
|
|
||||||
|
.. csv-table:: mat4x2 **(dest)**
|
||||||
|
:header: "", "column 1", "column 2", "column 3", "column 4"
|
||||||
|
|
||||||
|
"row 1", "b00 = a00", "b10 = a01", "b20 = a02", "b30 = a03"
|
||||||
|
"row 2", "b01 = a10", "b11 = a11", "b21 = a12", "b31 = a13"
|
||||||
|
|
||||||
.. c:function:: void glm_mat2x4_scale(mat2x4 m, float s)
|
.. c:function:: void glm_mat2x4_scale(mat2x4 m, float s)
|
||||||
|
|
||||||
multiply matrix with scalar
|
Multiply mat2x4 (m) by scalar constant (s).
|
||||||
|
|
||||||
Parameters:
|
Parameters:
|
||||||
| *[in, out]* **m** matrix
|
| *[in, out]* **m** mat2x4 (src, dest)
|
||||||
| *[in]* **s** scalar
|
| *[in]* **s** float (scalar)
|
||||||
|
|
||||||
|
.. csv-table:: mat2x4 **(m)**
|
||||||
|
:header: "", "column 1", "column 2"
|
||||||
|
|
||||||
|
"row 1", "m00 = m00 * s", "m10 = m10 * s"
|
||||||
|
"row 2", "m01 = m01 * s", "m11 = m11 * s"
|
||||||
|
"row 3", "m02 = m02 * s", "m12 = m12 * s"
|
||||||
|
"row 4", "m03 = m03 * s", "m13 = m13 * s"
|
||||||
|
|||||||
1152
docs/source/mat3.rst
1152
docs/source/mat3.rst
File diff suppressed because it is too large
Load Diff
@@ -35,58 +35,98 @@ Represented
|
|||||||
Functions documentation
|
Functions documentation
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
.. c:function:: void glm_mat3x2_copy(mat3x2 mat, mat3x2 dest)
|
.. c:function:: void glm_mat3x2_copy(mat3x2 src, mat3x2 dest)
|
||||||
|
|
||||||
copy mat3x2 to another one (dest).
|
Copy mat3x2 (src) to mat3x2 (dest).
|
||||||
|
|
||||||
Parameters:
|
Parameters:
|
||||||
| *[in]* **mat** source
|
| *[in]* **src** mat3x2 (left)
|
||||||
| *[out]* **dest** destination
|
| *[out]* **dest** destination (result, mat3x2)
|
||||||
|
|
||||||
.. c:function:: void glm_mat3x2_zero(mat3x2 mat)
|
.. csv-table:: mat3x2 **(src)**
|
||||||
|
:header: "", "column 1", "column 2", "column 3"
|
||||||
|
|
||||||
make given matrix zero
|
"row 1", "a00", "a10", "a20"
|
||||||
|
"row 2", "a01", "a11", "a21"
|
||||||
|
|
||||||
|
.. csv-table:: mat3x2 **(dest)**
|
||||||
|
:header: "", "column 1", "column 2", "column 3"
|
||||||
|
|
||||||
|
"row 1", "b00 = a00", "b10 = a10", "b20 = a20"
|
||||||
|
"row 2", "b01 = a01", "b11 = a11", "b21 = a21"
|
||||||
|
|
||||||
|
.. c:function:: void glm_mat3x2_zero(mat3x2 m)
|
||||||
|
|
||||||
|
Zero out the mat3x2 (m).
|
||||||
|
|
||||||
Parameters:
|
Parameters:
|
||||||
| *[in,out]* **mat** matrix
|
| *[in, out]* **m** mat3x2 (src, dest)
|
||||||
|
|
||||||
|
.. csv-table:: mat3x2 **(m)**
|
||||||
|
:header: "", "column 1", "column 2", "column 3"
|
||||||
|
|
||||||
|
"row 1", "0.00", "2.00", "15.00"
|
||||||
|
"row 2", "5.00", "4.00", "6.00"
|
||||||
|
|
||||||
|
.. csv-table:: mat3x2 **(m)**
|
||||||
|
:header: "", "column 1", "column 2", "column 3"
|
||||||
|
|
||||||
|
"row 1", "0.00", "0.00", "0.00"
|
||||||
|
"row 2", "0.00", "0.00", "0.00"
|
||||||
|
|
||||||
.. c:function:: void glm_mat3x2_make(const float * __restrict src, mat3x2 dest)
|
.. c:function:: void glm_mat3x2_make(const float * __restrict src, mat3x2 dest)
|
||||||
|
|
||||||
Create mat3x2 matrix from pointer
|
Create mat3x2 (dest) from pointer (src).
|
||||||
|
|
||||||
.. note:: **@src** must contain at least 6 elements.
|
.. note:: **@src** must contain at least 6 elements.
|
||||||
|
|
||||||
Parameters:
|
Parameters:
|
||||||
| *[in]* **src** pointer to an array of floats
|
| *[in]* **src** pointer to an array of floats (left)
|
||||||
| *[out]* **dest** destination matrix3x2
|
| *[out]* **dest** destination (result, mat3x2)
|
||||||
|
|
||||||
|
.. csv-table:: float array (1x6) **(src)**
|
||||||
|
:header: "", "column 1"
|
||||||
|
|
||||||
|
"row 1", "v0"
|
||||||
|
"row 2", "v1"
|
||||||
|
"row 3", "v2"
|
||||||
|
"row 4", "v3"
|
||||||
|
"row 5", "v4"
|
||||||
|
"row 6", "v5"
|
||||||
|
|
||||||
|
.. csv-table:: mat3x2 **(dest)**
|
||||||
|
:header: "", "column 1", "column 2", "column 3"
|
||||||
|
|
||||||
|
"row 1", "v0", "v2", "v4"
|
||||||
|
"row 2", "v1", "v3", "v5"
|
||||||
|
|
||||||
.. c:function:: void glm_mat3x2_mul(mat3x2 m1, mat2x3 m2, mat2 dest)
|
.. c:function:: void glm_mat3x2_mul(mat3x2 m1, mat2x3 m2, mat2 dest)
|
||||||
|
|
||||||
multiply m1 and m2 to dest
|
Multiply mat3x2 (m1) by mat2x3 (m2) and store in mat2 (dest).
|
||||||
|
|
||||||
.. code-block:: c
|
.. code-block:: c
|
||||||
|
|
||||||
glm_mat3x2_mul(mat3x2, mat2x3, mat2);
|
glm_mat3x2_mul(mat3x2, mat2x3, mat2);
|
||||||
|
|
||||||
Parameters:
|
Parameters:
|
||||||
| *[in]* **m1** left matrix (mat3x2)
|
| *[in]* **m1** mat3x2 (left)
|
||||||
| *[in]* **m2** right matrix (mat2x3)
|
| *[in]* **m2** mat2x3 (right)
|
||||||
| *[out]* **dest** destination matrix (mat2)
|
| *[out]* **dest** destination (result, mat2)
|
||||||
|
|
||||||
.. csv-table:: mat3x2
|
.. csv-table:: mat3x2 **(m1)**
|
||||||
:header: "", "column 1", "column 2", "column 3"
|
:header: "", "column 1", "column 2", "column 3"
|
||||||
|
|
||||||
"row 1", "a00", "a10", "a20"
|
"row 1", "a00", "a10", "a20"
|
||||||
"row 2", "a01", "a11", "a21"
|
"row 2", "a01", "a11", "a21"
|
||||||
|
|
||||||
.. csv-table:: mat2x3
|
.. csv-table:: mat2x3 **(m2)**
|
||||||
:header: "", "column 1", "column 2"
|
:header: "", "column 1", "column 2"
|
||||||
|
|
||||||
"row 1", "b00", "b10"
|
"row 1", "b00", "b10"
|
||||||
"row 2", "b01", "b11"
|
"row 2", "b01", "b11"
|
||||||
"row 3", "b02", "b12"
|
"row 3", "b02", "b12"
|
||||||
|
|
||||||
.. csv-table:: mat2x2
|
.. csv-table:: mat2x2 **(dest)**
|
||||||
:header: "", "column 1", "column 2"
|
:header: "", "column 1", "column 2"
|
||||||
|
|
||||||
"row 1", "a00 * b00 + a10 * b01 + a20 * b02", "a00 * b10 + a10 * b11 + a20 * b12"
|
"row 1", "a00 * b00 + a10 * b01 + a20 * b02", "a00 * b10 + a10 * b11 + a20 * b12"
|
||||||
@@ -94,44 +134,63 @@ Functions documentation
|
|||||||
|
|
||||||
.. c:function:: void glm_mat3x2_mulv(mat3x2 m, vec3 v, vec2 dest)
|
.. c:function:: void glm_mat3x2_mulv(mat3x2 m, vec3 v, vec2 dest)
|
||||||
|
|
||||||
multiply mat3x2 with vec3 (column vector) and store in dest vector
|
Multiply mat3x2 (m) by vec3 (v) and store in vec2 (dest).
|
||||||
|
|
||||||
Parameters:
|
Parameters:
|
||||||
| *[in]* **m** mat3x2 (left)
|
| *[in]* **m** mat3x2 (left)
|
||||||
| *[in]* **v** vec3 (right, column vector)
|
| *[in]* **v** vec3 (right, column vector)
|
||||||
| *[out]* **dest** destination (result, column vector)
|
| *[out]* **dest** destination (result, column vector)
|
||||||
|
|
||||||
.. csv-table:: mat3x2
|
.. csv-table:: mat3x2 **(m)**
|
||||||
:header: "", "column 1", "column 2", "column 3"
|
:header: "", "column 1", "column 2", "column 3"
|
||||||
|
|
||||||
"row 1", "m00", "m10", "m20"
|
"row 1", "m00", "m10", "m20"
|
||||||
"row 2", "m01", "m11", "m21"
|
"row 2", "m01", "m11", "m21"
|
||||||
|
|
||||||
.. csv-table:: column vec3 (1x3)
|
.. csv-table:: column vec3 (1x3) **(v)**
|
||||||
:header: "", "column 1"
|
:header: "", "column 1"
|
||||||
|
|
||||||
"row 1", "v0"
|
"row 1", "v0"
|
||||||
"row 2", "v1"
|
"row 2", "v1"
|
||||||
"row 3", "v2"
|
"row 3", "v2"
|
||||||
|
|
||||||
.. csv-table:: column vec2 (1x2)
|
.. csv-table:: column vec2 (1x2) **(dest)**
|
||||||
:header: "", "column 1"
|
:header: "", "column 1"
|
||||||
|
|
||||||
"row 1", "m00 * v0 + m10 * v1 + m20 * v2"
|
"row 1", "m00 * v0 + m10 * v1 + m20 * v2"
|
||||||
"row 2", "m01 * v0 + m11 * v1 + m21 * v2"
|
"row 2", "m01 * v0 + m11 * v1 + m21 * v2"
|
||||||
|
|
||||||
.. c:function:: void glm_mat3x2_transpose(mat3x2 m, mat2x3 dest)
|
.. c:function:: void glm_mat3x2_transpose(mat3x2 src, mat2x3 dest)
|
||||||
|
|
||||||
transpose matrix and store in dest
|
Transpose mat3x2 (src) and store in mat2x3 (dest).
|
||||||
|
|
||||||
Parameters:
|
Parameters:
|
||||||
| *[in]* **m** matrix
|
| *[in]* **src** mat3x2 (left)
|
||||||
| *[out]* **dest** destination
|
| *[out]* **dest** destination (result, mat2x3)
|
||||||
|
|
||||||
.. c:function:: void glm_mat3x2_scale(mat3x2 m, float s)
|
.. csv-table:: mat3x2 **(src)**
|
||||||
|
:header: "", "column 1", "column 2", "column 3"
|
||||||
|
|
||||||
multiply matrix with scalar
|
"row 1", "a00", "a10", "a20"
|
||||||
|
"row 2", "a01", "a11", "a21"
|
||||||
|
|
||||||
|
.. csv-table:: mat2x3 **(dest)**
|
||||||
|
:header: "", "column 1", "column 2"
|
||||||
|
|
||||||
|
"row 1", "b00 = a00", "b10 = a01"
|
||||||
|
"row 2", "b01 = a10", "b11 = a11"
|
||||||
|
"row 3", "b02 = a20", "b12 = a21"
|
||||||
|
|
||||||
|
.. c:function:: void glm_mat3x2_scale(mat3x2 m, float s)
|
||||||
|
|
||||||
|
Multiply mat3x2 (m) by scalar constant (s).
|
||||||
|
|
||||||
Parameters:
|
Parameters:
|
||||||
| *[in, out]* **m** matrix
|
| *[in, out]* **m** mat3x2 (src, dest)
|
||||||
| *[in]* **s** scalar
|
| *[in]* **s** float (scalar)
|
||||||
|
|
||||||
|
.. csv-table:: mat3x2 **(m)**
|
||||||
|
:header: "", "column 1", "column 2", "column 3"
|
||||||
|
|
||||||
|
"row 1", "m00 = m00 * s", "m10 = m10 * s", "m20 = m20 * s"
|
||||||
|
"row 2", "m01 = m01 * s", "m11 = m11 * s", "m21 = m21 * s"
|
||||||
|
|||||||
@@ -37,45 +37,15 @@ Represented
|
|||||||
Functions documentation
|
Functions documentation
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
.. c:function:: void glm_mat3x4_copy(mat3x4 mat, mat3x4 dest)
|
.. c:function:: void glm_mat3x4_copy(mat3x4 src, mat3x4 dest)
|
||||||
|
|
||||||
copy mat3x4 to another one (dest).
|
Copy mat3x4 (src) to mat3x4 (dest).
|
||||||
|
|
||||||
Parameters:
|
Parameters:
|
||||||
| *[in]* **mat** source
|
| *[in]* **src** mat3x4 (left)
|
||||||
| *[out]* **dest** destination
|
| *[out]* **dest** destination (result, mat3x4)
|
||||||
|
|
||||||
.. c:function:: void glm_mat3x4_zero(mat3x4 mat)
|
.. csv-table:: mat3x4 **(src)**
|
||||||
|
|
||||||
make given matrix zero
|
|
||||||
|
|
||||||
Parameters:
|
|
||||||
| *[in,out]* **mat** matrix
|
|
||||||
|
|
||||||
.. c:function:: void glm_mat3x4_make(const float * __restrict src, mat3x4 dest)
|
|
||||||
|
|
||||||
Create mat3x4 matrix from pointer
|
|
||||||
|
|
||||||
.. note::: **@src** must contain at least 12 elements.
|
|
||||||
|
|
||||||
Parameters:
|
|
||||||
| *[in]* **src** pointer to an array of floats
|
|
||||||
| *[out]* **dest** destination matrix3x4
|
|
||||||
|
|
||||||
.. c:function:: void glm_mat3x4_mul(mat3x4 m1, mat4x3 m2, mat4 dest)
|
|
||||||
|
|
||||||
multiply m1 and m2 to dest
|
|
||||||
|
|
||||||
.. code-block:: c
|
|
||||||
|
|
||||||
glm_mat3x4_mul(mat3x4, mat4x3, mat4);
|
|
||||||
|
|
||||||
Parameters:
|
|
||||||
| *[in]* **m1** left matrix (mat3x4)
|
|
||||||
| *[in]* **m2** right matrix (mat4x3)
|
|
||||||
| *[out]* **dest** destination matrix (mat4)
|
|
||||||
|
|
||||||
.. csv-table:: mat3x4
|
|
||||||
:header: "", "column 1", "column 2", "column 3"
|
:header: "", "column 1", "column 2", "column 3"
|
||||||
|
|
||||||
"row 1", "a00", "a10", "a20"
|
"row 1", "a00", "a10", "a20"
|
||||||
@@ -83,14 +53,100 @@ Functions documentation
|
|||||||
"row 3", "a02", "a12", "a22"
|
"row 3", "a02", "a12", "a22"
|
||||||
"row 4", "a03", "a13", "a23"
|
"row 4", "a03", "a13", "a23"
|
||||||
|
|
||||||
.. csv-table:: mat4x3
|
.. csv-table:: mat3x4 **(dest)**
|
||||||
|
:header: "", "column 1", "column 2", "column 3"
|
||||||
|
|
||||||
|
"row 1", "b00 = a00", "b10 = a10", "b20 = a20"
|
||||||
|
"row 2", "b01 = a01", "b11 = a11", "b21 = a21"
|
||||||
|
"row 3", "b02 = a02", "b12 = a12", "b22 = a22"
|
||||||
|
"row 4", "b03 = a03", "b13 = a13", "b23 = a23"
|
||||||
|
|
||||||
|
.. c:function:: void glm_mat3x4_zero(mat3x4 m)
|
||||||
|
|
||||||
|
Zero out the mat3x4 (m).
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
| *[in, out]* **m** mat3x4 (src, dest)
|
||||||
|
|
||||||
|
.. csv-table:: mat3x4 **(m)**
|
||||||
|
:header: "", "column 1", "column 2", "column 3"
|
||||||
|
|
||||||
|
"row 1", "0.00", "2.00", "78.00"
|
||||||
|
"row 2", "5.00", "4.00", "12.00"
|
||||||
|
"row 3", "7.00", "6.00", "32.00"
|
||||||
|
"row 4", "23.00", "1.00", "9.00"
|
||||||
|
|
||||||
|
.. csv-table:: mat3x4 **(m)**
|
||||||
|
:header: "", "column 1", "column 2", "column 3"
|
||||||
|
|
||||||
|
"row 1", "0.00", "0.00", "0.00"
|
||||||
|
"row 2", "0.00", "0.00", "0.00"
|
||||||
|
"row 3", "0.00", "0.00", "0.00"
|
||||||
|
"row 4", "0.00", "0.00", "0.00"
|
||||||
|
|
||||||
|
.. c:function:: void glm_mat3x4_make(const float * __restrict src, mat3x4 dest)
|
||||||
|
|
||||||
|
Create mat3x4 (dest) from pointer (src).
|
||||||
|
|
||||||
|
.. note:: **@src** must contain at least 12 elements.
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
| *[in]* **src** pointer to an array of floats (left)
|
||||||
|
| *[out]* **dest** destination (result, mat3x4)
|
||||||
|
|
||||||
|
.. csv-table:: float array (1x12) **(src)**
|
||||||
|
:header: "", "column 1"
|
||||||
|
|
||||||
|
"row 1", "v0"
|
||||||
|
"row 2", "v1"
|
||||||
|
"row 3", "v2"
|
||||||
|
"row 4", "v3"
|
||||||
|
"row 5", "v4"
|
||||||
|
"row 6", "v5"
|
||||||
|
"row 7", "v6"
|
||||||
|
"row 8", "v7"
|
||||||
|
"row 9", "v8"
|
||||||
|
"row 10", "v9"
|
||||||
|
"row 11", "v10"
|
||||||
|
"row 12", "v11"
|
||||||
|
|
||||||
|
.. csv-table:: mat3x4 **(dest)**
|
||||||
|
:header: "", "column 1", "column 2", "column 3"
|
||||||
|
|
||||||
|
"row 1", "v0", "v4", "v8"
|
||||||
|
"row 2", "v1", "v5", "v9"
|
||||||
|
"row 3", "v2", "v6", "v10"
|
||||||
|
"row 4", "v3", "v7", "v11"
|
||||||
|
|
||||||
|
.. c:function:: void glm_mat3x4_mul(mat3x4 m1, mat4x3 m2, mat4 dest)
|
||||||
|
|
||||||
|
Multiply mat3x4 (m1) by mat4x3 (m2) and store in mat4 (dest).
|
||||||
|
|
||||||
|
.. code-block:: c
|
||||||
|
|
||||||
|
glm_mat3x4_mul(mat3x4, mat4x3, mat4);
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
| *[in]* **m1** mat2x4 (left)
|
||||||
|
| *[in]* **m2** mat4x2 (right)
|
||||||
|
| *[out]* **dest** destination (result, mat4)
|
||||||
|
|
||||||
|
.. csv-table:: mat3x4 **(m1)**
|
||||||
|
:header: "", "column 1", "column 2", "column 3"
|
||||||
|
|
||||||
|
"row 1", "a00", "a10", "a20"
|
||||||
|
"row 2", "a01", "a11", "a21"
|
||||||
|
"row 3", "a02", "a12", "a22"
|
||||||
|
"row 4", "a03", "a13", "a23"
|
||||||
|
|
||||||
|
.. csv-table:: mat4x3 **(m2)**
|
||||||
:header: "", "column 1", "column 2", "column 3", "column 4"
|
:header: "", "column 1", "column 2", "column 3", "column 4"
|
||||||
|
|
||||||
"row 1", "b00", "b10", "b20", "b30"
|
"row 1", "b00", "b10", "b20", "b30"
|
||||||
"row 2", "b01", "b11", "b21", "b31"
|
"row 2", "b01", "b11", "b21", "b31"
|
||||||
"row 3", "b02", "b12", "b22", "b32"
|
"row 3", "b02", "b12", "b22", "b32"
|
||||||
|
|
||||||
.. csv-table:: mat4x4
|
.. csv-table:: mat4x4 **(dest)**
|
||||||
:header: "", "column 1", "column 2", "column 3", "column 4"
|
:header: "", "column 1", "column 2", "column 3", "column 4"
|
||||||
|
|
||||||
"row 1", "a00 * b00 + a10 * b01 + a20 * b02", "a00 * b10 + a10 * b11 + a20 * b12", "a00 * b20 + a10 * b21 + a20 * b22", "a00 * b30 + a10 * b31 + a20 * b32"
|
"row 1", "a00 * b00 + a10 * b01 + a20 * b02", "a00 * b10 + a10 * b11 + a20 * b12", "a00 * b20 + a10 * b21 + a20 * b22", "a00 * b30 + a10 * b31 + a20 * b32"
|
||||||
@@ -100,14 +156,14 @@ Functions documentation
|
|||||||
|
|
||||||
.. c:function:: void glm_mat3x4_mulv(mat3x4 m, vec3 v, vec4 dest)
|
.. c:function:: void glm_mat3x4_mulv(mat3x4 m, vec3 v, vec4 dest)
|
||||||
|
|
||||||
multiply mat3x4 with vec3 (column vector) and store in dest vector
|
Multiply ma3x4 (m) by vec3 (v) and store in vec4 (dest).
|
||||||
|
|
||||||
Parameters:
|
Parameters:
|
||||||
| *[in]* **m** mat3x4 (left)
|
| *[in]* **m** mat3x4 (left)
|
||||||
| *[in]* **v** vec3 (right, column vector)
|
| *[in]* **v** vec3 (right, column vector)
|
||||||
| *[out]* **dest** destination (result, column vector)
|
| *[out]* **dest** destination (result, column vector)
|
||||||
|
|
||||||
.. csv-table:: mat3x4
|
.. csv-table:: mat3x4 **(m)**
|
||||||
:header: "", "column 1", "column 2", "column 3"
|
:header: "", "column 1", "column 2", "column 3"
|
||||||
|
|
||||||
"row 1", "m00", "m10", "m20"
|
"row 1", "m00", "m10", "m20"
|
||||||
@@ -115,14 +171,14 @@ Functions documentation
|
|||||||
"row 3", "m02", "m12", "m22"
|
"row 3", "m02", "m12", "m22"
|
||||||
"row 4", "m03", "m13", "m23"
|
"row 4", "m03", "m13", "m23"
|
||||||
|
|
||||||
.. csv-table:: column vec3 (1x3)
|
.. csv-table:: column vec3 (1x3) **(v)**
|
||||||
:header: "", "column 1"
|
:header: "", "column 1"
|
||||||
|
|
||||||
"row 1", "v0"
|
"row 1", "v0"
|
||||||
"row 2", "v1"
|
"row 2", "v1"
|
||||||
"row 3", "v2"
|
"row 3", "v2"
|
||||||
|
|
||||||
.. csv-table:: column vec4 (1x4)
|
.. csv-table:: column vec4 (1x4) **(dest)**
|
||||||
:header: "", "column 1"
|
:header: "", "column 1"
|
||||||
|
|
||||||
"row 1", "m00 * v0 + m10 * v1 + m20 * v2"
|
"row 1", "m00 * v0 + m10 * v1 + m20 * v2"
|
||||||
@@ -130,18 +186,41 @@ Functions documentation
|
|||||||
"row 3", "m02 * v0 + m12 * v1 + m22 * v2"
|
"row 3", "m02 * v0 + m12 * v1 + m22 * v2"
|
||||||
"row 4", "m03 * v0 + m13 * v1 + m23 * v2"
|
"row 4", "m03 * v0 + m13 * v1 + m23 * v2"
|
||||||
|
|
||||||
.. c:function:: void glm_mat3x4_transpose(mat3x4 m, mat4x3 dest)
|
.. c:function:: void glm_mat3x4_transpose(mat3x4 src, mat4x3 dest)
|
||||||
|
|
||||||
transpose matrix and store in dest
|
Transpose mat3x4 (src) and store in mat4x3 (dest).
|
||||||
|
|
||||||
Parameters:
|
Parameters:
|
||||||
| *[in]* **m** matrix
|
| *[in]* **src** mat3x4 (left)
|
||||||
| *[out]* **dest** destination
|
| *[out]* **dest** destination (result, mat4x3)
|
||||||
|
|
||||||
|
.. csv-table:: mat3x4 **(src)**
|
||||||
|
:header: "", "column 1", "column 2", "column 3"
|
||||||
|
|
||||||
|
"row 1", "a00", "a10", "a20"
|
||||||
|
"row 2", "a01", "a11", "a21"
|
||||||
|
"row 3", "a02", "a12", "a22"
|
||||||
|
"row 4", "a03", "a13", "a23"
|
||||||
|
|
||||||
|
.. csv-table:: mat4x3 **(dest)**
|
||||||
|
:header: "", "column 1", "column 2", "column 3", "column 4"
|
||||||
|
|
||||||
|
"row 1", "b00 = a00", "b10 = a01", "b20 = a02", "b30 = a03"
|
||||||
|
"row 2", "b01 = a10", "b11 = a11", "b21 = a12", "b31 = a13"
|
||||||
|
"row 3", "b02 = a20", "b12 = a21", "b22 = a22", "b32 = a23"
|
||||||
|
|
||||||
.. c:function:: void glm_mat3x4_scale(mat3x4 m, float s)
|
.. c:function:: void glm_mat3x4_scale(mat3x4 m, float s)
|
||||||
|
|
||||||
multiply matrix with scalar
|
Multiply mat3x4 (m) by scalar constant (s).
|
||||||
|
|
||||||
Parameters:
|
Parameters:
|
||||||
| *[in, out]* **m** matrix
|
| *[in, out]* **m** mat3x4 (src, dest)
|
||||||
| *[in]* **s** scalar
|
| *[in]* **s** float (scalar)
|
||||||
|
|
||||||
|
.. csv-table:: mat3x4 **(m)**
|
||||||
|
:header: "", "column 1", "column 2", "column 3"
|
||||||
|
|
||||||
|
"row 1", "m00 = m00 * s", "m10 = m10 * s", "m20 = m20 * s"
|
||||||
|
"row 2", "m01 = m01 * s", "m11 = m11 * s", "m21 = m21 * s"
|
||||||
|
"row 3", "m02 = m02 * s", "m12 = m12 * s", "m22 = m22 * s"
|
||||||
|
"row 4", "m03 = m03 * s", "m13 = m13 * s", "m23 = m23 * s"
|
||||||
|
|||||||
@@ -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
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
@@ -143,7 +144,7 @@ Functions documentation
|
|||||||
|
|
||||||
.. code-block:: c
|
.. code-block:: c
|
||||||
|
|
||||||
mat m1, m2, m3, m4, res;
|
mat4 m1, m2, m3, m4, res;
|
||||||
glm_mat4_mulN((mat4 *[]){&m1, &m2, &m3, &m4}, 4, res);
|
glm_mat4_mulN((mat4 *[]){&m1, &m2, &m3, &m4}, 4, res);
|
||||||
|
|
||||||
Parameters:
|
Parameters:
|
||||||
@@ -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
|
||||||
|
|||||||
@@ -35,51 +35,93 @@ Represented
|
|||||||
Functions documentation
|
Functions documentation
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
.. c:function:: void glm_mat4x2_copy(mat4x2 mat, mat4x2 dest)
|
.. c:function:: void glm_mat4x2_copy(mat4x2 src, mat4x2 dest)
|
||||||
|
|
||||||
copy mat4x2 to another one (dest).
|
Copy mat4x2 (src) to mat4x2 (dest).
|
||||||
|
|
||||||
Parameters:
|
Parameters:
|
||||||
| *[in]* **mat** source
|
| *[in]* **src** mat4x2 (left)
|
||||||
| *[out]* **dest** destination
|
| *[out]* **dest** destination (result, mat4x2)
|
||||||
|
|
||||||
.. c:function:: void glm_mat4x2_zero(mat4x2 mat)
|
.. csv-table:: mat4x2 **(src)**
|
||||||
|
:header: "", "column 1", "column 2", "column 3", "column 4"
|
||||||
|
|
||||||
make given matrix zero
|
"row 1", "a00", "a10", "a20", "a30"
|
||||||
|
"row 2", "a01", "a11", "a21", "a31"
|
||||||
|
|
||||||
|
.. csv-table:: ma4x2 **(dest)**
|
||||||
|
:header: "", "column 1", "column 2", "column 3", "column 4"
|
||||||
|
|
||||||
|
"row 1", "b00 = a00", "b10 = a10", "b20 = a20", "b30 = a30"
|
||||||
|
"row 2", "b01 = a01", "b11 = a11", "b21 = a21", "b31 = a31"
|
||||||
|
|
||||||
|
.. c:function:: void glm_mat4x2_zero(mat4x2 m)
|
||||||
|
|
||||||
|
Zero out the mat4x2 (m).
|
||||||
|
|
||||||
Parameters:
|
Parameters:
|
||||||
| *[in,out]* **mat** matrix
|
| *[in, out]* **m** mat4x2 (src, dest)
|
||||||
|
|
||||||
|
.. csv-table:: mat4x2 **(m)**
|
||||||
|
:header: "", "column 1", "column 2", "column 3", "column 4"
|
||||||
|
|
||||||
|
"row 1", "0.00", "2.00", "15.00", "44.00"
|
||||||
|
"row 2", "5.00", "4.00", "6.00", "12.00"
|
||||||
|
|
||||||
|
.. csv-table:: mat4x2 **(m)**
|
||||||
|
:header: "", "column 1", "column 2", "column 3", "column 4"
|
||||||
|
|
||||||
|
"row 1", "0.00", "0.00", "0.00", "0.00"
|
||||||
|
"row 2", "0.00", "0.00", "0.00", "0.00"
|
||||||
|
|
||||||
.. c:function:: void glm_mat4x2_make(const float * __restrict src, mat4x2 dest)
|
.. c:function:: void glm_mat4x2_make(const float * __restrict src, mat4x2 dest)
|
||||||
|
|
||||||
Create mat4x2 matrix from pointer
|
Create mat4x2 (dest) from pointer (src).
|
||||||
|
|
||||||
.. note:: **@src** must contain at least 8 elements.
|
.. note:: **@src** must contain at least 8 elements.
|
||||||
|
|
||||||
Parameters:
|
Parameters:
|
||||||
| *[in]* **src** pointer to an array of floats
|
| *[in]* **src** pointer to an array of floats (left)
|
||||||
| *[out]* **dest** destination matrix4x2
|
| *[out]* **dest** destination (result, mat4x2)
|
||||||
|
|
||||||
|
.. csv-table:: float array (1x8) **(src)**
|
||||||
|
:header: "", "column 1"
|
||||||
|
|
||||||
|
"row 1", "v0"
|
||||||
|
"row 2", "v1"
|
||||||
|
"row 3", "v2"
|
||||||
|
"row 4", "v3"
|
||||||
|
"row 5", "v4"
|
||||||
|
"row 6", "v5"
|
||||||
|
"row 7", "v6"
|
||||||
|
"row 8", "v7"
|
||||||
|
|
||||||
|
.. csv-table:: mat4x2 **(dest)**
|
||||||
|
:header: "", "column 1", "column 2", "column 3", "column 4"
|
||||||
|
|
||||||
|
"row 1", "v0", "v2", "v4", "v6"
|
||||||
|
"row 2", "v1", "v3", "v5", "v7"
|
||||||
|
|
||||||
.. c:function:: void glm_mat4x2_mul(mat4x2 m1, mat2x4 m2, mat2 dest)
|
.. c:function:: void glm_mat4x2_mul(mat4x2 m1, mat2x4 m2, mat2 dest)
|
||||||
|
|
||||||
multiply m1 and m2 to dest
|
Multiply mat4x2 (m1) by mat2x4 (m2) and store in mat2 (dest).
|
||||||
|
|
||||||
.. code-block:: c
|
.. code-block:: c
|
||||||
|
|
||||||
glm_mat4x2_mul(mat4x2, mat2x4, mat2);
|
glm_mat4x2_mul(mat4x2, mat2x4, mat2);
|
||||||
|
|
||||||
Parameters:
|
Parameters:
|
||||||
| *[in]* **m1** left matrix (mat4x2)
|
| *[in]* **m1** mat4x2 (left)
|
||||||
| *[in]* **m2** right matrix (mat2x4)
|
| *[in]* **m2** mat2x4 (right)
|
||||||
| *[out]* **dest** destination matrix (mat2)
|
| *[out]* **dest** destination (result, mat2)
|
||||||
|
|
||||||
.. csv-table:: mat4x2
|
.. csv-table:: mat4x2 **(m1)**
|
||||||
:header: "", "column 1", "column 2", "column 3", "column 4"
|
:header: "", "column 1", "column 2", "column 3", "column 4"
|
||||||
|
|
||||||
"row 1", "a00", "a10", "a20", "a30"
|
"row 1", "a00", "a10", "a20", "a30"
|
||||||
"row 2", "a01", "a11", "a21", "a31"
|
"row 2", "a01", "a11", "a21", "a31"
|
||||||
|
|
||||||
.. csv-table:: mat2x4
|
.. csv-table:: mat2x4 **(m2)**
|
||||||
:header: "", "column 1", "column 2"
|
:header: "", "column 1", "column 2"
|
||||||
|
|
||||||
"row 1", "b00", "b10"
|
"row 1", "b00", "b10"
|
||||||
@@ -87,7 +129,7 @@ Functions documentation
|
|||||||
"row 3", "b02", "b12"
|
"row 3", "b02", "b12"
|
||||||
"row 4", "b03", "b13"
|
"row 4", "b03", "b13"
|
||||||
|
|
||||||
.. csv-table:: mat2x2
|
.. csv-table:: mat2x2 **(dest)**
|
||||||
:header: "", "column 1", "column 2"
|
:header: "", "column 1", "column 2"
|
||||||
|
|
||||||
"row 1", "a00 * b00 + a10 * b01 + a20 * b02 + a30 * b03", "a00 * b10 + a10 * b11 + a20 * b12 + a30 * b13"
|
"row 1", "a00 * b00 + a10 * b01 + a20 * b02 + a30 * b03", "a00 * b10 + a10 * b11 + a20 * b12 + a30 * b13"
|
||||||
@@ -95,22 +137,20 @@ Functions documentation
|
|||||||
|
|
||||||
.. c:function:: void glm_mat4x2_mulv(mat4x2 m, vec4 v, vec2 dest)
|
.. c:function:: void glm_mat4x2_mulv(mat4x2 m, vec4 v, vec2 dest)
|
||||||
|
|
||||||
multiply mat4x2 with vec4 (column vector) and store in dest vector
|
Multiply mat4x2 (m) by vec4 (v) and store in vec2 (dest).
|
||||||
|
|
||||||
Parameters:
|
Parameters:
|
||||||
| *[in]* **m** mat4x2 (left)
|
| *[in]* **m** mat4x2 (left)
|
||||||
| *[in]* **v** vec4 (right, column vector)
|
| *[in]* **v** vec4 (right, column vector)
|
||||||
| *[out]* **dest** destination (result, column vector)
|
| *[out]* **dest** destination (result, column vector)
|
||||||
|
|
||||||
.. csv-table:: mat4x2
|
.. csv-table:: mat4x2 **(m)**
|
||||||
:header: "", "column 1", "column 2", "column 3"
|
:header: "", "column 1", "column 2", "column 3", "column 4"
|
||||||
|
|
||||||
"row 1", "m00", "m10", "m20"
|
"row 1", "m00", "m10", "m20", "m30"
|
||||||
"row 2", "m01", "m11", "m21"
|
"row 2", "m01", "m11", "m21", "m31"
|
||||||
"row 3", "m02", "m12", "m22"
|
|
||||||
"row 4", "m03", "m13", "m23"
|
|
||||||
|
|
||||||
.. csv-table:: column vec4 (1x4)
|
.. csv-table:: column vec4 (1x4) **(v)**
|
||||||
:header: "", "column 1"
|
:header: "", "column 1"
|
||||||
|
|
||||||
"row 1", "v0"
|
"row 1", "v0"
|
||||||
@@ -118,24 +158,44 @@ Functions documentation
|
|||||||
"row 3", "v2"
|
"row 3", "v2"
|
||||||
"row 4", "v3"
|
"row 4", "v3"
|
||||||
|
|
||||||
.. csv-table:: column vec2 (1x2)
|
.. csv-table:: column vec2 (1x2) **(dest)**
|
||||||
:header: "", "column 1"
|
:header: "", "column 1"
|
||||||
|
|
||||||
"row 1", "m00 * v0 + m10 * v1 + m20 * v2 + m30 * v3"
|
"row 1", "m00 * v0 + m10 * v1 + m20 * v2 + m30 * v3"
|
||||||
"row 2", "m01 * v0 + m11 * v1 + m21 * v2 + m31 * v3"
|
"row 2", "m01 * v0 + m11 * v1 + m21 * v2 + m31 * v3"
|
||||||
|
|
||||||
.. c:function:: void glm_mat4x2_transpose(mat4x2 m, mat2x4 dest)
|
.. c:function:: void glm_mat4x2_transpose(mat4x2 src, mat2x4 dest)
|
||||||
|
|
||||||
transpose matrix and store in dest
|
Transpose mat4x2 (src) and store in mat2x4 (dest).
|
||||||
|
|
||||||
Parameters:
|
Parameters:
|
||||||
| *[in]* **m** matrix
|
| *[in]* **src** mat4x2 (left)
|
||||||
| *[out]* **dest** destination
|
| *[out]* **dest** destination (result, mat2x4)
|
||||||
|
|
||||||
|
.. csv-table:: mat4x2 **(src)**
|
||||||
|
:header: "", "column 1", "column 2", "column 3", "column 4"
|
||||||
|
|
||||||
|
"row 1", "a00", "a10", "a20", "a30"
|
||||||
|
"row 2", "a01", "a11", "a21", "a31"
|
||||||
|
|
||||||
|
.. csv-table:: mat2x4 **(dest)**
|
||||||
|
:header: "", "column 1", "column 2"
|
||||||
|
|
||||||
|
"row 1", "b00 = a00", "b10 = a01"
|
||||||
|
"row 2", "b01 = a10", "b11 = a11"
|
||||||
|
"row 3", "b02 = a20", "b12 = a21"
|
||||||
|
"row 4", "b03 = a30", "b13 = a31"
|
||||||
|
|
||||||
.. c:function:: void glm_mat4x2_scale(mat4x2 m, float s)
|
.. c:function:: void glm_mat4x2_scale(mat4x2 m, float s)
|
||||||
|
|
||||||
multiply matrix with scalar
|
Multiply mat4x2 (m) by scalar constant (s).
|
||||||
|
|
||||||
Parameters:
|
Parameters:
|
||||||
| *[in, out]* **m** matrix
|
| *[in, out]* **m** mat4x2 (src, dest)
|
||||||
| *[in]* **s** scalar
|
| *[in]* **s** float (scalar)
|
||||||
|
|
||||||
|
.. csv-table:: mat4x2 **(m)**
|
||||||
|
:header: "", "column 1", "column 2", "column 3", "column 4"
|
||||||
|
|
||||||
|
"row 1", "m00 = m00 * s", "m10 = m10 * s", "m20 = m20 * s", "m30 = m30 * s"
|
||||||
|
"row 2", "m01 = m01 * s", "m11 = m11 * s", "m21 = m21 * s", "m31 = m31 * s"
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ Represented
|
|||||||
~~~~~~~~~~~
|
~~~~~~~~~~~
|
||||||
|
|
||||||
.. csv-table:: mat4x3
|
.. csv-table:: mat4x3
|
||||||
:header: "", "column 1", "column 2", "column 3", "column4"
|
:header: "", "column 1", "column 2", "column 3", "column 4"
|
||||||
|
|
||||||
"row 1", "m00", "m10", "m20", "m30"
|
"row 1", "m00", "m10", "m20", "m30"
|
||||||
"row 2", "m01", "m11", "m21", "m31"
|
"row 2", "m01", "m11", "m21", "m31"
|
||||||
@@ -36,52 +36,103 @@ Represented
|
|||||||
Functions documentation
|
Functions documentation
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
.. c:function:: void glm_mat4x3_copy(mat4x3 mat, mat4x3 dest)
|
.. c:function:: void glm_mat4x3_copy(mat4x3 src, mat4x3 dest)
|
||||||
|
|
||||||
copy mat4x3 to another one (dest).
|
Copy mat4x3 (src) to mat4x3 (dest).
|
||||||
|
|
||||||
Parameters:
|
Parameters:
|
||||||
| *[in]* **mat** source
|
| *[in]* **src** mat4x3 (left)
|
||||||
| *[out]* **dest** destination
|
| *[out]* **dest** destination (result, mat4x3)
|
||||||
|
|
||||||
.. c:function:: void glm_mat4x3_zero(mat4x3 mat)
|
.. csv-table:: mat4x3 **(src)**
|
||||||
|
|
||||||
make given matrix zero
|
|
||||||
|
|
||||||
Parameters:
|
|
||||||
| *[in,out]* **mat** matrix
|
|
||||||
|
|
||||||
.. c:function:: void glm_mat4x3_make(const float * __restrict src, mat4x3 dest)
|
|
||||||
|
|
||||||
Create mat4x3 matrix from pointer
|
|
||||||
|
|
||||||
.. note:: **@src** must contain at least 12 elements.
|
|
||||||
|
|
||||||
Parameters:
|
|
||||||
| *[in]* **src** pointer to an array of floats
|
|
||||||
| *[out]* **dest** destination matrix4x3
|
|
||||||
|
|
||||||
.. c:function:: void glm_mat4x3_mul(mat4x3 m1, mat3x4 m2, mat3 dest)
|
|
||||||
|
|
||||||
multiply m1 and m2 to dest
|
|
||||||
|
|
||||||
.. code-block:: c
|
|
||||||
|
|
||||||
glm_mat4x3_mul(mat4x3, mat3x4, mat3);
|
|
||||||
|
|
||||||
Parameters:
|
|
||||||
| *[in]* **m1** left matrix (mat4x3)
|
|
||||||
| *[in]* **m2** right matrix (mat3x4)
|
|
||||||
| *[out]* **dest** destination matrix (mat3)
|
|
||||||
|
|
||||||
.. csv-table:: mat4x3
|
|
||||||
:header: "", "column 1", "column 2", "column 3", "column 4"
|
:header: "", "column 1", "column 2", "column 3", "column 4"
|
||||||
|
|
||||||
"row 1", "a00", "a10", "a20", "a30"
|
"row 1", "a00", "a10", "a20", "a30"
|
||||||
"row 2", "a01", "a11", "a21", "a31"
|
"row 2", "a01", "a11", "a21", "a31"
|
||||||
"row 3", "a02", "a12", "a22", "a32"
|
"row 3", "a02", "a12", "a22", "a32"
|
||||||
|
|
||||||
.. csv-table:: mat3x4
|
.. csv-table:: mat4x3 **(dest)**
|
||||||
|
:header: "", "column 1", "column 2", "column 3", "column 4"
|
||||||
|
|
||||||
|
"row 1", "b00 = a00", "b10 = a10", "b20 = a20", "b30 = a30"
|
||||||
|
"row 2", "b01 = a01", "b11 = a11", "b21 = a21", "b31 = a31"
|
||||||
|
"row 3", "b02 = a02", "b12 = a12", "b22 = a22", "b32 = a32"
|
||||||
|
|
||||||
|
.. c:function:: void glm_mat4x3_zero(mat4x3 m)
|
||||||
|
|
||||||
|
Zero out the mat4x3 (m).
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
| *[in, out]* **m** mat4x3 (src, dest)
|
||||||
|
|
||||||
|
.. csv-table:: mat4x3 **(m)**
|
||||||
|
:header: "", "column 1", "column 2", "column 3", "column 4"
|
||||||
|
|
||||||
|
"row 1", "0.00", "2.00", "15.00", "44.00"
|
||||||
|
"row 2", "5.00", "4.00", "6.00", "12.00"
|
||||||
|
"row 3", "88.00", "8.00", "4.30", "15.00"
|
||||||
|
|
||||||
|
.. csv-table:: mat4x3 **(m)**
|
||||||
|
:header: "", "column 1", "column 2", "column 3", "column 4"
|
||||||
|
|
||||||
|
"row 1", "0.00", "0.00", "0.00", "0.00"
|
||||||
|
"row 2", "0.00", "0.00", "0.00", "0.00"
|
||||||
|
"row3", "0.00", "0.00", "0.00", "0.00"
|
||||||
|
|
||||||
|
.. c:function:: void glm_mat4x3_make(const float * __restrict src, mat4x3 dest)
|
||||||
|
|
||||||
|
Create mat4x3 (dest) from pointer (src).
|
||||||
|
|
||||||
|
.. note:: **@src** must contain at least 12 elements.
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
| *[in]* **src** pointer to an array of floats (left)
|
||||||
|
| *[out]* **dest** destination (result, mat4x3)
|
||||||
|
|
||||||
|
.. csv-table:: float array (1x12) **(src)**
|
||||||
|
:header: "", "column 1"
|
||||||
|
|
||||||
|
"row 1", "v0"
|
||||||
|
"row 2", "v1"
|
||||||
|
"row 3", "v2"
|
||||||
|
"row 4", "v3"
|
||||||
|
"row 5", "v4"
|
||||||
|
"row 6", "v5"
|
||||||
|
"row 7", "v6"
|
||||||
|
"row 8", "v7"
|
||||||
|
"row 9", "v8"
|
||||||
|
"row 10", "v9"
|
||||||
|
"row 11", "v10"
|
||||||
|
"row 12", "v11"
|
||||||
|
|
||||||
|
.. csv-table:: mat4x3 **(dest)**
|
||||||
|
:header: "", "column 1", "column 2", "column 3", "column 4"
|
||||||
|
|
||||||
|
"row 1", "v0", "v3", "v6", "v9"
|
||||||
|
"row 2", "v1", "v4", "v7", "v10"
|
||||||
|
"row 3", "v2", "v5", "v8", "v11"
|
||||||
|
|
||||||
|
.. c:function:: void glm_mat4x3_mul(mat4x3 m1, mat3x4 m2, mat3 dest)
|
||||||
|
|
||||||
|
Multiply mat4x3 (m1) by mat3x4 (m2) and store in mat3 (dest).
|
||||||
|
|
||||||
|
.. code-block:: c
|
||||||
|
|
||||||
|
glm_mat4x3_mul(mat4x3, mat3x4, mat3);
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
| *[in]* **m1** mat4x3 (left)
|
||||||
|
| *[in]* **m2** mat3x4 (right)
|
||||||
|
| *[out]* **dest** destination (result, mat3)
|
||||||
|
|
||||||
|
.. csv-table:: mat4x3 **(m1)**
|
||||||
|
:header: "", "column 1", "column 2", "column 3", "column 4"
|
||||||
|
|
||||||
|
"row 1", "a00", "a10", "a20", "a30"
|
||||||
|
"row 2", "a01", "a11", "a21", "a31"
|
||||||
|
"row 3", "a02", "a12", "a22", "a32"
|
||||||
|
|
||||||
|
.. csv-table:: mat3x4 **(m2)**
|
||||||
:header: "", "column 1", "column 2", "column 3"
|
:header: "", "column 1", "column 2", "column 3"
|
||||||
|
|
||||||
"row 1", "b00", "b10", "b20"
|
"row 1", "b00", "b10", "b20"
|
||||||
@@ -89,7 +140,7 @@ Functions documentation
|
|||||||
"row 3", "b02", "b12", "b22"
|
"row 3", "b02", "b12", "b22"
|
||||||
"row 4", "b03", "b13", "b23"
|
"row 4", "b03", "b13", "b23"
|
||||||
|
|
||||||
.. csv-table:: mat3x3
|
.. csv-table:: mat3x3 **(dest)**
|
||||||
:header: "", "column 1", "column 2", "column 3"
|
:header: "", "column 1", "column 2", "column 3"
|
||||||
|
|
||||||
"row 1", "a00 * b00 + a10 * b01 + a20 * b02 + a30 * b03", "a00 * b10 + a10 * b11 + a20 * b12 + a30 * b13", "a00 * b20 + a10 * b21 + a20 * b22 + a30 * b23"
|
"row 1", "a00 * b00 + a10 * b01 + a20 * b02 + a30 * b03", "a00 * b10 + a10 * b11 + a20 * b12 + a30 * b13", "a00 * b20 + a10 * b21 + a20 * b22 + a30 * b23"
|
||||||
@@ -98,21 +149,21 @@ Functions documentation
|
|||||||
|
|
||||||
.. c:function:: void glm_mat4x3_mulv(mat4x3 m, vec4 v, vec3 dest)
|
.. c:function:: void glm_mat4x3_mulv(mat4x3 m, vec4 v, vec3 dest)
|
||||||
|
|
||||||
multiply mat4x3 with vec4 (column vector) and store in dest column vector
|
Multiply mat4x3 (m) by vec4 (v) and store in vec3 (dest).
|
||||||
|
|
||||||
Parameters:
|
Parameters:
|
||||||
| *[in]* **m** mat4x3 (left)
|
| *[in]* **m** mat4x3 (left)
|
||||||
| *[in]* **v** vec4 (right, column vector)
|
| *[in]* **v** vec4 (right, column vector)
|
||||||
| *[out]* **dest** destination (result, column vector)
|
| *[out]* **dest** destination (result, column vector)
|
||||||
|
|
||||||
.. csv-table:: mat4x3
|
.. csv-table:: mat4x3 **(m)**
|
||||||
:header: "", "column 1", "column 2", "column 3", "column 4"
|
:header: "", "column 1", "column 2", "column 3", "column 4"
|
||||||
|
|
||||||
"row 1", "m00", "m10", "m20", "m30"
|
"row 1", "m00", "m10", "m20", "m30"
|
||||||
"row 2", "m01", "m11", "m21", "m31"
|
"row 2", "m01", "m11", "m21", "m31"
|
||||||
"row 3", "m02", "m12", "m22", "m32"
|
"row 3", "m02", "m12", "m22", "m32"
|
||||||
|
|
||||||
.. csv-table:: column vec4 (1x4)
|
.. csv-table:: column vec4 (1x4) **(v)**
|
||||||
:header: "", "column 1"
|
:header: "", "column 1"
|
||||||
|
|
||||||
"row 1", "v0"
|
"row 1", "v0"
|
||||||
@@ -120,25 +171,47 @@ Functions documentation
|
|||||||
"row 3", "v2"
|
"row 3", "v2"
|
||||||
"row 4", "v3"
|
"row 4", "v3"
|
||||||
|
|
||||||
.. csv-table:: column vec3 (1x3)
|
.. csv-table:: column vec3 (1x3) **(dest)**
|
||||||
:header: "", "column 1"
|
:header: "", "column 1"
|
||||||
|
|
||||||
"row 1", "m00 * v0 + m10 * v1 + m20 * v2 + m30 * v3"
|
"row 1", "m00 * v0 + m10 * v1 + m20 * v2 + m30 * v3"
|
||||||
"row 2", "m01 * v0 + m11 * v1 + m21 * v2 + m31 * v3"
|
"row 2", "m01 * v0 + m11 * v1 + m21 * v2 + m31 * v3"
|
||||||
"row 3", "m02 * v0 + m12 * v1 + m22 * v2 + m32 * v3"
|
"row 3", "m02 * v0 + m12 * v1 + m22 * v2 + m32 * v3"
|
||||||
|
|
||||||
.. c:function:: void glm_mat4x3_transpose(mat4x3 m, mat3x4 dest)
|
.. c:function:: void glm_mat4x3_transpose(mat4x3 src, mat3x4 dest)
|
||||||
|
|
||||||
transpose matrix and store in dest
|
Transpose mat4x3 (src) and store in mat3x4 (dest).
|
||||||
|
|
||||||
Parameters:
|
Parameters:
|
||||||
| *[in]* **m** matrix
|
| *[in]* **src** mat4x3 (left)
|
||||||
| *[out]* **dest** destination
|
| *[out]* **dest** destination (result, mat3x4)
|
||||||
|
|
||||||
.. c:function:: void glm_mat4x3_scale(mat4x3 m, float s)
|
.. csv-table:: mat4x3 **(src)**
|
||||||
|
:header: "", "column 1", "column 2", "column 3", "column 4"
|
||||||
|
|
||||||
multiply matrix with scalar
|
"row 1", "a00", "a10", "a20", "a30"
|
||||||
|
"row 2", "a01", "a11", "a21", "a31"
|
||||||
|
"row 3", "a02", "a12", "a22", "a32"
|
||||||
|
|
||||||
|
.. csv-table:: mat3x4 **(dest)**
|
||||||
|
:header: "", "column 1", "column 2", "column 3"
|
||||||
|
|
||||||
|
"row 1", "b00 = a00", "b10 = a01", "b20 = a02"
|
||||||
|
"row 2", "b01 = a10", "b11 = a11", "b21 = a12"
|
||||||
|
"row 3", "b02 = a20", "b12 = a21", "b22 = a22"
|
||||||
|
"row 4", "b03 = a30", "b13 = a31", "b23 = a32"
|
||||||
|
|
||||||
|
.. c:function:: void glm_mat4x3_scale(mat4x3 m, float s)
|
||||||
|
|
||||||
|
Multiply mat4x3 (m) by scalar constant (s).
|
||||||
|
|
||||||
Parameters:
|
Parameters:
|
||||||
| *[in, out]* **m** matrix
|
| *[in, out]* **m** mat4x3 (src, dest)
|
||||||
| *[in]* **s** scalar
|
| *[in]* **s** float (scalar)
|
||||||
|
|
||||||
|
.. csv-table:: mat4x3 **(m)**
|
||||||
|
:header: "", "column 1", "column 2", "column 3", "column 4"
|
||||||
|
|
||||||
|
"row 1", "m00 = m00 * s", "m10 = m10 * s", "m20 = m20 * s", "m30 = m30 * s"
|
||||||
|
"row 2", "m01 = m01 * s", "m11 = m11 * s", "m21 = m21 * s", "m31 = m31 * s"
|
||||||
|
"row 3", "m02 = m02 * s", "m12 = m12 * s", "m22 = m22 * s", "m32 = m32 * s"
|
||||||
|
|||||||
132
include/cglm/affine2d-post.h
Normal file
132
include/cglm/affine2d-post.h
Normal file
@@ -0,0 +1,132 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c), Recep Aslantas.
|
||||||
|
*
|
||||||
|
* MIT License (MIT), http://opensource.org/licenses/MIT
|
||||||
|
* Full license can be found in the LICENSE file
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef cglm_affine2d_post_h
|
||||||
|
#define cglm_affine2d_post_h
|
||||||
|
|
||||||
|
/*
|
||||||
|
Functions:
|
||||||
|
CGLM_INLINE void glm_translated2d(mat3 m, vec2 v);
|
||||||
|
CGLM_INLINE void glm_translated2d_x(mat3 m, float to);
|
||||||
|
CGLM_INLINE void glm_translated2d_y(mat3 m, float to);
|
||||||
|
CGLM_INLINE void glm_rotated2d(mat3 m, float angle);
|
||||||
|
CGLM_INLINE void glm_scaled2d(mat3 m, vec2 v);
|
||||||
|
CGLM_INLINE void glm_scaled2d_uni(mat3 m, float s);
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "vec2.h"
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief translate existing transform matrix by v vector
|
||||||
|
* and store result in same matrix
|
||||||
|
*
|
||||||
|
* this is POST transform, applies to existing transform as last transform
|
||||||
|
*
|
||||||
|
* @param[in, out] m affine transform
|
||||||
|
* @param[in] v translate vector [x, y]
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
void
|
||||||
|
glm_translated2d(mat3 m, vec2 v) {
|
||||||
|
glm_vec2_add(m[2], v, m[2]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief translate existing transform matrix by x factor
|
||||||
|
*
|
||||||
|
* this is POST transform, applies to existing transform as last transform
|
||||||
|
*
|
||||||
|
* @param[in, out] m affine transform
|
||||||
|
* @param[in] x x factor
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
void
|
||||||
|
glm_translated2d_x(mat3 m, float x) {
|
||||||
|
m[2][0] += x;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief translate existing transform matrix by y factor
|
||||||
|
*
|
||||||
|
* this is POST transform, applies to existing transform as last transform
|
||||||
|
*
|
||||||
|
* @param[in, out] m affine transform
|
||||||
|
* @param[in] y y factor
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
void
|
||||||
|
glm_translated2d_y(mat3 m, float y) {
|
||||||
|
m[2][1] += y;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief rotate existing transform matrix by angle
|
||||||
|
*
|
||||||
|
* this is POST transform, applies to existing transform as last transform
|
||||||
|
*
|
||||||
|
* @param[in, out] m affine transform
|
||||||
|
* @param[in] angle angle (radians)
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
void
|
||||||
|
glm_rotated2d(mat3 m, float angle) {
|
||||||
|
float c = cosf(angle),
|
||||||
|
s = sinf(angle),
|
||||||
|
|
||||||
|
m00 = m[0][0], m10 = m[1][0], m20 = m[2][0],
|
||||||
|
m01 = m[0][1], m11 = m[1][1], m21 = m[2][1];
|
||||||
|
|
||||||
|
m[0][0] = c * m00 - s * m01;
|
||||||
|
m[1][0] = c * m10 - s * m11;
|
||||||
|
m[2][0] = c * m20 - s * m21;
|
||||||
|
|
||||||
|
m[0][1] = s * m00 + c * m01;
|
||||||
|
m[1][1] = s * m10 + c * m11;
|
||||||
|
m[2][1] = s * m20 + c * m21;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief scale existing 2d transform matrix by v vector
|
||||||
|
*
|
||||||
|
* this is POST transform, applies to existing transform as last transform
|
||||||
|
*
|
||||||
|
* @param[in, out] m affine transform
|
||||||
|
* @param[in] v scale vector [x, y]
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
void
|
||||||
|
glm_scaled2d(mat3 m, vec2 v) {
|
||||||
|
m[0][0] *= v[0];
|
||||||
|
m[1][0] *= v[0];
|
||||||
|
m[2][0] *= v[0];
|
||||||
|
|
||||||
|
m[0][1] *= v[1];
|
||||||
|
m[1][1] *= v[1];
|
||||||
|
m[2][1] *= v[1];
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief applies uniform scale to existing 2d transform matrix v = [s, s]
|
||||||
|
*
|
||||||
|
* this is POST transform, applies to existing transform as last transform
|
||||||
|
*
|
||||||
|
* @param[in, out] m affine transform
|
||||||
|
* @param[in] s scale factor
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
void
|
||||||
|
glm_scaled2d_uni(mat3 m, float s) {
|
||||||
|
m[0][0] *= s;
|
||||||
|
m[1][0] *= s;
|
||||||
|
m[2][0] *= s;
|
||||||
|
|
||||||
|
m[0][1] *= s;
|
||||||
|
m[1][1] *= s;
|
||||||
|
m[2][1] *= s;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* cglm_affine2d_post_h */
|
||||||
@@ -14,11 +14,12 @@
|
|||||||
&& defined(SIMD_VECTOR_TYPES)
|
&& defined(SIMD_VECTOR_TYPES)
|
||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
#include "struct.h"
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief converts mat4 to Apple's simd type simd_float4x4
|
* @brief converts mat4 to Apple's simd type simd_float4x4
|
||||||
* @return simd_float4x4
|
* @return simd_float4x4
|
||||||
*/
|
*/
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
simd_float4x4
|
simd_float4x4
|
||||||
glm_mat4_applesimd(mat4 m) {
|
glm_mat4_applesimd(mat4 m) {
|
||||||
@@ -83,7 +84,7 @@ glm_vec4_applesimd(vec4 v) {
|
|||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief converts vec3 to Apple's simd type simd_float3
|
* @brief converts vec3 to Apple's simd type simd_float3
|
||||||
* @return v
|
* @return simd_float3
|
||||||
*/
|
*/
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
simd_float3
|
simd_float3
|
||||||
@@ -91,5 +92,45 @@ glm_vec3_applesimd(vec3 v) {
|
|||||||
return (simd_float3){v[0], v[1], v[2]};
|
return (simd_float3){v[0], v[1], v[2]};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief generic function to convert cglm types to Apple's simd types
|
||||||
|
*
|
||||||
|
* Example usage:
|
||||||
|
* simd_float4x4 m = applesimd(mat4_value);
|
||||||
|
* simd_float3 v = applesimd(vec3_value);
|
||||||
|
*
|
||||||
|
* @param x cglm type (mat4, mat3, vec4, vec3)
|
||||||
|
* @return corresponding Apple simd type
|
||||||
|
*/
|
||||||
|
#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L)
|
||||||
|
# define applesimd(x) _Generic((x), \
|
||||||
|
mat4: glm_mat4_applesimd, \
|
||||||
|
mat3: glm_mat3_applesimd, \
|
||||||
|
vec4: glm_vec4_applesimd, \
|
||||||
|
vec3: glm_vec3_applesimd \
|
||||||
|
)((x))
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef cglm_types_struct_h
|
||||||
|
CGLM_INLINE simd_float4x4 glms_mat4_(applesimd)(mat4s m) { return glm_mat4_applesimd(m.raw); }
|
||||||
|
CGLM_INLINE simd_float3x3 glms_mat3_(applesimd)(mat3s m) { return glm_mat3_applesimd(m.raw); }
|
||||||
|
CGLM_INLINE simd_float4 glms_vec4_(applesimd)(vec4s v) { return glm_vec4_applesimd(v.raw); }
|
||||||
|
CGLM_INLINE simd_float3 glms_vec3_(applesimd)(vec3s v) { return glm_vec3_applesimd(v.raw); }
|
||||||
|
|
||||||
|
#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L)
|
||||||
|
# undef applesimd
|
||||||
|
# define applesimd(x) _Generic((x), \
|
||||||
|
mat4: glm_mat4_applesimd, \
|
||||||
|
mat3: glm_mat3_applesimd, \
|
||||||
|
vec4: glm_vec4_applesimd, \
|
||||||
|
vec3: glm_vec3_applesimd, \
|
||||||
|
mat4s: glms_mat4_(applesimd), \
|
||||||
|
mat3s: glms_mat3_(applesimd), \
|
||||||
|
vec4s: glms_vec4_(applesimd), \
|
||||||
|
vec3s: glms_vec3_(applesimd) \
|
||||||
|
)((x))
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
#endif /* cglm_applesimd_h */
|
#endif /* cglm_applesimd_h */
|
||||||
|
|||||||
@@ -51,6 +51,10 @@ CGLM_EXPORT
|
|||||||
void
|
void
|
||||||
glmc_perspective(float fovy, float aspect, float nearZ, float farZ, mat4 dest);
|
glmc_perspective(float fovy, float aspect, float nearZ, float farZ, mat4 dest);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_perspective_infinite(float fovy, float aspect, float nearZ, mat4 dest);
|
||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
void
|
void
|
||||||
glmc_persp_move_far(mat4 proj, float deltaFar);
|
glmc_persp_move_far(mat4 proj, float deltaFar);
|
||||||
@@ -59,6 +63,10 @@ CGLM_EXPORT
|
|||||||
void
|
void
|
||||||
glmc_perspective_default(float aspect, mat4 dest);
|
glmc_perspective_default(float aspect, mat4 dest);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_perspective_default_infinite(float aspect, mat4 dest);
|
||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
void
|
void
|
||||||
glmc_perspective_resize(float aspect, mat4 proj);
|
glmc_perspective_resize(float aspect, mat4 proj);
|
||||||
|
|||||||
@@ -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
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,11 +15,11 @@ extern "C" {
|
|||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
void
|
void
|
||||||
glmc_mat2x3_copy(mat2x3 mat, mat2x3 dest);
|
glmc_mat2x3_copy(mat2x3 src, mat2x3 dest);
|
||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
void
|
void
|
||||||
glmc_mat2x3_zero(mat2x3 mat);
|
glmc_mat2x3_zero(mat2x3 m);
|
||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
void
|
void
|
||||||
@@ -35,7 +35,7 @@ glmc_mat2x3_mulv(mat2x3 m, vec2 v, vec3 dest);
|
|||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
void
|
void
|
||||||
glmc_mat2x3_transpose(mat2x3 m, mat3x2 dest);
|
glmc_mat2x3_transpose(mat2x3 src, mat3x2 dest);
|
||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
void
|
void
|
||||||
|
|||||||
@@ -15,11 +15,11 @@ extern "C" {
|
|||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
void
|
void
|
||||||
glmc_mat2x4_copy(mat2x4 mat, mat2x4 dest);
|
glmc_mat2x4_copy(mat2x4 src, mat2x4 dest);
|
||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
void
|
void
|
||||||
glmc_mat2x4_zero(mat2x4 mat);
|
glmc_mat2x4_zero(mat2x4 m);
|
||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
void
|
void
|
||||||
@@ -35,7 +35,7 @@ glmc_mat2x4_mulv(mat2x4 m, vec2 v, vec4 dest);
|
|||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
void
|
void
|
||||||
glmc_mat2x4_transpose(mat2x4 m, mat4x2 dest);
|
glmc_mat2x4_transpose(mat2x4 src, mat4x2 dest);
|
||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
void
|
void
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -15,11 +15,11 @@ extern "C" {
|
|||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
void
|
void
|
||||||
glmc_mat3x2_copy(mat3x2 mat, mat3x2 dest);
|
glmc_mat3x2_copy(mat3x2 src, mat3x2 dest);
|
||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
void
|
void
|
||||||
glmc_mat3x2_zero(mat3x2 mat);
|
glmc_mat3x2_zero(mat3x2 m);
|
||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
void
|
void
|
||||||
@@ -35,7 +35,7 @@ glmc_mat3x2_mulv(mat3x2 m, vec3 v, vec2 dest);
|
|||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
void
|
void
|
||||||
glmc_mat3x2_transpose(mat3x2 m, mat2x3 dest);
|
glmc_mat3x2_transpose(mat3x2 src, mat2x3 dest);
|
||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
void
|
void
|
||||||
|
|||||||
@@ -15,11 +15,11 @@ extern "C" {
|
|||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
void
|
void
|
||||||
glmc_mat3x4_copy(mat3x4 mat, mat3x4 dest);
|
glmc_mat3x4_copy(mat3x4 src, mat3x4 dest);
|
||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
void
|
void
|
||||||
glmc_mat3x4_zero(mat3x4 mat);
|
glmc_mat3x4_zero(mat3x4 m);
|
||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
void
|
void
|
||||||
@@ -35,7 +35,7 @@ glmc_mat3x4_mulv(mat3x4 m, vec3 v, vec4 dest);
|
|||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
void
|
void
|
||||||
glmc_mat3x4_transpose(mat3x4 m, mat4x3 dest);
|
glmc_mat3x4_transpose(mat3x4 src, mat4x3 dest);
|
||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
void
|
void
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -15,11 +15,11 @@ extern "C" {
|
|||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
void
|
void
|
||||||
glmc_mat4x2_copy(mat4x2 mat, mat4x2 dest);
|
glmc_mat4x2_copy(mat4x2 src, mat4x2 dest);
|
||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
void
|
void
|
||||||
glmc_mat4x2_zero(mat4x2 mat);
|
glmc_mat4x2_zero(mat4x2 m);
|
||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
void
|
void
|
||||||
@@ -35,7 +35,7 @@ glmc_mat4x2_mulv(mat4x2 m, vec4 v, vec2 dest);
|
|||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
void
|
void
|
||||||
glmc_mat4x2_transpose(mat4x2 m, mat2x4 dest);
|
glmc_mat4x2_transpose(mat4x2 src, mat2x4 dest);
|
||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
void
|
void
|
||||||
|
|||||||
@@ -15,11 +15,11 @@ extern "C" {
|
|||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
void
|
void
|
||||||
glmc_mat4x3_copy(mat4x3 mat, mat4x3 dest);
|
glmc_mat4x3_copy(mat4x3 src, mat4x3 dest);
|
||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
void
|
void
|
||||||
glmc_mat4x3_zero(mat4x3 mat);
|
glmc_mat4x3_zero(mat4x3 m);
|
||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
void
|
void
|
||||||
@@ -35,7 +35,7 @@ glmc_mat4x3_mulv(mat4x3 m, vec4 v, vec3 dest);
|
|||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
void
|
void
|
||||||
glmc_mat4x3_transpose(mat4x3 m, mat3x4 dest);
|
glmc_mat4x3_transpose(mat4x3 src, mat3x4 dest);
|
||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
void
|
void
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -25,7 +25,12 @@
|
|||||||
float nearZ,
|
float nearZ,
|
||||||
float farZ,
|
float farZ,
|
||||||
mat4 dest)
|
mat4 dest)
|
||||||
|
CGLM_INLINE void glm_perspective_infinite(float fovy,
|
||||||
|
float aspect,
|
||||||
|
float nearZ,
|
||||||
|
mat4 dest)
|
||||||
CGLM_INLINE void glm_perspective_default(float aspect, mat4 dest)
|
CGLM_INLINE void glm_perspective_default(float aspect, mat4 dest)
|
||||||
|
CGLM_INLINE void glm_perspective_default_infinite(float aspect, mat4 dest)
|
||||||
CGLM_INLINE void glm_perspective_resize(float aspect, mat4 proj)
|
CGLM_INLINE void glm_perspective_resize(float aspect, mat4 proj)
|
||||||
CGLM_INLINE void glm_lookat(vec3 eye, vec3 center, vec3 up, mat4 dest)
|
CGLM_INLINE void glm_lookat(vec3 eye, vec3 center, vec3 up, mat4 dest)
|
||||||
CGLM_INLINE void glm_look(vec3 eye, vec3 dir, vec3 up, mat4 dest)
|
CGLM_INLINE void glm_look(vec3 eye, vec3 dir, vec3 up, mat4 dest)
|
||||||
@@ -87,7 +92,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief set up perspective peprojection matrix
|
* @brief set up perspective projection matrix
|
||||||
*
|
*
|
||||||
* @param[in] left viewport.left
|
* @param[in] left viewport.left
|
||||||
* @param[in] right viewport.right
|
* @param[in] right viewport.right
|
||||||
@@ -274,6 +279,28 @@ glm_perspective(float fovy, float aspect, float nearZ, float farZ, mat4 dest) {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief set up perspective projection matrix with infinite far plane
|
||||||
|
*
|
||||||
|
* @param[in] fovy field of view angle
|
||||||
|
* @param[in] aspect aspect ratio ( width / height )
|
||||||
|
* @param[in] nearZ near clipping plane
|
||||||
|
* @param[out] dest result matrix
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
void
|
||||||
|
glm_perspective_infinite(float fovy, float aspect, float nearZ, mat4 dest) {
|
||||||
|
#if CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_LH_ZO
|
||||||
|
glm_perspective_infinite_lh_zo(fovy, aspect, nearZ, dest);
|
||||||
|
#elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_LH_NO
|
||||||
|
glm_perspective_infinite_lh_no(fovy, aspect, nearZ, dest);
|
||||||
|
#elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_RH_ZO
|
||||||
|
glm_perspective_infinite_rh_zo(fovy, aspect, nearZ, dest);
|
||||||
|
#elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_RH_NO
|
||||||
|
glm_perspective_infinite_rh_no(fovy, aspect, nearZ, dest);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief extend perspective projection matrix's far distance
|
* @brief extend perspective projection matrix's far distance
|
||||||
*
|
*
|
||||||
@@ -317,6 +344,27 @@ glm_perspective_default(float aspect, mat4 dest) {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief set up infinite perspective projection matrix with default near
|
||||||
|
* and angle values
|
||||||
|
*
|
||||||
|
* @param[in] aspect aspect ratio ( width / height )
|
||||||
|
* @param[out] dest result matrix
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
void
|
||||||
|
glm_perspective_default_infinite(float aspect, mat4 dest) {
|
||||||
|
#if CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_LH_ZO
|
||||||
|
glm_perspective_default_infinite_lh_zo(aspect, dest);
|
||||||
|
#elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_LH_NO
|
||||||
|
glm_perspective_default_infinite_lh_no(aspect, dest);
|
||||||
|
#elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_RH_ZO
|
||||||
|
glm_perspective_default_infinite_rh_zo(aspect, dest);
|
||||||
|
#elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_RH_NO
|
||||||
|
glm_perspective_default_infinite_rh_no(aspect, dest);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief resize perspective matrix by aspect ratio ( width / height )
|
* @brief resize perspective matrix by aspect ratio ( width / height )
|
||||||
* this makes very easy to resize proj matrix when window /viewport
|
* this makes very easy to resize proj matrix when window /viewport
|
||||||
|
|||||||
@@ -43,5 +43,6 @@
|
|||||||
#include "bezier.h"
|
#include "bezier.h"
|
||||||
#include "ray.h"
|
#include "ray.h"
|
||||||
#include "affine2d.h"
|
#include "affine2d.h"
|
||||||
|
#include "affine2d-post.h"
|
||||||
|
|
||||||
#endif /* cglm_h */
|
#endif /* cglm_h */
|
||||||
|
|||||||
@@ -16,7 +16,12 @@
|
|||||||
float nearZ,
|
float nearZ,
|
||||||
float farZ,
|
float farZ,
|
||||||
mat4 dest)
|
mat4 dest)
|
||||||
|
CGLM_INLINE void glm_perspective_infinite_lh_no(float fovy,
|
||||||
|
float aspect,
|
||||||
|
float nearZ,
|
||||||
|
mat4 dest)
|
||||||
CGLM_INLINE void glm_perspective_default_lh_no(float aspect, mat4 dest)
|
CGLM_INLINE void glm_perspective_default_lh_no(float aspect, mat4 dest)
|
||||||
|
CGLM_INLINE void glm_perspective_default_infinite_lh_no(float aspect, mat4 dest)
|
||||||
CGLM_INLINE void glm_perspective_resize_lh_no(float aspect, mat4 proj)
|
CGLM_INLINE void glm_perspective_resize_lh_no(float aspect, mat4 proj)
|
||||||
CGLM_INLINE void glm_persp_move_far_lh_no(mat4 proj,
|
CGLM_INLINE void glm_persp_move_far_lh_no(mat4 proj,
|
||||||
float deltaFar)
|
float deltaFar)
|
||||||
@@ -116,7 +121,35 @@ glm_perspective_lh_no(float fovy,
|
|||||||
dest[2][2] =-(nearZ + farZ) * fn;
|
dest[2][2] =-(nearZ + farZ) * fn;
|
||||||
dest[2][3] = 1.0f;
|
dest[2][3] = 1.0f;
|
||||||
dest[3][2] = 2.0f * nearZ * farZ * fn;
|
dest[3][2] = 2.0f * nearZ * farZ * fn;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief set up infinite perspective projection matrix
|
||||||
|
* with a left-hand coordinate system and a
|
||||||
|
* clip-space of [-1, 1].
|
||||||
|
*
|
||||||
|
* @param[in] fovy field of view angle
|
||||||
|
* @param[in] aspect aspect ratio ( width / height )
|
||||||
|
* @param[in] nearZ near clipping plane
|
||||||
|
* @param[out] dest result matrix
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
void
|
||||||
|
glm_perspective_infinite_lh_no(float fovy,
|
||||||
|
float aspect,
|
||||||
|
float nearZ,
|
||||||
|
mat4 dest) {
|
||||||
|
float f;
|
||||||
|
|
||||||
|
glm_mat4_zero(dest);
|
||||||
|
|
||||||
|
f = 1.0f / tanf(fovy * 0.5f);
|
||||||
|
|
||||||
|
dest[0][0] = f / aspect;
|
||||||
|
dest[1][1] = f;
|
||||||
|
dest[2][2] = 1.0f;
|
||||||
|
dest[2][3] = 1.0f;
|
||||||
|
dest[3][2] =-2.0f * nearZ;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@@ -133,6 +166,20 @@ glm_perspective_default_lh_no(float aspect, mat4 dest) {
|
|||||||
glm_perspective_lh_no(GLM_PI_4f, aspect, 0.01f, 100.0f, dest);
|
glm_perspective_lh_no(GLM_PI_4f, aspect, 0.01f, 100.0f, dest);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief set up infinite perspective projection matrix with default near
|
||||||
|
* and angle values with a left-hand coordinate system and a
|
||||||
|
* clip-space of [-1, 1].
|
||||||
|
*
|
||||||
|
* @param[in] aspect aspect ratio ( width / height )
|
||||||
|
* @param[out] dest result matrix
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
void
|
||||||
|
glm_perspective_default_infinite_lh_no(float aspect, mat4 dest) {
|
||||||
|
glm_perspective_infinite_lh_no(GLM_PI_4f, aspect, 0.01f, dest);
|
||||||
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief resize perspective matrix by aspect ratio ( width / height )
|
* @brief resize perspective matrix by aspect ratio ( width / height )
|
||||||
* this makes very easy to resize proj matrix when window /viewport
|
* this makes very easy to resize proj matrix when window /viewport
|
||||||
|
|||||||
@@ -16,7 +16,12 @@
|
|||||||
float nearZ,
|
float nearZ,
|
||||||
float farZ,
|
float farZ,
|
||||||
mat4 dest)
|
mat4 dest)
|
||||||
|
CGLM_INLINE void glm_perspective_infinite_lh_zo(float fovy,
|
||||||
|
float aspect,
|
||||||
|
float nearZ,
|
||||||
|
mat4 dest)
|
||||||
CGLM_INLINE void glm_perspective_default_lh_zo(float aspect, mat4 dest)
|
CGLM_INLINE void glm_perspective_default_lh_zo(float aspect, mat4 dest)
|
||||||
|
CGLM_INLINE void glm_perspective_default_infinite_lh_zo(float aspect, mat4 dest)
|
||||||
CGLM_INLINE void glm_perspective_resize_lh_zo(float aspect, mat4 proj)
|
CGLM_INLINE void glm_perspective_resize_lh_zo(float aspect, mat4 proj)
|
||||||
CGLM_INLINE void glm_persp_move_far_lh_zo(mat4 proj,
|
CGLM_INLINE void glm_persp_move_far_lh_zo(mat4 proj,
|
||||||
float deltaFar)
|
float deltaFar)
|
||||||
@@ -116,6 +121,35 @@ glm_perspective_lh_zo(float fovy,
|
|||||||
dest[3][2] = nearZ * farZ * fn;
|
dest[3][2] = nearZ * farZ * fn;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief set up infinite perspective projection matrix
|
||||||
|
* with a left-hand coordinate system and a
|
||||||
|
* clip-space of [0, 1].
|
||||||
|
*
|
||||||
|
* @param[in] fovy field of view angle
|
||||||
|
* @param[in] aspect aspect ratio ( width / height )
|
||||||
|
* @param[in] nearZ near clipping plane
|
||||||
|
* @param[out] dest result matrix
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
void
|
||||||
|
glm_perspective_infinite_lh_zo(float fovy,
|
||||||
|
float aspect,
|
||||||
|
float nearZ,
|
||||||
|
mat4 dest) {
|
||||||
|
float f;
|
||||||
|
|
||||||
|
glm_mat4_zero(dest);
|
||||||
|
|
||||||
|
f = 1.0f / tanf(fovy * 0.5f);
|
||||||
|
|
||||||
|
dest[0][0] = f / aspect;
|
||||||
|
dest[1][1] = f;
|
||||||
|
dest[2][2] = 1.0f;
|
||||||
|
dest[2][3] = 1.0f;
|
||||||
|
dest[3][2] =-nearZ;
|
||||||
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief extend perspective projection matrix's far distance with a
|
* @brief extend perspective projection matrix's far distance with a
|
||||||
* left-hand coordinate system and a clip-space with depth values
|
* left-hand coordinate system and a clip-space with depth values
|
||||||
@@ -156,6 +190,20 @@ glm_perspective_default_lh_zo(float aspect, mat4 dest) {
|
|||||||
glm_perspective_lh_zo(GLM_PI_4f, aspect, 0.01f, 100.0f, dest);
|
glm_perspective_lh_zo(GLM_PI_4f, aspect, 0.01f, 100.0f, dest);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief set up infinite perspective projection matrix with default near
|
||||||
|
* and angle values with a left-hand coordinate system and a
|
||||||
|
* clip-space of [0, 1].
|
||||||
|
*
|
||||||
|
* @param[in] aspect aspect ratio ( width / height )
|
||||||
|
* @param[out] dest result matrix
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
void
|
||||||
|
glm_perspective_default_infinite_lh_zo(float aspect, mat4 dest) {
|
||||||
|
glm_perspective_infinite_lh_zo(GLM_PI_4f, aspect, 0.01f, dest);
|
||||||
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief resize perspective matrix by aspect ratio ( width / height )
|
* @brief resize perspective matrix by aspect ratio ( width / height )
|
||||||
* this makes very easy to resize proj matrix when window /viewport
|
* this makes very easy to resize proj matrix when window /viewport
|
||||||
|
|||||||
@@ -16,7 +16,12 @@
|
|||||||
float nearZ,
|
float nearZ,
|
||||||
float farZ,
|
float farZ,
|
||||||
mat4 dest)
|
mat4 dest)
|
||||||
|
CGLM_INLINE void glm_perspective_infinite_rh_no(float fovy,
|
||||||
|
float aspect,
|
||||||
|
float nearZ,
|
||||||
|
mat4 dest)
|
||||||
CGLM_INLINE void glm_perspective_default_rh_no(float aspect, mat4 dest)
|
CGLM_INLINE void glm_perspective_default_rh_no(float aspect, mat4 dest)
|
||||||
|
CGLM_INLINE void glm_perspective_default_infinite_rh_no(float aspect, mat4 dest)
|
||||||
CGLM_INLINE void glm_perspective_resize_rh_no(float aspect, mat4 proj)
|
CGLM_INLINE void glm_perspective_resize_rh_no(float aspect, mat4 proj)
|
||||||
CGLM_INLINE void glm_persp_move_far_rh_no(mat4 proj,
|
CGLM_INLINE void glm_persp_move_far_rh_no(mat4 proj,
|
||||||
float deltaFar)
|
float deltaFar)
|
||||||
@@ -116,7 +121,35 @@ glm_perspective_rh_no(float fovy,
|
|||||||
dest[2][2] = (nearZ + farZ) * fn;
|
dest[2][2] = (nearZ + farZ) * fn;
|
||||||
dest[2][3] =-1.0f;
|
dest[2][3] =-1.0f;
|
||||||
dest[3][2] = 2.0f * nearZ * farZ * fn;
|
dest[3][2] = 2.0f * nearZ * farZ * fn;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief set up infinite perspective projection matrix
|
||||||
|
* with a right-hand coordinate system and a
|
||||||
|
* clip-space of [-1, 1].
|
||||||
|
*
|
||||||
|
* @param[in] fovy field of view angle
|
||||||
|
* @param[in] aspect aspect ratio ( width / height )
|
||||||
|
* @param[in] nearZ near clipping plane
|
||||||
|
* @param[out] dest result matrix
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
void
|
||||||
|
glm_perspective_infinite_rh_no(float fovy,
|
||||||
|
float aspect,
|
||||||
|
float nearZ,
|
||||||
|
mat4 dest) {
|
||||||
|
float f;
|
||||||
|
|
||||||
|
glm_mat4_zero(dest);
|
||||||
|
|
||||||
|
f = 1.0f / tanf(fovy * 0.5f);
|
||||||
|
|
||||||
|
dest[0][0] = f / aspect;
|
||||||
|
dest[1][1] = f;
|
||||||
|
dest[2][2] =-1.0f;
|
||||||
|
dest[2][3] =-1.0f;
|
||||||
|
dest[3][2] =-2.0f * nearZ;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@@ -133,6 +166,20 @@ glm_perspective_default_rh_no(float aspect, mat4 dest) {
|
|||||||
glm_perspective_rh_no(GLM_PI_4f, aspect, 0.01f, 100.0f, dest);
|
glm_perspective_rh_no(GLM_PI_4f, aspect, 0.01f, 100.0f, dest);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief set up infinite perspective projection matrix with default near
|
||||||
|
* and angle values with a right-hand coordinate system and a
|
||||||
|
* clip-space of [-1, 1].
|
||||||
|
*
|
||||||
|
* @param[in] aspect aspect ratio ( width / height )
|
||||||
|
* @param[out] dest result matrix
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
void
|
||||||
|
glm_perspective_default_infinite_rh_no(float aspect, mat4 dest) {
|
||||||
|
glm_perspective_infinite_rh_no(GLM_PI_4f, aspect, 0.01f, dest);
|
||||||
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief resize perspective matrix by aspect ratio ( width / height )
|
* @brief resize perspective matrix by aspect ratio ( width / height )
|
||||||
* this makes very easy to resize proj matrix when window /viewport
|
* this makes very easy to resize proj matrix when window /viewport
|
||||||
|
|||||||
@@ -16,7 +16,12 @@
|
|||||||
float nearZ,
|
float nearZ,
|
||||||
float farZ,
|
float farZ,
|
||||||
mat4 dest)
|
mat4 dest)
|
||||||
|
CGLM_INLINE void glm_perspective_infinite_rh_zo(float fovy,
|
||||||
|
float aspect,
|
||||||
|
float nearZ,
|
||||||
|
mat4 dest)
|
||||||
CGLM_INLINE void glm_perspective_default_rh_zo(float aspect, mat4 dest)
|
CGLM_INLINE void glm_perspective_default_rh_zo(float aspect, mat4 dest)
|
||||||
|
CGLM_INLINE void glm_perspective_default_infinite_rh_zo(float aspect, mat4 dest)
|
||||||
CGLM_INLINE void glm_perspective_resize_rh_zo(float aspect, mat4 proj)
|
CGLM_INLINE void glm_perspective_resize_rh_zo(float aspect, mat4 proj)
|
||||||
CGLM_INLINE void glm_persp_move_far_rh_zo(mat4 proj,
|
CGLM_INLINE void glm_persp_move_far_rh_zo(mat4 proj,
|
||||||
float deltaFar)
|
float deltaFar)
|
||||||
@@ -116,6 +121,35 @@ glm_perspective_rh_zo(float fovy,
|
|||||||
dest[3][2] = nearZ * farZ * fn;
|
dest[3][2] = nearZ * farZ * fn;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief set up infinite perspective projection matrix
|
||||||
|
* with a right-hand coordinate system and a
|
||||||
|
* clip-space of [0, 1].
|
||||||
|
*
|
||||||
|
* @param[in] fovy field of view angle
|
||||||
|
* @param[in] aspect aspect ratio ( width / height )
|
||||||
|
* @param[in] nearZ near clipping plane
|
||||||
|
* @param[out] dest result matrix
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
void
|
||||||
|
glm_perspective_infinite_rh_zo(float fovy,
|
||||||
|
float aspect,
|
||||||
|
float nearZ,
|
||||||
|
mat4 dest) {
|
||||||
|
float f;
|
||||||
|
|
||||||
|
glm_mat4_zero(dest);
|
||||||
|
|
||||||
|
f = 1.0f / tanf(fovy * 0.5f);
|
||||||
|
|
||||||
|
dest[0][0] = f / aspect;
|
||||||
|
dest[1][1] = f;
|
||||||
|
dest[2][2] =-1.0f;
|
||||||
|
dest[2][3] =-1.0f;
|
||||||
|
dest[3][2] =-nearZ;
|
||||||
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief set up perspective projection matrix with default near/far
|
* @brief set up perspective projection matrix with default near/far
|
||||||
* and angle values with a right-hand coordinate system and a
|
* and angle values with a right-hand coordinate system and a
|
||||||
@@ -130,6 +164,20 @@ glm_perspective_default_rh_zo(float aspect, mat4 dest) {
|
|||||||
glm_perspective_rh_zo(GLM_PI_4f, aspect, 0.01f, 100.0f, dest);
|
glm_perspective_rh_zo(GLM_PI_4f, aspect, 0.01f, 100.0f, dest);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief set up infinite perspective projection matrix with default near
|
||||||
|
* and angle values with a right-hand coordinate system and a
|
||||||
|
* clip-space of [0, 1].
|
||||||
|
*
|
||||||
|
* @param[in] aspect aspect ratio ( width / height )
|
||||||
|
* @param[out] dest result matrix
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
void
|
||||||
|
glm_perspective_default_infinite_rh_zo(float aspect, mat4 dest) {
|
||||||
|
glm_perspective_infinite_rh_zo(GLM_PI_4f, aspect, 0.01f, dest);
|
||||||
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief resize perspective matrix by aspect ratio ( width / height )
|
* @brief resize perspective matrix by aspect ratio ( width / height )
|
||||||
* this makes very easy to resize proj matrix when window /viewport
|
* this makes very easy to resize proj matrix when window /viewport
|
||||||
|
|||||||
@@ -8,6 +8,8 @@
|
|||||||
#ifndef cglm_common_h
|
#ifndef cglm_common_h
|
||||||
#define cglm_common_h
|
#define cglm_common_h
|
||||||
|
|
||||||
|
#define __cglm__ 1
|
||||||
|
|
||||||
#ifndef _USE_MATH_DEFINES
|
#ifndef _USE_MATH_DEFINES
|
||||||
# define _USE_MATH_DEFINES /* for windows */
|
# define _USE_MATH_DEFINES /* for windows */
|
||||||
#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,59 +97,57 @@ 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:
|
||||||
*
|
*
|
||||||
* @code
|
* @code
|
||||||
* mat2 m = GLM_MAT2_IDENTITY_INIT;
|
* mat2 m = GLM_MAT2_IDENTITY_INIT;
|
||||||
* 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.
|
||||||
*
|
*
|
||||||
* rmc stands for Row * Matrix * Column
|
* @param[in] m mat2 (src)
|
||||||
*
|
*
|
||||||
* the result is scalar because R * M = Matrix1x2 (row vector),
|
* @return[out] mat2 determinant (float)
|
||||||
* then Matrix1x2 * Vec2 (column vector) = Matrix1x1 (Scalar)
|
*/
|
||||||
|
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:
|
||||||
*
|
*
|
||||||
* @param[in] r row vector or matrix1x2
|
* The sum of the elements on the main diagonal from
|
||||||
* @param[in] m matrix2x2
|
* upper left corner to the bottom right corner.
|
||||||
* @param[in] c column vector or matrix2x1
|
|
||||||
*
|
*
|
||||||
* @return scalar value e.g. Matrix1x1
|
* @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
|
||||||
|
*
|
||||||
|
* the result is scalar because M * C = ResC (1x2, column vector),
|
||||||
|
* then if you take the dot_product(R (2x1), ResC (1x2)) = scalar value.
|
||||||
|
*
|
||||||
|
* @param[in] r vec2 (2x1, row vector)
|
||||||
|
* @param[in] m mat2 (2x2, matrix)
|
||||||
|
* @param[in] c vec2 (1x2, column vector)
|
||||||
|
*
|
||||||
|
* @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 */
|
||||||
|
|||||||
@@ -11,12 +11,12 @@
|
|||||||
GLM_MAT2X3_ZERO
|
GLM_MAT2X3_ZERO
|
||||||
|
|
||||||
Functions:
|
Functions:
|
||||||
CGLM_INLINE void glm_mat2x3_copy(mat2x3 mat, mat2x3 dest);
|
CGLM_INLINE void glm_mat2x3_copy(mat2x3 src, mat2x3 dest);
|
||||||
CGLM_INLINE void glm_mat2x3_zero(mat2x3 mat);
|
CGLM_INLINE void glm_mat2x3_zero(mat2x3 m);
|
||||||
CGLM_INLINE void glm_mat2x3_make(const float * __restrict src, mat2x3 dest);
|
CGLM_INLINE void glm_mat2x3_make(const float * __restrict src, mat2x3 dest);
|
||||||
CGLM_INLINE void glm_mat2x3_mul(mat2x3 m1, mat3x2 m2, mat3 dest);
|
CGLM_INLINE void glm_mat2x3_mul(mat2x3 m1, mat3x2 m2, mat3 dest);
|
||||||
CGLM_INLINE void glm_mat2x3_mulv(mat2x3 m, vec2 v, vec3 dest);
|
CGLM_INLINE void glm_mat2x3_mulv(mat2x3 m, vec2 v, vec3 dest);
|
||||||
CGLM_INLINE void glm_mat2x3_transpose(mat2x3 m, mat3x2 dest);
|
CGLM_INLINE void glm_mat2x3_transpose(mat2x3 src, mat3x2 dest);
|
||||||
CGLM_INLINE void glm_mat2x3_scale(mat2x3 m, float s);
|
CGLM_INLINE void glm_mat2x3_scale(mat2x3 m, float s);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -31,40 +31,35 @@
|
|||||||
#define GLM_MAT2X3_ZERO GLM_MAT2X3_ZERO_INIT
|
#define GLM_MAT2X3_ZERO GLM_MAT2X3_ZERO_INIT
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief copy all members of [mat] to [dest]
|
* @brief Copy mat2x3 (src) to mat2x3 (dest).
|
||||||
*
|
*
|
||||||
* @param[in] mat source
|
* @param[in] src mat2x3 (left)
|
||||||
* @param[out] dest destination
|
* @param[out] dest destination (result, mat2x3)
|
||||||
*/
|
*/
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
void
|
void
|
||||||
glm_mat2x3_copy(mat2x3 mat, mat2x3 dest) {
|
glm_mat2x3_copy(mat2x3 src, mat2x3 dest) {
|
||||||
dest[0][0] = mat[0][0];
|
glm_vec3_copy(src[0], dest[0]);
|
||||||
dest[0][1] = mat[0][1];
|
glm_vec3_copy(src[1], dest[1]);
|
||||||
dest[0][2] = mat[0][2];
|
|
||||||
|
|
||||||
dest[1][0] = mat[1][0];
|
|
||||||
dest[1][1] = mat[1][1];
|
|
||||||
dest[1][2] = mat[1][2];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief make given matrix zero.
|
* @brief Zero out the mat2x3 (m).
|
||||||
*
|
*
|
||||||
* @param[in, out] mat matrix
|
* @param[in, out] mat2x3 (src, dest)
|
||||||
*/
|
*/
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
void
|
void
|
||||||
glm_mat2x3_zero(mat2x3 mat) {
|
glm_mat2x3_zero(mat2x3 m) {
|
||||||
CGLM_ALIGN_MAT mat2x3 t = GLM_MAT2X3_ZERO_INIT;
|
CGLM_ALIGN_MAT mat2x3 t = GLM_MAT2X3_ZERO_INIT;
|
||||||
glm_mat2x3_copy(t, mat);
|
glm_mat2x3_copy(t, m);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief Create mat2x3 matrix from pointer
|
* @brief Create mat2x3 (dest) from pointer (src).
|
||||||
*
|
*
|
||||||
* @param[in] src pointer to an array of floats
|
* @param[in] src pointer to an array of floats (left)
|
||||||
* @param[out] dest matrix
|
* @param[out] dest destination (result, mat2x3)
|
||||||
*/
|
*/
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
void
|
void
|
||||||
@@ -79,15 +74,15 @@ glm_mat2x3_make(const float * __restrict src, mat2x3 dest) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief multiply m1 and m2 to dest
|
* @brief Multiply mat2x3 (m1) by mat3x2 (m2) and store in mat3 (dest).
|
||||||
*
|
*
|
||||||
* @code
|
* @code
|
||||||
* glm_mat2x3_mul(mat2x3, mat3x2, mat3);
|
* glm_mat2x3_mul(mat2x3, mat3x2, mat3);
|
||||||
* @endcode
|
* @endcode
|
||||||
*
|
*
|
||||||
* @param[in] m1 left matrix (mat2x3)
|
* @param[in] m1 mat2x3 (left)
|
||||||
* @param[in] m2 right matrix (mat3x2)
|
* @param[in] m2 mat3x2 (right)
|
||||||
* @param[out] dest destination matrix (mat2)
|
* @param[out] dest destination (result, mat3)
|
||||||
*/
|
*/
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
void
|
void
|
||||||
@@ -113,11 +108,11 @@ glm_mat2x3_mul(mat2x3 m1, mat3x2 m2, mat3 dest) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief multiply matrix with column vector and store in dest vector
|
* @brief Multiply mat2x3 (m) by vec2 (v) and store in vec3 (dest).
|
||||||
*
|
*
|
||||||
* @param[in] m matrix (left)
|
* @param[in] m mat2x3 (left)
|
||||||
* @param[in] v vector (right, column vector)
|
* @param[in] v vec2 (right, column vector)
|
||||||
* @param[out] dest result vector
|
* @param[out] dest destination (result, column vector)
|
||||||
*/
|
*/
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
void
|
void
|
||||||
@@ -130,26 +125,24 @@ glm_mat2x3_mulv(mat2x3 m, vec2 v, vec3 dest) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief transpose matrix and store in dest
|
* @brief Transpose mat2x3 (src) and store in mat3x2 (dest).
|
||||||
*
|
*
|
||||||
* @param[in] m matrix
|
* @param[in] src mat2x3 (left)
|
||||||
* @param[out] dest result
|
* @param[out] dest destination (result, mat3x2)
|
||||||
*/
|
*/
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
void
|
void
|
||||||
glm_mat2x3_transpose(mat2x3 m, mat3x2 dest) {
|
glm_mat2x3_transpose(mat2x3 src, mat3x2 dest) {
|
||||||
dest[0][0] = m[0][0]; dest[0][1] = m[1][0];
|
dest[0][0] = src[0][0]; dest[0][1] = src[1][0];
|
||||||
dest[1][0] = m[0][1]; dest[1][1] = m[1][1];
|
dest[1][0] = src[0][1]; dest[1][1] = src[1][1];
|
||||||
dest[2][0] = m[0][2]; dest[2][1] = m[1][2];
|
dest[2][0] = src[0][2]; dest[2][1] = src[1][2];
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief scale (multiply with scalar) matrix
|
* @brief Multiply mat2x3 (m) by scalar constant (s).
|
||||||
*
|
*
|
||||||
* multiply matrix with scalar
|
* @param[in, out] m (src, dest)
|
||||||
*
|
* @param[in] float (scalar)
|
||||||
* @param[in, out] m matrix
|
|
||||||
* @param[in] s scalar
|
|
||||||
*/
|
*/
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
void
|
void
|
||||||
|
|||||||
@@ -11,12 +11,12 @@
|
|||||||
GLM_MAT2X4_ZERO
|
GLM_MAT2X4_ZERO
|
||||||
|
|
||||||
Functions:
|
Functions:
|
||||||
CGLM_INLINE void glm_mat2x4_copy(mat2x4 mat, mat2x4 dest);
|
CGLM_INLINE void glm_mat2x4_copy(mat2x4 src, mat2x4 dest);
|
||||||
CGLM_INLINE void glm_mat2x4_zero(mat2x4 mat);
|
CGLM_INLINE void glm_mat2x4_zero(mat2x4 m);
|
||||||
CGLM_INLINE void glm_mat2x4_make(const float * __restrict src, mat2x4 dest);
|
CGLM_INLINE void glm_mat2x4_make(const float * __restrict src, mat2x4 dest);
|
||||||
CGLM_INLINE void glm_mat2x4_mul(mat2x4 m1, mat4x2 m2, mat4 dest);
|
CGLM_INLINE void glm_mat2x4_mul(mat2x4 m1, mat4x2 m2, mat4 dest);
|
||||||
CGLM_INLINE void glm_mat2x4_mulv(mat2x4 m, vec2 v, vec4 dest);
|
CGLM_INLINE void glm_mat2x4_mulv(mat2x4 m, vec2 v, vec4 dest);
|
||||||
CGLM_INLINE void glm_mat2x4_transpose(mat2x4 m, mat4x2 dest);
|
CGLM_INLINE void glm_mat2x4_transpose(mat2x4 src, mat4x2 dest);
|
||||||
CGLM_INLINE void glm_mat2x4_scale(mat2x4 m, float s);
|
CGLM_INLINE void glm_mat2x4_scale(mat2x4 m, float s);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -32,35 +32,35 @@
|
|||||||
#define GLM_MAT2X4_ZERO GLM_MAT2X4_ZERO_INIT
|
#define GLM_MAT2X4_ZERO GLM_MAT2X4_ZERO_INIT
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief copy all members of [mat] to [dest]
|
* @brief Copy mat2x4 (src) to mat2x4 (dest).
|
||||||
*
|
*
|
||||||
* @param[in] mat source
|
* @param[in] src mat2x4 (left)
|
||||||
* @param[out] dest destination
|
* @param[out] dest destination (result, mat2x4)
|
||||||
*/
|
*/
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
void
|
void
|
||||||
glm_mat2x4_copy(mat2x4 mat, mat2x4 dest) {
|
glm_mat2x4_copy(mat2x4 src, mat2x4 dest) {
|
||||||
glm_vec4_ucopy(mat[0], dest[0]);
|
glm_vec4_ucopy(src[0], dest[0]);
|
||||||
glm_vec4_ucopy(mat[1], dest[1]);
|
glm_vec4_ucopy(src[1], dest[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief make given matrix zero.
|
* @brief Zero out the mat2x4 (m).
|
||||||
*
|
*
|
||||||
* @param[in, out] mat matrix
|
* @param[in, out] mat2x4 (src, dest)
|
||||||
*/
|
*/
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
void
|
void
|
||||||
glm_mat2x4_zero(mat2x4 mat) {
|
glm_mat2x4_zero(mat2x4 m) {
|
||||||
CGLM_ALIGN_MAT mat2x4 t = GLM_MAT2X4_ZERO_INIT;
|
CGLM_ALIGN_MAT mat2x4 t = GLM_MAT2X4_ZERO_INIT;
|
||||||
glm_mat2x4_copy(t, mat);
|
glm_mat2x4_copy(t, m);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief Create mat2x4 matrix from pointer
|
* @brief Create mat2x4 (dest) from pointer (src).
|
||||||
*
|
*
|
||||||
* @param[in] src pointer to an array of floats
|
* @param[in] src pointer to an array of floats (left)
|
||||||
* @param[out] dest matrix
|
* @param[out] dest destination (result, mat2x4)
|
||||||
*/
|
*/
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
void
|
void
|
||||||
@@ -77,15 +77,15 @@ glm_mat2x4_make(const float * __restrict src, mat2x4 dest) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief multiply m1 and m2 to dest
|
* @brief Multiply mat2x4 (m1) by mat4x2 (m2) and store in mat4 (dest).
|
||||||
*
|
*
|
||||||
* @code
|
* @code
|
||||||
* glm_mat2x4_mul(mat2x4, mat4x2, mat4);
|
* glm_mat2x4_mul(mat2x4, mat4x2, mat4);
|
||||||
* @endcode
|
* @endcode
|
||||||
*
|
*
|
||||||
* @param[in] m1 left matrix (mat2x4)
|
* @param[in] m1 mat2x4 (left)
|
||||||
* @param[in] m2 right matrix (mat4x2)
|
* @param[in] m2 mat4x2 (right)
|
||||||
* @param[out] dest destination matrix (mat4)
|
* @param[out] dest destination (result, mat4)
|
||||||
*/
|
*/
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
void
|
void
|
||||||
@@ -120,11 +120,11 @@ glm_mat2x4_mul(mat2x4 m1, mat4x2 m2, mat4 dest) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief multiply matrix with column vector and store in dest column vector
|
* @brief Multiply mat2x4 (m) by vec2 (v) and store in vec4 (dest).
|
||||||
*
|
*
|
||||||
* @param[in] m matrix (left)
|
* @param[in] m mat2x4 (left)
|
||||||
* @param[in] v vector (right, column vector)
|
* @param[in] v vec2 (right, column vector)
|
||||||
* @param[out] dest result vector
|
* @param[out] dest destination (result, column vector)
|
||||||
*/
|
*/
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
void
|
void
|
||||||
@@ -138,27 +138,25 @@ glm_mat2x4_mulv(mat2x4 m, vec2 v, vec4 dest) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief transpose matrix and store in dest
|
* @brief Transpose mat2x4 (src) and store in mat4x2 (dest).
|
||||||
*
|
*
|
||||||
* @param[in] m matrix
|
* @param[in] src mat2x4 (left)
|
||||||
* @param[out] dest result
|
* @param[out] dest destination (result, mat4x2)
|
||||||
*/
|
*/
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
void
|
void
|
||||||
glm_mat2x4_transpose(mat2x4 m, mat4x2 dest) {
|
glm_mat2x4_transpose(mat2x4 src, mat4x2 dest) {
|
||||||
dest[0][0] = m[0][0]; dest[0][1] = m[1][0];
|
dest[0][0] = src[0][0]; dest[0][1] = src[1][0];
|
||||||
dest[1][0] = m[0][1]; dest[1][1] = m[1][1];
|
dest[1][0] = src[0][1]; dest[1][1] = src[1][1];
|
||||||
dest[2][0] = m[0][2]; dest[2][1] = m[1][2];
|
dest[2][0] = src[0][2]; dest[2][1] = src[1][2];
|
||||||
dest[3][0] = m[0][3]; dest[3][1] = m[1][3];
|
dest[3][0] = src[0][3]; dest[3][1] = src[1][3];
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief scale (multiply with scalar) matrix
|
* @brief Multiply mat2x4 (m) by scalar constant (s).
|
||||||
*
|
*
|
||||||
* multiply matrix with scalar
|
* @param[in, out] m (src, dest)
|
||||||
*
|
* @param[in] s float (scalar)
|
||||||
* @param[in, out] m matrix
|
|
||||||
* @param[in] s scalar
|
|
||||||
*/
|
*/
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
void
|
void
|
||||||
|
|||||||
@@ -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 */
|
||||||
|
|||||||
@@ -11,12 +11,12 @@
|
|||||||
GLM_MAT3X2_ZERO
|
GLM_MAT3X2_ZERO
|
||||||
|
|
||||||
Functions:
|
Functions:
|
||||||
CGLM_INLINE void glm_mat3x2_copy(mat3x2 mat, mat3x2 dest);
|
CGLM_INLINE void glm_mat3x2_copy(mat3x2 src, mat3x2 dest);
|
||||||
CGLM_INLINE void glm_mat3x2_zero(mat3x2 mat);
|
CGLM_INLINE void glm_mat3x2_zero(mat3x2 m);
|
||||||
CGLM_INLINE void glm_mat3x2_make(const float * __restrict src, mat3x2 dest);
|
CGLM_INLINE void glm_mat3x2_make(const float * __restrict src, mat3x2 dest);
|
||||||
CGLM_INLINE void glm_mat3x2_mul(mat3x2 m1, mat2x3 m2, mat2 dest);
|
CGLM_INLINE void glm_mat3x2_mul(mat3x2 m1, mat2x3 m2, mat2 dest);
|
||||||
CGLM_INLINE void glm_mat3x2_mulv(mat3x2 m, vec3 v, vec2 dest);
|
CGLM_INLINE void glm_mat3x2_mulv(mat3x2 m, vec3 v, vec2 dest);
|
||||||
CGLM_INLINE void glm_mat3x2_transpose(mat3x2 m, mat2x3 dest);
|
CGLM_INLINE void glm_mat3x2_transpose(mat3x2 src, mat2x3 dest);
|
||||||
CGLM_INLINE void glm_mat3x2_scale(mat3x2 m, float s);
|
CGLM_INLINE void glm_mat3x2_scale(mat3x2 m, float s);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -31,41 +31,36 @@
|
|||||||
#define GLM_MAT3X2_ZERO GLM_MAT3X2_ZERO_INIT
|
#define GLM_MAT3X2_ZERO GLM_MAT3X2_ZERO_INIT
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief copy all members of [mat] to [dest]
|
* @brief Copy mat3x2 (src) to mat3x2 (dest).
|
||||||
*
|
*
|
||||||
* @param[in] mat source
|
* @param[in] src mat3x2 (left)
|
||||||
* @param[out] dest destination
|
* @param[out] dest destination (result, mat3x2)
|
||||||
*/
|
*/
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
void
|
void
|
||||||
glm_mat3x2_copy(mat3x2 mat, mat3x2 dest) {
|
glm_mat3x2_copy(mat3x2 src, mat3x2 dest) {
|
||||||
dest[0][0] = mat[0][0];
|
glm_vec2_copy(src[0], dest[0]);
|
||||||
dest[0][1] = mat[0][1];
|
glm_vec2_copy(src[1], dest[1]);
|
||||||
|
glm_vec2_copy(src[2], dest[2]);
|
||||||
dest[1][0] = mat[1][0];
|
|
||||||
dest[1][1] = mat[1][1];
|
|
||||||
|
|
||||||
dest[2][0] = mat[2][0];
|
|
||||||
dest[2][1] = mat[2][1];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief make given matrix zero.
|
* @brief Zero out the mat3x2 (m).
|
||||||
*
|
*
|
||||||
* @param[in, out] mat matrix
|
* @param[in, out] mat3x2 (src, dest)
|
||||||
*/
|
*/
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
void
|
void
|
||||||
glm_mat3x2_zero(mat3x2 mat) {
|
glm_mat3x2_zero(mat3x2 m) {
|
||||||
CGLM_ALIGN_MAT mat3x2 t = GLM_MAT3X2_ZERO_INIT;
|
CGLM_ALIGN_MAT mat3x2 t = GLM_MAT3X2_ZERO_INIT;
|
||||||
glm_mat3x2_copy(t, mat);
|
glm_mat3x2_copy(t, m);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief Create mat3x2 matrix from pointer
|
* @brief Create mat3x2 (dest) from pointer (src).
|
||||||
*
|
*
|
||||||
* @param[in] src pointer to an array of floats
|
* @param[in] src pointer to an array of floats (left)
|
||||||
* @param[out] dest matrix
|
* @param[out] dest destination (result, mat3x2)
|
||||||
*/
|
*/
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
void
|
void
|
||||||
@@ -81,15 +76,15 @@ glm_mat3x2_make(const float * __restrict src, mat3x2 dest) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief multiply m1 and m2 to dest
|
* @brief Multiply mat3x2 (m1) by mat2x3 (m2) and store in mat2 (dest).
|
||||||
*
|
*
|
||||||
* @code
|
* @code
|
||||||
* glm_mat3x2_mul(mat3x2, mat2x3, mat2);
|
* glm_mat3x2_mul(mat3x2, mat2x3, mat2);
|
||||||
* @endcode
|
* @endcode
|
||||||
*
|
*
|
||||||
* @param[in] m1 left matrix (mat3x2)
|
* @param[in] m1 mat3x2 (left)
|
||||||
* @param[in] m2 right matrix (mat2x3)
|
* @param[in] m2 mat2x3 (right)
|
||||||
* @param[out] dest destination matrix (mat2)
|
* @param[out] dest destination (result, mat2)
|
||||||
*/
|
*/
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
void
|
void
|
||||||
@@ -109,11 +104,11 @@ glm_mat3x2_mul(mat3x2 m1, mat2x3 m2, mat2 dest) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief multiply matrix with column vector and store in dest column vector
|
* @brief Multiply mat3x2 (m) by vec3 (v) and store in vec2 (dest).
|
||||||
*
|
*
|
||||||
* @param[in] m matrix (left)
|
* @param[in] m mat3x2 (left)
|
||||||
* @param[in] v vector (right, column vector)
|
* @param[in] v vec3 (right, column vector)
|
||||||
* @param[out] dest result vector
|
* @param[out] dest destination (result, column vector)
|
||||||
*/
|
*/
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
void
|
void
|
||||||
@@ -125,25 +120,23 @@ glm_mat3x2_mulv(mat3x2 m, vec3 v, vec2 dest) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief transpose matrix and store in dest
|
* @brief Transpose mat3x2 (src) and store in mat2x3 (dest).
|
||||||
*
|
*
|
||||||
* @param[in] m matrix
|
* @param[in] src mat3x2 (left)
|
||||||
* @param[out] dest result
|
* @param[out] dest destination (result, mat2x3)
|
||||||
*/
|
*/
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
void
|
void
|
||||||
glm_mat3x2_transpose(mat3x2 m, mat2x3 dest) {
|
glm_mat3x2_transpose(mat3x2 src, mat2x3 dest) {
|
||||||
dest[0][0] = m[0][0]; dest[0][1] = m[1][0]; dest[0][2] = m[2][0];
|
dest[0][0] = src[0][0]; dest[0][1] = src[1][0]; dest[0][2] = src[2][0];
|
||||||
dest[1][0] = m[0][1]; dest[1][1] = m[1][1]; dest[1][2] = m[2][1];
|
dest[1][0] = src[0][1]; dest[1][1] = src[1][1]; dest[1][2] = src[2][1];
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief scale (multiply with scalar) matrix
|
* @brief Multiply mat3x2 (m) by scalar constant (s).
|
||||||
*
|
*
|
||||||
* multiply matrix with scalar
|
* @param[in, out] m (src, dest)
|
||||||
*
|
* @param[in] s float (scalar)
|
||||||
* @param[in, out] m matrix
|
|
||||||
* @param[in] s scalar
|
|
||||||
*/
|
*/
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
void
|
void
|
||||||
|
|||||||
@@ -11,12 +11,12 @@
|
|||||||
GLM_MAT3X4_ZERO
|
GLM_MAT3X4_ZERO
|
||||||
|
|
||||||
Functions:
|
Functions:
|
||||||
CGLM_INLINE void glm_mat3x4_copy(mat3x4 mat, mat3x4 dest);
|
CGLM_INLINE void glm_mat3x4_copy(mat3x4 src, mat3x4 dest);
|
||||||
CGLM_INLINE void glm_mat3x4_zero(mat3x4 mat);
|
CGLM_INLINE void glm_mat3x4_zero(mat3x4 m);
|
||||||
CGLM_INLINE void glm_mat3x4_make(const float * __restrict src, mat3x4 dest);
|
CGLM_INLINE void glm_mat3x4_make(const float * __restrict src, mat3x4 dest);
|
||||||
CGLM_INLINE void glm_mat3x4_mul(mat3x4 m1, mat4x3 m2, mat4 dest);
|
CGLM_INLINE void glm_mat3x4_mul(mat3x4 m1, mat4x3 m2, mat4 dest);
|
||||||
CGLM_INLINE void glm_mat3x4_mulv(mat3x4 m, vec3 v, vec4 dest);
|
CGLM_INLINE void glm_mat3x4_mulv(mat3x4 m, vec3 v, vec4 dest);
|
||||||
CGLM_INLINE void glm_mat3x4_transpose(mat3x4 m, mat4x3 dest);
|
CGLM_INLINE void glm_mat3x4_transpose(mat3x4 src, mat4x3 dest);
|
||||||
CGLM_INLINE void glm_mat3x4_scale(mat3x4 m, float s);
|
CGLM_INLINE void glm_mat3x4_scale(mat3x4 m, float s);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -33,36 +33,36 @@
|
|||||||
#define GLM_MAT3X4_ZERO GLM_MAT3X4_ZERO_INIT
|
#define GLM_MAT3X4_ZERO GLM_MAT3X4_ZERO_INIT
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief copy all members of [mat] to [dest]
|
* @brief Copy mat3x4 (src) to mat3x4 (dest).
|
||||||
*
|
*
|
||||||
* @param[in] mat source
|
* @param[in] src mat3x4 (left)
|
||||||
* @param[out] dest destination
|
* @param[out] dest destination (result, mat3x4)
|
||||||
*/
|
*/
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
void
|
void
|
||||||
glm_mat3x4_copy(mat3x4 mat, mat3x4 dest) {
|
glm_mat3x4_copy(mat3x4 src, mat3x4 dest) {
|
||||||
glm_vec4_ucopy(mat[0], dest[0]);
|
glm_vec4_ucopy(src[0], dest[0]);
|
||||||
glm_vec4_ucopy(mat[1], dest[1]);
|
glm_vec4_ucopy(src[1], dest[1]);
|
||||||
glm_vec4_ucopy(mat[2], dest[2]);
|
glm_vec4_ucopy(src[2], dest[2]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief make given matrix zero.
|
* @brief Zero out the mat3x4 (m).
|
||||||
*
|
*
|
||||||
* @param[in, out] mat matrix
|
* @param[in, out] mat3x4 (src, dest)
|
||||||
*/
|
*/
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
void
|
void
|
||||||
glm_mat3x4_zero(mat3x4 mat) {
|
glm_mat3x4_zero(mat3x4 m) {
|
||||||
CGLM_ALIGN_MAT mat3x4 t = GLM_MAT3X4_ZERO_INIT;
|
CGLM_ALIGN_MAT mat3x4 t = GLM_MAT3X4_ZERO_INIT;
|
||||||
glm_mat3x4_copy(t, mat);
|
glm_mat3x4_copy(t, m);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief Create mat3x4 matrix from pointer
|
* @brief Create mat3x4 (dest) from pointer (src).
|
||||||
*
|
*
|
||||||
* @param[in] src pointer to an array of floats
|
* @param[in] src pointer to an array of floats (left)
|
||||||
* @param[out] dest matrix
|
* @param[out] dest destination (result, mat3x4)
|
||||||
*/
|
*/
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
void
|
void
|
||||||
@@ -84,15 +84,15 @@ glm_mat3x4_make(const float * __restrict src, mat3x4 dest) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief multiply m1 and m2 to dest
|
* @brief Multiply mat3x4 (m1) by mat4x3 (m2) and store in mat4 (dest).
|
||||||
*
|
*
|
||||||
* @code
|
* @code
|
||||||
* glm_mat3x4_mul(mat3x4, mat4x3, mat4);
|
* glm_mat3x4_mul(mat3x4, mat4x3, mat4);
|
||||||
* @endcode
|
* @endcode
|
||||||
*
|
*
|
||||||
* @param[in] m1 left matrix (mat3x4)
|
* @param[in] m1 mat3x4 (left)
|
||||||
* @param[in] m2 right matrix (mat4x3)
|
* @param[in] m2 mat4x3 (right)
|
||||||
* @param[out] dest destination matrix (mat4)
|
* @param[out] dest destination (result, mat4)
|
||||||
*/
|
*/
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
void
|
void
|
||||||
@@ -128,11 +128,11 @@ glm_mat3x4_mul(mat3x4 m1, mat4x3 m2, mat4 dest) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief multiply matrix with column vector and store in dest column vector
|
* @brief Multiply mat3x4 (m) by vec3 (v) and store in vec4 (dest).
|
||||||
*
|
*
|
||||||
* @param[in] m matrix (left)
|
* @param[in] m mat3x4 (left)
|
||||||
* @param[in] v vector (right, column vector)
|
* @param[in] v vec3 (right, column vector)
|
||||||
* @param[out] dest result vector
|
* @param[out] dest destination (result, column vector)
|
||||||
*/
|
*/
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
void
|
void
|
||||||
@@ -146,27 +146,25 @@ glm_mat3x4_mulv(mat3x4 m, vec3 v, vec4 dest) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief transpose matrix and store in dest
|
* @brief Transpose mat3x4 (src) and store in mat4x3 (dest).
|
||||||
*
|
*
|
||||||
* @param[in] m matrix
|
* @param[in] src mat3x4 (left)
|
||||||
* @param[out] dest result
|
* @param[out] dest destination (result, mat4x3)
|
||||||
*/
|
*/
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
void
|
void
|
||||||
glm_mat3x4_transpose(mat3x4 m, mat4x3 dest) {
|
glm_mat3x4_transpose(mat3x4 src, mat4x3 dest) {
|
||||||
dest[0][0] = m[0][0]; dest[0][1] = m[1][0]; dest[0][2] = m[2][0];
|
dest[0][0] = src[0][0]; dest[0][1] = src[1][0]; dest[0][2] = src[2][0];
|
||||||
dest[1][0] = m[0][1]; dest[1][1] = m[1][1]; dest[1][2] = m[2][1];
|
dest[1][0] = src[0][1]; dest[1][1] = src[1][1]; dest[1][2] = src[2][1];
|
||||||
dest[2][0] = m[0][2]; dest[2][1] = m[1][2]; dest[2][2] = m[2][2];
|
dest[2][0] = src[0][2]; dest[2][1] = src[1][2]; dest[2][2] = src[2][2];
|
||||||
dest[3][0] = m[0][3]; dest[3][1] = m[1][3]; dest[3][2] = m[2][3];
|
dest[3][0] = src[0][3]; dest[3][1] = src[1][3]; dest[3][2] = src[2][3];
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief scale (multiply with scalar) matrix
|
* @brief Multiply mat3x4 (m) by scalar constant (s).
|
||||||
*
|
*
|
||||||
* multiply matrix with scalar
|
* @param[in, out] m (src, dest)
|
||||||
*
|
* @param[in] s float (scalar)
|
||||||
* @param[in, out] m matrix
|
|
||||||
* @param[in] s scalar
|
|
||||||
*/
|
*/
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
void
|
void
|
||||||
|
|||||||
@@ -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
|
||||||
@@ -360,7 +361,7 @@ glm_mat4_mul(mat4 m1, mat4 m2, mat4 dest) {
|
|||||||
* size but if <b>len</b> is too small then compiler may unroll whole loop,
|
* size but if <b>len</b> is too small then compiler may unroll whole loop,
|
||||||
* usage:
|
* usage:
|
||||||
* @code
|
* @code
|
||||||
* mat m1, m2, m3, m4, res;
|
* mat4 m1, m2, m3, m4, res;
|
||||||
*
|
*
|
||||||
* glm_mat4_mulN((mat4 *[]){&m1, &m2, &m3, &m4}, 4, res);
|
* glm_mat4_mulN((mat4 *[]){&m1, &m2, &m3, &m4}, 4, res);
|
||||||
* @endcode
|
* @endcode
|
||||||
@@ -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 */
|
||||||
|
|||||||
@@ -11,12 +11,12 @@
|
|||||||
GLM_MAT4X2_ZERO
|
GLM_MAT4X2_ZERO
|
||||||
|
|
||||||
Functions:
|
Functions:
|
||||||
CGLM_INLINE void glm_mat4x2_copy(mat4x2 mat, mat4x2 dest);
|
CGLM_INLINE void glm_mat4x2_copy(mat4x2 src, mat4x2 dest);
|
||||||
CGLM_INLINE void glm_mat4x2_zero(mat4x2 mat);
|
CGLM_INLINE void glm_mat4x2_zero(mat4x2 m);
|
||||||
CGLM_INLINE void glm_mat4x2_make(const float * __restrict src, mat4x2 dest);
|
CGLM_INLINE void glm_mat4x2_make(const float * __restrict src, mat4x2 dest);
|
||||||
CGLM_INLINE void glm_mat4x2_mul(mat4x2 m1, mat2x4 m2, mat2 dest);
|
CGLM_INLINE void glm_mat4x2_mul(mat4x2 m1, mat2x4 m2, mat2 dest);
|
||||||
CGLM_INLINE void glm_mat4x2_mulv(mat4x2 m, vec4 v, vec2 dest);
|
CGLM_INLINE void glm_mat4x2_mulv(mat4x2 m, vec4 v, vec2 dest);
|
||||||
CGLM_INLINE void glm_mat4x2_transpose(mat4x2 m, mat2x4 dest);
|
CGLM_INLINE void glm_mat4x2_transpose(mat4x2 src, mat2x4 dest);
|
||||||
CGLM_INLINE void glm_mat4x2_scale(mat4x2 m, float s);
|
CGLM_INLINE void glm_mat4x2_scale(mat4x2 m, float s);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -31,44 +31,37 @@
|
|||||||
#define GLM_MAT4X2_ZERO GLM_MAT4X2_ZERO_INIT
|
#define GLM_MAT4X2_ZERO GLM_MAT4X2_ZERO_INIT
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief copy all members of [mat] to [dest]
|
* @brief Copy mat4x2 (src) to mat4x2 (dest).
|
||||||
*
|
*
|
||||||
* @param[in] mat source
|
* @param[in] src mat4x2 (left)
|
||||||
* @param[out] dest destination
|
* @param[out] dest destination (result, mat4x2)
|
||||||
*/
|
*/
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
void
|
void
|
||||||
glm_mat4x2_copy(mat4x2 mat, mat4x2 dest) {
|
glm_mat4x2_copy(mat4x2 src, mat4x2 dest) {
|
||||||
dest[0][0] = mat[0][0];
|
glm_vec2_copy(src[0], dest[0]);
|
||||||
dest[0][1] = mat[0][1];
|
glm_vec2_copy(src[1], dest[1]);
|
||||||
|
glm_vec2_copy(src[2], dest[2]);
|
||||||
dest[1][0] = mat[1][0];
|
glm_vec2_copy(src[3], dest[3]);
|
||||||
dest[1][1] = mat[1][1];
|
|
||||||
|
|
||||||
dest[2][0] = mat[2][0];
|
|
||||||
dest[2][1] = mat[2][1];
|
|
||||||
|
|
||||||
dest[3][0] = mat[3][0];
|
|
||||||
dest[3][1] = mat[3][1];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief make given matrix zero.
|
* @brief Zero out the mat4x2 (m).
|
||||||
*
|
*
|
||||||
* @param[in, out] mat matrix
|
* @param[in, out] mat4x2 (src, dest)
|
||||||
*/
|
*/
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
void
|
void
|
||||||
glm_mat4x2_zero(mat4x2 mat) {
|
glm_mat4x2_zero(mat4x2 m) {
|
||||||
CGLM_ALIGN_MAT mat4x2 t = GLM_MAT4X2_ZERO_INIT;
|
CGLM_ALIGN_MAT mat4x2 t = GLM_MAT4X2_ZERO_INIT;
|
||||||
glm_mat4x2_copy(t, mat);
|
glm_mat4x2_copy(t, m);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief Create mat4x2 matrix from pointer
|
* @brief Create mat4x2 (dest) from pointer (src).
|
||||||
*
|
*
|
||||||
* @param[in] src pointer to an array of floats
|
* @param[in] src pointer to an array of floats (left)
|
||||||
* @param[out] dest matrix
|
* @param[out] dest destination (result, mat4x2)
|
||||||
*/
|
*/
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
void
|
void
|
||||||
@@ -87,15 +80,15 @@ glm_mat4x2_make(const float * __restrict src, mat4x2 dest) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief multiply m1 and m2 to dest
|
* @brief Multiply mat4x2 (m1) by mat2x4 (m2) and store in mat2 (dest).
|
||||||
*
|
*
|
||||||
* @code
|
* @code
|
||||||
* glm_mat4x2_mul(mat4x2, mat2x4, mat2);
|
* glm_mat4x2_mul(mat4x2, mat2x4, mat2);
|
||||||
* @endcode
|
* @endcode
|
||||||
*
|
*
|
||||||
* @param[in] m1 left matrix (mat4x2)
|
* @param[in] m1 mat4x2 (left)
|
||||||
* @param[in] m2 right matrix (mat2x4)
|
* @param[in] m2 mat2x4 (right)
|
||||||
* @param[out] dest destination matrix (mat2)
|
* @param[out] dest destination (result, mat2)
|
||||||
*/
|
*/
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
void
|
void
|
||||||
@@ -116,11 +109,11 @@ glm_mat4x2_mul(mat4x2 m1, mat2x4 m2, mat2 dest) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief multiply matrix with column vector and store in dest column vector
|
* @brief Multiply mat4x2 (m) by vec4 (v) and store in vec2 (dest).
|
||||||
*
|
*
|
||||||
* @param[in] m matrix (left)
|
* @param[in] m mat4x2 (left)
|
||||||
* @param[in] v vector (right, column vector)
|
* @param[in] v vec4 (right, column vector)
|
||||||
* @param[out] dest result vector
|
* @param[out] dest destination (result, column vector)
|
||||||
*/
|
*/
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
void
|
void
|
||||||
@@ -132,31 +125,23 @@ glm_mat4x2_mulv(mat4x2 m, vec4 v, vec2 dest) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief transpose matrix and store in dest
|
* @brief Transpose mat4x2 (src) and store in mat2x4 (dest).
|
||||||
*
|
*
|
||||||
* @param[in] m matrix
|
* @param[in] src mat4x2 (left)
|
||||||
* @param[out] dest result
|
* @param[out] dest destination (result, mat2x4)
|
||||||
*/
|
*/
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
void
|
void
|
||||||
glm_mat4x2_transpose(mat4x2 m, mat2x4 dest) {
|
glm_mat4x2_transpose(mat4x2 m, mat2x4 dest) {
|
||||||
dest[0][0] = m[0][0];
|
dest[0][0] = m[0][0]; dest[0][1] = m[1][0]; dest[0][2] = m[2][0]; dest[0][3] = m[3][0];
|
||||||
dest[0][1] = m[1][0];
|
dest[1][0] = m[0][1]; dest[1][1] = m[1][1]; dest[1][2] = m[2][1]; dest[1][3] = m[3][1];
|
||||||
dest[0][2] = m[2][0];
|
|
||||||
dest[0][3] = m[3][0];
|
|
||||||
dest[1][0] = m[0][1];
|
|
||||||
dest[1][1] = m[1][1];
|
|
||||||
dest[1][2] = m[2][1];
|
|
||||||
dest[1][3] = m[3][1];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief scale (multiply with scalar) matrix
|
* @brief Multiply mat4x2 (m) by scalar constant (s).
|
||||||
*
|
*
|
||||||
* multiply matrix with scalar
|
* @param[in, out] m (src, dest)
|
||||||
*
|
* @param[in] s float (scalar)
|
||||||
* @param[in, out] m matrix
|
|
||||||
* @param[in] s scalar
|
|
||||||
*/
|
*/
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
void
|
void
|
||||||
|
|||||||
@@ -11,12 +11,12 @@
|
|||||||
GLM_MAT4X3_ZERO
|
GLM_MAT4X3_ZERO
|
||||||
|
|
||||||
Functions:
|
Functions:
|
||||||
CGLM_INLINE void glm_mat4x3_copy(mat4x3 mat, mat4x3 dest);
|
CGLM_INLINE void glm_mat4x3_copy(mat4x3 src, mat4x3 dest);
|
||||||
CGLM_INLINE void glm_mat4x3_zero(mat4x3 mat);
|
CGLM_INLINE void glm_mat4x3_zero(mat4x3 m);
|
||||||
CGLM_INLINE void glm_mat4x3_make(const float * __restrict src, mat4x3 dest);
|
CGLM_INLINE void glm_mat4x3_make(const float * __restrict src, mat4x3 dest);
|
||||||
CGLM_INLINE void glm_mat4x3_mul(mat4x3 m1, mat3x4 m2, mat3 dest);
|
CGLM_INLINE void glm_mat4x3_mul(mat4x3 m1, mat3x4 m2, mat3 dest);
|
||||||
CGLM_INLINE void glm_mat4x3_mulv(mat4x3 m, vec4 v, vec3 dest);
|
CGLM_INLINE void glm_mat4x3_mulv(mat4x3 m, vec4 v, vec3 dest);
|
||||||
CGLM_INLINE void glm_mat4x3_transpose(mat4x3 m, mat3x4 dest);
|
CGLM_INLINE void glm_mat4x3_transpose(mat4x3 src, mat3x4 dest);
|
||||||
CGLM_INLINE void glm_mat4x3_scale(mat4x3 m, float s);
|
CGLM_INLINE void glm_mat4x3_scale(mat4x3 m, float s);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -32,48 +32,37 @@
|
|||||||
#define GLM_MAT4X3_ZERO GLM_MAT4X3_ZERO_INIT
|
#define GLM_MAT4X3_ZERO GLM_MAT4X3_ZERO_INIT
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief copy all members of [mat] to [dest]
|
* @brief Copy mat4x3 (src) to mat4x3 (dest).
|
||||||
*
|
*
|
||||||
* @param[in] mat source
|
* @param[in] src mat4x3 (left)
|
||||||
* @param[out] dest destination
|
* @param[out] dest destination (result, mat4x3)
|
||||||
*/
|
*/
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
void
|
void
|
||||||
glm_mat4x3_copy(mat4x3 mat, mat4x3 dest) {
|
glm_mat4x3_copy(mat4x3 src, mat4x3 dest) {
|
||||||
dest[0][0] = mat[0][0];
|
glm_vec3_copy(src[0], dest[0]);
|
||||||
dest[0][1] = mat[0][1];
|
glm_vec3_copy(src[1], dest[1]);
|
||||||
dest[0][2] = mat[0][2];
|
glm_vec3_copy(src[2], dest[2]);
|
||||||
|
glm_vec3_copy(src[3], dest[3]);
|
||||||
dest[1][0] = mat[1][0];
|
|
||||||
dest[1][1] = mat[1][1];
|
|
||||||
dest[1][2] = mat[1][2];
|
|
||||||
|
|
||||||
dest[2][0] = mat[2][0];
|
|
||||||
dest[2][1] = mat[2][1];
|
|
||||||
dest[2][2] = mat[2][2];
|
|
||||||
|
|
||||||
dest[3][0] = mat[3][0];
|
|
||||||
dest[3][1] = mat[3][1];
|
|
||||||
dest[3][2] = mat[3][2];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief make given matrix zero.
|
* @brief Zero out the mat4x3 (m).
|
||||||
*
|
*
|
||||||
* @param[in, out] mat matrix
|
* @param[in, out] mat4x3 (src, dest)
|
||||||
*/
|
*/
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
void
|
void
|
||||||
glm_mat4x3_zero(mat4x3 mat) {
|
glm_mat4x3_zero(mat4x3 m) {
|
||||||
CGLM_ALIGN_MAT mat4x3 t = GLM_MAT4X3_ZERO_INIT;
|
CGLM_ALIGN_MAT mat4x3 t = GLM_MAT4X3_ZERO_INIT;
|
||||||
glm_mat4x3_copy(t, mat);
|
glm_mat4x3_copy(t, m);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief Create mat4x3 matrix from pointer
|
* @brief Create mat4x3 (dest) from pointer (src).
|
||||||
*
|
*
|
||||||
* @param[in] src pointer to an array of floats
|
* @param[in] src pointer to an array of floats (left)
|
||||||
* @param[out] dest matrix
|
* @param[out] dest destination (result, mat4x3)
|
||||||
*/
|
*/
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
void
|
void
|
||||||
@@ -96,15 +85,15 @@ glm_mat4x3_make(const float * __restrict src, mat4x3 dest) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief multiply m1 and m2 to dest
|
* @brief Multiply mat4x3 (m1) by mat3x4 (m2) and store in mat3 (dest).
|
||||||
*
|
*
|
||||||
* @code
|
* @code
|
||||||
* glm_mat4x3_mul(mat4x3, mat3x4, mat3);
|
* glm_mat4x3_mul(mat4x3, mat3x4, mat3);
|
||||||
* @endcode
|
* @endcode
|
||||||
*
|
*
|
||||||
* @param[in] m1 left matrix (mat4x3)
|
* @param[in] m1 mat4x3 (left)
|
||||||
* @param[in] m2 right matrix (mat3x4)
|
* @param[in] m2 mat3x4 (right)
|
||||||
* @param[out] dest destination matrix (mat3)
|
* @param[out] dest destination (result, mat3)
|
||||||
*/
|
*/
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
void
|
void
|
||||||
@@ -132,11 +121,11 @@ glm_mat4x3_mul(mat4x3 m1, mat3x4 m2, mat3 dest) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief multiply matrix with column vector and store in dest column vector
|
* @brief Multiply mat4x3 (m) by vec4 (v) and store in vec3 (dest).
|
||||||
*
|
*
|
||||||
* @param[in] m matrix (left)
|
* @param[in] m mat4x3 (left)
|
||||||
* @param[in] v vector (right, column vector)
|
* @param[in] v vec3 (right, column vector)
|
||||||
* @param[out] dest result vector
|
* @param[out] dest destination (result, column vector)
|
||||||
*/
|
*/
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
void
|
void
|
||||||
@@ -149,37 +138,24 @@ glm_mat4x3_mulv(mat4x3 m, vec4 v, vec3 dest) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief transpose matrix and store in dest
|
* @brief Transpose mat4x3 (src) and store in mat3x4 (dest).
|
||||||
*
|
*
|
||||||
* @param[in] m matrix
|
* @param[in] src mat4x3 (left)
|
||||||
* @param[out] dest result
|
* @param[out] dest destination (result, mat3x4)
|
||||||
*/
|
*/
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
void
|
void
|
||||||
glm_mat4x3_transpose(mat4x3 m, mat3x4 dest) {
|
glm_mat4x3_transpose(mat4x3 src, mat3x4 dest) {
|
||||||
dest[0][0] = m[0][0];
|
dest[0][0] = src[0][0]; dest[0][1] = src[1][0]; dest[0][2] = src[2][0]; dest[0][3] = src[3][0];
|
||||||
dest[0][1] = m[1][0];
|
dest[1][0] = src[0][1]; dest[1][1] = src[1][1]; dest[1][2] = src[2][1]; dest[1][3] = src[3][1];
|
||||||
dest[0][2] = m[2][0];
|
dest[2][0] = src[0][2]; dest[2][1] = src[1][2]; dest[2][2] = src[2][2]; dest[2][3] = src[3][2];
|
||||||
dest[0][3] = m[3][0];
|
|
||||||
|
|
||||||
dest[1][0] = m[0][1];
|
|
||||||
dest[1][1] = m[1][1];
|
|
||||||
dest[1][2] = m[2][1];
|
|
||||||
dest[1][3] = m[3][1];
|
|
||||||
|
|
||||||
dest[2][0] = m[0][2];
|
|
||||||
dest[2][1] = m[1][2];
|
|
||||||
dest[2][2] = m[2][2];
|
|
||||||
dest[2][3] = m[3][2];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief scale (multiply with scalar) matrix
|
* @brief Multiply mat4x3 (m) by scalar constant (s).
|
||||||
*
|
*
|
||||||
* multiply matrix with scalar
|
* @param[in, out] m (src, dest)
|
||||||
*
|
* @param[in] s float (scalar)
|
||||||
* @param[in, out] m matrix
|
|
||||||
* @param[in] s scalar
|
|
||||||
*/
|
*/
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
void
|
void
|
||||||
@@ -189,4 +165,4 @@ glm_mat4x3_scale(mat4x3 m, float s) {
|
|||||||
m[2][2] *= s; m[3][0] *= s; m[3][1] *= s; m[3][2] *= s;
|
m[2][2] *= s; m[3][0] *= s; m[3][1] *= s; m[3][2] *= s;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif /* cglm_mat4x3_h */
|
||||||
|
|||||||
@@ -19,8 +19,10 @@
|
|||||||
#define glmm_load(p) vld1q_f32(p)
|
#define glmm_load(p) vld1q_f32(p)
|
||||||
#define glmm_store(p, a) vst1q_f32(p, a)
|
#define glmm_store(p, a) vst1q_f32(p, a)
|
||||||
|
|
||||||
#define glmm_set1(x) vdupq_n_f32(x)
|
#define glmm_set1(x) vdupq_n_f32(x)
|
||||||
#define glmm_128 float32x4_t
|
#define glmm_set1_ptr(x) vdupq_n_f32(*x)
|
||||||
|
#define glmm_set1_rval(x) vdupq_n_f32(x)
|
||||||
|
#define glmm_128 float32x4_t
|
||||||
|
|
||||||
#define glmm_splat_x(x) vdupq_lane_f32(vget_low_f32(x), 0)
|
#define glmm_splat_x(x) vdupq_lane_f32(vget_low_f32(x), 0)
|
||||||
#define glmm_splat_y(x) vdupq_lane_f32(vget_low_f32(x), 1)
|
#define glmm_splat_y(x) vdupq_lane_f32(vget_low_f32(x), 1)
|
||||||
|
|||||||
@@ -15,6 +15,7 @@
|
|||||||
#define glmm_store(p, a) wasm_v128_store(p, (a))
|
#define glmm_store(p, a) wasm_v128_store(p, (a))
|
||||||
|
|
||||||
#define glmm_set1(x) wasm_f32x4_splat(x)
|
#define glmm_set1(x) wasm_f32x4_splat(x)
|
||||||
|
#define glmm_set1_ptr(x) wasm_f32x4_splat(*x)
|
||||||
#define glmm_set1_rval(x) wasm_f32x4_splat(x)
|
#define glmm_set1_rval(x) wasm_f32x4_splat(x)
|
||||||
#define glmm_128 v128_t
|
#define glmm_128 v128_t
|
||||||
|
|
||||||
|
|||||||
@@ -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.
|
||||||
*
|
*
|
||||||
* rmc stands for Row * Matrix * Column
|
* @param[in] m mat2 (src)
|
||||||
*
|
*
|
||||||
* the result is scalar because R * M = Matrix1x2 (row vector),
|
* @return[out] mat2s raw pointers determinant (float)
|
||||||
* then Matrix1x2 * Vec2 (column vector) = Matrix1x1 (Scalar)
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
float
|
||||||
|
glms_mat2_(det)(mat2s m) {
|
||||||
|
return glm_mat2_det(m.raw);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Returns trace of matrix. Which is:
|
||||||
*
|
*
|
||||||
* @param[in] r row vector or matrix1x2
|
* The sum of the elements on the main diagonal from
|
||||||
* @param[in] m matrix2x2
|
* upper left corner to the bottom right corner.
|
||||||
* @param[in] c column vector or matrix2x1
|
|
||||||
*
|
*
|
||||||
* @return scalar value e.g. Matrix1x1
|
* @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
|
||||||
|
*
|
||||||
|
* the result is scalar because M * C = ResC (1x2, column vector),
|
||||||
|
* then if you take the dot_product(R (2x1), ResC (1x2)) = scalar value.
|
||||||
|
*
|
||||||
|
* @param[in] r vec2s (2x1, row vector)
|
||||||
|
* @param[in] m mat2s (2x2, matrix)
|
||||||
|
* @param[in] c vec2s (1x2, column vector)
|
||||||
|
*
|
||||||
|
* @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 */
|
||||||
|
|||||||
@@ -35,87 +35,85 @@
|
|||||||
#define GLMS_MAT2X3_ZERO ((mat2x3s)GLMS_MAT2X3_ZERO_INIT)
|
#define GLMS_MAT2X3_ZERO ((mat2x3s)GLMS_MAT2X3_ZERO_INIT)
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief make given matrix zero.
|
* @brief Zero out the mat2x3s (dest).
|
||||||
*
|
*
|
||||||
* @param[in, out] mat matrix
|
* @return[out] dest constructed mat2x3s from raw pointer
|
||||||
*/
|
*/
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
mat2x3s
|
mat2x3s
|
||||||
glms_mat2x3_(zero)(void) {
|
glms_mat2x3_(zero)(void) {
|
||||||
mat2x3s r;
|
mat2x3s dest;
|
||||||
glm_mat2x3_zero(r.raw);
|
glm_mat2x3_zero(dest.raw);
|
||||||
return r;
|
return dest;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief Create mat2x3 matrix from pointer
|
* @brief Create mat2x3s (dest) from pointer (src).
|
||||||
*
|
*
|
||||||
* @param[in] src pointer to an array of floats
|
* @param[in] src pointer to an array of floats
|
||||||
* @return constructed matrix from raw pointer
|
* @return[out] dest constructed mat2x3s from raw pointer
|
||||||
*/
|
*/
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
mat2x3s
|
mat2x3s
|
||||||
glms_mat2x3_(make)(const float * __restrict src) {
|
glms_mat2x3_(make)(const float * __restrict src) {
|
||||||
mat2x3s r;
|
mat2x3s dest;
|
||||||
glm_mat2x3_make(src, r.raw);
|
glm_mat2x3_make(src, dest.raw);
|
||||||
return r;
|
return dest;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief multiply m1 and m2 to dest
|
* @brief Multiply mat2x3s (m1) by mat3x2s (m2) and store in mat3s (dest).
|
||||||
*
|
*
|
||||||
* @code
|
* @code
|
||||||
* r = glms_mat2x3_mul(mat2x3s, mat3x2s);
|
* r = glms_mat2x3_mul(mat2x3s, mat3x2s);
|
||||||
* @endcode
|
* @endcode
|
||||||
*
|
*
|
||||||
* @param[in] m1 left matrix (mat2x3s)
|
* @param[in] m1 mat2x3s (left)
|
||||||
* @param[in] m2 right matrix (mat3x2s)
|
* @param[in] m2 mat3x2s (right)
|
||||||
* @returns destination matrix (mat2s)
|
* @return[out] dest constructed mat3s from raw pointers
|
||||||
*/
|
*/
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
mat3s
|
mat3s
|
||||||
glms_mat2x3_(mul)(mat2x3s m1, mat3x2s m2) {
|
glms_mat2x3_(mul)(mat2x3s m1, mat3x2s m2) {
|
||||||
mat3s r;
|
mat3s dest;
|
||||||
glm_mat2x3_mul(m1.raw, m2.raw, r.raw);
|
glm_mat2x3_mul(m1.raw, m2.raw, dest.raw);
|
||||||
return r;
|
return dest;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief multiply matrix with column vector and store in dest vector
|
* @brief Multiply mat2x3s (m) by vec2s (v) and store in vec3s (dest).
|
||||||
*
|
*
|
||||||
* @param[in] m matrix (left)
|
* @param[in] m mat2x3s (left)
|
||||||
* @param[in] v vector (right, column vector)
|
* @param[in] v vec2s (right, column vector)
|
||||||
* @returns destination vector (vec3s)
|
* @return[out] dest constructed vec3s from raw pointers
|
||||||
*/
|
*/
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
vec3s
|
vec3s
|
||||||
glms_mat2x3_(mulv)(mat2x3s m, vec2s v) {
|
glms_mat2x3_(mulv)(mat2x3s m, vec2s v) {
|
||||||
vec3s r;
|
vec3s dest;
|
||||||
glm_mat2x3_mulv(m.raw, v.raw, r.raw);
|
glm_mat2x3_mulv(m.raw, v.raw, dest.raw);
|
||||||
return r;
|
return dest;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief transpose matrix and store in dest
|
* @brief Transpose mat2x3s (m) and store in mat3x2s (dest).
|
||||||
*
|
*
|
||||||
* @param[in] m matrix
|
* @param[in] m mat2x3s (left)
|
||||||
* @param[out] dest result
|
* @return[out] dest constructed mat3x2s from raw pointers
|
||||||
*/
|
*/
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
mat3x2s
|
mat3x2s
|
||||||
glms_mat2x3_(transpose)(mat2x3s m) {
|
glms_mat2x3_(transpose)(mat2x3s m) {
|
||||||
mat3x2s r;
|
mat3x2s dest;
|
||||||
glm_mat2x3_transpose(m.raw, r.raw);
|
glm_mat2x3_transpose(m.raw, dest.raw);
|
||||||
return r;
|
return dest;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief scale (multiply with scalar) matrix
|
* @brief Multiply mat2x3s (m) by scalar constant (s).
|
||||||
*
|
*
|
||||||
* multiply matrix with scalar
|
* @param[in, out] m mat2x3 (src, dest)
|
||||||
*
|
* @param[in] s float (scalar)
|
||||||
* @param[in, out] m matrix
|
|
||||||
* @param[in] s scalar
|
|
||||||
*/
|
*/
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
mat2x3s
|
mat2x3s
|
||||||
|
|||||||
@@ -35,87 +35,85 @@
|
|||||||
#define GLMS_MAT2X4_ZERO ((mat2x4s)GLMS_MAT2X4_ZERO_INIT)
|
#define GLMS_MAT2X4_ZERO ((mat2x4s)GLMS_MAT2X4_ZERO_INIT)
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief make given matrix zero.
|
* @brief Zero out the mat2x4s (dest).
|
||||||
*
|
*
|
||||||
* @param[in, out] mat matrix
|
* @return[out] dest constructed mat2x4s from raw pointer
|
||||||
*/
|
*/
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
mat2x4s
|
mat2x4s
|
||||||
glms_mat2x4_(zero)(void) {
|
glms_mat2x4_(zero)(void) {
|
||||||
mat2x4s r;
|
mat2x4s dest;
|
||||||
glm_mat2x4_zero(r.raw);
|
glm_mat2x4_zero(dest.raw);
|
||||||
return r;
|
return dest;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief Create mat2x4 matrix from pointer
|
* @brief Create mat2x4s (dest) from pointer (src).
|
||||||
*
|
*
|
||||||
* @param[in] src pointer to an array of floats
|
* @param[in] src pointer to an array of floats
|
||||||
* @return constructed matrix from raw pointer
|
* @return[out] dest constructed mat2x4s from raw pointer
|
||||||
*/
|
*/
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
mat2x4s
|
mat2x4s
|
||||||
glms_mat2x4_(make)(const float * __restrict src) {
|
glms_mat2x4_(make)(const float * __restrict src) {
|
||||||
mat2x4s r;
|
mat2x4s dest;
|
||||||
glm_mat2x4_make(src, r.raw);
|
glm_mat2x4_make(src, dest.raw);
|
||||||
return r;
|
return dest;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief multiply m1 and m2 to dest
|
* @brief Multiply mat2x4s (m1) by mat4x2s (m2) and store in mat4s (dest).
|
||||||
*
|
*
|
||||||
* @code
|
* @code
|
||||||
* r = glms_mat2x4_mul(mat2x4s, mat4x2s);
|
* r = glms_mat2x4_mul(mat2x4s, mat4x2s);
|
||||||
* @endcode
|
* @endcode
|
||||||
*
|
*
|
||||||
* @param[in] m1 left matrix (mat2x4s)
|
* @param[in] m1 mat2x4s (left)
|
||||||
* @param[in] m2 right matrix (mat4x2s)
|
* @param[in] m2 mat4x2s (right)
|
||||||
* @returns destination matrix (mat2s)
|
* @return[out] dest constructed mat4s from raw pointers
|
||||||
*/
|
*/
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
mat4s
|
mat4s
|
||||||
glms_mat2x4_(mul)(mat2x4s m1, mat4x2s m2) {
|
glms_mat2x4_(mul)(mat2x4s m1, mat4x2s m2) {
|
||||||
mat4s r;
|
mat4s dest;
|
||||||
glm_mat2x4_mul(m1.raw, m2.raw, r.raw);
|
glm_mat2x4_mul(m1.raw, m2.raw, dest.raw);
|
||||||
return r;
|
return dest;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief multiply matrix with column vector and store in dest column vector
|
* @brief Multiply mat2x4s (m) by vec2s (v) and store in vec4s (dest).
|
||||||
*
|
*
|
||||||
* @param[in] m matrix (left)
|
* @param[in] m mat2x4s (left)
|
||||||
* @param[in] v vector (right, column vector)
|
* @param[in] v vec2s (right, column vector)
|
||||||
* @param[out] dest result vector
|
* @return[out] dest constructed vec4s from raw pointers
|
||||||
*/
|
*/
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
vec4s
|
vec4s
|
||||||
glms_mat2x4_(mulv)(mat2x4s m, vec2s v) {
|
glms_mat2x4_(mulv)(mat2x4s m, vec2s v) {
|
||||||
vec4s r;
|
vec4s dest;
|
||||||
glm_mat2x4_mulv(m.raw, v.raw, r.raw);
|
glm_mat2x4_mulv(m.raw, v.raw, dest.raw);
|
||||||
return r;
|
return dest;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief transpose matrix and store in dest
|
* @brief Transpose mat2x4s (m) and store in mat4x2s (dest).
|
||||||
*
|
*
|
||||||
* @param[in] m matrix
|
* @param[in] m mat2x4s (left)
|
||||||
* @param[out] dest result
|
* @return[out] dest constructed mat4x2s from raw pointers
|
||||||
*/
|
*/
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
mat4x2s
|
mat4x2s
|
||||||
glms_mat2x4_(transpose)(mat2x4s m) {
|
glms_mat2x4_(transpose)(mat2x4s m) {
|
||||||
mat4x2s r;
|
mat4x2s dest;
|
||||||
glm_mat2x4_transpose(m.raw, r.raw);
|
glm_mat2x4_transpose(m.raw, dest.raw);
|
||||||
return r;
|
return dest;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief scale (multiply with scalar) matrix
|
* @brief Multiply mat2x4s (m) by scalar constant (s).
|
||||||
*
|
*
|
||||||
* multiply matrix with scalar
|
* @param[in, out] m mat2x4s (src, dest)
|
||||||
*
|
* @param[in] s float (scalar)
|
||||||
* @param[in, out] m matrix
|
|
||||||
* @param[in] s scalar
|
|
||||||
*/
|
*/
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
mat2x4s
|
mat2x4s
|
||||||
|
|||||||
@@ -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 */
|
||||||
|
|||||||
@@ -35,87 +35,85 @@
|
|||||||
#define GLMS_MAT3X2_ZERO ((mat3x2s)GLMS_MAT3X2_ZERO_INIT)
|
#define GLMS_MAT3X2_ZERO ((mat3x2s)GLMS_MAT3X2_ZERO_INIT)
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief make given matrix zero.
|
* @brief Zero out the mat3x2s (dest).
|
||||||
*
|
*
|
||||||
* @param[in, out] mat matrix
|
* @return[out] dest constructed mat3x2s from raw pointer
|
||||||
*/
|
*/
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
mat3x2s
|
mat3x2s
|
||||||
glms_mat3x2_(zero)(void) {
|
glms_mat3x2_(zero)(void) {
|
||||||
mat3x2s r;
|
mat3x2s dest;
|
||||||
glm_mat3x2_zero(r.raw);
|
glm_mat3x2_zero(dest.raw);
|
||||||
return r;
|
return dest;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief Create mat3x2 matrix from pointer
|
* @brief Create mat3x2s (dest) from pointer (src).
|
||||||
*
|
*
|
||||||
* @param[in] src pointer to an array of floats
|
* @param[in] src pointer to an array of floats
|
||||||
* @return constructed matrix from raw pointer
|
* @return[out] dest constructed mat3x2s from raw pointer
|
||||||
*/
|
*/
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
mat3x2s
|
mat3x2s
|
||||||
glms_mat3x2_(make)(const float * __restrict src) {
|
glms_mat3x2_(make)(const float * __restrict src) {
|
||||||
mat3x2s r;
|
mat3x2s dest;
|
||||||
glm_mat3x2_make(src, r.raw);
|
glm_mat3x2_make(src, dest.raw);
|
||||||
return r;
|
return dest;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief multiply m1 and m2 to dest
|
* @brief Multiply mat3x2s (m1) by mat2x3s (m2) and store in mat2s (dest).
|
||||||
*
|
*
|
||||||
* @code
|
* @code
|
||||||
* r = glms_mat3x2_mul(mat3x2s, mat2x3s);
|
* r = glms_mat3x2_mul(mat3x2s, mat2x3s);
|
||||||
* @endcode
|
* @endcode
|
||||||
*
|
*
|
||||||
* @param[in] m1 left matrix (mat3x2s)
|
* @param[in] m1 mat3x2s (left)
|
||||||
* @param[in] m2 right matrix (mat2x3s)
|
* @param[in] m2 mat2x3s (right)
|
||||||
* @returns destination matrix (mat3s)
|
* @return[out] dest constructed mat2s from raw pointers
|
||||||
*/
|
*/
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
mat2s
|
mat2s
|
||||||
glms_mat3x2_(mul)(mat3x2s m1, mat2x3s m2) {
|
glms_mat3x2_(mul)(mat3x2s m1, mat2x3s m2) {
|
||||||
mat2s r;
|
mat2s dest;
|
||||||
glm_mat3x2_mul(m1.raw, m2.raw, r.raw);
|
glm_mat3x2_mul(m1.raw, m2.raw, dest.raw);
|
||||||
return r;
|
return dest;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief multiply matrix with column vector and store in dest vector
|
* @brief Multiply mat3x2s (m) by vec3s (v) and store in vec2s (dest).
|
||||||
*
|
*
|
||||||
* @param[in] m matrix (left)
|
* @param[in] m mat3x2s (left)
|
||||||
* @param[in] v vector (right, column vector)
|
* @param[in] v vec3s (right, column vector)
|
||||||
* @param[out] dest result vector
|
* @return[out] dest constructed vec2s from raw pointers
|
||||||
*/
|
*/
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
vec2s
|
vec2s
|
||||||
glms_mat3x2_(mulv)(mat3x2s m, vec3s v) {
|
glms_mat3x2_(mulv)(mat3x2s m, vec3s v) {
|
||||||
vec2s r;
|
vec2s dest;
|
||||||
glm_mat3x2_mulv(m.raw, v.raw, r.raw);
|
glm_mat3x2_mulv(m.raw, v.raw, dest.raw);
|
||||||
return r;
|
return dest;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief transpose matrix and store in dest
|
* @brief Transpose mat3x2s (m) and store in mat2x3s (dest).
|
||||||
*
|
*
|
||||||
* @param[in] m matrix
|
* @param[in] m mat3x2s (left)
|
||||||
* @param[out] dest result
|
* @return[out] dest constructed mat2x3s from raw pointers
|
||||||
*/
|
*/
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
mat2x3s
|
mat2x3s
|
||||||
glms_mat3x2_(transpose)(mat3x2s m) {
|
glms_mat3x2_(transpose)(mat3x2s m) {
|
||||||
mat2x3s r;
|
mat2x3s dest;
|
||||||
glm_mat3x2_transpose(m.raw, r.raw);
|
glm_mat3x2_transpose(m.raw, dest.raw);
|
||||||
return r;
|
return dest;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief scale (multiply with scalar) matrix
|
* @brief Multiply mat3x2s (m) by scalar constant (s).
|
||||||
*
|
*
|
||||||
* multiply matrix with scalar
|
* @param[in, out] m mat3x2s (src, dest)
|
||||||
*
|
* @param[in] s float (scalar)
|
||||||
* @param[in, out] m matrix
|
|
||||||
* @param[in] s scalar
|
|
||||||
*/
|
*/
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
mat3x2s
|
mat3x2s
|
||||||
|
|||||||
@@ -35,87 +35,85 @@
|
|||||||
#define GLMS_MAT3X4_ZERO ((mat3x4s)GLMS_MAT3X4_ZERO_INIT)
|
#define GLMS_MAT3X4_ZERO ((mat3x4s)GLMS_MAT3X4_ZERO_INIT)
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief make given matrix zero.
|
* @brief Zero out the mat3x4s (dest).
|
||||||
*
|
*
|
||||||
* @param[in, out] mat matrix
|
* @return[out] dest constructed mat3x4s from raw pointer
|
||||||
*/
|
*/
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
mat3x4s
|
mat3x4s
|
||||||
glms_mat3x4_(zero)(void) {
|
glms_mat3x4_(zero)(void) {
|
||||||
mat3x4s r;
|
mat3x4s dest;
|
||||||
glm_mat3x4_zero(r.raw);
|
glm_mat3x4_zero(dest.raw);
|
||||||
return r;
|
return dest;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief Create mat3x4 matrix from pointer
|
* @brief Create mat3x4s (dest) from pointer (src).
|
||||||
*
|
*
|
||||||
* @param[in] src pointer to an array of floats
|
* @param[in] src pointer to an array of floats
|
||||||
* @return constructed matrix from raw pointer
|
* @return[out] dest constructed mat3x4s from raw pointer
|
||||||
*/
|
*/
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
mat3x4s
|
mat3x4s
|
||||||
glms_mat3x4_(make)(const float * __restrict src) {
|
glms_mat3x4_(make)(const float * __restrict src) {
|
||||||
mat3x4s r;
|
mat3x4s dest;
|
||||||
glm_mat3x4_make(src, r.raw);
|
glm_mat3x4_make(src, dest.raw);
|
||||||
return r;
|
return dest;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief multiply m1 and m2 to dest
|
* @brief Multiply mat3x4s (m1) by mat4x3s (m2) and store in mat4s (dest).
|
||||||
*
|
*
|
||||||
* @code
|
* @code
|
||||||
* r = glms_mat3x4_mul(mat3x4s, mat4x3s);
|
* r = glms_mat3x4_mul(mat3x4s, mat4x3s);
|
||||||
* @endcode
|
* @endcode
|
||||||
*
|
*
|
||||||
* @param[in] m1 left matrix (mat3x4s)
|
* @param[in] m1 mat3x4s (left)
|
||||||
* @param[in] m2 right matrix (mat4x3s)
|
* @param[in] m2 mat4x3s (right)
|
||||||
* @returns destination matrix (mat4s)
|
* @return[out] dest constructed mat4s from raw pointers
|
||||||
*/
|
*/
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
mat4s
|
mat4s
|
||||||
glms_mat3x4_(mul)(mat3x4s m1, mat4x3s m2) {
|
glms_mat3x4_(mul)(mat3x4s m1, mat4x3s m2) {
|
||||||
mat4s r;
|
mat4s dest;
|
||||||
glm_mat3x4_mul(m1.raw, m2.raw, r.raw);
|
glm_mat3x4_mul(m1.raw, m2.raw, dest.raw);
|
||||||
return r;
|
return dest;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief multiply matrix with column vector and store in dest column vector
|
* @brief Multiply mat3x4s (m) by vec3s (v) and store in vec4s (dest).
|
||||||
*
|
*
|
||||||
* @param[in] m matrix (left)
|
* @param[in] m mat3x4s (left)
|
||||||
* @param[in] v vector (right, column vector)
|
* @param[in] v vec3s (right, column vector)
|
||||||
* @returns destination vector (vec4s)
|
* @return[out] dest constructed vec4s from raw pointers
|
||||||
*/
|
*/
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
vec4s
|
vec4s
|
||||||
glms_mat3x4_(mulv)(mat3x4s m, vec3s v) {
|
glms_mat3x4_(mulv)(mat3x4s m, vec3s v) {
|
||||||
vec4s r;
|
vec4s dest;
|
||||||
glm_mat3x4_mulv(m.raw, v.raw, r.raw);
|
glm_mat3x4_mulv(m.raw, v.raw, dest.raw);
|
||||||
return r;
|
return dest;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief transpose matrix and store in dest
|
* @brief Transpose mat3x4s (m) and store in mat4x3s (dest).
|
||||||
*
|
*
|
||||||
* @param[in] m matrix
|
* @param[in] m mat3x4s (left)
|
||||||
* @param[out] dest result
|
* @return[out] dest constructed mat4x3s from raw pointers
|
||||||
*/
|
*/
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
mat4x3s
|
mat4x3s
|
||||||
glms_mat3x4_(transpose)(mat3x4s m) {
|
glms_mat3x4_(transpose)(mat3x4s m) {
|
||||||
mat4x3s r;
|
mat4x3s dest;
|
||||||
glm_mat3x4_transpose(m.raw, r.raw);
|
glm_mat3x4_transpose(m.raw, dest.raw);
|
||||||
return r;
|
return dest;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief scale (multiply with scalar) matrix
|
* @brief Multiply mat3x4s (m) by scalar constant (s).
|
||||||
*
|
*
|
||||||
* multiply matrix with scalar
|
* @param[in, out] m mat3x4s (src, dest)
|
||||||
*
|
* @param[in] s float (scalar)
|
||||||
* @param[in, out] m matrix
|
|
||||||
* @param[in] s scalar
|
|
||||||
*/
|
*/
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
mat3x4s
|
mat3x4s
|
||||||
|
|||||||
@@ -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
|
||||||
@@ -223,7 +224,7 @@ glms_mat4_(mul)(mat4s m1, mat4s m2) {
|
|||||||
* size but if <b>len</b> is too small then compiler may unroll whole loop,
|
* size but if <b>len</b> is too small then compiler may unroll whole loop,
|
||||||
* usage:
|
* usage:
|
||||||
* @code
|
* @code
|
||||||
* mat m1, m2, m3, m4, res;
|
* mat4 m1, m2, m3, m4, res;
|
||||||
*
|
*
|
||||||
* res = glm_mat4_mulN((mat4 *[]){&m1, &m2, &m3, &m4}, 4);
|
* res = glm_mat4_mulN((mat4 *[]){&m1, &m2, &m3, &m4}, 4);
|
||||||
* @endcode
|
* @endcode
|
||||||
@@ -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 */
|
||||||
|
|||||||
@@ -36,87 +36,85 @@
|
|||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief make given matrix zero.
|
* @brief Zero out the mat4x2s (dest).
|
||||||
*
|
*
|
||||||
* @param[in, out] mat matrix
|
* @return[out] dest constructed mat4x2s from raw pointer
|
||||||
*/
|
*/
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
mat4x2s
|
mat4x2s
|
||||||
glms_mat4x2_(zero)(void) {
|
glms_mat4x2_(zero)(void) {
|
||||||
mat4x2s r;
|
mat4x2s dest;
|
||||||
glm_mat4x2_zero(r.raw);
|
glm_mat4x2_zero(dest.raw);
|
||||||
return r;
|
return dest;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief Create mat4x2 matrix from pointer
|
* @brief Create mat4x2s (dest) from pointer (src).
|
||||||
*
|
*
|
||||||
* @param[in] src pointer to an array of floats
|
* @param[in] src pointer to an array of floats
|
||||||
* @return constructed matrix from raw pointer
|
* @return[out] dest constructed mat4x2s from raw pointer
|
||||||
*/
|
*/
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
mat4x2s
|
mat4x2s
|
||||||
glms_mat4x2_(make)(const float * __restrict src) {
|
glms_mat4x2_(make)(const float * __restrict src) {
|
||||||
mat4x2s r;
|
mat4x2s dest;
|
||||||
glm_mat4x2_make(src, r.raw);
|
glm_mat4x2_make(src, dest.raw);
|
||||||
return r;
|
return dest;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief multiply m1 and m2 to dest
|
* @brief Multiply mat4x2s (m1) by mat2x4s (m2) and store in mat2s (dest).
|
||||||
*
|
*
|
||||||
* @code
|
* @code
|
||||||
* r = glms_mat4x2_mul(mat4x2s, mat2x4s);
|
* r = glms_mat4x2_mul(mat4x2s, mat2x4s);
|
||||||
* @endcode
|
* @endcode
|
||||||
*
|
*
|
||||||
* @param[in] m1 left matrix (mat4x2s)
|
* @param[in] m1 mat4x2s (left)
|
||||||
* @param[in] m2 right matrix (mat2x4s)
|
* @param[in] m2 mat2x4s (right)
|
||||||
* @returns destination matrix (mat2s)
|
* @return[out] dest constructed mat2s from raw pointers
|
||||||
*/
|
*/
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
mat2s
|
mat2s
|
||||||
glms_mat4x2_(mul)(mat4x2s m1, mat2x4s m2) {
|
glms_mat4x2_(mul)(mat4x2s m1, mat2x4s m2) {
|
||||||
mat2s r;
|
mat2s dest;
|
||||||
glm_mat4x2_mul(m1.raw, m2.raw, r.raw);
|
glm_mat4x2_mul(m1.raw, m2.raw, dest.raw);
|
||||||
return r;
|
return dest;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief multiply matrix with column vector and store in dest column vector
|
* @brief Multiply mat4x2s (m) by vec4s (v) and store in vec2s (dest).
|
||||||
*
|
*
|
||||||
* @param[in] m matrix (left)
|
* @param[in] m mat4x2s (left)
|
||||||
* @param[in] v vector (right, column vector)
|
* @param[in] v vec4s (right, column vector)
|
||||||
* @returns destination vector (vec2s)
|
* @return[out] dest constructed vec2s from raw pointers
|
||||||
*/
|
*/
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
vec2s
|
vec2s
|
||||||
glms_mat4x2_(mulv)(mat4x2s m, vec4s v) {
|
glms_mat4x2_(mulv)(mat4x2s m, vec4s v) {
|
||||||
vec2s r;
|
vec2s dest;
|
||||||
glm_mat4x2_mulv(m.raw, v.raw, r.raw);
|
glm_mat4x2_mulv(m.raw, v.raw, dest.raw);
|
||||||
return r;
|
return dest;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief transpose matrix and store in dest
|
* @brief Transpose mat4x2s (m) and store in mat2x4s (dest).
|
||||||
*
|
*
|
||||||
* @param[in] m matrix
|
* @param[in] m mat4x2s (left)
|
||||||
* @param[out] dest result
|
* @return[out] dest constructed mat2x4s from raw pointers
|
||||||
*/
|
*/
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
mat2x4s
|
mat2x4s
|
||||||
glms_mat4x2_(transpose)(mat4x2s m) {
|
glms_mat4x2_(transpose)(mat4x2s m) {
|
||||||
mat2x4s r;
|
mat2x4s dest;
|
||||||
glm_mat4x2_transpose(m.raw, r.raw);
|
glm_mat4x2_transpose(m.raw, dest.raw);
|
||||||
return r;
|
return dest;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief scale (multiply with scalar) matrix
|
* @brief Multiply mat4x2s (m) by scalar constant (s).
|
||||||
*
|
*
|
||||||
* multiply matrix with scalar
|
* @param[in, out] m mat4x2s (src, dest)
|
||||||
*
|
* @param[in] s float (scalar)
|
||||||
* @param[in, out] m matrix
|
|
||||||
* @param[in] s scalar
|
|
||||||
*/
|
*/
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
mat4x2s
|
mat4x2s
|
||||||
|
|||||||
@@ -35,87 +35,85 @@
|
|||||||
#define GLMS_MAT4X3_ZERO ((mat4x3s)GLMS_MAT4X3_ZERO_INIT)
|
#define GLMS_MAT4X3_ZERO ((mat4x3s)GLMS_MAT4X3_ZERO_INIT)
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief make given matrix zero.
|
* @brief Zero out the mat4x3s (dest).
|
||||||
*
|
*
|
||||||
* @param[in, out] mat matrix
|
* @return[out] dest constructed mat4x3s from raw pointer
|
||||||
*/
|
*/
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
mat4x3s
|
mat4x3s
|
||||||
glms_mat4x3_(zero)(void) {
|
glms_mat4x3_(zero)(void) {
|
||||||
mat4x3s r;
|
mat4x3s dest;
|
||||||
glm_mat4x3_zero(r.raw);
|
glm_mat4x3_zero(dest.raw);
|
||||||
return r;
|
return dest;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief Create mat4x3 matrix from pointer
|
* @brief Create mat4x3s (dest) from pointer (src).
|
||||||
*
|
*
|
||||||
* @param[in] src pointer to an array of floats
|
* @param[in] src pointer to an array of floats
|
||||||
* @return constructed matrix from raw pointer
|
* @return[out] dest constructed mat4x3s from raw pointer
|
||||||
*/
|
*/
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
mat4x3s
|
mat4x3s
|
||||||
glms_mat4x3_(make)(const float * __restrict src) {
|
glms_mat4x3_(make)(const float * __restrict src) {
|
||||||
mat4x3s r;
|
mat4x3s dest;
|
||||||
glm_mat4x3_make(src, r.raw);
|
glm_mat4x3_make(src, dest.raw);
|
||||||
return r;
|
return dest;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief multiply m1 and m2 to dest
|
* @brief Multiply mat4x3s (m1) by mat3x4s (m2) and store in mat3s (dest).
|
||||||
*
|
*
|
||||||
* @code
|
* @code
|
||||||
* r = glms_mat4x3_mul(mat4x3s, mat3x4s);
|
* r = glms_mat4x3_mul(mat4x3s, mat3x4s);
|
||||||
* @endcode
|
* @endcode
|
||||||
*
|
*
|
||||||
* @param[in] m1 left matrix (mat4x3s)
|
* @param[in] m1 mat4x3s (left)
|
||||||
* @param[in] m2 right matrix (mat3x4s)
|
* @param[in] m2 mat3x4s (right)
|
||||||
* @returns destination matrix (mat3s)
|
* @return[out] dest constructed mat3s from raw pointers
|
||||||
*/
|
*/
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
mat3s
|
mat3s
|
||||||
glms_mat4x3_(mul)(mat4x3s m1, mat3x4s m2) {
|
glms_mat4x3_(mul)(mat4x3s m1, mat3x4s m2) {
|
||||||
mat3s r;
|
mat3s dest;
|
||||||
glm_mat4x3_mul(m1.raw, m2.raw, r.raw);
|
glm_mat4x3_mul(m1.raw, m2.raw, dest.raw);
|
||||||
return r;
|
return dest;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief multiply matrix with column vector and store in dest vector
|
* @brief Multiply mat4x3s (m) by vec4s (v) and store in vec3s (dest).
|
||||||
*
|
*
|
||||||
* @param[in] m matrix (left)
|
* @param[in] m mat4x3s (left)
|
||||||
* @param[in] v vector (right, column vector)
|
* @param[in] v vec4s (right, column vector)
|
||||||
* @returns destination vector (vec3s)
|
* @return[out] dest constructed vec3s from raw pointers
|
||||||
*/
|
*/
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
vec3s
|
vec3s
|
||||||
glms_mat4x3_(mulv)(mat4x3s m, vec4s v) {
|
glms_mat4x3_(mulv)(mat4x3s m, vec4s v) {
|
||||||
vec3s r;
|
vec3s dest;
|
||||||
glm_mat4x3_mulv(m.raw, v.raw, r.raw);
|
glm_mat4x3_mulv(m.raw, v.raw, dest.raw);
|
||||||
return r;
|
return dest;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief transpose matrix and store in dest
|
* @brief Transpose mat4x3s (m) and store in mat3x4s (dest).
|
||||||
*
|
*
|
||||||
* @param[in] m matrix
|
* @param[in] m mat4x3s (left)
|
||||||
* @param[out] dest result
|
* @return[out] dest constructed mat3x4s from raw pointers
|
||||||
*/
|
*/
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
mat3x4s
|
mat3x4s
|
||||||
glms_mat4x3_(transpose)(mat4x3s m) {
|
glms_mat4x3_(transpose)(mat4x3s m) {
|
||||||
mat3x4s r;
|
mat3x4s dest;
|
||||||
glm_mat4x3_transpose(m.raw, r.raw);
|
glm_mat4x3_transpose(m.raw, dest.raw);
|
||||||
return r;
|
return dest;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief scale (multiply with scalar) matrix
|
* @brief Multiply mat4x3s (m) by scalar constant (s).
|
||||||
*
|
*
|
||||||
* multiply matrix with scalar
|
* @param[in, out] m mat4x3s (src, dest)
|
||||||
*
|
* @param[in] s float (scalar)
|
||||||
* @param[in, out] m matrix
|
|
||||||
* @param[in] s scalar
|
|
||||||
*/
|
*/
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
mat4x3s
|
mat4x3s
|
||||||
|
|||||||
@@ -106,23 +106,35 @@ typedef vec3 mat4x3[4]; /* [col (4), row (3)] */
|
|||||||
#define GLM_PI_4 0.785398163397448309615660845819875721 /* pi/4 */
|
#define GLM_PI_4 0.785398163397448309615660845819875721 /* pi/4 */
|
||||||
#define GLM_1_PI 0.318309886183790671537767526745028724 /* 1/pi */
|
#define GLM_1_PI 0.318309886183790671537767526745028724 /* 1/pi */
|
||||||
#define GLM_2_PI 0.636619772367581343075535053490057448 /* 2/pi */
|
#define GLM_2_PI 0.636619772367581343075535053490057448 /* 2/pi */
|
||||||
|
#define GLM_TAU 6.283185307179586476925286766559005768 /* tau */
|
||||||
|
#define GLM_TAU_2 GLM_PI /* tau/2 */
|
||||||
|
#define GLM_TAU_4 GLM_PI_2 /* tau/4 */
|
||||||
|
#define GLM_1_TAU 0.159154943091895335768883763372514362 /* 1/tau */
|
||||||
|
#define GLM_2_TAU 0.318309886183790671537767526745028724 /* 2/tau */
|
||||||
#define GLM_2_SQRTPI 1.12837916709551257389615890312154517 /* 2/sqrt(pi) */
|
#define GLM_2_SQRTPI 1.12837916709551257389615890312154517 /* 2/sqrt(pi) */
|
||||||
|
#define GLM_SQRTTAU 2.506628274631000502415765284811045253 /* sqrt(tau) */
|
||||||
#define GLM_SQRT2 1.41421356237309504880168872420969808 /* sqrt(2) */
|
#define GLM_SQRT2 1.41421356237309504880168872420969808 /* sqrt(2) */
|
||||||
#define GLM_SQRT1_2 0.707106781186547524400844362104849039 /* 1/sqrt(2) */
|
#define GLM_SQRT1_2 0.707106781186547524400844362104849039 /* 1/sqrt(2) */
|
||||||
|
|
||||||
#define GLM_Ef ((float)GLM_E)
|
#define GLM_Ef ((float)GLM_E)
|
||||||
#define GLM_LOG2Ef ((float)GLM_LOG2E)
|
#define GLM_LOG2Ef ((float)GLM_LOG2E)
|
||||||
#define GLM_LOG10Ef ((float)GLM_LOG10E)
|
#define GLM_LOG10Ef ((float)GLM_LOG10E)
|
||||||
#define GLM_LN2f ((float)GLM_LN2)
|
#define GLM_LN2f ((float)GLM_LN2)
|
||||||
#define GLM_LN10f ((float)GLM_LN10)
|
#define GLM_LN10f ((float)GLM_LN10)
|
||||||
#define GLM_PIf ((float)GLM_PI)
|
#define GLM_PIf ((float)GLM_PI)
|
||||||
#define GLM_PI_2f ((float)GLM_PI_2)
|
#define GLM_PI_2f ((float)GLM_PI_2)
|
||||||
#define GLM_PI_4f ((float)GLM_PI_4)
|
#define GLM_PI_4f ((float)GLM_PI_4)
|
||||||
#define GLM_1_PIf ((float)GLM_1_PI)
|
#define GLM_1_PIf ((float)GLM_1_PI)
|
||||||
#define GLM_2_PIf ((float)GLM_2_PI)
|
#define GLM_2_PIf ((float)GLM_2_PI)
|
||||||
#define GLM_2_SQRTPIf ((float)GLM_2_SQRTPI)
|
#define GLM_TAUf ((float)GLM_TAU)
|
||||||
#define GLM_SQRT2f ((float)GLM_SQRT2)
|
#define GLM_TAU_2f ((float)GLM_TAU_2)
|
||||||
#define GLM_SQRT1_2f ((float)GLM_SQRT1_2)
|
#define GLM_TAU_4f ((float)GLM_TAU_4)
|
||||||
|
#define GLM_1_TAUf ((float)GLM_1_TAU)
|
||||||
|
#define GLM_2_TAUf ((float)GLM_2_TAU)
|
||||||
|
#define GLM_2_SQRTPIf ((float)GLM_2_SQRTPI)
|
||||||
|
#define GLM_2_SQRTTAUf ((float)GLM_SQRTTAU)
|
||||||
|
#define GLM_SQRT2f ((float)GLM_SQRT2)
|
||||||
|
#define GLM_SQRT1_2f ((float)GLM_SQRT1_2)
|
||||||
|
|
||||||
/* DEPRECATED! use GLM_PI and friends */
|
/* DEPRECATED! use GLM_PI and friends */
|
||||||
#define CGLM_PI GLM_PIf
|
#define CGLM_PI GLM_PIf
|
||||||
|
|||||||
@@ -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 */
|
||||||
|
|||||||
12
src/cam.c
12
src/cam.c
@@ -62,6 +62,12 @@ glmc_perspective(float fovy, float aspect, float nearZ, float farZ, mat4 dest) {
|
|||||||
glm_perspective(fovy, aspect, nearZ, farZ, dest);
|
glm_perspective(fovy, aspect, nearZ, farZ, dest);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_perspective_infinite(float fovy, float aspect, float nearZ, mat4 dest) {
|
||||||
|
glm_perspective_infinite(fovy, aspect, nearZ, dest);
|
||||||
|
}
|
||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
void
|
void
|
||||||
glmc_persp_move_far(mat4 proj, float deltaFar) {
|
glmc_persp_move_far(mat4 proj, float deltaFar) {
|
||||||
@@ -74,6 +80,12 @@ glmc_perspective_default(float aspect, mat4 dest) {
|
|||||||
glm_perspective_default(aspect, dest);
|
glm_perspective_default(aspect, dest);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_perspective_default_infinite(float aspect, mat4 dest) {
|
||||||
|
glm_perspective_default_infinite(aspect, dest);
|
||||||
|
}
|
||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
void
|
void
|
||||||
glmc_perspective_resize(float aspect, mat4 proj) {
|
glmc_perspective_resize(float aspect, mat4 proj) {
|
||||||
|
|||||||
@@ -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);
|
||||||
}
|
}
|
||||||
|
|||||||
12
src/mat2x3.c
12
src/mat2x3.c
@@ -10,14 +10,14 @@
|
|||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
void
|
void
|
||||||
glmc_mat2x3_copy(mat2x3 mat, mat2x3 dest) {
|
glmc_mat2x3_copy(mat2x3 src, mat2x3 dest) {
|
||||||
glm_mat2x3_copy(mat, dest);
|
glm_mat2x3_copy(src, dest);
|
||||||
}
|
}
|
||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
void
|
void
|
||||||
glmc_mat2x3_zero(mat2x3 mat) {
|
glmc_mat2x3_zero(mat2x3 m) {
|
||||||
glm_mat2x3_zero(mat);
|
glm_mat2x3_zero(m);
|
||||||
}
|
}
|
||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
@@ -40,8 +40,8 @@ glmc_mat2x3_mulv(mat2x3 m, vec2 v, vec3 dest) {
|
|||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
void
|
void
|
||||||
glmc_mat2x3_transpose(mat2x3 m, mat3x2 dest) {
|
glmc_mat2x3_transpose(mat2x3 src, mat3x2 dest) {
|
||||||
glm_mat2x3_transpose(m, dest);
|
glm_mat2x3_transpose(src, dest);
|
||||||
}
|
}
|
||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
|
|||||||
12
src/mat2x4.c
12
src/mat2x4.c
@@ -10,14 +10,14 @@
|
|||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
void
|
void
|
||||||
glmc_mat2x4_copy(mat2x4 mat, mat2x4 dest) {
|
glmc_mat2x4_copy(mat2x4 src, mat2x4 dest) {
|
||||||
glm_mat2x4_copy(mat, dest);
|
glm_mat2x4_copy(src, dest);
|
||||||
}
|
}
|
||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
void
|
void
|
||||||
glmc_mat2x4_zero(mat2x4 mat) {
|
glmc_mat2x4_zero(mat2x4 m) {
|
||||||
glm_mat2x4_zero(mat);
|
glm_mat2x4_zero(m);
|
||||||
}
|
}
|
||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
@@ -40,8 +40,8 @@ glmc_mat2x4_mulv(mat2x4 m, vec2 v, vec4 dest) {
|
|||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
void
|
void
|
||||||
glmc_mat2x4_transpose(mat2x4 m, mat4x2 dest) {
|
glmc_mat2x4_transpose(mat2x4 src, mat4x2 dest) {
|
||||||
glm_mat2x4_transpose(m, dest);
|
glm_mat2x4_transpose(src, dest);
|
||||||
}
|
}
|
||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
|
|||||||
@@ -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);
|
||||||
|
}
|
||||||
|
|||||||
12
src/mat3x2.c
12
src/mat3x2.c
@@ -10,14 +10,14 @@
|
|||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
void
|
void
|
||||||
glmc_mat3x2_copy(mat3x2 mat, mat3x2 dest) {
|
glmc_mat3x2_copy(mat3x2 src, mat3x2 dest) {
|
||||||
glm_mat3x2_copy(mat, dest);
|
glm_mat3x2_copy(src, dest);
|
||||||
}
|
}
|
||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
void
|
void
|
||||||
glmc_mat3x2_zero(mat3x2 mat) {
|
glmc_mat3x2_zero(mat3x2 m) {
|
||||||
glm_mat3x2_zero(mat);
|
glm_mat3x2_zero(m);
|
||||||
}
|
}
|
||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
@@ -40,8 +40,8 @@ glmc_mat3x2_mulv(mat3x2 m, vec3 v, vec2 dest) {
|
|||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
void
|
void
|
||||||
glmc_mat3x2_transpose(mat3x2 m, mat2x3 dest) {
|
glmc_mat3x2_transpose(mat3x2 src, mat2x3 dest) {
|
||||||
glm_mat3x2_transpose(m, dest);
|
glm_mat3x2_transpose(src, dest);
|
||||||
}
|
}
|
||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
|
|||||||
12
src/mat3x4.c
12
src/mat3x4.c
@@ -10,14 +10,14 @@
|
|||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
void
|
void
|
||||||
glmc_mat3x4_copy(mat3x4 mat, mat3x4 dest) {
|
glmc_mat3x4_copy(mat3x4 src, mat3x4 dest) {
|
||||||
glm_mat3x4_copy(mat, dest);
|
glm_mat3x4_copy(src, dest);
|
||||||
}
|
}
|
||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
void
|
void
|
||||||
glmc_mat3x4_zero(mat3x4 mat) {
|
glmc_mat3x4_zero(mat3x4 m) {
|
||||||
glm_mat3x4_zero(mat);
|
glm_mat3x4_zero(m);
|
||||||
}
|
}
|
||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
@@ -40,8 +40,8 @@ glmc_mat3x4_mulv(mat3x4 m, vec3 v, vec4 dest) {
|
|||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
void
|
void
|
||||||
glmc_mat3x4_transpose(mat3x4 m, mat4x3 dest) {
|
glmc_mat3x4_transpose(mat3x4 src, mat4x3 dest) {
|
||||||
glm_mat3x4_transpose(m, dest);
|
glm_mat3x4_transpose(src, dest);
|
||||||
}
|
}
|
||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
|
|||||||
@@ -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);
|
||||||
|
}
|
||||||
|
|||||||
12
src/mat4x2.c
12
src/mat4x2.c
@@ -10,14 +10,14 @@
|
|||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
void
|
void
|
||||||
glmc_mat4x2_copy(mat4x2 mat, mat4x2 dest) {
|
glmc_mat4x2_copy(mat4x2 src, mat4x2 dest) {
|
||||||
glm_mat4x2_copy(mat, dest);
|
glm_mat4x2_copy(src, dest);
|
||||||
}
|
}
|
||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
void
|
void
|
||||||
glmc_mat4x2_zero(mat4x2 mat) {
|
glmc_mat4x2_zero(mat4x2 m) {
|
||||||
glm_mat4x2_zero(mat);
|
glm_mat4x2_zero(m);
|
||||||
}
|
}
|
||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
@@ -40,8 +40,8 @@ glmc_mat4x2_mulv(mat4x2 m, vec4 v, vec2 dest) {
|
|||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
void
|
void
|
||||||
glmc_mat4x2_transpose(mat4x2 m, mat2x4 dest) {
|
glmc_mat4x2_transpose(mat4x2 src, mat2x4 dest) {
|
||||||
glm_mat4x2_transpose(m, dest);
|
glm_mat4x2_transpose(src, dest);
|
||||||
}
|
}
|
||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
|
|||||||
12
src/mat4x3.c
12
src/mat4x3.c
@@ -10,14 +10,14 @@
|
|||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
void
|
void
|
||||||
glmc_mat4x3_copy(mat4x3 mat, mat4x3 dest) {
|
glmc_mat4x3_copy(mat4x3 src, mat4x3 dest) {
|
||||||
glm_mat4x3_copy(mat, dest);
|
glm_mat4x3_copy(src, dest);
|
||||||
}
|
}
|
||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
void
|
void
|
||||||
glmc_mat4x3_zero(mat4x3 mat) {
|
glmc_mat4x3_zero(mat4x3 m) {
|
||||||
glm_mat4x3_zero(mat);
|
glm_mat4x3_zero(m);
|
||||||
}
|
}
|
||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
@@ -40,8 +40,8 @@ glmc_mat4x3_mulv(mat4x3 m, vec4 v, vec3 dest) {
|
|||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
void
|
void
|
||||||
glmc_mat4x3_transpose(mat4x3 m, mat3x4 dest) {
|
glmc_mat4x3_transpose(mat4x3 src, mat3x4 dest) {
|
||||||
glm_mat4x3_transpose(m, dest);
|
glm_mat4x3_transpose(src, dest);
|
||||||
}
|
}
|
||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
|
|||||||
@@ -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);
|
||||||
|
}
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ main(int argc, const char * argv[]) {
|
|||||||
test_entry_t *entry;
|
test_entry_t *entry;
|
||||||
test_status_t st;
|
test_status_t st;
|
||||||
int32_t i, count, passed, failed, maxlen;
|
int32_t i, count, passed, failed, maxlen;
|
||||||
double start, end, elapsed, total;
|
clock_t start, end, elapsed, total;
|
||||||
(void)argc;
|
(void)argc;
|
||||||
(void)argv;
|
(void)argv;
|
||||||
|
|
||||||
@@ -70,7 +70,7 @@ main(int argc, const char * argv[]) {
|
|||||||
fprintf(stderr, GREEN " " OK_TEXT RESET " %-*s ", maxlen, entry->name);
|
fprintf(stderr, GREEN " " OK_TEXT RESET " %-*s ", maxlen, entry->name);
|
||||||
|
|
||||||
if (elapsed > 0.01)
|
if (elapsed > 0.01)
|
||||||
fprintf(stderr, YELLOW "%.2fs", elapsed);
|
fprintf(stderr, YELLOW "%.2lus", elapsed);
|
||||||
else
|
else
|
||||||
fprintf(stderr, "0");
|
fprintf(stderr, "0");
|
||||||
|
|
||||||
@@ -85,7 +85,7 @@ main(int argc, const char * argv[]) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
CYAN "\ncglm test results (%0.2fs):\n" RESET
|
CYAN "\ncglm test results (%0.2lus):\n" RESET
|
||||||
"--------------------------\n"
|
"--------------------------\n"
|
||||||
|
|
||||||
MAGENTA "%d" RESET " tests ran, "
|
MAGENTA "%d" RESET " tests ran, "
|
||||||
|
|||||||
104
test/src/test_affine2d_post.h
Normal file
104
test/src/test_affine2d_post.h
Normal file
@@ -0,0 +1,104 @@
|
|||||||
|
/*
|
||||||
|
* 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"
|
||||||
|
|
||||||
|
TEST_IMPL(GLM_PREFIX, translated2d) {
|
||||||
|
mat3 m1, m2, tmp;
|
||||||
|
vec2 v = { 1.2f, 3.4f };
|
||||||
|
|
||||||
|
test_rand_transform2d(m1);
|
||||||
|
glm_mat3_copy(m1, m2);
|
||||||
|
GLM(translated2d)(m2, v);
|
||||||
|
|
||||||
|
glm_translate2d_make(tmp, v);
|
||||||
|
glm_mat3_mul(tmp, m1, m1);
|
||||||
|
|
||||||
|
test_assert_mat3_eq(m1, m2);
|
||||||
|
|
||||||
|
TEST_SUCCESS
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_IMPL(GLM_PREFIX, translated2d_x) {
|
||||||
|
mat3 m1, m2, tmp;
|
||||||
|
float x = test_rand();
|
||||||
|
|
||||||
|
test_rand_transform2d(m1);
|
||||||
|
glm_mat3_copy(m1, m2);
|
||||||
|
GLM(translated2d_x)(m2, x);
|
||||||
|
|
||||||
|
glm_translate2d_make(tmp, (vec2) { x, 0.0f });
|
||||||
|
glm_mat3_mul(tmp, m1, m1);
|
||||||
|
|
||||||
|
test_assert_mat3_eq(m1, m2);
|
||||||
|
|
||||||
|
TEST_SUCCESS
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_IMPL(GLM_PREFIX, translated2d_y) {
|
||||||
|
mat3 m1, m2, tmp;
|
||||||
|
float y = test_rand();
|
||||||
|
|
||||||
|
test_rand_transform2d(m1);
|
||||||
|
glm_mat3_copy(m1, m2);
|
||||||
|
GLM(translated2d_y)(m2, y);
|
||||||
|
|
||||||
|
glm_translate2d_make(tmp, (vec2) { 0.0f, y });
|
||||||
|
glm_mat3_mul(tmp, m1, m1);
|
||||||
|
|
||||||
|
test_assert_mat3_eq(m1, m2);
|
||||||
|
|
||||||
|
TEST_SUCCESS
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_IMPL(GLM_PREFIX, rotated2d) {
|
||||||
|
mat3 m1, m2, tmp;
|
||||||
|
float a = test_rand();
|
||||||
|
|
||||||
|
test_rand_transform2d(m1);
|
||||||
|
glm_mat3_copy(m1, m2);
|
||||||
|
GLM(rotated2d)(m2, a);
|
||||||
|
|
||||||
|
glm_rotate2d_make(tmp, a);
|
||||||
|
glm_mat3_mul(tmp, m1, m1);
|
||||||
|
|
||||||
|
test_assert_mat3_eq(m1, m2);
|
||||||
|
|
||||||
|
TEST_SUCCESS
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_IMPL(GLM_PREFIX, scaled2d) {
|
||||||
|
mat3 m1, m2, tmp;
|
||||||
|
vec2 v = { test_rand(), test_rand() };
|
||||||
|
|
||||||
|
test_rand_transform2d(m1);
|
||||||
|
glm_mat3_copy(m1, m2);
|
||||||
|
GLM(scaled2d)(m2, v);
|
||||||
|
|
||||||
|
glm_scale2d_make(tmp, v);
|
||||||
|
glm_mat3_mul(tmp, m1, m1);
|
||||||
|
|
||||||
|
test_assert_mat3_eq(m1, m2);
|
||||||
|
|
||||||
|
TEST_SUCCESS
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_IMPL(GLM_PREFIX, scaled2d_uni) {
|
||||||
|
mat3 m1, m2, tmp;
|
||||||
|
float s = test_rand();
|
||||||
|
|
||||||
|
test_rand_transform2d(m1);
|
||||||
|
glm_mat3_copy(m1, m2);
|
||||||
|
GLM(scaled2d_uni)(m2, s);
|
||||||
|
|
||||||
|
glm_scale2d_make(tmp, (vec2) { s, s });
|
||||||
|
glm_mat3_mul(tmp, m1, m1);
|
||||||
|
|
||||||
|
test_assert_mat3_eq(m1, m2);
|
||||||
|
|
||||||
|
TEST_SUCCESS
|
||||||
|
}
|
||||||
@@ -61,8 +61,8 @@ TEST_IMPL(GLM_PREFIX, mul_rot) {
|
|||||||
mat4 m4 = GLM_MAT4_ZERO_INIT;
|
mat4 m4 = GLM_MAT4_ZERO_INIT;
|
||||||
int i, j, k;
|
int i, j, k;
|
||||||
|
|
||||||
glm_rotate(m1, drand48(), (vec3){drand48(), drand48(), drand48()});
|
glm_rotate(m1, frand48(), (vec3){frand48(), frand48(), frand48()});
|
||||||
glm_rotate(m2, drand48(), (vec3){drand48(), drand48(), drand48()});
|
glm_rotate(m2, frand48(), (vec3){frand48(), frand48(), frand48()});
|
||||||
|
|
||||||
GLM(mul_rot)(m1, m2, m3);
|
GLM(mul_rot)(m1, m2, m3);
|
||||||
for (i = 0; i < 4; i++) {
|
for (i = 0; i < 4; i++) {
|
||||||
|
|||||||
@@ -11,49 +11,49 @@ test_rand_mat4(mat4 dest) {
|
|||||||
glm_mat4_copy(GLM_MAT4_IDENTITY, dest);
|
glm_mat4_copy(GLM_MAT4_IDENTITY, dest);
|
||||||
|
|
||||||
/* random position */
|
/* random position */
|
||||||
dest[3][0] = drand48();
|
dest[3][0] = frand48();
|
||||||
dest[3][1] = drand48();
|
dest[3][1] = frand48();
|
||||||
dest[3][2] = drand48();
|
dest[3][2] = frand48();
|
||||||
|
|
||||||
/* random rotatation around random axis with random angle */
|
/* random rotatation around random axis with random angle */
|
||||||
glm_rotate(dest, drand48(), (vec3){drand48(), drand48(), drand48()});
|
glm_rotate(dest, frand48(), (vec3){frand48(), frand48(), frand48()});
|
||||||
|
|
||||||
/* random scale */
|
/* random scale */
|
||||||
/* glm_scale(dest, (vec3){drand48(), drand48(), drand48()}); */
|
/* glm_scale(dest, (vec3){frand48(), frand48(), frand48()}); */
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
test_rand_mat4x2(mat4x2 dest) {
|
test_rand_mat4x2(mat4x2 dest) {
|
||||||
dest[0][0] = drand48();
|
dest[0][0] = frand48();
|
||||||
dest[0][1] = drand48();
|
dest[0][1] = frand48();
|
||||||
|
|
||||||
dest[1][0] = drand48();
|
dest[1][0] = frand48();
|
||||||
dest[1][1] = drand48();
|
dest[1][1] = frand48();
|
||||||
|
|
||||||
dest[2][0] = drand48();
|
dest[2][0] = frand48();
|
||||||
dest[2][1] = drand48();
|
dest[2][1] = frand48();
|
||||||
|
|
||||||
dest[3][0] = drand48();
|
dest[3][0] = frand48();
|
||||||
dest[3][1] = drand48();
|
dest[3][1] = frand48();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
test_rand_mat4x3(mat4x3 dest) {
|
test_rand_mat4x3(mat4x3 dest) {
|
||||||
dest[0][0] = drand48();
|
dest[0][0] = frand48();
|
||||||
dest[0][1] = drand48();
|
dest[0][1] = frand48();
|
||||||
dest[0][2] = drand48();
|
dest[0][2] = frand48();
|
||||||
|
|
||||||
dest[1][0] = drand48();
|
dest[1][0] = frand48();
|
||||||
dest[1][1] = drand48();
|
dest[1][1] = frand48();
|
||||||
dest[1][2] = drand48();
|
dest[1][2] = frand48();
|
||||||
|
|
||||||
dest[2][0] = drand48();
|
dest[2][0] = frand48();
|
||||||
dest[2][1] = drand48();
|
dest[2][1] = frand48();
|
||||||
dest[2][2] = drand48();
|
dest[2][2] = frand48();
|
||||||
|
|
||||||
dest[3][0] = drand48();
|
dest[3][0] = frand48();
|
||||||
dest[3][1] = drand48();
|
dest[3][1] = frand48();
|
||||||
dest[3][2] = drand48();
|
dest[3][2] = frand48();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -61,73 +61,80 @@ test_rand_mat3(mat3 dest) {
|
|||||||
mat4 m4;
|
mat4 m4;
|
||||||
|
|
||||||
/* random rotatation around random axis with random angle */
|
/* random rotatation around random axis with random angle */
|
||||||
glm_rotate_make(m4, drand48(), (vec3){drand48(), drand48(), drand48()});
|
glm_rotate_make(m4, frand48(), (vec3){frand48(), frand48(), frand48()});
|
||||||
glm_mat4_pick3(m4, dest);
|
glm_mat4_pick3(m4, dest);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
test_rand_mat3x2(mat3x2 dest) {
|
test_rand_mat3x2(mat3x2 dest) {
|
||||||
dest[0][0] = drand48();
|
dest[0][0] = frand48();
|
||||||
dest[0][1] = drand48();
|
dest[0][1] = frand48();
|
||||||
dest[1][0] = drand48();
|
dest[1][0] = frand48();
|
||||||
dest[1][1] = drand48();
|
dest[1][1] = frand48();
|
||||||
dest[2][0] = drand48();
|
dest[2][0] = frand48();
|
||||||
dest[2][1] = drand48();
|
dest[2][1] = frand48();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
test_rand_mat3x4(mat3x4 dest) {
|
test_rand_mat3x4(mat3x4 dest) {
|
||||||
dest[0][0] = drand48();
|
dest[0][0] = frand48();
|
||||||
dest[0][1] = drand48();
|
dest[0][1] = frand48();
|
||||||
dest[0][2] = drand48();
|
dest[0][2] = frand48();
|
||||||
dest[0][3] = drand48();
|
dest[0][3] = frand48();
|
||||||
|
|
||||||
dest[1][0] = drand48();
|
dest[1][0] = frand48();
|
||||||
dest[1][1] = drand48();
|
dest[1][1] = frand48();
|
||||||
dest[1][2] = drand48();
|
dest[1][2] = frand48();
|
||||||
dest[1][3] = drand48();
|
dest[1][3] = frand48();
|
||||||
|
|
||||||
dest[2][0] = drand48();
|
dest[2][0] = frand48();
|
||||||
dest[2][1] = drand48();
|
dest[2][1] = frand48();
|
||||||
dest[2][2] = drand48();
|
dest[2][2] = frand48();
|
||||||
dest[2][3] = drand48();
|
dest[2][3] = frand48();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
test_rand_mat2(mat2 dest) {
|
test_rand_mat2(mat2 dest) {
|
||||||
dest[0][0] = drand48();
|
dest[0][0] = frand48();
|
||||||
dest[0][1] = drand48();
|
dest[0][1] = frand48();
|
||||||
dest[1][0] = drand48();
|
dest[1][0] = frand48();
|
||||||
dest[1][1] = drand48();
|
dest[1][1] = frand48();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
test_rand_mat2x3(mat2x3 dest) {
|
test_rand_mat2x3(mat2x3 dest) {
|
||||||
dest[0][0] = drand48();
|
dest[0][0] = frand48();
|
||||||
dest[0][1] = drand48();
|
dest[0][1] = frand48();
|
||||||
dest[0][2] = drand48();
|
dest[0][2] = frand48();
|
||||||
dest[1][0] = drand48();
|
dest[1][0] = frand48();
|
||||||
dest[1][1] = drand48();
|
dest[1][1] = frand48();
|
||||||
dest[1][2] = drand48();
|
dest[1][2] = frand48();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
test_rand_mat2x4(mat2x4 dest) {
|
test_rand_mat2x4(mat2x4 dest) {
|
||||||
dest[0][0] = drand48();
|
dest[0][0] = frand48();
|
||||||
dest[0][1] = drand48();
|
dest[0][1] = frand48();
|
||||||
dest[0][2] = drand48();
|
dest[0][2] = frand48();
|
||||||
dest[0][3] = drand48();
|
dest[0][3] = frand48();
|
||||||
dest[1][0] = drand48();
|
dest[1][0] = frand48();
|
||||||
dest[1][1] = drand48();
|
dest[1][1] = frand48();
|
||||||
dest[1][2] = drand48();
|
dest[1][2] = frand48();
|
||||||
dest[1][3] = drand48();
|
dest[1][3] = frand48();
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
test_rand_transform2d(mat3 dest) {
|
||||||
|
glm_translate2d_make(dest, (vec2) { frand48(), frand48() });
|
||||||
|
glm_rotate2d(dest, frand48());
|
||||||
|
glm_scale2d(dest, (vec2) { frand48(), frand48() });
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
test_rand_vec3(vec3 dest) {
|
test_rand_vec3(vec3 dest) {
|
||||||
dest[0] = drand48();
|
dest[0] = frand48();
|
||||||
dest[1] = drand48();
|
dest[1] = frand48();
|
||||||
dest[2] = drand48();
|
dest[2] = frand48();
|
||||||
}
|
}
|
||||||
|
|
||||||
vec3s
|
vec3s
|
||||||
@@ -139,10 +146,10 @@ test_rand_vec3s(void) {
|
|||||||
|
|
||||||
void
|
void
|
||||||
test_rand_vec4(vec4 dest) {
|
test_rand_vec4(vec4 dest) {
|
||||||
dest[0] = drand48();
|
dest[0] = frand48();
|
||||||
dest[1] = drand48();
|
dest[1] = frand48();
|
||||||
dest[2] = drand48();
|
dest[2] = frand48();
|
||||||
dest[3] = drand48();
|
dest[3] = frand48();
|
||||||
}
|
}
|
||||||
|
|
||||||
vec4s
|
vec4s
|
||||||
@@ -154,12 +161,12 @@ test_rand_vec4s(void) {
|
|||||||
|
|
||||||
float
|
float
|
||||||
test_rand(void) {
|
test_rand(void) {
|
||||||
return drand48();
|
return frand48();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
test_rand_quat(versor q) {
|
test_rand_quat(versor q) {
|
||||||
glm_quat(q, drand48(), drand48(), drand48(), drand48());
|
glm_quat(q, frand48(), frand48(), frand48(), frand48());
|
||||||
glm_quat_normalize(q);
|
glm_quat_normalize(q);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -169,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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -182,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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -208,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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -221,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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -277,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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -303,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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -316,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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -329,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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -385,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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -411,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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -467,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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -493,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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -502,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
|
||||||
}
|
}
|
||||||
@@ -533,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
|
||||||
}
|
}
|
||||||
@@ -550,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
|
||||||
}
|
}
|
||||||
@@ -572,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
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,6 +41,9 @@ test_rand_mat2x3(mat2x3 dest);
|
|||||||
void
|
void
|
||||||
test_rand_mat2x4(mat2x4 dest);
|
test_rand_mat2x4(mat2x4 dest);
|
||||||
|
|
||||||
|
void
|
||||||
|
test_rand_transform2d(mat3 dest);
|
||||||
|
|
||||||
test_status_t
|
test_status_t
|
||||||
test_assert_eqf(float a, float b);
|
test_assert_eqf(float a, float b);
|
||||||
|
|
||||||
@@ -173,4 +176,11 @@ test_eq_th(float a, float b, float th) {
|
|||||||
return fabsf(a - b) <= th;
|
return fabsf(a - b) <= th;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* drand with explicit conversion to lower precision */
|
||||||
|
CGLM_INLINE
|
||||||
|
float
|
||||||
|
frand48(void) {
|
||||||
|
return (float)drand48();
|
||||||
|
}
|
||||||
|
|
||||||
#endif /* test_common_h */
|
#endif /* test_common_h */
|
||||||
|
|||||||
@@ -196,11 +196,12 @@ TEST_IMPL(GLM_PREFIX, mat2_trace) {
|
|||||||
TEST_IMPL(GLM_PREFIX, mat2_scale) {
|
TEST_IMPL(GLM_PREFIX, mat2_scale) {
|
||||||
mat2 m1 = A_MATRIX2x2;
|
mat2 m1 = A_MATRIX2x2;
|
||||||
mat2 m2 = A_MATRIX2x2;
|
mat2 m2 = A_MATRIX2x2;
|
||||||
int i, j, scale;
|
int i, j;
|
||||||
|
float scale;
|
||||||
|
|
||||||
scale = rand() % 100;
|
scale = rand() % 100;
|
||||||
|
|
||||||
GLM(mat2_scale)(m1, (float)scale);
|
GLM(mat2_scale)(m1, scale);
|
||||||
|
|
||||||
for (i = 0; i < 2; i++) {
|
for (i = 0; i < 2; i++) {
|
||||||
for (j = 0; j < 2; j++) {
|
for (j = 0; j < 2; j++) {
|
||||||
|
|||||||
@@ -140,11 +140,12 @@ TEST_IMPL(GLM_PREFIX, mat2x3_transpose) {
|
|||||||
TEST_IMPL(GLM_PREFIX, mat2x3_scale) {
|
TEST_IMPL(GLM_PREFIX, mat2x3_scale) {
|
||||||
mat2x3 m1 = A_MATRIX2X3;
|
mat2x3 m1 = A_MATRIX2X3;
|
||||||
mat2x3 m2 = A_MATRIX2X3;
|
mat2x3 m2 = A_MATRIX2X3;
|
||||||
int i, j, scale;
|
int i, j;
|
||||||
|
float scale;
|
||||||
|
|
||||||
scale = rand() % 100;
|
scale = rand() % 100;
|
||||||
|
|
||||||
GLM(mat2x3_scale)(m1, (float) scale);
|
GLM(mat2x3_scale)(m1, scale);
|
||||||
|
|
||||||
for (i = 0; i < 2; i++) {
|
for (i = 0; i < 2; i++) {
|
||||||
for (j = 0; j < 3; j++) {
|
for (j = 0; j < 3; j++) {
|
||||||
|
|||||||
@@ -143,11 +143,12 @@ TEST_IMPL(GLM_PREFIX, mat2x4_transpose) {
|
|||||||
TEST_IMPL(GLM_PREFIX, mat2x4_scale) {
|
TEST_IMPL(GLM_PREFIX, mat2x4_scale) {
|
||||||
mat2x4 m1 = A_MATRIX2X4;
|
mat2x4 m1 = A_MATRIX2X4;
|
||||||
mat2x4 m2 = A_MATRIX2X4;
|
mat2x4 m2 = A_MATRIX2X4;
|
||||||
int i, j, scale;
|
int i, j;
|
||||||
|
float scale;
|
||||||
|
|
||||||
scale = rand() % 100;
|
scale = rand() % 100;
|
||||||
|
|
||||||
GLM(mat2x4_scale)(m1, (float) scale);
|
GLM(mat2x4_scale)(m1, scale);
|
||||||
|
|
||||||
for (i = 0; i < 2; i++) {
|
for (i = 0; i < 2; i++) {
|
||||||
for (j = 0; j < 4; j++) {
|
for (j = 0; j < 4; j++) {
|
||||||
|
|||||||
@@ -184,11 +184,12 @@ TEST_IMPL(GLM_PREFIX, mat3_transpose) {
|
|||||||
TEST_IMPL(GLM_PREFIX, mat3_scale) {
|
TEST_IMPL(GLM_PREFIX, mat3_scale) {
|
||||||
mat3 m1 = A_MATRIX;
|
mat3 m1 = A_MATRIX;
|
||||||
mat3 m2 = A_MATRIX;
|
mat3 m2 = A_MATRIX;
|
||||||
int i, j, k, scale;
|
int i, j, k;
|
||||||
|
float scale;
|
||||||
|
|
||||||
scale = rand() % 100;
|
scale = rand() % 100;
|
||||||
|
|
||||||
GLM(mat3_scale)(m1, (float)scale);
|
GLM(mat3_scale)(m1, scale);
|
||||||
|
|
||||||
for (i = 0; i < 3; i++) {
|
for (i = 0; i < 3; i++) {
|
||||||
for (j = 0; j < 3; j++) {
|
for (j = 0; j < 3; j++) {
|
||||||
@@ -326,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
|
||||||
|
|||||||
@@ -139,11 +139,12 @@ TEST_IMPL(GLM_PREFIX, mat3x2_transpose) {
|
|||||||
TEST_IMPL(GLM_PREFIX, mat3x2_scale) {
|
TEST_IMPL(GLM_PREFIX, mat3x2_scale) {
|
||||||
mat3x2 m1 = A_MATRIX3X2;
|
mat3x2 m1 = A_MATRIX3X2;
|
||||||
mat3x2 m2 = A_MATRIX3X2;
|
mat3x2 m2 = A_MATRIX3X2;
|
||||||
int i, j, scale;
|
int i, j;
|
||||||
|
float scale;
|
||||||
|
|
||||||
scale = rand() % 100;
|
scale = rand() % 100;
|
||||||
|
|
||||||
GLM(mat3x2_scale)(m1, (float) scale);
|
GLM(mat3x2_scale)(m1, scale);
|
||||||
|
|
||||||
for (i = 0; i < 3; i++) {
|
for (i = 0; i < 3; i++) {
|
||||||
for (j = 0; j < 2; j++) {
|
for (j = 0; j < 2; j++) {
|
||||||
|
|||||||
@@ -145,11 +145,12 @@ TEST_IMPL(GLM_PREFIX, mat3x4_transpose) {
|
|||||||
TEST_IMPL(GLM_PREFIX, mat3x4_scale) {
|
TEST_IMPL(GLM_PREFIX, mat3x4_scale) {
|
||||||
mat3x4 m1 = A_MATRIX3X4;
|
mat3x4 m1 = A_MATRIX3X4;
|
||||||
mat3x4 m2 = A_MATRIX3X4;
|
mat3x4 m2 = A_MATRIX3X4;
|
||||||
int i, j, scale;
|
int i, j;
|
||||||
|
float scale;
|
||||||
|
|
||||||
scale = rand() % 100;
|
scale = rand() % 100;
|
||||||
|
|
||||||
GLM(mat3x4_scale)(m1, (float) scale);
|
GLM(mat3x4_scale)(m1, scale);
|
||||||
|
|
||||||
for (i = 0; i < 3; i++) {
|
for (i = 0; i < 3; i++) {
|
||||||
for (j = 0; j < 4; j++) {
|
for (j = 0; j < 4; j++) {
|
||||||
|
|||||||
@@ -292,11 +292,12 @@ TEST_IMPL(GLM_PREFIX, mat4_transpose) {
|
|||||||
TEST_IMPL(GLM_PREFIX, mat4_scale_p) {
|
TEST_IMPL(GLM_PREFIX, mat4_scale_p) {
|
||||||
mat4 m1 = A_MATRIX;
|
mat4 m1 = A_MATRIX;
|
||||||
mat4 m2 = A_MATRIX;
|
mat4 m2 = A_MATRIX;
|
||||||
int i, j, k, scale;
|
int i, j, k;
|
||||||
|
float scale;
|
||||||
|
|
||||||
scale = rand() % 100;
|
scale = rand() % 100;
|
||||||
|
|
||||||
GLM(mat4_scale_p)(m1, (float)scale);
|
GLM(mat4_scale_p)(m1, scale);
|
||||||
|
|
||||||
for (i = 0; i < 4; i++) {
|
for (i = 0; i < 4; i++) {
|
||||||
for (j = 0; j < 4; j++) {
|
for (j = 0; j < 4; j++) {
|
||||||
@@ -311,11 +312,12 @@ TEST_IMPL(GLM_PREFIX, mat4_scale_p) {
|
|||||||
TEST_IMPL(GLM_PREFIX, mat4_scale) {
|
TEST_IMPL(GLM_PREFIX, mat4_scale) {
|
||||||
mat4 m1 = A_MATRIX;
|
mat4 m1 = A_MATRIX;
|
||||||
mat4 m2 = A_MATRIX;
|
mat4 m2 = A_MATRIX;
|
||||||
int i, j, k, scale;
|
int i, j, k;
|
||||||
|
float scale;
|
||||||
|
|
||||||
scale = rand() % 100;
|
scale = rand() % 100;
|
||||||
|
|
||||||
GLM(mat4_scale)(m1, (float)scale);
|
GLM(mat4_scale)(m1, scale);
|
||||||
|
|
||||||
for (i = 0; i < 4; i++) {
|
for (i = 0; i < 4; i++) {
|
||||||
for (j = 0; j < 4; j++) {
|
for (j = 0; j < 4; j++) {
|
||||||
@@ -502,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
|
||||||
|
|||||||
@@ -142,11 +142,12 @@ TEST_IMPL(GLM_PREFIX, mat4x2_transpose) {
|
|||||||
TEST_IMPL(GLM_PREFIX, mat4x2_scale) {
|
TEST_IMPL(GLM_PREFIX, mat4x2_scale) {
|
||||||
mat4x2 m1 = A_MATRIX4X2;
|
mat4x2 m1 = A_MATRIX4X2;
|
||||||
mat4x2 m2 = A_MATRIX4X2;
|
mat4x2 m2 = A_MATRIX4X2;
|
||||||
int i, j, scale;
|
int i, j;
|
||||||
|
float scale;
|
||||||
|
|
||||||
scale = rand() % 100;
|
scale = rand() % 100;
|
||||||
|
|
||||||
GLM(mat4x2_scale)(m1, (float) scale);
|
GLM(mat4x2_scale)(m1, scale);
|
||||||
|
|
||||||
for (i = 0; i < 4; i++) {
|
for (i = 0; i < 4; i++) {
|
||||||
for (j = 0; j < 2; j++) {
|
for (j = 0; j < 2; j++) {
|
||||||
|
|||||||
@@ -146,11 +146,12 @@ TEST_IMPL(GLM_PREFIX, mat4x3_transpose) {
|
|||||||
TEST_IMPL(GLM_PREFIX, mat4x3_scale) {
|
TEST_IMPL(GLM_PREFIX, mat4x3_scale) {
|
||||||
mat4x3 m1 = A_MATRIX4X3;
|
mat4x3 m1 = A_MATRIX4X3;
|
||||||
mat4x3 m2 = A_MATRIX4X3;
|
mat4x3 m2 = A_MATRIX4X3;
|
||||||
int i, j, scale;
|
int i, j;
|
||||||
|
float scale;
|
||||||
|
|
||||||
scale = rand() % 100;
|
scale = rand() % 100;
|
||||||
|
|
||||||
GLM(mat4x3_scale)(m1, (float) scale);
|
GLM(mat4x3_scale)(m1, scale);
|
||||||
|
|
||||||
for (i = 0; i < 4; i++) {
|
for (i = 0; i < 4; i++) {
|
||||||
for (j = 0; j < 3; j++) {
|
for (j = 0; j < 3; j++) {
|
||||||
|
|||||||
@@ -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
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,6 +33,7 @@
|
|||||||
#include "test_noise.h"
|
#include "test_noise.h"
|
||||||
#include "test_affine.h"
|
#include "test_affine.h"
|
||||||
#include "test_affine2d.h"
|
#include "test_affine2d.h"
|
||||||
|
#include "test_affine2d_post.h"
|
||||||
#include "test_affine_mat.h"
|
#include "test_affine_mat.h"
|
||||||
#include "test_aabb2d.h"
|
#include "test_aabb2d.h"
|
||||||
#include "test_ray.h"
|
#include "test_ray.h"
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user