Compare commits

...

60 Commits

Author SHA1 Message Date
Recep Aslantas
83d5b2c973 docs: add infinite perspective 2026-02-10 22:59:46 +03:00
Recep Aslantas
7e1bdd0676 Merge pull request #489 from Lephar/master
Implement infinite perspective projection matrix creation functions
2026-02-10 22:45:21 +03:00
Ali Emre Gülcü
0dc17e5d47 Implement default infinite perspective projection matrix creation functions 2026-02-10 16:35:50 +03:00
Ali Emre Gülcü
d6c6b4c542 Implement infinite perspective projection matrix creation functions 2026-02-10 12:30:11 +03:00
Recep Aslantas
0356534c0c Merge pull request #488 from lesleyrs/wextra
fix -ffast-math with -Wextra warnings
2026-01-31 14:44:49 +03:00
lesleyrs
5ff0d80c85 fix -ffast-math with -Wextra warnings 2026-01-22 16:09:11 +01:00
Recep Aslantas
1952042f2c Merge pull request #487 from tayoky/master
add glm_vecx_swap functions
2025-11-19 23:44:21 +03:00
tayoky
3aad5823ca add glm_vecx_swap functions 2025-11-15 10:39:14 +01:00
Recep Aslantas
da957fa421 Merge pull request #483 from Lephar/master
Add missing glmc_perspective_resize_**_**() call/clipspace functions
2025-11-08 17:41:00 +03:00
Ali Emre Gülcü
47e5d48749 Add missing glmc_perspective_resize_**_**() call/clipspace functions 2025-11-05 09:56:28 +03:00
Recep Aslantas
a4602f2d5f Merge pull request #478 from fd00/fix-make
Fix `make` on `srcdir != builddir`
2025-06-18 17:44:56 +03:00
Daisuke Fujimura (fd0)
6af4e0d565 Fix make on srcdir != builddir 2025-06-18 20:55:40 +09:00
Recep Aslantas
a311dbfe4c Merge pull request #476 from aganm/double-promotion
Fix double-promotion warnings in tests
2025-05-13 12:33:55 +03:00
Michael Aganier
a761088e15 Fix double-promotion warnings in tests 2025-05-12 17:38:21 -04:00
Recep Aslantas
a886d6e170 Merge pull request #471 from under-view/feature/mat3-tables
mat3: add tables to docs & fix comments
2025-04-24 16:07:51 +03:00
Recep Aslantas
1a8b105ce6 Merge pull request #472 from under-view/mat2-docs-cleanup
mat2: docs cleanup
2025-04-24 16:07:31 +03:00
Vincent Davis Jr
ec5f8074c4 mat2: docs cleanup
Signed-off-by: Vincent Davis Jr <vince@underview.tech>
2025-04-17 18:08:50 -04:00
Vincent Davis Jr
6f5fde8b52 mat3: add tables to docs & fix comments
Signed-off-by: Vincent Davis Jr <vince@underview.tech>
2025-04-17 14:22:00 -04:00
Recep Aslantas
9da4e78c2e Merge pull request #469 from under-view/feature/mat2-tables
mat2: add tables to docs & fix comments
2025-04-11 17:14:17 +03:00
Vincent Davis Jr
27a3ddc928 gitignore: ignore vim swp files
Signed-off-by: Vincent Davis Jr <vince@underview.tech>
2025-04-11 00:13:55 -04:00
Vincent Davis Jr
5d530cd8e0 mat2: add tables to docs & fix comments
Signed-off-by: Vincent Davis Jr <vince@underview.tech>
2025-04-11 00:13:54 -04:00
Vincent Davis Jr
dde053a295 mat2x3[docs]: fix glm_mat2x3_zero parameters
Signed-off-by: Vincent Davis Jr <vince@underview.tech>
2025-04-05 09:58:49 -04:00
Recep Aslantas
2128235d42 Merge pull request #467 from recp/textrans
build texture transform matrix helper
2025-04-05 13:52:15 +03:00
Recep Aslantas
9fb418bcac Update include/cglm/mat3.h
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-04-05 13:36:12 +03:00
Recep Aslantas
5fde20d65c build texture transform matrix helper 2025-04-05 13:32:47 +03:00
Recep Aslantas
ebc65782f8 Merge pull request #466 from recp/integration_1 2025-04-05 06:32:01 +03:00
Recep Aslantas
1bd04c819b some apple simd framework integration helpers 2025-04-04 23:02:12 +03:00
Recep Aslantas
8560da0e70 define __cglm__ to publish cglm availability universally
in this way we wont need to check arbitrary header check e.g. cglm_common_h
2025-04-04 23:01:55 +03:00
Recep Aslantas
ed7a658637 Merge pull request #465 from under-view/feature/mat4x3-tables
mat4x3: add tables to docs & fix comments
2025-04-04 22:57:01 +03:00
Recep Aslantas
bcc475e2b7 Merge pull request #464 from under-view/feature/mat4x2-tables
mat4x2: add tables to docs & fix comments
2025-04-04 22:56:30 +03:00
Vincent Davis Jr
bdca98ba48 mat4x2: add tables to docs & fix comments
Signed-off-by: Vincent Davis Jr <vince@underview.tech>
2025-04-04 13:29:10 -04:00
Vincent Davis Jr
b33e29d50f mat4x3: add tables to docs & fix comments
Signed-off-by: Vincent Davis Jr <vince@underview.tech>
2025-04-04 13:22:27 -04:00
Vincent Davis Jr
4b3e9bb779 mat3x2: fix scale comment
Signed-off-by: Vincent Davis Jr <vince@underview.tech>
2025-04-04 11:04:44 -04:00
Recep Aslantas
214842db27 Merge pull request #462 from under-view/feature/mat3x4-tables
mat3x4: add tables to docs & fix comments
2025-04-03 21:42:27 +03:00
Recep Aslantas
60e4d6c188 Merge pull request #461 from under-view/feature/mat3x2-tables
mat3x2: add tables to docs & fix comments
2025-04-03 21:41:44 +03:00
Recep Aslantas
5063d4b2b0 Merge pull request #460 from under-view/feature/mat2x4-tables
mat2x4: add tables to docs & fix comments
2025-04-03 21:40:57 +03:00
Recep Aslantas
a16bc2ae4a Merge pull request #459 from under-view/feature/mat2x3-tables
mat2x3: add tables to docs & fix comments
2025-04-03 21:38:32 +03:00
Vincent Davis Jr
b694c97204 mat2x4: add tables to docs & fix comments
Signed-off-by: Vincent Davis Jr <vince@underview.tech>
2025-04-03 11:30:34 -04:00
Vincent Davis Jr
4791fe3f24 mat3x4: add tables to docs & fix comments
Signed-off-by: Vincent Davis Jr <vince@underview.tech>
2025-04-03 11:27:00 -04:00
Vincent Davis Jr
b64067a94d mat3x2: add tables to docs & fix comments
Signed-off-by: Vincent Davis Jr <vince@underview.tech>
2025-04-03 01:22:55 -04:00
Vincent Davis Jr
43363e8c43 mat2x3: add tables to docs & fix comments
Signed-off-by: Vincent Davis Jr <vince@underview.tech>
2025-04-02 19:59:20 -04:00
Recep Aslantas
f3094cdc65 add missing almm_*_set1() to arm and wasm 2025-03-19 23:28:58 +03:00
Recep Aslantas
a7bd64952e Update .gitignore 2025-03-19 23:28:26 +03:00
Recep Aslantas
4141298161 Merge pull request #452 from RolandMarchand/add-tau-constants
Added Tau constant definitions to types.h
2025-03-19 17:27:45 +03:00
Recep Aslantas
05979281ac Merge pull request #457 from MarcinKonowalczyk/typo
Typo
2025-03-19 17:24:56 +03:00
Recep Aslantas
4b3dcceb9d Merge pull request #456 from MarcinKonowalczyk/w-conversion
Add -Wconversion
2025-03-19 17:22:55 +03:00
Marcin
cfb8cd9447 more mat4's 2025-03-18 14:17:35 +00:00
Marcin
8d01d1d135 mat4 in docs 2025-03-18 14:14:37 +00:00
Marcin
c6caddc75e frand48 2025-03-18 13:30:59 +00:00
Marcin
8b810c2280 -Wconversion 2025-03-18 13:25:32 +00:00
Marcin
fd3b21f5d7 newline 2025-03-18 13:24:28 +00:00
Marcin
c1ea9e7a69 -Wextra and -Wpedantic 2025-03-18 13:24:23 +00:00
Roland Marchand
44b5952ec3 Added Tau constant definitions to types.h 2025-03-11 08:05:51 -04:00
Recep Aslantas
6e2976d415 Merge pull request #450 from ATMI/affine2d-post
Added 2D Post Transformations
2025-02-22 14:49:35 +03:00
Artemii Miasoedov
9a7f52202d Fixed broken formatting in test_common.c 2025-02-16 15:55:40 +03:00
Artemii Miasoedov
e96b6a382d Added tests for 2D affine post transformations (translate, rotate, scale) 2025-02-16 15:50:53 +03:00
Artemii Miasoedov
091c475422 Implemented 2D affine post transformations (translate, rotate, scale) 2025-02-16 14:39:10 +03:00
Recep Aslantas
144d1e7c29 build: add missing call/aabb2d.h 2025-02-13 22:35:16 +03:00
Recep Aslantas
643700c05e now working on v0.9.6 2025-02-13 12:25:10 +03:00
Recep Aslantas
fb4eac2ee0 Merge pull request #413 from recp/optimize-inv
WIP: More Optimizations and SIMD fixes for MSVC & ARM
2025-02-12 23:08:07 +03:00
107 changed files with 4456 additions and 1531 deletions

4
.gitignore vendored
View File

@@ -80,4 +80,6 @@ confdefs.h
cmake-build-debug
*.o.tmp
xcode/*
.vscode
.vscode
.build
*.swp

View File

@@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 3.13)
project(cglm
VERSION 0.9.5
VERSION 0.9.6
HOMEPAGE_URL https://github.com/recp/cglm
DESCRIPTION "OpenGL Mathematics (glm) for C"
LANGUAGES C
@@ -44,7 +44,7 @@ if(MSVC)
endforeach(flag_var)
endif()
else()
add_compile_options(-Wall)
add_compile_options(-Wall -Wextra -Wpedantic -Wconversion)
if(NOT CMAKE_BUILD_TYPE MATCHES Debug)
add_compile_options(-O3)

View File

@@ -23,7 +23,7 @@ checkCFLAGS = $(AM_CFLAGS) \
-std=gnu11 \
-O3 \
-DCGLM_DEFINE_PRINTS \
-I./include
-I$(srcdir)/include
check_PROGRAMS = test/tests
TESTS = $(check_PROGRAMS)
@@ -131,7 +131,8 @@ cglm_call_HEADERS = include/cglm/call/mat4.h \
include/cglm/call/bezier.h \
include/cglm/call/ray.h \
include/cglm/call/affine.h \
include/cglm/call/affine2d.h
include/cglm/call/affine2d.h \
include/cglm/call/aabb2d.h
cglm_call_clipspacedir=$(includedir)/cglm/call/clipspace
cglm_call_clipspace_HEADERS = include/cglm/call/clipspace/persp_lh_no.h \

View File

@@ -2,7 +2,7 @@ Pod::Spec.new do |s|
# Description
s.name = "cglm"
s.version = "0.9.4"
s.version = "0.9.5"
s.summary = "📽 Highly Optimized Graphics Math (glm) for C"
s.description = <<-DESC
cglm is math library for graphics programming for C. See the documentation or README for all features.

View File

@@ -7,7 +7,7 @@
#*****************************************************************************
AC_PREREQ([2.69])
AC_INIT([cglm], [0.9.5], [info@recp.me])
AC_INIT([cglm], [0.9.6], [info@recp.me])
AM_INIT_AUTOMAKE([-Wall foreign subdir-objects serial-tests])
# Don't use the default cflags (-O2 -g), we set ours manually in Makefile.am.

View File

@@ -36,8 +36,10 @@ Functions:
#. :c:func:`glm_ortho_default`
#. :c:func:`glm_ortho_default_s`
#. :c:func:`glm_perspective`
#. :c:func:`glm_perspective_infinite`
#. :c:func:`glm_persp_move_far`
#. :c:func:`glm_perspective_default`
#. :c:func:`glm_perspective_default_infinite`
#. :c:func:`glm_perspective_resize`
#. :c:func:`glm_lookat`
#. :c:func:`glm_look`
@@ -146,6 +148,21 @@ Functions documentation
| *[in]* **farVal** far clipping planes
| *[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)
| extend perspective projection matrix's far distance
@@ -165,6 +182,20 @@ Functions documentation
| *[in]* **aspect** aspect aspect ratio ( width / height )
| *[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)
| resize perspective matrix by aspect ratio ( width / height )

View File

@@ -62,9 +62,9 @@ author = u'Recep Aslantas'
# built documents.
#
# The short X.Y version.
version = u'0.9.5'
version = u'0.9.6'
# The full version, including alpha/beta/rc tags.
release = u'0.9.5'
release = u'0.9.6'
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.

File diff suppressed because it is too large Load Diff

View File

@@ -36,58 +36,103 @@ Represented
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:
| *[in]* **mat** source
| *[out]* **dest** destination
| *[in]* **src** mat2x3 (left)
| *[out]* **dest** destination (result, mat2x3)
.. c:function:: void glm_mat2x3_zero(mat2x3 mat)
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
.. csv-table:: mat2x3 **(src)**
:header: "", "column 1", "column 2"
"row 1", "a00", "a10"
"row 2", "a01", "a11"
"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"
"row 1", "b00", "b10", "b20"
"row 2", "b01", "b11", "b21"
.. csv-table:: mat3x3
.. csv-table:: mat3 **(dest)**
:header: "", "column 1", "column 2", "column 3"
"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)
multiply mat2x3 with vec2 (column vector) and store in dest column vector
Multiply mat2x3 (m) by vec2 (v) and store in vec3 (dest).
Parameters:
| *[in]* **m** mat2x3 (left)
| *[in]* **v** vec3 (right, column vector)
| *[out]* **dest** destination (result, column vector)
| *[in]* **m** mat2x3 (left)
| *[in]* **v** vec2 (right, column vector)
| *[out]* **dest** destination (result, column vector)
.. csv-table:: mat2x3
.. csv-table:: mat2x3 **(m)**
:header: "", "column 1", "column 2"
"row 1", "m00", "m10"
"row 2", "m01", "m11"
"row 3", "m02", "m12"
.. csv-table:: column vec2 (1x2)
.. csv-table:: column vec2 (1x2) **(v)**
:header: "", "column 1"
"row 1", "v0"
"row 2", "v1"
.. csv-table:: column vec3 (1x3)
.. csv-table:: column vec3 (1x3) **(dest)**
:header: "", "column 1"
"row 1", "m00 * v0 + m10 * v1"
"row 2", "m01 * v0 + m11 * 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:
| *[in]* **m** matrix
| *[out]* **dest** destination
| *[in]* **src** mat2x3 (left)
| *[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:
| *[in, out]* **m** matrix
| *[in]* **s** scalar
| *[in, out]* **m** mat2x3 (src, dest)
| *[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"

View File

@@ -37,45 +37,15 @@ Represented
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:
| *[in]* **mat** source
| *[out]* **dest** destination
| *[in]* **src** mat2x4 (left)
| *[out]* **dest** destination (result, mat2x4)
.. c:function:: void glm_mat2x4_zero(mat2x4 mat)
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
.. csv-table:: mat2x4 **(src)**
:header: "", "column 1", "column 2"
"row 1", "a00", "a10"
@@ -83,13 +53,95 @@ Functions documentation
"row 3", "a02", "a12"
"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"
"row 1", "b00", "b10", "b20", "b30"
"row 2", "b01", "b11", "b21", "b31"
.. csv-table:: mat4x4
.. csv-table:: mat4x4 **(dest)**
: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"
@@ -99,14 +151,14 @@ Functions documentation
.. 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:
| *[in]* **m** mat2x4 (left)
| *[in]* **v** vec2 (right, column vector)
| *[out]* **dest** destination (result, column vector)
| *[in]* **m** mat2x4 (left)
| *[in]* **v** vec2 (right, column vector)
| *[out]* **dest** destination (result, column vector)
.. csv-table:: mat2x4
.. csv-table:: mat2x4 **(m)**
:header: "", "column 1", "column 2"
"row 1", "m00", "m10"
@@ -114,13 +166,13 @@ Functions documentation
"row 3", "m02", "m12"
"row 4", "m03", "m13"
.. csv-table:: column vec2 (1x2)
.. csv-table:: column vec2 (1x2) **(v)**
:header: "", "column 1"
"row 1", "v0"
"row 2", "v1"
.. csv-table:: column vec4 (1x4)
.. csv-table:: column vec4 (1x4) **(dest)**
:header: "", "column 1"
"row 1", "m00 * v0 + m10 * v1"
@@ -128,18 +180,40 @@ Functions documentation
"row 3", "m02 * v0 + m12 * 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:
| *[in]* **m** matrix
| *[out]* **dest** destination
| *[in]* **src** mat2x4 (left)
| *[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)
multiply matrix with scalar
Multiply mat2x4 (m) by scalar constant (s).
Parameters:
| *[in, out]* **m** matrix
| *[in]* **s** scalar
| *[in, out]* **m** mat2x4 (src, dest)
| *[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"

File diff suppressed because it is too large Load Diff

View File

@@ -35,58 +35,98 @@ Represented
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:
| *[in]* **mat** source
| *[out]* **dest** destination
| *[in]* **src** mat3x2 (left)
| *[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:
| *[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)
Create mat3x2 matrix from pointer
Create mat3x2 (dest) from pointer (src).
.. note:: **@src** must contain at least 6 elements.
Parameters:
| *[in]* **src** pointer to an array of floats
| *[out]* **dest** destination matrix3x2
| *[in]* **src** pointer to an array of floats (left)
| *[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)
multiply m1 and m2 to dest
Multiply mat3x2 (m1) by mat2x3 (m2) and store in mat2 (dest).
.. code-block:: c
glm_mat3x2_mul(mat3x2, mat2x3, mat2);
Parameters:
| *[in]* **m1** left matrix (mat3x2)
| *[in]* **m2** right matrix (mat2x3)
| *[out]* **dest** destination matrix (mat2)
| *[in]* **m1** mat3x2 (left)
| *[in]* **m2** mat2x3 (right)
| *[out]* **dest** destination (result, mat2)
.. csv-table:: mat3x2
.. csv-table:: mat3x2 **(m1)**
:header: "", "column 1", "column 2", "column 3"
"row 1", "a00", "a10", "a20"
"row 2", "a01", "a11", "a21"
.. csv-table:: mat2x3
.. csv-table:: mat2x3 **(m2)**
:header: "", "column 1", "column 2"
"row 1", "b00", "b10"
"row 2", "b01", "b11"
"row 3", "b02", "b12"
.. csv-table:: mat2x2
.. csv-table:: mat2x2 **(dest)**
:header: "", "column 1", "column 2"
"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)
multiply mat3x2 with vec3 (column vector) and store in dest vector
Multiply mat3x2 (m) by vec3 (v) and store in vec2 (dest).
Parameters:
| *[in]* **m** mat3x2 (left)
| *[in]* **v** vec3 (right, column vector)
| *[out]* **dest** destination (result, column vector)
| *[in]* **m** mat3x2 (left)
| *[in]* **v** vec3 (right, column vector)
| *[out]* **dest** destination (result, column vector)
.. csv-table:: mat3x2
.. csv-table:: mat3x2 **(m)**
:header: "", "column 1", "column 2", "column 3"
"row 1", "m00", "m10", "m20"
"row 2", "m01", "m11", "m21"
.. csv-table:: column vec3 (1x3)
.. csv-table:: column vec3 (1x3) **(v)**
:header: "", "column 1"
"row 1", "v0"
"row 2", "v1"
"row 3", "v2"
.. csv-table:: column vec2 (1x2)
.. csv-table:: column vec2 (1x2) **(dest)**
:header: "", "column 1"
"row 1", "m00 * v0 + m10 * v1 + m20 * 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:
| *[in]* **m** matrix
| *[out]* **dest** destination
| *[in]* **src** mat3x2 (left)
| *[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:
| *[in, out]* **m** matrix
| *[in]* **s** scalar
| *[in, out]* **m** mat3x2 (src, dest)
| *[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"

View File

@@ -37,45 +37,15 @@ Represented
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:
| *[in]* **mat** source
| *[out]* **dest** destination
| *[in]* **src** mat3x4 (left)
| *[out]* **dest** destination (result, mat3x4)
.. c:function:: void glm_mat3x4_zero(mat3x4 mat)
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
.. csv-table:: mat3x4 **(src)**
:header: "", "column 1", "column 2", "column 3"
"row 1", "a00", "a10", "a20"
@@ -83,14 +53,100 @@ Functions documentation
"row 3", "a02", "a12", "a22"
"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"
"row 1", "b00", "b10", "b20", "b30"
"row 2", "b01", "b11", "b21", "b31"
"row 3", "b02", "b12", "b22", "b32"
.. csv-table:: mat4x4
.. csv-table:: mat4x4 **(dest)**
: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"
@@ -100,14 +156,14 @@ Functions documentation
.. 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:
| *[in]* **m** mat3x4 (left)
| *[in]* **v** vec3 (right, column vector)
| *[out]* **dest** destination (result, column vector)
| *[in]* **m** mat3x4 (left)
| *[in]* **v** vec3 (right, column vector)
| *[out]* **dest** destination (result, column vector)
.. csv-table:: mat3x4
.. csv-table:: mat3x4 **(m)**
:header: "", "column 1", "column 2", "column 3"
"row 1", "m00", "m10", "m20"
@@ -115,14 +171,14 @@ Functions documentation
"row 3", "m02", "m12", "m22"
"row 4", "m03", "m13", "m23"
.. csv-table:: column vec3 (1x3)
.. csv-table:: column vec3 (1x3) **(v)**
:header: "", "column 1"
"row 1", "v0"
"row 2", "v1"
"row 3", "v2"
.. csv-table:: column vec4 (1x4)
.. csv-table:: column vec4 (1x4) **(dest)**
:header: "", "column 1"
"row 1", "m00 * v0 + m10 * v1 + m20 * v2"
@@ -130,18 +186,41 @@ Functions documentation
"row 3", "m02 * v0 + m12 * v1 + m22 * 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:
| *[in]* **m** matrix
| *[out]* **dest** destination
| *[in]* **src** mat3x4 (left)
| *[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)
multiply matrix with scalar
Multiply mat3x4 (m) by scalar constant (s).
Parameters:
| *[in, out]* **m** matrix
| *[in]* **s** scalar
| *[in, out]* **m** mat3x4 (src, dest)
| *[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"

View File

@@ -48,6 +48,7 @@ Functions:
#. :c:func:`glm_mat4_swap_row`
#. :c:func:`glm_mat4_rmc`
#. :c:func:`glm_mat4_make`
#. :c:func:`glm_mat4_textrans`
Functions documentation
~~~~~~~~~~~~~~~~~~~~~~~
@@ -143,7 +144,7 @@ Functions documentation
.. 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);
Parameters:
@@ -313,3 +314,15 @@ Functions documentation
Parameters:
| *[in]* **src** pointer to an array of floats
| *[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

View File

@@ -35,51 +35,93 @@ Represented
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:
| *[in]* **mat** source
| *[out]* **dest** destination
| *[in]* **src** mat4x2 (left)
| *[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:
| *[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)
Create mat4x2 matrix from pointer
Create mat4x2 (dest) from pointer (src).
.. note:: **@src** must contain at least 8 elements.
Parameters:
| *[in]* **src** pointer to an array of floats
| *[out]* **dest** destination matrix4x2
| *[in]* **src** pointer to an array of floats (left)
| *[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)
multiply m1 and m2 to dest
Multiply mat4x2 (m1) by mat2x4 (m2) and store in mat2 (dest).
.. code-block:: c
glm_mat4x2_mul(mat4x2, mat2x4, mat2);
Parameters:
| *[in]* **m1** left matrix (mat4x2)
| *[in]* **m2** right matrix (mat2x4)
| *[out]* **dest** destination matrix (mat2)
| *[in]* **m1** mat4x2 (left)
| *[in]* **m2** mat2x4 (right)
| *[out]* **dest** destination (result, mat2)
.. csv-table:: mat4x2
.. csv-table:: mat4x2 **(m1)**
:header: "", "column 1", "column 2", "column 3", "column 4"
"row 1", "a00", "a10", "a20", "a30"
"row 2", "a01", "a11", "a21", "a31"
.. csv-table:: mat2x4
.. csv-table:: mat2x4 **(m2)**
:header: "", "column 1", "column 2"
"row 1", "b00", "b10"
@@ -87,7 +129,7 @@ Functions documentation
"row 3", "b02", "b12"
"row 4", "b03", "b13"
.. csv-table:: mat2x2
.. csv-table:: mat2x2 **(dest)**
:header: "", "column 1", "column 2"
"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)
multiply mat4x2 with vec4 (column vector) and store in dest vector
Multiply mat4x2 (m) by vec4 (v) and store in vec2 (dest).
Parameters:
| *[in]* **m** mat4x2 (left)
| *[in]* **v** vec4 (right, column vector)
| *[out]* **dest** destination (result, column vector)
| *[in]* **m** mat4x2 (left)
| *[in]* **v** vec4 (right, column vector)
| *[out]* **dest** destination (result, column vector)
.. csv-table:: mat4x2
:header: "", "column 1", "column 2", "column 3"
.. csv-table:: mat4x2 **(m)**
:header: "", "column 1", "column 2", "column 3", "column 4"
"row 1", "m00", "m10", "m20"
"row 2", "m01", "m11", "m21"
"row 3", "m02", "m12", "m22"
"row 4", "m03", "m13", "m23"
"row 1", "m00", "m10", "m20", "m30"
"row 2", "m01", "m11", "m21", "m31"
.. csv-table:: column vec4 (1x4)
.. csv-table:: column vec4 (1x4) **(v)**
:header: "", "column 1"
"row 1", "v0"
@@ -118,24 +158,44 @@ Functions documentation
"row 3", "v2"
"row 4", "v3"
.. csv-table:: column vec2 (1x2)
.. csv-table:: column vec2 (1x2) **(dest)**
:header: "", "column 1"
"row 1", "m00 * v0 + m10 * v1 + m20 * v2 + m30 * 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:
| *[in]* **m** matrix
| *[out]* **dest** destination
| *[in]* **src** mat4x2 (left)
| *[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)
multiply matrix with scalar
Multiply mat4x2 (m) by scalar constant (s).
Parameters:
| *[in, out]* **m** matrix
| *[in]* **s** scalar
| *[in, out]* **m** mat4x2 (src, dest)
| *[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"

View File

@@ -27,7 +27,7 @@ Represented
~~~~~~~~~~~
.. 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 2", "m01", "m11", "m21", "m31"
@@ -36,52 +36,103 @@ Represented
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:
| *[in]* **mat** source
| *[out]* **dest** destination
| *[in]* **src** mat4x3 (left)
| *[out]* **dest** destination (result, mat4x3)
.. c:function:: void glm_mat4x3_zero(mat4x3 mat)
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
.. csv-table:: mat4x3 **(src)**
: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
.. 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"
"row 1", "b00", "b10", "b20"
@@ -89,7 +140,7 @@ Functions documentation
"row 3", "b02", "b12", "b22"
"row 4", "b03", "b13", "b23"
.. csv-table:: mat3x3
.. csv-table:: mat3x3 **(dest)**
: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"
@@ -98,21 +149,21 @@ Functions documentation
.. 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:
| *[in]* **m** mat4x3 (left)
| *[in]* **v** vec4 (right, column vector)
| *[out]* **dest** destination (result, column vector)
| *[in]* **m** mat4x3 (left)
| *[in]* **v** vec4 (right, column vector)
| *[out]* **dest** destination (result, column vector)
.. csv-table:: mat4x3
.. csv-table:: mat4x3 **(m)**
:header: "", "column 1", "column 2", "column 3", "column 4"
"row 1", "m00", "m10", "m20", "m30"
"row 2", "m01", "m11", "m21", "m31"
"row 3", "m02", "m12", "m22", "m32"
.. csv-table:: column vec4 (1x4)
.. csv-table:: column vec4 (1x4) **(v)**
:header: "", "column 1"
"row 1", "v0"
@@ -120,25 +171,47 @@ Functions documentation
"row 3", "v2"
"row 4", "v3"
.. csv-table:: column vec3 (1x3)
.. csv-table:: column vec3 (1x3) **(dest)**
:header: "", "column 1"
"row 1", "m00 * v0 + m10 * v1 + m20 * v2 + m30 * v3"
"row 2", "m01 * v0 + m11 * v1 + m21 * v2 + m31 * 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:
| *[in]* **m** matrix
| *[out]* **dest** destination
| *[in]* **src** mat4x3 (left)
| *[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:
| *[in, out]* **m** matrix
| *[in]* **s** scalar
| *[in, out]* **m** mat4x3 (src, dest)
| *[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"

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

View File

@@ -14,16 +14,17 @@
&& defined(SIMD_VECTOR_TYPES)
#include "common.h"
#include "struct.h"
/*!
* @brief converts mat4 to Apple's simd type simd_float4x4
* @return simd_float4x4
*/
* @brief converts mat4 to Apple's simd type simd_float4x4
* @return simd_float4x4
*/
CGLM_INLINE
simd_float4x4
glm_mat4_applesimd(mat4 m) {
simd_float4x4 t;
t.columns[0][0] = m[0][0];
t.columns[0][1] = m[0][1];
t.columns[0][2] = m[0][2];
@@ -55,7 +56,7 @@ CGLM_INLINE
simd_float3x3
glm_mat3_applesimd(mat3 m) {
simd_float3x3 t;
t.columns[0][0] = m[0][0];
t.columns[0][1] = m[0][1];
t.columns[0][2] = m[0][2];
@@ -83,7 +84,7 @@ glm_vec4_applesimd(vec4 v) {
/*!
* @brief converts vec3 to Apple's simd type simd_float3
* @return v
* @return simd_float3
*/
CGLM_INLINE
simd_float3
@@ -91,5 +92,45 @@ glm_vec3_applesimd(vec3 v) {
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 /* cglm_applesimd_h */

View File

@@ -51,6 +51,10 @@ CGLM_EXPORT
void
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
void
glmc_persp_move_far(mat4 proj, float deltaFar);
@@ -59,6 +63,10 @@ CGLM_EXPORT
void
glmc_perspective_default(float aspect, mat4 dest);
CGLM_EXPORT
void
glmc_perspective_default_infinite(float aspect, mat4 dest);
CGLM_EXPORT
void
glmc_perspective_resize(float aspect, mat4 proj);

View File

@@ -27,6 +27,10 @@ glmc_perspective_lh_no(float fovy,
float nearVal,
float farVal,
mat4 dest);
CGLM_EXPORT
void
glmc_perspective_resize_lh_no(float aspect, mat4 proj);
CGLM_EXPORT
void

View File

@@ -27,6 +27,10 @@ glmc_perspective_lh_zo(float fovy,
float nearVal,
float farVal,
mat4 dest);
CGLM_EXPORT
void
glmc_perspective_resize_lh_zo(float aspect, mat4 proj);
CGLM_EXPORT
void

View File

@@ -27,6 +27,10 @@ glmc_perspective_rh_no(float fovy,
float nearVal,
float farVal,
mat4 dest);
CGLM_EXPORT
void
glmc_perspective_resize_rh_no(float aspect, mat4 proj);
CGLM_EXPORT
void

View File

@@ -27,6 +27,10 @@ glmc_perspective_rh_zo(float fovy,
float nearVal,
float farVal,
mat4 dest);
CGLM_EXPORT
void
glmc_perspective_resize_rh_zo(float aspect, mat4 proj);
CGLM_EXPORT
void

View File

@@ -13,21 +13,25 @@ extern "C" {
#include "../cglm.h"
CGLM_EXPORT
void
glmc_mat2_make(const float * __restrict src, mat2 dest);
CGLM_EXPORT
void
glmc_mat2_copy(mat2 mat, mat2 dest);
CGLM_EXPORT
void
glmc_mat2_identity(mat2 mat);
glmc_mat2_identity(mat2 m);
CGLM_EXPORT
void
glmc_mat2_identity_array(mat2 * __restrict mat, size_t count);
glmc_mat2_identity_array(mat2 * __restrict mats, size_t count);
CGLM_EXPORT
void
glmc_mat2_zero(mat2 mat);
glmc_mat2_zero(mat2 m);
CGLM_EXPORT
void
@@ -35,28 +39,20 @@ glmc_mat2_mul(mat2 m1, mat2 m2, mat2 dest);
CGLM_EXPORT
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
void
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
void
glmc_mat2_scale(mat2 m, float s);
CGLM_EXPORT
float
glmc_mat2_det(mat2 mat);
CGLM_EXPORT
void
glmc_mat2_inv(mat2 mat, mat2 dest);
@@ -71,11 +67,15 @@ glmc_mat2_swap_row(mat2 mat, int row1, int row2);
CGLM_EXPORT
float
glmc_mat2_rmc(vec2 r, mat2 m, vec2 c);
glmc_mat2_trace(mat2 m);
CGLM_EXPORT
void
glmc_mat2_make(const float * __restrict src, mat2 dest);
float
glmc_mat2_det(mat2 m);
CGLM_EXPORT
float
glmc_mat2_rmc(vec2 r, mat2 m, vec2 c);
#ifdef __cplusplus
}

View File

@@ -15,11 +15,11 @@ extern "C" {
CGLM_EXPORT
void
glmc_mat2x3_copy(mat2x3 mat, mat2x3 dest);
glmc_mat2x3_copy(mat2x3 src, mat2x3 dest);
CGLM_EXPORT
void
glmc_mat2x3_zero(mat2x3 mat);
glmc_mat2x3_zero(mat2x3 m);
CGLM_EXPORT
void
@@ -35,7 +35,7 @@ glmc_mat2x3_mulv(mat2x3 m, vec2 v, vec3 dest);
CGLM_EXPORT
void
glmc_mat2x3_transpose(mat2x3 m, mat3x2 dest);
glmc_mat2x3_transpose(mat2x3 src, mat3x2 dest);
CGLM_EXPORT
void

View File

@@ -15,11 +15,11 @@ extern "C" {
CGLM_EXPORT
void
glmc_mat2x4_copy(mat2x4 mat, mat2x4 dest);
glmc_mat2x4_copy(mat2x4 src, mat2x4 dest);
CGLM_EXPORT
void
glmc_mat2x4_zero(mat2x4 mat);
glmc_mat2x4_zero(mat2x4 m);
CGLM_EXPORT
void
@@ -35,7 +35,7 @@ glmc_mat2x4_mulv(mat2x4 m, vec2 v, vec4 dest);
CGLM_EXPORT
void
glmc_mat2x4_transpose(mat2x4 m, mat4x2 dest);
glmc_mat2x4_transpose(mat2x4 src, mat4x2 dest);
CGLM_EXPORT
void

View File

@@ -84,6 +84,10 @@ CGLM_EXPORT
void
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
}
#endif

View File

@@ -15,11 +15,11 @@ extern "C" {
CGLM_EXPORT
void
glmc_mat3x2_copy(mat3x2 mat, mat3x2 dest);
glmc_mat3x2_copy(mat3x2 src, mat3x2 dest);
CGLM_EXPORT
void
glmc_mat3x2_zero(mat3x2 mat);
glmc_mat3x2_zero(mat3x2 m);
CGLM_EXPORT
void
@@ -35,7 +35,7 @@ glmc_mat3x2_mulv(mat3x2 m, vec3 v, vec2 dest);
CGLM_EXPORT
void
glmc_mat3x2_transpose(mat3x2 m, mat2x3 dest);
glmc_mat3x2_transpose(mat3x2 src, mat2x3 dest);
CGLM_EXPORT
void

View File

@@ -15,11 +15,11 @@ extern "C" {
CGLM_EXPORT
void
glmc_mat3x4_copy(mat3x4 mat, mat3x4 dest);
glmc_mat3x4_copy(mat3x4 src, mat3x4 dest);
CGLM_EXPORT
void
glmc_mat3x4_zero(mat3x4 mat);
glmc_mat3x4_zero(mat3x4 m);
CGLM_EXPORT
void
@@ -35,7 +35,7 @@ glmc_mat3x4_mulv(mat3x4 m, vec3 v, vec4 dest);
CGLM_EXPORT
void
glmc_mat3x4_transpose(mat3x4 m, mat4x3 dest);
glmc_mat3x4_transpose(mat3x4 src, mat4x3 dest);
CGLM_EXPORT
void

View File

@@ -125,6 +125,10 @@ CGLM_EXPORT
void
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
}
#endif

View File

@@ -15,11 +15,11 @@ extern "C" {
CGLM_EXPORT
void
glmc_mat4x2_copy(mat4x2 mat, mat4x2 dest);
glmc_mat4x2_copy(mat4x2 src, mat4x2 dest);
CGLM_EXPORT
void
glmc_mat4x2_zero(mat4x2 mat);
glmc_mat4x2_zero(mat4x2 m);
CGLM_EXPORT
void
@@ -35,7 +35,7 @@ glmc_mat4x2_mulv(mat4x2 m, vec4 v, vec2 dest);
CGLM_EXPORT
void
glmc_mat4x2_transpose(mat4x2 m, mat2x4 dest);
glmc_mat4x2_transpose(mat4x2 src, mat2x4 dest);
CGLM_EXPORT
void

View File

@@ -15,11 +15,11 @@ extern "C" {
CGLM_EXPORT
void
glmc_mat4x3_copy(mat4x3 mat, mat4x3 dest);
glmc_mat4x3_copy(mat4x3 src, mat4x3 dest);
CGLM_EXPORT
void
glmc_mat4x3_zero(mat4x3 mat);
glmc_mat4x3_zero(mat4x3 m);
CGLM_EXPORT
void
@@ -35,7 +35,7 @@ glmc_mat4x3_mulv(mat4x3 m, vec4 v, vec3 dest);
CGLM_EXPORT
void
glmc_mat4x3_transpose(mat4x3 m, mat3x4 dest);
glmc_mat4x3_transpose(mat4x3 src, mat3x4 dest);
CGLM_EXPORT
void

View File

@@ -245,6 +245,10 @@ CGLM_EXPORT
bool
glmc_vec2_refract(vec2 v, vec2 n, float eta, vec2 dest);
CGLM_EXPORT
void
glmc_vec2_swap(vec2 a, vec2 b);
#ifdef __cplusplus
}
#endif

View File

@@ -363,6 +363,10 @@ CGLM_EXPORT
bool
glmc_vec3_refract(vec3 v, vec3 n, float eta, vec3 dest);
CGLM_EXPORT
void
glmc_vec3_swap(vec3 a, vec3 b);
#ifdef __cplusplus
}
#endif

View File

@@ -336,6 +336,10 @@ CGLM_EXPORT
bool
glmc_vec4_refract(vec4 v, vec4 n, float eta, vec4 dest);
CGLM_EXPORT
void
glmc_vec4_swap(vec4 a, vec4 b);
#ifdef __cplusplus
}
#endif

View File

@@ -25,7 +25,12 @@
float nearZ,
float farZ,
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_infinite(float aspect, mat4 dest)
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_look(vec3 eye, vec3 dir, vec3 up, mat4 dest)
@@ -87,7 +92,7 @@
#endif
/*!
* @brief set up perspective peprojection matrix
* @brief set up perspective projection matrix
*
* @param[in] left viewport.left
* @param[in] right viewport.right
@@ -274,6 +279,28 @@ glm_perspective(float fovy, float aspect, float nearZ, float farZ, mat4 dest) {
#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
*
@@ -317,6 +344,27 @@ glm_perspective_default(float aspect, mat4 dest) {
#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 )
* this makes very easy to resize proj matrix when window /viewport

View File

@@ -43,5 +43,6 @@
#include "bezier.h"
#include "ray.h"
#include "affine2d.h"
#include "affine2d-post.h"
#endif /* cglm_h */

View File

@@ -16,7 +16,12 @@
float nearZ,
float farZ,
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_infinite_lh_no(float aspect, mat4 dest)
CGLM_INLINE void glm_perspective_resize_lh_no(float aspect, mat4 proj)
CGLM_INLINE void glm_persp_move_far_lh_no(mat4 proj,
float deltaFar)
@@ -116,7 +121,35 @@ glm_perspective_lh_no(float fovy,
dest[2][2] =-(nearZ + farZ) * fn;
dest[2][3] = 1.0f;
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);
}
/*!
* @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 )
* this makes very easy to resize proj matrix when window /viewport

View File

@@ -16,7 +16,12 @@
float nearZ,
float farZ,
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_infinite_lh_zo(float aspect, mat4 dest)
CGLM_INLINE void glm_perspective_resize_lh_zo(float aspect, mat4 proj)
CGLM_INLINE void glm_persp_move_far_lh_zo(mat4 proj,
float deltaFar)
@@ -116,6 +121,35 @@ glm_perspective_lh_zo(float fovy,
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
* left-hand coordinate system and a clip-space with depth values
@@ -144,7 +178,7 @@ glm_persp_move_far_lh_zo(mat4 proj, float deltaFar) {
/*!
* @brief set up perspective projection matrix with default near/far
* and angle values with a left-hand coordinate system and a
* and angle values with a left-hand coordinate system and a
* clip-space of [0, 1].
*
* @param[in] aspect aspect ratio ( width / height )
@@ -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);
}
/*!
* @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 )
* this makes very easy to resize proj matrix when window /viewport

View File

@@ -16,7 +16,12 @@
float nearZ,
float farZ,
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_infinite_rh_no(float aspect, mat4 dest)
CGLM_INLINE void glm_perspective_resize_rh_no(float aspect, mat4 proj)
CGLM_INLINE void glm_persp_move_far_rh_no(mat4 proj,
float deltaFar)
@@ -116,7 +121,35 @@ glm_perspective_rh_no(float fovy,
dest[2][2] = (nearZ + farZ) * fn;
dest[2][3] =-1.0f;
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);
}
/*!
* @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 )
* this makes very easy to resize proj matrix when window /viewport

View File

@@ -16,7 +16,12 @@
float nearZ,
float farZ,
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_infinite_rh_zo(float aspect, mat4 dest)
CGLM_INLINE void glm_perspective_resize_rh_zo(float aspect, mat4 proj)
CGLM_INLINE void glm_persp_move_far_rh_zo(mat4 proj,
float deltaFar)
@@ -116,6 +121,35 @@ glm_perspective_rh_zo(float fovy,
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
* 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);
}
/*!
* @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 )
* this makes very easy to resize proj matrix when window /viewport

View File

@@ -8,6 +8,8 @@
#ifndef cglm_common_h
#define cglm_common_h
#define __cglm__ 1
#ifndef _USE_MATH_DEFINES
# define _USE_MATH_DEFINES /* for windows */
#endif

View File

@@ -13,22 +13,22 @@
GLM_MAT2_ZERO
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_identity(mat2 mat)
CGLM_INLINE void glm_mat2_identity_array(mat2 * restrict mat, size_t count)
CGLM_INLINE void glm_mat2_zero(mat2 mat)
CGLM_INLINE void glm_mat2_identity(mat2 m)
CGLM_INLINE void glm_mat2_identity_array(mat2 * restrict mats, size_t count)
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_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 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 float glm_mat2_det(mat2 mat)
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_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 void glm_mat2_make(float * restrict src, mat2 dest)
*/
#ifndef cglm_mat2_h
@@ -57,10 +57,25 @@
#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[out] dest destination
* @param[in] src pointer to an array of floats (left)
* @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
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
* e.g. glm_mat2_identity(aStruct->aMatrix);
*
@@ -80,59 +97,57 @@ glm_mat2_copy(mat2 mat, mat2 dest) {
* mat2 mat = GLM_MAT2_IDENTITY_INIT;
* @endcode
*
* @param[in, out] mat destination
* @param[in, out] m mat2 (src, dest)
*/
CGLM_INLINE
void
glm_mat2_identity(mat2 mat) {
glm_mat2_identity(mat2 m) {
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 mat2s (mats) make each matrix an identity matrix.
*
* @param[in, out] mat matrix array (must be aligned (16)
* if alignment is not disabled)
*
* @param[in] count count of matrices
* @param[in, out] mats Array of mat2s (must be aligned (16/32) if alignment is not disabled)
* @param[in] count Array size of mats or number of matrices
*/
CGLM_INLINE
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;
size_t 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
void
glm_mat2_zero(mat2 mat) {
glm_mat2_zero(mat2 m) {
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
* mat2 m = GLM_MAT2_IDENTITY_INIT;
* glm_mat2_mul(m, m, m);
* @endcode
*
* @param[in] m1 left matrix
* @param[in] m2 right matrix
* @param[out] dest destination matrix
* @param[in] m1 mat2 (left)
* @param[in] m2 mat2 (right)
* @param[out] dest destination (result, mat2)
*/
CGLM_INLINE
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 matrix
* @param[out] dest result
* @param[in] m mat2 (left)
* @param[in] v vec2 (right, column vector)
* @param[out] dest destination (result, column vector)
*/
CGLM_INLINE
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__)
glm_mat2_transp_wasm(m, dest);
glm_mat2_transp_wasm(mat, dest);
#elif defined( __SSE__ ) || defined( __SSE2__ )
glm_mat2_transp_sse2(m, dest);
glm_mat2_transp_sse2(mat, dest);
#else
dest[0][0] = m[0][0];
dest[0][1] = m[1][0];
dest[1][0] = m[0][1];
dest[1][1] = m[1][1];
dest[0][0] = mat[0][0];
dest[0][1] = mat[1][0];
dest[1][0] = mat[0][1];
dest[1][1] = mat[1][1];
#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
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] v vec2 (right, column vector)
* @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
* @param[in, out] m mat2 (src, dest)
* @param[in] s float (scalar)
*/
CGLM_INLINE
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
*
* @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
* @param[in] mat mat2 (left, src)
* @param[out] dest destination (result, inverse mat2)
*/
CGLM_INLINE
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] col1 col1
* @param[in] col2 col2
* @param[in, out] mat mat2 (src, dest)
* @param[in] col1 Column 1 array index
* @param[in] col2 Column 2 array index
*/
CGLM_INLINE
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] row1 row1
* @param[in] row2 row2
* @param[in, out] mat mat2 (src, dest)
* @param[in] row1 Row 1 array index
* @param[in] row2 Row 2 array index
*/
CGLM_INLINE
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),
* then Matrix1x2 * Vec2 (column vector) = Matrix1x1 (Scalar)
* @return[out] mat2 determinant (float)
*/
CGLM_INLINE
float
glm_mat2_det(mat2 m) {
return m[0][0] * m[1][1] - m[1][0] * m[0][1];
}
/*!
* @brief Returns trace of matrix. Which is:
*
* @param[in] r row vector or matrix1x2
* @param[in] m matrix2x2
* @param[in] c column vector or matrix2x1
* The sum of the elements on the main diagonal from
* upper left corner to the bottom right corner.
*
* @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
float
@@ -346,19 +360,4 @@ glm_mat2_rmc(vec2 r, mat2 m, vec2 c) {
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 */

View File

@@ -11,12 +11,12 @@
GLM_MAT2X3_ZERO
Functions:
CGLM_INLINE void glm_mat2x3_copy(mat2x3 mat, mat2x3 dest);
CGLM_INLINE void glm_mat2x3_zero(mat2x3 mat);
CGLM_INLINE void glm_mat2x3_copy(mat2x3 src, mat2x3 dest);
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_mul(mat2x3 m1, mat3x2 m2, mat3 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);
*/
@@ -31,40 +31,35 @@
#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[out] dest destination
* @param[in] src mat2x3 (left)
* @param[out] dest destination (result, mat2x3)
*/
CGLM_INLINE
void
glm_mat2x3_copy(mat2x3 mat, mat2x3 dest) {
dest[0][0] = mat[0][0];
dest[0][1] = mat[0][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];
glm_mat2x3_copy(mat2x3 src, mat2x3 dest) {
glm_vec3_copy(src[0], dest[0]);
glm_vec3_copy(src[1], dest[1]);
}
/*!
* @brief make given matrix zero.
* @brief Zero out the mat2x3 (m).
*
* @param[in, out] mat matrix
* @param[in, out] mat2x3 (src, dest)
*/
CGLM_INLINE
void
glm_mat2x3_zero(mat2x3 mat) {
glm_mat2x3_zero(mat2x3 m) {
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[out] dest matrix
* @param[in] src pointer to an array of floats (left)
* @param[out] dest destination (result, mat2x3)
*/
CGLM_INLINE
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
* glm_mat2x3_mul(mat2x3, mat3x2, mat3);
* @endcode
*
* @param[in] m1 left matrix (mat2x3)
* @param[in] m2 right matrix (mat3x2)
* @param[out] dest destination matrix (mat2)
* @param[in] m1 mat2x3 (left)
* @param[in] m2 mat3x2 (right)
* @param[out] dest destination (result, mat3)
*/
CGLM_INLINE
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] v vector (right, column vector)
* @param[out] dest result vector
* @param[in] m mat2x3 (left)
* @param[in] v vec2 (right, column vector)
* @param[out] dest destination (result, column vector)
*/
CGLM_INLINE
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[out] dest result
* @param[in] src mat2x3 (left)
* @param[out] dest destination (result, mat3x2)
*/
CGLM_INLINE
void
glm_mat2x3_transpose(mat2x3 m, mat3x2 dest) {
dest[0][0] = m[0][0]; dest[0][1] = m[1][0];
dest[1][0] = m[0][1]; dest[1][1] = m[1][1];
dest[2][0] = m[0][2]; dest[2][1] = m[1][2];
glm_mat2x3_transpose(mat2x3 src, mat3x2 dest) {
dest[0][0] = src[0][0]; dest[0][1] = src[1][0];
dest[1][0] = src[0][1]; dest[1][1] = src[1][1];
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 matrix
* @param[in] s scalar
* @param[in, out] m (src, dest)
* @param[in] float (scalar)
*/
CGLM_INLINE
void

View File

@@ -11,12 +11,12 @@
GLM_MAT2X4_ZERO
Functions:
CGLM_INLINE void glm_mat2x4_copy(mat2x4 mat, mat2x4 dest);
CGLM_INLINE void glm_mat2x4_zero(mat2x4 mat);
CGLM_INLINE void glm_mat2x4_copy(mat2x4 src, mat2x4 dest);
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_mul(mat2x4 m1, mat4x2 m2, mat4 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);
*/
@@ -32,35 +32,35 @@
#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[out] dest destination
* @param[in] src mat2x4 (left)
* @param[out] dest destination (result, mat2x4)
*/
CGLM_INLINE
void
glm_mat2x4_copy(mat2x4 mat, mat2x4 dest) {
glm_vec4_ucopy(mat[0], dest[0]);
glm_vec4_ucopy(mat[1], dest[1]);
glm_mat2x4_copy(mat2x4 src, mat2x4 dest) {
glm_vec4_ucopy(src[0], dest[0]);
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
void
glm_mat2x4_zero(mat2x4 mat) {
glm_mat2x4_zero(mat2x4 m) {
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[out] dest matrix
* @param[in] src pointer to an array of floats (left)
* @param[out] dest destination (result, mat2x4)
*/
CGLM_INLINE
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
* glm_mat2x4_mul(mat2x4, mat4x2, mat4);
* @endcode
*
* @param[in] m1 left matrix (mat2x4)
* @param[in] m2 right matrix (mat4x2)
* @param[out] dest destination matrix (mat4)
* @param[in] m1 mat2x4 (left)
* @param[in] m2 mat4x2 (right)
* @param[out] dest destination (result, mat4)
*/
CGLM_INLINE
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] v vector (right, column vector)
* @param[out] dest result vector
* @param[in] m mat2x4 (left)
* @param[in] v vec2 (right, column vector)
* @param[out] dest destination (result, column vector)
*/
CGLM_INLINE
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[out] dest result
* @param[in] src mat2x4 (left)
* @param[out] dest destination (result, mat4x2)
*/
CGLM_INLINE
void
glm_mat2x4_transpose(mat2x4 m, mat4x2 dest) {
dest[0][0] = m[0][0]; dest[0][1] = m[1][0];
dest[1][0] = m[0][1]; dest[1][1] = m[1][1];
dest[2][0] = m[0][2]; dest[2][1] = m[1][2];
dest[3][0] = m[0][3]; dest[3][1] = m[1][3];
glm_mat2x4_transpose(mat2x4 src, mat4x2 dest) {
dest[0][0] = src[0][0]; dest[0][1] = src[1][0];
dest[1][0] = src[0][1]; dest[1][1] = src[1][1];
dest[2][0] = src[0][2]; dest[2][1] = src[1][2];
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 matrix
* @param[in] s scalar
* @param[in, out] m (src, dest)
* @param[in] s float (scalar)
*/
CGLM_INLINE
void

View File

@@ -31,6 +31,7 @@
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 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
@@ -448,4 +449,32 @@ glm_mat3_make(const float * __restrict src, mat3 dest) {
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 */

View File

@@ -11,12 +11,12 @@
GLM_MAT3X2_ZERO
Functions:
CGLM_INLINE void glm_mat3x2_copy(mat3x2 mat, mat3x2 dest);
CGLM_INLINE void glm_mat3x2_zero(mat3x2 mat);
CGLM_INLINE void glm_mat3x2_copy(mat3x2 src, mat3x2 dest);
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_mul(mat3x2 m1, mat2x3 m2, mat2 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);
*/
@@ -31,41 +31,36 @@
#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[out] dest destination
* @param[in] src mat3x2 (left)
* @param[out] dest destination (result, mat3x2)
*/
CGLM_INLINE
void
glm_mat3x2_copy(mat3x2 mat, mat3x2 dest) {
dest[0][0] = mat[0][0];
dest[0][1] = mat[0][1];
dest[1][0] = mat[1][0];
dest[1][1] = mat[1][1];
dest[2][0] = mat[2][0];
dest[2][1] = mat[2][1];
glm_mat3x2_copy(mat3x2 src, mat3x2 dest) {
glm_vec2_copy(src[0], dest[0]);
glm_vec2_copy(src[1], dest[1]);
glm_vec2_copy(src[2], dest[2]);
}
/*!
* @brief make given matrix zero.
* @brief Zero out the mat3x2 (m).
*
* @param[in, out] mat matrix
* @param[in, out] mat3x2 (src, dest)
*/
CGLM_INLINE
void
glm_mat3x2_zero(mat3x2 mat) {
glm_mat3x2_zero(mat3x2 m) {
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[out] dest matrix
* @param[in] src pointer to an array of floats (left)
* @param[out] dest destination (result, mat3x2)
*/
CGLM_INLINE
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
* glm_mat3x2_mul(mat3x2, mat2x3, mat2);
* @endcode
*
* @param[in] m1 left matrix (mat3x2)
* @param[in] m2 right matrix (mat2x3)
* @param[out] dest destination matrix (mat2)
* @param[in] m1 mat3x2 (left)
* @param[in] m2 mat2x3 (right)
* @param[out] dest destination (result, mat2)
*/
CGLM_INLINE
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] v vector (right, column vector)
* @param[out] dest result vector
* @param[in] m mat3x2 (left)
* @param[in] v vec3 (right, column vector)
* @param[out] dest destination (result, column vector)
*/
CGLM_INLINE
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[out] dest result
* @param[in] src mat3x2 (left)
* @param[out] dest destination (result, mat2x3)
*/
CGLM_INLINE
void
glm_mat3x2_transpose(mat3x2 m, mat2x3 dest) {
dest[0][0] = m[0][0]; dest[0][1] = m[1][0]; dest[0][2] = m[2][0];
dest[1][0] = m[0][1]; dest[1][1] = m[1][1]; dest[1][2] = m[2][1];
glm_mat3x2_transpose(mat3x2 src, mat2x3 dest) {
dest[0][0] = src[0][0]; dest[0][1] = src[1][0]; dest[0][2] = src[2][0];
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 matrix
* @param[in] s scalar
* @param[in, out] m (src, dest)
* @param[in] s float (scalar)
*/
CGLM_INLINE
void

View File

@@ -11,12 +11,12 @@
GLM_MAT3X4_ZERO
Functions:
CGLM_INLINE void glm_mat3x4_copy(mat3x4 mat, mat3x4 dest);
CGLM_INLINE void glm_mat3x4_zero(mat3x4 mat);
CGLM_INLINE void glm_mat3x4_copy(mat3x4 src, mat3x4 dest);
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_mul(mat3x4 m1, mat4x3 m2, mat4 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);
*/
@@ -33,36 +33,36 @@
#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[out] dest destination
* @param[in] src mat3x4 (left)
* @param[out] dest destination (result, mat3x4)
*/
CGLM_INLINE
void
glm_mat3x4_copy(mat3x4 mat, mat3x4 dest) {
glm_vec4_ucopy(mat[0], dest[0]);
glm_vec4_ucopy(mat[1], dest[1]);
glm_vec4_ucopy(mat[2], dest[2]);
glm_mat3x4_copy(mat3x4 src, mat3x4 dest) {
glm_vec4_ucopy(src[0], dest[0]);
glm_vec4_ucopy(src[1], dest[1]);
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
void
glm_mat3x4_zero(mat3x4 mat) {
glm_mat3x4_zero(mat3x4 m) {
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[out] dest matrix
* @param[in] src pointer to an array of floats (left)
* @param[out] dest destination (result, mat3x4)
*/
CGLM_INLINE
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
* glm_mat3x4_mul(mat3x4, mat4x3, mat4);
* @endcode
*
* @param[in] m1 left matrix (mat3x4)
* @param[in] m2 right matrix (mat4x3)
* @param[out] dest destination matrix (mat4)
* @param[in] m1 mat3x4 (left)
* @param[in] m2 mat4x3 (right)
* @param[out] dest destination (result, mat4)
*/
CGLM_INLINE
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] v vector (right, column vector)
* @param[out] dest result vector
* @param[in] m mat3x4 (left)
* @param[in] v vec3 (right, column vector)
* @param[out] dest destination (result, column vector)
*/
CGLM_INLINE
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[out] dest result
* @param[in] src mat3x4 (left)
* @param[out] dest destination (result, mat4x3)
*/
CGLM_INLINE
void
glm_mat3x4_transpose(mat3x4 m, mat4x3 dest) {
dest[0][0] = m[0][0]; dest[0][1] = m[1][0]; dest[0][2] = m[2][0];
dest[1][0] = m[0][1]; dest[1][1] = m[1][1]; dest[1][2] = m[2][1];
dest[2][0] = m[0][2]; dest[2][1] = m[1][2]; dest[2][2] = m[2][2];
dest[3][0] = m[0][3]; dest[3][1] = m[1][3]; dest[3][2] = m[2][3];
glm_mat3x4_transpose(mat3x4 src, mat4x3 dest) {
dest[0][0] = src[0][0]; dest[0][1] = src[1][0]; dest[0][2] = src[2][0];
dest[1][0] = src[0][1]; dest[1][1] = src[1][1]; dest[1][2] = src[2][1];
dest[2][0] = src[0][2]; dest[2][1] = src[1][2]; dest[2][2] = src[2][2];
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 matrix
* @param[in] s scalar
* @param[in, out] m (src, dest)
* @param[in] s float (scalar)
*/
CGLM_INLINE
void

View File

@@ -44,6 +44,7 @@
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 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
@@ -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,
* usage:
* @code
* mat m1, m2, m3, m4, res;
* mat4 m1, m2, m3, m4, res;
*
* glm_mat4_mulN((mat4 *[]){&m1, &m2, &m3, &m4}, 4, res);
* @endcode
@@ -799,4 +800,32 @@ glm_mat4_make(const float * __restrict src, mat4 dest) {
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 */

View File

@@ -11,12 +11,12 @@
GLM_MAT4X2_ZERO
Functions:
CGLM_INLINE void glm_mat4x2_copy(mat4x2 mat, mat4x2 dest);
CGLM_INLINE void glm_mat4x2_zero(mat4x2 mat);
CGLM_INLINE void glm_mat4x2_copy(mat4x2 src, mat4x2 dest);
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_mul(mat4x2 m1, mat2x4 m2, mat2 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);
*/
@@ -31,44 +31,37 @@
#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[out] dest destination
* @param[in] src mat4x2 (left)
* @param[out] dest destination (result, mat4x2)
*/
CGLM_INLINE
void
glm_mat4x2_copy(mat4x2 mat, mat4x2 dest) {
dest[0][0] = mat[0][0];
dest[0][1] = mat[0][1];
dest[1][0] = mat[1][0];
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];
glm_mat4x2_copy(mat4x2 src, mat4x2 dest) {
glm_vec2_copy(src[0], dest[0]);
glm_vec2_copy(src[1], dest[1]);
glm_vec2_copy(src[2], dest[2]);
glm_vec2_copy(src[3], dest[3]);
}
/*!
* @brief make given matrix zero.
* @brief Zero out the mat4x2 (m).
*
* @param[in, out] mat matrix
* @param[in, out] mat4x2 (src, dest)
*/
CGLM_INLINE
void
glm_mat4x2_zero(mat4x2 mat) {
glm_mat4x2_zero(mat4x2 m) {
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[out] dest matrix
* @param[in] src pointer to an array of floats (left)
* @param[out] dest destination (result, mat4x2)
*/
CGLM_INLINE
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
* glm_mat4x2_mul(mat4x2, mat2x4, mat2);
* @endcode
*
* @param[in] m1 left matrix (mat4x2)
* @param[in] m2 right matrix (mat2x4)
* @param[out] dest destination matrix (mat2)
* @param[in] m1 mat4x2 (left)
* @param[in] m2 mat2x4 (right)
* @param[out] dest destination (result, mat2)
*/
CGLM_INLINE
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] v vector (right, column vector)
* @param[out] dest result vector
* @param[in] m mat4x2 (left)
* @param[in] v vec4 (right, column vector)
* @param[out] dest destination (result, column vector)
*/
CGLM_INLINE
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[out] dest result
* @param[in] src mat4x2 (left)
* @param[out] dest destination (result, mat2x4)
*/
CGLM_INLINE
void
glm_mat4x2_transpose(mat4x2 m, mat2x4 dest) {
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[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][0] = m[0][0]; dest[0][1] = m[1][0]; 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 matrix
* @param[in] s scalar
* @param[in, out] m (src, dest)
* @param[in] s float (scalar)
*/
CGLM_INLINE
void

View File

@@ -11,12 +11,12 @@
GLM_MAT4X3_ZERO
Functions:
CGLM_INLINE void glm_mat4x3_copy(mat4x3 mat, mat4x3 dest);
CGLM_INLINE void glm_mat4x3_zero(mat4x3 mat);
CGLM_INLINE void glm_mat4x3_copy(mat4x3 src, mat4x3 dest);
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_mul(mat4x3 m1, mat3x4 m2, mat3 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);
*/
@@ -32,48 +32,37 @@
#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[out] dest destination
* @param[in] src mat4x3 (left)
* @param[out] dest destination (result, mat4x3)
*/
CGLM_INLINE
void
glm_mat4x3_copy(mat4x3 mat, mat4x3 dest) {
dest[0][0] = mat[0][0];
dest[0][1] = mat[0][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];
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];
glm_mat4x3_copy(mat4x3 src, mat4x3 dest) {
glm_vec3_copy(src[0], dest[0]);
glm_vec3_copy(src[1], dest[1]);
glm_vec3_copy(src[2], dest[2]);
glm_vec3_copy(src[3], dest[3]);
}
/*!
* @brief make given matrix zero.
* @brief Zero out the mat4x3 (m).
*
* @param[in, out] mat matrix
* @param[in, out] mat4x3 (src, dest)
*/
CGLM_INLINE
void
glm_mat4x3_zero(mat4x3 mat) {
glm_mat4x3_zero(mat4x3 m) {
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[out] dest matrix
* @param[in] src pointer to an array of floats (left)
* @param[out] dest destination (result, mat4x3)
*/
CGLM_INLINE
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
* glm_mat4x3_mul(mat4x3, mat3x4, mat3);
* @endcode
*
* @param[in] m1 left matrix (mat4x3)
* @param[in] m2 right matrix (mat3x4)
* @param[out] dest destination matrix (mat3)
* @param[in] m1 mat4x3 (left)
* @param[in] m2 mat3x4 (right)
* @param[out] dest destination (result, mat3)
*/
CGLM_INLINE
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] v vector (right, column vector)
* @param[out] dest result vector
* @param[in] m mat4x3 (left)
* @param[in] v vec3 (right, column vector)
* @param[out] dest destination (result, column vector)
*/
CGLM_INLINE
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[out] dest result
* @param[in] src mat4x3 (left)
* @param[out] dest destination (result, mat3x4)
*/
CGLM_INLINE
void
glm_mat4x3_transpose(mat4x3 m, mat3x4 dest) {
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[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];
glm_mat4x3_transpose(mat4x3 src, mat3x4 dest) {
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[1][0] = src[0][1]; dest[1][1] = src[1][1]; dest[1][2] = src[2][1]; dest[1][3] = src[3][1];
dest[2][0] = src[0][2]; dest[2][1] = src[1][2]; dest[2][2] = src[2][2]; dest[2][3] = src[3][2];
}
/*!
* @brief scale (multiply with scalar) matrix
* @brief Multiply mat4x3 (m) by scalar constant (s).
*
* multiply matrix with scalar
*
* @param[in, out] m matrix
* @param[in] s scalar
* @param[in, out] m (src, dest)
* @param[in] s float (scalar)
*/
CGLM_INLINE
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;
}
#endif
#endif /* cglm_mat4x3_h */

View File

@@ -19,8 +19,10 @@
#define glmm_load(p) vld1q_f32(p)
#define glmm_store(p, a) vst1q_f32(p, a)
#define glmm_set1(x) vdupq_n_f32(x)
#define glmm_128 float32x4_t
#define glmm_set1(x) vdupq_n_f32(x)
#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_y(x) vdupq_lane_f32(vget_low_f32(x), 1)

View File

@@ -15,6 +15,7 @@
#define glmm_store(p, a) wasm_v128_store(p, (a))
#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_128 v128_t

View File

@@ -13,21 +13,20 @@
GLM_MAT2_ZERO
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_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
@@ -48,7 +47,23 @@
#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
* e.g. glm_mat2_identity(aStruct->aMatrix);
*
@@ -59,7 +74,7 @@
* mat2 mat = GLM_MAT2_IDENTITY_INIT;
* @endcode
*
* @returns identity matrix
* @return[out] r constructed mat2s from raw pointer
*/
CGLM_INLINE
mat2s
@@ -70,28 +85,26 @@ glms_mat2_(identity)(void) {
}
/*!
* @brief make given matrix array's each element identity matrix
* @brief Given an array of mat2ss (mats) make each matrix an identity matrix.
*
* @param[in, out] mat matrix array (must be aligned (16)
* if alignment is not disabled)
*
* @param[in] count count of matrices
* @param[in, out] mats Array of mat2ss (must be aligned (16/32) if alignment is not disabled)
* @param[in] count Array size of mats or number of matrices
*/
CGLM_INLINE
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;
size_t 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
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
* mat2 m = GLM_MAT2_IDENTITY_INIT;
* r = glms_mat2_mul(m, m);
* mat2s r = glms_mat2_mul(m, m);
* @endcode
*
* @param[in] m1 left matrix
* @param[in] m2 right matrix
*
* @returns destination matrix
* @param[in] m1 mat2s (left)
* @param[in] m2 mat2s (right)
* @return[out] r constructed mat2s from raw pointers
*/
CGLM_INLINE
mat2s
@@ -124,26 +136,12 @@ glms_mat2_(mul)(mat2s m1, mat2s m2) {
return r;
}
/*!
* @brief transpose mat2
/*
* @brief Multiply mat2s (m) by vec2s (v) and return in vec2s (r).
*
* @param[in] m matrix to transpose
*
* @returns transposed matrix
*/
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)
* @param[in] m mat2s (left)
* @param[in] v vec2s (right, column vector)
* @return[out] r constructed vec2s from raw pointers
*/
CGLM_INLINE
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 matrix
* @param[in] m mat2s (src)
* @return[out] m constructed mat2s from raw pointers
*/
CGLM_INLINE
float
glms_mat2_(trace)(mat2s m) {
return glm_mat2_trace(m.raw);
mat2s
glms_mat2_(transpose)(mat2s m) {
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, out] m matrix
* @param[in] s scalar
* @returns matrix
* @param[in] m mat2s (src)
* @param[in] s scalar value
* @return[out] m constructed mat2s from raw pointers
*/
CGLM_INLINE
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
*
* @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
* @param[in] m mat2s (left, src)
* @return[out] r constructed mat2s from raw pointers
*/
CGLM_INLINE
mat2s
glms_mat2_(inv)(mat2s mat) {
glms_mat2_(inv)(mat2s m) {
mat2s r;
glm_mat2_inv(mat.raw, r.raw);
glm_mat2_inv(m.raw, r.raw);
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] col1 col1
* @param[in] col2 col2
* @returns matrix
* @param[in] mat mat2s
* @param[in] col1 column 1 array index
* @param[in] col2 column 2 array index
* @return[out] mat constructed mat2s from raw pointers columns swapped
*/
CGLM_INLINE
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] row1 row1
* @param[in] row2 row2
* @returns matrix
* @param[in] mat mat2s
* @param[in] row1 row 1 array index
* @param[in] row2 row 2 array index
* @return[out] mat constructed mat2s from raw pointers rows swapped
*/
CGLM_INLINE
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),
* then Matrix1x2 * Vec2 (column vector) = Matrix1x1 (Scalar)
* @return[out] mat2s raw pointers determinant (float)
*/
CGLM_INLINE
float
glms_mat2_(det)(mat2s m) {
return glm_mat2_det(m.raw);
}
/*!
* @brief Returns trace of matrix. Which is:
*
* @param[in] r row vector or matrix1x2
* @param[in] m matrix2x2
* @param[in] c column vector or matrix2x1
* The sum of the elements on the main diagonal from
* upper left corner to the bottom right corner.
*
* @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
float
@@ -259,18 +271,4 @@ glms_mat2_(rmc)(vec2s r, mat2s m, vec2s c) {
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 */

View File

@@ -35,87 +35,85 @@
#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
mat2x3s
glms_mat2x3_(zero)(void) {
mat2x3s r;
glm_mat2x3_zero(r.raw);
return r;
mat2x3s dest;
glm_mat2x3_zero(dest.raw);
return dest;
}
/*!
* @brief Create mat2x3 matrix from pointer
* @brief Create mat2x3s (dest) from pointer (src).
*
* @param[in] src pointer to an array of floats
* @return constructed matrix from raw pointer
* @param[in] src pointer to an array of floats
* @return[out] dest constructed mat2x3s from raw pointer
*/
CGLM_INLINE
mat2x3s
glms_mat2x3_(make)(const float * __restrict src) {
mat2x3s r;
glm_mat2x3_make(src, r.raw);
return r;
mat2x3s dest;
glm_mat2x3_make(src, dest.raw);
return dest;
}
/*!
* @brief multiply m1 and m2 to dest
* @brief Multiply mat2x3s (m1) by mat3x2s (m2) and store in mat3s (dest).
*
* @code
* r = glms_mat2x3_mul(mat2x3s, mat3x2s);
* @endcode
*
* @param[in] m1 left matrix (mat2x3s)
* @param[in] m2 right matrix (mat3x2s)
* @returns destination matrix (mat2s)
* @param[in] m1 mat2x3s (left)
* @param[in] m2 mat3x2s (right)
* @return[out] dest constructed mat3s from raw pointers
*/
CGLM_INLINE
mat3s
glms_mat2x3_(mul)(mat2x3s m1, mat3x2s m2) {
mat3s r;
glm_mat2x3_mul(m1.raw, m2.raw, r.raw);
return r;
mat3s dest;
glm_mat2x3_mul(m1.raw, m2.raw, dest.raw);
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] v vector (right, column vector)
* @returns destination vector (vec3s)
* @param[in] m mat2x3s (left)
* @param[in] v vec2s (right, column vector)
* @return[out] dest constructed vec3s from raw pointers
*/
CGLM_INLINE
vec3s
glms_mat2x3_(mulv)(mat2x3s m, vec2s v) {
vec3s r;
glm_mat2x3_mulv(m.raw, v.raw, r.raw);
return r;
vec3s dest;
glm_mat2x3_mulv(m.raw, v.raw, dest.raw);
return dest;
}
/*!
* @brief transpose matrix and store in dest
* @brief Transpose mat2x3s (m) and store in mat3x2s (dest).
*
* @param[in] m matrix
* @param[out] dest result
* @param[in] m mat2x3s (left)
* @return[out] dest constructed mat3x2s from raw pointers
*/
CGLM_INLINE
mat3x2s
glms_mat2x3_(transpose)(mat2x3s m) {
mat3x2s r;
glm_mat2x3_transpose(m.raw, r.raw);
return r;
mat3x2s dest;
glm_mat2x3_transpose(m.raw, dest.raw);
return dest;
}
/*!
* @brief scale (multiply with scalar) matrix
* @brief Multiply mat2x3s (m) by scalar constant (s).
*
* multiply matrix with scalar
*
* @param[in, out] m matrix
* @param[in] s scalar
* @param[in, out] m mat2x3 (src, dest)
* @param[in] s float (scalar)
*/
CGLM_INLINE
mat2x3s

View File

@@ -35,87 +35,85 @@
#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
mat2x4s
glms_mat2x4_(zero)(void) {
mat2x4s r;
glm_mat2x4_zero(r.raw);
return r;
mat2x4s dest;
glm_mat2x4_zero(dest.raw);
return dest;
}
/*!
* @brief Create mat2x4 matrix from pointer
* @brief Create mat2x4s (dest) from pointer (src).
*
* @param[in] src pointer to an array of floats
* @return constructed matrix from raw pointer
* @param[in] src pointer to an array of floats
* @return[out] dest constructed mat2x4s from raw pointer
*/
CGLM_INLINE
mat2x4s
glms_mat2x4_(make)(const float * __restrict src) {
mat2x4s r;
glm_mat2x4_make(src, r.raw);
return r;
mat2x4s dest;
glm_mat2x4_make(src, dest.raw);
return dest;
}
/*!
* @brief multiply m1 and m2 to dest
* @brief Multiply mat2x4s (m1) by mat4x2s (m2) and store in mat4s (dest).
*
* @code
* r = glms_mat2x4_mul(mat2x4s, mat4x2s);
* @endcode
*
* @param[in] m1 left matrix (mat2x4s)
* @param[in] m2 right matrix (mat4x2s)
* @returns destination matrix (mat2s)
* @param[in] m1 mat2x4s (left)
* @param[in] m2 mat4x2s (right)
* @return[out] dest constructed mat4s from raw pointers
*/
CGLM_INLINE
mat4s
glms_mat2x4_(mul)(mat2x4s m1, mat4x2s m2) {
mat4s r;
glm_mat2x4_mul(m1.raw, m2.raw, r.raw);
return r;
mat4s dest;
glm_mat2x4_mul(m1.raw, m2.raw, dest.raw);
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] v vector (right, column vector)
* @param[out] dest result vector
* @param[in] m mat2x4s (left)
* @param[in] v vec2s (right, column vector)
* @return[out] dest constructed vec4s from raw pointers
*/
CGLM_INLINE
vec4s
glms_mat2x4_(mulv)(mat2x4s m, vec2s v) {
vec4s r;
glm_mat2x4_mulv(m.raw, v.raw, r.raw);
return r;
vec4s dest;
glm_mat2x4_mulv(m.raw, v.raw, dest.raw);
return dest;
}
/*!
* @brief transpose matrix and store in dest
* @brief Transpose mat2x4s (m) and store in mat4x2s (dest).
*
* @param[in] m matrix
* @param[out] dest result
* @param[in] m mat2x4s (left)
* @return[out] dest constructed mat4x2s from raw pointers
*/
CGLM_INLINE
mat4x2s
glms_mat2x4_(transpose)(mat2x4s m) {
mat4x2s r;
glm_mat2x4_transpose(m.raw, r.raw);
return r;
mat4x2s dest;
glm_mat2x4_transpose(m.raw, dest.raw);
return dest;
}
/*!
* @brief scale (multiply with scalar) matrix
* @brief Multiply mat2x4s (m) by scalar constant (s).
*
* multiply matrix with scalar
*
* @param[in, out] m matrix
* @param[in] s scalar
* @param[in, out] m mat2x4s (src, dest)
* @param[in] s float (scalar)
*/
CGLM_INLINE
mat2x4s

View File

@@ -29,6 +29,7 @@
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 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
@@ -300,4 +301,22 @@ glms_mat3_(make)(const float * __restrict src) {
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 */

View File

@@ -35,87 +35,85 @@
#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
mat3x2s
glms_mat3x2_(zero)(void) {
mat3x2s r;
glm_mat3x2_zero(r.raw);
return r;
mat3x2s dest;
glm_mat3x2_zero(dest.raw);
return dest;
}
/*!
* @brief Create mat3x2 matrix from pointer
* @brief Create mat3x2s (dest) from pointer (src).
*
* @param[in] src pointer to an array of floats
* @return constructed matrix from raw pointer
* @param[in] src pointer to an array of floats
* @return[out] dest constructed mat3x2s from raw pointer
*/
CGLM_INLINE
mat3x2s
glms_mat3x2_(make)(const float * __restrict src) {
mat3x2s r;
glm_mat3x2_make(src, r.raw);
return r;
mat3x2s dest;
glm_mat3x2_make(src, dest.raw);
return dest;
}
/*!
* @brief multiply m1 and m2 to dest
* @brief Multiply mat3x2s (m1) by mat2x3s (m2) and store in mat2s (dest).
*
* @code
* r = glms_mat3x2_mul(mat3x2s, mat2x3s);
* @endcode
*
* @param[in] m1 left matrix (mat3x2s)
* @param[in] m2 right matrix (mat2x3s)
* @returns destination matrix (mat3s)
* @param[in] m1 mat3x2s (left)
* @param[in] m2 mat2x3s (right)
* @return[out] dest constructed mat2s from raw pointers
*/
CGLM_INLINE
mat2s
glms_mat3x2_(mul)(mat3x2s m1, mat2x3s m2) {
mat2s r;
glm_mat3x2_mul(m1.raw, m2.raw, r.raw);
return r;
mat2s dest;
glm_mat3x2_mul(m1.raw, m2.raw, dest.raw);
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] v vector (right, column vector)
* @param[out] dest result vector
* @param[in] m mat3x2s (left)
* @param[in] v vec3s (right, column vector)
* @return[out] dest constructed vec2s from raw pointers
*/
CGLM_INLINE
vec2s
glms_mat3x2_(mulv)(mat3x2s m, vec3s v) {
vec2s r;
glm_mat3x2_mulv(m.raw, v.raw, r.raw);
return r;
vec2s dest;
glm_mat3x2_mulv(m.raw, v.raw, dest.raw);
return dest;
}
/*!
* @brief transpose matrix and store in dest
* @brief Transpose mat3x2s (m) and store in mat2x3s (dest).
*
* @param[in] m matrix
* @param[out] dest result
* @param[in] m mat3x2s (left)
* @return[out] dest constructed mat2x3s from raw pointers
*/
CGLM_INLINE
mat2x3s
glms_mat3x2_(transpose)(mat3x2s m) {
mat2x3s r;
glm_mat3x2_transpose(m.raw, r.raw);
return r;
mat2x3s dest;
glm_mat3x2_transpose(m.raw, dest.raw);
return dest;
}
/*!
* @brief scale (multiply with scalar) matrix
* @brief Multiply mat3x2s (m) by scalar constant (s).
*
* multiply matrix with scalar
*
* @param[in, out] m matrix
* @param[in] s scalar
* @param[in, out] m mat3x2s (src, dest)
* @param[in] s float (scalar)
*/
CGLM_INLINE
mat3x2s

View File

@@ -35,87 +35,85 @@
#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
mat3x4s
glms_mat3x4_(zero)(void) {
mat3x4s r;
glm_mat3x4_zero(r.raw);
return r;
mat3x4s dest;
glm_mat3x4_zero(dest.raw);
return dest;
}
/*!
* @brief Create mat3x4 matrix from pointer
* @brief Create mat3x4s (dest) from pointer (src).
*
* @param[in] src pointer to an array of floats
* @return constructed matrix from raw pointer
* @param[in] src pointer to an array of floats
* @return[out] dest constructed mat3x4s from raw pointer
*/
CGLM_INLINE
mat3x4s
glms_mat3x4_(make)(const float * __restrict src) {
mat3x4s r;
glm_mat3x4_make(src, r.raw);
return r;
mat3x4s dest;
glm_mat3x4_make(src, dest.raw);
return dest;
}
/*!
* @brief multiply m1 and m2 to dest
* @brief Multiply mat3x4s (m1) by mat4x3s (m2) and store in mat4s (dest).
*
* @code
* r = glms_mat3x4_mul(mat3x4s, mat4x3s);
* @endcode
*
* @param[in] m1 left matrix (mat3x4s)
* @param[in] m2 right matrix (mat4x3s)
* @returns destination matrix (mat4s)
* @param[in] m1 mat3x4s (left)
* @param[in] m2 mat4x3s (right)
* @return[out] dest constructed mat4s from raw pointers
*/
CGLM_INLINE
mat4s
glms_mat3x4_(mul)(mat3x4s m1, mat4x3s m2) {
mat4s r;
glm_mat3x4_mul(m1.raw, m2.raw, r.raw);
return r;
mat4s dest;
glm_mat3x4_mul(m1.raw, m2.raw, dest.raw);
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] v vector (right, column vector)
* @returns destination vector (vec4s)
* @param[in] m mat3x4s (left)
* @param[in] v vec3s (right, column vector)
* @return[out] dest constructed vec4s from raw pointers
*/
CGLM_INLINE
vec4s
glms_mat3x4_(mulv)(mat3x4s m, vec3s v) {
vec4s r;
glm_mat3x4_mulv(m.raw, v.raw, r.raw);
return r;
vec4s dest;
glm_mat3x4_mulv(m.raw, v.raw, dest.raw);
return dest;
}
/*!
* @brief transpose matrix and store in dest
* @brief Transpose mat3x4s (m) and store in mat4x3s (dest).
*
* @param[in] m matrix
* @param[out] dest result
* @param[in] m mat3x4s (left)
* @return[out] dest constructed mat4x3s from raw pointers
*/
CGLM_INLINE
mat4x3s
glms_mat3x4_(transpose)(mat3x4s m) {
mat4x3s r;
glm_mat3x4_transpose(m.raw, r.raw);
return r;
mat4x3s dest;
glm_mat3x4_transpose(m.raw, dest.raw);
return dest;
}
/*!
* @brief scale (multiply with scalar) matrix
* @brief Multiply mat3x4s (m) by scalar constant (s).
*
* multiply matrix with scalar
*
* @param[in, out] m matrix
* @param[in] s scalar
* @param[in, out] m mat3x4s (src, dest)
* @param[in] s float (scalar)
*/
CGLM_INLINE
mat3x4s

View File

@@ -43,6 +43,7 @@
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 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
@@ -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,
* usage:
* @code
* mat m1, m2, m3, m4, res;
* mat4 m1, m2, m3, m4, res;
*
* res = glm_mat4_mulN((mat4 *[]){&m1, &m2, &m3, &m4}, 4);
* @endcode
@@ -474,4 +475,22 @@ glms_mat4_(make)(const float * __restrict src) {
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 */

View File

@@ -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
mat4x2s
glms_mat4x2_(zero)(void) {
mat4x2s r;
glm_mat4x2_zero(r.raw);
return r;
mat4x2s dest;
glm_mat4x2_zero(dest.raw);
return dest;
}
/*!
* @brief Create mat4x2 matrix from pointer
* @brief Create mat4x2s (dest) from pointer (src).
*
* @param[in] src pointer to an array of floats
* @return constructed matrix from raw pointer
* @param[in] src pointer to an array of floats
* @return[out] dest constructed mat4x2s from raw pointer
*/
CGLM_INLINE
mat4x2s
glms_mat4x2_(make)(const float * __restrict src) {
mat4x2s r;
glm_mat4x2_make(src, r.raw);
return r;
mat4x2s dest;
glm_mat4x2_make(src, dest.raw);
return dest;
}
/*!
* @brief multiply m1 and m2 to dest
* @brief Multiply mat4x2s (m1) by mat2x4s (m2) and store in mat2s (dest).
*
* @code
* r = glms_mat4x2_mul(mat4x2s, mat2x4s);
* @endcode
*
* @param[in] m1 left matrix (mat4x2s)
* @param[in] m2 right matrix (mat2x4s)
* @returns destination matrix (mat2s)
* @param[in] m1 mat4x2s (left)
* @param[in] m2 mat2x4s (right)
* @return[out] dest constructed mat2s from raw pointers
*/
CGLM_INLINE
mat2s
glms_mat4x2_(mul)(mat4x2s m1, mat2x4s m2) {
mat2s r;
glm_mat4x2_mul(m1.raw, m2.raw, r.raw);
return r;
mat2s dest;
glm_mat4x2_mul(m1.raw, m2.raw, dest.raw);
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] v vector (right, column vector)
* @returns destination vector (vec2s)
* @param[in] m mat4x2s (left)
* @param[in] v vec4s (right, column vector)
* @return[out] dest constructed vec2s from raw pointers
*/
CGLM_INLINE
vec2s
glms_mat4x2_(mulv)(mat4x2s m, vec4s v) {
vec2s r;
glm_mat4x2_mulv(m.raw, v.raw, r.raw);
return r;
vec2s dest;
glm_mat4x2_mulv(m.raw, v.raw, dest.raw);
return dest;
}
/*!
* @brief transpose matrix and store in dest
* @brief Transpose mat4x2s (m) and store in mat2x4s (dest).
*
* @param[in] m matrix
* @param[out] dest result
* @param[in] m mat4x2s (left)
* @return[out] dest constructed mat2x4s from raw pointers
*/
CGLM_INLINE
mat2x4s
glms_mat4x2_(transpose)(mat4x2s m) {
mat2x4s r;
glm_mat4x2_transpose(m.raw, r.raw);
return r;
mat2x4s dest;
glm_mat4x2_transpose(m.raw, dest.raw);
return dest;
}
/*!
* @brief scale (multiply with scalar) matrix
* @brief Multiply mat4x2s (m) by scalar constant (s).
*
* multiply matrix with scalar
*
* @param[in, out] m matrix
* @param[in] s scalar
* @param[in, out] m mat4x2s (src, dest)
* @param[in] s float (scalar)
*/
CGLM_INLINE
mat4x2s

View File

@@ -35,87 +35,85 @@
#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
mat4x3s
glms_mat4x3_(zero)(void) {
mat4x3s r;
glm_mat4x3_zero(r.raw);
return r;
mat4x3s dest;
glm_mat4x3_zero(dest.raw);
return dest;
}
/*!
* @brief Create mat4x3 matrix from pointer
* @brief Create mat4x3s (dest) from pointer (src).
*
* @param[in] src pointer to an array of floats
* @return constructed matrix from raw pointer
* @param[in] src pointer to an array of floats
* @return[out] dest constructed mat4x3s from raw pointer
*/
CGLM_INLINE
mat4x3s
glms_mat4x3_(make)(const float * __restrict src) {
mat4x3s r;
glm_mat4x3_make(src, r.raw);
return r;
mat4x3s dest;
glm_mat4x3_make(src, dest.raw);
return dest;
}
/*!
* @brief multiply m1 and m2 to dest
* @brief Multiply mat4x3s (m1) by mat3x4s (m2) and store in mat3s (dest).
*
* @code
* r = glms_mat4x3_mul(mat4x3s, mat3x4s);
* @endcode
*
* @param[in] m1 left matrix (mat4x3s)
* @param[in] m2 right matrix (mat3x4s)
* @returns destination matrix (mat3s)
* @param[in] m1 mat4x3s (left)
* @param[in] m2 mat3x4s (right)
* @return[out] dest constructed mat3s from raw pointers
*/
CGLM_INLINE
mat3s
glms_mat4x3_(mul)(mat4x3s m1, mat3x4s m2) {
mat3s r;
glm_mat4x3_mul(m1.raw, m2.raw, r.raw);
return r;
mat3s dest;
glm_mat4x3_mul(m1.raw, m2.raw, dest.raw);
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] v vector (right, column vector)
* @returns destination vector (vec3s)
* @param[in] m mat4x3s (left)
* @param[in] v vec4s (right, column vector)
* @return[out] dest constructed vec3s from raw pointers
*/
CGLM_INLINE
vec3s
glms_mat4x3_(mulv)(mat4x3s m, vec4s v) {
vec3s r;
glm_mat4x3_mulv(m.raw, v.raw, r.raw);
return r;
vec3s dest;
glm_mat4x3_mulv(m.raw, v.raw, dest.raw);
return dest;
}
/*!
* @brief transpose matrix and store in dest
* @brief Transpose mat4x3s (m) and store in mat3x4s (dest).
*
* @param[in] m matrix
* @param[out] dest result
* @param[in] m mat4x3s (left)
* @return[out] dest constructed mat3x4s from raw pointers
*/
CGLM_INLINE
mat3x4s
glms_mat4x3_(transpose)(mat4x3s m) {
mat3x4s r;
glm_mat4x3_transpose(m.raw, r.raw);
return r;
mat3x4s dest;
glm_mat4x3_transpose(m.raw, dest.raw);
return dest;
}
/*!
* @brief scale (multiply with scalar) matrix
* @brief Multiply mat4x3s (m) by scalar constant (s).
*
* multiply matrix with scalar
*
* @param[in, out] m matrix
* @param[in] s scalar
* @param[in, out] m mat4x3s (src, dest)
* @param[in] s float (scalar)
*/
CGLM_INLINE
mat4x3s

View File

@@ -106,23 +106,35 @@ typedef vec3 mat4x3[4]; /* [col (4), row (3)] */
#define GLM_PI_4 0.785398163397448309615660845819875721 /* pi/4 */
#define GLM_1_PI 0.318309886183790671537767526745028724 /* 1/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_SQRTTAU 2.506628274631000502415765284811045253 /* sqrt(tau) */
#define GLM_SQRT2 1.41421356237309504880168872420969808 /* sqrt(2) */
#define GLM_SQRT1_2 0.707106781186547524400844362104849039 /* 1/sqrt(2) */
#define GLM_Ef ((float)GLM_E)
#define GLM_LOG2Ef ((float)GLM_LOG2E)
#define GLM_LOG10Ef ((float)GLM_LOG10E)
#define GLM_LN2f ((float)GLM_LN2)
#define GLM_LN10f ((float)GLM_LN10)
#define GLM_PIf ((float)GLM_PI)
#define GLM_PI_2f ((float)GLM_PI_2)
#define GLM_PI_4f ((float)GLM_PI_4)
#define GLM_1_PIf ((float)GLM_1_PI)
#define GLM_2_PIf ((float)GLM_2_PI)
#define GLM_2_SQRTPIf ((float)GLM_2_SQRTPI)
#define GLM_SQRT2f ((float)GLM_SQRT2)
#define GLM_SQRT1_2f ((float)GLM_SQRT1_2)
#define GLM_Ef ((float)GLM_E)
#define GLM_LOG2Ef ((float)GLM_LOG2E)
#define GLM_LOG10Ef ((float)GLM_LOG10E)
#define GLM_LN2f ((float)GLM_LN2)
#define GLM_LN10f ((float)GLM_LN10)
#define GLM_PIf ((float)GLM_PI)
#define GLM_PI_2f ((float)GLM_PI_2)
#define GLM_PI_4f ((float)GLM_PI_4)
#define GLM_1_PIf ((float)GLM_1_PI)
#define GLM_2_PIf ((float)GLM_2_PI)
#define GLM_TAUf ((float)GLM_TAU)
#define GLM_TAU_2f ((float)GLM_TAU_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 */
#define CGLM_PI GLM_PIf

View File

@@ -144,6 +144,7 @@ glm_vec2_isnan(vec2 v) {
#ifndef CGLM_FAST_MATH
return isnan(v[0]) || isnan(v[1]);
#else
(void)v;
return false;
#endif
}
@@ -160,6 +161,7 @@ glm_vec2_isinf(vec2 v) {
#ifndef CGLM_FAST_MATH
return isinf(v[0]) || isinf(v[1]);
#else
(void)v;
return false;
#endif
}

View File

@@ -59,6 +59,7 @@
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_refract(vec2 v, vec2 n, float eta, vec2 dest)
CGLM_INLINE void glm_vec2_swap(vec2 a, vec2 b)
*/
#ifndef cglm_vec2_h
@@ -795,4 +796,16 @@ glm_vec2_refract(vec2 v, vec2 n, float eta, vec2 dest) {
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 */

View File

@@ -179,6 +179,7 @@ glm_vec3_isnan(vec3 v) {
#ifndef CGLM_FAST_MATH
return isnan(v[0]) || isnan(v[1]) || isnan(v[2]);
#else
(void)v;
return false;
#endif
}
@@ -195,6 +196,7 @@ glm_vec3_isinf(vec3 v) {
#ifndef CGLM_FAST_MATH
return isinf(v[0]) || isinf(v[1]) || isinf(v[2]);
#else
(void)v;
return false;
#endif
}

View File

@@ -82,6 +82,7 @@
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_refract(vec3 v, vec3 n, float eta, vec3 dest);
CGLM_INLINE void glm_vec3_swap(vec3 a, vec3 b)
Convenient:
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;
}
/*!
* @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 */

View File

@@ -193,6 +193,7 @@ glm_vec4_isnan(vec4 v) {
#ifndef CGLM_FAST_MATH
return isnan(v[0]) || isnan(v[1]) || isnan(v[2]) || isnan(v[3]);
#else
(void)v;
return false;
#endif
}
@@ -209,6 +210,7 @@ glm_vec4_isinf(vec4 v) {
#ifndef CGLM_FAST_MATH
return isinf(v[0]) || isinf(v[1]) || isinf(v[2]) || isinf(v[3]);
#else
(void)v;
return false;
#endif
}

View File

@@ -66,6 +66,7 @@
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_refract(vec4 v, vec4 n, float eta, vec4 dest);
CGLM_INLINE void glm_vec4_swap(vec4 a, vec4 b)
DEPRECATED:
glm_vec4_dup
@@ -1345,4 +1346,16 @@ glm_vec4_refract(vec4 v, vec4 n, float eta, vec4 dest) {
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 */

View File

@@ -10,6 +10,6 @@
#define CGLM_VERSION_MAJOR 0
#define CGLM_VERSION_MINOR 9
#define CGLM_VERSION_PATCH 5
#define CGLM_VERSION_PATCH 6
#endif /* cglm_version_h */

View File

@@ -1,5 +1,5 @@
project('cglm', 'c',
version : '0.9.5',
version : '0.9.6',
license : 'mit',
default_options : [
'c_std=c11',

View File

@@ -62,6 +62,12 @@ glmc_perspective(float fovy, float aspect, float nearZ, float farZ, mat4 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
void
glmc_persp_move_far(mat4 proj, float deltaFar) {
@@ -74,6 +80,12 @@ glmc_perspective_default(float aspect, mat4 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
void
glmc_perspective_resize(float aspect, mat4 proj) {

View File

@@ -34,6 +34,12 @@ glmc_perspective_lh_no(float fovy,
dest);
}
CGLM_EXPORT
void
glmc_perspective_resize_lh_no(float aspect, mat4 proj) {
glm_perspective_resize_lh_no(aspect, proj);
}
CGLM_EXPORT
void
glmc_persp_move_far_lh_no(mat4 proj, float deltaFar) {

View File

@@ -34,6 +34,12 @@ glmc_perspective_lh_zo(float fovy,
dest);
}
CGLM_EXPORT
void
glmc_perspective_resize_lh_zo(float aspect, mat4 proj) {
glm_perspective_resize_lh_zo(aspect, proj);
}
CGLM_EXPORT
void
glmc_persp_move_far_lh_zo(mat4 proj, float deltaFar) {

View File

@@ -34,6 +34,12 @@ glmc_perspective_rh_no(float fovy,
dest);
}
CGLM_EXPORT
void
glmc_perspective_resize_rh_no(float aspect, mat4 proj) {
glm_perspective_resize_rh_no(aspect, proj);
}
CGLM_EXPORT
void
glmc_persp_move_far_rh_no(mat4 proj, float deltaFar) {

View File

@@ -34,6 +34,12 @@ glmc_perspective_rh_zo(float fovy,
dest);
}
CGLM_EXPORT
void
glmc_perspective_resize_rh_zo(float aspect, mat4 proj) {
glm_perspective_resize_rh_zo(aspect, proj);
}
CGLM_EXPORT
void
glmc_persp_move_far_rh_zo(mat4 proj, float deltaFar) {

View File

@@ -8,6 +8,12 @@
#include "../include/cglm/cglm.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
void
glmc_mat2_copy(mat2 mat, mat2 dest) {
@@ -16,20 +22,20 @@ glmc_mat2_copy(mat2 mat, mat2 dest) {
CGLM_EXPORT
void
glmc_mat2_identity(mat2 mat) {
glm_mat2_identity(mat);
glmc_mat2_identity(mat2 m) {
glm_mat2_identity(m);
}
CGLM_EXPORT
void
glmc_mat2_identity_array(mat2 * __restrict mat, size_t count) {
glm_mat2_identity_array(mat, count);
glmc_mat2_identity_array(mat2 * __restrict mats, size_t count) {
glm_mat2_identity_array(mats, count);
}
CGLM_EXPORT
void
glmc_mat2_zero(mat2 mat) {
glm_mat2_zero(mat);
glmc_mat2_zero(mat2 m) {
glm_mat2_zero(m);
}
CGLM_EXPORT
@@ -40,8 +46,14 @@ glmc_mat2_mul(mat2 m1, mat2 m2, mat2 dest) {
CGLM_EXPORT
void
glmc_mat2_transpose_to(mat2 m, mat2 dest) {
glm_mat2_transpose_to(m, dest);
glmc_mat2_mulv(mat2 m, vec2 v, vec2 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
@@ -50,30 +62,12 @@ glmc_mat2_transpose(mat2 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
void
glmc_mat2_scale(mat2 m, float s) {
glm_mat2_scale(m, s);
}
CGLM_EXPORT
float
glmc_mat2_det(mat2 mat) {
return glm_mat2_det(mat);
}
CGLM_EXPORT
void
glmc_mat2_inv(mat2 mat, mat2 dest) {
@@ -94,12 +88,18 @@ glmc_mat2_swap_row(mat2 mat, int row1, int row2) {
CGLM_EXPORT
float
glmc_mat2_rmc(vec2 r, mat2 m, vec2 c) {
return glm_mat2_rmc(r, m, c);
glmc_mat2_det(mat2 m) {
return glm_mat2_det(m);
}
CGLM_EXPORT
void
glmc_mat2_make(const float * __restrict src, mat2 dest) {
glm_mat2_make(src, dest);
float
glmc_mat2_trace(mat2 m) {
return glm_mat2_trace(m);
}
CGLM_EXPORT
float
glmc_mat2_rmc(vec2 r, mat2 m, vec2 c) {
return glm_mat2_rmc(r, m, c);
}

View File

@@ -10,14 +10,14 @@
CGLM_EXPORT
void
glmc_mat2x3_copy(mat2x3 mat, mat2x3 dest) {
glm_mat2x3_copy(mat, dest);
glmc_mat2x3_copy(mat2x3 src, mat2x3 dest) {
glm_mat2x3_copy(src, dest);
}
CGLM_EXPORT
void
glmc_mat2x3_zero(mat2x3 mat) {
glm_mat2x3_zero(mat);
glmc_mat2x3_zero(mat2x3 m) {
glm_mat2x3_zero(m);
}
CGLM_EXPORT
@@ -40,8 +40,8 @@ glmc_mat2x3_mulv(mat2x3 m, vec2 v, vec3 dest) {
CGLM_EXPORT
void
glmc_mat2x3_transpose(mat2x3 m, mat3x2 dest) {
glm_mat2x3_transpose(m, dest);
glmc_mat2x3_transpose(mat2x3 src, mat3x2 dest) {
glm_mat2x3_transpose(src, dest);
}
CGLM_EXPORT

View File

@@ -10,14 +10,14 @@
CGLM_EXPORT
void
glmc_mat2x4_copy(mat2x4 mat, mat2x4 dest) {
glm_mat2x4_copy(mat, dest);
glmc_mat2x4_copy(mat2x4 src, mat2x4 dest) {
glm_mat2x4_copy(src, dest);
}
CGLM_EXPORT
void
glmc_mat2x4_zero(mat2x4 mat) {
glm_mat2x4_zero(mat);
glmc_mat2x4_zero(mat2x4 m) {
glm_mat2x4_zero(m);
}
CGLM_EXPORT
@@ -40,8 +40,8 @@ glmc_mat2x4_mulv(mat2x4 m, vec2 v, vec4 dest) {
CGLM_EXPORT
void
glmc_mat2x4_transpose(mat2x4 m, mat4x2 dest) {
glm_mat2x4_transpose(m, dest);
glmc_mat2x4_transpose(mat2x4 src, mat4x2 dest) {
glm_mat2x4_transpose(src, dest);
}
CGLM_EXPORT

View File

@@ -109,3 +109,9 @@ void
glmc_mat3_make(const float * __restrict src, mat3 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);
}

View File

@@ -10,14 +10,14 @@
CGLM_EXPORT
void
glmc_mat3x2_copy(mat3x2 mat, mat3x2 dest) {
glm_mat3x2_copy(mat, dest);
glmc_mat3x2_copy(mat3x2 src, mat3x2 dest) {
glm_mat3x2_copy(src, dest);
}
CGLM_EXPORT
void
glmc_mat3x2_zero(mat3x2 mat) {
glm_mat3x2_zero(mat);
glmc_mat3x2_zero(mat3x2 m) {
glm_mat3x2_zero(m);
}
CGLM_EXPORT
@@ -40,8 +40,8 @@ glmc_mat3x2_mulv(mat3x2 m, vec3 v, vec2 dest) {
CGLM_EXPORT
void
glmc_mat3x2_transpose(mat3x2 m, mat2x3 dest) {
glm_mat3x2_transpose(m, dest);
glmc_mat3x2_transpose(mat3x2 src, mat2x3 dest) {
glm_mat3x2_transpose(src, dest);
}
CGLM_EXPORT

View File

@@ -10,14 +10,14 @@
CGLM_EXPORT
void
glmc_mat3x4_copy(mat3x4 mat, mat3x4 dest) {
glm_mat3x4_copy(mat, dest);
glmc_mat3x4_copy(mat3x4 src, mat3x4 dest) {
glm_mat3x4_copy(src, dest);
}
CGLM_EXPORT
void
glmc_mat3x4_zero(mat3x4 mat) {
glm_mat3x4_zero(mat);
glmc_mat3x4_zero(mat3x4 m) {
glm_mat3x4_zero(m);
}
CGLM_EXPORT
@@ -40,8 +40,8 @@ glmc_mat3x4_mulv(mat3x4 m, vec3 v, vec4 dest) {
CGLM_EXPORT
void
glmc_mat3x4_transpose(mat3x4 m, mat4x3 dest) {
glm_mat3x4_transpose(m, dest);
glmc_mat3x4_transpose(mat3x4 src, mat4x3 dest) {
glm_mat3x4_transpose(src, dest);
}
CGLM_EXPORT

View File

@@ -169,3 +169,9 @@ void
glmc_mat4_make(const float * __restrict src, mat4 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);
}

View File

@@ -10,14 +10,14 @@
CGLM_EXPORT
void
glmc_mat4x2_copy(mat4x2 mat, mat4x2 dest) {
glm_mat4x2_copy(mat, dest);
glmc_mat4x2_copy(mat4x2 src, mat4x2 dest) {
glm_mat4x2_copy(src, dest);
}
CGLM_EXPORT
void
glmc_mat4x2_zero(mat4x2 mat) {
glm_mat4x2_zero(mat);
glmc_mat4x2_zero(mat4x2 m) {
glm_mat4x2_zero(m);
}
CGLM_EXPORT
@@ -40,8 +40,8 @@ glmc_mat4x2_mulv(mat4x2 m, vec4 v, vec2 dest) {
CGLM_EXPORT
void
glmc_mat4x2_transpose(mat4x2 m, mat2x4 dest) {
glm_mat4x2_transpose(m, dest);
glmc_mat4x2_transpose(mat4x2 src, mat2x4 dest) {
glm_mat4x2_transpose(src, dest);
}
CGLM_EXPORT

View File

@@ -10,14 +10,14 @@
CGLM_EXPORT
void
glmc_mat4x3_copy(mat4x3 mat, mat4x3 dest) {
glm_mat4x3_copy(mat, dest);
glmc_mat4x3_copy(mat4x3 src, mat4x3 dest) {
glm_mat4x3_copy(src, dest);
}
CGLM_EXPORT
void
glmc_mat4x3_zero(mat4x3 mat) {
glm_mat4x3_zero(mat);
glmc_mat4x3_zero(mat4x3 m) {
glm_mat4x3_zero(m);
}
CGLM_EXPORT
@@ -40,8 +40,8 @@ glmc_mat4x3_mulv(mat4x3 m, vec4 v, vec3 dest) {
CGLM_EXPORT
void
glmc_mat4x3_transpose(mat4x3 m, mat3x4 dest) {
glm_mat4x3_transpose(m, dest);
glmc_mat4x3_transpose(mat4x3 src, mat3x4 dest) {
glm_mat4x3_transpose(src, dest);
}
CGLM_EXPORT

View File

@@ -24,4 +24,4 @@ CGLM_EXPORT
float
glmc_perlin_vec2(vec2 p) {
return glm_perlin_vec2(p);
}
}

View File

@@ -356,3 +356,9 @@ bool
glmc_vec2_refract(vec2 v, vec2 n, float eta, vec2 dest) {
return glm_vec2_refract(v, n, eta, dest);
}
CGLM_EXPORT
void
glmc_vec2_swap(vec2 a, vec2 b) {
glm_vec2_swap(a, b);
}

View File

@@ -501,3 +501,9 @@ bool
glmc_vec3_refract(vec3 v, vec3 n, float eta, vec3 dest) {
return glm_vec3_refract(v, n, eta, dest);
}
CGLM_EXPORT
void
glmc_vec3_swap(vec3 a, vec3 b) {
glm_vec3_swap(a, b);
}

View File

@@ -459,3 +459,9 @@ bool
glmc_vec4_refract(vec4 v, vec4 n, float eta, vec4 dest) {
return glm_vec4_refract(v, n, eta, dest);
}
CGLM_EXPORT
void
glmc_vec4_swap(vec4 a, vec4 b) {
glm_vec4_swap(a, b);
}

View File

@@ -17,7 +17,7 @@ main(int argc, const char * argv[]) {
test_entry_t *entry;
test_status_t st;
int32_t i, count, passed, failed, maxlen;
double start, end, elapsed, total;
clock_t start, end, elapsed, total;
(void)argc;
(void)argv;
@@ -70,7 +70,7 @@ main(int argc, const char * argv[]) {
fprintf(stderr, GREEN " " OK_TEXT RESET " %-*s ", maxlen, entry->name);
if (elapsed > 0.01)
fprintf(stderr, YELLOW "%.2fs", elapsed);
fprintf(stderr, YELLOW "%.2lus", elapsed);
else
fprintf(stderr, "0");
@@ -85,7 +85,7 @@ main(int argc, const char * argv[]) {
}
fprintf(stderr,
CYAN "\ncglm test results (%0.2fs):\n" RESET
CYAN "\ncglm test results (%0.2lus):\n" RESET
"--------------------------\n"
MAGENTA "%d" RESET " tests ran, "

View 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
}

View File

@@ -61,8 +61,8 @@ TEST_IMPL(GLM_PREFIX, mul_rot) {
mat4 m4 = GLM_MAT4_ZERO_INIT;
int i, j, k;
glm_rotate(m1, drand48(), (vec3){drand48(), drand48(), drand48()});
glm_rotate(m2, drand48(), (vec3){drand48(), drand48(), drand48()});
glm_rotate(m1, frand48(), (vec3){frand48(), frand48(), frand48()});
glm_rotate(m2, frand48(), (vec3){frand48(), frand48(), frand48()});
GLM(mul_rot)(m1, m2, m3);
for (i = 0; i < 4; i++) {

View File

@@ -11,49 +11,49 @@ test_rand_mat4(mat4 dest) {
glm_mat4_copy(GLM_MAT4_IDENTITY, dest);
/* random position */
dest[3][0] = drand48();
dest[3][1] = drand48();
dest[3][2] = drand48();
dest[3][0] = frand48();
dest[3][1] = frand48();
dest[3][2] = frand48();
/* 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 */
/* glm_scale(dest, (vec3){drand48(), drand48(), drand48()}); */
/* glm_scale(dest, (vec3){frand48(), frand48(), frand48()}); */
}
void
test_rand_mat4x2(mat4x2 dest) {
dest[0][0] = drand48();
dest[0][1] = drand48();
dest[0][0] = frand48();
dest[0][1] = frand48();
dest[1][0] = drand48();
dest[1][1] = drand48();
dest[1][0] = frand48();
dest[1][1] = frand48();
dest[2][0] = drand48();
dest[2][1] = drand48();
dest[2][0] = frand48();
dest[2][1] = frand48();
dest[3][0] = drand48();
dest[3][1] = drand48();
dest[3][0] = frand48();
dest[3][1] = frand48();
}
void
test_rand_mat4x3(mat4x3 dest) {
dest[0][0] = drand48();
dest[0][1] = drand48();
dest[0][2] = drand48();
dest[0][0] = frand48();
dest[0][1] = frand48();
dest[0][2] = frand48();
dest[1][0] = drand48();
dest[1][1] = drand48();
dest[1][2] = drand48();
dest[1][0] = frand48();
dest[1][1] = frand48();
dest[1][2] = frand48();
dest[2][0] = drand48();
dest[2][1] = drand48();
dest[2][2] = drand48();
dest[2][0] = frand48();
dest[2][1] = frand48();
dest[2][2] = frand48();
dest[3][0] = drand48();
dest[3][1] = drand48();
dest[3][2] = drand48();
dest[3][0] = frand48();
dest[3][1] = frand48();
dest[3][2] = frand48();
}
void
@@ -61,73 +61,80 @@ test_rand_mat3(mat3 dest) {
mat4 m4;
/* 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);
}
void
test_rand_mat3x2(mat3x2 dest) {
dest[0][0] = drand48();
dest[0][1] = drand48();
dest[1][0] = drand48();
dest[1][1] = drand48();
dest[2][0] = drand48();
dest[2][1] = drand48();
dest[0][0] = frand48();
dest[0][1] = frand48();
dest[1][0] = frand48();
dest[1][1] = frand48();
dest[2][0] = frand48();
dest[2][1] = frand48();
}
void
test_rand_mat3x4(mat3x4 dest) {
dest[0][0] = drand48();
dest[0][1] = drand48();
dest[0][2] = drand48();
dest[0][3] = drand48();
dest[0][0] = frand48();
dest[0][1] = frand48();
dest[0][2] = frand48();
dest[0][3] = frand48();
dest[1][0] = drand48();
dest[1][1] = drand48();
dest[1][2] = drand48();
dest[1][3] = drand48();
dest[1][0] = frand48();
dest[1][1] = frand48();
dest[1][2] = frand48();
dest[1][3] = frand48();
dest[2][0] = drand48();
dest[2][1] = drand48();
dest[2][2] = drand48();
dest[2][3] = drand48();
dest[2][0] = frand48();
dest[2][1] = frand48();
dest[2][2] = frand48();
dest[2][3] = frand48();
}
void
test_rand_mat2(mat2 dest) {
dest[0][0] = drand48();
dest[0][1] = drand48();
dest[1][0] = drand48();
dest[1][1] = drand48();
dest[0][0] = frand48();
dest[0][1] = frand48();
dest[1][0] = frand48();
dest[1][1] = frand48();
}
void
test_rand_mat2x3(mat2x3 dest) {
dest[0][0] = drand48();
dest[0][1] = drand48();
dest[0][2] = drand48();
dest[1][0] = drand48();
dest[1][1] = drand48();
dest[1][2] = drand48();
dest[0][0] = frand48();
dest[0][1] = frand48();
dest[0][2] = frand48();
dest[1][0] = frand48();
dest[1][1] = frand48();
dest[1][2] = frand48();
}
void
test_rand_mat2x4(mat2x4 dest) {
dest[0][0] = drand48();
dest[0][1] = drand48();
dest[0][2] = drand48();
dest[0][3] = drand48();
dest[1][0] = drand48();
dest[1][1] = drand48();
dest[1][2] = drand48();
dest[1][3] = drand48();
dest[0][0] = frand48();
dest[0][1] = frand48();
dest[0][2] = frand48();
dest[0][3] = frand48();
dest[1][0] = frand48();
dest[1][1] = frand48();
dest[1][2] = frand48();
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
test_rand_vec3(vec3 dest) {
dest[0] = drand48();
dest[1] = drand48();
dest[2] = drand48();
dest[0] = frand48();
dest[1] = frand48();
dest[2] = frand48();
}
vec3s
@@ -139,10 +146,10 @@ test_rand_vec3s(void) {
void
test_rand_vec4(vec4 dest) {
dest[0] = drand48();
dest[1] = drand48();
dest[2] = drand48();
dest[3] = drand48();
dest[0] = frand48();
dest[1] = frand48();
dest[2] = frand48();
dest[3] = frand48();
}
vec4s
@@ -154,12 +161,12 @@ test_rand_vec4s(void) {
float
test_rand(void) {
return drand48();
return frand48();
}
void
test_rand_quat(versor q) {
glm_quat(q, drand48(), drand48(), drand48(), drand48());
glm_quat(q, frand48(), frand48(), frand48(), frand48());
glm_quat_normalize(q);
}
@@ -169,7 +176,7 @@ test_assert_mat4_eq(mat4 m1, mat4 m2) {
for (i = 0; i < 4; i++) {
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 (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 (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 (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 (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 (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 (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 (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 (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 (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 (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 (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_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_status_t
test_assert_vec2_eq(vec2 v1, vec2 v2) {
ASSERT(fabsf(v1[0] - v2[0]) <= 0.000009); /* rounding errors */
ASSERT(fabsf(v1[1] - v2[1]) <= 0.000009);
ASSERT(fabsf(v1[0] - v2[0]) <= 0.000009f); /* rounding errors */
ASSERT(fabsf(v1[1] - v2[1]) <= 0.000009f);
TEST_SUCCESS
}
test_status_t
test_assert_vec3_eq(vec3 v1, vec3 v2) {
ASSERT(fabsf(v1[0] - v2[0]) <= 0.000009); /* rounding errors */
ASSERT(fabsf(v1[1] - v2[1]) <= 0.000009);
ASSERT(fabsf(v1[2] - v2[2]) <= 0.000009);
ASSERT(fabsf(v1[0] - v2[0]) <= 0.000009f); /* rounding errors */
ASSERT(fabsf(v1[1] - v2[1]) <= 0.000009f);
ASSERT(fabsf(v1[2] - v2[2]) <= 0.000009f);
TEST_SUCCESS
}
@@ -533,10 +540,10 @@ test_assert_vec3s_eq(vec3s v1, vec3s v2) {
test_status_t
test_assert_vec4_eq(vec4 v1, vec4 v2) {
ASSERT(fabsf(v1[0] - v2[0]) <= 0.000009); /* rounding errors */
ASSERT(fabsf(v1[1] - v2[1]) <= 0.000009);
ASSERT(fabsf(v1[2] - v2[2]) <= 0.000009);
ASSERT(fabsf(v1[3] - v2[3]) <= 0.000009);
ASSERT(fabsf(v1[0] - v2[0]) <= 0.000009f); /* rounding errors */
ASSERT(fabsf(v1[1] - v2[1]) <= 0.000009f);
ASSERT(fabsf(v1[2] - v2[2]) <= 0.000009f);
ASSERT(fabsf(v1[3] - v2[3]) <= 0.000009f);
TEST_SUCCESS
}
@@ -550,20 +557,20 @@ test_assert_vec4s_eq(vec4s v1, vec4s v2) {
test_status_t
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[1]) - fabsf(v2[1])) <= 0.0009);
ASSERT(fabsf(fabsf(v1[2]) - fabsf(v2[2])) <= 0.0009);
ASSERT(fabsf(fabsf(v1[3]) - fabsf(v2[3])) <= 0.0009);
ASSERT(fabsf(fabsf(v1[0]) - fabsf(v2[0])) <= 0.0009f); /* rounding errors */
ASSERT(fabsf(fabsf(v1[1]) - fabsf(v2[1])) <= 0.0009f);
ASSERT(fabsf(fabsf(v1[2]) - fabsf(v2[2])) <= 0.0009f);
ASSERT(fabsf(fabsf(v1[3]) - fabsf(v2[3])) <= 0.0009f);
TEST_SUCCESS
}
test_status_t
test_assert_quat_eq(versor v1, versor v2) {
ASSERT(fabsf(v1[0] - v2[0]) <= 0.000009); /* rounding errors */
ASSERT(fabsf(v1[1] - v2[1]) <= 0.000009);
ASSERT(fabsf(v1[2] - v2[2]) <= 0.000009);
ASSERT(fabsf(v1[3] - v2[3]) <= 0.000009);
ASSERT(fabsf(v1[0] - v2[0]) <= 0.000009f); /* rounding errors */
ASSERT(fabsf(v1[1] - v2[1]) <= 0.000009f);
ASSERT(fabsf(v1[2] - v2[2]) <= 0.000009f);
ASSERT(fabsf(v1[3] - v2[3]) <= 0.000009f);
TEST_SUCCESS
}
@@ -572,10 +579,10 @@ test_status_t
test_assert_quat_eq_identity(versor q) {
versor p = GLM_QUAT_IDENTITY_INIT;
ASSERT(fabsf(q[0] - p[0]) <= 0.000009); /* rounding errors */
ASSERT(fabsf(q[1] - p[1]) <= 0.000009);
ASSERT(fabsf(q[2] - p[2]) <= 0.000009);
ASSERT(fabsf(q[3] - p[3]) <= 0.000009);
ASSERT(fabsf(q[0] - p[0]) <= 0.000009f); /* rounding errors */
ASSERT(fabsf(q[1] - p[1]) <= 0.000009f);
ASSERT(fabsf(q[2] - p[2]) <= 0.000009f);
ASSERT(fabsf(q[3] - p[3]) <= 0.000009f);
TEST_SUCCESS
}

View File

@@ -41,6 +41,9 @@ test_rand_mat2x3(mat2x3 dest);
void
test_rand_mat2x4(mat2x4 dest);
void
test_rand_transform2d(mat3 dest);
test_status_t
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;
}
/* drand with explicit conversion to lower precision */
CGLM_INLINE
float
frand48(void) {
return (float)drand48();
}
#endif /* test_common_h */

View File

@@ -196,11 +196,12 @@ TEST_IMPL(GLM_PREFIX, mat2_trace) {
TEST_IMPL(GLM_PREFIX, mat2_scale) {
mat2 m1 = A_MATRIX2x2;
mat2 m2 = A_MATRIX2x2;
int i, j, scale;
int i, j;
float scale;
scale = rand() % 100;
GLM(mat2_scale)(m1, (float)scale);
GLM(mat2_scale)(m1, scale);
for (i = 0; i < 2; i++) {
for (j = 0; j < 2; j++) {

View File

@@ -140,11 +140,12 @@ TEST_IMPL(GLM_PREFIX, mat2x3_transpose) {
TEST_IMPL(GLM_PREFIX, mat2x3_scale) {
mat2x3 m1 = A_MATRIX2X3;
mat2x3 m2 = A_MATRIX2X3;
int i, j, scale;
int i, j;
float scale;
scale = rand() % 100;
GLM(mat2x3_scale)(m1, (float) scale);
GLM(mat2x3_scale)(m1, scale);
for (i = 0; i < 2; i++) {
for (j = 0; j < 3; j++) {

View File

@@ -143,11 +143,12 @@ TEST_IMPL(GLM_PREFIX, mat2x4_transpose) {
TEST_IMPL(GLM_PREFIX, mat2x4_scale) {
mat2x4 m1 = A_MATRIX2X4;
mat2x4 m2 = A_MATRIX2X4;
int i, j, scale;
int i, j;
float scale;
scale = rand() % 100;
GLM(mat2x4_scale)(m1, (float) scale);
GLM(mat2x4_scale)(m1, scale);
for (i = 0; i < 2; i++) {
for (j = 0; j < 4; j++) {

View File

@@ -184,11 +184,12 @@ TEST_IMPL(GLM_PREFIX, mat3_transpose) {
TEST_IMPL(GLM_PREFIX, mat3_scale) {
mat3 m1 = A_MATRIX;
mat3 m2 = A_MATRIX;
int i, j, k, scale;
int i, j, k;
float scale;
scale = rand() % 100;
GLM(mat3_scale)(m1, (float)scale);
GLM(mat3_scale)(m1, scale);
for (i = 0; i < 3; i++) {
for (j = 0; j < 3; j++) {
@@ -326,4 +327,26 @@ TEST_IMPL(GLM_PREFIX, mat3_make) {
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

View File

@@ -139,11 +139,12 @@ TEST_IMPL(GLM_PREFIX, mat3x2_transpose) {
TEST_IMPL(GLM_PREFIX, mat3x2_scale) {
mat3x2 m1 = A_MATRIX3X2;
mat3x2 m2 = A_MATRIX3X2;
int i, j, scale;
int i, j;
float scale;
scale = rand() % 100;
GLM(mat3x2_scale)(m1, (float) scale);
GLM(mat3x2_scale)(m1, scale);
for (i = 0; i < 3; i++) {
for (j = 0; j < 2; j++) {

View File

@@ -145,11 +145,12 @@ TEST_IMPL(GLM_PREFIX, mat3x4_transpose) {
TEST_IMPL(GLM_PREFIX, mat3x4_scale) {
mat3x4 m1 = A_MATRIX3X4;
mat3x4 m2 = A_MATRIX3X4;
int i, j, scale;
int i, j;
float scale;
scale = rand() % 100;
GLM(mat3x4_scale)(m1, (float) scale);
GLM(mat3x4_scale)(m1, scale);
for (i = 0; i < 3; i++) {
for (j = 0; j < 4; j++) {

Some files were not shown because too many files have changed in this diff Show More