Compare commits

...

1076 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
Recep Aslantas
4d0a0a7025 Update wasm.h 2025-02-09 15:30:49 +03:00
Recep Aslantas
a88d32c776 Merge branch 'master' into optimize-inv 2025-02-09 15:13:28 +03:00
Recep Aslantas
3bfd31af99 build, win: add missing files 2025-02-09 15:01:55 +03:00
Recep Aslantas
3ee809b9b3 Merge pull request #444 from wethu/wethu-docs-minor-fix-example-numbering
Fix numbering - opengl matrix uniform examples (docs)
2025-01-30 23:10:03 +03:00
Ellis
8cdf496baf Fix numbering 2025-01-30 21:39:17 +10:00
Recep Aslantas
d42bff7773 Update ci.yml 2025-01-25 11:53:27 +03:00
Recep Aslantas
365d43bef4 Update ci.yml 2025-01-25 11:47:32 +03:00
Recep Aslantas
5770fdb336 ci: add arm builds 2025-01-25 11:08:06 +03:00
Recep Aslantas
042d84f058 ci: add arm builds 2025-01-25 10:58:48 +03:00
Recep Aslantas
70a1a946ee arm: use glmm_div where possible to fix ARMv7 <-> ARM64 2025-01-24 22:21:11 +03:00
Recep Aslantas
8ca1f19aa2 arm: use glmm_div where possible to fix ARMv7 <-> ARM64 2025-01-24 22:20:57 +03:00
Recep Aslantas
adb3ac18c0 Merge branch 'master' into optimize-inv 2025-01-24 16:04:49 +03:00
Recep Aslantas
441f2657ab suppress param-name warns 2025-01-24 11:20:49 +03:00
Recep Aslantas
9b660e8bd0 Update cmake-wasm.yml 2025-01-23 14:10:04 +03:00
Recep Aslantas
40a2aca7ec Update cmake-wasm.yml 2025-01-23 13:55:14 +03:00
Recep Aslantas
a48fa8be65 Update cmake-wasm.yml 2025-01-23 13:54:37 +03:00
Recep Aslantas
2f36faa70a Update cmake-wasm.yml 2025-01-23 13:45:19 +03:00
Recep Aslantas
36f59b7b6c Update cmake-wasm.yml 2025-01-23 13:39:30 +03:00
Recep Aslantas
f4993318d2 Update ci.yml 2025-01-23 13:04:37 +03:00
Recep Aslantas
5672370e31 Update ci.yml 2025-01-23 12:49:52 +03:00
Recep Aslantas
ae1b9a3982 Update ci.yml 2025-01-23 12:44:04 +03:00
Recep Aslantas
a18d9c28e7 Update ci.yml 2025-01-23 12:41:08 +03:00
Recep Aslantas
fc91f95bb2 Merge branch 'master' of https://github.com/recp/cglm 2025-01-23 12:24:49 +03:00
Recep Aslantas
39052494a2 Revert "Update ci.yml"
This reverts commit 488f782704.
2025-01-23 12:22:27 +03:00
Recep Aslantas
488f782704 Update ci.yml
Update ci.yml

Update ci.yml
2025-01-23 12:22:09 +03:00
Recep Aslantas
814c354337 Update ci.yml 2025-01-23 12:18:12 +03:00
Recep Aslantas
1ad56f0e94 Update ci.yml 2025-01-23 12:16:07 +03:00
Recep Aslantas
cc54ad3f92 Update ci.yml 2025-01-23 12:15:22 +03:00
Recep Aslantas
3971ef8ef1 Update ci.yml 2025-01-23 01:09:20 +03:00
Recep Aslantas
b4a3ed32d9 Update ci.yml 2025-01-23 01:07:32 +03:00
Recep Aslantas
eb37a28ff5 Update ci.yml 2025-01-23 00:58:02 +03:00
Recep Aslantas
925f9c1d1a Update ci.yml 2025-01-23 00:50:36 +03:00
Recep Aslantas
9f74fd9597 Update ci.yml 2025-01-23 00:44:12 +03:00
Recep Aslantas
99937807cf Update ci.yml 2025-01-23 00:19:52 +03:00
Recep Aslantas
cc79b440e7 Update ci.yml 2025-01-23 00:13:59 +03:00
Recep Aslantas
e161c4d0a7 Update ci.yml 2025-01-23 00:06:00 +03:00
Recep Aslantas
e8c791e91e Merge pull request #441 from MarcinKonowalczyk/perlin
Implement Perlin noise
2025-01-22 23:23:03 +03:00
Recep Aslantas
241b751d8c build, autotools: add missing file 2025-01-22 23:17:23 +03:00
Marcin
dfc9969f85 vectorise fades
fix fade for vec2
2025-01-22 16:49:27 +00:00
Marcin
2b4aef2a29 glm__noiseDetail_fade_vec2 arg restrict 2025-01-22 16:49:26 +00:00
Marcin
fd0131734f fix granNorm arg order 2025-01-22 16:49:26 +00:00
Marcin
9cfa40f423 glm__noiseDetail_taylorInvSqrt 2025-01-22 16:49:26 +00:00
Marcin
b79347eb13 vdivq_f32 2025-01-22 16:49:26 +00:00
Marcin
450d747867 1/7 patch 2025-01-22 14:40:18 +00:00
Recep Aslantas
26e174db46 Merge pull request #442 from duarm/master
Rename struct/aabb2d.h functions to match aabb2d.h, add tests
2025-01-21 10:00:12 +03:00
Recep Aslantas
e605c1d585 Update aabb2d.h 2025-01-21 09:59:48 +03:00
duarm
f815918a74 rename struct/aabb2d.h functions to match aabb2d.h, add tests 2025-01-20 13:29:21 -03:00
Marcin
948642ff33 _glm_ -> glm__ for internal macros 2025-01-20 14:09:05 +00:00
Marcin
23c0f5f660 couple more // comments 2025-01-18 20:11:00 +00:00
Marcin
d3ad1645fc purged // comments in noise.h 2025-01-18 20:11:00 +00:00
Marcin
fa7bc07ae9 changed noiseDetail to #defines
_glm_noiseDetail_mod289
_glm_noiseDetail_permute
_glm_noiseDetail_fade_vec4
_glm_noiseDetail_fade_vec3
_glm_noiseDetail_fade_vec2
_glm_noiseDetail_taylorInvSqrt
_glm_noiseDetail_gradNorm_vec4
_glm_noiseDetail_gradNorm_vec3
_glm_noiseDetail_gradNorm_vec2
_glm_noiseDetail_i2gxyzw
_glm_noiseDetail_i2gxyz
_glm_noiseDetail_i2gxy
2025-01-18 20:11:00 +00:00
Marcin
f32f18a373 sets -> fill 2025-01-18 20:10:59 +00:00
Marcin
082f1878dd glms_vec2_mods doc 2025-01-18 20:10:59 +00:00
Marcin
4b0e7dadd6 vec2 swizzle 2025-01-18 20:10:59 +00:00
Marcin
b45bf1d571 switch deprecation in cglm/call.h to #define 2025-01-18 20:10:59 +00:00
Marcin
8493a6c0d3 fix cglm_vec3/4_swizzle 2025-01-18 20:10:59 +00:00
Marcin
f50736aee7 vec2_step test 2025-01-18 20:10:59 +00:00
Marcin
6bc980f3d9 add missing vec2 step 2025-01-18 20:10:59 +00:00
Marcin
5cffcf74c4 missing glmc_vec2_stepr 2025-01-18 20:10:58 +00:00
Marcin
fb469c779d missing doc 2025-01-18 20:10:58 +00:00
Marcin
8e69157052 missing vec4 steps and stepr 2025-01-18 20:10:58 +00:00
Marcin
6c0e3e9460 deprecate step_uni in favour of steps
This seems to be the newer naming system
2025-01-18 20:10:58 +00:00
Marcin
4ca0c536af steps and stepr test 2025-01-18 20:10:58 +00:00
Marcin
9a1206f3f1 steps and stepr boilerplate 2025-01-18 20:10:58 +00:00
Marcin
c2ebef3867 change steps -> stepr and move to ext 2025-01-18 20:10:57 +00:00
Marcin
0e0eff71ce correct vec4_mods doc 2025-01-18 20:10:57 +00:00
Marcin
6620adcc16 fix invalid types in vec2_frac/floor 2025-01-18 20:10:57 +00:00
Marcin
a986a4d741 add missing floor tests 2025-01-18 20:10:57 +00:00
Marcin
32e7d5cceb mods test 2025-01-18 20:10:57 +00:00
Marcin
e14c730d5c mods boilerplate 2025-01-18 20:10:57 +00:00
Marcin
fbf0014c82 missing vec4_floor doc 2025-01-18 20:10:56 +00:00
Marcin
0483362f5c move mods to ext 2025-01-18 20:10:56 +00:00
Marcin
35af0c04fe remove extra spaces from vec3.h and vec4.h 2025-01-18 13:19:29 +00:00
Marcin
66d51e5771 double spaces in other files 2025-01-18 13:19:29 +00:00
Marcin
5a3a16d9ad double spaces in noise.h 2025-01-18 13:19:29 +00:00
Marcin
651ad8ca32 vec2-ext docs 2025-01-18 12:57:33 +00:00
Marcin
b1192c8638 vec3-ext docs 2025-01-18 12:57:33 +00:00
Marcin
eaf2d7314e vec4-ext docs 2025-01-18 12:57:33 +00:00
Marcin
200b0875ba vec2_floor test 2025-01-18 12:57:32 +00:00
Marcin
9a25fab6f0 vec2_floor boilerplate 2025-01-18 12:57:32 +00:00
Marcin
bfaf413a5d vec2_floor impl 2025-01-18 12:57:32 +00:00
Marcin
9594d0cc86 add missing glms_vec2_abs 2025-01-18 12:57:32 +00:00
Marcin
2890472a0b add missing test entry for vec2_abs 2025-01-18 12:57:32 +00:00
Marcin
c48befca37 vec2_fract test 2025-01-18 12:57:32 +00:00
Marcin
3c9eecd0be vec2_fract boilerplate 2025-01-18 12:57:32 +00:00
Marcin
a9fee1b4d7 vec2_fract 2025-01-18 12:57:31 +00:00
Marcin
52753672bb vec4_fract test 2025-01-18 12:57:31 +00:00
Marcin
68215526cf vec4_floor boilerplate 2025-01-18 12:57:31 +00:00
Marcin
c27ef7e93b vec3_floor struct doc 2025-01-18 12:57:31 +00:00
Marcin
2ba561cc92 move vec4_floor to ext 2025-01-18 12:57:31 +00:00
Marcin
e66f2f3df4 vec3_floor test 2025-01-18 12:57:31 +00:00
Marcin
967c9e0a09 vec3_floor boilerplate 2025-01-18 12:57:31 +00:00
Marcin
1637d2cef1 move vec3_floor to ext 2025-01-18 12:57:30 +00:00
Marcin
2acdd1e4d0 fix _glm_noiseDetail_gradNorm_vec2 2025-01-18 12:57:30 +00:00
Marcin
606ecbceaa vac_muls -> vec_scale 2025-01-18 12:57:30 +00:00
Marcin
f1a72241b1 docs 2025-01-17 20:34:47 +00:00
Marcin
9085ed020a glm_perlin_vec2 test 2025-01-17 20:22:00 +00:00
Marcin
1377a94a17 glm_perlin_vec2 boilerplate 2025-01-17 20:21:59 +00:00
Marcin
a98c270eee glm_perlin_vec2 impl 2025-01-17 20:21:59 +00:00
Marcin
83b67baa23 glm_perlin_vec3 docs 2025-01-17 16:40:07 +00:00
Marcin
ae82a493f7 note 2025-01-17 16:38:19 +00:00
Marcin
98ab6fcbe0 glm_perlin_vec3 test 2025-01-17 16:38:19 +00:00
Marcin
f0529646b2 glm_perlin_vec3 boilerplate 2025-01-17 16:38:19 +00:00
Marcin
585a999d79 docs 2025-01-17 16:38:19 +00:00
Marcin
5f241a2daf glm_perlin_vec3 impl 2025-01-17 16:38:19 +00:00
Marcin
fbdc46b205 more doc 2025-01-17 16:38:18 +00:00
Marcin
ae1bee7481 doc 2025-01-17 16:38:18 +00:00
Marcin
a0d8803f76 perlin.h -> noise.h 2025-01-15 14:05:08 +00:00
Marcin
43c9f84c8c test_perlin 2025-01-15 13:35:10 +00:00
Marcin
71a0dc6c35 minor reshuffle 2025-01-15 13:35:10 +00:00
Marcin
5d34a04496 refactor gNorm 2025-01-15 13:35:10 +00:00
Marcin
b54dff0124 minor comment 2025-01-15 13:35:10 +00:00
Marcin
fda5406ac0 unnecessary zero init 2025-01-15 13:35:10 +00:00
Marcin
f19dc13e39 missed bracket 2025-01-15 13:35:09 +00:00
Marcin
f3f75a2727 impl but buggy 2025-01-15 13:35:09 +00:00
Marcin
c3e16a53f4 work in progress 2025-01-15 13:35:09 +00:00
Marcin
8a2fd9cda9 docs boilerplate 2025-01-14 17:34:51 +00:00
Marcin
98f53c750d test boilerplate 2025-01-14 17:32:56 +00:00
Marcin
3e52d90ecb boilerplate 2025-01-14 17:32:46 +00:00
Marcin
a4cd7e008d initial impl 2025-01-14 17:31:35 +00:00
Recep Aslantas
5861c37a93 Merge pull request #437 from master30f/readme-restructure
Restructure and rephrase README
2025-01-08 11:28:30 +03:00
zorby
aae82c1d4a README: Add chapter about alignment 2025-01-04 11:51:43 +01:00
zorby
7e51ed88e8 README: Add Features 2025-01-04 11:23:37 +01:00
zorby
32a05a579b README: Move Struct API chapter 2025-01-04 11:22:52 +01:00
Recep Aslantas
9b67866154 Merge pull request #438 from master30f/file-cleanup
Remove .vscode and .gitmodules
2025-01-03 23:42:41 +03:00
zorby
bab7d7bb12 Add .vscode to .gitignore 2025-01-03 17:09:44 +01:00
zorby
5a207d84bb Remove .gitmodules
See issue #436.
2025-01-03 10:43:47 +01:00
zorby
7783acae10 Remove .vscode
See issue #436.
2025-01-03 10:40:17 +01:00
zorby
9d079d3cc3 Restructure README 2024-12-30 13:50:11 +01:00
Recep Aslantas
054b2df004 vscode: disable formatOnSave 2024-12-03 14:27:06 +03:00
Recep Aslantas
93a2926a13 Merge pull request #430 from nitrix/feat/cmake-3.13
Bump CMake minimum version to 3.13
2024-09-10 14:06:45 +03:00
Alex Belanger
5484259328 Undid the formatting. 2024-09-09 10:35:24 -04:00
Alex Belanger
e930737807 Bump CMake minimum version to 3.13 2024-09-09 10:06:09 -04:00
Recep Aslantas
c12f318fab supress fast-math warns 2024-08-27 13:40:34 +03:00
Recep Aslantas
b0f35203f9 suppress warns 2024-08-27 12:32:58 +03:00
Recep Aslantas
ad009d4e49 doc: improve briefs 2024-08-27 12:29:43 +03:00
Recep Aslantas
2f619cdd6f newlines 2024-08-27 12:22:42 +03:00
Recep Aslantas
33e78ca2ad suppress warns about va-args 2024-08-27 12:13:28 +03:00
Recep Aslantas
f82d570dec take -pedantic into account to validate CGLM_USE_ANONYMOUS_STRUCT 2024-08-27 11:58:34 +03:00
Recep Aslantas
48839a38a1 fix refract 2024-07-15 12:41:23 +03:00
Recep Aslantas
d491108386 Merge pull request #423 from waywardmonkeys/reduce-typo-count
Reduce typo count.
2024-07-15 11:29:42 +03:00
Bruce Mitchener
068f6951b3 Reduce typo count. 2024-07-14 09:10:19 +07:00
Recep Aslantas
ed731f991d Merge pull request #421 from myfreeer/patch-1
mat4: wasm simd128 for glm_mat4_inv
2024-07-03 17:06:53 +03:00
myfreeer
07dc9520a4 mat4: wasm simd128 for glm_mat4_inv
The function `glm_mat4_inv_wasm` has been implemented, but not used in `glm_mat4_inv`. This commit adds a conditional macro to add the case of wasm and simd128 case for calling `glm_mat4_inv_wasm`.
2024-07-03 20:04:50 +08:00
Recep Aslantas
be0defb7ac Merge pull request #420 from not-kaz/master
Fixed 'missing-prototypes' warnings for some vec2 funcs.
2024-06-11 14:52:02 +03:00
Kaz
5b2c37f73b Fixed 'missing-prototypes' warnings for some vec2 funcs.
Using gcc and missing-prototypes flag shows warnings for:
glmc_vec2_fill, glmc_vec2_eq and glmc_vec2_eqv. 
Seems they were not added to call/vec2.h for some reason. This should fix the warnings.
2024-06-09 11:06:18 +02:00
Recep Aslantas
a93a9ef9a2 Merge pull request #416 from telephone001/quat_slerp_longest
added quat_slerp_longest
2024-05-13 17:26:49 +03:00
Recep Aslantas
c5b2afc1c4 Update quat.h 2024-05-13 17:20:28 +03:00
John Choi
cd5ed1f4c4 added quat_slerp_longest 2024-05-10 22:32:25 -05:00
Recep Aslantas
eb3a51e591 win: suppress C4996; use snprintf() instead of sprintf() 2024-04-22 21:33:31 +03:00
Recep Aslantas
44cd0ae4fd avx: optimize avx mat4 scale and mat4 mul 2024-04-13 00:33:57 +03:00
Recep Aslantas
d75467f93f avx: implement transpose with AVX 2024-04-13 00:12:14 +03:00
Recep Aslantas
45c1beff51 simd: fix glmm_set1, glmm_splat 2024-04-12 21:53:20 +03:00
Recep Aslantas
14c567d9d9 sse: drop unused macros: glmm_shuff1x, glmm_shuff2 2024-04-11 21:57:46 +03:00
Recep Aslantas
480e1de048 sse: make use of int domain as default behavior if possible ( compiler may ignore it )
also use AVX's `_mm_permute_ps`for shuffling single vector
2024-04-11 21:57:16 +03:00
Recep Aslantas
de66f0a67f glmm, avx: optimize splat macros 2024-04-10 23:49:18 +03:00
Recep Aslantas
68bdec4510 simd: use glmm_set1() to optimize broadcasting single float 2024-04-10 22:52:53 +03:00
Recep Aslantas
62c0448e25 simd, msvc: ensure required definitions are exist on msvc 2024-04-07 22:48:11 +03:00
Recep Aslantas
4f00ce0e52 sse: reduce some instructions in mat4 inv 2024-04-07 22:33:37 +03:00
Recep Aslantas
a7845ffc44 msvc, simd: fix simd headers for _M_ARM64EC 2024-04-07 00:54:29 +03:00
Recep Aslantas
bd941ed7fb arm, neon: fix neon support on GCC ARM 2024-04-06 14:23:36 +03:00
Recep Aslantas
87350f809b msvc bug: dont align types due to "ARM32 = C2719: formal parameter with requested alignment of 16 won't be aligned." on ARM32/MSVC
until a good solution.
2024-04-06 14:11:46 +03:00
Recep Aslantas
f50a7a7d00 arm, neon: improve glm_mat4_inv_neon 2024-04-06 14:10:13 +03:00
Recep Aslantas
b3308af146 arm: fix glmm_vhadd on ARM32 2024-04-06 14:09:52 +03:00
Recep Aslantas
a94f839d6d Merge branch 'master' into optimize-inv 2024-04-04 00:31:08 +03:00
Recep Aslantas
0ff0e8948f Update mat4.h 2024-04-03 00:05:42 +03:00
Recep Aslantas
5b772d0eb4 neon: mat4_inv, reduce 1mul for two extra 2xor 2024-04-03 00:03:55 +03:00
Recep Aslantas
c528ca1095 neon: mat4_inv remastered 2024-04-02 13:21:49 +03:00
Recep Aslantas
f0e09776d7 arm, neon: optimize glmm_vhadd and add glmm_vdot 2024-04-02 02:36:16 +03:00
Recep Aslantas
da4224ba32 now working on v0.9.5 2024-04-02 00:52:54 +03:00
Recep Aslantas
1796cc5ce2 Merge pull request #412 from recp/sse_only
separate SSE and SSE2
2024-04-01 17:52:06 +03:00
Recep Aslantas
568634a79e tests: dont test isinf == true on fast math 2024-04-01 16:48:58 +03:00
Recep Aslantas
c9c7941a72 tests: dont test isnan on fast math 2024-04-01 14:10:38 +03:00
Recep Aslantas
4e929a81c2 Update x86.h 2024-04-01 13:26:08 +03:00
Recep Aslantas
1d09c41e18 make xor enable in SSEonly + fast math 2024-04-01 13:23:52 +03:00
Recep Aslantas
d8e933b5b1 Update test_project.h 2024-04-01 13:23:22 +03:00
Recep Aslantas
8b15fd51ba common way to identify CGLM_FAST_MATH 2024-04-01 13:23:17 +03:00
Recep Aslantas
9ce0a3b625 tests: disable isnan check for min/max which may not work correctly especially in fast-math environment 2024-04-01 13:22:51 +03:00
Recep Aslantas
00d2e8a4cf suppress warnings 2024-04-01 01:46:25 +03:00
Recep Aslantas
35a12ed033 make SSE2-only features not available in SSE 2024-04-01 00:52:59 +03:00
Recep Aslantas
9ad7dd3fbc Merge pull request #409 from EasyIP2023/feature/expand-content-width
docs: expand wy-nav-content width to edge of screen
2024-03-31 23:44:40 +03:00
Recep Aslantas
28142b5912 Merge pull request #411 from EasyIP2023/bugfix/mat4x3-multiplication
mat4x3: fix multiplication functions
2024-03-31 23:44:00 +03:00
Recep Aslantas
f07d75c680 Merge pull request #410 from EasyIP2023/bugfix/mat4x2-multiplication
mat4x2: fix multiplication functions
2024-03-31 23:43:11 +03:00
Recep Aslantas
17d8b83a38 Merge pull request #408 from EasyIP2023/bugfix/mat3x4-multiplication
mat3x4: fix multiplication functions
2024-03-31 23:41:40 +03:00
Recep Aslantas
32a477ef07 separate SSE and SSE2 2024-03-31 23:35:15 +03:00
Recep Aslantas
e3ed9834a1 Update mat2x3.h 2024-03-31 23:06:50 +03:00
Recep Aslantas
8396bbf0b3 coding style 2024-03-31 23:06:30 +03:00
Vincent Davis Jr
013ac5dd07 docs: mat4x3 account for latest mulitplication changes
This also includes tables to explain how
mat4x3, column vectors, and row vectors are
represented. Also includes how resulting
matrix or vector is formed.

Signed-off-by: Vincent Davis Jr <vince@underview.tech>
2024-03-31 14:43:31 -04:00
Vincent Davis Jr
a0e3d3766f mat4x3: fix multiplication functions
Signed-off-by: Vincent Davis Jr <vince@underview.tech>
2024-03-31 14:43:30 -04:00
Vincent Davis Jr
fc7f0e13fd docs: mat3x4 account for latest mulitplication changes
This also includes tables to explain how
mat3x4, column vectors, and row vectors are
represented. Also includes how resulting
matrix or vector is formed.

Signed-off-by: Vincent Davis Jr <vince@underview.tech>
2024-03-31 13:43:41 -04:00
Vincent Davis Jr
1340b5d512 mat3x4: fix multiplication functions
Signed-off-by: Vincent Davis Jr <vince@underview.tech>
2024-03-31 13:43:39 -04:00
Vincent Davis Jr
85165dd3e3 docs: mat4x2 account for latest mulitplication changes
This also includes tables to explain how
mat4x2, column vectors, and row vectors are
represented. Also includes how resulting
matrix or vector is formed.

Signed-off-by: Vincent Davis Jr <vince@underview.tech>
2024-03-31 13:40:43 -04:00
Vincent Davis Jr
3445f93fbc mat4x2: fix multiplication functions
Signed-off-by: Vincent Davis Jr <vince@underview.tech>
2024-03-31 13:40:41 -04:00
Vincent Davis Jr
d2642eb206 docs: expand wy-nav-content width to edge of screen
RTD theme's default is 800px as max width for the content,
but we have tables with tons of columns, which need the
full width of the view-port.

Comment from yocto project theme_overrides.css

Signed-off-by: Vincent Davis Jr <vince@underview.tech>
2024-03-31 12:22:13 -04:00
Recep Aslantas
929963c6eb Merge pull request #407 from EasyIP2023/bugfix/mat3x2-multiplication
mat3x2: fix multiplication functions
2024-03-31 13:40:58 +03:00
Recep Aslantas
25b33fab6b Merge pull request #405 from EasyIP2023/bugfix/mat2x4-mutli
mat2x4: fix multiplication functions
2024-03-31 13:40:45 +03:00
Recep Aslantas
c9adbaabd7 Merge pull request #403 from EasyIP2023/bugfix/mat2x3-multiplication
mat2x3: fix multiplication functions
2024-03-31 13:36:39 +03:00
Recep Aslantas
b22e8230d0 Merge pull request #406 from recp/I_macro
dont use I macro defined in standard
2024-03-31 13:30:42 +03:00
Recep Aslantas
bf4c5b4e26 dont use I macro defined in standard 2024-03-31 13:24:50 +03:00
Vincent Davis Jr
54dfbc5a28 docs: mat2x4 account for latest mulitplication changes
This also includes tables to explain how
mat2x4, column vectors, and row vectors are
represented. Also includes how resulting
matrix or vector is formed.

Signed-off-by: Vincent Davis Jr <vince@underview.tech>
2024-03-31 00:44:58 -04:00
Vincent Davis Jr
088c66029d docs: mat3x2 account for latest mulitplication changes
This also includes tables to explain how
mat3x2, column vectors, and row vectors are
represented. Also includes how resulting
matrix or vector is formed.

Signed-off-by: Vincent Davis Jr <vince@underview.tech>
2024-03-31 00:39:27 -04:00
Vincent Davis Jr
2283c708c6 mat3x2: fix multiplication functions
Signed-off-by: Vincent Davis Jr <vince@underview.tech>
2024-03-31 00:23:39 -04:00
Vincent Davis Jr
46864ba2f7 mat2x4: fix multiplication functions
Signed-off-by: Vincent Davis Jr <vince@underview.tech>
2024-03-30 22:22:34 -04:00
Vincent Davis Jr
c5dcb93c92 docs: mat2x3 account for latest mulitplication changes
This also includes tables to explain how
mat2x3, column vectors and row vectors are
represented. Also includes how resulting
matrix or vector is formed.

Signed-off-by: Vincent Davis Jr <vince@underview.tech>
2024-03-30 22:08:23 -04:00
Vincent Davis Jr
050bc95264 mat2x3: fix multiplication functions
Signed-off-by: Vincent Davis Jr <vince@underview.tech>
2024-03-30 22:08:19 -04:00
Recep Aslantas
f388df7f3e fix typos 2024-03-31 04:40:42 +03:00
Recep Aslantas
4c872238d9 dont use I macro defined in standard 2024-03-31 04:22:42 +03:00
Recep Aslantas
8366e51b47 optimize mat4 scalar inv 2024-03-29 22:13:23 +03:00
Recep Aslantas
30b4ea80a9 optimize mat3 scalar inv 2024-03-29 20:59:54 +03:00
Recep Aslantas
edfb5e3984 docs: alignment 2024-03-29 08:42:07 +03:00
Recep Aslantas
4d43241a69 docs: add note to enable config where may not work is some environments 2024-03-29 08:21:14 +03:00
Recep Aslantas
1337e9cdfb docs: ray sphere docs improvements 2024-03-29 08:10:56 +03:00
Recep Aslantas
9df36ce005 docs: ray sphere docs improvements 2024-03-29 08:05:10 +03:00
Recep Aslantas
55521ecd61 Merge pull request #402 from nitrix/fix/struct-api-ray-at
Struct API glms_ray_at incorrect dir param.
2024-03-29 07:55:28 +03:00
Recep Aslantas
829b7dddce now working on v0.9.4 2024-03-29 07:53:48 +03:00
Alex Belanger
2fced7181a Struct API glms_ray_at incorrect dir param. 2024-03-28 14:22:39 -04:00
Recep Aslantas
1de373a9bd normalize: norm == 0.0f to norm < FLT_EPSILON, improving handling of very small vectors to prevent instability and overflow 2024-03-25 02:22:46 +03:00
Recep Aslantas
6a7d03bafb suppress warnings 2024-03-25 02:17:03 +03:00
Recep Aslantas
aad5223da0 change signature of refraction to let caller know if refraction occurs or not 2024-03-24 06:31:29 +03:00
Recep Aslantas
707bff021c Merge pull request #399 from recp/ray
Some missing ray functions
2024-03-23 11:26:17 +03:00
Recep Aslantas
e4c38ccc4c docs: update ray sphere intersection brief 2024-03-22 23:49:05 +03:00
Recep Aslantas
ceaa54aef8 tests: test for ray, reflect, refract and faceforward 2024-03-22 23:44:43 +03:00
Recep Aslantas
da57558078 docs for new ray functions 2024-03-22 22:30:22 +03:00
Recep Aslantas
6ad0aca7e0 fix refract 2024-03-22 21:59:10 +03:00
Recep Aslantas
96e415daa4 build: add missing file 2024-03-22 10:42:29 +03:00
Recep Aslantas
3701305c9e suppress warnings 2024-03-22 10:36:28 +03:00
Recep Aslantas
2b78f9ab47 refract 2024-03-22 00:18:55 +03:00
Recep Aslantas
41d1a8b9eb faceforward 2024-03-21 02:21:28 +03:00
Recep Aslantas
8ea2fd1cd1 reflect missing stuff 2024-03-21 02:21:07 +03:00
Recep Aslantas
8c81443f24 reflect 2024-03-21 00:18:02 +03:00
Recep Aslantas
608e7d9c2c Update CREDITS 2024-03-20 07:33:43 +03:00
Recep Aslantas
73a4fc76d7 ray: point along a ray at a parameter t 2024-03-20 07:24:07 +03:00
Recep Aslantas
aa45d081fc ray: ray sphere intersection 2024-03-20 07:22:36 +03:00
Recep Aslantas
f1d4aea69b win: add missing files to vsproj 2024-03-20 07:16:17 +03:00
Recep Aslantas
0ef8ebe84e Merge pull request #397 from recp/affine-docs
clarify some rotation rules
2024-03-20 01:05:18 +03:00
Recep Aslantas
8b6eca29cf docs: clarify some rotation rules 2024-03-19 23:55:42 +03:00
Recep Aslantas
0fbad944c5 Merge pull request #398 from waywardmonkeys/make-const-floats
Allow passing `const float*` to `make` functions.
2024-03-18 16:48:02 +03:00
Bruce Mitchener
182c28faf8 Allow passing const float* to make functions. 2024-03-18 19:49:50 +07:00
Recep Aslantas
995fb2e347 clarify some rotation rules 2024-03-16 00:34:11 +03:00
Recep Aslantas
838c5078b7 Merge pull request #395 from recp/ndebug
Ndebug
2024-03-02 11:15:18 +03:00
Recep Aslantas
772238f53f update cmake to respect DEBUG 2024-03-01 12:01:58 +03:00
Recep Aslantas
b9e62b6fe5 use NDEBUG to check DEBUG mode 2024-03-01 12:00:01 +03:00
Recep Aslantas
c9e2b81e99 test: fix ivec2 and ivec3 comparison and suppress warnings 2024-02-24 06:55:45 +03:00
Recep Aslantas
ee18e58815 test: fix ivec2 and ivec3 comparison and suppress warnings 2024-02-24 06:50:07 +03:00
Recep Aslantas
85ee366861 move deprecated glmc_aabb2d_size to right place 2024-02-24 06:33:30 +03:00
Recep Aslantas
0e4201b816 suppress warnings: C4244: 'function': conversion from 'int' to 'float' 2024-02-24 06:10:48 +03:00
Recep Aslantas
b7e4c96738 Merge pull request #392 from duarm/master
aabb2d_zero, aabb2d_diagonal and aabb2d_size
2024-02-24 05:58:49 +03:00
duarm
0d92bfc722 docs and call api for _aabb2d_zero 2024-02-23 14:07:58 -03:00
duarm
237432969d macro for call api too 2024-02-23 14:01:26 -03:00
duarm
131ac68ad3 size -> diag, new sizev 2024-02-23 13:53:25 -03:00
duarm
7e6a463256 call api 2024-02-19 14:38:05 -03:00
duarm
e312f282b4 glm_aabb2d_zero, _size -> _diagonal, new _size 2024-02-19 14:34:30 -03:00
Recep Aslantas
78fb330850 Merge pull request #391 from waywardmonkeys/ci-add-arm64-uwp
ci: Add ARM64 UWP for WindowsStore.
2024-02-12 12:23:31 +03:00
Recep Aslantas
4896b2ea8d Merge pull request #390 from waywardmonkeys/doc-improvements
Doc improvements
2024-02-12 12:21:59 +03:00
Bruce Mitchener
366e0d44e2 ci: Add ARM64 UWP for WindowsStore.
This is one of the core vcpkg targets and I'm trying to enable
the cglm port there to support UWP, so we should have it in the
CI here.
2024-02-12 09:17:56 +07:00
Bruce Mitchener
47a27f9d07 ci / docs: Turn sphinx warnings into errors.
This will help prevent future warnings from sphinx.
2024-02-12 09:01:29 +07:00
Bruce Mitchener
7957179808 docs: Remove duplicate definitions. 2024-02-12 09:00:08 +07:00
Bruce Mitchener
3e79c4d799 docs: Additions and corrections.
* Add missing doc for `glm_vec4_one`.
* mat4: correct links to some functions.
2024-02-12 08:49:50 +07:00
Bruce Mitchener
af5048595f docs: Use .. note:: to display better.
Also, make sure the note content has a blank line after it to
remove a warning from Sphinx.
2024-02-11 23:43:35 +07:00
Bruce Mitchener
270d2b9d05 docs: Add missing aabb2d, fix broken link. 2024-02-11 23:43:35 +07:00
Recep Aslantas
eb9a200b6c Merge pull request #389 from waywardmonkeys/aabb2d-struct-api
aabb2d: Fix struct api.
2024-02-11 19:09:58 +03:00
Bruce Mitchener
fd661d1b43 aabb2d: Fix struct api. 2024-02-11 06:41:39 +07:00
Recep Aslantas
db6f9641ab Merge pull request #387 from waywardmonkeys/remove-narrowing-conversion
glm_ease_back_inout: Use float constant for float var.
2024-02-10 23:49:37 +03:00
Recep Aslantas
125002cfb3 Merge pull request #388 from waywardmonkeys/remove-appveyor
ci: Remove appveyor.
2024-02-10 23:43:25 +03:00
Bruce Mitchener
bb9a35caaf ci: Remove appveyor.
This is now handled by the GitHub Actions CI.
2024-02-10 22:47:33 +07:00
Recep Aslantas
b89315f2c5 Merge pull request #386 from waywardmonkeys/improve-ci
Add additional CI via GitHub Actions.
2024-02-10 17:29:42 +03:00
Bruce Mitchener
e80d163d71 glm_ease_back_inout: Use float constant for float var. 2024-02-10 19:47:38 +07:00
Bruce Mitchener
74c5e86d0c Add additional CI via GitHub Actions. 2024-02-10 14:10:12 +07:00
Recep Aslantas
45134b1265 Merge pull request #384 from waywardmonkeys/fix-more-typos
Fix typos.
2024-02-08 17:18:29 +03:00
Recep Aslantas
b63b2b90b3 Merge pull request #383 from tarhses/structapi-ivec
Implement struct API for ivec2, ivec3, and ivec4
2024-02-08 17:13:03 +03:00
Bruce Mitchener
e4419c4f18 Fix typos. 2024-02-08 15:12:30 +07:00
Pierre Luycx
17f3ea5fab Implement struct API for ivec2, ivec3, and ivec4 2024-02-07 20:53:40 +01:00
Recep Aslantas
a8685ed6ab Merge pull request #381 from vitassuper/vector_improvements
Add new functions for ivec2 and ivec3
2024-01-27 19:33:45 +03:00
Vitaliy Klychkov
029bead207 Update ivec2 and ivec3 documentation 2024-01-27 13:45:27 +00:00
Vitaliy Klychkov
30845124b4 Add additional functions for ivec2 and ivec3 2024-01-27 13:11:04 +00:00
Recep Aslantas
80d5064476 docs: update read the docs package versions 2024-01-15 21:44:48 +03:00
Recep Aslantas
2bd97f6599 Merge pull request #379 from recp/simd_min_max
simd: min / max helpers
2024-01-11 00:21:10 +03:00
Recep Aslantas
6d8dd42ac2 simd: use new glmm_min/max in vec4 where possible 2024-01-11 00:14:28 +03:00
Recep Aslantas
dab86796a4 simd: min / max helpers 2024-01-09 21:35:39 +03:00
Recep Aslantas
4b93cb3e05 Merge pull request #378 from recp/win32_intrin
win32, simd: ensure we are on msvc when checking MSVC specific headers
2024-01-08 00:10:43 +03:00
Recep Aslantas
a682b9e6cf win32, tests: fix drand48() error on mingw 2024-01-04 12:49:45 +03:00
Recep Aslantas
bca93a379d win32, simd: ensure we are on msvc when checking MSVC specific headers 2024-01-04 11:54:42 +03:00
Recep Aslantas
34f0d59f5a now working on v0.9.3 2023-12-31 15:19:36 +03:00
Recep Aslantas
c878161518 Update project.h 2023-12-31 13:49:06 +03:00
Recep Aslantas
3b1d4fc546 struct: add missing glms_project_z() 2023-12-31 13:46:51 +03:00
Recep Aslantas
5be1c2f059 struct: fix glms_rotate_atm signature 2023-12-31 13:21:08 +03:00
Recep Aslantas
67ce1519c5 tests: fix comparing integers in tests 2023-12-30 23:47:58 +03:00
Recep Aslantas
86743c98e5 build: add missing files 2023-12-30 23:35:03 +03:00
Recep Aslantas
015e859075 fix some doc typos & warnings 2023-12-30 23:11:15 +03:00
Recep Aslantas
3a2a26e5a4 Merge pull request #377 from telephone001/euler_to_quat_lh 2023-12-30 21:31:28 +03:00
John Choi
1ccd9af866 added comment about rh vs lh zsin 2023-12-30 12:06:40 -06:00
John Choi
aa20b8ae7f added implementation of euler_to_quat_lh and fixed the tests. Now I gotta decide what to name the macros for controlling lefthand and also make call functions for rh and lh conditionally declared 2023-12-28 11:01:01 -06:00
John Choi
fa6244c42b added tests for euler_to_quat_lh. Currently they don't have any euler->mat4->quat tests because there is no left handed version of those. But I could try to find a way to change it 2023-12-28 10:31:14 -06:00
John Choi
c998d0186a made struct versions of euler to quat. Also fixed up documentation in euler to quat struct. 2023-12-28 09:52:17 -06:00
John Choi
a94861dd5d cleaned up documentation for euler to quat functions and also created the lh file. Made a handed struct file so I remember to do that 2023-12-28 09:21:05 -06:00
Recep Aslantas
040926999a Merge pull request #369 from telephone001/master
euler to quat functions
2023-12-25 10:42:04 +03:00
Recep Aslantas
40cfbe9717 Merge pull request #373 from BeeverFeever/master
ivec += and -= functions
2023-12-25 10:34:10 +03:00
John Choi
d820410435 Merge remote-tracking branch 'refs/remotes/origin/master' 2023-12-24 23:59:34 -06:00
John Choi
39c0c1e784 added handed folder and also made rh tests for the euler->quat functions. Still deciding on what to name the macro for lefthanded stuff 2023-12-24 23:58:29 -06:00
BeeverFeever
4c9b32324d Add tests for ivec -= and += functions 2023-12-25 12:51:33 +11:00
BeeverFeever
921ab6640b Implement -= and += functions for ivecs 2023-12-25 12:51:10 +11:00
BeeverFeever
7701a1a789 Add int min and max functions 2023-12-25 12:50:29 +11:00
telephone001.mdl
46aaf250fa Merge branch 'master' into master 2023-12-14 14:19:22 -06:00
John Choi
42b5e834d1 re-added the euler->mat4->quat tests 2023-12-14 12:00:58 -06:00
John Choi
732a403112 changed last parameter to be destination and also removed the euler->mat4->quat test. 2023-12-13 08:57:10 -06:00
Recep Aslantas
559a6588c8 readthedocs 2023-12-12 13:19:19 +03:00
Recep Aslantas
8277473202 Create .readthedocs.yaml 2023-12-12 13:02:04 +03:00
Recep Aslantas
97575bdcd6 fix glmm_fmsub() on arm-neon: https://github.com/recp/cglm/pull/364 thanks to @gottfriedleibniz 2023-12-12 11:24:25 +03:00
Recep Aslantas
bc2a918ad0 Merge pull request #374 from waywardmonkeys/update-ci-checkout-action
ci: Update to `actions/checkout@v4` from `v3`.
2023-12-11 21:49:09 +03:00
Bruce Mitchener
8ebcc3aceb ci: Update to actions/checkout@v4 from v3. 2023-12-11 22:33:29 +07:00
BeeverFeever
d341478342 testing new ivec* funcs 2023-12-11 20:18:18 +11:00
John Choi
7e4383cb3d found out I was using glm_euler_xyz_quat in some testers that tests other types. I thought I changed it yesterday. Also there is still a problem with quaternion axis multiplication vs euler to mat4 to quat 2023-12-10 11:46:50 -06:00
Recep Aslantas
b45657f673 Update tests.h 2023-12-10 20:39:52 +03:00
telephone001.mdl
e24675c6e0 Merge branch 'recp:master' into master 2023-12-10 11:38:51 -06:00
Recep Aslantas
2e6e4a9a44 Merge branch 'master' of https://github.com/recp/cglm 2023-12-10 20:30:52 +03:00
Recep Aslantas
4f88a027bc Merge pull request #364 from BeeverFeever/master
New subtraction family of vector functions
2023-12-10 20:29:19 +03:00
Recep Aslantas
673263265b fix glmm_fmsub() on arm-neon 2023-12-10 20:28:39 +03:00
Recep Aslantas
dd9235dfee fix glmm_fmsub() on arm-neon 2023-12-10 17:13:11 +03:00
BeeverFeever
4c4a69ddfe Should be all 2023-12-11 01:08:10 +11:00
John Choi
d6139559b6 Merge remote-tracking branch 'refs/remotes/origin/master' 2023-12-10 01:19:12 -06:00
John Choi
2eb9a67a3a fixed up the code to fit with the style, Also found out that I was calculating my quaternion rotations the opposite way (zyx order instead of xyz order) 2023-12-10 01:16:09 -06:00
Recep Aslantas
8a1d1cf35d fix glmm_fmsub() on arm-neon 2023-12-10 10:06:36 +03:00
telephone001.mdl
fee2b7d344 Merge branch 'recp:master' into master 2023-12-09 23:41:25 -06:00
BeeverFeever
865faad116 Fix simd versions 2023-12-10 15:49:59 +11:00
Recep Aslantas
7ccf199066 Merge pull request #372 from EasyIP2023/bugfix/docs-non-square
docs: 2/2 fixes https://github.com/recp/cglm/issues/371
2023-12-09 23:08:29 +03:00
Vincent Davis Jr
047138321c docs: 2/2 fixes https://github.com/recp/cglm/issues/371
Second commit for fixing non-square matrix
multiplication docs.

Signed-off-by: Vincent Davis Jr <vince@underview.tech>
2023-12-09 14:28:57 -05:00
Recep Aslantas
75b99ef87d fixes: https://github.com/recp/cglm/issues/371 2023-12-09 21:28:53 +03:00
John Choi
036fd4848b moved all my stuff to euler because it fits there better. Also, had to move my tests into a single euler test because it wouldn't work outside that one test. Maybe later I will create test_euler.h like how test_quat.h works 2023-12-09 00:38:38 -06:00
John Choi
666d692dfb fixed the bug with the tester. Its weird that the broken tester worked on my computer 2023-12-08 23:06:36 -06:00
John Choi
ec3796973e finished but trying to figure out why its not running in wasm 2023-12-08 14:15:49 -06:00
telephone001.mdl
45f2fff22f Merge branch 'recp:master' into master 2023-12-08 13:09:24 -06:00
John Choi
4ee6aea037 made quat struct and also exported it 2023-12-08 13:05:53 -06:00
John Choi
2f7dbad6a8 finally done with tests and all euler to quaternion functions 2023-12-08 12:19:09 -06:00
Recep Aslantas
5ae0cd4618 Merge pull request #367 from v1993/struct-clipspace-fixes
Fix struct clipspace headers
2023-12-08 15:12:12 +03:00
Valeri Ochinski
23d03ffe6c Fix struct clipspace headers
Add missing includes, fix signatures
2023-12-08 10:14:43 +03:00
John Choi
c5694c5c17 made all the functions. I have miscalculated some stuff and am currently trying to test them. I have created all the testing functions as well 2023-12-08 00:26:33 -06:00
John Choi
d67ac97323 got the euler to quat xyz working and got the tests to pass 2023-12-07 12:21:55 -06:00
John Choi
05ea35ffec made euler to quat xyz. Now I'm trying to test if it works or not 2023-12-07 10:29:07 -06:00
Recep Aslantas
05d45872a3 Merge pull request #355 from duarm/aabb2d
aabb2d
2023-12-06 22:58:31 +03:00
duarm
c431bbf190 fix procedure comment on transform 2023-12-06 16:54:46 -03:00
duarm
340292c0fb fix transform 2023-12-06 16:52:55 -03:00
duarm
2106f9ebcb remove _aabb2d_frustum 2023-12-06 16:48:48 -03:00
duarm
c1d78d835b changing from mat4 to mat3 2023-12-06 16:34:18 -03:00
duarm
de80b8325f Merge branch 'master' into aabb2d 2023-12-06 16:14:00 -03:00
duarm
7061df0066 circle docs fixup 2023-12-06 16:14:59 -03:00
duarm
eb73e4123b docs fix 2023-12-06 16:13:08 -03:00
BeeverFeever
22140d8e1b Fix test 2023-12-05 19:48:54 +11:00
BeeverFeever
39602ef4d7 Fix vec4 functions 2023-12-05 18:49:10 +11:00
Recep Aslantas
abb71a8e32 fixes: https://github.com/recp/cglm/pull/360#issuecomment-1838122934 2023-12-05 10:31:46 +03:00
BeeverFeever
f8b6573de8 Write tests for new functions 2023-12-04 23:28:56 +11:00
BeeverFeever
15f29e05eb Fixed missed function 2023-12-04 23:28:29 +11:00
BeeverFeever
7696374f1e Vector subtraction functions
Add subtraction family of functions for vectors.
2023-12-04 21:32:19 +11:00
duarm
44d103fa00 typos 2023-12-03 02:36:04 -03:00
duarm
c29f077bed Merge branch 'master' into aabb2d 2023-12-02 21:02:20 -03:00
duarm
2a975a7d0a circle fix, new copy func 2023-12-02 21:00:21 -03:00
Recep Aslantas
049db64a0f Merge pull request #360 from v1993/meson-header-only-subproject
meson: don't build by default if used in a subproject
2023-12-02 15:49:24 +03:00
Recep Aslantas
e71694bb57 Merge branch 'master' into meson-header-only-subproject 2023-12-02 15:48:54 +03:00
Recep Aslantas
8754158fbe Merge pull request #362 from myfreeer/patch-1
ci: initial support of meson and emscripten
2023-12-02 11:13:20 +03:00
Recep Aslantas
e1a0892097 Merge branch 'master' into patch-1 2023-12-02 11:12:43 +03:00
Recep Aslantas
9b26aff466 Merge pull request #361 from myfreeer/myfreeer-patch-4
wasm: prefer pmin/pmax
2023-12-02 11:12:15 +03:00
myfreeer
24e417107b ci: initial support of meson and emscripten
It seems that meson only supports emscripten as a compiler to wasm at present, wasi-sdk support is not completed yet, so this only adds ci build scripts for emscripten.

References:
* <f41bdae368>
* <https://github.com/mesonbuild/meson/pull/11862>
2023-12-02 11:08:33 +08:00
myfreeer
009405adcd wasm: prefer pmin/pmax
According to [emscripten](https://emscripten.org/docs/porting/simd.html) and [v8](b6520eda5e/src/compiler/backend/x64/code-generator-x64.cc (L2661-L2699)), `[f32x4|f64x2].[min|max]` compiles to much more instructions than `[f32x4|f64x2].[pmin|pmax]`.
It is defined in [spec](https://github.com/WebAssembly/spec/blob/main/proposals/simd/SIMD.md#floating-point-min-and-max) that the difference between pmin/pmax and min/max is NaN-propagating behavior, and the equivalent to the x86 `_mm_min_ps`/`_mm_max_ps` is pmin/pmax in [v8](b6520eda5e/src/compiler/backend/x64/code-generator-x64.cc (L2740-L2747)).
This should make functions with min/max faster on webassembly, and align with the existing behavior with x86 sse.
2023-12-02 09:54:49 +08:00
Valeri
0b2006dd47 meson: don't build by default if used in a subproject 2023-12-02 01:44:54 +03:00
Recep Aslantas
1fdc1c8675 struct: remove _vec_inv from struct function lists 2023-12-01 11:18:48 +03:00
Recep Aslantas
6e1d6d505b Merge pull request #357 from v1993/vs-fix
Use the appropriate version of alignof
2023-12-01 11:11:11 +03:00
Valeri
45cf4710c4 Use the appropriate version of alignof 2023-12-01 04:19:47 +03:00
duarm
056b28e4da Merge branch 'master' into aabb2d 2023-11-19 10:00:00 -03:00
Recep Aslantas
c6e58bd44a Update vec4-ext.h 2023-11-16 13:06:51 +03:00
Recep Aslantas
a81c0f076a Merge pull request #356 from havrik/patch-1
Fix definition logic misspell in 'glm_quat_normalize_to' -> cglm/quat.h
2023-11-16 13:05:42 +03:00
havrik
ab684b7c66 Fix definition logic misspell in 'glm_quat_normalize_to' -> cglm/quat.h 2023-11-16 11:38:47 +03:00
duarm
53bde05bd9 aabb2d functions 2023-11-11 08:13:28 -03:00
Recep Aslantas
58a4b47830 Merge pull request #354 from One234Fi/revise_troubleshooting_page
Fix spelling and grammar on troubleshooting page
2023-11-09 10:44:06 +03:00
One234Fi
1bfa53f44c spelling and grammar revision 2023-11-08 16:41:07 -06:00
Recep Aslantas
d93b46bab7 Merge pull request #350 from duarm/vec2_center
adding glm_vec2_center
2023-10-15 00:17:47 +03:00
duarm
9efc255451 struct api 2023-10-14 14:24:25 -03:00
duarm
9484155c98 adding vec2_center 2023-10-11 16:51:14 -03:00
Recep Aslantas
509078817c fix glm_ivec2|3_fill and glm_ivec2|3_eq params continue 2023-09-05 20:41:55 +03:00
Recep Aslantas
126f809dae fix glm_ivec2|3_fill and glm_ivec2|3_eq params 2023-09-05 20:19:33 +03:00
Recep Aslantas
e0e7e380e5 Merge pull request #346 from duarm/master
eqv, eq, fill for ivec2 and ivec3, documentation fixes
2023-09-05 09:34:28 +03:00
duarm
d3169b12a7 missing call functions from vec2 2023-09-04 20:14:59 -03:00
duarm
9d0c9fdb87 adding ivec2, ivec3, ivec4 prints, eqv, eq and fill, documentation fixes 2023-09-04 20:07:37 -03:00
Recep Aslantas
f496146bce Merge pull request #345 from telephone001/ins3_bugfix
Fixed glms_mat4_ins3 bug.
2023-08-30 13:03:16 +03:00
LAPTOP-GHFRJ92J\John
54632ecce5 mat4_ins3 should copy mat3s to upper left mat4s. Previously, it just made a new mat4s r and put the mat3 into that and returned it. Now it takes in a mat4s and copies the mat3s to that. 2023-08-29 02:13:24 -05:00
Recep Aslantas
61478d2563 now working on v0.9.2 2023-08-10 09:20:39 +03:00
Recep Aslantas
cdd4d0e83e Merge pull request #340 from recp/non-square-matrix
add some missing non-square matrix funcs
2023-08-07 17:58:05 +03:00
Recep Aslantas
54dfc4b4f0 Merge branch 'master' into non-square-matrix 2023-08-07 15:37:44 +03:00
Recep Aslantas
f6cb3ba31a Merge pull request #343 from EasyIP2023/non-square-matrix
add docs and tests to non-square-matrix branch
2023-08-07 14:41:08 +03:00
Vincent Davis Jr
da51741c50 test: add missing mat4x3 tests
Signed-off-by: Vincent Davis Jr <vince@underview.tech>
2023-08-06 14:12:46 -04:00
Vincent Davis Jr
a5d8e61c2b test: add missing mat4x2 tests
Signed-off-by: Vincent Davis Jr <vince@underview.tech>
2023-08-06 14:12:26 -04:00
Vincent Davis Jr
f0f7b67ef4 test: add missing mat3x4 tests
Signed-off-by: Vincent Davis Jr <vince@underview.tech>
2023-08-06 14:12:26 -04:00
Vincent Davis Jr
eece0b7bc9 test: add missing mat3x2 tests
Signed-off-by: Vincent Davis Jr <vince@underview.tech>
2023-08-06 14:12:26 -04:00
Vincent Davis Jr
37d20f7da8 test: add missing mat2x4 tests
Signed-off-by: Vincent Davis Jr <vince@underview.tech>
2023-08-06 14:12:26 -04:00
Vincent Davis Jr
006e4ffbdf test: add missing mat2x3 tests
Signed-off-by: Vincent Davis Jr <vince@underview.tech>
2023-08-06 14:12:26 -04:00
Vincent Davis Jr
aa37c1aa74 fix array subscript is outside array bounds
warning: array subscript # is outside array bounds
of ‘float[#]’ [-Warray-bounds]

Commit also fixes variable order when calculating
multiplication between two matrices.

Signed-off-by: Vincent Davis Jr <vince@underview.tech>
2023-08-06 14:12:24 -04:00
Vincent Davis Jr
0fb9e73ec1 docs: add missing non-square matrix funcs
Functions include:
	* glm_mat#x#_copy
	* glm_mat#x#_zero
	* glm_mat#x#_mul
	* glm_mat#x#_mulv
	* glm_mat#x#_transpose
	* glm_mat#x#_scale

Commit also includes some minor changes to
	* mat2
	* mat3
	* mat4

Signed-off-by: Vincent Davis Jr <vince@underview.tech>
2023-08-05 20:54:24 -04:00
Recep Aslantas
129287b809 Merge pull request #341 from taisei-project/assume-aligned-detection
more robust __builtin_assume_aligned detection
2023-08-01 18:22:24 +03:00
Andrei Alexeyev
2724620d83 more robust __builtin_assume_aligned detection
__builtin_assume_aligned is available since GCC 4.7, but __has_builtin
was added much later. Check for the GCC version if __has_builtin is not
available.

Users can also define CGLM_HAVE_BUILTIN_ASSUME_ALIGNED to either 1 or 0
to explicitly enable/disable the use of __builtin_assume_aligned. Meson
will do it automatically (by performing a configure-time test).
2023-07-31 22:33:51 +02:00
Recep Aslantas
4d5653b1f6 add some missing non-square matrix funcs in struct api 2023-07-22 14:17:26 +03:00
Recep Aslantas
dbb85f24c8 add some missing non-square matrix funcs 2023-07-22 13:37:36 +03:00
Recep Aslantas
6e9e91be05 add _mul for non-square matrices 2023-07-22 12:00:23 +03:00
Recep Aslantas
1e077fd125 add some missing non-square matrix funcs 2023-07-22 01:21:14 +03:00
Recep Aslantas
cb4a1b2677 Merge pull request #338 from EasyIP2023/feature/mat4x3
add new matrix mat4x3
2023-07-18 09:09:00 +03:00
Recep Aslantas
924db3307e Merge pull request #339 from EasyIP2023/bug/fix-mat4x2s
types-struct: fix mat4x2s struct members
2023-07-18 09:07:41 +03:00
Vincent Davis Jr
e9df003e56 types-struct: fix mat4x2s struct members
union mat4x2s { struct {  } } contains
members with incorrect naming.

Signed-off-by: Vincent Davis Jr <vince@underview.tech>
2023-07-17 23:09:40 -04:00
Vincent Davis Jr
3d292c3a2e add new matrix mat4x3
Initial function being

glm_mat4x3_make

Signed-off-by: Vincent Davis Jr <vince@underview.tech>
2023-07-17 22:57:52 -04:00
Recep Aslantas
4bb7e778c4 Merge pull request #337 from EasyIP2023/feature/mat4x2
add new matrix mat4x2
2023-07-17 10:41:09 +03:00
Vincent Davis Jr
2df26c0ecf add new matrix mat4x2
Initial function being

glm_mat4x2_make

Signed-off-by: Vincent Davis Jr <vince@underview.tech>
2023-07-16 20:19:25 -04:00
Recep Aslantas
5193b50133 Merge pull request #334 from EasyIP2023/feature/mat3x4
add new matrix mat3x4
2023-07-16 23:32:05 +03:00
Recep Aslantas
ef8954ccbc Merge branch 'master' into feature/mat3x4 2023-07-16 23:31:33 +03:00
Recep Aslantas
91b40eb7eb Merge pull request #335 from EasyIP2023/fix/comments-docs
docs: fix mat#x# comments and documentation
2023-07-16 23:29:38 +03:00
Vincent Davis Jr
82892085b3 docs: fix mat#x# comments and documentation
Signed-off-by: Vincent Davis Jr <vince@underview.tech>
2023-07-16 15:46:35 -04:00
Vincent Davis Jr
e09cf11f1c add new matrix mat3x4
Initial function being

glm_mat3x4_make

Signed-off-by: Vincent Davis Jr <vince@underview.tech>
2023-07-16 15:41:36 -04:00
Recep Aslantas
8966f296ac Merge pull request #333 from EasyIP2023/feature/mat3x2
add new matrix mat3x2
2023-07-16 12:10:45 +03:00
Vincent Davis Jr
4e44e74d48 add new matrix mat3x2
Initial function being

glm_mat3x2_make

Signed-off-by: Vincent Davis Jr <vince@underview.tech>
2023-07-15 18:48:50 -04:00
Recep Aslantas
f817c4cbb0 Merge pull request #332 from EasyIP2023/fix/mat2x3
add missing mat2x# test and mat2x3 window headers
2023-07-15 23:55:19 +03:00
Vincent Davis Jr
dd6a0b3175 add missing mat2x# test and mat2x3 window headers
Missing tests where
	* MACRO_GLM_MAT2X3_ZERO_INIT
	* MACRO_GLM_MAT2X3_ZERO
	* mat2x3s_zero_init
	* mat2x3s_zero
	* mat2x4s_zero_init
	* mat2x4s_zero

Commit:
	* removes (mat2x3) from
	  ((mat2x3)GLM_MAT2X3_ZERO_INIT) to fix
	  error: array initialized from non-constant array expression
	* removes test_assert_mat2x3_eq_zero
	  from test/src/test_struct.c
	* adds TEST_IMPL(mat2x3s_zero) to
	  test/src/test_struct.c

Signed-off-by: Vincent Davis Jr <vince@underview.tech>
2023-07-15 16:16:03 -04:00
Recep Aslantas
1401af4c34 Merge pull request #331 from EasyIP2023/feature/mat2x4
add new matrix mat2x4
2023-07-15 22:33:54 +03:00
Vincent Davis Jr
fe7471e8f8 add new matrix mat2x4
Initial function being

glm_mat2x4_make

Signed-off-by: Vincent Davis Jr <vince@underview.tech>
2023-07-15 14:32:48 -04:00
Recep Aslantas
1ca261b118 Merge pull request #330 from EasyIP2023/feature/mat2x3
add new matrix mat2x3
2023-07-15 11:03:59 +03:00
Vincent Davis Jr
6317ed90e7 add new matrix mat2x3
Initial function being

glm_mat2x3_make

Signed-off-by: Vincent Davis Jr <vince@underview.tech>
2023-07-14 18:57:45 -04:00
Recep Aslantas
3b683cf28c Merge pull request #328 from recp/werror
drop "-Werror" to allow skip warnings on production build
2023-07-13 11:09:16 +03:00
Recep Aslantas
d6267e623b drop "-Werror" to allow skip warnings on production build 2023-07-08 23:16:15 +03:00
Recep Aslantas
93cdc897a5 suppress warinngs 2023-07-08 23:13:20 +03:00
Recep Aslantas
0962f7d2e7 fix param name in inline doc 2023-07-08 12:19:22 +03:00
Recep Aslantas
487b18e326 Merge pull request #324 from EasyIP2023/feature/glm_vec2_make
vec2: add new function glm_vec2_make
2023-07-02 22:04:44 +03:00
Recep Aslantas
8e2074c274 Merge branch 'master' into feature/glm_vec2_make 2023-07-02 22:03:40 +03:00
Recep Aslantas
0ab1f21816 Merge pull request #326 from EasyIP2023/feature/glm_vec4_make
vec4: add new function glm_vec4_make
2023-07-02 22:02:18 +03:00
Recep Aslantas
b8d565c6b6 Merge branch 'master' into feature/glm_vec4_make 2023-07-02 22:02:10 +03:00
Recep Aslantas
c5c997ca13 Merge pull request #325 from EasyIP2023/feature/glm_vec3_make
vec3: add new function glm_vec3_make
2023-07-02 22:01:51 +03:00
Recep Aslantas
924d92ae3f Merge branch 'master' into feature/glm_vec3_make 2023-07-02 22:01:43 +03:00
Recep Aslantas
d673f3d765 Merge pull request #323 from EasyIP2023/feture/update-test_quat-glm_quat_make
test_quat: add more robust quat_make test
2023-07-02 22:00:28 +03:00
Vincent Davis Jr
5833d1bf44 vec4: add new function glm_vec4_make
Function takes in a float array. Array must be
at least of size 4 and converts it into
a 4D vector.

Signed-off-by: Vincent Davis Jr <vince@underview.tech>
2023-07-02 13:54:10 -05:00
Vincent Davis Jr
aeeeac4c5a vec3: add new function glm_vec3_make
Function takes in a float array. Array must be
at least of size 3 and converts it into
a 3D vector.

Signed-off-by: Vincent Davis Jr <vince@underview.tech>
2023-07-02 13:25:25 -05:00
Vincent Davis Jr
b3de85a14e vec2: add new function glm_vec2_make
Just a copy of glm_vec2, but with the
word _make suffixed at the end.

Function takes in a float array array must be
at least of size 2 and converts it into
a 2D vector.

Signed-off-by: Vincent Davis Jr <vince@underview.tech>
2023-07-02 12:41:23 -05:00
Vincent Davis Jr
5e798a94e3 test_quat: add more robust quat_make test
Makes it so that it's easier to identify
the potential usecase of function. Commit also
includes a fix to the struct/quat.h glms_quat_make
comment. Should be returning versors it's not
a void function.

Signed-off-by: Vincent Davis Jr <vince@underview.tech>
2023-07-02 12:37:28 -05:00
Recep Aslantas
49dd24eaf2 Merge pull request #321 from EasyIP2023/feature/glm_quat
quat: add new function glm_quat_make
2023-06-30 06:05:13 +03:00
Vincent Davis Jr
bfe5ea6ab7 quat: add new function glm_quat_make
Function takes in a 4 element float array
and converts it into a quaternion.

Signed-off-by: Vincent Davis Jr <vince@underview.tech>
2023-06-28 22:49:49 -05:00
Recep Aslantas
6d39ef0026 Merge pull request #319 from FrostKiwi/master
Small comment fixes
2023-06-16 12:46:42 +03:00
Wladislav ヴラド Artsimovich
87ae96b847 Fix Singular / Plural in comments 2023-06-16 17:40:06 +09:00
Wladislav ヴラド Artsimovich
9cf4190c9b Fix comments of vec2 explaining vec3 math 2023-06-16 17:26:30 +09:00
Recep Aslantas
2bbaeb8db9 Merge pull request #317 from FrostKiwi/master
Implement missing 3D Affine Transforms in the Struct API
2023-06-15 16:07:08 +03:00
Wladislav ヴラド Artsimovich
a7cda7f969 Add new header to Visual Studio as well 2023-06-15 22:02:21 +09:00
Wladislav ヴラド Artsimovich
c4d4c48518 Add affine-mat.h to the Makefile 2023-06-15 21:54:54 +09:00
Wladislav ヴラド Artsimovich
702bed8173 Implement missing Struct API 3D Affine Transforms 2023-06-15 18:18:52 +09:00
Wladislav ヴラド Artsimovich
e9aa249a73 Add forgotten function listing in comment 2023-06-15 17:42:06 +09:00
Recep Aslantas
adec2ee8e6 Update box.h 2023-06-15 10:16:06 +03:00
Recep Aslantas
5cd16194c8 Merge pull request #313 from myfreeer/master
ci: update mymindstorm/setup-emsdk to v12
2023-06-14 17:38:10 +03:00
myfreeer
02b9dc067a ci: update mymindstorm/setup-emsdk to v12
Github is using node16 by default for actions, so it might worth to update this to latest version supporting node16 by default.

See also:
* <https://github.com/mymindstorm/setup-emsdk/issues/28>
* <https://github.blog/changelog/2022-09-22-github-actions-all-actions-will-begin-running-on-node16-instead-of-node12/>
* <https://github.blog/changelog/2023-06-13-github-actions-all-actions-will-run-on-node16-instead-of-node12-by-default>
2023-06-14 19:52:13 +08:00
Recep Aslantas
a447365bc5 Merge pull request #311 from recp/suppress-sign-conversion
suppress sign conversion warnings
2023-06-12 14:55:47 +03:00
Recep Aslantas
6183b213e2 suppress sign conversion warnings 2023-06-12 13:56:49 +03:00
Recep Aslantas
768d36f4b6 suppress some warnings on tests 2023-06-12 13:15:47 +03:00
Recep Aslantas
2c39193016 Merge pull request #309 from recp/anonymous-structs-check
Add Enhanced Support for Anonymous Structs
2023-06-10 20:40:26 +03:00
Recep Aslantas
16fcaf7fc0 Update types-struct.h 2023-06-08 06:28:40 +03:00
Recep Aslantas
530ec2d0f8 reduce glms_mat[4|3|2]_make()'s dest parameter
the return value is the dest.
2023-05-16 14:26:11 +03:00
Recep Aslantas
56d9e41465 Merge pull request #303 from EasyIP2023/bug/test-runner
io: fix test runner.c implicit declaration glm_arch_print
2023-05-15 21:33:05 +03:00
Recep Aslantas
610788bed1 Merge branch 'master' into bug/test-runner 2023-05-15 21:32:51 +03:00
Vincent Davis Jr
2d6538ecec io: fix test runner.c implicit declaration glm_arch_print
Problem:

../test/runner.c:29:3: error: implicit declaration of function
‘glm_arch_print’ [-Werror=implicit-function-declaration]
   29 |   glm_arch_print(stderr);
      |   ^~~~~~~~~~~~~~
      |   glm_vec2_print

glm_arch_print is not available unless you add the DEBUG macro.

Signed-off-by: Vincent Davis Jr <vince@underview.tech>
2023-05-15 11:30:13 -05:00
Recep Aslantas
0de379c632 Merge pull request #300 from EasyIP2023/feature/update-readme-meson-build
README: update meson option for running test
2023-05-15 14:57:09 +03:00
Recep Aslantas
31cbd41e3b Merge pull request #302 from EasyIP2023/feature/glm_mat3_make
mat3: add new function glm_mat3_make
2023-05-15 11:18:41 +03:00
Recep Aslantas
c691bc5bc0 Merge pull request #301 from EasyIP2023/feature/glm_mat2_make
mat2: add new function glm_mat2_make
2023-05-15 11:18:27 +03:00
Recep Aslantas
7346e91574 Merge pull request #299 from EasyIP2023/feature/glm_mat4_make
mat4: add new function glm_mat4_make
2023-05-15 11:15:34 +03:00
Vincent Davis Jr
0566a040c0 mat3: add new function glm_mat3_make
Function takes in a 9 element float array
and converts it into a mat3 matrix.

Signed-off-by: Vincent Davis Jr <vince@underview.tech>
2023-05-14 20:56:25 -05:00
Vincent Davis Jr
e6681e78c8 mat2: add new function glm_mat2_make
Function takes in a 4 element float array
and converts it into a mat2 matrix.

Signed-off-by: Vincent Davis Jr <vince@underview.tech>
2023-05-14 20:30:36 -05:00
Vincent Davis Jr
e17f115f91 mat4: add new function glm_mat4_make
Function takes in a 16 element float array
and converts it into a mat4 matrix.

Signed-off-by: Vincent Davis Jr <vince@underview.tech>
2023-05-14 20:10:48 -05:00
Vincent Davis Jr
2631d3b5ea README: update meson option for running test
Running on an already built build directory

meson configure -Denable_tests=true build/

Leads to

ERROR: Unknown options: "enable_tests"

Seems the meson option was updated

Signed-off-by: Vincent Davis Jr <vince@underview.tech>
2023-05-14 19:38:58 -05:00
Recep Aslantas
9772948831 improve printing arch name in tests 2023-05-06 16:28:52 +03:00
Recep Aslantas
988dd13d61 make GLM_TESTS_NO_COLORFUL_OUTPUT work on non-test print colors too 2023-05-06 15:36:41 +03:00
Recep Aslantas
ed09fb5819 fix glm_arch_print_name and print it on tests 2023-05-06 14:58:45 +03:00
Recep Aslantas
c4a348ac71 now working on v0.9.1 2023-05-02 08:22:18 +03:00
Recep Aslantas
7e9d2aa6a4 Merge pull request #295 from myfreeer/patch-1
README: add build docs for WebAssembly
2023-05-02 08:19:25 +03:00
myfreeer
091102e2c1 README: add build docs for WebAssembly
See alse https://github.com/recp/cglm/discussions/282#discussioncomment-5770919
2023-05-02 13:07:59 +08:00
Recep Aslantas
50b1c189b1 update docs 2023-05-01 23:03:19 +03:00
Recep Aslantas
44268d24f9 Merge pull request #293 from recp/fix-simd-signmask
Fix simd signmask
2023-04-22 23:53:50 +03:00
Recep Aslantas
65fd77d255 Merge branch 'master' into fix-simd-signmask 2023-04-22 23:53:20 +03:00
Recep Aslantas
5883ed3495 Merge pull request #292 from myfreeer/fix-simd-signmask-wasm
wasm: replace usage of -0.f to 0x80000000
2023-04-22 10:11:46 +03:00
Recep Aslantas
e2e923554b Merge pull request #291 from recp/fix-simd-signmask
simd, sse: use 0x80000000 insteaf of -0.f to fix fastmath on msvc
2023-04-22 10:11:17 +03:00
myfreeer
6b2c91ecf7 wasm: replace usage of -0.f to 0x80000000
Part of https://github.com/recp/cglm/pull/291
2023-04-22 10:50:54 +08:00
Recep Aslantas
a4b8778be9 fixes for "simd, sse: use 0x80000000 insteaf of -0.f to fix fastmath on msvc" 2023-04-21 22:42:04 +03:00
Recep Aslantas
5ce7dff812 Merge remote-tracking branch 'origin/master' into fix-simd-signmask 2023-04-21 22:31:55 +03:00
Recep Aslantas
13036036c4 fix existing tests build 2023-04-21 22:29:55 +03:00
Recep Aslantas
c1ff76d3b1 fix existing tests build 2023-04-21 22:15:04 +03:00
Recep Aslantas
17b3911e7c fix struct api calls 2023-04-21 21:20:11 +03:00
Recep Aslantas
7307b1cbbe simd, sse: use 0x80000000 insteaf of -0.f to fix fastmath on msvc 2023-04-21 20:36:50 +03:00
Recep Aslantas
391d8670c2 simd, sse: use 0x80000000 insteaf of -0.f to fix fastmath on msvc 2023-04-21 20:14:58 +03:00
Recep Aslantas
8d441902c0 fix struct api calls 2023-04-21 20:07:14 +03:00
Recep Aslantas
490d0bb9a1 Merge pull request #290 from recp/structapi-conf
struct: provide option to omit struct api namespace e.g. `glms_` and …
2023-04-21 17:38:22 +03:00
Recep Aslantas
4c6fb156ef Merge pull request #286 from myfreeer/master
WIP: Wasm simd128 support
2023-04-21 16:49:51 +03:00
myfreeer
81b7c90271 simd128: simplify calls 2023-04-15 22:06:04 +08:00
Recep Aslantas
c221f8883a struct: provide option to omit struct api namespace e.g. glms_ and an … 2023-04-09 17:20:38 +03:00
Recep Aslantas
ea8ef4a3c9 struct: provide option to omit struct api namespace e.g. glms_ and an option to add s suffix e.g. mat4s_mul if preferred 2023-04-09 14:28:05 +03:00
myfreeer
765771227a io: add case of wasm simd128 2023-04-08 18:28:49 +08:00
myfreeer
1940f1d4bc wasm: build with emsdk on github actions 2023-04-08 15:21:29 +08:00
myfreeer
061f096d8f wasm: add --no-verbose to wget 2023-04-08 14:12:23 +08:00
myfreeer
884be84506 wasm: fix clang path for github actions 2023-04-08 14:07:00 +08:00
myfreeer
18ed15c53a wasm: init github action ci 2023-04-08 14:05:01 +08:00
myfreeer
2614a1805d Merge remote-tracking branch 'upstream/master' 2023-04-08 13:41:53 +08:00
myfreeer
d7c0edcbd9 simd128: minor lint 2023-04-08 13:40:46 +08:00
Recep Aslantas
0b3049dca0 utility to print selected simd path (docs) 2023-04-08 01:03:31 +03:00
Recep Aslantas
a542d54fca utility to print selected simd path 2023-04-08 00:59:06 +03:00
Recep Aslantas
1d51459a4f Merge pull request #287 from krishna2803/patch-1
Updated parameter name (d -> dest)
2023-04-02 14:00:14 +03:00
krishna2803
6e35d927eb Updated parameter name (d -> dest) 2023-04-02 16:20:45 +05:30
myfreeer
07bc4be18b simd128: cmake options
After this, the required options for cmake are listed below:
```
-DCMAKE_C_FLAGS="-msimd128"
-DCMAKE_TOOLCHAIN_FILE=/path/to/wasi-sdk-19.0/share/cmake/wasi-sdk.cmake
-DWASI_SDK_PREFIX=/path/to/wasi-sdk-19.0
-DCGLM_USE_TEST=ON
```
If compiling to wasi with simd128 support, `-DCMAKE_C_FLAGS="-msimd128"` can be removed.
If tests are not needed, `-DCGLM_USE_TEST=ON` can be removed.
2023-04-02 13:09:00 +08:00
myfreeer
3a9e4df393 simd128: handle both sse2 and simd128 enabled by Emscripten
https://github.com/recp/cglm/pull/286#issuecomment-1492985403
2023-04-02 12:39:20 +08:00
myfreeer
7ca9a64ecf simd128: code style 2023-04-01 19:38:57 +08:00
myfreeer
51ce4db82e simd128: code style 2023-04-01 19:38:28 +08:00
myfreeer
73adfe08c0 simd128: inline _mm_cvtss_f32 2023-04-01 19:34:19 +08:00
myfreeer
48d6ab79bd simd128: inline _mm_movehl_ps 2023-04-01 19:28:45 +08:00
myfreeer
e40b477929 simd128: inline _mm_movelh_ps 2023-04-01 19:19:49 +08:00
myfreeer
5e05eec6d6 simd128: inline _MM_TRANSPOSE4_PS 2023-04-01 19:03:48 +08:00
myfreeer
3aca10ecda simd128: minor lint 2023-03-29 20:41:47 +08:00
myfreeer
5c7cd42407 simd128: inline _mm_sqrt_ss 2023-03-29 20:22:03 +08:00
myfreeer
e27f80b0bb simd128: inline _mm_rcp_ps 2023-03-29 20:16:16 +08:00
myfreeer
3845345f4c simd128: inline _mm_storeu_ps and _mm_store_ss 2023-03-29 20:12:51 +08:00
myfreeer
998d9626a2 simd128: inline _mm_unpackhi_ps and _mm_unpacklo_ps 2023-03-26 19:34:08 +08:00
myfreeer
84b482971d simd128: inline _mm_shuffle_ps 2023-03-26 19:34:08 +08:00
myfreeer
f24ec41a26 simd128: inline _mm_shuffle_ps for glmm_shuff1 2023-03-26 19:34:08 +08:00
myfreeer
e62b782039 simd128: fix a const in glm_mat4_inv_fast_wasm
making it the same as glm_mat4_inv_wasm, does not make any difference in tests
2023-03-26 19:34:08 +08:00
myfreeer
be76d96e8f simd128: inline _mm_set_ps 2023-03-26 19:34:07 +08:00
myfreeer
03c7bee863 simd128: inline some functions 2023-03-26 19:34:07 +08:00
myfreeer
71c585b159 simd128: enable in headers 2023-03-26 19:34:07 +08:00
myfreeer
6b7a63953c simd128: enable in mat2 2023-03-26 19:34:07 +08:00
myfreeer
fdef58bd1a simd128: enable in mat3 2023-03-26 19:34:07 +08:00
myfreeer
a0dd85f3d1 simd128: enable in quat 2023-03-26 19:34:07 +08:00
myfreeer
84c521c203 simd128: enable in mat4 2023-03-26 19:34:07 +08:00
myfreeer
5d60c17435 simd128: fix tests for vec4_norm_one and vec4_norm_inf 2023-03-26 19:34:07 +08:00
myfreeer
da5f18f10f simd128: fix tests for glm_inv_tr 2023-03-26 19:34:07 +08:00
myfreeer
2bc9573e1a simd128: include a fix 2023-03-26 19:34:07 +08:00
myfreeer
576d1d141e initial code on wasm simd128 2023-03-26 19:34:07 +08:00
Recep Aslantas
92a8e38162 vscode settings 2023-03-23 23:18:08 +03:00
Recep Aslantas
dd3c3ceae0 Merge pull request #280 from recp/win32-msvc-arm-neon
fix building ARM NEON on windows & msvc
2023-03-16 13:19:47 +03:00
Recep Aslantas
77b4c5cffb reset visual studio tool verisons 2023-03-16 13:16:24 +03:00
Recep Aslantas
e276b5b405 Update intrin.h 2023-03-14 09:54:32 +03:00
Recep Aslantas
13ed79a61a arm: fix checking arm64 2023-03-12 16:43:47 +03:00
Recep Aslantas
ba993b3ea9 arm: use intrin to set/init vec4 as @gottfriedleibniz suggests 2023-03-11 14:15:30 +03:00
Recep Aslantas
4a6fc485fd use CGLM_SIMD_NEON instead of CGLM_NEON_FP 2023-03-09 22:16:39 +03:00
Recep Aslantas
9ed325018d Update intrin.h 2023-03-09 22:06:20 +03:00
Recep Aslantas
a30baffafa arm: update ARM/NEON macros 2023-03-09 21:56:25 +03:00
Recep Aslantas
8a117017ea fix building ARM NEON on windows & msvc 2023-03-07 13:11:08 +03:00
Recep Aslantas
799749fc6a Merge pull request #279 from NeRdTheNed/master
Check for builtin before using it
2023-03-07 03:44:36 +03:00
Ned Loynd
f4c9ddf530 Check for builtin before using it
The check for __has_builtin being defined and using the __has_builtin() macro need to be on different lines, as when __has_builtin is not defined, using the __has_builtin() macro is an invalid preprocessor directive.
2023-03-07 10:17:44 +11:00
Recep Aslantas
bc8dc72739 now working on v0.9.0 2023-02-08 18:12:23 +03:00
Recep Aslantas
3eafc599ac Merge pull request #277 from Ransel117/patch-1
Fixed glm_mat4_mulv3
2023-02-08 18:09:58 +03:00
Ransel117
7fba424f64 Fixed glm_mat4_mulv3
Fixed it so that the function has all of it's parameters in the comments
2023-02-05 20:57:36 +01:00
Recep Aslantas
c51040cd41 Merge pull request #276 from recp/cmake-fix-buildtype
cmake: prevent overriding CMAKE_BUILD_TYPE if it is subdirectory
2023-01-27 21:01:54 +03:00
Recep Aslantas
9fc3a20d0f cmake: prevent overriding CMAKE_BUILD_TYPE if it is subdirectory 2023-01-26 11:07:08 +03:00
Recep Aslantas
7f1c062696 Merge pull request #274 from duarm/master
Adding initialization macros for ivec types
2023-01-17 21:07:32 +03:00
duarm
e70571e9e0 ivec initialization macros docs, fixing vec2 macro docs 2023-01-15 20:52:18 -03:00
duarm
007ee48b58 adding initialization macros for ivec types 2023-01-15 20:47:40 -03:00
Recep Aslantas
38771599c7 Merge pull request #273 from JulianSchoenbaechler/fix-Wdouble-promotion
Make implicit double promotion/casting explicit (fixes #228)
2022-12-31 21:18:40 +03:00
Julian Schönbächler
bfd87acfc4 Make double promotion in printf args explicit
Also use f-suffix on epsilon definitions for float comparisons.
2022-12-29 13:00:15 +01:00
Recep Aslantas
a38622e1d6 Merge pull request #272 from Artturin/revert259
Revert "fix: simplified pkgconfig generation"
2022-12-19 20:07:37 +03:00
Artturin
9c7012bb39 Revert "fix: simplified pkgconfig generation"
This reverts commit c7393f75c3.
2022-12-19 00:22:55 +02:00
Recep Aslantas
71367b67cf now working on v0.8.9 2022-12-14 14:12:29 +03:00
Recep Aslantas
3894ea32fb Merge pull request #270 from suicvne/cglm-pc-fix-cmake
Switch CMAKE_BINARY_DIR to CMAKE_CURRENT_BINARY_DIR for cmake.pc
2022-12-13 20:17:03 +03:00
Michael Santiago
a430408ec4 Switch CMAKE_BINARY_DIR to CMAKE_CURRENT_BINARY_DIR for cmake.pc install target 2022-12-13 10:59:54 -05:00
Recep Aslantas
3815e18fea bring the fix https://github.com/recp/cglm/pull/269 outside Emscripten 2022-12-12 00:37:07 +03:00
Recep Aslantas
8b5eaa5301 Merge pull request #269 from KivApple/master
Fix missing abs declaration on Emscripten
2022-12-09 14:54:37 +03:00
Ivan Kolesikov
6037618942 Fix missing abs declaration on Emscripten 2022-12-09 00:24:53 +01:00
Recep Aslantas
c6d198d780 Merge pull request #268 from bl4ckb0ne/test-clamp-fix
test_clamp: use glm_eq for floating point comparison
2022-12-07 23:17:13 +03:00
Simon Zeni
d001593f9c test_clamp: use glm_eq for floating point comparison
Fixes #266
2022-12-07 15:06:45 -05:00
Recep Aslantas
ac9461778c possible fix for https://github.com/recp/cglm/issues/266 2022-12-07 12:57:26 +03:00
Recep Aslantas
0b3d227568 Merge branch 'master' of https://github.com/recp/cglm 2022-12-07 12:55:57 +03:00
Recep Aslantas
78236d24a1 now working on v0.8.8 2022-12-07 12:55:51 +03:00
Recep Aslantas
b41858f184 Merge pull request #265 from duarm/abs-functions
New abs functions for vec2, ivec2, ivec3, ivec4
2022-11-20 12:16:49 +03:00
duarm
60bf21ba43 add missing table of contents 2022-11-19 17:48:32 -03:00
duarm
2386cdcc19 docs 2022-11-19 17:46:08 -03:00
duarm
a0f01c5ed1 new abs functions for vec2, ivec2, ivec3, ivec4 2022-11-18 14:28:39 -03:00
Recep Aslantas
8cfc98d283 Merge branch 'master' of https://github.com/recp/cglm 2022-10-26 23:15:54 +03:00
Recep Aslantas
074189163f add missing struct affine functions and headers 2022-10-26 23:15:27 +03:00
Recep Aslantas
bfbd9ba1dc add struct affine functions and headers 2022-10-26 23:13:36 +03:00
Recep Aslantas
89cee7912a now working on v0.8.7 2022-10-26 23:12:52 +03:00
Recep Aslantas
da5c66d735 update affine-post.h 2022-10-23 14:27:34 +03:00
Recep Aslantas
c4b45a0917 remove redundant comments 2022-10-23 14:22:16 +03:00
Recep Aslantas
8034073965 Merge pull request #260 from recp/new-affine
new affine transform functions 🚀
2022-10-23 14:06:34 +03:00
Recep Aslantas
53009d69c0 update build files 2022-10-23 12:09:44 +03:00
Recep Aslantas
7c62ad965b add missing call functions 2022-10-23 12:08:37 +03:00
Recep Aslantas
878e829767 update docs 2022-10-23 12:00:17 +03:00
Recep Aslantas
7c7ac8b82e add missing impl for project_z 2022-10-22 23:06:46 +03:00
Recep Aslantas
ba66459708 new project function for projecting Z
someitmes we need to project z only. this function reduces a few calculations and parameters.
2022-10-21 10:20:03 +03:00
Recep Aslantas
45e176680f post rotation operaqtions 2022-10-18 15:43:07 +03:00
Recep Aslantas
c0bd65027a add missing spin impl 2022-10-18 07:38:06 +03:00
Recep Aslantas
03d5699f32 new rotation function: spin; rotate around self at any position 2022-10-17 23:57:41 +03:00
Recep Aslantas
199d1fa031 Merge pull request #259 from bobvanderlinden/pr-cmake-pkgconfig-fix
fix: simplified pkgconfig generation
2022-09-20 16:38:48 +03:00
Bob van der Linden
c7393f75c3 fix: simplified pkgconfig generation 2022-09-16 16:45:12 +02:00
Recep Aslantas
a3186a7f32 Merge pull request #257 from Rokannon/patch-1
Added missing include in io.h which adds GLM_MAX macro
2022-09-11 11:33:46 +03:00
Vladimir Atamanov
5a89faafff Added missing include in io.h which adds GLM_MAX macro 2022-09-11 00:49:24 +02:00
Recep Aslantas
51853db559 Merge pull request #256 from ogtn/master
Fix typo in comment
2022-09-04 07:25:27 +03:00
Olivier Guittonneau
8f8417a883 Fix typo in comment 2022-09-04 01:08:50 +02:00
Recep Aslantas
2238fd127c win: suppress warnings for tests 2022-08-23 18:01:05 +03:00
Recep Aslantas
073a11a6b8 win: add missing files to visual studio project 2022-08-23 16:01:40 +03:00
Recep Aslantas
2d348ceba0 build: add missing files to meson and cmake lists 2022-08-23 15:43:04 +03:00
Recep Aslantas
ce69ecaa5a struct: project_no and project_zo apis for struct api 2022-08-23 15:31:55 +03:00
Recep Aslantas
5ad0f1c6f3 fix MIT License links 2022-08-23 15:30:09 +03:00
Recep Aslantas
aea75bbe7c build: update Makefile.am 2022-08-23 14:13:00 +03:00
Recep Aslantas
7dfe67cdde Update .gitignore 2022-08-07 11:49:13 +03:00
Recep Aslantas
84f64a5b65 Update FUNDING.yml 2022-08-01 05:10:14 +03:00
Recep Aslantas
7df8ffa7fe Merge pull request #254 from Chris-F5/fix-readme-notes
Update README to show that integer types are supported
2022-07-16 12:01:00 +03:00
Christopher Lang
dc5558d8f4 Fix readme supported types note 2022-07-15 20:17:58 +01:00
Recep Aslantas
63990be905 Merge pull request #251 from Chris-F5/add-basic-ivec-functions
Add basic ivec functions
2022-05-22 21:06:07 +03:00
Christopher Lang
cd0ae19459 Add ivec[2|3|4] sources to meson.build 2022-05-21 11:11:34 +01:00
Christopher Lang
838124af49 Declare varables at top of scope for ivec[2|3|4] 2022-05-20 17:30:54 +01:00
Christopher Lang
e3981b6d96 Add ivec[3|4] docs 2022-05-20 17:16:41 +01:00
Christopher Lang
7bb765367e Small ivec2 docs fix 2022-05-20 17:16:09 +01:00
Christopher Lang
82982abaef Add ivec2 documentation 2022-05-20 17:07:16 +01:00
Christopher Lang
dbe3b719c7 Fix ivec[2|3|4]_clamp doc comments 2022-05-20 16:53:02 +01:00
Christopher Lang
09155986fe Update ivec[2|3|4]_distance2 doc comments 2022-05-20 16:49:23 +01:00
Christopher Lang
1b3e2fdaec Improve ivec[2|3|4] documentation comments 2022-05-20 15:24:36 +01:00
Christopher Lang
4aef2510e9 Init ivec[2|3|4] docs 2022-05-20 15:02:58 +01:00
Chris-F5
2432970f90 Merge branch 'recp:master' into add-basic-ivec-functions 2022-05-20 14:45:57 +01:00
Christopher Lang
d1bdfde48d Add ivec4 tests 2022-05-20 14:42:42 +01:00
Christopher Lang
f27e26f632 Fix glm_ivec3 test 2022-05-20 14:41:59 +01:00
Christopher Lang
a3265ebe84 Fix glm_ivec3_one test 2022-05-20 14:27:30 +01:00
Christopher Lang
57ec29bd31 Update glm_ivec3 test 2022-05-20 14:26:49 +01:00
Recep Aslantas
1b217c3dd0 Merge pull request #250 from alexshpilkin/fix-pkg-config
Fix pkg-config generation when CMAKE_INSTALL_*DIR is absolute
2022-05-19 22:23:10 +03:00
Christopher Lang
94a1e6f6e1 Add ivec4 functions 2022-05-19 17:43:17 +01:00
Christopher Lang
a1a2a046a4 Fix ivec[2|3]_clamp comment docs 2022-05-19 17:32:01 +01:00
Christopher Lang
bffaa13bd5 Add ivec3 tests 2022-05-19 17:12:38 +01:00
Christopher Lang
cd4d0a1efe Update glm_ivec2_copy test 2022-05-19 17:11:58 +01:00
Christopher Lang
8916c50a3d Update glm_ivec2 test 2022-05-19 16:52:55 +01:00
Christopher Lang
7a19b8f8a3 Fix glmc_ivec3 naming 2022-05-19 16:52:10 +01:00
Alexander Shpilkin
f587c00f26 allow absolute paths in CMAKE_INSTALL_*DIR 2022-05-19 18:47:00 +03:00
Christopher Lang
65409bcda1 Add ivec3 functions 2022-05-18 18:05:17 +01:00
Christopher Lang
d2957e6275 Fix ivec2 function list comment 2022-05-18 17:55:25 +01:00
Christopher Lang
04bd1bd633 Fix ivec2 doc comment 2022-05-17 23:03:26 +01:00
Christopher Lang
db1a23d13c Add ivec2 tests 2022-05-17 22:27:38 +01:00
Christopher Lang
a85744430a Add ivec2 functions 2022-05-17 22:25:10 +01:00
Christopher Lang
d582146d9a Add ivec3 and ivec4 files 2022-05-17 16:04:47 +01:00
Christopher Lang
ee09707c1c Fix ivec2 test 2022-05-17 15:53:37 +01:00
Christopher Lang
4c85b970a9 Add ivec2 files 2022-05-16 22:41:04 +01:00
Christopher Lang
f7f0f66193 Reorder api docs 2022-05-16 22:14:57 +01:00
Christopher Lang
495b98a54d Fix tests.h comments 2022-05-16 20:51:44 +01:00
Recep Aslantas
aee47ce545 Merge pull request #247 from Chris-F5/improve-docs-index
Fix grammatical errors in docs index
2022-05-12 07:11:38 +03:00
Christopher Lang
52debe6a04 improve docs index 2022-05-08 21:49:30 +01:00
Recep Aslantas
cf7f4231f0 now working on v0.8.6 2022-03-20 22:19:31 +03:00
Recep Aslantas
7e5d1f435f Merge pull request #244 from geckor14/master
Remove unused variable
2022-03-18 12:39:29 +03:00
geckor14
851a58cedb Remove unused variable
The most recent version of Apple Clang (13.1.6) on macOS complains r3 is an unused variable. With -Werror enabled, this breaks the build.
2022-03-18 18:42:19 +11:00
Recep Aslantas
6fa1cefcc2 Merge pull request #243 from Sand3r-/patch-1
Fix a bug in glm_lookat_lh
2022-03-09 09:38:26 +03:00
Michał Gallus
7e211e1f49 Fix bug in view_lh.h #2
Reverse order of parameters in the second crossproduct
2022-03-08 01:42:43 +01:00
Michał Gallus
7d47b7f1fd Fix a bug in glm_lookat_lh
Fix the order of arguments passed to glm_vec3_crossn to avoid the negation of X axis.
2022-03-08 01:29:35 +01:00
Recep Aslantas
2a4748d452 fix glm_pickmatrix()'s param type 2022-01-31 02:56:39 +03:00
Recep Aslantas
f20bf0aaaf Merge pull request #236 from recp/ivec
add missing ivec types
2022-01-07 00:23:32 +03:00
Recep Aslantas
3a141b7cc8 extend unions for struct api 2022-01-06 18:12:46 +03:00
Recep Aslantas
5cd1a4ab44 add missing ivec types 2022-01-06 18:01:35 +03:00
Recep Aslantas
897f2afd88 Merge pull request #234 from madebr/sse3_header
Header containing sse3 intrinsics is pmmintrin.h
2021-12-31 17:51:30 +03:00
Anonymous Maarten
68e3a072e8 Header containing sse3 intrinsics is pmmintrin.h 2021-12-29 08:48:55 +01:00
Recep Aslantas
282ea84dc0 Merge pull request #231 from omar-polo/master
set PACKAGE_VERSION so it gets substituted in cglm.pc.in by cmake
2021-11-22 11:20:20 +03:00
Omar Polo
2d5506d15d set PACKAGE_VERSION so it gets substituted in cglm.pc.in by cmake
otherwise it ends up being an empty string and the installed pc has a
bogus line:

	Version:
2021-11-21 21:04:59 +01:00
Recep Aslantas
87f561fb06 Merge pull request #229 from mxi/vec2-ext-complex
Add complex routines to `vec2-ext`
2021-11-10 10:09:09 +03:00
Maxim Kasyanenko
522b18bda9 Add tests 2021-11-08 17:53:39 -08:00
Maxim Kasyanenko
b7178749ee Forgot to add the dynamic implementation file itself 2021-11-08 17:53:27 -08:00
Maxim Kasyanenko
98c708281f Syntax errors 2021-11-08 17:52:47 -08:00
Maxim Kasyanenko
896ba0a0f9 Add dynamic/struct versions of routines 2021-11-08 17:52:31 -08:00
Maxim Kasyanenko
4603816330 Forgot return type 2021-11-08 17:09:28 -08:00
Maxim Kasyanenko
9f5cc3a745 Implement a few complex routines 2021-11-08 16:28:55 -08:00
Recep Aslantas
bde653b607 Update CMakeLists.txt 2021-10-28 19:10:19 +03:00
Recep Aslantas
ede72ca412 Merge pull request #225 from podsvirov/fix-win32-shared
win: fix shared library name and destination
2021-10-17 18:09:18 +03:00
Konstantin Podsvirov
8e784e762f win: fix shared library name and destination 2021-10-10 12:02:44 +03:00
Recep Aslantas
82d1050c63 update GLM_FLT_EPSILON to use 1e-5 instead of 1e-6 2021-10-06 21:08:55 +03:00
Recep Aslantas
0631598d08 now working on v0.8.5 2021-08-18 05:03:59 +03:00
Recep Aslantas
34e5704fe8 bump version to v0.8.4 2021-08-18 04:47:11 +03:00
Recep Aslantas
672523e5af Merge pull request #219 from recp/project_zo
extend glm_project() to support ZERO_TO_ONE
2021-08-16 16:55:19 +03:00
Recep Aslantas
8427d02a9b pick matrix helper (aka gluPickMatrix) 2021-08-16 16:53:46 +03:00
Recep Aslantas
a2bd00df32 fix including headers, and suppress warnings 2021-08-16 15:51:52 +03:00
Recep Aslantas
4c8f7f310c Update project_zo.h 2021-08-16 14:27:20 +03:00
Recep Aslantas
9096fa6bab fix include paths 2021-08-16 14:27:12 +03:00
Recep Aslantas
29c3837672 implement project zo 2021-08-16 14:16:43 +03:00
Recep Aslantas
4530e0381b build: add missing files 2021-08-16 01:10:29 +03:00
Recep Aslantas
6cf1fb8992 Update .gitignore 2021-08-16 01:10:19 +03:00
Recep Aslantas
9ed4e41afd call version for clipspace-project 2021-08-16 01:08:11 +03:00
Recep Aslantas
28d24da6df build: add missing files 2021-08-16 00:55:19 +03:00
Recep Aslantas
ef22e2063f win: fix build error and comment style 2021-08-16 00:54:37 +03:00
Recep Aslantas
5a48aad1b0 Merge pull request #218 from Nairou/master
Add CGLM_FORCE_DEPTH_ZERO_TO_ONE support to glm_unprojecti
2021-08-16 00:45:22 +03:00
Caleb Gingles
07aee82125 Add CGLM_FORCE_DEPTH_ZERO_TO_ONE support to glm_unprojecti 2021-08-15 17:34:26 -04:00
Recep Aslantas
abbeb274c5 Merge pull request #214 from bubba2k/patch-1
Note that radians is expected in glm_perspective()
2021-08-09 10:54:02 +03:00
bubba2k
814adf11de Note that radians is expected in glm_perspective()
The `fovy` parameter is expected in radians, which isn't mentioned anywhere in the docs. Causes unnecessary confusion. Might as well point it out.
2021-08-09 03:02:47 +02:00
Recep Aslantas
d0d1e46533 Merge pull request #210 from legends2k/quat_rot_vecs 2021-06-15 19:59:45 +03:00
Sundaram Ramaswamy
03b4594d9e quat_from_vecs: incorporate PR comments
* C89-style comments
* Move all variable declarations to function start
* Remove constant variables
* Remove newline for ‘else’
2021-06-15 19:11:41 +05:30
Sundaram Ramaswamy
01e2b74a29 Update documentation for qaut_from_vecs 2021-06-10 23:52:09 +05:30
Sundaram Ramaswamy
ee5050f43c Tests for quaternion from two vec3 2021-06-10 23:15:10 +05:30
Sundaram Ramaswamy
b5802b99b2 Compute quaternion rotating a vector into another
Both `vec3` inputs should be of unit length; returns a unit quaternion.
2021-06-10 23:10:54 +05:30
Recep Aslantas
8b958e9600 Merge pull request #209 from legends2k/fix_vec3_cross
Fix cross product when an operand is also dest
2021-06-10 16:49:17 +03:00
Sundaram Ramaswamy
aa071b2a6b Fix cross product when operand is also dest 2021-06-10 17:20:50 +05:30
Recep Aslantas
479e7d4240 Merge pull request #207 from legends2k/fix_vec3_ortho
Fix vec3_ortho
2021-06-10 10:15:12 +03:00
Recep Aslantas
38c6188e12 Update vec3.h 2021-06-10 10:13:51 +03:00
Sundaram Ramaswamy
c330b47ded Remove debug printf statements 2021-06-10 10:27:28 +05:30
Sundaram Ramaswamy
2e8162b133 Fix vec3_ortho 2021-06-09 23:18:32 +05:30
Recep Aslantas
afdcae08dd Merge pull request #205 from legends2k/master
Include affine.h in quat.h; remove needless decls
2021-06-07 11:45:54 +03:00
Sundaram Ramaswamy
32d1c96dc0 Include affine.h in quat.h; remove needless decls
* affine.h is needed for glm_translate_make
* Remove function declarations
  - glm_mat4_mulv since mat4.h is already included
  - glm_mul_rot as affine-mat.h is already include
  - glm_translate as affine.h is included with this change
2021-06-07 11:35:56 +05:30
Recep Aslantas
4d2ba464a0 Update README.md 2021-05-30 18:11:17 +03:00
Recep Aslantas
398e47070b Update README.md 2021-05-30 18:09:17 +03:00
Recep Aslantas
619ac4ce9a Update README.md 2021-05-30 18:03:33 +03:00
Recep Aslantas
e83940f3b1 Create cglm.png 2021-05-30 17:48:29 +03:00
Recep Aslantas
e5d88f22a0 Update README.md 2021-05-30 15:31:06 +03:00
Recep Aslantas
8e10ab2b49 Update features.rst 2021-05-30 15:30:55 +03:00
Recep Aslantas
4ede0815d4 Update features.rst 2021-05-30 15:28:38 +03:00
Recep Aslantas
7d16e3583f Merge branch 'master' of https://github.com/recp/cglm 2021-05-30 15:23:38 +03:00
Recep Aslantas
6011baff06 Update opt.rst 2021-05-30 15:23:30 +03:00
Recep Aslantas
af92df4e84 ci: migrate cglm from tavis-ci.org to travis-ci.com 2021-05-30 15:17:33 +03:00
Recep Aslantas
94381d3067 struct: fix glms_perspective_resize
since struct param is copy-by-value, result was noop
2021-05-30 13:06:49 +03:00
Recep Aslantas
0e794f8f8f struct: fix glms_persp_move_far
since struct param is copy-by-value, result was noop
2021-05-30 13:02:10 +03:00
Recep Aslantas
b895e424b0 docs: add docs about clipspace configuration 2021-05-30 12:53:04 +03:00
Recep Aslantas
a2b8858e36 win: suppress warnings 2021-05-30 12:50:30 +03:00
Recep Aslantas
9d08407897 win: suppress warnings 2021-05-30 12:46:26 +03:00
Recep Aslantas
8898c3b471 win: add missing files to build 2021-05-30 12:43:17 +03:00
Recep Aslantas
f0c2860179 Merge pull request #203 from bwhmather/meson-fixes
Update lists of source files in meson.build
2021-05-29 14:31:41 +03:00
Ben Mather
f142e8e16e build: rebuild list of test files in meson.build 2021-05-29 10:43:29 +01:00
Ben Mather
5ac916236c build: fix lists broken by missing commas in meson.build 2021-05-29 10:43:29 +01:00
Ben Mather
4327935b9f style: fix trailing whitespace in meson.build 2021-05-29 10:43:23 +01:00
Recep Aslantas
086b40bf6a Merge pull request #201 from hartenfels/master
Add struct clipspace files to autoconf build
2021-05-24 22:31:33 +03:00
Carsten Hartenfels
af3b356762 Add struct clipspace files to autoconf build
They weren't being installed.

Fixes #200.
2021-05-24 21:20:27 +02:00
Recep Aslantas
9ac291c673 Merge pull request #198 from raedwulf/clipspace
Clipspace implementations for left/righted-handed coordinate systems and [-1,1] and [0,1] clipspace
2021-05-23 18:59:01 +03:00
Tai Chi Minh Ralph Eastwood
7f7e9f69da clipspace: add struct API implementations 2021-05-22 22:41:03 +02:00
Tai Chi Minh Ralph Eastwood
8ddb5d5740 build: fix incorrect include paths for libcglm 2021-05-14 16:58:48 +02:00
Tai Chi Minh Ralph Eastwood
56ec058c7d style: fix documentation consistency for describing clipspace 2021-05-14 16:55:16 +02:00
Tai Chi Minh Ralph Eastwood
a5af9e5eac build: fix Makefile.am missing clipspace source files 2021-05-14 16:49:18 +02:00
Tai Chi Minh Ralph Eastwood
4d20f97275 clipspace: fix typo'd clip control define 2021-05-14 16:33:16 +02:00
Tai Chi Minh Ralph Eastwood
89e8c352ec style: fix missing whitespace for alignment
Co-authored-by: Michael <michael.guyver@gmail.com>
2021-05-14 15:44:10 +02:00
Tai Chi Minh Ralph Eastwood
403097d56c build: fix duplicate line in CMakeLists.txt 2021-05-14 15:27:28 +02:00
Tai Chi Minh Ralph Eastwood
eddaf464ff style: fix missing whitespace for alignment
Co-authored-by: Michael <michael.guyver@gmail.com>
2021-05-14 15:25:29 +02:00
Tai Chi Minh Ralph Eastwood
7065011bf3 clipspace: add initial implementations LH, RH and NO, ZO
Add the initial implementations of the left-handed and right-handed
coordinate systems as well as clipspace depth values of [-1, 0] and
[0, 1].
2021-05-13 23:22:58 +02:00
michaelg
db46ea110a Updated README.md to remove ref to glm_cmp stub 2021-05-13 23:18:05 +02:00
michaelg
c013bd462c Add LH & RH_NO perspective functions
This commit adds functions `glm_perspective_lh_no` and
`glm_perspective_rh_no` to the code. Unit tests are added and this
commit follows the new pattern of adding the a new file per
coordinate-system and clip-space tuple.

. Makefile.am updated
. removed test/glm_cmp project stub
. unit tests include naive implementations to as well as magic number
  ref-data generated by the corresponding GLM functions.

No tests run yet on Windows or Mac.
2021-05-13 23:18:05 +02:00
michaelg
b3a18b8a15 Add glm_perspective_rh_zo function + tests
This commit adds the RH/ZO perspective function. It does so in the new
file `cam_rh_zo.h` and further refactors the LH variant into new file
`cam_lh_zo.h`. This creates some churn in the tests and configuration
files as new test files were added as well, and all these changes found
their way into the build files.

Tests passing on Linux.
2021-05-13 23:18:05 +02:00
michaelg
1bce62c371 Add function glm_perspective_lh_zo
This commit adds the function `glm_perspective_lh_zo`, modelled on the
implementation of glm_perspective, but amended to provide a left-hand
coordinate system expected by DirectX, Metal and Vulkan (per the GLM
project's `glm/detail/setup.hpp`). It uses a clip-space of zero-to-one.

The function is tested against a longhand version of the algorithm it
seeks to implement as well as against the output of the GLM project's
`glm::perspectiveLH_ZO` function. This commit adds a new subdirectory
`test/glm_cmp` which contains a basic CMake file and `main.cpp`. An
interested user should link or copy or clone the GLM project into this
directory. The `main` function can be used to print the reference data
used so others can verify behaviour in the future, or add new literal
reference values.
2021-05-13 23:18:05 +02:00
Recep Aslantas
a242d83805 style: rename nearVal, farVal to nearZ and farZ 2021-05-08 22:42:44 +03:00
Recep Aslantas
7760c709da build, meson: add so version to meson build 2021-05-08 15:44:14 +03:00
Recep Aslantas
919e3bcf4a Merge pull request #193 from recp/simd-3
SIMD and ILP Update
2021-05-08 14:14:22 +03:00
Recep Aslantas
607182982d Merge branch 'master' into simd-3 2021-05-07 14:08:56 +03:00
Recep Aslantas
ad17f38934 Merge pull request #195 from legends2k/master
Add nlerp for quaternions
2021-05-07 12:58:05 +03:00
Sundaram Ramaswamy
8302f78484 Update documentation with nlerp 2021-05-07 14:26:31 +05:30
Sundaram Ramaswamy
9665be3138 Add struct API wrapper 2021-05-07 13:49:44 +05:30
Recep Aslantas
5c22ca3abb arrm, neon: use negate instruction instead of xor in glm_inv_tr_neon() 2021-05-07 01:52:12 +03:00
Recep Aslantas
7f9585ca72 arrm, neon: impove hadd performance 2021-05-07 01:46:24 +03:00
Recep Aslantas
d0ab3aaa2e arm, neon: util macros 2021-05-07 01:46:03 +03:00
Sundaram Ramaswamy
83dbdcc4a9 Add nlerp tests 2021-05-07 01:21:28 +05:30
Sundaram Ramaswamy
8ce45b4303 Add call and struct interfaces 2021-05-07 00:35:20 +05:30
Sundaram Ramaswamy
f19ff5d064 Use scale for both cases 2021-05-06 23:47:03 +05:30
Sundaram Ramaswamy
d6b93f052e Add nlerp for quaternions
Normalized linear interpolation for quaterions are a cheaper
alternative to slerp.  This PR adds nlerp operaiton for quaternions.
2021-05-06 23:38:26 +05:30
Recep Aslantas
28705be5a3 simd, sse: reduce some computation at glm_mul_rot_sse2() 2021-05-01 23:16:03 +03:00
Recep Aslantas
e1b142bce7 add todo to quat.h 2021-05-01 23:03:41 +03:00
Recep Aslantas
0f96eaad20 sse2: optimize glm_mat3_mul_sse2() with sse2
* reduce memory access for dest[2][2]
* the speed is increased ;)
2021-05-01 22:55:19 +03:00
Recep Aslantas
d5d3178ae0 Merge pull request #192 from Winter091/fixing-typo
fix typo: vec3 -> vec4
2021-05-01 21:24:31 +03:00
winter091
13269f4af8 fix typo: vec3 -> vec4 2021-05-01 16:48:31 +03:00
Recep Aslantas
faf6186c29 sse: optimize glm_mat2_mul_sse2 with sse 2021-05-01 03:44:04 +03:00
Recep Aslantas
2be6ac949b sse: optimize glm_quat_mul with sse 2021-05-01 03:18:26 +03:00
Recep Aslantas
5b7bc522ac sse: optimize affine with sse
* re-oder instructions for ILP
2021-05-01 02:58:14 +03:00
Recep Aslantas
376cf31ee7 armi neon: optimize affine with neon 2021-05-01 02:46:14 +03:00
Recep Aslantas
d28b381dd6 armi neon: optimize mat4 mul with neon 2021-05-01 02:45:15 +03:00
Recep Aslantas
3673622cc3 simd, sse: optimize mat4 mul-v with sse
* re-oder instructions for ILP
2021-05-01 02:17:34 +03:00
Recep Aslantas
a90f706e12 simd, sse: optimize mat4 mul with sse
* re-oder instructions for ILP
2021-05-01 02:17:08 +03:00
Recep Aslantas
c065d71a2f simd, sse: optimize mat4 inv with sse
* reduce a few shufflees
* re-oder instructions for ILP
2021-04-30 21:12:17 +03:00
Recep Aslantas
1b3b91fe0b Merge pull request #191 from quadroli/master
very minor correction in readme
2021-04-30 20:35:15 +03:00
quadroli
17560a0687 very minor correction in readme 2021-04-30 18:03:50 +03:00
Recep Aslantas
ba634d6c83 simd: optimize glm_mat4_zero() with simd 2021-04-30 04:04:27 +03:00
Recep Aslantas
f35badd436 now working on v0.8.3 2021-04-30 01:00:42 +03:00
Recep Aslantas
04eaf9c535 arm, neon: neon/fma support for glm_quat_mul() 2021-04-29 01:12:00 +03:00
Recep Aslantas
bd6641bd0a build: add missing files to build files 2021-04-28 22:45:03 +03:00
Recep Aslantas
4e4bff418d arm, neon: neon/fma support for glm_mat2_mul() 2021-04-28 22:06:46 +03:00
Recep Aslantas
55ebbdbe40 arm, neon: neon/fma support for glm_inv_tr() 2021-04-28 14:46:14 +03:00
Recep Aslantas
e4c35e32fc Merge pull request #190 from ylecuyer/patch-3
Minor typo in doc
2021-04-27 23:52:40 +03:00
Yoann Lecuyer
ec467fef1f Minor typo in doc
I stumbled upon while reading the doc
2021-04-27 22:09:13 +02:00
Recep Aslantas
1e8865233b Merge pull request #189 from recp/simd-2
ARM Neon Update
2021-04-25 15:20:24 +03:00
Recep Aslantas
155eb109a8 arm, neon: neon/fma support for glm_mul_rot() 2021-04-25 03:49:35 +03:00
Recep Aslantas
2903813765 arm, neon: neon/fma support for glm_mul() 2021-04-25 03:45:00 +03:00
Recep Aslantas
0ab50f7208 arm, neon: update mat4_mul to use FMA 2021-04-25 03:41:39 +03:00
Recep Aslantas
701e015bfd avoid loading vec3 by glmm_load()
* use glmm_set1() for each for now
2021-04-25 02:36:06 +03:00
Recep Aslantas
1fb941a41b drop swizzling helpers fro now for simplicity 2021-04-25 02:35:55 +03:00
Recep Aslantas
92151c6328 arm, neon: use div instead of mul by 1 / det for mat4_inv 2021-04-24 18:02:47 +03:00
Recep Aslantas
afac887850 arm, neon: implement mat4 inv with neon 2021-04-24 17:54:01 +03:00
Recep Aslantas
a111693b6b arm, neon: implement mat4 determinant with neon 2021-04-24 15:45:36 +03:00
Recep Aslantas
ce9e5f5575 arm: update glmm swizzling func names 2021-04-24 01:38:04 +03:00
Recep Aslantas
d13842e7de arm: optimize vec4 div with NEON 2021-04-24 00:51:09 +03:00
Recep Aslantas
059e5010e6 arm: define CGLM_ARM64 for identify arm64 2021-04-24 00:44:07 +03:00
Recep Aslantas
65292a94a6 swizzling functions for NEON 2021-04-24 00:00:00 +03:00
Recep Aslantas
f303984aad use unified glmm api for vec4 2021-04-23 23:34:36 +03:00
Recep Aslantas
7d5c4da7cf optimize translate functions 2021-04-23 23:32:48 +03:00
Recep Aslantas
63988a515c glmm: new defines for splat 2021-04-23 23:32:21 +03:00
Recep Aslantas
9725b60d46 rename glmm_shuff1x() to glmm_splat()
* mark glmm_shuff1x() as DEPRECATED
2021-04-23 22:12:57 +03:00
Recep Aslantas
50c93f3d30 Merge pull request #188 from wdouglass/cmake-pkgconfig
configure and install cglm.pc with cmake
2021-04-23 17:12:04 +03:00
Recep Aslantas
f14ca0c3f2 now working on v0.8.2 2021-04-23 17:03:39 +03:00
Woodrow Douglass
0c165cba76 configure and install cglm.pc with cmake 2021-04-23 09:28:55 -04:00
Recep Aslantas
2de1133012 fix enabling FMA macro for MSVC 2021-04-19 06:04:22 +03:00
Recep Aslantas
12dc054e49 Merge pull request #186 from recp/fma
Optimizations with FMA
2021-04-19 04:32:01 +03:00
Recep Aslantas
ebba4eea8e win, msvc: enable FMA macro for MSVC 2021-04-19 04:14:14 +03:00
Recep Aslantas
aa2fa89e6c arm: fma msub and nmsub 2021-04-19 00:35:19 +03:00
Recep Aslantas
7b0eee497e arm: fix fmadd parameter order 2021-04-19 00:28:07 +03:00
Recep Aslantas
04008d9c3f arm: fix fma for glm_vec4_muladds 2021-04-19 00:21:04 +03:00
Recep Aslantas
11b1588105 glmm: missing FMA funcs for SSE and AVX 2021-04-19 00:20:47 +03:00
Recep Aslantas
7c81482248 avx: implement scale matrix using AVX 2021-04-19 00:11:43 +03:00
Recep Aslantas
f3f29bd383 vec4: optimize muladd and muladds with fma 2021-04-18 16:24:29 +03:00
Recep Aslantas
0d0d22f96c opitimize affine matrix operations with fma 2021-04-18 13:51:22 +03:00
Recep Aslantas
7df5aa2e26 opitimize mat2 operations with fma 2021-04-18 13:51:09 +03:00
Recep Aslantas
7cc4c37afb opitimize mat3 operations with fma 2021-04-18 13:51:03 +03:00
Recep Aslantas
abe29a788a opitimize mat4 operations with fma 2021-04-18 13:50:51 +03:00
Recep Aslantas
c5655bbd2e glmm: define fma functions 2021-04-18 13:49:50 +03:00
Recep Aslantas
47e0045015 glmm, x86: define hadd function 2021-04-18 13:49:36 +03:00
Recep Aslantas
8f09cc8583 Merge pull request #183 from legends2k/master
Add CMake interface library target
2021-03-26 20:36:56 +03:00
Sundaram Ramaswamy
d6a0ac320b Update docs on CMake header-only usage 2021-03-26 12:32:36 +05:30
Sundaram Ramaswamy
616d38c13a Remove redundant header listing 2021-03-26 12:23:56 +05:30
Sundaram Ramaswamy
9e12908556 Add CMake interface library target
Projects using cglm as a header-only library needn’t build files under
src/. Provide a target which allows them to skip compiling them by

add_subdirectory(external/cglm EXCLUDE_FROM_ALL)
target_link_libraries(MyExe PRIVATE cglm_headers)
2021-03-25 17:47:43 +05:30
Recep Aslantas
405cda6ee9 now working on v0.8.1 2021-03-02 23:36:33 +03:00
Recep Aslantas
1b0322e51c Merge pull request #180 from recp/aabb-sphere-fix
fix aabb-sphere test (#179)
2021-03-01 10:48:04 +03:00
Recep Aslantas
4a308dcd9e fix aabb-sphere test (#179) 2021-02-28 23:12:06 +03:00
Recep Aslantas
fec396950b Merge pull request #178 from gaurapanasenko/master
Fixed cmake config install path
2021-02-22 10:31:06 +03:00
Yehor Panasenko
981af0565e Fixed cmake config install path
Now you can use library with
```cmake
find_package(cglm REQUIRED)
target_link_libraries(${PROJECT_NAME} PRIVATE ${CGLM_LIBRARY})
```
2021-02-22 04:46:22 +02:00
Recep Aslantas
1d215ef5f3 Merge pull request #177 from Winter091/master
remove wrong c standard bug
2021-01-25 20:05:58 +03:00
winter091
2b7cfde64f remove wrong c standard bug 2021-01-25 15:50:18 +03:00
Recep Aslantas
c783c42101 Merge pull request #174 from timgates42/bugfix_typo_assume
docs: fix simple typo, asume -> assume
2020-12-12 09:18:09 +03:00
Tim Gates
bddcfedead docs: fix simple typo, asume -> assume
There is a small typo in include/cglm/affine.h.

Should read `assume` rather than `asume`.
2020-12-12 12:13:48 +11:00
Recep Aslantas
34e7438271 Merge pull request #172 from SanderMertens/master
Replace hex floating point literals
2020-12-04 13:00:07 +03:00
Sander Mertens
485ff6bc46 Replace hex floating point literals 2020-12-01 21:49:35 -08:00
Recep Aslantas
4ab9ab4772 docs: fix/improve build documentation 2020-11-21 18:20:04 +03:00
Recep Aslantas
a5ff477fc8 doc: fix duplicate entry warning 2020-11-21 18:13:59 +03:00
Recep Aslantas
254570d006 Merge pull request #169 from podsvirov/docs-c-id-attribute-restrict
Fix Documentions WARNING for __restrict attribute
2020-11-21 18:11:28 +03:00
Konstantin Podsvirov
681f20d540 Fix Documentions WARNING for __restrict attribute
Add `__restrict` keyword to `c_id_attributes` added in `sphinx 3.0`.

Closes #167
2020-11-21 15:34:18 +03:00
Recep Aslantas
fd87f6e2c3 Merge pull request #168 from podsvirov/fix-fix-docs-for-vec2
Fix fix docs for glm_vec2()
2020-11-21 14:32:48 +03:00
Konstantin Podsvirov
2c12c6dce5 Fix fix docs for glm_vec2()
Remove extra `\` symbol.
2020-11-21 14:05:19 +03:00
Recep Aslantas
5619527fd3 Update cglm.podspec 2020-11-19 22:42:12 +03:00
Recep Aslantas
8b1c3c3fc4 now working on v0.8.0 2020-11-19 22:21:21 +03:00
Recep Aslantas
ec852c7682 Merge pull request #164 from taisei-project/fix-cast-align
simd/x86: fix -Wcast-align warnings (gcc/clang)
2020-11-09 11:19:02 +03:00
Recep Aslantas
5433c9ed6c Merge pull request #165 from taisei-project/meson-install-option
meson: add 'install' option
2020-11-09 11:11:36 +03:00
Andrei Alexeyev
2a2d51624b meson: add 'install' option
This is useful for people who want to use cglm as a meson subproject
without polluting the main project's install target.
2020-11-08 20:30:24 +02:00
Andrei Alexeyev
5fa908602f simd/x86: fix -Wcast-align warnings (gcc/clang)
This modifies glmm_{load,store}3 functions to make the compiler assume
the v pointer is appropriately aligned for the type it is being cast to.
Not tested with CGLM_ALL_UNALIGNED, but it probably doesn't matter.
2020-11-08 20:09:57 +02:00
Recep Aslantas
9da74f9654 Update CREDITS 2020-11-08 17:57:34 +03:00
Recep Aslantas
dddb077b13 ignore xcode user data 2020-11-08 17:42:55 +03:00
Recep Aslantas
6107287c9a Merge pull request #163 from emersion/glm-vec2-doc-fix
Fix docs for glm_vec2()
2020-10-17 09:19:33 +03:00
Simon Ser
7dccbef6e3 Fix docs for glm_vec2()
The prototype takes a float *, which can be vec3 or vec4.
2020-10-16 22:32:24 +02:00
Recep Aslantas
d920a62be2 Merge pull request #160 from smumryak/master
Added simple swiftpm package file
2020-09-08 11:55:18 +03:00
Serhii Mumriak
73f32b9ef7 Updated README.md with swift configuration information 2020-09-07 17:26:33 -07:00
Serhii Mumriak
2e5257bcc1 Updated 160 PR according review comments. 2020-09-07 17:09:37 -07:00
Serhii Mumriak
65b0b461ab Added simple swiftpm package file with module map and empty C file to trick the compiler to build the empty C target. 2020-09-05 20:39:12 -07:00
Recep Aslantas
e34601f578 arm neon: multiply mat4 with vec4 2020-08-29 11:51:07 +03:00
Recep Aslantas
fa01a3077b neon: support transpose mat4 with neon 2020-08-29 11:33:13 +03:00
Recep Aslantas
54f805a62d neon: move neon-scale to simd header 2020-08-29 11:32:44 +03:00
Recep Aslantas
a05b282fad now working on v0.7.9 2020-08-29 10:19:50 +03:00
Recep Aslantas
66f6bbde6c io: deprecate CGLM_NO_PRINTS_NOOP 2020-08-08 10:53:35 +03:00
Recep Aslantas
4054d9a190 io: update documentation + README 2020-08-08 10:47:38 +03:00
Recep Aslantas
c1112f0063 io: make options changable by user
* this will help to disable colorful output because not all terminals can print colors.
2020-08-08 10:22:16 +03:00
Recep Aslantas
b62e922f32 io: make prints noop if we can't define them 2020-08-08 10:20:44 +03:00
Recep Aslantas
3c53bed709 now working on v0.7.8 2020-08-08 10:14:41 +03:00
Recep Aslantas
a2b6d71558 Merge pull request #158 from randy408/meson
Add meson build support
2020-08-06 00:55:04 +03:00
Randy
fdfceb9f5b update build.rst 2020-08-05 23:14:05 +02:00
Randy
d273daecfe update README 2020-08-05 23:05:11 +02:00
Randy
92b75a1345 meson: add option to build tests, default to false 2020-08-05 22:49:52 +02:00
Randy
640795a771 update README 2020-08-04 20:50:33 +02:00
Randy
cad265ebcd add meson.build 2020-08-04 20:31:39 +02:00
Recep Aslantas
387c33fb4d Merge pull request #154 from randy408/symbol
win32: fix symbol exports
2020-08-04 21:05:28 +03:00
Randy
77585de397 remove CGLM_DLL from vs solution 2020-08-04 19:16:05 +02:00
Randy
a9b06e4b35 gcc: fix warnings (#156) 2020-08-04 19:57:10 +03:00
Recep Aslantas
7976ac78f2 Merge pull request #155 from randy408/test
test: don't link 'm' with msvc
2020-08-04 00:23:13 +03:00
Randy
208f8073ad test: don't link 'm' with msvc 2020-08-03 22:47:23 +02:00
Randy
009fb966a6 drop CGLM_DLL, add CGLM_STATIC 2020-08-03 22:45:50 +02:00
Randy
09fd9f86b9 update CMakefile 2020-08-03 20:47:12 +02:00
Randy
2ff4ae0b4c simplify exports check 2020-08-03 20:47:00 +02:00
Randy
aa0a195e98 win32: fix symbol exports 2020-08-03 19:34:45 +02:00
Recep Aslantas
87092e6849 build: add missing files to project files 2020-07-31 20:09:57 +03:00
Recep Aslantas
89ced4166a Merge pull request #151 from recp/affine2d
2D Affine Transforms
2020-07-31 19:21:30 +03:00
Recep Aslantas
6080099434 2d: add documentation for 2D Affine Transforms 2020-07-31 19:19:07 +03:00
Recep Aslantas
f3735c9036 2d: struct versions of affine2d transforms 2020-07-31 18:38:32 +03:00
Recep Aslantas
2242e9a5e1 2d: add tests for rotate2d and its friends 2020-07-31 18:21:23 +03:00
Recep Aslantas
a12364d486 2d: fix rotate2d and its friends 2020-07-31 18:20:51 +03:00
Recep Aslantas
b133c2e3e3 2d: add rotate2d and its friends 2020-07-31 15:11:00 +03:00
Recep Aslantas
0127d30fa8 2d: add scale2d and its friends 2020-07-31 13:49:33 +03:00
Recep Aslantas
9b13b2f872 add tests for translate2d functions 2020-07-31 12:43:46 +03:00
Recep Aslantas
40d903c2bc build: define CGLM_DEFINE_PRINTS to enable print functions for test results 2020-07-31 12:41:53 +03:00
Recep Aslantas
06016220c0 build: add affine2d to CMake 2020-07-31 12:41:29 +03:00
Recep Aslantas
bb751d32ca 2d: add translate2d and its friends 2020-07-31 11:40:52 +03:00
Recep Aslantas
6dc37f6cc9 build: CFLAGS for check/test target to match the main target 2020-07-31 00:25:08 +03:00
Recep Aslantas
5ff42799b2 mat2: don't use vec4 directly on mat2 becauce of alignment requirements may be different 2020-07-31 00:06:38 +03:00
Recep Aslantas
2326e627b5 now working on v0.7.7 2020-07-31 00:06:17 +03:00
Recep Aslantas
c18fe8098f build: try to remove RTC1 from CMake build 2020-07-23 19:12:54 +03:00
Recep Aslantas
a9ed8470b4 win: try to disable /RTC flags 2020-07-20 20:41:00 +03:00
Recep Aslantas
332087da61 Update mat4.rst 2020-07-12 23:30:04 +03:00
Recep Aslantas
56c43d7a74 Update mat4.rst 2020-07-12 23:29:44 +03:00
Recep Aslantas
649f390662 Update mat4.rst 2020-07-12 23:27:15 +03:00
Recep Aslantas
0818bbdf51 Update mat4.rst 2020-07-12 23:24:41 +03:00
Recep Aslantas
edd1517f85 Update mat4.rst 2020-07-12 23:23:50 +03:00
Recep Aslantas
d0c2e8233c Update mat4.rst 2020-07-12 23:23:06 +03:00
Recep Aslantas
87837aa074 Merge branch 'master' of https://github.com/recp/cglm 2020-07-12 23:21:16 +03:00
Recep Aslantas
62ab6c56c0 Update mat4.rst 2020-07-12 23:21:13 +03:00
Recep Aslantas
a2985aa444 Merge pull request #146 from Terri00/patch-1
mat3_mulv: function behaviour to match with mat4
2020-07-03 23:25:54 +03:00
Harry Godden
7274cee153 mat3_mulv: function behaviour to match with mat4
Using mat3_mulv with the same input/output vector creates undesired results. 

Respective mat4_mulv function provides temporary vec3 'res'.
Updated this function to match behaviour of mat4.
2020-07-02 23:29:10 +01:00
Recep Aslantas
79c44fdbfa drop pedantic from C Flags and allow extensions
this will also suppress warnings on test target
2020-05-29 13:01:36 +03:00
Recep Aslantas
c32e986497 mat2: suppress warnings for initializing mat2 sruct 2020-05-29 12:51:45 +03:00
Recep Aslantas
b953fcf1bd ci, travis: add multiple cpu arch 2020-05-29 00:47:18 +03:00
Recep Aslantas
c0a4c245f0 tests: add test for frustum 2020-05-28 14:19:35 +03:00
Recep Aslantas
acc0885e52 tests: add option to disable colors in test output
* because some terminals may not support colors, in that case, colors can be disabled by defining `GLM_TESTS_NO_COLORFUL_OUTPUT`
2020-05-28 11:47:13 +03:00
Recep Aslantas
f49e8f9991 neon: fix vec4_muladds (critical) 2020-05-26 23:03:32 +03:00
Recep Aslantas
d2e5a3cd5b use epsilon to compare vec2/vec3/vec4_eq_all 2020-05-26 23:02:58 +03:00
Recep Aslantas
a1485a14f6 option to override FLT_EPSILON with GLM_FLT_EPSILON 2020-05-26 23:00:00 +03:00
Recep Aslantas
271e3b15d6 Merge branch 'cmake' 2020-05-25 17:07:46 +03:00
Recep Aslantas
74cf89a82f build, cmake: update cmake to export Config to use find_package() 2020-05-25 17:06:48 +03:00
Recep Aslantas
8698082411 Merge pull request #143 from recp/cmake
Improve CMakeLists.txt
2020-05-22 00:01:42 +03:00
Recep Aslantas
799de548f4 Update CMakeLists.txt 2020-05-18 16:04:15 +03:00
Recep Aslantas
671dae3e22 now working on v0.7.6 2020-05-18 15:55:04 +03:00
Recep Aslantas
7e142132bf win: suppress warning; C4005: '_CRT_SECURE_NO_WARNINGS': macro redefinition 2020-05-17 19:24:48 +03:00
Recep Aslantas
0ccd58da01 docs: add clarification/troubleshooting for a crash type 2020-05-16 22:37:16 +03:00
Recep Aslantas
4211c230cc now working on v0.7.5 2020-05-16 22:11:54 +03:00
Recep Aslantas
269bdb3dbd fix arm neon build 2020-05-11 20:19:05 +03:00
Recep Aslantas
b032b803ca build, cmake: use PROJECT_VERSION_** to set so version instead of custom variables 2020-05-10 23:54:55 +03:00
Recep Aslantas
26a638e11d io: make print functions macro to supress unused parameter warrnings 2020-05-03 14:10:24 +03:00
Recep Aslantas
099522ada3 fix LICENSE alignments 2020-05-02 22:32:57 +03:00
Recep Aslantas
4903dd62ea now working on v0.7.4 2020-05-02 22:32:53 +03:00
Recep Aslantas
95161f7776 Merge pull request #140 from recp/print-io
Print Improvements
2020-05-01 01:12:16 +03:00
Recep Aslantas
f0942c13a1 remove redundant typedef. 2020-05-01 01:07:18 +03:00
Recep Aslantas
8eddeb77d0 win: fix print function for _DEBUG and supress warnings 2020-05-01 01:03:20 +03:00
Recep Aslantas
cbed29820b ios: update docs for prints 2020-04-30 23:49:38 +03:00
Recep Aslantas
3ec6bad5b3 io: open library-called print functions 2020-04-30 23:40:21 +03:00
Recep Aslantas
fefc3dc32d io: print has been maden optional to DEBUG or to CGLM_DEFINE_PRINTS 2020-04-30 23:38:27 +03:00
Recep Aslantas
203d40208c io: new way to print items
* now mis-alignment of columns are fixed: larger numbers are printed via %g and others are printed via %f. Column withs are calculated before print.

* Now values are colorful ;)
* Some print improvements
2020-04-30 23:37:51 +03:00
Recep Aslantas
c45445c613 suppress documentation warnings 2020-04-30 10:15:55 +03:00
Recep Aslantas
73c6766806 Update .gitignore 2020-04-30 10:14:12 +03:00
Recep Aslantas
65dff25ed5 build: add version info to cmake 2020-04-28 00:33:29 +03:00
Recep Aslantas
c2584c0fe6 now working on v0.7.3 2020-04-28 00:20:04 +03:00
Recep Aslantas
bd951f96be Update cglm.podspec 2020-04-28 00:18:15 +03:00
Recep Aslantas
1200372ced vscode settings 2020-04-28 00:04:24 +03:00
Recep Aslantas
75a5ca153d Merge branch 'master' of https://github.com/recp/cglm 2020-04-27 22:46:22 +03:00
Recep Aslantas
5a9593d9bc update docs 2020-04-27 22:30:52 +03:00
Recep Aslantas
edf46aaf2b Update README.md 2020-04-27 22:26:29 +03:00
Recep Aslantas
e2ba795603 Update README.md 2020-04-27 22:25:36 +03:00
Recep Aslantas
5e6b566d6a Update CMakeLists.txt 2020-04-27 13:43:08 +03:00
altf_four
c973768495 CMake: Fix incorrect compiler flags (#139)
* Fix CMake compiler args.

- Replace -stdlib=libc++ with -std=gnu11 & apply it to clang too.
- Remove redundant -fstrict-aliasing.
- Remove warned and redundant -Weverything
2020-04-27 00:11:51 +03:00
altf_four
6d8e2cc92d Add flags required for cmake. (#138)
- Add flags for clang
- Add flags for msvc
- Use modern cmake in compiler flags handling.
- Globalize compiler options for library and tests
- Address issue with cmake output binary being bigger than make's. (Now
cmake is smaller ~176 (confirmed on dynamic library on Linux)).
2020-04-26 19:42:23 +03:00
Recep Aslantas
010dda6a77 Merge pull request #130 from FMMazur/cmake
Cmake: Integratrion
2020-04-26 14:59:55 +03:00
Recep Aslantas
345c7307ef Merge branch 'master' into cmake 2020-04-26 14:34:34 +03:00
Recep Aslantas
f485c928b1 Merge pull request #136 from Uwila/documentation-fix
Fix some documentation mistakes
2020-04-13 21:13:47 +03:00
Uwila
e895fe884e Fix some documentation mistakes 2020-04-12 16:11:18 +02:00
Felipe Munoz Mazur
18fe47d0c7 Merge branch 'master' into cmake 2020-04-10 00:33:07 -04:00
FMMazur
a84ebc4aaa CMake: Use CCMAKE_INSTALL_PREFIX as default to set directory install 2020-04-09 14:03:18 -04:00
Recep Aslantas
5c35c4ef5d Merge pull request #134 from Uwila/patch-1
Link contributors' avatars to the correct page
2020-04-07 22:47:26 +03:00
Uwila
f79674f66a Link contributors' avatars to the correct page 2020-04-07 21:39:27 +02:00
Recep Aslantas
e40373a1fa Merge pull request #132 from Uwila/ray-tests
* tests: add tests for glm_ray_triangle
2020-04-06 16:44:35 +03:00
Recep Aslantas
47807b7955 Update test_ray.h 2020-04-06 16:44:07 +03:00
Uwila
38cb693834 Update vcxproj files for test_ray 2020-04-06 13:51:29 +02:00
Uwila
7bcd7609eb Fix test_ray.h style 2020-04-06 11:43:12 +02:00
Uwila
90eb164a43 Add tests for cglm_ray_triangle 2020-04-06 11:42:23 +02:00
Uwila
78b2e2d2cc Add tests for glm_ray_triangle 2020-04-06 11:38:27 +02:00
Recep Aslantas
e60e7b5750 Merge pull request #131 from Uwila/ray-triangle-intersection
feature: ray-triangle intersection
2020-04-04 00:33:45 +03:00
Uwila
c1331a1dd4 Improve ray.h style 2020-04-03 18:00:49 +02:00
Uwila
339adab783 Align variables in ray code 2020-04-03 17:56:53 +02:00
Uwila
7bf38a3062 Update credits with ray-triangle intersection algorithm 2020-04-03 13:10:38 +02:00
Uwila
99076be6bb Improve code style in ray.h
- 2 spaces instead of 4, for indentation
- Newline after return
- Check if pointer is null
2020-04-03 13:03:46 +02:00
Uwila
eb332acd7e Merge branch 'master' into ray-triangle-intersection 2020-04-02 14:33:57 +02:00
Uwila
c67f7a14a1 Add ray-triangle intersection check 2020-04-02 14:28:28 +02:00
FMMazur
83f6db1bf8 CMake: Fix install error 2020-03-27 18:43:28 -04:00
FMMazur
e493149a0a CMake: Fix errors 2020-03-27 16:04:46 -04:00
FMMazur
38019f0913 CMake: add lib and include install path 2020-03-27 15:57:26 -04:00
FMMazur
bc6b751429 CMake: add install path option 2020-03-27 15:50:37 -04:00
FMMazur
be68d57499 CMake: Added 'make check' as alias to 'make test' 2020-03-27 15:31:55 -04:00
FMMazur
1fb5f89eaa CMake: Change c99 to c11 and shared build as default options. 2020-03-27 15:30:03 -04:00
FMMazur
6470a91265 Merge branch 'cmake' of https://github.com/FMMazur/cglm into cmake 2020-03-27 11:22:48 -04:00
FMMazur
d4235b2431 CMake: Added test configuration 2020-03-27 11:19:56 -04:00
FMMazur
0ef028244a CMake: Added LDFlags Configuration 2020-03-27 09:11:08 -04:00
FMMazur
a8543bc813 Added folder build/ to .gitignore 2020-03-27 09:02:52 -04:00
Felipe Munoz Mazur
cf3888d734 Update README.md
Document CMake Usage and Project Example
2020-03-27 00:12:47 -04:00
FMMazur
b8e978862e Added install to CMakeLists.txt 2020-03-27 00:04:15 -04:00
FMMazur
dfba2072f7 Added simple CMakeLists.txt 2020-03-26 23:36:20 -04:00
Uwila
2bf576c2cd Fix documentation mistake for glm_vec3_rotate (#126)
In the documentation, for glm_vec3_rotate, correctly labels `angle` as `in` rather than `out`.

Co-authored-by: Recep Aslantas <info@recp.me>
2020-03-20 22:58:48 +03:00
Uwila
3abf47f175 Make Github recognize header language as C (#127)
Without this a lot of `*.h` files are marked as being C++ or Objective-C, even though all of it is C.
2020-03-20 22:56:17 +03:00
Recep Aslantas
2fc51c67a3 Update version.rst 2020-03-19 12:58:48 +03:00
Recep Aslantas
34753546f2 Update version.rst 2020-03-19 12:55:49 +03:00
Recep Aslantas
1711db4fef Update util.rst 2020-03-19 12:54:57 +03:00
Recep Aslantas
373b8d216a Update version.rst 2020-03-19 12:53:54 +03:00
Recep Aslantas
7f9487fd62 docs: update documentation 2020-03-19 12:51:05 +03:00
Recep Aslantas
686deb8eb1 util: use glm_clamp_zo to clamp between 0 and 1 2020-03-19 12:37:52 +03:00
Uwila
a392ac3012 Fix small documentation mistake (#125)
At two points in the documentation the names of the parameters in the parameters list do not match the parameter names in the function:
- glm_look
- glm_look_anyup
2020-03-12 09:47:05 +03:00
Recep Aslantas
fabc655919 Merge branch 'master' of https://github.com/recp/cglm 2020-03-06 23:33:30 +03:00
Recep Aslantas
7eada03909 reemove redundant forward declerations 2020-03-06 23:33:27 +03:00
Zollerboy1
ad4a763d47 fix glms_vec2_rotate() by using a dest vec2s instead of taking an axis vector (#122) 2020-03-04 17:05:32 +03:00
Zollerboy1
1f9765c5e5 fix glms_sphere_transform by using mat4s instead of mat4 (#121)
Co-authored-by: Recep Aslantas <m@recp.me>
2020-03-04 11:56:40 +03:00
Recep Aslantas
b3a464bf89 now working on v0.7.2 2020-03-04 11:51:05 +03:00
Recep Aslantas
69b5584f11 build: add missing headers 2020-03-02 10:09:48 +03:00
Recep Aslantas
00523f0b89 helper to swap two float values 2020-03-01 12:56:11 +03:00
Recep Aslantas
31f313caff now working on v0.7.1 2020-02-29 14:00:50 +03:00
Recep Aslantas
010b88ee7a set version to v0.7.0 for vec2/mat2 release 2020-02-25 22:13:25 +03:00
Recep Aslantas
702da626f1 docs: add documentation for vec2 and mat2 2020-02-25 22:11:10 +03:00
Recep Aslantas
8e008511f4 Merge pull request #97 from recp/vec2_mat2
vec2 and mat2 support
2020-02-25 14:54:22 +03:00
Recep Aslantas
eb0d47cfa1 vec2: add struct version for vec2 and vec2-ext 2020-02-25 14:34:11 +03:00
Recep Aslantas
638b9f6dbe fix 'function declaration isn’t a prototype' 2020-02-24 23:11:03 +03:00
Recep Aslantas
ab20ebc28c build: add vec2 and mat2 files 2020-02-24 22:22:27 +03:00
Recep Aslantas
701a95583a vec2: fix memory access error[s] 2020-02-24 22:21:43 +03:00
Recep Aslantas
ad9370537c add tests for mat2 and its call version 2020-02-24 22:14:26 +03:00
Recep Aslantas
43ae3b332a add tests for vec2 and its call version 2020-02-24 10:06:19 +03:00
Recep Aslantas
8a068c3291 Merge branch 'master' into vec2_mat2 2020-02-23 13:10:36 +03:00
Recep Aslantas
4a7c153d2d tests: fix test for mul_rot 2020-02-23 11:19:30 +03:00
Recep Aslantas
7b0f62f1eb tests: add some tests for affine matrices 2020-02-22 10:54:47 +03:00
Recep Aslantas
0c8dc070d5 tests: tests for affine transforms (continue) 2020-02-22 10:29:16 +03:00
Recep Aslantas
0822d46cd9 tests: tests for remaining rotations 2020-02-22 00:58:04 +03:00
Recep Aslantas
3fca734c30 tests: remove unused variables 2020-02-22 00:48:41 +03:00
Recep Aslantas
5995269195 tests: add tests for some affine rotations 2020-02-21 17:52:50 +03:00
Recep Aslantas
6b32b5dc35 tests: add tests for affine scales 2020-02-21 16:57:09 +03:00
Recep Aslantas
a1f7afe055 Update test_affine.h 2020-02-21 15:56:15 +03:00
Recep Aslantas
81ae182972 tests: add tests for affine translations 2020-02-21 15:52:34 +03:00
Recep Aslantas
de85a4eb2b quat: add tests for quat_rotate_at[m] 2020-02-21 14:28:41 +03:00
Recep Aslantas
8ac1347f8a remove unused params from docs 2020-02-21 12:55:52 +03:00
Recep Aslantas
e7a0906bc2 quat: add tests for quat_rotate 2020-02-21 11:48:25 +03:00
Recep Aslantas
6aa8df8e9b quat: add tests for quat_rotatev 2020-02-21 10:51:53 +03:00
Recep Aslantas
2278eba93c quat: fix quat_for and quat_forp implementations 2020-02-20 23:37:35 +03:00
Recep Aslantas
5ee9bb88df add notes for versor/quaternion type to describe memory layout 2020-02-20 17:29:32 +03:00
Recep Aslantas
349dc274f4 add forward vector as macro (vec3, RH)
* this will be used for where Vec3.Forward is needed
2020-02-20 15:19:20 +03:00
Recep Aslantas
b9f9548b06 test: test for plane 2020-01-19 22:15:19 +03:00
Recep Aslantas
c630293c7d merge test sources into one C source 2020-01-19 22:12:25 +03:00
Recep Aslantas
406d09e085 make plane zero if norm is zero after normalization 2020-01-19 21:48:55 +03:00
Recep Aslantas
65de029acb now working on v0.6.3 2020-01-19 20:37:49 +03:00
Recep Aslantas
b46a4ccee5 Merge branch 'vec2_mat2' of https://github.com/recp/cglm into vec2_mat2 2019-09-01 17:12:12 +03:00
Recep Aslantas
5da864f345 Merge branch 'master' into vec2_mat2 2019-09-01 17:10:28 +03:00
Recep Aslantas
3640e402da mat2 struct version 2019-08-31 14:36:57 +03:00
Recep Aslantas
d86f5df776 vec: call version for vec2 2019-08-30 22:56:20 +03:00
Recep Aslantas
cb54a8b8c5 vec2: rotate vec2 by angle 2019-08-30 22:00:20 +03:00
Recep Aslantas
8cb6fa792c Merge branch 'master' into vec2_mat2 2019-08-30 21:34:23 +03:00
Recep Aslantas
ef89cd7236 Merge branch 'master' into vec2_mat2 2019-08-22 15:16:35 +03:00
Recep Aslantas
a4c7c5e1ba implement call version for mat2 2019-06-21 23:17:08 +03:00
Recep Aslantas
2827fbfa79 mat2, vec2: add missing functions 2019-06-20 22:51:51 +03:00
Recep Aslantas
ad823d9681 mat2: implement some mat2 func
* also implement as SSE
2019-06-19 23:35:38 +03:00
Recep Aslantas
047ed259ae vec2: distance implementation 2019-06-04 19:03:31 +03:00
Recep Aslantas
0729fd40a4 implement vec2 2019-03-31 18:50:52 +03:00
345 changed files with 49235 additions and 3527 deletions

1
.gitattributes vendored Normal file
View File

@@ -0,0 +1 @@
*.h linguist-language=C

4
.github/FUNDING.yml vendored
View File

@@ -1,7 +1,7 @@
# These are supported funding model platforms
github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
patreon: # Replace with a single Patreon username
github: [recp]
patreon: recp
open_collective: cglm
ko_fi: # Replace with a single Ko-fi username
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel

645
.github/workflows/ci.yml vendored Normal file
View File

@@ -0,0 +1,645 @@
name: CI
on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]
jobs:
build_autotools:
name: Autotools / ${{ matrix.os }} / ${{ matrix.simd }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
# x86/x64 builds
- { os: macos-13, simd: none }
- { os: macos-13, simd: sse }
- { os: macos-13, simd: sse2 }
- { os: macos-13, simd: sse3 }
- { os: macos-13, simd: sse4 }
- { os: macos-13, simd: avx }
- { os: macos-13, simd: avx2 }
- { os: macos-14, simd: none }
- { os: macos-14, simd: sse }
- { os: macos-14, simd: sse2 }
- { os: macos-14, simd: sse3 }
- { os: macos-14, simd: sse4 }
- { os: macos-14, simd: avx }
- { os: macos-14, simd: avx2 }
- { os: ubuntu-22.04, simd: none }
- { os: ubuntu-22.04, simd: sse }
- { os: ubuntu-22.04, simd: sse2 }
- { os: ubuntu-22.04, simd: sse3 }
- { os: ubuntu-22.04, simd: sse4 }
- { os: ubuntu-22.04, simd: avx }
- { os: ubuntu-22.04, simd: avx2 }
- { os: ubuntu-24.04, simd: none }
- { os: ubuntu-24.04, simd: sse }
- { os: ubuntu-24.04, simd: sse2 }
- { os: ubuntu-24.04, simd: sse3 }
- { os: ubuntu-24.04, simd: sse4 }
- { os: ubuntu-24.04, simd: avx }
- { os: ubuntu-24.04, simd: avx2 }
# ARM64 builds
- { os: ubuntu-latest-arm64, simd: neon }
steps:
- uses: actions/checkout@v4
- name: Install Autotools on macOS
if: runner.os == 'macOS'
run: brew upgrade && brew install autoconf automake libtool
- name: Install Autotools on Ubuntu
if: matrix.os == 'ubuntu-22.04' || matrix.os == 'ubuntu-24.04'
run: sudo apt-get install -y autoconf automake libtool
- name: Set SIMD flags
run: |
if [ "${{ matrix.simd }}" == "none" ]; then
export CFLAGS=""
elif [ "${{ matrix.simd }}" == "sse" ]; then
export CFLAGS="-msse"
elif [ "${{ matrix.simd }}" == "sse2" ]; then
export CFLAGS="-msse2"
elif [ "${{ matrix.simd }}" == "sse3" ]; then
export CFLAGS="-msse3"
elif [ "${{ matrix.simd }}" == "sse4" ]; then
export CFLAGS="-msse4"
elif [ "${{ matrix.simd }}" == "avx" ]; then
export CFLAGS="-mavx"
elif [ "${{ matrix.simd }}" == "avx2" ]; then
export CFLAGS="-mavx2"
elif [ "${{ matrix.simd }}" == "neon" ]; then
export CFLAGS="-mfpu=neon"
fi
- name: Generate Autotools
run: ./autogen.sh
- name: Configure Autotools
run: ./configure CFLAGS="$CFLAGS"
- name: Build
run: make
- name: Test
run: make check
build_cmake_ios:
name: CMake / iOS
runs-on: macos-14
steps:
- uses: actions/checkout@v4
- name: Configure CMake
run: |
cmake \
-B build \
-GXcode \
-DCMAKE_SYSTEM_NAME=iOS \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_ALLOWED=NO \
-DCGLM_STATIC=ON \
-DCGLM_USE_TEST=ON
- name: Build
run: cmake --build build
build_cmake_ubuntu:
name: CMake / ${{ matrix.target.os }} / ${{ matrix.target.cc }} / ${{ matrix.target.arch }} / ${{ matrix.target.simd }}
runs-on: ${{ matrix.target.arch == 'arm64' && 'ubuntu-latest-arm64' || matrix.target.os }}
strategy:
fail-fast: false
matrix:
target:
# GCC 11 builds
- { os: ubuntu-20.04, cc: gcc-11, arch: x64, simd: none }
- { os: ubuntu-20.04, cc: gcc-11, arch: x64, simd: sse }
- { os: ubuntu-20.04, cc: gcc-11, arch: x64, simd: sse2 }
- { os: ubuntu-20.04, cc: gcc-11, arch: x64, simd: sse3 }
- { os: ubuntu-20.04, cc: gcc-11, arch: x64, simd: sse4 }
- { os: ubuntu-20.04, cc: gcc-11, arch: x64, simd: avx }
- { os: ubuntu-20.04, cc: gcc-11, arch: x64, simd: avx2 }
# GCC 12 builds
- { os: ubuntu-22.04, cc: gcc-12, arch: x64, simd: none }
- { os: ubuntu-22.04, cc: gcc-12, arch: x64, simd: sse }
- { os: ubuntu-22.04, cc: gcc-12, arch: x64, simd: sse2 }
- { os: ubuntu-22.04, cc: gcc-12, arch: x64, simd: sse3 }
- { os: ubuntu-22.04, cc: gcc-12, arch: x64, simd: sse4 }
- { os: ubuntu-22.04, cc: gcc-12, arch: x64, simd: avx }
- { os: ubuntu-22.04, cc: gcc-12, arch: x64, simd: avx2 }
# GCC 13 builds
- { os: ubuntu-24.04, cc: gcc-13, arch: x64, simd: none }
- { os: ubuntu-24.04, cc: gcc-13, arch: x64, simd: sse }
- { os: ubuntu-24.04, cc: gcc-13, arch: x64, simd: sse2 }
- { os: ubuntu-24.04, cc: gcc-13, arch: x64, simd: sse3 }
- { os: ubuntu-24.04, cc: gcc-13, arch: x64, simd: sse4 }
- { os: ubuntu-24.04, cc: gcc-13, arch: x64, simd: avx }
- { os: ubuntu-24.04, cc: gcc-13, arch: x64, simd: avx2 }
# Clang 12 builds
- { os: ubuntu-20.04, cc: clang-12, arch: x64, simd: none }
- { os: ubuntu-20.04, cc: clang-12, arch: x64, simd: sse }
- { os: ubuntu-20.04, cc: clang-12, arch: x64, simd: sse2 }
- { os: ubuntu-20.04, cc: clang-12, arch: x64, simd: sse3 }
- { os: ubuntu-20.04, cc: clang-12, arch: x64, simd: sse4 }
- { os: ubuntu-20.04, cc: clang-12, arch: x64, simd: avx }
- { os: ubuntu-20.04, cc: clang-12, arch: x64, simd: avx2 }
# Clang 15 builds
- { os: ubuntu-22.04, cc: clang-15, arch: x64, simd: none }
- { os: ubuntu-22.04, cc: clang-15, arch: x64, simd: sse }
- { os: ubuntu-22.04, cc: clang-15, arch: x64, simd: sse2 }
- { os: ubuntu-22.04, cc: clang-15, arch: x64, simd: sse3 }
- { os: ubuntu-22.04, cc: clang-15, arch: x64, simd: sse4 }
- { os: ubuntu-22.04, cc: clang-15, arch: x64, simd: avx }
- { os: ubuntu-22.04, cc: clang-15, arch: x64, simd: avx2 }
# ARM64 builds
- { os: ubuntu-latest, cc: gcc-12, arch: arm64, simd: neon }
- { os: ubuntu-latest, cc: gcc-13, arch: arm64, simd: neon }
# ARMv7 builds
- { os: ubuntu-latest-arm64, cc: gcc-12, arch: armv7, simd: neon }
- { os: ubuntu-latest-arm64, cc: gcc-12, arch: armv7, simd: none }
steps:
- uses: actions/checkout@v4
- name: Add Ubuntu Toolchain PPA
if: matrix.target.os == 'ubuntu-20.04'
run: |
sudo apt-get update
sudo apt-get install -y software-properties-common
sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
sudo apt-get update
- name: Install Compiler and Ninja
run: |
sudo apt-get install -y ${{ matrix.target.cc }} ninja-build
- name: Set SIMD flags
run: |
if [ "${{ matrix.simd }}" == "none" ]; then
export CFLAGS=""
elif [ "${{ matrix.simd }}" == "sse" ]; then
export CFLAGS="-msse"
elif [ "${{ matrix.simd }}" == "sse2" ]; then
export CFLAGS="-msse2"
elif [ "${{ matrix.simd }}" == "sse3" ]; then
export CFLAGS="-msse3"
elif [ "${{ matrix.simd }}" == "sse4" ]; then
export CFLAGS="-msse4"
elif [ "${{ matrix.simd }}" == "avx" ]; then
export CFLAGS="-mavx"
elif [ "${{ matrix.simd }}" == "avx2" ]; then
export CFLAGS="-mavx2"
elif [ "${{ matrix.simd }}" == "neon" ]; then
export CFLAGS="-mfpu=neon"
fi
- name: Configure CMake
run: |
if [ "${{ matrix.target.arch }}" == "armv7" ]; then
# Build for ARMv7
neon_flags=""
if [ "${{ matrix.simd }}" == "neon" ]; then
neon_flags="-mfpu=neon -mfloat-abi=hard"
fi
cmake -B build -GNinja -DCMAKE_BUILD_TYPE=Release \
-DCMAKE_C_COMPILER=${{ matrix.target.cc }} \
-DCMAKE_C_FLAGS="$CFLAGS -m32 -march=armv7-a ${neon_flags}" \
-DCGLM_STATIC=ON -DCGLM_USE_TEST=ON
elif [ "${{ matrix.target.arch }}" == "arm64" ]; then
# Build for ARM64 (AArch64)
neon_flags=""
if [ "${{ matrix.simd }}" == "neon" ]; then
neon_flags="+simd" # Enable SIMD/NEON features on ARM64
else
neon_flags="+nosimd" # Explicitly disable SIMD/NEON
fi
cmake -B build -GNinja -DCMAKE_BUILD_TYPE=Release \
-DCMAKE_C_COMPILER=${{ matrix.target.cc }} \
-DCMAKE_C_FLAGS="$CFLAGS -march=armv8-a${neon_flags}" \
-DCGLM_STATIC=ON -DCGLM_USE_TEST=ON
else
# Normal build (x86/x64)
cmake -B build -GNinja -DCMAKE_BUILD_TYPE=Release \
-DCMAKE_C_COMPILER=${{ matrix.target.cc }} \
-DCMAKE_C_FLAGS="$CFLAGS" \
-DCGLM_STATIC=ON -DCGLM_USE_TEST=ON
fi
- name: Build
run: cmake --build build
- name: Test
working-directory: build
run: ./tests
build_cmake_macos:
name: CMake / ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [macos-13, macos-14]
steps:
- uses: actions/checkout@v4
- name: Install Ninja
if: runner.os == 'macOS'
run: brew upgrade && brew install ninja
- name: Configure CMake
run: |
cmake \
-B build \
-GNinja \
-DCMAKE_BUILD_TYPE=Release \
-DCGLM_STATIC=ON \
-DCGLM_USE_TEST=ON
- name: Build
run: cmake --build build
- name: Test
working-directory: build
run: ./tests
build_cmake:
name: CMake / ${{ matrix.os }} / ${{ matrix.simd }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
# x86/x64 builds
- { os: macos-13, simd: none }
- { os: macos-13, simd: sse }
- { os: macos-13, simd: sse2 }
- { os: macos-13, simd: sse3 }
- { os: macos-13, simd: sse4 }
- { os: macos-13, simd: avx }
- { os: macos-13, simd: avx2 }
- { os: macos-14, simd: none }
- { os: macos-14, simd: sse }
- { os: macos-14, simd: sse2 }
- { os: macos-14, simd: sse3 }
- { os: macos-14, simd: sse4 }
- { os: macos-14, simd: avx }
- { os: macos-14, simd: avx2 }
- { os: windows-2022, simd: none }
- { os: windows-2022, simd: sse }
- { os: windows-2022, simd: sse2 }
- { os: windows-2022, simd: sse3 }
- { os: windows-2022, simd: sse4 }
- { os: windows-2022, simd: avx }
- { os: windows-2022, simd: avx2 }
# ARM64 builds
- { os: macos-14-arm64, simd: neon }
steps:
- uses: actions/checkout@v4
- name: Install Ninja on macOS
if: runner.os == 'macOS'
run: brew upgrade && brew install ninja
- name: Set SIMD flags (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: |
$simd = "${{ matrix.simd }}"
if ($simd -eq "none") {
$env:CFLAGS = ""
} elseif ($simd -eq "sse") {
$env:CFLAGS = "-arch:SSE"
} elseif ($simd -eq "sse2") {
$env:CFLAGS = "-arch:SSE2"
} elseif ($simd -eq "sse3") {
$env:CFLAGS = "-arch:SSE3"
} elseif ($simd -eq "sse4") {
$env:CFLAGS = "-arch:SSE4"
} elseif ($simd -eq "avx") {
$env:CFLAGS = "-arch:AVX"
} elseif ($simd -eq "avx2") {
$env:CFLAGS = "-arch:AVX2"
} elseif ($simd -eq "neon") {
$env:CFLAGS = "-arch:NEON"
}
- name: Set SIMD flags (Unix)
if: runner.os != 'Windows'
shell: bash
run: |
if [ "${{ matrix.simd }}" == "none" ]; then
export CFLAGS=""
elif [ "${{ matrix.simd }}" == "sse" ]; then
export CFLAGS="-msse"
elif [ "${{ matrix.simd }}" == "sse2" ]; then
export CFLAGS="-msse2"
elif [ "${{ matrix.simd }}" == "sse3" ]; then
export CFLAGS="-msse3"
elif [ "${{ matrix.simd }}" == "sse4" ]; then
export CFLAGS="-msse4"
elif [ "${{ matrix.simd }}" == "avx" ]; then
export CFLAGS="-mavx"
elif [ "${{ matrix.simd }}" == "avx2" ]; then
export CFLAGS="-mavx2"
elif [ "${{ matrix.simd }}" == "neon" ]; then
export CFLAGS="-mfpu=neon"
fi
- name: Configure CMake (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: cmake -B build -G "Visual Studio 17 2022" -A x64 -T host=x64 -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_FLAGS="$env:CFLAGS" -DCGLM_STATIC=ON -DCGLM_USE_TEST=ON
- name: Configure CMake (Unix)
if: runner.os != 'Windows'
shell: bash
run: cmake -B build -GNinja -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_FLAGS="$CFLAGS" -DCGLM_STATIC=ON -DCGLM_USE_TEST=ON
- name: Build
run: cmake --build build
- name: Test (Windows)
if: runner.os == 'Windows'
shell: pwsh
working-directory: build
run: .\Debug\tests.exe
- name: Test (Unix)
if: runner.os != 'Windows'
shell: bash
working-directory: build
run: ./tests
build_meson:
name: Meson / ${{ matrix.os }} / ${{ matrix.simd }}
runs-on: ${{ contains(matrix.os, 'arm64') && 'ubuntu-latest-arm64' || matrix.os }}
strategy:
fail-fast: false
matrix:
include:
# x86/x64 builds
- { os: macos-14, simd: none }
- { os: macos-14, simd: sse }
- { os: macos-14, simd: sse2 }
- { os: macos-14, simd: sse3 }
- { os: macos-14, simd: sse4 }
- { os: macos-14, simd: avx }
- { os: macos-14, simd: avx2 }
- { os: ubuntu-22.04, simd: none }
- { os: ubuntu-22.04, simd: sse }
- { os: ubuntu-22.04, simd: sse2 }
- { os: ubuntu-22.04, simd: sse3 }
- { os: ubuntu-22.04, simd: sse4 }
- { os: ubuntu-22.04, simd: avx }
- { os: ubuntu-22.04, simd: avx2 }
- { os: ubuntu-24.04, simd: none }
- { os: ubuntu-24.04, simd: sse }
- { os: ubuntu-24.04, simd: sse2 }
- { os: ubuntu-24.04, simd: sse3 }
- { os: ubuntu-24.04, simd: sse4 }
- { os: ubuntu-24.04, simd: avx }
- { os: ubuntu-24.04, simd: avx2 }
- { os: windows-2022, simd: none }
- { os: windows-2022, simd: sse }
- { os: windows-2022, simd: sse2 }
- { os: windows-2022, simd: sse3 }
- { os: windows-2022, simd: sse4 }
- { os: windows-2022, simd: avx }
- { os: windows-2022, simd: avx2 }
# ARM64 builds
- { os: ubuntu-latest-arm64, simd: neon }
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.12'
cache: 'pip'
- name: Install meson
run: python3 -m pip install meson ninja
- name: Set SIMD flags (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: |
$simd = "${{ matrix.simd }}"
if ($simd -eq "none") {
$env:CFLAGS = ""
} elseif ($simd -eq "sse") {
$env:CFLAGS = "-arch:SSE"
} elseif ($simd -eq "sse2") {
$env:CFLAGS = "-arch:SSE2"
} elseif ($simd -eq "sse3") {
$env:CFLAGS = "-arch:SSE3"
} elseif ($simd -eq "sse4") {
$env:CFLAGS = "-arch:SSE4"
} elseif ($simd -eq "avx") {
$env:CFLAGS = "-arch:AVX"
} elseif ($simd -eq "avx2") {
$env:CFLAGS = "-arch:AVX2"
} elseif ($simd -eq "neon") {
$env:CFLAGS = "-arch:NEON"
}
- name: Set SIMD flags (Unix)
if: runner.os != 'Windows'
shell: bash
run: |
if [ "${{ matrix.simd }}" == "none" ]; then
export CFLAGS=""
elif [ "${{ matrix.simd }}" == "sse" ]; then
export CFLAGS="-msse"
elif [ "${{ matrix.simd }}" == "sse2" ]; then
export CFLAGS="-msse2"
elif [ "${{ matrix.simd }}" == "sse3" ]; then
export CFLAGS="-msse3"
elif [ "${{ matrix.simd }}" == "sse4" ]; then
export CFLAGS="-msse4"
elif [ "${{ matrix.simd }}" == "avx" ]; then
export CFLAGS="-mavx"
elif [ "${{ matrix.simd }}" == "avx2" ]; then
export CFLAGS="-mavx2"
elif [ "${{ matrix.simd }}" == "neon" ]; then
export CFLAGS="-mfpu=neon"
fi
- name: Build with meson (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: |
meson setup build -Dbuildtype=release --default-library=static -Dbuild_tests=true -Dc_args="$env:CFLAGS"
meson test -C build
- name: Build with meson (Unix)
if: runner.os != 'Windows'
shell: bash
run: |
meson setup build -Dbuildtype=release --default-library=static -Dbuild_tests=true -Dc_args="$CFLAGS"
meson test -C build
build_msbuild:
name: MSBuild / Windows / ${{ matrix.simd }}
runs-on: windows-2022
strategy:
fail-fast: false
matrix:
simd: [none, sse, sse2, sse3, sse4, avx, avx2, neon]
steps:
- uses: actions/checkout@v4
- uses: microsoft/setup-msbuild@v2
- name: Retarget solution
run: |
vswhere -latest -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath
$vsInstallPath = vswhere -latest -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath
& "$vsInstallPath\Common7\IDE\devenv.com" cglm.sln /Upgrade
- name: Set SIMD flags
run: |
if ($Env:SIMD -eq 'none') {
$Env:CFLAGS=""
} elseif ($Env:SIMD -eq 'sse') {
$Env:CFLAGS="-arch:SSE"
} elseif ($Env:SIMD -eq 'sse2') {
$Env:CFLAGS="-arch:SSE2"
} elseif ($Env:SIMD -eq 'sse3') {
$Env:CFLAGS="-arch:SSE3"
} elseif ($Env:SIMD -eq 'sse4') {
$Env:CFLAGS="-arch:SSE4"
} elseif ($Env:SIMD -eq 'avx') {
$Env:CFLAGS="-arch:AVX"
} elseif ($Env:SIMD -eq 'avx2') {
$Env:CFLAGS="-arch:AVX2"
} elseif ($Env:SIMD -eq 'neon') {
$Env:CFLAGS="-arch:NEON"
}
- name: Build (x86)
working-directory: win
run: msbuild cglm.vcxproj /p:Configuration=Release /p:Platform=x86 /p:PlatformToolset=v143 /p:BuildInParallel=true /p:AdditionalOptions="$Env:CFLAGS"
- name: Build (x64)
working-directory: win
run: msbuild cglm.vcxproj /p:Configuration=Release /p:Platform=x64 /p:PlatformToolset=v143 /p:BuildInParallel=true /p:AdditionalOptions="$Env:CFLAGS"
build_documentation:
name: Documentation
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Install Dependencies
working-directory: docs
run: python3 -m pip install -r requirements.txt
- name: Build
working-directory: docs
run: sphinx-build -W --keep-going source build
build_swift:
name: Swift ${{ matrix.swift }} / ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [macos-13, macos-14, ubuntu-22.04]
# This has no test yet.
steps:
- uses: actions/checkout@v4
- name: Build
run: swift build
build_cmake_arm:
name: CMake / ARM / ${{ matrix.os }} / ${{ matrix.arch }} / ${{ matrix.simd }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
# Linux ARM builds
- os: ubuntu-latest-arm64
arch: arm64
simd: neon
- os: ubuntu-latest-arm64
arch: armv7
simd: neon
- os: ubuntu-latest-arm64
arch: armv7
simd: none
# Windows ARM builds
- os: windows-latest-arm64
arch: arm64
simd: neon
- os: windows-latest-arm64
arch: arm
simd: neon
- os: windows-latest-arm64
arch: arm
simd: none
steps:
- uses: actions/checkout@v4
- name: Configure CMake (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: |
$flags = ""
if ("${{ matrix.arch }}" -eq "arm") {
$flags = "-m32 -march=armv7-a"
if ("${{ matrix.simd }}" -eq "neon") {
$flags += " -mfpu=neon"
}
}
elseif ("${{ matrix.simd }}" -eq "neon") {
$flags = "-march=armv8-a+simd"
}
cmake -B build -G "Visual Studio 17 2022" -A ${{ matrix.arch == 'arm64' && 'ARM64' || 'ARM' }} `
-DCMAKE_BUILD_TYPE=Release `
-DCMAKE_C_FLAGS="$flags" `
-DCGLM_STATIC=ON -DCGLM_USE_TEST=ON
- name: Configure CMake (Unix)
if: runner.os != 'Windows'
shell: bash
run: |
flags=""
if [ "${{ matrix.arch }}" = "armv7" ]; then
flags="-m32 -march=armv7-a"
if [ "${{ matrix.simd }}" = "neon" ]; then
flags="$flags -mfpu=neon -mfloat-abi=hard"
fi
elif [ "${{ matrix.simd }}" = "neon" ]; then
flags="-march=armv8-a+simd"
fi
cmake -B build -GNinja -DCMAKE_BUILD_TYPE=Release \
-DCMAKE_C_FLAGS="$flags" \
-DCGLM_STATIC=ON -DCGLM_USE_TEST=ON
- name: Build
run: cmake --build build
- name: Test
working-directory: build
run: ./tests

107
.github/workflows/cmake-wasm.yml vendored Normal file
View File

@@ -0,0 +1,107 @@
name: CMake WebAssembly
on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]
env:
wasmtime_version: v7.0.0
wasmer_version: v3.1.1
jobs:
build_wasi_sdk:
strategy:
matrix:
BUILD_TYPE: [Release, Debug, RelWithDebInfo, MinSizeRel]
C_FLAGS: ['', '-msimd128']
wasi_sdk_version: [19, 20]
# The CMake configure and build commands are platform agnostic and should work equally well on Windows or Mac.
# You can convert this to a matrix build if you need cross-platform coverage.
# See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Downloading wasi-sdk
run: |
cd ${{github.workspace}}
wget --no-verbose https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-${{matrix.wasi_sdk_version}}/wasi-sdk-${{matrix.wasi_sdk_version}}.0-linux.tar.gz
tar xf wasi-sdk-${{matrix.wasi_sdk_version}}.0-linux.tar.gz
# Building a wasm library without needing to define a main():
# https://github.com/WebAssembly/wasi-sdk/issues/332
- name: Modify CMakeLists.txt for WASI
run: |
echo 'if (CMAKE_SYSTEM_NAME STREQUAL "WASI")' >> CMakeLists.txt
echo ' target_link_options(${PROJECT_NAME} PRIVATE -mexec-model=reactor)' >> CMakeLists.txt
echo 'endif()' >> CMakeLists.txt
- name: Configure CMake
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
# Below suppress <<'clock' is deprecated: WASI lacks process-associated clocks; ...>> warns:
# -D_WASI_EMULATED_PROCESS_CLOCKS" -DCMAKE_EXE_LINKER_FLAGS="-lwasi-emulated-process-clocks
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{matrix.BUILD_TYPE}} -DCMAKE_C_FLAGS="${{matrix.C_FLAGS}} -D_WASI_EMULATED_PROCESS_CLOCKS" -DCMAKE_EXE_LINKER_FLAGS="-lwasi-emulated-process-clocks" -DCMAKE_TOOLCHAIN_FILE=${{github.workspace}}/wasi-sdk-${{matrix.wasi_sdk_version}}.0/share/cmake/wasi-sdk.cmake -DWASI_SDK_PREFIX=${{github.workspace}}/wasi-sdk-${{matrix.wasi_sdk_version}}.0 -DCGLM_STATIC=ON -DCGLM_SHARED=OFF -DCGLM_USE_TEST=ON
- name: Build
# Build your program with the given configuration
run: cmake --build ${{github.workspace}}/build --config ${{matrix.BUILD_TYPE}}
- name: Test with wasmtime
run: |
cd ${{github.workspace}}
ls -lh ${{github.workspace}}/build/
wget --no-verbose https://github.com/bytecodealliance/wasmtime/releases/download/${{env.wasmtime_version}}/wasmtime-${{env.wasmtime_version}}-x86_64-linux.tar.xz
tar xf wasmtime-${{env.wasmtime_version}}-x86_64-linux.tar.xz
./wasmtime-${{env.wasmtime_version}}-x86_64-linux/wasmtime run --wasm-features simd ${{github.workspace}}/build/tests
- name: Test with wasmer
run: |
cd ${{github.workspace}}
mkdir wasmer
cd wasmer
wget --no-verbose https://github.com/wasmerio/wasmer/releases/download/${{env.wasmer_version}}/wasmer-linux-amd64.tar.gz
tar xf wasmer-linux-amd64.tar.gz
./bin/wasmer run --enable-simd ${{github.workspace}}/build/tests
build_emsdk:
strategy:
matrix:
BUILD_TYPE: [Release, Debug, RelWithDebInfo, MinSizeRel]
C_FLAGS: ['', '-msimd128', '-msse -msse2 -msimd128', '-msse -msse2 -msse3 -msse4 -msimd128']
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup emsdk
uses: mymindstorm/setup-emsdk@v12
- name: Verify emsdk
run: emcc -v
- name: Configure CMake
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
run: emcmake cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{matrix.BUILD_TYPE}} -DCMAKE_C_FLAGS="${{matrix.C_FLAGS}}" -DCMAKE_EXE_LINKER_FLAGS="-s STANDALONE_WASM" -DCGLM_STATIC=ON -DCGLM_USE_TEST=ON
- name: Build
# Build your program with the given configuration
run: cmake --build ${{github.workspace}}/build --config ${{matrix.BUILD_TYPE}}
- name: Test with wasmtime
run: |
cd ${{github.workspace}}
ls -lh ${{github.workspace}}/build/
wget --no-verbose https://github.com/bytecodealliance/wasmtime/releases/download/${{env.wasmtime_version}}/wasmtime-${{env.wasmtime_version}}-x86_64-linux.tar.xz
tar xf wasmtime-${{env.wasmtime_version}}-x86_64-linux.tar.xz
./wasmtime-${{env.wasmtime_version}}-x86_64-linux/wasmtime run --wasm-features simd ${{github.workspace}}/build/tests.wasm
- name: Test with wasmer
run: |
cd ${{github.workspace}}
mkdir wasmer
cd wasmer
wget --no-verbose https://github.com/wasmerio/wasmer/releases/download/${{env.wasmer_version}}/wasmer-linux-amd64.tar.gz
tar xf wasmer-linux-amd64.tar.gz
./bin/wasmer run --enable-simd ${{github.workspace}}/build/tests.wasm

79
.github/workflows/meson-wasm.yml vendored Normal file
View File

@@ -0,0 +1,79 @@
name: Meson WebAssembly
on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]
env:
wasmtime_version: v7.0.0
wasmer_version: v3.1.1
jobs:
build_emsdk:
strategy:
matrix:
BUILD_TYPE: [debug, debugoptimized, release, minsize]
C_FLAGS: ['', '-msimd128', '-msse -msse2 -msimd128', '-msse -msse2 -msse3 -msse4 -msimd128']
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup emsdk
uses: mymindstorm/setup-emsdk@v13
- name: Verify emsdk
run: emcc -v
- name: Creating cross file
run: |
cat << EOF > ${{github.workspace}}/meson_cross_emsdk.txt
[binaries]
c = '`which emcc`'
cpp = '`which em++`'
ar = '`which emar`'
[built-in options]
c_args = ['-Wno-unused-parameter']
c_link_args = ['-s', 'STANDALONE_WASM']
cpp_args = ['-Wno-unused-parameter']
cpp_link_args = ['-s', 'STANDALONE_WASM']
[host_machine]
system = 'emscripten'
cpu_family = 'wasm32'
cpu = 'wasm32'
endian = 'little'
EOF
cat ${{github.workspace}}/meson_cross_emsdk.txt
- uses: actions/setup-python@v4
- name: Install meson
run: |
sudo python3 -m pip install meson ninja
- name: Build with meson
run: |
meson setup build -Dbuildtype=${{matrix.BUILD_TYPE}} --cross-file ${{github.workspace}}/meson_cross_emsdk.txt --default-library=static -Dbuild_tests=true
meson test -C build
- name: Test with wasmtime
run: |
cd ${{github.workspace}}
ls -lh ${{github.workspace}}/build/
wget --no-verbose https://github.com/bytecodealliance/wasmtime/releases/download/${{env.wasmtime_version}}/wasmtime-${{env.wasmtime_version}}-x86_64-linux.tar.xz
tar xf wasmtime-${{env.wasmtime_version}}-x86_64-linux.tar.xz
./wasmtime-${{env.wasmtime_version}}-x86_64-linux/wasmtime run --wasm-features simd ${{github.workspace}}/build/tests.wasm
- name: Test with wasmer
run: |
cd ${{github.workspace}}
mkdir wasmer
cd wasmer
wget --no-verbose https://github.com/wasmerio/wasmer/releases/download/${{env.wasmer_version}}/wasmer-linux-amd64.tar.gz
tar xf wasmer-linux-amd64.tar.gz
./bin/wasmer run --enable-simd ${{github.workspace}}/build/tests.wasm

11
.gitignore vendored
View File

@@ -72,3 +72,14 @@ cglm-test-ios*
/cglm.pc
test-driver
Default-568h@2x.png
build/
conftest.dir/*
confdefs.h
*.xcuserdatad
.idea
cmake-build-debug
*.o.tmp
xcode/*
.vscode
.build
*.swp

0
.gitmodules vendored
View File

39
.readthedocs.yaml Normal file
View File

@@ -0,0 +1,39 @@
# Read the Docs configuration file for Sphinx projects
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
# Required
version: 2
# Set the OS, Python version and other tools you might need
build:
os: ubuntu-22.04
tools:
python: "3.12"
# You can also specify other tool versions:
# nodejs: "20"
# rust: "1.70"
# golang: "1.20"
# Build documentation in the "docs/" directory with Sphinx
sphinx:
configuration: docs/source/conf.py
# You can configure Sphinx to use a different builder, for instance use the dirhtml builder for simpler URLs
# builder: "dirhtml"
# Fail on all warnings to avoid broken references
# fail_on_warning: true
# Optionally build your docs in additional formats such as PDF and ePub
# formats:
# - pdf
# - epub
# Optional but recommended, declare the Python requirements required
# to build your documentation
# See https://docs.readthedocs.io/en/stable/guides/reproducible-builds.html
# python:
# install:
# - requirements: docs/requirements.txt
python:
install:
- requirements: docs/requirements.txt

View File

@@ -4,6 +4,12 @@ os:
- linux
- osx
arch:
- amd64
- ppc64le
- s390x
- arm64
sudo: required
dist: trusty

199
BUILDING.md Normal file
View File

@@ -0,0 +1,199 @@
# Building the library
cglm can be built using one of the following build systems:
## CMake (All platforms)
```bash
$ mkdir build
$ cd build
$ cmake .. # [Optional] -DCGLM_SHARED=ON
$ make
$ sudo make install # [Optional]
```
### Options with defaults
```CMake
option(CGLM_SHARED "Shared build" ON)
option(CGLM_STATIC "Static build" OFF)
option(CGLM_USE_C99 "" OFF) # C11
option(CGLM_USE_TEST "Enable Tests" OFF) # for make check - make test
```
### Including in a CMake project
#### Header only
This requires no building or installation of cglm.
* Example:
``` cmake
cmake_minimum_required(VERSION 3.8.2)
project(<Your Project Name>)
add_executable(${PROJECT_NAME} src/main.c)
target_link_libraries(${LIBRARY_NAME} PRIVATE
cglm_headers)
add_subdirectory(external/cglm/ EXCLUDE_FROM_ALL)
```
#### Linked
* Example:
```cmake
cmake_minimum_required(VERSION 3.8.2)
project(<Your Project Name>)
add_executable(${PROJECT_NAME} src/main.c)
target_link_libraries(${LIBRARY_NAME} PRIVATE
cglm)
add_subdirectory(external/cglm/)
# or you can use find_package to configure cglm
```
### Using CMake to build for WebAssembly
Since math functions like `sinf` are used, this can not be targeted at `wasm32-unknown-unknown`, one of [wasi-sdk](https://github.com/WebAssembly/wasi-sdk) or [emscripten](https://github.com/emscripten-core/emsdk) should be used.
Should note that shared build is not yet supported for WebAssembly.
For [simd128](https://github.com/WebAssembly/simd) support, add `-msimd128` to `CMAKE_C_FLAGS`, in command line `-DCMAKE_C_FLAGS="-msimd128"`.
For tests, the cmake option `CGLM_USE_TEST` would still work, you'll need a wasi runtime for running tests, see our [ci config file](.github/workflows/cmake-wasm.yml) for a detailed example.
#### WASI SDK
```bash
$ cmake .. \
-DCMAKE_TOOLCHAIN_FILE=/path/to/wasi-sdk-19.0/share/cmake/wasi-sdk.cmake \
-DWASI_SDK_PREFIX=/path/to/wasi-sdk-19.0
```
Where `/path/to/wasi-sdk-19.0/` is the path to extracted [wasi sdk](https://github.com/WebAssembly/wasi-sdk).
In this case it would by default make a static build.
#### Emscripten
```bash
$ emcmake cmake .. \
-DCMAKE_EXE_LINKER_FLAGS="-s STANDALONE_WASM" \
-DCGLM_STATIC=ON
```
The `emcmake` here is the cmake wrapper for Emscripten from installed [emsdk](https://github.com/emscripten-core/emsdk).
## Meson (All platforms)
```bash
$ meson build # [Optional] --default-library=static
$ cd build
$ ninja
$ sudo ninja install # [Optional]
```
### Options with Defaults:
```meson
c_std=c11
buildtype=release
default_library=shared
build_tests=true # to run tests: ninja test
```
### Including in a Meson project
* Example:
```meson
# Clone cglm or create a cglm.wrap under <source_root>/subprojects
project('name', 'c')
cglm_dep = dependency('cglm', fallback : 'cglm', 'cglm_dep')
executable('exe', 'src/main.c', dependencies : cglm_dep)
```
## Swift (Swift Package Manager)
Currently only default build options are supported. Add **cglm** dependency to your project:
```swift
...
Package(
...
dependencies: [
...
.package(url: "https://github.com/recp/cglm", .branch("master")),
]
...
)
```
Now add **cgml** as a dependency to your target. Product choices are:
- **cglm** for inlined version of the library which can be linked only statically
- **cglmc** for a compiled version of the library with no linking limitation
```swift
...
.target(
...
dependencies: [
...
.product(name: "cglm", package: "cglm"),
]
...
)
...
```
## Unix (Autotools)
```bash
$ sh autogen.sh
$ ./configure
$ make
$ make check # [Optional]
$ [sudo] make install # [Optional]
```
This will also install pkg-config files so you can use
`pkg-config --cflags cglm` and `pkg-config --libs cglm` to retrieve compiler
and linker flags.
The files will be installed into the given prefix (usually `/usr/local` by
default on Linux), but your pkg-config may not be configured to actually check
there. You can figure out where it's looking by running `pkg-config --variable
pc_path pkg-config` and change the path the files are installed to via
`./configure --with-pkgconfigdir=/your/path`. Alternatively, you can add the
prefix path to your `PKG_CONFIG_PATH` environment variable.
## Windows (MSBuild)
Windows related build file and project files are located in `win` folder,
make sure you are inside `cglm/win` folder.
Code Analysis is enabled, so it may take awhile to build.
```Powershell
$ cd win
$ .\build.bat
```
if `msbuild` won't work (because of multi version VS) then try to build with `devenv`:
```Powershell
$ devenv cglm.sln /Build Release
```
### Running Tests on Windows
You can see test project in same visual studio solution file. It is enough to run that project to run tests.
# Building the documentation
First you need install Sphinx: http://www.sphinx-doc.org/en/master/usage/installation.html
then:
```bash
$ cd docs
$ sphinx-build source build
```
it will compile docs into build folder, you can run index.html inside that function.

197
CMakeLists.txt Normal file
View File

@@ -0,0 +1,197 @@
cmake_minimum_required(VERSION 3.13)
project(cglm
VERSION 0.9.6
HOMEPAGE_URL https://github.com/recp/cglm
DESCRIPTION "OpenGL Mathematics (glm) for C"
LANGUAGES C
)
set(CMAKE_C_STANDARD 11)
set(CMAKE_C_STANDARD_REQUIRED YES)
set(DEFAULT_BUILD_TYPE "Release")
set(CGLM_BUILD)
option(CGLM_SHARED "Shared build" ON)
option(CGLM_STATIC "Static build" OFF)
option(CGLM_USE_C99 "" OFF)
option(CGLM_USE_TEST "Enable Tests" OFF)
if(CMAKE_SYSTEM_NAME STREQUAL WASI)
set(CGLM_STATIC ON CACHE BOOL "Static option" FORCE)
set(CGLM_SHARED OFF CACHE BOOL "Shared option" FORCE)
endif()
if(NOT CGLM_STATIC AND CGLM_SHARED)
set(CGLM_BUILD SHARED)
else(CGLM_STATIC)
set(CGLM_BUILD STATIC)
endif()
if(CGLM_USE_C99)
set(CMAKE_C_STANDARD 99)
endif()
if(MSVC)
add_definitions(-D_WINDOWS -D_USRDLL)
if(NOT CMAKE_BUILD_TYPE MATCHES Debug)
add_definitions(-DNDEBUG)
add_compile_options(/W3 /Ox /Gy /Oi /TC)
foreach(flag_var
CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE
CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO)
string(REGEX REPLACE "/RTC(su|[1su])" "" ${flag_var} "${${flag_var}}")
endforeach(flag_var)
endif()
else()
add_compile_options(-Wall -Wextra -Wpedantic -Wconversion)
if(NOT CMAKE_BUILD_TYPE MATCHES Debug)
add_compile_options(-O3)
endif()
endif()
get_directory_property(hasParent PARENT_DIRECTORY)
if(NOT hasParent AND NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
message(STATUS "Setting build type to '${DEFAULT_BUILD_TYPE}' as none was specified.")
set(CMAKE_BUILD_TYPE "${DEFAULT_BUILD_TYPE}" CACHE STRING "Choose the type of build." FORCE)
# Set the possible values of build type for cmake-gui
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo")
endif()
include(GNUInstallDirs)
set(CPACK_PROJECT_NAME ${PROJECT_NAME})
set(CPACK_PROJECT_VERSION ${PROJECT_VERSION})
if(NOT CPack_CMake_INCLUDED)
include(CPack)
endif()
# Target Start
add_library(${PROJECT_NAME}
${CGLM_BUILD}
src/euler.c
src/affine.c
src/io.c
src/quat.c
src/cam.c
src/vec2.c
src/ivec2.c
src/vec3.c
src/ivec3.c
src/vec4.c
src/ivec4.c
src/mat2.c
src/mat2x3.c
src/mat2x4.c
src/mat3.c
src/mat3x2.c
src/mat3x4.c
src/mat4.c
src/mat4x2.c
src/mat4x3.c
src/plane.c
src/noise.c
src/frustum.c
src/box.c
src/aabb2d.c
src/project.c
src/sphere.c
src/ease.c
src/curve.c
src/bezier.c
src/ray.c
src/affine2d.c
src/clipspace/ortho_lh_no.c
src/clipspace/ortho_lh_zo.c
src/clipspace/ortho_rh_no.c
src/clipspace/ortho_rh_zo.c
src/clipspace/persp_lh_no.c
src/clipspace/persp_lh_zo.c
src/clipspace/persp_rh_no.c
src/clipspace/persp_rh_zo.c
src/clipspace/view_lh_no.c
src/clipspace/view_lh_zo.c
src/clipspace/view_rh_no.c
src/clipspace/view_rh_zo.c
src/clipspace/project_no.c
src/clipspace/project_zo.c
)
if(CGLM_SHARED)
add_definitions(-DCGLM_EXPORTS)
else()
target_compile_definitions(${PROJECT_NAME} PUBLIC -DCGLM_STATIC)
endif()
set_target_properties(${PROJECT_NAME} PROPERTIES
VERSION ${PROJECT_VERSION}
SOVERSION ${PROJECT_VERSION_MAJOR})
if(WIN32)
# Because SOVERSION has no effect to file naming on Windows
set_target_properties(${PROJECT_NAME} PROPERTIES
RUNTIME_OUTPUT_NAME ${PROJECT_NAME}-${PROJECT_VERSION_MAJOR})
endif()
target_include_directories(${PROJECT_NAME}
PUBLIC
$<INSTALL_INTERFACE:include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/src
)
# Target for header-only usage
add_library(${PROJECT_NAME}_headers INTERFACE)
target_include_directories(${PROJECT_NAME}_headers INTERFACE
${CMAKE_CURRENT_SOURCE_DIR}/include)
# Test Configuration
if(CGLM_USE_TEST)
include(CTest)
enable_testing()
add_subdirectory(test)
endif()
# Install
install(TARGETS ${PROJECT_NAME}
EXPORT ${PROJECT_NAME}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
install(DIRECTORY include/${PROJECT_NAME} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
PATTERN ".*" EXCLUDE)
# Config
export(TARGETS ${PROJECT_NAME}
NAMESPACE ${PROJECT_NAME}::
FILE "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
)
install(EXPORT ${PROJECT_NAME}
FILE "${PROJECT_NAME}Config.cmake"
NAMESPACE ${PROJECT_NAME}::
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME})
set(PACKAGE_NAME ${PROJECT_NAME})
set(prefix ${CMAKE_INSTALL_PREFIX})
set(exec_prefix ${CMAKE_INSTALL_PREFIX})
if (IS_ABSOLUTE "${CMAKE_INSTALL_INCLUDEDIR}")
set(includedir "${CMAKE_INSTALL_INCLUDEDIR}")
else()
set(includedir "\${prefix}/${CMAKE_INSTALL_INCLUDEDIR}")
endif()
if (IS_ABSOLUTE "${CMAKE_INSTALL_LIBDIR}")
set(libdir "${CMAKE_INSTALL_LIBDIR}")
else()
set(libdir "\${exec_prefix}/${CMAKE_INSTALL_LIBDIR}")
endif()
set(PACKAGE_VERSION "${PROJECT_VERSION}")
configure_file(cglm.pc.in cglm.pc @ONLY)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/cglm.pc
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)

35
CREDITS
View File

@@ -61,3 +61,38 @@ https://forums.khronos.org/showthread.php/10264-Animations-in-1-4-1-release-note
https://forums.khronos.org/showthread.php/10644-Animation-Bezier-interpolation
https://forums.khronos.org/showthread.php/10387-2D-Tangents-in-Bezier-Splines?p=34164&viewfull=1#post34164
https://forums.khronos.org/showthread.php/10651-Animation-TCB-Spline-Interpolation-in-COLLADA?highlight=bezier
12. vec2 cross product
http://allenchou.net/2013/07/cross-product-of-2d-vectors/
13. Ray triangle intersect
MöllerTrumbore ray-triangle intersection algorithm, from "Fast, Minimum Storage Ray/Triangle Intersection"
Authors:
Thomas Möller (tompa@clarus.se)
Ben Trumbore (wbt@graphics.cornell.edu)
Link to paper: http://webserver2.tecgraf.puc-rio.br/~mgattass/cg/trbRR/Fast%20MinimumStorage%20RayTriangle%20Intersection.pdf
14. ARM NEON: Matrix Vector Multiplication
https://stackoverflow.com/a/57793352/2676533
16. ARM NEON Div
http://github.com/microsoft/DirectXMath
17. Pick Matrix
glu project -> project.c
18. Ray sphere intersection
RAY TRACING GEMS
HIGH-QUALITY AND REAL-TIME RENDERING WITH DXR AND OTHER APIS
CHAPTER 7
Precision Improvements for Ray/Sphere Intersection
Eric Haines (1), Johannes Günther (2), and Tomas Akenine-Möller (1)
(1) NVIDIA
(2) Intel
Wyman, C., and Haines, E. Getting Started with RTX Ray Tracing.
https://github.com/NVIDIAGameWorks/GettingStartedWithRTXRayTracing

View File

@@ -11,9 +11,7 @@ AM_CFLAGS = -Wall \
-std=gnu11 \
-O3 \
-Wstrict-aliasing=2 \
-fstrict-aliasing \
-pedantic \
-Werror=strict-prototypes
-fstrict-aliasing
lib_LTLIBRARIES = libcglm.la
libcglm_la_LDFLAGS = -no-undefined -version-info 0:1:0
@@ -22,7 +20,10 @@ checkLDFLAGS = -L./.libs \
-lm \
-lcglm
checkCFLAGS = $(AM_CFLAGS) \
-I./include
-std=gnu11 \
-O3 \
-DCGLM_DEFINE_PRINTS \
-I$(srcdir)/include
check_PROGRAMS = test/tests
TESTS = $(check_PROGRAMS)
@@ -41,55 +42,125 @@ cglm_HEADERS = include/cglm/version.h \
include/cglm/cam.h \
include/cglm/io.h \
include/cglm/mat4.h \
include/cglm/mat4x2.h \
include/cglm/mat4x3.h \
include/cglm/mat3.h \
include/cglm/mat3x2.h \
include/cglm/mat3x4.h \
include/cglm/mat2.h \
include/cglm/mat2x3.h \
include/cglm/mat2x4.h \
include/cglm/affine-pre.h \
include/cglm/affine-post.h \
include/cglm/affine.h \
include/cglm/affine-mat.h \
include/cglm/vec2.h \
include/cglm/vec2-ext.h \
include/cglm/ivec2.h \
include/cglm/vec3.h \
include/cglm/vec3-ext.h \
include/cglm/ivec3.h \
include/cglm/vec4.h \
include/cglm/vec4-ext.h \
include/cglm/ivec4.h \
include/cglm/euler.h \
include/cglm/util.h \
include/cglm/quat.h \
include/cglm/affine-mat.h \
include/cglm/plane.h \
include/cglm/noise.h \
include/cglm/frustum.h \
include/cglm/box.h \
include/cglm/aabb2d.h \
include/cglm/color.h \
include/cglm/project.h \
include/cglm/sphere.h \
include/cglm/ease.h \
include/cglm/curve.h \
include/cglm/bezier.h \
include/cglm/applesimd.h
include/cglm/applesimd.h \
include/cglm/ray.h \
include/cglm/affine2d.h
cglm_clipspacedir=$(includedir)/cglm/clipspace
cglm_clipspace_HEADERS = include/cglm/clipspace/persp.h \
include/cglm/clipspace/persp_lh_no.h \
include/cglm/clipspace/persp_lh_zo.h \
include/cglm/clipspace/persp_rh_no.h \
include/cglm/clipspace/persp_rh_zo.h \
include/cglm/clipspace/ortho_lh_no.h \
include/cglm/clipspace/ortho_lh_zo.h \
include/cglm/clipspace/ortho_rh_no.h \
include/cglm/clipspace/ortho_rh_zo.h \
include/cglm/clipspace/view_lh.h \
include/cglm/clipspace/view_rh.h \
include/cglm/clipspace/view_lh_no.h \
include/cglm/clipspace/view_lh_zo.h \
include/cglm/clipspace/view_rh_no.h \
include/cglm/clipspace/view_rh_zo.h \
include/cglm/clipspace/project_no.h \
include/cglm/clipspace/project_zo.h
cglm_calldir=$(includedir)/cglm/call
cglm_call_HEADERS = include/cglm/call/mat4.h \
include/cglm/call/mat4x2.h \
include/cglm/call/mat4x3.h \
include/cglm/call/mat3.h \
include/cglm/call/mat3x2.h \
include/cglm/call/mat3x4.h \
include/cglm/call/mat2.h \
include/cglm/call/mat2x3.h \
include/cglm/call/mat2x4.h \
include/cglm/call/vec2.h \
include/cglm/call/vec3.h \
include/cglm/call/vec4.h \
include/cglm/call/affine.h \
include/cglm/call/ivec2.h \
include/cglm/call/ivec3.h \
include/cglm/call/ivec4.h \
include/cglm/call/io.h \
include/cglm/call/cam.h \
include/cglm/call/quat.h \
include/cglm/call/euler.h \
include/cglm/call/plane.h \
include/cglm/call/noise.h \
include/cglm/call/frustum.h \
include/cglm/call/box.h \
include/cglm/call/project.h \
include/cglm/call/sphere.h \
include/cglm/call/ease.h \
include/cglm/call/curve.h \
include/cglm/call/bezier.h
include/cglm/call/bezier.h \
include/cglm/call/ray.h \
include/cglm/call/affine.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 \
include/cglm/call/clipspace/persp_lh_zo.h \
include/cglm/call/clipspace/persp_rh_no.h \
include/cglm/call/clipspace/persp_rh_zo.h \
include/cglm/call/clipspace/ortho_lh_no.h \
include/cglm/call/clipspace/ortho_lh_zo.h \
include/cglm/call/clipspace/ortho_rh_no.h \
include/cglm/call/clipspace/ortho_rh_zo.h \
include/cglm/call/clipspace/view_lh_no.h \
include/cglm/call/clipspace/view_lh_zo.h \
include/cglm/call/clipspace/view_rh_no.h \
include/cglm/call/clipspace/view_rh_zo.h \
include/cglm/call/clipspace/project_no.h \
include/cglm/call/clipspace/project_zo.h
cglm_simddir=$(includedir)/cglm/simd
cglm_simd_HEADERS = include/cglm/simd/intrin.h \
include/cglm/simd/x86.h \
include/cglm/simd/arm.h
include/cglm/simd/arm.h \
include/cglm/simd/wasm.h
cglm_simd_sse2dir=$(includedir)/cglm/simd/sse2
cglm_simd_sse2_HEADERS = include/cglm/simd/sse2/affine.h \
include/cglm/simd/sse2/mat4.h \
include/cglm/simd/sse2/mat3.h \
include/cglm/simd/sse2/mat2.h \
include/cglm/simd/sse2/quat.h
cglm_simd_avxdir=$(includedir)/cglm/simd/avx
@@ -97,27 +168,80 @@ cglm_simd_avx_HEADERS = include/cglm/simd/avx/mat4.h \
include/cglm/simd/avx/affine.h
cglm_simd_neondir=$(includedir)/cglm/simd/neon
cglm_simd_neon_HEADERS = include/cglm/simd/neon/mat4.h
cglm_simd_neon_HEADERS = include/cglm/simd/neon/affine.h \
include/cglm/simd/neon/mat2.h \
include/cglm/simd/neon/mat4.h \
include/cglm/simd/neon/quat.h
cglm_simd_wasmdir=$(includedir)/cglm/simd/wasm
cglm_simd_wasm_HEADERS = include/cglm/simd/wasm/affine.h \
include/cglm/simd/wasm/mat2.h \
include/cglm/simd/wasm/mat3.h \
include/cglm/simd/wasm/mat4.h \
include/cglm/simd/wasm/quat.h
cglm_handeddir=$(includedir)/cglm/handed
cglm_handed_HEADERS = include/cglm/handed/euler_to_quat_lh.h \
include/cglm/handed/euler_to_quat_rh.h
cglm_structdir=$(includedir)/cglm/struct
cglm_struct_HEADERS = include/cglm/struct/mat4.h \
include/cglm/struct/mat4x2.h \
include/cglm/struct/mat4x3.h \
include/cglm/struct/mat3.h \
include/cglm/struct/mat3x2.h \
include/cglm/struct/mat3x4.h \
include/cglm/struct/mat2.h \
include/cglm/struct/mat2x3.h \
include/cglm/struct/mat2x4.h \
include/cglm/struct/affine-pre.h \
include/cglm/struct/affine-post.h \
include/cglm/struct/affine-mat.h \
include/cglm/struct/affine.h \
include/cglm/struct/affine2d.h \
include/cglm/struct/vec2.h \
include/cglm/struct/vec2-ext.h \
include/cglm/struct/ivec2.h \
include/cglm/struct/vec3.h \
include/cglm/struct/vec3-ext.h \
include/cglm/struct/ivec3.h \
include/cglm/struct/vec4.h \
include/cglm/struct/vec4-ext.h \
include/cglm/struct/affine.h \
include/cglm/struct/ivec4.h \
include/cglm/struct/io.h \
include/cglm/struct/cam.h \
include/cglm/struct/quat.h \
include/cglm/struct/euler.h \
include/cglm/struct/plane.h \
include/cglm/struct/noise.h \
include/cglm/struct/frustum.h \
include/cglm/struct/box.h \
include/cglm/struct/aabb2d.h \
include/cglm/struct/project.h \
include/cglm/struct/sphere.h \
include/cglm/struct/color.h \
include/cglm/struct/curve.h
include/cglm/struct/curve.h \
include/cglm/struct/ray.h
cglm_struct_clipspacedir=$(includedir)/cglm/struct/clipspace
cglm_struct_clipspace_HEADERS = include/cglm/struct/clipspace/persp_lh_no.h \
include/cglm/struct/clipspace/persp_lh_zo.h \
include/cglm/struct/clipspace/persp_rh_no.h \
include/cglm/struct/clipspace/persp_rh_zo.h \
include/cglm/struct/clipspace/ortho_lh_no.h \
include/cglm/struct/clipspace/ortho_lh_zo.h \
include/cglm/struct/clipspace/ortho_rh_no.h \
include/cglm/struct/clipspace/ortho_rh_zo.h \
include/cglm/struct/clipspace/view_lh_no.h \
include/cglm/struct/clipspace/view_lh_zo.h \
include/cglm/struct/clipspace/view_rh_no.h \
include/cglm/struct/clipspace/view_rh_zo.h \
include/cglm/struct/clipspace/project_no.h \
include/cglm/struct/clipspace/project_zo.h
cglm_struct_handeddir=$(includedir)/cglm/struct/handed
cglm_struct_handed_HEADERS = include/cglm/struct/handed/euler_to_quat_lh.h \
include/cglm/struct/handed/euler_to_quat_rh.h
libcglm_la_SOURCES=\
src/euler.c \
@@ -125,32 +249,54 @@ libcglm_la_SOURCES=\
src/io.c \
src/quat.c \
src/cam.c \
src/vec2.c \
src/ivec2.c \
src/vec3.c \
src/ivec3.c \
src/vec4.c \
src/ivec4.c \
src/mat2.c \
src/mat2x3.c \
src/mat2x4.c \
src/mat3.c \
src/mat3x2.c \
src/mat3x4.c \
src/mat4.c \
src/mat4x2.c \
src/mat4x3.c \
src/plane.c \
src/noise.c \
src/frustum.c \
src/box.c \
src/project.c \
src/sphere.c \
src/ease.c \
src/curve.c \
src/bezier.c
src/bezier.c \
src/ray.c \
src/affine2d.c \
src/aabb2d.c \
src/clipspace/ortho_lh_no.c \
src/clipspace/ortho_lh_zo.c \
src/clipspace/ortho_rh_no.c \
src/clipspace/ortho_rh_zo.c \
src/clipspace/persp_lh_no.c \
src/clipspace/persp_lh_zo.c \
src/clipspace/persp_rh_no.c \
src/clipspace/persp_rh_zo.c \
src/clipspace/view_lh_no.c \
src/clipspace/view_lh_zo.c \
src/clipspace/view_rh_no.c \
src/clipspace/view_rh_zo.c \
src/clipspace/project_no.c \
src/clipspace/project_zo.c
test_tests_SOURCES=\
test/runner.c \
test/src/test_common.c \
test/src/test_mat4.c \
test/src/test_cam.c \
test/src/test_project.c \
test/src/tests.c \
test/src/test_clamp.c \
test/src/test_euler.c \
test/src/test_quat.c \
test/src/test_vec4.c \
test/src/test_vec3.c \
test/src/test_mat3.c \
test/src/test_affine.c \
test/src/test_bezier.c \
test/src/test_struct.c

44
Package.swift Normal file
View File

@@ -0,0 +1,44 @@
// swift-tools-version:5.2
import PackageDescription
let package = Package(
name: "cglm",
products: [
.library(name: "cglm", type: .static, targets: ["cglmHeader"]),
.library(name: "cglmc", targets: ["cglmCompiled"]),
],
dependencies: [],
targets: [
.target(
name: "cglmCompiled",
path: "./",
exclude: [
"./docs",
"./src/swift",
"./include",
"./test",
"./win",
],
sources: [
"./src",
],
publicHeadersPath: "./include"
),
.target(
name: "cglmHeader",
path: "./",
exclude: [
"./docs",
"./include",
"./test",
"./win",
],
sources: [
"./src/swift",
],
publicHeadersPath: "./include"
),
],
cLanguageStandard: .c11
)

395
README.md
View File

@@ -1,74 +1,138 @@
# 🎥 OpenGL Mathematics (glm) for `C`
[![Build Status](https://travis-ci.org/recp/cglm.svg?branch=master)](https://travis-ci.org/recp/cglm)
[![Build status](https://ci.appveyor.com/api/projects/status/av7l3gc0yhfex8y4/branch/master?svg=true)](https://ci.appveyor.com/project/recp/cglm/branch/master)
[![Documentation Status](https://readthedocs.org/projects/cglm/badge/?version=latest)](http://cglm.readthedocs.io/en/latest/?badge=latest)
[![Coverage Status](https://coveralls.io/repos/github/recp/cglm/badge.svg?branch=master)](https://coveralls.io/github/recp/cglm?branch=master)
[![codecov](https://codecov.io/gh/recp/cglm/branch/master/graph/badge.svg)](https://codecov.io/gh/recp/cglm)
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/6a62b37d5f214f178ebef269dc4a6bf1)](https://www.codacy.com/app/recp/cglm?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=recp/cglm&amp;utm_campaign=Badge_Grade)
[![Backers on Open Collective](https://opencollective.com/cglm/backers/badge.svg)](#backers)
[![Sponsors on Open Collective](https://opencollective.com/cglm/sponsors/badge.svg)](#sponsors)
#### Documentation
<p align="center">
<img alt="" src="cglm.png" width="550" />
</p>
<br>
<p align="center">
<a href="https://github.com/recp/cglm/actions/workflows/ci.yml">
<img src="https://github.com/recp/cglm/actions/workflows/ci.yml/badge.svg"
alt="Build Status">
</a>
<a href="http://cglm.readthedocs.io/en/latest/?badge=latest">
<img src="https://readthedocs.org/projects/cglm/badge/?version=latest"
alt="Documentation Status">
</a>
<a href="https://www.codacy.com/app/recp/cglm?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=recp/cglm&amp;utm_campaign=Badge_Grade">
<img src="https://api.codacy.com/project/badge/Grade/6a62b37d5f214f178ebef269dc4a6bf1"
alt="Codacy Badge"/>
</a>
<a href="https://coveralls.io/github/recp/cglm?branch=master">
<img src="https://coveralls.io/repos/github/recp/cglm/badge.svg?branch=master"
alt="Coverage Status"/>
</a>
<a href="https://codecov.io/gh/recp/cglm">
<img src="https://codecov.io/gh/recp/cglm/branch/master/graph/badge.svg"
alt="Coverage Status"/>
</a>
<br /><br />
<a href="#sponsors">
<img src="https://opencollective.com/cglm/sponsors/badge.svg"
alt="Sponsors on Open Collective"/>
</a>
<a href="#backers">
<img src="https://opencollective.com/cglm/backers/badge.svg"
alt="Backers on Open Collective"/>
</a>
</p>
Almost all functions (inline versions) and parameters are documented inside the corresponding headers. <br />
Complete documentation: http://cglm.readthedocs.io
<br>
#### Note for previous versions:
<p align="center">
A highly optimized 2D|3D math library. Also known as OpenGL Mathematics (glm) for C. <b>cglm</b> provides fast and ergonomic math functions to ease graphics programming. It is community friendly feel free to report any bugs and issues you face. <br>
<i>If you're using C++, you might want to check out <a href="https://github.com/g-truc/glm">GLM</a></i>
</p>
- _dup (duplicate) is changed to _copy. For instance `glm_vec_dup -> glm_vec3_copy`
- OpenGL related functions are dropped to make this lib platform/third-party independent
- make sure you have latest version and feel free to report bugs, troubles
- **[bugfix]** euler angles was implemented in reverse order (extrinsic) it was fixed, now they are intrinsic. Make sure that
you have the latest version
- **[major change]** by starting v0.4.0, quaternions are stored as [x, y, z, w], it was [w, x, y, z] in v0.3.5 and earlier versions
- **[api rename]** by starting v0.4.5, **glm_simd** functions are renamed to **glmm_**
- **[new option]** by starting v0.4.5, you can disable alignment requirement, check options in docs.
- **[major change]** by starting v0.5.0, vec3 functions use **glm_vec3_** namespace, it was **glm_vec_** until v0.5.0
- **[major change]** by starting v0.5.1, built-in alignment is removed from **vec3** and **mat3** types
- Allocation-free
- Header-only
- SIMD-optimized
- API-agnostic
#### Note for C++ developers:
If you are not aware of the original GLM library yet, you may also want to look at:
https://github.com/g-truc/glm
---
#### Note for new comers (Important):
- `vec4` and `mat4` variables must be aligned. (There will be unaligned versions later)
- **in** and **[in, out]** parameters must be initialized (please). But **[out]** parameters not, initializing out param is also redundant
- All functions are inline if you don't want to use pre-compiled versions with glmc_ prefix, you can ignore build process. Just include headers.
- if your debugger takes you to cglm headers then make sure you are not trying to copy vec4 to vec3 or alig issues...
- Welcome!
### 📚 Documentation
#### Note for experienced developers:
- Since I'm testing this library in my projects, sometimes bugs occurs; finding that bug[s] and making improvements would be more easy with multiple developer/contributor and their projects or knowledge. Consider to make some tests if you suspect something is wrong and any feedbacks, contributions and bug reports are always welcome.
All functions and their parameters are documented above their declaration inside their corresponding headers. <br />
Alternatively, you can read the complete documentation [here](http://cglm.readthedocs.io).
#### Allocations?
`cglm` doesn't alloc any memory on heap. So it doesn't provide any allocator. You should alloc memory for **out** parameters too if you pass pointer of memory location. Don't forget that **vec4** (also quat/**versor**) and **mat4** must be aligned (16-bytes), because *cglm* uses SIMD instructions to optimize most operations if available.
### 🔨 Building
#### Returning vector or matrix... ?
cglm can be used in it's entirety as a header-only library simply by including `cglm/cglm.h`. If you wish to link against it instead, it can be built using one of the supported build systems. Detailed information about building on individual platforms and build systems along with the instructions for building the documentation can be found in [BUILDING.md](./BUILDING.md).
**cglm** supports both *ARRAY API* and *STRUCT API*, so you can return structs if you utilize struct api (`glms_`).
### ✅ Usage
#### Other APIs like Vulkan, Metal, Dx?
Currently *cglm* uses default clip space configuration (-1, 1) for camera functions (perspective, extract corners...), in the future other clip space configurations will be supported
#### Header-only
<hr/>
Include the `cglm/cglm.h` header and use functions with the `glm_` prefix.
```c
#include "cglm/cglm.h"
<table>
<tbody>
<tr>
<td>
<div>Like some other graphics libraries (especially OpenGL) this library use Column-Major layout to keep matrices in the memory. </div>
<div>&nbsp;</div>
<div>In the future the library may support an option to use row-major layout, CURRENTLY if you need to row-major layout you will need to transpose it. </div>
</td>
<td>
<img src="https://upload.wikimedia.org/wikipedia/commons/3/3f/Matrix_Columns.svg" width="300px" />
</td>
</tr>
</tbody>
</table>
// ...
## Features
- array api and struct api, you can use arrays or structs.
vec2 vector;
glm_vec2_zero(vector);
```
#### Struct API
Include `cglm/struct.h` and use `glms_`.
```c
#include "cglm/struct.h"
// ...
vec2s vector = glms_vec2_zero();
```
#### Linked
Include `cglm/call.h` and use `glmc_`.
```c
#include "cglm/call.h"
// ...
vec2 vector;
glmc_vec2_zero(vector);
```
### ❗ Alignment
While cglm by default aligns what's necessary, it is possible to disable this by defining `CGLM_ALL_UNALIGNED`. If you're targeting machines with any kind of SIMD support, make sure that all `vec4`, `mat4` and `mat2` arguments you pass to cglm functions are aligned to prevent unexpected crashes, alternatively use the unaligned versions if present.
### Struct API
The struct API works as follows (note the `s` suffix on types, `glms_` prefix on functions and `GLMS_` on constants):
```C
#include <cglm/struct.h>
mat4s mat = GLMS_MAT4_IDENTITY_INIT;
mat4s inv = glms_mat4_inv(mat);
```
Struct functions generally take parameters *by copy* and *return* the results rather than taking pointers and writing to out parameters. That means your variables can usually be `const`, if you're into that.
The types used are actually unions that allow access to the same data in multiple ways. One of these involves anonymous structures available since C11. MSVC supports them in earlier versions out of the box and GCC/Clang as well if you enable `-fms-extensions`.
To explicitly enable anonymous structures `#define CGLM_USE_ANONYMOUS_STRUCT 1`, or `0` to disable them.
For backwards compatibility, you can also `#define CGLM_NO_ANONYMOUS_STRUCT` to disable them. If you don't specify explicitly, cglm will attempt a best guess based on your compiler and C version.
### 📌 Migration notes:
- `_dup` (duplicate) functions were renamed to `_copy`. For instance: `glm_vec_dup` -> `glm_vec3_copy`.
- OpenGL related functions were dropped to make cglm API independent.
- **[bugfix]** Euler angles had been previously implemented in reverse order (extrinsic). This was fixed to be intrinsic.
- **[major change]** Starting with **v0.4.0**, quaternions are stored as [x, y, z, w]. Previously it was [w, x, y, z].
- **[api rename]** Starting with **v0.4.5**, `glm_simd_` functions are renamed to `glmm_`.
- **[new option]** Starting with **v0.4.5**, alignment requirements can be disabled. Read more in the documentation.
- **[major change]** Starting with **v0.5.0**, vec3 functions occupy the **glm_vec3_** namespace. This used to be **glm_vec_** in earlier versions.
- **[major change]** Starting with **v0.5.1**, `vec3` and `mat3` types are not aligned by default.
- **[major change]** Starting with **v0.7.3**, inline print functions are disabled by default in release mode to eliminate printing costs (see the Options chapter of the docs). <br> Colored output can be disabled (see documentation).
- **[major change]** Starting with **v0.8.3**, alternate clipspace configurations are supported. The `CGLM_FORCE_DEPTH_ZERO_TO_ONE` and `CGLM_FORCE_LEFT_HANDED` flags are provided to control clip depth and handedness. This makes it easier to incorporate cglm into projects using graphics APIs such as Vulkan or Metal. See https://cglm.readthedocs.io/en/latest/opt.html#clipspace-option-s
### 🚀 Features
- scalar and simd (sse, avx, neon...) optimizations
- general purpose matrix operations (mat4, mat3)
- chain matrix multiplication (square only)
- general purpose vector operations (cross, dot, rotate, proj, angle...)
@@ -80,48 +144,35 @@ Currently *cglm* uses default clip space configuration (-1, 1) for camera functi
- quaternions
- euler angles / yaw-pitch-roll to matrix
- extract euler angles
- inline or pre-compiled function call
- frustum (extract view frustum planes, corners...)
- bounding box (AABB in Frustum (culling), crop, merge...)
- bounding box (AABB in Frustum (culling), crop, merge...)
- bounding sphere
- project, unproject
- easing functions
- curves
- curve interpolation helpers (S*M*C, deCasteljau...)
- helpers to convert cglm types to Apple's simd library to pass cglm types to Metal GL without packing them on both sides
- and others...
- curve interpolation helpers (SMC, deCasteljau...)
- comversion helpers from cglm types to Apple's simd library to pass cglm types to Metal GL without packing them on both sides
- ray intersection helpers
---
<hr />
<table>
<tbody>
<tr>
<td>
<div>Like other graphics libraries (especially OpenGL), cglm uses column-major layout to keep matrices in memory. </div>
<div>&nbsp;</div>
<div>While we might support row-major matrices in the future, currently if you need your matrices to be in row-major layout you have to transpose them. </div>
</td>
<td>
<img src="https://upload.wikimedia.org/wikipedia/commons/3/3f/Matrix_Columns.svg" width="300px" />
</td>
</tr>
</tbody>
</table>
You have two option to call a function/operation: inline or library call (link)
Almost all functions are marked inline (always_inline) so compiler will probably inline.
To call pre-compiled version, just use `glmc_` (c stands for 'call') instead of `glm_`.
---
```C
#include <cglm/cglm.h> /* for inline */
#include <cglm/call.h> /* for library call (this also includes cglm.h) */
mat4 rot, trans, rt;
/* ... */
glm_mul(trans, rot, rt); /* inline */
glmc_mul(trans, rot, rt); /* call from library */
```
Most of math functions are optimized manualy with SSE2 if available, if not? Dont worry there are non-sse versions of all operations
You can pass matrices and vectors as array to functions rather than get address.
```C
mat4 m = {
1, 0, 0, 0,
0, 1, 0, 0,
0, 0, 1, 0,
0, 0, 0, 1
};
glm_translate(m, (vec3){1.0f, 0.0f, 0.0f});
```
Library contains general purpose mat4 mul and inverse functions, and also contains some special forms (optimized) of these functions for affine transformations' matrices. If you want to multiply two affine transformation matrices you can use glm_mul instead of glm_mat4_mul and glm_inv_tr (ROT + TR) instead glm_mat4_inv
cglm contains general purpose mat4 product and inverse functions but also provides optimized versions for affine transformations. If you want to multiply two affine transformation matrices you can use glm_mul instead of glm_mat4_mul and glm_inv_tr (ROT + TR) instead glm_mat4_inv.
```C
/* multiplication */
mat4 modelMat;
@@ -131,167 +182,10 @@ glm_mul(T, R, modelMat);
glm_inv_tr(modelMat);
```
### Struct API
The struct API works as follows, note the `s` suffix on types, the `glms_` prefix on functions and the `GLMS_` prefix on constants:
```C
#include <cglm/struct.h>
mat4s mat = GLMS_MAT4_IDENTITY_INIT;
mat4s inv = glms_mat4_inv(mat);
```
Struct functions generally take their parameters as *values* and *return* their results, rather than taking pointers and writing to out parameters. That means your parameters can usually be `const`, if you're into that.
The types used are actually unions that allow access to the same data multiple ways. One of those ways involves anonymous structures, available since C11. MSVC also supports it for earlier C versions out of the box and GCC/Clang do if you enable `-fms-extensions`. To explicitly enable these anonymous structures, `#define CGLM_USE_ANONYMOUS_STRUCT` to `1`, to disable them, to `0`. For backward compatibility, you can also `#define CGLM_NO_ANONYMOUS_STRUCT` (value is irrelevant) to disable them. If you don't specify explicitly, cglm will do a best guess based on your compiler and the C version you're using.
## Build
### Unix (Autotools)
```bash
$ sh autogen.sh
$ ./configure
$ make
$ make check # [Optional]
$ [sudo] make install # [Optional]
```
This will also install pkg-config files so you can use
`pkg-config --cflags cglm` and `pkg-config --libs cglm` to retrieve compiler
and linker flags.
The files will be installed into the given prefix (usually `/usr/local` by
default on Linux), but your pkg-config may not be configured to actually check
there. You can figure out where it's looking by running `pkg-config --variable
pc_path pkg-config` and change the path the files are installed to via
`./configure --with-pkgconfigdir=/your/path`. Alternatively, you can add the
prefix path to your `PKG_CONFIG_PATH` environment variable.
### Windows (MSBuild)
Windows related build file and project files are located in `win` folder,
make sure you are inside `cglm/win` folder.
Code Analysis is enabled, so it may take awhile to build.
```Powershell
$ cd win
$ .\build.bat
```
if `msbuild` won't work (because of multi version VS) then try to build with `devenv`:
```Powershell
$ devenv cglm.sln /Build Release
```
#### Running Tests on Windows
You can see test project in same visual studio solution file. It is enough to run that project to run tests.
### Building Docs
First you need install Sphinx: http://www.sphinx-doc.org/en/master/usage/installation.html
then:
```bash
$ cd docs
$ sphinx-build source build
```
it will compile docs into build folder, you can run index.html inside that function.
## How to use
If you want to use the inline versions of functions, then include the main header
```C
#include <cglm/cglm.h>
```
the header will include all headers. Then call the func you want e.g. rotate vector by axis:
```C
glm_vec3_rotate(v1, glm_rad(45), (vec3){1.0f, 0.0f, 0.0f});
```
some functions are overloaded :) e.g you can normalize vector:
```C
glm_vec3_normalize(vec);
```
this will normalize vec and store normalized vector into `vec` but if you will store normalized vector into another vector do this:
```C
glm_vec3_normalize_to(vec, result);
```
like this function you may see `_to` postfix, this functions store results to another variables and save temp memory
to call pre-compiled versions include header with `c` postfix, c means call. Pre-compiled versions are just wrappers.
```C
#include <cglm/call.h>
```
this header will include all headers with c postfix. You need to call functions with c posfix:
```C
glmc_vec3_normalize(vec);
```
Function usage and parameters are documented inside related headers. You may see same parameter passed twice in some examples like this:
```C
glm_mat4_mul(m1, m2, m1);
/* or */
glm_mat4_mul(m1, m1, m1);
```
the first two parameter are **[in]** and the last one is **[out]** parameter. After multiplying *m1* and *m2*, the result is stored in *m1*. This is why we send *m1* twice. You may store the result in a different matrix, this is just an example.
### Example: Computing MVP matrix
#### Option 1
```C
mat4 proj, view, model, mvp;
/* init proj, view and model ... */
glm_mat4_mul(proj, view, viewProj);
glm_mat4_mul(viewProj, model, mvp);
```
#### Option 2
```C
mat4 proj, view, model, mvp;
/* init proj, view and model ... */
glm_mat4_mulN((mat4 *[]){&proj, &view, &model}, 3, mvp);
```
## How to send matrix to OpenGL
mat4 is array of vec4 and vec4 is array of floats. `glUniformMatrix4fv` functions accecpts `float*` as `value` (last param), so you can cast mat4 to float* or you can pass first column of matrix as beginning of memory of matrix:
Option 1: Send first column
```C
glUniformMatrix4fv(location, 1, GL_FALSE, matrix[0]);
/* array of matrices */
glUniformMatrix4fv(location, 1, GL_FALSE, matrix[0][0]);
```
Option 2: Cast matrix to pointer type (also valid for multiple dimensional arrays)
```C
glUniformMatrix4fv(location, 1, GL_FALSE, (float *)matrix);
```
You can pass matrices the same way to other APIs e.g. Vulkan, DX...
## Notes
- This library uses float types only, does not support Integers, Double... yet
- If headers are not working properly with your compiler, IDE please open an issue, because I'm using GCC and clang to test it maybe sometimes MSVC
**TODO:**
- [ ] Unit tests (In Progress)
- [ ] Unit tests for comparing cglm with glm results
- [x] Add version info
- [ ] Unaligned operations (e.g. `glm_umat4_mul`)
- [x] Extra documentation
- [ ] ARM Neon Arch (In Progress)
## Contributors
This project exists thanks to all the people who contribute. [[Contribute](CONTRIBUTING.md)].
<a href="graphs/contributors"><img src="https://opencollective.com/cglm/contributors.svg?width=890&button=false" /></a>
This project exists thanks to all the people who contribute. [[Contribute](CONTRIBUTING.md)]
<a href="https://github.com/recp/cglm/graphs/contributors"><img src="https://opencollective.com/cglm/contributors.svg?width=890&button=false" /></a>
## Backers
@@ -315,6 +209,3 @@ Support this project by becoming a sponsor. Your logo will show up here with a l
<a href="https://opencollective.com/cglm/sponsor/7/website" target="_blank"><img src="https://opencollective.com/cglm/sponsor/7/avatar.svg"></a>
<a href="https://opencollective.com/cglm/sponsor/8/website" target="_blank"><img src="https://opencollective.com/cglm/sponsor/8/avatar.svg"></a>
<a href="https://opencollective.com/cglm/sponsor/9/website" target="_blank"><img src="https://opencollective.com/cglm/sponsor/9/avatar.svg"></a>
## License
MIT. check the LICENSE file

View File

@@ -1,7 +0,0 @@
image: Visual Studio 2017
build_script:
- ps: >-
cd win
.\build.bat

0
autogen.sh Normal file → Executable file
View File

BIN
cglm.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 378 KiB

View File

@@ -2,10 +2,10 @@ Pod::Spec.new do |s|
# Description
s.name = "cglm"
s.version = "0.6.1"
s.summary = "📽 Optimized OpenGL/Graphics Math (glm) for C"
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. It is similar to original glm but it is written for C instead of C++ (you can use here too). See the documentation or README for all features.
cglm is math library for graphics programming for C. See the documentation or README for all features.
DESC
s.documentation_url = "http://cglm.readthedocs.io"
@@ -25,4 +25,13 @@ cglm is math library for graphics programming for C. It is similar to original g
# Linking
s.library = "m"
# Configuration
s.pod_target_xcconfig = {
'CLANG_ENABLE_MODULES' => 'NO',
'CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES' => 'YES',
'CLANG_WARN_DOCUMENTATION_COMMENTS' => 'NO',
'GCC_C_LANGUAGE_STANDARD' => 'gnu11',
'GCC_PREPROCESSOR_DEFINITIONS' => '$(inherited) GLM_TESTS_NO_COLORFUL_OUTPUT'
}
end

View File

@@ -7,8 +7,8 @@
#*****************************************************************************
AC_PREREQ([2.69])
AC_INIT([cglm], [0.6.2], [info@recp.me])
AM_INIT_AUTOMAKE([-Wall -Werror foreign subdir-objects serial-tests])
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.
: ${CFLAGS=""}

0
docs/make.bat Normal file → Executable file
View File

4
docs/requirements.txt Normal file
View File

@@ -0,0 +1,4 @@
# Defining the exact version will make sure things don't break
sphinx==7.2.6
sphinx_rtd_theme==2.0.0
readthedocs-sphinx-search==0.3.2

198
docs/source/aabb2d.rst Normal file
View File

@@ -0,0 +1,198 @@
.. default-domain:: C
2d axis aligned bounding box (AABB)
================================================================================
Header: cglm/aabb2d.h
Some convenient functions provided for AABB.
**Definition of aabb:**
cglm defines an aabb as a two dimensional array of vec2's.
The first element is the **min** point and the second one is the **max** point.
If you have another type e.g. struct or even another representation then you must
convert it before and after calling a cglm aabb2d function.
Table of contents (click to go):
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Macros:
1. :c:func:`glm_aabb2d_size`
Functions:
1. :c:func:`glm_aabb2d_copy`
#. :c:func:`glm_aabb2d_zero`
#. :c:func:`glm_aabb2d_transform`
#. :c:func:`glm_aabb2d_merge`
#. :c:func:`glm_aabb2d_crop`
#. :c:func:`glm_aabb2d_crop_until`
#. :c:func:`glm_aabb2d_invalidate`
#. :c:func:`glm_aabb2d_isvalid`
#. :c:func:`glm_aabb2d_diag`
#. :c:func:`glm_aabb2d_sizev`
#. :c:func:`glm_aabb2d_radius`
#. :c:func:`glm_aabb2d_center`
#. :c:func:`glm_aabb2d_aabb`
#. :c:func:`glm_aabb2d_circle`
#. :c:func:`glm_aabb2d_point`
#. :c:func:`glm_aabb2d_contains`
Functions documentation
~~~~~~~~~~~~~~~~~~~~~~~
.. c:function:: void glm_aabb2d_copy(vec2 aabb[2], vec2 dest[2])
| copy all members of [aabb] to [dest]
Parameters:
| *[in]* **aabb** bounding box
| *[out]* **dest** destination
.. c:function:: void glm_aabb2d_zero(vec2 aabb[2])
| makes all members of [aabb] 0.0f (zero)
Parameters:
| *[in, out]* **aabb** bounding box
.. c:function:: void glm_aabb2d_transform(vec2 aabb[2], mat3 m, vec2 dest[2])
| apply transform to Axis-Aligned Bounding Box
Parameters:
| *[in]* **aabb** bounding box
| *[in]* **m** transform matrix
| *[out]* **dest** transformed bounding box
.. c:function:: void glm_aabb2d_merge(vec2 aabb1[2], vec2 aabb2[2], vec2 dest[2])
| merges two AABB bounding box and creates new one
two aabb must be in the same space
Parameters:
| *[in]* **aabb1** bounding box 1
| *[in]* **aabb2** bounding box 2
| *[out]* **dest** merged bounding box
.. c:function:: void glm_aabb2d_crop(vec2 aabb[2], vec2 cropAabb[2], vec2 dest[2])
| crops a bounding box with another one.
this could be useful for getting a bbox which fits with view frustum and
object bounding boxes. In this case you crop view frustum box with objects
box
Parameters:
| *[in]* **aabb** bounding box 1
| *[in]* **cropAabb** crop box
| *[out]* **dest** cropped bounding box
.. c:function:: void glm_aabb2d_crop_until(vec2 aabb[2], vec2 cropAabb[2], vec2 clampAabb[2], vec2 dest[2])
| crops a bounding box with another one.
this could be useful for getting a bbox which fits with view frustum and
object bounding boxes. In this case you crop view frustum box with objects
box
Parameters:
| *[in]* **aabb** bounding box
| *[in]* **cropAabb** crop box
| *[in]* **clampAabb** minimum box
| *[out]* **dest** cropped bounding box
.. c:function:: void glm_aabb2d_invalidate(vec2 aabb[2])
| invalidate AABB min and max values
| It fills *max* values with -FLT_MAX and *min* values with +FLT_MAX
Parameters:
| *[in, out]* **aabb** bounding box
.. c:function:: bool glm_aabb2d_isvalid(vec2 aabb[2])
| check if AABB is valid or not
Parameters:
| *[in]* **aabb** bounding box
Returns:
returns true if aabb is valid otherwise false
.. c:function:: float glm_aabb2d_diag(vec2 aabb[2])
| distance between min and max
Parameters:
| *[in]* **aabb** bounding box
Returns:
distance between min - max
.. c:function:: void glm_aabb2d_sizev(vec2 aabb[2], vec2 dest)
| size vector of aabb
Parameters:
| *[in]* **aabb** bounding box
| *[out]* **dest** size vector
Returns:
size vector of aabb max - min
.. c:function:: float glm_aabb2d_radius(vec2 aabb[2])
| radius of sphere which surrounds AABB
Parameters:
| *[in]* **aabb** bounding box
.. c:function:: void glm_aabb2d_center(vec2 aabb[2], vec2 dest)
| computes center point of AABB
Parameters:
| *[in]* **aabb** bounding box
| *[out]* **dest** center of bounding box
.. c:function:: bool glm_aabb2d_aabb(vec2 aabb[2], vec2 other[2])
| check if two AABB intersects
Parameters:
| *[in]* **aabb** bounding box
| *[out]* **other** other bounding box
.. c:function:: bool glm_aabb2d_circle(vec2 aabb[2], vec3 c)
| check if AABB intersects with sphere
| https://github.com/erich666/GraphicsGems/blob/master/gems/BoxSphere.c
| Solid Box - Solid Sphere test.
Parameters:
| *[in]* **aabb** solid bounding box
| *[out]* **c** solid circle
.. c:function:: bool glm_aabb2d_point(vec2 aabb[2], vec2 point)
| check if point is inside of AABB
Parameters:
| *[in]* **aabb** bounding box
| *[out]* **point** point
.. c:function:: bool glm_aabb2d_contains(vec2 aabb[2], vec2 other[2])
| check if AABB contains other AABB
Parameters:
| *[in]* **aabb** bounding box
| *[out]* **other** other bounding box

View File

@@ -0,0 +1,129 @@
.. default-domain:: C
3D Affine Transforms (common)
================================================================================
Common transform functions.
Table of contents (click to go):
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Functions:
1. :c:func:`glm_translate_make`
#. :c:func:`glm_scale_to`
#. :c:func:`glm_scale_make`
#. :c:func:`glm_scale`
#. :c:func:`glm_scale_uni`
#. :c:func:`glm_rotate_make`
#. :c:func:`glm_rotate_atm`
#. :c:func:`glm_decompose_scalev`
#. :c:func:`glm_uniscaled`
#. :c:func:`glm_decompose_rs`
#. :c:func:`glm_decompose`
Functions documentation
~~~~~~~~~~~~~~~~~~~~~~~
.. c:function:: void glm_translate_make(mat4 m, vec3 v)
creates NEW translate transform matrix by *v* vector.
Parameters:
| *[in, out]* **m** affine transform
| *[in]* **v** translate vector [x, y, z]
.. c:function:: void glm_scale_to(mat4 m, vec3 v, mat4 dest)
scale existing transform matrix by *v* vector and store result in dest
Parameters:
| *[in]* **m** affine transform
| *[in]* **v** scale vector [x, y, z]
| *[out]* **dest** scaled matrix
.. c:function:: void glm_scale_make(mat4 m, vec3 v)
creates NEW scale matrix by v vector
Parameters:
| *[out]* **m** affine transform
| *[in]* **v** scale vector [x, y, z]
.. c:function:: void glm_scale(mat4 m, vec3 v)
scales existing transform matrix by v vector
and stores result in same matrix
Parameters:
| *[in, out]* **m** affine transform
| *[in]* **v** scale vector [x, y, z]
.. c:function:: void glm_scale_uni(mat4 m, float s)
applies uniform scale to existing transform matrix v = [s, s, s]
and stores result in same matrix
Parameters:
| *[in, out]* **m** affine transform
| *[in]* **v** scale factor
.. c:function:: void glm_rotate_make(mat4 m, float angle, vec3 axis)
creates NEW rotation matrix by angle and axis,
axis will be normalized so you don't need to normalize it
Parameters:
| *[out]* **m** affine transform
| *[in]* **axis** angle (radians)
| *[in]* **axis** axis
.. c:function:: void glm_rotate_atm(mat4 m, vec3 pivot, float angle, vec3 axis)
| creates NEW rotation matrix by angle and axis at given point
| this creates rotation matrix, it assumes you don't have a matrix
| this should work faster than glm_rotate_at because it reduces one glm_translate.
Parameters:
| *[in, out]* **m** affine transform
| *[in]* **pivot** pivot, anchor point, rotation center
| *[in]* **angle** angle (radians)
| *[in]* **axis** axis
.. c:function:: void glm_decompose_scalev(mat4 m, vec3 s)
decompose scale vector
Parameters:
| *[in]* **m** affine transform
| *[out]* **s** scale vector (Sx, Sy, Sz)
.. c:function:: bool glm_uniscaled(mat4 m)
returns true if matrix is uniform scaled.
This is helpful for creating normal matrix.
Parameters:
| *[in]* **m** matrix
.. c:function:: void glm_decompose_rs(mat4 m, mat4 r, vec3 s)
decompose rotation matrix (mat4) and scale vector [Sx, Sy, Sz]
DON'T pass projected matrix here
Parameters:
| *[in]* **m** affine transform
| *[out]* **r** rotation matrix
| *[out]* **s** scale matrix
.. c:function:: void glm_decompose(mat4 m, vec4 t, mat4 r, vec3 s)
decompose affine transform, TODO: extract shear factors.
DON'T pass projected matrix here
Parameters:
| *[in]* **m** affine transform
| *[out]* **t** translation vector
| *[out]* **r** rotation matrix (mat4)
| *[out]* **s** scaling vector [X, Y, Z]

View File

@@ -1,6 +1,6 @@
.. default-domain:: C
affine transform matrix (specialized functions)
3D Affine Transform Matrix (specialized functions)
================================================================================
Header: cglm/affine-mat.h
@@ -25,7 +25,7 @@ You cannot use :c:func:`glm_mul` anymore.
Same is also true for :c:func:`glm_inv_tr` if you only have rotation and
translation then it will work as expected, otherwise you cannot use that.
In the future it may accept scale factors too but currectly it does not.
In the future it may accept scale factors too but currently it does not.
Table of contents (click func go):
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

127
docs/source/affine-post.rst Normal file
View File

@@ -0,0 +1,127 @@
.. default-domain:: C
3D Affine Transforms (post)
================================================================================
Post transform functions are similar to pre transform functions except order of application is reversed.
Post transform functions are applied after the object is transformed with given (model matrix) transform.
Table of contents (click to go):
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Functions:
1. :c:func:`glm_translated_to`
#. :c:func:`glm_translated`
#. :c:func:`glm_translated_x`
#. :c:func:`glm_translated_y`
#. :c:func:`glm_translated_z`
#. :c:func:`glm_rotated_x`
#. :c:func:`glm_rotated_y`
#. :c:func:`glm_rotated_z`
#. :c:func:`glm_rotated`
#. :c:func:`glm_rotated_at`
#. :c:func:`glm_spinned`
Functions documentation
~~~~~~~~~~~~~~~~~~~~~~~
.. c:function:: void glm_translated_to(mat4 m, vec3 v, mat4 dest)
translate existing transform matrix by *v* vector and store result in dest
Parameters:
| *[in]* **m** affine transform
| *[in]* **v** translate vector [x, y, z]
| *[out]* **dest** translated matrix
.. c:function:: void glm_translated(mat4 m, vec3 v)
translate existing transform matrix by *v* vector
and stores result in same matrix
Parameters:
| *[in, out]* **m** affine transform
| *[in]* **v** translate vector [x, y, z]
.. c:function:: void glm_translated_x(mat4 m, float x)
translate existing transform matrix by x factor
Parameters:
| *[in, out]* **m** affine transform
| *[in]* **v** x factor
.. c:function:: void glm_translated_y(mat4 m, float y)
translate existing transform matrix by *y* factor
Parameters:
| *[in, out]* **m** affine transform
| *[in]* **v** y factor
.. c:function:: void glm_translated_z(mat4 m, float z)
translate existing transform matrix by *z* factor
Parameters:
| *[in, out]* **m** affine transform
| *[in]* **v** z factor
.. c:function:: void glm_rotated_x(mat4 m, float angle, mat4 dest)
rotate existing transform matrix around X axis by angle
and store result in dest
Parameters:
| *[in]* **m** affine transform
| *[in]* **angle** angle (radians)
| *[out]* **dest** rotated matrix
.. c:function:: void glm_rotated_y(mat4 m, float angle, mat4 dest)
rotate existing transform matrix around Y axis by angle
and store result in dest
Parameters:
| *[in]* **m** affine transform
| *[in]* **angle** angle (radians)
| *[out]* **dest** rotated matrix
.. c:function:: void glm_rotated_z(mat4 m, float angle, mat4 dest)
rotate existing transform matrix around Z axis by angle
and store result in dest
Parameters:
| *[in]* **m** affine transform
| *[in]* **angle** angle (radians)
| *[out]* **dest** rotated matrix
.. c:function:: void glm_rotated(mat4 m, float angle, vec3 axis)
rotate existing transform matrix around Z axis by angle and axis
Parameters:
| *[in, out]* **m** affine transform
| *[in]* **angle** angle (radians)
| *[in]* **axis** axis
.. c:function:: void glm_rotated_at(mat4 m, vec3 pivot, float angle, vec3 axis)
rotate existing transform around given axis by angle at given pivot point (rotation center)
Parameters:
| *[in, out]* **m** affine transform
| *[in]* **pivot** pivot, anchor point, rotation center
| *[in]* **angle** angle (radians)
| *[in]* **axis** axis
.. c:function:: void glm_spinned(mat4 m, float angle, vec3 axis)
| rotate existing transform matrix around given axis by angle around self (doesn't affected by position)
Parameters:
| *[in, out]* **m** affine transform
| *[in]* **angle** angle (radians)
| *[in]* **axis** axis

154
docs/source/affine-pre.rst Normal file
View File

@@ -0,0 +1,154 @@
.. default-domain:: C
3D Affine Transforms (pre)
================================================================================
Pre transform functions which are regular transform functions.
Table of contents (click to go):
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Functions:
1. :c:func:`glm_translate_to`
#. :c:func:`glm_translate`
#. :c:func:`glm_translate_x`
#. :c:func:`glm_translate_y`
#. :c:func:`glm_translate_z`
#. :c:func:`glm_translate_make`
#. :c:func:`glm_scale_to`
#. :c:func:`glm_scale_make`
#. :c:func:`glm_scale`
#. :c:func:`glm_scale_uni`
#. :c:func:`glm_rotate_x`
#. :c:func:`glm_rotate_y`
#. :c:func:`glm_rotate_z`
#. :c:func:`glm_rotate_make`
#. :c:func:`glm_rotate`
#. :c:func:`glm_rotate_at`
#. :c:func:`glm_rotate_atm`
#. :c:func:`glm_decompose_scalev`
#. :c:func:`glm_uniscaled`
#. :c:func:`glm_decompose_rs`
#. :c:func:`glm_decompose`
#. :c:func:`glm_spin`
Functions documentation
~~~~~~~~~~~~~~~~~~~~~~~
.. c:function:: void glm_translate_to(mat4 m, vec3 v, mat4 dest)
translate existing transform matrix by *v* vector and store result in dest
Parameters:
| *[in]* **m** affine transform
| *[in]* **v** translate vector [x, y, z]
| *[out]* **dest** translated matrix
.. c:function:: void glm_translate(mat4 m, vec3 v)
translate existing transform matrix by *v* vector
and stores result in same matrix
Parameters:
| *[in, out]* **m** affine transform
| *[in]* **v** translate vector [x, y, z]
.. c:function:: void glm_translate_x(mat4 m, float x)
translate existing transform matrix by x factor
Parameters:
| *[in, out]* **m** affine transform
| *[in]* **v** x factor
.. c:function:: void glm_translate_y(mat4 m, float y)
translate existing transform matrix by *y* factor
Parameters:
| *[in, out]* **m** affine transform
| *[in]* **v** y factor
.. c:function:: void glm_translate_z(mat4 m, float z)
translate existing transform matrix by *z* factor
Parameters:
| *[in, out]* **m** affine transform
| *[in]* **v** z factor
.. c:function:: void glm_rotate_x(mat4 m, float angle, mat4 dest)
rotate existing transform matrix around X axis by angle
and store result in dest
Parameters:
| *[in]* **m** affine transform
| *[in]* **angle** angle (radians)
| *[out]* **dest** rotated matrix
.. c:function:: void glm_rotate_y(mat4 m, float angle, mat4 dest)
rotate existing transform matrix around Y axis by angle
and store result in dest
Parameters:
| *[in]* **m** affine transform
| *[in]* **angle** angle (radians)
| *[out]* **dest** rotated matrix
.. c:function:: void glm_rotate_z(mat4 m, float angle, mat4 dest)
rotate existing transform matrix around Z axis by angle
and store result in dest
Parameters:
| *[in]* **m** affine transform
| *[in]* **angle** angle (radians)
| *[out]* **dest** rotated matrix
.. c:function:: void glm_rotate(mat4 m, float angle, vec3 axis)
rotate existing transform matrix around given axis by angle at ORIGIN (0,0,0)
**❗IMPORTANT ❗️**
If you need to rotate object around itself e.g. center of object or at
some point [of object] then `glm_rotate_at()` would be better choice to do so.
Even if object's model transform is identity, rotation may not be around
center of object if object does not lay out at ORIGIN perfectly.
Using `glm_rotate_at()` with center of bounding shape ( AABB, Sphere ... )
would be an easy option to rotate around object if object is not at origin.
One another option to rotate around itself at any point is `glm_spin()`
which is perfect if only rotating around model position is desired e.g. not
specific point on model for instance center of geometry or center of mass,
again if geometry is not perfectly centered at origin at identity transform,
rotation may not be around geometry.
Parameters:
| *[in, out]* **m** affine transform
| *[in]* **angle** angle (radians)
| *[in]* **axis** axis
.. c:function:: void glm_rotate_at(mat4 m, vec3 pivot, float angle, vec3 axis)
rotate existing transform around given axis by angle at given pivot point (rotation center)
Parameters:
| *[in, out]* **m** affine transform
| *[in]* **pivot** pivot, anchor point, rotation center
| *[in]* **angle** angle (radians)
| *[in]* **axis** axis
.. c:function:: void glm_spin(mat4 m, float angle, vec3 axis)
| rotate existing transform matrix around given axis by angle around self (doesn't affected by position)
Parameters:
| *[in, out]* **m** affine transform
| *[in]* **angle** angle (radians)
| *[in]* **axis** axis

View File

@@ -1,10 +1,22 @@
.. default-domain:: C
affine transforms
3D Affine Transforms
================================================================================
Header: cglm/affine.h
Before starting, **cglm** provides two kind of transform functions; pre and post.
Pre functions (`T' = Tnew * T`) are like `glm_translate`, `glm_rotate` which means it will translate the vector first and then apply the model transformation.
Post functions (`T' = T * Tnew`) are like `glm_translated`, `glm_rotated` which means it will apply the model transformation first and then translate the vector.
`glm_translate`, `glm_rotate` are pre functions and are similar to C++ **glm** which you are familiar with.
In new versions of **cglm** we added `glm_translated`, `glm_rotated`... which are post functions,
they are useful in some cases, e.g. append transform to existing transform (apply/append transform as last transform T' = T * Tnew).
Post functions are named after pre functions with `ed` suffix, e.g. `glm_translate` -> `glm_translated`. So don't mix them up.
Initialize Transform Matrices
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Functions with **_make** prefix expect you don't have a matrix and they create
@@ -12,7 +24,7 @@ a matrix for you. You don't need to pass identity matrix.
But other functions expect you have a matrix and you want to transform them. If
you didn't have any existing matrix you have to initialize matrix to identity
before sending to transfrom functions.
before sending to transform functions.
There are also functions to decompose transform matrix. These functions can't
decompose matrix after projected.
@@ -23,18 +35,22 @@ Rotation Center
Rotating functions uses origin as rotation center (pivot/anchor point),
since scale factors are stored in rotation matrix, same may also true for scalling.
cglm provides some functions for rotating around at given point e.g.
**glm_rotate_at**, **glm_quat_rotate_at**. Use them or follow next section for algorihm ("Rotate or Scale around specific Point (Pivot Point / Anchor Point)").
**glm_rotate_at**, **glm_quat_rotate_at**. Use them or follow next section for algorithm ("Rotate or Scale around specific Point (Pivot Point / Anchor Point)").
Also **cglm** provides :c:func:`glm_spin` and :c:func:`glm_spinned` functions to rotate around itself. No need to give pivot.
These functions are useful for rotating around center of object.
Rotate or Scale around specific Point (Anchor Point)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
If you want to rotate model around arbibtrary point follow these steps:
If you want to rotate model around arbitrary point follow these steps:
1. Move model from pivot point to origin: **translate(-pivot.x, -pivot.y, -pivot.z)**
2. Apply rotation (or scaling maybe)
3. Move model back from origin to pivot (reverse of step-1): **translate(pivot.x, pivot.y, pivot.z)**
**glm_rotate_at**, **glm_quat_rotate_at** and their helper functions works that way.
**glm_rotate_at**, **glm_quat_rotate_at** and their helper functions works that way.
So if you use them you don't need to do these steps manually which are done by **cglm**.
The implementation would be:
@@ -45,6 +61,15 @@ The implementation would be:
glm_rotate(m, angle, axis);
glm_translate(m, pivotInv); /* pivotInv = -pivot */
or just:
.. code-block:: c
:linenos:
glm_rotate_at(m, pivot, angle, axis);
.. _TransformsOrder:
Transforms Order
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -52,16 +77,16 @@ It is important to understand this part especially if you call transform
functions multiple times
`glm_translate`, `glm_rotate`, `glm_scale` and `glm_quat_rotate` and their
helpers functions works like this (cglm may provide reverse order too as alternative in the future):
helpers functions works like this (cglm provides reverse order as `ed` suffix e.g `glm_translated`, `glm_rotated` see post transforms):
.. code-block:: c
:linenos:
TransformMatrix = TransformMatrix * TraslateMatrix; // glm_translate()
TransformMatrix = TransformMatrix * TranslateMatrix; // glm_translate()
TransformMatrix = TransformMatrix * RotateMatrix; // glm_rotate(), glm_quat_rotate()
TransformMatrix = TransformMatrix * ScaleMatrix; // glm_scale()
As you can see it is multipled as right matrix. For instance what will happen if you call `glm_translate` twice?
As you can see it is multiplied as right matrix. For instance what will happen if you call `glm_translate` twice?
.. code-block:: c
:linenos:
@@ -145,199 +170,27 @@ Functions:
#. :c:func:`glm_decompose_rs`
#. :c:func:`glm_decompose`
Post functions (**NEW**):
1. :c:func:`glm_translated_to`
#. :c:func:`glm_translated`
#. :c:func:`glm_translated_x`
#. :c:func:`glm_translated_y`
#. :c:func:`glm_translated_z`
#. :c:func:`glm_rotated_x`
#. :c:func:`glm_rotated_y`
#. :c:func:`glm_rotated_z`
#. :c:func:`glm_rotated`
#. :c:func:`glm_rotated_at`
#. :c:func:`glm_spinned`
Functions documentation
~~~~~~~~~~~~~~~~~~~~~~~
.. c:function:: void glm_translate_to(mat4 m, vec3 v, mat4 dest)
.. toctree::
:maxdepth: 1
:caption: Affine categories:
translate existing transform matrix by *v* vector and store result in dest
Parameters:
| *[in]* **m** affine transfrom
| *[in]* **v** translate vector [x, y, z]
| *[out]* **dest** translated matrix
.. c:function:: void glm_translate(mat4 m, vec3 v)
translate existing transform matrix by *v* vector
and stores result in same matrix
Parameters:
| *[in, out]* **m** affine transfrom
| *[in]* **v** translate vector [x, y, z]
.. c:function:: void glm_translate_x(mat4 m, float x)
translate existing transform matrix by x factor
Parameters:
| *[in, out]* **m** affine transfrom
| *[in]* **v** x factor
.. c:function:: void glm_translate_y(mat4 m, float y)
translate existing transform matrix by *y* factor
Parameters:
| *[in, out]* **m** affine transfrom
| *[in]* **v** y factor
.. c:function:: void glm_translate_z(mat4 m, float z)
translate existing transform matrix by *z* factor
Parameters:
| *[in, out]* **m** affine transfrom
| *[in]* **v** z factor
.. c:function:: void glm_translate_make(mat4 m, vec3 v)
creates NEW translate transform matrix by *v* vector.
Parameters:
| *[in, out]* **m** affine transfrom
| *[in]* **v** translate vector [x, y, z]
.. c:function:: void glm_scale_to(mat4 m, vec3 v, mat4 dest)
scale existing transform matrix by *v* vector and store result in dest
Parameters:
| *[in]* **m** affine transfrom
| *[in]* **v** scale vector [x, y, z]
| *[out]* **dest** scaled matrix
.. c:function:: void glm_scale_make(mat4 m, vec3 v)
creates NEW scale matrix by v vector
Parameters:
| *[out]* **m** affine transfrom
| *[in]* **v** scale vector [x, y, z]
.. c:function:: void glm_scale(mat4 m, vec3 v)
scales existing transform matrix by v vector
and stores result in same matrix
Parameters:
| *[in, out]* **m** affine transfrom
| *[in]* **v** scale vector [x, y, z]
.. c:function:: void glm_scale_uni(mat4 m, float s)
applies uniform scale to existing transform matrix v = [s, s, s]
and stores result in same matrix
Parameters:
| *[in, out]* **m** affine transfrom
| *[in]* **v** scale factor
.. c:function:: void glm_rotate_x(mat4 m, float angle, mat4 dest)
rotate existing transform matrix around X axis by angle
and store result in dest
Parameters:
| *[in]* **m** affine transfrom
| *[in]* **angle** angle (radians)
| *[out]* **dest** rotated matrix
.. c:function:: void glm_rotate_y(mat4 m, float angle, mat4 dest)
rotate existing transform matrix around Y axis by angle
and store result in dest
Parameters:
| *[in]* **m** affine transfrom
| *[in]* **angle** angle (radians)
| *[out]* **dest** rotated matrix
.. c:function:: void glm_rotate_z(mat4 m, float angle, mat4 dest)
rotate existing transform matrix around Z axis by angle
and store result in dest
Parameters:
| *[in]* **m** affine transfrom
| *[in]* **angle** angle (radians)
| *[out]* **dest** rotated matrix
.. c:function:: void glm_rotate_make(mat4 m, float angle, vec3 axis)
creates NEW rotation matrix by angle and axis,
axis will be normalized so you don't need to normalize it
Parameters:
| *[out]* **m** affine transfrom
| *[in]* **axis** angle (radians)
| *[in]* **axis** axis
.. c:function:: void glm_rotate(mat4 m, float angle, vec3 axis)
rotate existing transform matrix around Z axis by angle and axis
Parameters:
| *[in, out]* **m** affine transfrom
| *[in]* **angle** angle (radians)
| *[in]* **axis** axis
.. c:function:: void glm_rotate_at(mat4 m, vec3 pivot, float angle, vec3 axis)
rotate existing transform around given axis by angle at given pivot point (rotation center)
Parameters:
| *[in, out]* **m** affine transfrom
| *[in]* **pivot** pivot, anchor point, rotation center
| *[in]* **angle** angle (radians)
| *[in]* **axis** axis
.. c:function:: void glm_rotate_atm(mat4 m, vec3 pivot, float angle, vec3 axis)
| creates NEW rotation matrix by angle and axis at given point
| this creates rotation matrix, it assumes you don't have a matrix
| this should work faster than glm_rotate_at because it reduces one glm_translate.
Parameters:
| *[in, out]* **m** affine transfrom
| *[in]* **pivot** pivot, anchor point, rotation center
| *[in]* **angle** angle (radians)
| *[in]* **axis** axis
.. c:function:: void glm_decompose_scalev(mat4 m, vec3 s)
decompose scale vector
Parameters:
| *[in]* **m** affine transform
| *[out]* **s** scale vector (Sx, Sy, Sz)
.. c:function:: bool glm_uniscaled(mat4 m)
returns true if matrix is uniform scaled.
This is helpful for creating normal matrix.
Parameters:
| *[in]* **m** matrix
.. c:function:: void glm_decompose_rs(mat4 m, mat4 r, vec3 s)
decompose rotation matrix (mat4) and scale vector [Sx, Sy, Sz]
DON'T pass projected matrix here
Parameters:
| *[in]* **m** affine transform
| *[out]* **r** rotation matrix
| *[out]* **s** scale matrix
.. c:function:: void glm_decompose(mat4 m, vec4 t, mat4 r, vec3 s)
decompose affine transform, TODO: extract shear factors.
DON'T pass projected matrix here
Parameters:
| *[in]* **m** affine transfrom
| *[out]* **t** translation vector
| *[out]* **r** rotation matrix (mat4)
| *[out]* **s** scaling vector [X, Y, Z]
affine-common
affine-pre
affine-post

140
docs/source/affine2d.rst Normal file
View File

@@ -0,0 +1,140 @@
.. default-domain:: C
2D Affine Transforms
================================================================================
Header: cglm/affine2d.h
2D Transforms uses `2d` suffix for naming. If there is no 2D suffix it is 3D function.
Initialize Transform Matrices
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Functions with **_make** prefix expect you don't have a matrix and they create
a matrix for you. You don't need to pass identity matrix.
But other functions expect you have a matrix and you want to transform them. If
you didn't have any existing matrix you have to initialize matrix to identity
before sending to transform functions.
Transforms Order
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
See :ref:`TransformsOrder` to read similar section.
Table of contents (click to go):
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Functions:
1. :c:func:`glm_translate2d`
#. :c:func:`glm_translate2d_to`
#. :c:func:`glm_translate2d_x`
#. :c:func:`glm_translate2d_y`
#. :c:func:`glm_translate2d_make`
#. :c:func:`glm_scale2d_to`
#. :c:func:`glm_scale2d_make`
#. :c:func:`glm_scale2d`
#. :c:func:`glm_scale2d_uni`
#. :c:func:`glm_rotate2d_make`
#. :c:func:`glm_rotate2d`
#. :c:func:`glm_rotate2d_to`
.. c:function:: void glm_translate2d(mat3 m, vec2 v)
translate existing 2d transform matrix by *v* vector and stores result in same matrix
Parameters:
| *[in, out]* **m** 2d affine transform
| *[in]* **v** translate vector [x, y]
.. c:function:: void glm_translate2d_to(mat3 m, vec2 v, mat3 dest)
translate existing 2d transform matrix by *v* vector and store result in dest
Parameters:
| *[in]* **m** 2d affine transform
| *[in]* **v** translate vector [x, y]
| *[out]* **dest** translated matrix
.. c:function:: void glm_translate2d_x(mat3 m, float x)
translate existing 2d transform matrix by x factor
Parameters:
| *[in, out]* **m** 2d affine transform
| *[in]* **x** x factor
.. c:function:: void glm_translate2d_y(mat3 m, float y)
translate existing 2d transform matrix by y factor
Parameters:
| *[in, out]* **m** 2d affine transform
| *[in]* **y** y factor
.. c:function:: void glm_translate2d_make(mat3 m, vec2 v)
creates NEW translate 2d transform matrix by *v* vector
Parameters:
| *[in, out]* **m** affine transform
| *[in]* **v** translate vector [x, y]
.. c:function:: void glm_scale2d_to(mat3 m, vec2 v, mat3 dest)
scale existing 2d transform matrix by *v* vector and store result in dest
Parameters:
| *[in]* **m** affine transform
| *[in]* **v** scale vector [x, y]
| *[out]* **dest** scaled matrix
.. c:function:: void glm_scale2d_make(mat3 m, vec2 v)
creates NEW 2d scale matrix by *v* vector
Parameters:
| *[in, out]* **m** affine transform
| *[in]* **v** scale vector [x, y]
.. c:function:: void glm_scale2d(mat3 m, vec2 v)
scales existing 2d transform matrix by *v* vector and stores result in same matrix
Parameters:
| *[in, out]* **m** affine transform
| *[in]* **v** translate vector [x, y]
.. c:function:: void glm_scale2d_uni(mat3 m, float s)
applies uniform scale to existing 2d transform matrix v = [s, s] and stores result in same matrix
Parameters:
| *[in, out]* **m** affine transform
| *[in]* **s** scale factor
.. c:function:: void glm_rotate2d_make(mat3 m, float angle)
creates NEW rotation matrix by angle around *Z* axis
Parameters:
| *[in, out]* **m** affine transform
| *[in]* **angle** angle (radians)
.. c:function:: void glm_rotate2d(mat3 m, float angle)
rotate existing 2d transform matrix around *Z* axis by angle and store result in same matrix
Parameters:
| *[in, out]* **m** affine transform
| *[in]* **angle** angle (radians)
.. c:function:: void glm_rotate2d_to(mat3 m, float angle, mat3 dest)
rotate existing 2d transform matrix around *Z* axis by angle and store result in dest
Parameters:
| *[in]* **m** affine transform
| *[in]* **angle** angle (radians)
| *[out]* **dest** rotated matrix

View File

@@ -1,50 +1,28 @@
API documentation
📚 API documentation
================================
Some functions may exist twice,
once for their namespace and once for global namespace
to make easier to write very common functions
**cglm** provides a few APIs for similar functions.
For instance, in general we use :code:`glm_vec3_dot` to get dot product
of two **vec3**. Now we can also do this with :code:`glm_dot`,
same for *_cross* and so on...
* 📦 **Inline API**: All functions are inline. You can include **cglm/cglm.h** header
to use this API. This is the default API. `glm_` is namespace/prefix for this API.
* 📦 **Call API**: All functions are not inline. You need to build *cglm* and link it
to your project. You can include **cglm/call.h** header to use this API. `glmc_` is namespace/prefix for this API.
The original function stays where it is, the function in global namespace
of same name is just an alias, so there is no call version of those functions.
e.g there is no func like :code:`glmc_dot` because *glm_dot* is just alias for
:code:`glm_vec3_dot`
And also there are also sub categories:
By including **cglm/cglm.h** header you will include all inline version
of functions. Since functions in this header[s] are inline you don't need to
build or link *cglm* against your project.
* 📦 **Array API**: Types are raw arrays and functions takes array as argument. You can include **cglm/cglm.h** header
to use this API. This is the default API. `glm_` is namespace/prefix for this API.
* 📦 **Struct API**: Types are union/struct and functions takes struct as argument and return structs if needed. You can include **cglm/struct.h** header
to use this API. This also includes **cglm/cglm.h** header.`glms_` is namespace/prefix for this API but your can omit or change it, see struct api docs.
* 📦 **SIMD API**: SIMD functions and helpers. `glmm_` is namespace/prefix for this API.
But by including **cglm/call.h** header you will include all *non-inline*
version of functions. You need to build *cglm* and link it.
Follow the :doc:`build` documentation for this
📌 Since struct api and call api are built top of inline array api, follow inline array api docs for individual functions.
.. toctree::
:maxdepth: 1
:caption: API categories:
:caption: API documentations:
affine
affine-mat
cam
frustum
box
quat
euler
mat4
mat3
vec3
vec3-ext
vec4
vec4-ext
color
plane
project
util
io
call
sphere
curve
bezier
api_inline_array
api_struct
api_call
api_simd

11
docs/source/api_call.rst Normal file
View File

@@ -0,0 +1,11 @@
Call API
================================
Call API is pre-built API for making calls from library. It is built on top of the array api. **glmc_** is the namespace for the call api.
**c** stands for call.
You need to built cglm to use call api. See build instructions (:doc:`build`) for more details.
The functions except namespace **glmc_** are same as inline api. See ( :doc:`api_inline_array` ) for more details.
📌 In the future we can define option to forward inline functions or struct api to call api.

View File

@@ -0,0 +1,78 @@
Array API - Inline (Default)
========================================
This is the default API of *cglm*. All functions are forced to be inlined
and struct api, call api uses this inline api to share implementation.
📌 Call api is also array api but it is not inlined.
In the future there may be option to forward struct api to call api instead of inline api to reduce binary size if needed.
📌 **USE this API docs for similar functions in struct and call api**
📌 In struct api you can omit namespace e.g :code:`glms_vec3_dot` can be called as :code:`vec3_dot` in struct api, see :doc:`api_struct` to configure struct api for more details.
📌 In struct api functions can return struct/union
📌 In struct api you can access items like **.x**, **.y**, **.z**, **.w**, **.r**, **.g**, **.b**, **.a**, **.m00**, **m01**...
Some functions may exist twice, once for their namespace and once for global namespace
to make easier to write very common functions
For instance, in general we use :code:`glm_vec3_dot` to get dot product
of two **vec3**. Now we can also do this with :code:`glm_dot`,
same for *_cross* and so on...
The original function stays where it is, the function in global namespace
of same name is just an alias, so there is no call version of those functions.
e.g there is no func like :code:`glmc_dot` because *glm_dot* is just alias for
:code:`glm_vec3_dot`
By including **cglm/cglm.h** header you will include all inline version
of functions. Since functions in this header[s] are inline you don't need to
build or link *cglm* against your project.
But by including **cglm/call.h** header you will include all *non-inline*
version of functions. You need to build *cglm* and link it.
Follow the :doc:`build` documentation for this
.. toctree::
:maxdepth: 1
:caption: API categories:
affine
affine-mat
affine2d
cam
frustum
box
aabb2d
quat
euler
mat2
mat2x3
mat2x4
mat3
mat3x2
mat3x4
mat4
mat4x2
mat4x3
vec2
vec2-ext
vec3
vec3-ext
vec4
vec4-ext
ivec2
ivec3
ivec4
color
plane
noise
project
util
io
call
sphere
curve
bezier
version
ray

12
docs/source/api_simd.rst Normal file
View File

@@ -0,0 +1,12 @@
SIMD API
================================
SIMD api is special api for SIMD operations. **glmm_** prefix is used for SIMD operations in cglm. It is used in many places in cglm.
You can use it for your own SIMD operations too. In the future the api may be extended by time.
Supported SIMD architectures ( may vary by time )
* SSE / SSE2
* AVX
* NEON
* WASM 128

101
docs/source/api_struct.rst Normal file
View File

@@ -0,0 +1,101 @@
Struct API
================================
Struct API is alternative API to array api to use **cglm** with improved type safety and easy to use.
Since struct api is built top of array api, every struct API is not documented here.
See array api documentation for more information for individual functions.
By default struct api adds `s` suffix to every type name e.g. vec3s, mat4s, versors etc.
Also struct api `s` suffix to namespace e.g. `glms_vec3_add`, `glms_mat4_mul` etc.
By starting v0.9.0, struct api namespace is configurable. We can omit **glms_** namespace or
even change it with custom name to move existing api integrations to **cglm** more easily...
We can also add **s** to function names if we want e.g. `glms_vec3_add()` -> `vec3_add()` or `vec3s_add()`.
By including **cglm/struct.h** header you will include all struct api. It will also include **cglm/cglm.h** too.
Since struct apis are inline you don't need to build or link *cglm* against
your project unless if you want to use pre-built call-api too.
Struct API is built top of array api. So you can mix them.
Use **.raw** union member to access raw array data to use it with array api.
Unlike array api ([0], [1], [0][0] ...), it is also possible to use struct api
with **.x**, **.y**, **.z**, **.w**, **.r**, **.g**, **.b**, **.a**, **.m00**, **m01**...
accessors to access individual elements/properties of vectors and matrices.
Struct API usage:
-----------------
.. code-block:: c
#include <cglm/struct.h>
mat4s m1 = glms_mat4_identity(); /* init... */
mat4s m2 = glms_mat4_identity(); /* init... */
mat4s m3 = glms_mat4_mul(glms_mat4_mul(m1, m2), glms_mat4_mul(m3, m4));
vec3s v1 = { 1.0f, 0.0f, 0.0f };
vec3s v2 = { 0.0f, 1.0f, 0.0f };
vec4s v4 = { 0.0f, 1.0f, 0.0f, 0.0f };
vec4 v5a = { 0.0f, 1.0f, 0.0f, 0.0f };
mat4s m4 = glms_rotate(m3, M_PI_2,
glms_vec3_cross(glms_vec3_add(v1, v6)
glms_vec3_add(v1, v7)));
v1.x = 1.0f; v1.y = 0.0f; v1.z = 0.0f;
// or
v1.raw[0] = 1.0f; v1.raw[1] = 0.0f; v1.raw[2] = 0.0f;
/* use struct api with array api (mix them). */
/* use .raw to access array and use it with array api */
glm_vec4_add(m4.col[0].raw, v5a, m4.col[0].raw);
glm_mat4_mulv(m4.raw, v4.raw, v5a);
or omit `glms_` namespace completely (see options below):
.. code-block:: c
#define CGLM_OMIT_NS_FROM_STRUCT_API
#include <cglm/struct.h>
mat4s m1 = mat4_identity(); /* init... */
mat4s m2 = mat4_identity(); /* init... */
mat4s m3 = mat4_mul(mat4_mul(m1, m2), mat4_mul(m3, m4));
vec3s v1 = { 1.0f, 0.0f, 0.0f };
vec3s v2 = { 0.0f, 1.0f, 0.0f };
vec4s v4 = { 0.0f, 1.0f, 0.0f, 0.0f };
vec4 v5a = { 0.0f, 1.0f, 0.0f, 0.0f };
mat4s m4 = glms_rotate(m3, M_PI_2,
vec3_cross(vec3_add(v1, v6)
vec3_add(v1, v7)));
v1.x = 1.0f; v1.y = 0.0f; v1.z = 0.0f;
// or
v1.raw[0] = 1.0f; v1.raw[1] = 0.0f; v1.raw[2] = 0.0f;
/* use struct api with array api (mix them) */
glm_vec4_add(m4.col[0].raw, v5a, m4.col[0].raw);
glm_mat4_mulv(m4.raw, v4.raw, v5a);
Configuring the Struct API:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
To configure the Struct API namespace, you can define the following macros before including the cglm/struct.h header:
- **CGLM_OMIT_NS_FROM_STRUCT_API**: omits CGLM_STRUCT_API_NS (`glms_`) namespace completely if there is sub namespace e.g `mat4_`, `vec4_` ... DEFAULT is not defined
- **CGLM_STRUCT_API_NS**: define name space for struct api, DEFAULT is **glms**
- **CGLM_STRUCT_API_NAME_SUFFIX**: define name suffix, DEFAULT is **empty** e.g defining it as #define CGLM_STRUCT_API_NAME_SUFFIX s will add s suffix to mat4_mul -> mat4s_mul
❗️ IMPORTANT ❗️
It's a good idea to set up your config macros in build settings like CMake, Xcode, or Visual Studio. This is especially important if you're using features like Modules in Xcode, where adding macros directly before the **cglm** headers might not work.
Detailed documentation for Struct API:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Since struct api if built top of array api, see array api functions for more information about individual functions.

View File

@@ -62,7 +62,7 @@ Functions documentation
| crops a bounding box with another one.
this could be useful for gettng a bbox which fits with view frustum and
this could be useful for getting a bbox which fits with view frustum and
object bounding boxes. In this case you crop view frustum box with objects
box
@@ -75,14 +75,14 @@ Functions documentation
| crops a bounding box with another one.
this could be useful for gettng a bbox which fits with view frustum and
this could be useful for getting a bbox which fits with view frustum and
object bounding boxes. In this case you crop view frustum box with objects
box
Parameters:
| *[in]* **box** bounding box
| *[in]* **cropBox** crop box
| *[in]* **clampBox** miniumum box
| *[in]* **clampBox** minimum box
| *[out]* **dest** cropped bounding box
.. c:function:: bool glm_aabb_frustum(vec3 box[2], vec4 planes[6])

View File

@@ -3,9 +3,100 @@ Build cglm
| **cglm** does not have any external dependencies.
**NOTE:**
If you only need to inline versions, you don't need to build **cglm**, you don't need to link it to your program.
Just import cglm to your project as dependency / external lib by copy-paste then use it as usual
.. note::
If you only need to inline versions, you don't need to build **cglm**, you don't need to link it to your program.
Just import cglm to your project as dependency / external lib by copy-paste then use it as usual
CMake (All platforms):
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. code-block:: bash
:linenos:
$ mkdir build
$ cd build
$ cmake .. # [Optional] -DCGLM_SHARED=ON
$ make
$ sudo make install # [Optional]
**make** will build cglm to **build** folder.
If you don't want to install **cglm** to your system's folder you can get static and dynamic libs in this folder.
**CMake Options:**
.. code-block:: CMake
:linenos:
option(CGLM_SHARED "Shared build" ON)
option(CGLM_STATIC "Static build" OFF)
option(CGLM_USE_C99 "" OFF) # C11
option(CGLM_USE_TEST "Enable Tests" OFF) # for make check - make test
**Use as header-only library with your CMake project example**
This requires no building or installation of cglm.
.. code-block:: CMake
:linenos:
cmake_minimum_required(VERSION 3.8.2)
project(<Your Project Name>)
add_executable(${PROJECT_NAME} src/main.c)
target_link_libraries(${LIBRARY_NAME} PRIVATE
cglm_headers)
add_subdirectory(external/cglm/ EXCLUDE_FROM_ALL)
**Use with your CMake project example**
.. code-block:: CMake
:linenos:
cmake_minimum_required(VERSION 3.8.2)
project(<Your Project Name>)
add_executable(${PROJECT_NAME} src/main.c)
target_link_libraries(${LIBRARY_NAME} PRIVATE
cglm)
add_subdirectory(external/cglm/)
Meson (All platforms):
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. code-block::
:linenos:
$ meson build # [Optional] --default-library=static
$ cd build
$ ninja
$ sudo ninja install # [Optional]
**Meson Options:**
.. code-block::
:linenos:
c_std=c11
buildtype=release
default_library=shared
enable_tests=false # to run tests: ninja test
**Use with your Meson project**
.. code-block::
:linenos:
# Clone cglm or create a cglm.wrap under <source_root>/subprojects
project('name', 'c')
cglm_dep = dependency('cglm', fallback : 'cglm', 'cglm_dep')
executable('exe', 'src/main.c', dependencies : cglm_dep)
Unix (Autotools):
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

View File

@@ -3,17 +3,17 @@
precompiled functions (call)
================================================================================
All funcitons in **glm_** namespace are forced to **inline**.
All functions in **glm_** namespace are forced to **inline**.
Most functions also have pre-compiled version.
Precompiled versions are in **glmc_** namespace. *c* in the namespace stands for
"call".
Since precompiled functions are just wrapper for inline verisons,
Since precompiled functions are just wrapper for inline versions,
these functions are not documented individually.
It would be duplicate documentation also it
would be hard to sync documentation between inline and call verison for me.
would be hard to sync documentation between inline and call version for me.
By including **clgm/cglm.h** you include all inline verisons. To get precompiled
By including **clgm/cglm.h** you include all inline versions. To get precompiled
versions you need to include **cglm/call.h** header it also includes all
call versions plus *clgm/cglm.h* (inline verisons)
call versions plus *clgm/cglm.h* (inline versions)

View File

@@ -18,10 +18,10 @@ fast if you don't care specific projection values.
*_decomp* means decompose; these function can help to decompose projection
matrices.
**NOTE**: Be careful when working with high range (very small near, very large
far) projection matrices. You may not get exact value you gave.
**float** type cannot store very high precision so you will lose precision.
Also your projection matrix will be inaccurate due to losing precision
.. note:: Be careful when working with high range (very small near, very large
far) projection matrices. You may not get exact value you gave.
**float** type cannot store very high precision so you will lose precision.
Also your projection matrix will be inaccurate due to losing precision
Table of contents (click to go):
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -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`
@@ -101,7 +103,7 @@ Functions documentation
Parameters:
| *[in]* **box** AABB
| *[in]* **padding** padding
| *[out]* **d** result matrix
| *[out]* **dest** result matrix
.. c:function:: void glm_ortho_aabb_pz(vec3 box[2], float padding, mat4 dest)
@@ -113,7 +115,7 @@ Functions documentation
Parameters:
| *[in]* **box** AABB
| *[in]* **padding** padding for near and far
| *[out]* **d** result matrix
| *[out]* **dest** result matrix
Returns:
square of norm / magnitude
@@ -140,12 +142,27 @@ Functions documentation
| set up perspective projection matrix
Parameters:
| *[in]* **fovy** field of view angle
| *[in]* **fovy** field of view angle (in radians)
| *[in]* **aspect** aspect ratio ( width / height )
| *[in]* **nearVal** near clipping plane
| *[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 )
@@ -178,7 +209,7 @@ Functions documentation
| set up view matrix
**NOTE:** The UP vector must not be parallel to the line of sight from the eye point to the reference point.
.. note:: The UP vector must not be parallel to the line of sight from the eye point to the reference point.
Parameters:
| *[in]* **eye** eye vector
@@ -194,11 +225,11 @@ Functions documentation
target self then this might be useful. Because you need to get target
from direction.
**NOTE:** The UP vector must not be parallel to the line of sight from the eye point to the reference point.
.. note:: The UP vector must not be parallel to the line of sight from the eye point to the reference point.
Parameters:
| *[in]* **eye** eye vector
| *[in]* **center** direction vector
| *[in]* **dir** direction vector
| *[in]* **up** up vector
| *[out]* **dest** result matrix
@@ -212,7 +243,7 @@ Functions documentation
Parameters:
| *[in]* **eye** eye vector
| *[in]* **center** direction vector
| *[in]* **dir** direction vector
| *[out]* **dest** result matrix
.. c:function:: void glm_persp_decomp(mat4 proj, float *nearVal, float *farVal, float *top, float *bottom, float *left, float *right)
@@ -250,7 +281,7 @@ Functions documentation
.. c:function:: void glm_persp_decomp_y(mat4 proj, float *top, float *bottom)
| decomposes top and bottom values of perspective projection.
| y stands for y axis (top / botom axis)
| y stands for y axis (top / bottom axis)
Parameters:
| *[in]* **proj** perspective projection matrix

View File

@@ -25,7 +25,7 @@
# If your documentation needs a minimal Sphinx version, state it here.
#
# needs_sphinx = '1.0'
# needs_sphinx = '3.0'
# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
@@ -62,16 +62,16 @@ author = u'Recep Aslantas'
# built documents.
#
# The short X.Y version.
version = u'0.6.2'
version = u'0.9.6'
# The full version, including alpha/beta/rc tags.
release = u'0.6.2'
release = u'0.9.6'
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
#
# This is also used if you do content translation via gettext catalogs.
# Usually you set "language" from the command line for these cases.
language = None
language = 'en'
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
@@ -91,6 +91,7 @@ todo_include_todos = False
# a list of builtin themes.
#
html_theme = 'sphinx_rtd_theme'
pygments_style = 'monokai'
# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
@@ -111,8 +112,11 @@ html_theme_options = {
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']
html_static_path = ['sphinx-static']
# Add customm CSS and JS files
html_css_files = ['theme_overrides.css']
html_js_files = []
# -- Options for HTMLHelp output ------------------------------------------
@@ -197,3 +201,7 @@ epub_exclude_files = ['search.html']
# If true, `todo` and `todoList` produce output, else they produce nothing.
todo_include_todos = True
# -- Options for the C domain ------------------------------------------------
c_id_attributes = ['__restrict']

View File

@@ -1,10 +1,13 @@
Features
================================================================================
* **scalar** and **simd** (sse, avx, neon, wasm...) optimizations
* option to use different clipspaces e.g. Left Handed, Zero-to-One... (currently right handed negative-one is default)
* array api and struct api, you can use arrays or structs.
* general purpose matrix operations (mat4, mat3)
* chain matrix multiplication (square only)
* general purpose vector operations (cross, dot, rotate, proj, angle...)
* affine transforms
* affine transformations
* matrix decomposition (extract rotation, scaling factor)
* optimized affine transform matrices (mul, rigid-body inverse)
* camera (lookat)
@@ -15,9 +18,12 @@ Features
* inline or pre-compiled function call
* frustum (extract view frustum planes, corners...)
* bounding box (AABB in Frustum (culling), crop, merge...)
* 2d bounding box (crop, merge...)
* bounding sphere
* project, unproject
* easing functions
* curves
* curve interpolation helpers (SMC, deCasteljau...)
* and other...
* helpers to convert cglm types to Apple's simd library to pass cglm types to Metal GL without packing them on both sides
* ray intersection helpers
* and others...

View File

@@ -11,9 +11,9 @@ not **vec3**. If you want to store them to save space you msut convert them
yourself.
**vec4** is used to speed up functions need to corners. This is why frustum
fucntions use *vec4* instead of *vec3*
functions use *vec4* instead of *vec3*
Currenty related-functions use [-1, 1] clip space configuration to extract
Currently related-functions use [-1, 1] clip space configuration to extract
corners but you can override it by prodiving **GLM_CUSTOM_CLIPSPACE** macro.
If you provide it then you have to all bottom macros as *vec4*

View File

@@ -22,7 +22,7 @@ Types:
typedef CGLM_ALIGN_IF(16) vec4 mat4[4];
#endif
As you can see types don't store extra informations in favor of space.
As you can see types don't store extra information in favor of space.
You can send these values e.g. matrix to OpenGL directly without casting or calling a function like *value_ptr*
Alignment Is Required:
@@ -35,16 +35,16 @@ Alignment Is Required:
| Check :doc:`opt` page for more details
Also alignment is disabled for older msvc verisons as default. Now alignment is only required in Visual Studio 2017 version 15.6+ if CGLM_ALL_UNALIGNED macro is not defined.
Also alignment is disabled for older msvc versions as default. Now alignment is only required in Visual Studio 2017 version 15.6+ if CGLM_ALL_UNALIGNED macro is not defined.
Allocations:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*cglm* doesn't alloc any memory on heap. So it doesn't provide any allocator.
You must allocate memory yourself. You should alloc memory for out parameters too if you pass pointer of memory location. When allocating memory, don't forget that **vec4** and **mat4** require alignment.
**NOTE:** Unaligned **vec4** and unaligned **mat4** operations will be supported in the future. Check todo list.
Because you may want to multiply a CGLM matrix with external matrix.
There is no guarantee that non-CGLM matrix is aligned. Unaligned types will have *u* prefix e.g. **umat4**
.. note:: Unaligned **vec4** and unaligned **mat4** operations will be supported in the future. Check todo list.
Because you may want to multiply a CGLM matrix with external matrix.
There is no guarantee that non-CGLM matrix is aligned. Unaligned types will have *u* prefix e.g. **umat4**
Array vs Struct:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

View File

@@ -6,13 +6,12 @@
cglm Documentation
================================
**cglm** is optimized 3D math library written in C99 (compatible with C89).
It is similar to original **glm** library except this is mainly for **C**
**cglm** is an optimized 3D math library written in C99 (compatible with C89).
It is similar to the original **glm** library, except **cglm** is mainly for
**C**.
This library stores matrices as column-major order but in the future row-major
is considered to be supported as optional.
Also currently only **float** type is supported for most operations.
**cglm** stores matrices as column-major order but in the future row-major is
considered to be supported as optional.
.. toctree::
:maxdepth: 2
@@ -29,7 +28,7 @@ Also currently only **float** type is supported for most operations.
opengl
.. toctree::
:maxdepth: 2
:maxdepth: 3
:caption: API:
api
@@ -46,8 +45,8 @@ Also currently only **float** type is supported for most operations.
troubleshooting
Indices and tables
==================
Indices and Tables:
===================
* :ref:`genindex`
* :ref:`modindex`

View File

@@ -24,9 +24,26 @@ Example to print mat4 matrix:
/* ... */
glm_mat4_print(transform, stderr);
**NOTE:** print functions use **%0.4f** precision if you need more
(you probably will in some cases), you can change it temporary.
cglm may provide precision parameter in the future
.. note:: print functions use **%0.4f** precision if you need more
(you probably will in some cases), you can change it temporary.
cglm may provide precision parameter in the future.
Changes since **v0.7.3**:
* Now mis-alignment of columns are fixed: larger numbers are printed via %g and others are printed via %f. Column widths are calculated before print.
* Now values are colorful ;)
* Some print improvements
* New options with default values:
.. code-block:: c
#define CGLM_PRINT_PRECISION 5
#define CGLM_PRINT_MAX_TO_SHORT 1e5
#define CGLM_PRINT_COLOR "\033[36m"
#define CGLM_PRINT_COLOR_RESET "\033[0m"
* Inline prints are only enabled in DEBUG mode and if **CGLM_DEFINE_PRINTS** is defined.
Check options page.
Table of contents (click to go):
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -36,8 +53,11 @@ Functions:
1. :c:func:`glm_mat4_print`
#. :c:func:`glm_mat3_print`
#. :c:func:`glm_vec4_print`
#. :c:func:`glm_ivec4_print`
#. :c:func:`glm_vec3_print`
#. :c:func:`glm_ivec3_print`
#. :c:func:`glm_vec2_print`
#. :c:func:`glm_ivec2_print`
#. :c:func:`glm_versor_print`
#. :c:func:`glm_aabb_print`
@@ -46,7 +66,7 @@ Functions documentation
.. c:function:: void glm_mat4_print(mat4 matrix, FILE * __restrict ostream)
| print mat4 to given stream
| print matrix to given stream
Parameters:
| *[in]* **matrix** matrix
@@ -54,7 +74,7 @@ Functions documentation
.. c:function:: void glm_mat3_print(mat3 matrix, FILE * __restrict ostream)
| print mat3 to given stream
| print matrix to given stream
Parameters:
| *[in]* **matrix** matrix
@@ -62,7 +82,15 @@ Functions documentation
.. c:function:: void glm_vec4_print(vec4 vec, FILE * __restrict ostream)
| print vec4 to given stream
| print vector to given stream
Parameters:
| *[in]* **vec** vector
| *[in]* **ostream** FILE to write
.. c:function:: void glm_ivec4_print(ivec4 vec, FILE * __restrict ostream)
| print vector to given stream
Parameters:
| *[in]* **vec** vector
@@ -70,7 +98,7 @@ Functions documentation
.. c:function:: void glm_vec3_print(vec3 vec, FILE * __restrict ostream)
| print vec3 to given stream
| print vector to given stream
Parameters:
| *[in]* **vec** vector
@@ -78,12 +106,29 @@ Functions documentation
.. c:function:: void glm_ivec3_print(ivec3 vec, FILE * __restrict ostream)
| print ivec3 to given stream
| print vector to given stream
Parameters:
| *[in]* **vec** vector
| *[in]* **ostream** FILE to write
.. c:function:: void glm_vec2_print(vec2 vec, FILE * __restrict ostream)
| print vector to given stream
Parameters:
| *[in]* **vec** vector
| *[in]* **ostream** FILE to write
.. c:function:: void glm_ivec2_print(ivec2 vec, FILE * __restrict ostream)
| print vector to given stream
Parameters:
| *[in]* **vec** vector
| *[in]* **ostream** FILE to write
.. c:function:: void glm_versor_print(versor vec, FILE * __restrict ostream)
| print quaternion to given stream
@@ -98,5 +143,5 @@ Functions documentation
Parameters:
| *[in]* **vec** aabb (axis-aligned bounding box)
| *[in]* **tag** tag to find it more easly in logs
| *[in]* **tag** tag to find it more easily in logs
| *[in]* **ostream** FILE to write

260
docs/source/ivec2.rst Normal file
View File

@@ -0,0 +1,260 @@
.. default-domain:: C
ivec2
=====
Header: cglm/ivec2.h
Table of contents (click to go):
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Macros:
1. GLM_IVEC2_ONE_INIT
#. GLM_IVEC2_ZERO_INIT
#. GLM_IVEC2_ONE
#. GLM_IVEC2_ZERO
Functions:
1. :c:func:`glm_ivec2`
#. :c:func:`glm_ivec2_copy`
#. :c:func:`glm_ivec2_zero`
#. :c:func:`glm_ivec2_one`
#. :c:func:`glm_ivec2_dot`
#. :c:func:`glm_ivec2_cross`
#. :c:func:`glm_ivec2_add`
#. :c:func:`glm_ivec2_adds`
#. :c:func:`glm_ivec2_sub`
#. :c:func:`glm_ivec2_subs`
#. :c:func:`glm_ivec2_mul`
#. :c:func:`glm_ivec2_scale`
#. :c:func:`glm_ivec2_div`
#. :c:func:`glm_ivec2_divs`
#. :c:func:`glm_ivec2_mod`
#. :c:func:`glm_ivec2_distance2`
#. :c:func:`glm_ivec2_distance`
#. :c:func:`glm_ivec2_maxv`
#. :c:func:`glm_ivec2_minv`
#. :c:func:`glm_ivec2_clamp`
#. :c:func:`glm_ivec2_abs`
Functions documentation
~~~~~~~~~~~~~~~~~~~~~~~
.. c:function:: void glm_ivec2(int * v, ivec2 dest)
init ivec2 using vec3 or vec4
Parameters:
| *[in]* **v** vector
| *[out]* **dest** destination
.. c:function:: void glm_ivec2_copy(ivec2 a, ivec2 dest)
copy all members of [a] to [dest]
Parameters:
| *[in]* **a** source vector
| *[out]* **dest** destination
.. c:function:: void glm_ivec2_zero(ivec2 v)
set all members of [v] to zero
Parameters:
| *[out]* **v** vector
.. c:function:: void glm_ivec2_one(ivec2 v)
set all members of [v] to one
Parameters:
| *[out]* **v** vector
.. c:function:: int glm_ivec2_dot(ivec2 a, ivec2 b)
dot product of ivec2
Parameters:
| *[in]* **a** vector1
| *[in]* **b** vector2
Returns:
dot product
.. c:function:: int glm_ivec2_cross(ivec2 a, ivec2 b)
cross product of two vector (RH)
| ref: http://allenchou.net/2013/07/cross-product-of-2d-vectors/
Parameters:
| *[in]* **a** vector 1
| *[in]* **b** vector 2
Returns:
Z component of cross product
.. c:function:: void glm_ivec2_add(ivec2 a, ivec2 b, ivec2 dest)
add vector [a] to vector [b] and store result in [dest]
Parameters:
| *[in]* **a** first vector
| *[in]* **b** second vector
| *[out]* **dest** destination
.. c:function:: void glm_ivec2_adds(ivec2 v, int s, ivec2 dest)
add scalar s to vector [v] and store result in [dest]
Parameters:
| *[in]* **v** vector
| *[in]* **s** scalar
| *[out]* **dest** destination
.. c:function:: void glm_ivec2_sub(ivec2 a, ivec2 b, ivec2 dest)
subtract vector [b] from vector [a] and store result in [dest]
Parameters:
| *[in]* **a** first vector
| *[in]* **b** second vector
| *[out]* **dest** destination
.. c:function:: void glm_ivec2_subs(ivec2 v, int s, ivec2 dest)
subtract scalar s from vector [v] and store result in [dest]
Parameters:
| *[in]* **v** vector
| *[in]* **s** scalar
| *[out]* **dest** destination
.. c:function:: void glm_ivec2_mul(ivec2 a, ivec2 b, ivec2 dest)
multiply vector [a] with vector [b] and store result in [dest]
Parameters:
| *[in]* **a** first vector
| *[in]* **b** second vector
| *[out]* **dest** destination
.. c:function:: void glm_ivec2_scale(ivec2 v, int s, ivec2 dest)
multiply vector [a] with scalar s and store result in [dest]
Parameters:
| *[in]* **v** vector
| *[in]* **s** scalar
| *[out]* **dest** destination
.. c:function:: void glm_ivec2_div(ivec2 a, ivec2 b, ivec2 dest)
div vector with another component-wise division: d = a / b
Parameters:
| *[in]* **a** vector 1
| *[in]* **b** vector 2
| *[out]* **dest** result = (a[0] / b[0], a[1] / b[1], a[2] / b[2])
.. c:function:: void glm_ivec2_divs(ivec2 v, int s, ivec2 dest)
div vector with scalar: d = v / s
Parameters:
| *[in]* **v** vector
| *[in]* **s** scalar
| *[out]* **dest** result = (a[0] / s, a[1] / s, a[2] / s)
.. c:function:: void glm_ivec2_mod(ivec2 a, ivec2 b, ivec2 dest)
mod vector with another component-wise modulo: d = a % b
Parameters:
| *[in]* **a** vector
| *[in]* **b** scalar
| *[out]* **dest** result = (a[0] % b[0], a[1] % b[1])
.. c:function:: int glm_ivec2_distance2(ivec2 a, ivec2 b)
squared distance between two vectors
Parameters:
| *[in]* **a** first vector
| *[in]* **b** second vector
Returns:
squared distance (distance * distance)
.. c:function:: float glm_ivec2_distance(ivec2 a, ivec2 b)
distance between two vectors
Parameters:
| *[in]* **a** first vector
| *[in]* **b** second vector
Returns:
distance
.. c:function:: void glm_ivec2_fill(ivec2 v, int val)
fill a vector with specified value
Parameters:
| *[out]* **v** vector
| *[in]* **val** value
.. c:function:: bool glm_ivec2_eq(ivec2 v, int val)
check if vector is equal to value
Parameters:
| *[in]* **v** vector
| *[in]* **val** value
.. c:function:: bool glm_ivec2_eqv(ivec2 v1, ivec2 v2)
check if vector is equal to another vector
Parameters:
| *[in]* **vec** vector 1
| *[in]* **vec** vector 2
.. c:function:: void glm_ivec2_maxv(ivec2 a, ivec2 b, ivec2 dest)
set each member of dest to greater of vector a and b
Parameters:
| *[in]* **a** first vector
| *[in]* **b** second vector
| *[out]* **dest** destination
.. c:function:: void glm_ivec2_minv(ivec2 a, ivec2 b, ivec2 dest)
set each member of dest to lesser of vector a and b
Parameters:
| *[in]* **a** first vector
| *[in]* **b** second vector
| *[out]* **dest** destination
.. c:function:: void glm_ivec2_clamp(ivec2 v, int minVal, int maxVal)
clamp each member of [v] between minVal and maxVal (inclusive)
Parameters:
| *[in, out]* **v** vector
| *[in]* **minVal** minimum value
| *[in]* **maxVal** maximum value
.. c:function:: void glm_ivec2_abs(ivec2 v, ivec2 dest)
absolute value of each vector item
Parameters:
| *[in]* **v** vector
| *[out]* **dest** destination vector

272
docs/source/ivec3.rst Normal file
View File

@@ -0,0 +1,272 @@
.. default-domain:: C
ivec3
=====
Header: cglm/ivec3.h
Table of contents (click to go):
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Macros:
1. GLM_IVEC3_ONE_INIT
#. GLM_IVEC3_ZERO_INIT
#. GLM_IVEC3_ONE
#. GLM_IVEC3_ZERO
Functions:
1. :c:func:`glm_ivec3`
#. :c:func:`glm_ivec3_copy`
#. :c:func:`glm_ivec3_zero`
#. :c:func:`glm_ivec3_one`
#. :c:func:`glm_ivec3_dot`
#. :c:func:`glm_ivec3_norm2`
#. :c:func:`glm_ivec3_norm`
#. :c:func:`glm_ivec3_add`
#. :c:func:`glm_ivec3_adds`
#. :c:func:`glm_ivec3_sub`
#. :c:func:`glm_ivec3_subs`
#. :c:func:`glm_ivec3_mul`
#. :c:func:`glm_ivec3_scale`
#. :c:func:`glm_ivec3_div`
#. :c:func:`glm_ivec3_divs`
#. :c:func:`glm_ivec3_mod`
#. :c:func:`glm_ivec3_distance2`
#. :c:func:`glm_ivec3_distance`
#. :c:func:`glm_ivec3_fill`
#. :c:func:`glm_ivec3_eq`
#. :c:func:`glm_ivec3_eqv`
#. :c:func:`glm_ivec3_maxv`
#. :c:func:`glm_ivec3_minv`
#. :c:func:`glm_ivec3_clamp`
#. :c:func:`glm_ivec2_abs`
Functions documentation
~~~~~~~~~~~~~~~~~~~~~~~
.. c:function:: void glm_ivec3(ivec4 v4, ivec3 dest)
init ivec3 using ivec4
Parameters:
| *[in]* **v** vector
| *[out]* **dest** destination
.. c:function:: void glm_ivec3_copy(ivec3 a, ivec3 dest)
copy all members of [a] to [dest]
Parameters:
| *[in]* **a** source vector
| *[out]* **dest** destination
.. c:function:: void glm_ivec3_zero(ivec3 v)
set all members of [v] to zero
Parameters:
| *[out]* **v** vector
.. c:function:: void glm_ivec3_one(ivec3 v)
set all members of [v] to one
Parameters:
| *[out]* **v** vector
.. c:function:: int glm_ivec3_dot(ivec3 a, ivec3 b)
dot product of ivec3
Parameters:
| *[in]* **a** vector1
| *[in]* **b** vector2
Returns:
dot product
.. c:function:: int glm_ivec3_norm2(ivec3 v)
norm * norm (magnitude) of vector
we can use this func instead of calling norm * norm, because it would call
sqrtf function twice but with this func we can avoid func call, maybe this is
not good name for this func
Parameters:
| *[in]* **v** vector
Returns:
square of norm / magnitude, cast to an integer
.. c:function:: int glm_ivec3_norm(ivec3 vec)
| euclidean norm (magnitude), also called L2 norm
| this will give magnitude of vector in euclidean space
Parameters:
| *[in]* **vec** vector
.. c:function:: void glm_ivec3_add(ivec3 a, ivec3 b, ivec3 dest)
add vector [a] to vector [b] and store result in [dest]
Parameters:
| *[in]* **a** first vector
| *[in]* **b** second vector
| *[out]* **dest** destination
.. c:function:: void glm_ivec3_adds(ivec3 v, int s, ivec3 dest)
add scalar s to vector [v] and store result in [dest]
Parameters:
| *[in]* **v** vector
| *[in]* **s** scalar
| *[out]* **dest** destination
.. c:function:: void glm_ivec3_sub(ivec3 a, ivec3 b, ivec3 dest)
subtract vector [b] from vector [a] and store result in [dest]
Parameters:
| *[in]* **a** first vector
| *[in]* **b** second vector
| *[out]* **dest** destination
.. c:function:: void glm_ivec3_subs(ivec3 v, int s, ivec3 dest)
subtract scalar s from vector [v] and store result in [dest]
Parameters:
| *[in]* **v** vector
| *[in]* **s** scalar
| *[out]* **dest** destination
.. c:function:: void glm_ivec3_mul(ivec3 a, ivec3 b, ivec3 dest)
multiply vector [a] with vector [b] and store result in [dest]
Parameters:
| *[in]* **a** first vector
| *[in]* **b** second vector
| *[out]* **dest** destination
.. c:function:: void glm_ivec3_scale(ivec3 v, int s, ivec3 dest)
multiply vector [a] with scalar s and store result in [dest]
Parameters:
| *[in]* **v** vector
| *[in]* **s** scalar
| *[out]* **dest** destination
.. c:function:: void glm_ivec3_div(ivec3 a, ivec3 b, ivec3 dest)
div vector with another component-wise division: d = a / b
Parameters:
| *[in]* **a** vector 1
| *[in]* **b** vector 2
| *[out]* **dest** result = (a[0] / b[0], a[1] / b[1], a[2] / b[2])
.. c:function:: void glm_ivec3_divs(ivec3 v, int s, ivec3 dest)
div vector with scalar: d = v / s
Parameters:
| *[in]* **v** vector
| *[in]* **s** scalar
| *[out]* **dest** result = (a[0] / s, a[1] / s, a[2] / s)
.. c:function:: void glm_ivec3_mod(ivec3 a, ivec3 b, ivec3 dest)
mod vector with another component-wise modulo: d = a % b
Parameters:
| *[in]* **a** vector
| *[in]* **b** scalar
| *[out]* **dest** result = (a[0] % b[0], a[1] % b[1], a[2] % b[2])
.. c:function:: int glm_ivec3_distance2(ivec3 a, ivec3 b)
squared distance between two vectors
Parameters:
| *[in]* **a** first vector
| *[in]* **b** second vector
Returns:
squared distance (distance * distance)
.. c:function:: float glm_ivec3_distance(ivec3 a, ivec3 b)
distance between two vectors
Parameters:
| *[in]* **a** first vector
| *[in]* **b** second vector
Returns:
distance
.. c:function:: void glm_ivec3_fill(ivec3 v, int val)
fill a vector with specified value
Parameters:
| *[out]* **v** vector
| *[in]* **val** value
.. c:function:: bool glm_ivec3_eq(ivec3 v, int val)
check if vector is equal to value
Parameters:
| *[in]* **v** vector
| *[in]* **val** value
.. c:function:: bool glm_ivec3_eqv(ivec3 v1, ivec3 v2)
check if vector is equal to another vector
Parameters:
| *[in]* **vec** vector 1
| *[in]* **vec** vector 2
.. c:function:: void glm_ivec3_maxv(ivec3 a, ivec3 b, ivec3 dest)
set each member of dest to greater of vector a and b
Parameters:
| *[in]* **a** first vector
| *[in]* **b** second vector
| *[out]* **dest** destination
.. c:function:: void glm_ivec3_minv(ivec3 a, ivec3 b, ivec3 dest)
set each member of dest to lesser of vector a and b
Parameters:
| *[in]* **a** first vector
| *[in]* **b** second vector
| *[out]* **dest** destination
.. c:function:: void glm_ivec3_clamp(ivec3 v, int minVal, int maxVal)
clamp each member of [v] between minVal and maxVal (inclusive)
Parameters:
| *[in, out]* **v** vector
| *[in]* **minVal** minimum value
| *[in]* **maxVal** maximum value
.. c:function:: void glm_ivec3_abs(ivec3 v, ivec3 dest)
absolute value of each vector item
Parameters:
| *[in]* **v** vector
| *[out]* **dest** destination vector

179
docs/source/ivec4.rst Normal file
View File

@@ -0,0 +1,179 @@
.. default-domain:: C
ivec4
=====
Header: cglm/ivec4.h
Table of contents (click to go):
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Macros:
1. GLM_IVEC4_ONE_INIT
#. GLM_IVEC4_ZERO_INIT
#. GLM_IVEC4_ONE
#. GLM_IVEC4_ZERO
Functions:
1. :c:func:`glm_ivec4`
#. :c:func:`glm_ivec4_copy`
#. :c:func:`glm_ivec4_zero`
#. :c:func:`glm_ivec4_one`
#. :c:func:`glm_ivec4_add`
#. :c:func:`glm_ivec4_adds`
#. :c:func:`glm_ivec4_sub`
#. :c:func:`glm_ivec4_subs`
#. :c:func:`glm_ivec4_mul`
#. :c:func:`glm_ivec4_scale`
#. :c:func:`glm_ivec4_distance2`
#. :c:func:`glm_ivec4_distance`
#. :c:func:`glm_ivec4_maxv`
#. :c:func:`glm_ivec4_minv`
#. :c:func:`glm_ivec4_clamp`
#. :c:func:`glm_ivec4_abs`
Functions documentation
~~~~~~~~~~~~~~~~~~~~~~~
.. c:function:: void glm_ivec4(ivec3 v3, int last, ivec4 dest)
init ivec4 using ivec3
Parameters:
| *[in]* **v** vector
| *[out]* **dest** destination
.. c:function:: void glm_ivec4_copy(ivec4 a, ivec4 dest)
copy all members of [a] to [dest]
Parameters:
| *[in]* **a** source vector
| *[out]* **dest** destination
.. c:function:: void glm_ivec4_zero(ivec4 v)
set all members of [v] to zero
Parameters:
| *[out]* **v** vector
.. c:function:: void glm_ivec4_one(ivec4 v)
set all members of [v] to one
Parameters:
| *[out]* **v** vector
.. c:function:: void glm_ivec4_add(ivec4 a, ivec4 b, ivec4 dest)
add vector [a] to vector [b] and store result in [dest]
Parameters:
| *[in]* **a** first vector
| *[in]* **b** second vector
| *[out]* **dest** destination
.. c:function:: void glm_ivec4_adds(ivec4 v, int s, ivec4 dest)
add scalar s to vector [v] and store result in [dest]
Parameters:
| *[in]* **v** vector
| *[in]* **s** scalar
| *[out]* **dest** destination
.. c:function:: void glm_ivec4_sub(ivec4 a, ivec4 b, ivec4 dest)
subtract vector [b] from vector [a] and store result in [dest]
Parameters:
| *[in]* **a** first vector
| *[in]* **b** second vector
| *[out]* **dest** destination
.. c:function:: void glm_ivec4_subs(ivec4 v, int s, ivec4 dest)
subtract scalar s from vector [v] and store result in [dest]
Parameters:
| *[in]* **v** vector
| *[in]* **s** scalar
| *[out]* **dest** destination
.. c:function:: void glm_ivec4_mul(ivec4 a, ivec4 b, ivec4 dest)
multiply vector [a] with vector [b] and store result in [dest]
Parameters:
| *[in]* **a** first vector
| *[in]* **b** second vector
| *[out]* **dest** destination
.. c:function:: void glm_ivec4_scale(ivec4 v, int s, ivec4 dest)
multiply vector [a] with scalar s and store result in [dest]
Parameters:
| *[in]* **v** vector
| *[in]* **s** scalar
| *[out]* **dest** destination
.. c:function:: int glm_ivec4_distance2(ivec4 a, ivec4 b)
squared distance between two vectors
Parameters:
| *[in]* **a** first vector
| *[in]* **b** second vector
Returns:
squared distance (distance * distance)
.. c:function:: float glm_ivec4_distance(ivec4 a, ivec4 b)
distance between two vectors
Parameters:
| *[in]* **a** first vector
| *[in]* **b** second vector
Returns:
distance
.. c:function:: void glm_ivec4_maxv(ivec4 a, ivec4 b, ivec4 dest)
set each member of dest to greater of vector a and b
Parameters:
| *[in]* **a** first vector
| *[in]* **b** second vector
| *[out]* **dest** destination
.. c:function:: void glm_ivec4_minv(ivec4 a, ivec4 b, ivec4 dest)
set each member of dest to lesser of vector a and b
Parameters:
| *[in]* **a** first vector
| *[in]* **b** second vector
| *[out]* **dest** destination
.. c:function:: void glm_ivec4_clamp(ivec4 v, int minVal, int maxVal)
clamp each member of [v] between minVal and maxVal (inclusive)
Parameters:
| *[in, out]* **v** vector
| *[in]* **minVal** minimum value
| *[in]* **maxVal** maximum value
.. c:function:: void glm_ivec4_abs(ivec4 v, ivec4 dest)
absolute value of each vector item
Parameters:
| *[in]* **v** vector
| *[out]* **dest** destination vector

871
docs/source/mat2.rst Normal file
View File

@@ -0,0 +1,871 @@
.. default-domain:: C
mat2
====
Header: cglm/mat2.h
Table of contents (click to go):
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Macros:
1. GLM_MAT2_IDENTITY_INIT
#. GLM_MAT2_ZERO_INIT
#. GLM_MAT2_IDENTITY
#. GLM_MAT2_ZERO
Functions:
1. :c:func:`glm_mat2_make`
#. :c:func:`glm_mat2_copy`
#. :c:func:`glm_mat2_identity`
#. :c:func:`glm_mat2_identity_array`
#. :c:func:`glm_mat2_zero`
#. :c:func:`glm_mat2_mul`
#. :c:func:`glm_mat2_mulv`
#. :c:func:`glm_mat2_transpose_to`
#. :c:func:`glm_mat2_transpose`
#. :c:func:`glm_mat2_scale`
#. :c:func:`glm_mat2_inv`
#. :c:func:`glm_mat2_swap_col`
#. :c:func:`glm_mat2_swap_row`
#. :c:func:`glm_mat2_det`
#. :c:func:`glm_mat2_trace`
#. :c:func:`glm_mat2_rmc`
Represented
~~~~~~~~~~~
.. csv-table:: mat2x2
:header: "", "column 1", "column 2"
"row 1", "m00", "m10"
"row 2", "m01", "m11"
Functions documentation
~~~~~~~~~~~~~~~~~~~~~~~
.. c:function:: void glm_mat2_make(const float * __restrict src, mat2 dest)
Create mat2 (dest) from pointer (src).
.. note:: **@src** must contain at least 4 elements.
Parameters:
| *[in]* **src** pointer to an array of floats (left)
| *[out]* **dest** destination (result, mat2)
.. note:: Mathematical explanation
.. csv-table:: float array (1x4) **(src)**
:header: "", "column 1"
"row 1", "v0"
"row 2", "v1"
"row 3", "v2"
"row 4", "v3"
.. csv-table:: mat2 **(dest)**
:header: "", "column 1", "column 2"
"row 1", "v0", "v2"
"row 2", "v1", "v3"
.. note:: Example
.. code-block:: c
mat2 dest = GLM_MAT2_ZERO_INIT;
float src[4] = { 1.00, 5.00, 8.00, 11.00 };
glm_mat2_make(src, dest);
.. csv-table:: float array (1x4) **(src)**
:header: "", "column 1"
"row 1", "1.00"
"row 2", "5.00"
"row 3", "8.00"
"row 4", "11.00"
.. csv-table:: mat2 **(dest)** Before
:header: "", "column 1", "column 2"
"row 1", "0.00", "0.00"
"row 2", "0.00", "0.00"
.. csv-table:: mat2 **(dest)** After
:header: "", "column 1", "column 2"
"row 1", "1.00", "8.00"
"row 2", "5.00", "11.00"
.. c:function:: void glm_mat2_copy(mat2 mat, mat2 dest)
Copy mat2 (mat) to mat2 (dest).
Parameters:
| *[in]* **mat** mat2 (left,src)
| *[out]* **dest** destination (result, mat2)
.. note:: Mathematical explanation
.. csv-table:: mat2 **(mat)**
:header: "", "column 1", "column 2"
"row 1", "m00", "m10"
"row 2", "m01", "m11"
.. csv-table:: mat2 **(dest)**
:header: "", "column 1", "column 2"
"row 1", "m00", "m10"
"row 2", "m01", "m11"
.. note:: Example
.. code-block:: c
mat2 mat = {{3.00,4.00},{7.00,8.00}};
mat2 dest = GLM_MAT2_ZERO_INIT;
glm_mat2_copy(mat, dest);
.. csv-table:: mat2 **(mat)**
:header: "", "column 1", "column 2"
"row 1", "3.00", "7.00"
"row 2", "4.00", "8.00"
.. csv-table:: mat2 **(dest)** Before
:header: "", "column 1", "column 2"
"row 1", "0.00", "0.00"
"row 2", "0.00", "0.00"
.. csv-table:: mat2 **(dest)** After
:header: "", "column 1", "column 2"
"row 1", "3.00", "7.00"
"row 2", "4.00", "8.00"
.. c:function:: void glm_mat2_identity(mat2 m)
| 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);``.
.. code-block:: c
glm_mat2_copy(GLM_MAT2_IDENTITY, m);
// or
mat2 mat = GLM_MAT2_IDENTITY_INIT;
Parameters:
| *[in, out]* **m** mat2 (src, dest)
.. note:: Mathematical explanation
.. csv-table:: mat2 **(m)**
:header: "", "column 1", "column 2"
"row 1", "m00", "m10"
"row 2", "m01", "m11"
.. csv-table:: mat2 **(m)**
:header: "", "column 1", "column 2"
"row 1", "1.00", "0.00"
"row 2", "0.00", "1.00"
.. note:: Example
.. code-block:: c
mat2 m = {{3.00,4.00},{7.00,8.00}};
glm_mat2_identity(m);
.. csv-table:: mat2 **(m)**
:header: "", "column 1", "column 2"
"row 1", "3.00", "7.00"
"row 2", "4.00", "8.00"
.. csv-table:: mat2 **(m)**
:header: "", "column 1", "column 2"
"row 1", "1.00", "0.00"
"row 2", "0.00", "1.00"
.. c:function:: void glm_mat2_identity_array(mat2 * __restrict mats, size_t count)
Given an array of mat2's **(mats)** make each matrix an identity matrix.
Parameters:
| *[in, out]* **mats** Array of mat2's (must be aligned (16/32) if alignment is not disabled)
| *[in]* **count** Array size of ``mats`` or number of matrices
.. note:: Mathematical explanation
.. csv-table:: mat2 **(mats[index])**
:header: "", "column 1", "column 2"
"row 1", "m00", "m10"
"row 2", "m01", "m11"
.. csv-table:: mat2 **(mats[index])**
:header: "", "column 1", "column 2"
"row 1", "1.00", "0.00"
"row 2", "0.00", "1.00"
.. note:: Example
.. code-block:: c
size_t count = 3;
mat2 matrices[count] = {
{{1.00,2.00},{5.00,6.00}},
{{3.00,4.00},{7.00,8.00}},
{{5.00,6.00},{9.00,10.00}},
};
glm_mat2_identity_array(matrices, count);
.. csv-table:: mat2 **(mats[0])** Before
:header: "", "column 1", "column 2"
"row 1", "1.00", "5.00"
"row 2", "2.00", "6.00"
.. csv-table:: mat2 **(mats[0])** After
:header: "", "column 1", "column 2"
"row 1", "1.00", "0.00"
"row 2", "0.00", "1.00"
.. csv-table:: mat2 **(mats[1])** Before
:header: "", "column 1", "column 2"
"row 1", "3.00", "7.00"
"row 2", "4.00", "8.00"
.. csv-table:: mat2 **(mats[1])** After
:header: "", "column 1", "column 2"
"row 1", "1.00", "0.00"
"row 2", "0.00", "1.00"
.. csv-table:: mat2 **(mats[2])** Before
:header: "", "column 1", "column 2"
"row 1", "5.00", "9.00"
"row 2", "6.00", "10.00"
.. csv-table:: mat2 **(mats[2])** After
:header: "", "column 1", "column 2"
"row 1", "1.00", "0.00"
"row 2", "0.00", "1.00"
.. c:function:: void glm_mat2_zero(mat2 m)
Zero out the mat2 (m).
Parameters:
| *[in, out]* **m** mat2 (src, dest)
.. note:: Mathematical explanation
.. csv-table:: mat2 **(m)**
:header: "", "column 1", "column 2"
"row 1", "m00", "m10"
"row 2", "m01", "m11"
.. csv-table:: mat2 **(m)**
:header: "", "column 1", "column 2"
"row 1", "0.00", "0.00"
"row 2", "0.00", "0.00"
.. note:: Example
.. code-block:: c
mat2 m = {{19.00,5.00},{2.00,4.00}};
glm_mat2_zero(m);
.. csv-table:: mat2 **(m)** Before
:header: "", "column 1", "column 2"
"row 1", "19.00", "2.00"
"row 2", "5.00", "4.00"
.. csv-table:: mat2 **(m)** After
:header: "", "column 1", "column 2"
"row 1", "0.00", "0.00"
"row 2", "0.00", "0.00"
.. c:function:: void glm_mat2_mul(mat2 m1, mat2 m2, mat2 dest)
| 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:
.. code-block:: c
mat2 m = GLM_MAT2_IDENTITY_INIT;
glm_mat2_mul(m, m, m);
Parameters:
| *[in]* **m1** mat2 (left)
| *[in]* **m2** mat2 (right)
| *[out]* **dest** destination (result, mat2)
.. note:: Mathematical explanation
.. csv-table:: mat2 **(m1)**
:header: "", "column 1", "column 2"
"row 1", "a00", "a10"
"row 2", "a01", "a11"
.. csv-table:: mat2 **(m2)**
:header: "", "column 1", "column 2"
"row 1", "b00", "b10"
"row 2", "b01", "b11"
.. csv-table:: mat2 **(dest)**
:header: "", "column 1", "column 2"
"row 1", "a00 * b00 + a10 * b01", "a00 * b10 + a10 * b11"
"row 2", "a01 * b00 + a11 * b01", "a01 * b10 + a11 * b11"
.. note:: Example
.. code-block:: c
mat2 m = {{19.00,5.00},{2.00,4.00}};
glm_mat2_mul(m, m, m);
.. csv-table:: mat2 **(m1)**
:header: "", "column 1", "column 2"
"row 1", "19.00", "2.00"
"row 2", "5.00", "4.00"
.. csv-table:: mat2 **(m2)**
:header: "", "column 1", "column 2"
"row 1", "19.00", "2.00"
"row 2", "5.00", "4.00"
.. csv-table:: mat2 **(dest)**
:header: "", "column 1", "column 2"
"row 1", "**371.00** = 19.00 * 19.00 + 2.00 * 5.00", "**46.00** = 19.00 * 2.00 + 2.00 * 4.00"
"row 2", "**115.00** = 5.00 * 19.00 + 4.00 * 5.00", "**18.00** = 5.00 * 2.00 + 4.00 * 4.00"
.. c:function:: void glm_mat2_mulv(mat2 m, vec2 v, vec2 dest)
Multiply mat2 (m) by vec2 (v) and store in vec2 (dest).
Parameters:
| *[in]* **m** mat2 (left)
| *[in]* **v** vec2 (right, column vector)
| *[out]* **dest** destination (result, column vector)
.. note:: Mathematical explanation
.. csv-table:: mat2 **(m)**
:header: "", "column 1", "column 2"
"row 1", "m00", "m10"
"row 2", "m01", "m11"
.. csv-table:: column vec2 (1x2) **(v)**
:header: "", "column 1"
"row 1", "v0"
"row 2", "v1"
.. csv-table:: column vec2 (1x2) **(dest)**
:header: "", "column 1"
"row 1", "m00 * v0 + m10 * v1"
"row 2", "m01 * v0 + m11 * v1"
.. note:: Example
.. code-block:: c
vec2 dest;
vec2 v = {33.00,55.00};
mat2 m = {{1.00,2.00},{3.00,4.00}};
glm_mat2_mulv(m, v, dest);
.. csv-table:: mat2 **(m)**
:header: "", "column 1", "column 2"
"row 1", "1.00", "3.00"
"row 2", "2.00", "4.00"
.. csv-table:: column vec2 **(v)**
:header: "", "column 1"
"row 1", "33.00"
"row 2", "55.00"
.. csv-table:: vec2 **(dest)** Result
:header: "", "column 1"
"row 1", "**198.00** = 1.00 * 33.00 + 3.00 * 55.00"
"row 2", "**286.00** = 2.00 * 33.00 + 4.00 * 55.00"
.. c:function:: void glm_mat2_transpose_to(mat2 mat, mat2 dest)
Transpose mat2 (mat) and store in mat2 (dest).
Parameters:
| *[in]* **mat** mat2 (left,src)
| *[out]* **dest** destination (result, mat2)
.. note:: Mathematical explanation
.. csv-table:: mat2 **(mat)**
:header: "", "column 1", "column 2"
"row 1", "m00", "m10"
"row 2", "m01", "m11"
.. csv-table:: mat2 **(dest)**
:header: "", "column 1", "column 2"
"row 1", "m00", "m01"
"row 2", "m10", "m11"
.. note:: Example
.. code-block:: c
mat2 mat = {{1.00,2.00},{3.00,4.00}};
mat2 dest = GLM_MAT2_ZERO_INIT;
glm_mat2_transpose_to(mat, dest);
.. csv-table:: mat2 **(mat)**
:header: "", "column 1", "column 2"
"row 1", "1.00", "3.00"
"row 2", "2.00", "4.00"
.. csv-table:: mat2 **(dest)** Before
:header: "", "column 1", "column 2"
"row 1", "0.00", "0.00"
"row 2", "0.00", "0.00"
.. csv-table:: mat2 **(dest)** After
:header: "", "column 1", "column 2"
"row 1", "1.00", "2.00"
"row 2", "3.00", "4.00"
.. c:function:: void glm_mat2_transpose(mat2 m)
Transpose mat2 (m) and store result in the same matrix.
Parameters:
| *[in, out]* **m** mat2 (src, dest)
.. note:: Mathematical explanation
.. csv-table:: mat2 **(m)** src
:header: "", "column 1", "column 2"
"row 1", "m00", "m10"
"row 2", "m01", "m11"
.. csv-table:: mat2 **(m)** dest
:header: "", "column 1", "column 2"
"row 1", "m00", "m01"
"row 2", "m10", "m11"
.. note:: Example
.. code-block:: c
mat2 m = {{1.00,2.00},{3.00,4.00}};
glm_mat2_transpose(m);
.. csv-table:: mat2 **(m)** Before
:header: "", "column 1", "column 2"
"row 1", "1.00", "3.00"
"row 2", "2.00", "4.00"
.. csv-table:: mat2 **(m)** After
:header: "", "column 1", "column 2"
"row 1", "1.00", "2.00"
"row 2", "3.00", "4.00"
.. c:function:: void glm_mat2_scale(mat2 m, float s)
Multiply mat2 (m) by scalar constant (s).
Parameters:
| *[in, out]* **m** mat2 (src, dest)
| *[in]* **s** float (scalar)
.. note:: Mathematical explanation
.. csv-table:: mat2 **(m)**
:header: "", "column 1", "column 2"
"row 1", "m00 * s", "m10 * s"
"row 2", "m01 * s", "m11 * s"
.. note:: Example
.. code-block:: c
float s = 3.00f;
mat2 m = {{1.00,2.00},{3.00,4.00}};
glm_mat2_scale(m, s);
.. csv-table:: mat2 **(m)** Before
:header: "", "column 1", "column 2"
"row 1", "1.00", "3.00"
"row 2", "2.00", "4.00"
.. csv-table:: mat2 **(m)** After
:header: "", "column 1", "column 2"
"row 1", "**3.00** = 1.00 * 3.00", "**9.00** = 3.00 * 3.00"
"row 2", "**6.00** = 2.00 * 3.00", "**12.00** = 4.00 * 3.00"
.. c:function:: void glm_mat2_inv(mat2 mat, mat2 dest)
Inverse mat2 (mat) and store in mat2 (dest).
Parameters:
| *[in]* **mat** mat2 (left,src)
| *[out]* **dest** destination (result, inverse mat2)
.. note:: Mathematical explanation
.. csv-table:: mat2 **(mat)**
:header: "", "column 1", "column 2"
"row 1", "m00", "m10"
"row 2", "m01", "m11"
.. list-table:: mat2 **(dest)**
:header-rows: 1
* -
- column 1
- column 2
* - row 1
- m11 * (1.0f / (m00 * m11 - m01 * m10))
- -m10 * (1.0f / (m00 * m11 - m01 * m10))
* - row 2
- -m01 * (1.0f / (m00 * m11 - m01 * m10))
- m00 * (1.0f / (m00 * m11 - m01 * m10))
.. note:: Example
.. code-block:: c
mat2 dest = GLM_MAT2_ZERO_INIT;
mat2 mat = {{1.00,2.00},{3.00,4.00}};
glm_mat2_inv(mat, dest);
.. csv-table:: mat2 **(mat)** Before
:header: "", "column 1", "column 2"
"row 1", "1.00", "3.00"
"row 2", "2.00", "4.00"
.. list-table:: mat2 **(dest)** After
:header-rows: 1
* -
- column 1
- column 2
* - row 1
- **-2.00** = 4.00 * (1.00 / (1.00 * 4.00 - 2.00 * 3.00))
- **1.50** = -3.00 * (1.00 / (1.00 * 4.00 - 2.00 * 3.00))
* - row 2
- **1.00** = -2.00 * (1.00 / (1.00 * 4.00 - 2.00 * 3.00))
- **-0.50** = 1.00 * (1.00 / (1.00 * 4.00 - 2.00 * 3.00))
.. c:function:: void glm_mat2_swap_col(mat2 mat, int col1, int col2)
Swap two columns in mat2 (mat) and store in same matrix.
Parameters:
| *[in, out]* **mat** mat2 (src, dest)
| *[in]* **col1** Column 1 array index
| *[in]* **col2** Column 2 array index
.. note:: Mathematical explanation
.. csv-table:: mat2 **(mat)** Before
:header: "", "column 1", "column 2"
"row 1", "m00", "m10"
"row 2", "m01", "m11"
.. code-block:: c
glm_mat2_swap_col(mat, 0, 1);
.. csv-table:: mat2 **(mat)** After
:header: "", "column 1", "column 2"
"row 1", "m10", "m00"
"row 2", "m11", "m01"
.. note:: Example
.. code-block:: c
mat2 mat = {{76.00,5.00},{3.00,6.00}};
glm_mat2_swap_col(mat, 0, 1);
.. csv-table:: mat2 **(mat)** Before
:header: "", "column 1", "column 2"
"row 1", "76.00", "3.00"
"row 2", "5.00", "6.00"
.. csv-table:: mat2 **(mat)** After
:header: "", "column 1", "column 2"
"row 1", "3.00", "76.00"
"row 2", "6.00", "5.00"
.. c:function:: void glm_mat2_swap_row(mat2 mat, int row1, int row2)
Swap two rows in mat2 (mat) and store in same matrix.
Parameters:
| *[in, out]* **mat** mat2 (src, dest)
| *[in]* **row1** Row 1 array index
| *[in]* **row2** Row 2 array index
.. note:: Mathematical explanation
.. csv-table:: mat2 **(mat)** Before
:header: "", "column 1", "column 2"
"row 1", "m00", "m10"
"row 2", "m01", "m11"
.. code-block:: c
glm_mat2_swap_row(mat, 0, 1);
.. csv-table:: mat2 **(mat)** After
:header: "", "column 1", "column 2"
"row 1", "m01", "m11"
"row 2", "m00", "m10"
.. note:: Example
.. code-block:: c
mat2 mat = {{76.00,5.00},{3.00,6.00}};
glm_mat2_swap_row(mat, 0, 1);
.. csv-table:: mat2 **(mat)** Before
:header: "", "column 1", "column 2"
"row 1", "76.00", "3.00"
"row 2", "5.00", "6.00"
.. csv-table:: mat2 **(mat)** After
:header: "", "column 1", "column 2"
"row 1", "5.00", "6.00"
"row 2", "76.00", "3.00"
.. c:function:: float glm_mat2_det(mat2 m)
Returns mat2 determinant.
Parameters:
| *[in]* **m** mat2 (src)
Returns:
| mat2 determinant (float)
.. note:: Mathematical explanation
.. csv-table:: mat2 **(m)**
:header: "", "column 1", "column 2"
"row 1", "m00", "m10"
"row 2", "m01", "m11"
.. code-block:: c
m00 * m11 - m10 * m01;
.. note:: Example
.. code-block:: c
mat2 m = {{76.00,5.00},{3.00,6.00}};
glm_mat2_det(m);
.. csv-table:: mat2 **(m)**
:header: "", "column 1", "column 2"
"row 1", "76.00", "3.00"
"row 2", "5.00", "6.00"
.. code-block:: c
441.00 = 76.00 * 6.00 - 3.00 * 5.00;
.. c:function:: void glm_mat2_trace(mat2 m)
| Returns trace of matrix. Which is:
|
| The sum of the elements on the main diagonal from
| upper left corner to the bottom right corner.
Parameters:
| *[in]* **m** mat2 (src)
Returns:
| mat2 trace (float)
.. note:: Mathematical explanation
.. csv-table:: mat2 **(m)**
:header: "", "column 1", "column 2"
"row 1", "m00", "m10"
"row 2", "m01", "m11"
.. code-block:: c
m00 + m11;
.. note:: Example
.. code-block:: c
mat2 m = {{76.00,5.00},{3.00,6.00}};
glm_mat2_trace(m);
.. csv-table:: mat2 **(m)**
:header: "", "column 1", "column 2"
"row 1", "76.00", "3.00"
"row 2", "5.00", "6.00"
.. code-block:: c
82.00 = 76.00 + 6.00;
.. c:function:: float glm_mat2_rmc(vec2 r, mat2 m, vec2 c)
| 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.
Parameters:
| *[in]* **r** vec2 (2x1, row vector)
| *[in]* **m** mat2 (2x2, matrix)
| *[in]* **c** vec2 (1x2, column vector)
Returns:
| Scalar value (float, 1x1)
.. note:: Mathematical explanation
.. csv-table:: row vec2 (2x1) **(r)**
:header: "", "column 1", "column 2"
"row 1", "a00", "a10"
.. csv-table:: mat2 **(m)**
:header: "", "column 1", "column 2"
"row 1", "b00", "b10"
"row 2", "b01", "b11"
.. csv-table:: column vec2 (1x2) **(c)**
:header: "", "column 1"
"row 1", "c00"
"row 2", "c01"
.. code-block:: c
M * C = C (column vector)
dot_product(R, C)
.. csv-table:: column vec2 (1x2) **(C)**
:header: "", "column 1"
"row 1", "b00 * c00 + b10 * c01"
"row 2", "b01 * c00 + b11 * c01"
.. csv-table:: float **(scalar)**
:header: "", "column 1"
"row 1", "a00 * (b00 * c00 + b10 * c01) + a10 * (b01 * c00 + b11 * c01)"
.. note:: Example
.. code-block:: c
vec2 r = {8.00,4.00};
vec2 c = {7.00,2.00};
mat2 m = {{5.00,9.00},{3.00,6.00}};
glm_mat2_rmc(r, m, c);
.. csv-table:: row vec2 (2x1) **(r)**
:header: "", "column 1", "column 2"
"row 1", "8.00", "4.00"
.. csv-table:: mat2 **(m)**
:header: "", "column 1", "column 2"
"row 1", "5.00", "3.00"
"row 2", "9.00", "6.00"
.. csv-table:: column vec2 (1x2) **(c)**
:header: "", "column 1"
"row 1", "7.00"
"row 2", "2.00"
.. csv-table:: column vec2 (1x2) **(C)**
:header: "", "column 1"
"row 1", "**41.00** = 5.00 * 7.00 + 3.00 * 2.00"
"row 2", "**75.00** = 9.00 * 7.00 + 6.00 * 2.00"
.. csv-table:: float (1x1) **(scalar)**
:header: "", "column 1"
"row 1", "**628.00** = 8.00 * 41.00 + 4.00 * 75.00"

205
docs/source/mat2x3.rst Normal file
View File

@@ -0,0 +1,205 @@
.. default-domain:: C
mat2x3
======
Header: cglm/mat2x3.h
Table of contents (click to go):
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Macros:
1. GLM_MAT2X3_ZERO_INIT
#. GLM_MAT2X3_ZERO
Functions:
1. :c:func:`glm_mat2x3_copy`
#. :c:func:`glm_mat2x3_zero`
#. :c:func:`glm_mat2x3_make`
#. :c:func:`glm_mat2x3_mul`
#. :c:func:`glm_mat2x3_mulv`
#. :c:func:`glm_mat2x3_transpose`
#. :c:func:`glm_mat2x3_scale`
Represented
~~~~~~~~~~~
.. csv-table:: mat2x3
:header: "", "column 1", "column 2"
"row 1", "m00", "m10"
"row 2", "m01", "m11"
"row 3", "m02", "m12"
Functions documentation
~~~~~~~~~~~~~~~~~~~~~~~
.. c:function:: void glm_mat2x3_copy(mat2x3 src, mat2x3 dest)
Copy mat2x3 (src) to mat2x3 (dest).
Parameters:
| *[in]* **src** mat2x3 (left)
| *[out]* **dest** destination (result, mat2x3)
.. csv-table:: mat2x3 **(src)**
:header: "", "column 1", "column 2"
"row 1", "a00", "a10"
"row 2", "a01", "a11"
"row 3", "a02", "a12"
.. 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:: mat3 **(dest)**
:header: "", "column 1", "column 2", "column 3"
"row 1", "a00 * b00 + a10 * b01", "a00 * b10 + a10 * b11", "a00 * b20 + a10 * b21"
"row 2", "a01 * b00 + a11 * b01", "a01 * b10 + a11 * b11", "a01 * b20 + a11 * b21"
"row 3", "a02 * b00 + a12 * b01", "a02 * b10 + a12 * b11", "a02 * b20 + a12 * b21"
.. c:function:: void glm_mat2x3_mulv(mat2x3 m, vec2 v, vec3 dest)
Multiply mat2x3 (m) by vec2 (v) and store in vec3 (dest).
Parameters:
| *[in]* **m** mat2x3 (left)
| *[in]* **v** vec2 (right, column vector)
| *[out]* **dest** destination (result, column vector)
.. 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) **(v)**
:header: "", "column 1"
"row 1", "v0"
"row 2", "v1"
.. 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 src, mat3x2 dest)
Transpose mat2x3 (src) and store in mat3x2 (dest).
Parameters:
| *[in]* **src** mat2x3 (left)
| *[out]* **dest** destination (result, mat3x2)
.. csv-table:: mat2x3 **(src)**
:header: "", "column 1", "column 2"
"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** 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"

219
docs/source/mat2x4.rst Normal file
View File

@@ -0,0 +1,219 @@
.. default-domain:: C
mat2x4
======
Header: cglm/mat2x4.h
Table of contents (click to go):
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Macros:
1. GLM_MAT2X4_ZERO_INIT
#. GLM_MAT2X4_ZERO
Functions:
1. :c:func:`glm_mat2x4_copy`
#. :c:func:`glm_mat2x4_zero`
#. :c:func:`glm_mat2x4_make`
#. :c:func:`glm_mat2x4_mul`
#. :c:func:`glm_mat2x4_mulv`
#. :c:func:`glm_mat2x4_transpose`
#. :c:func:`glm_mat2x4_scale`
Represented
~~~~~~~~~~~
.. csv-table:: mat2x4
:header: "", "column 1", "column 2"
"row 1", "m00", "m10"
"row 2", "m01", "m11"
"row 3", "m02", "m12"
"row 4", "m03", "m13"
Functions documentation
~~~~~~~~~~~~~~~~~~~~~~~
.. c:function:: void glm_mat2x4_copy(mat2x4 src, mat2x4 dest)
Copy mat2x4 (src) to mat2x4 (dest).
Parameters:
| *[in]* **src** mat2x4 (left)
| *[out]* **dest** destination (result, mat2x4)
.. 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:: 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 **(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"
"row 2", "a01 * b00 + a11 * b01", "a01 * b10 + a11 * b11", "a01 * b20 + a11 * b21", "a01 * b30 + a11 * b31"
"row 3", "a02 * b00 + a12 * b01", "a02 * b10 + a12 * b11", "a02 * b20 + a12 * b21", "a02 * b30 + a12 * b31"
"row 4", "a03 * b00 + a13 * b01", "a03 * b10 + a13 * b11", "a03 * b20 + a13 * b21", "a03 * b30 + a13 * b31"
.. c:function:: void glm_mat2x4_mulv(mat2x4 m, vec2 v, vec4 dest)
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)
.. csv-table:: mat2x4 **(m)**
:header: "", "column 1", "column 2"
"row 1", "m00", "m10"
"row 2", "m01", "m11"
"row 3", "m02", "m12"
"row 4", "m03", "m13"
.. csv-table:: column vec2 (1x2) **(v)**
:header: "", "column 1"
"row 1", "v0"
"row 2", "v1"
.. csv-table:: column vec4 (1x4) **(dest)**
:header: "", "column 1"
"row 1", "m00 * v0 + m10 * v1"
"row 2", "m01 * v0 + m11 * v1"
"row 3", "m02 * v0 + m12 * v1"
"row 4", "m03 * v0 + m13 * v1"
.. c:function:: void glm_mat2x4_transpose(mat2x4 src, mat4x2 dest)
Transpose mat2x4 (src) and store in mat4x2 (dest).
Parameters:
| *[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 mat2x4 (m) by scalar constant (s).
Parameters:
| *[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

196
docs/source/mat3x2.rst Normal file
View File

@@ -0,0 +1,196 @@
.. default-domain:: C
mat3x2
======
Header: cglm/mat3x2.h
Table of contents (click to go):
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Macros:
1. GLM_MAT3X2_ZERO_INIT
#. GLM_MAT3X2_ZERO
Functions:
1. :c:func:`glm_mat3x2_copy`
#. :c:func:`glm_mat3x2_zero`
#. :c:func:`glm_mat3x2_make`
#. :c:func:`glm_mat3x2_mul`
#. :c:func:`glm_mat3x2_mulv`
#. :c:func:`glm_mat3x2_transpose`
#. :c:func:`glm_mat3x2_scale`
Represented
~~~~~~~~~~~
.. csv-table:: mat3x2
:header: "", "column 1", "column 2", "column 3"
"row 1", "m00", "m10", "m20"
"row 2", "m01", "m11", "m21"
Functions documentation
~~~~~~~~~~~~~~~~~~~~~~~
.. c:function:: void glm_mat3x2_copy(mat3x2 src, mat3x2 dest)
Copy mat3x2 (src) to mat3x2 (dest).
Parameters:
| *[in]* **src** mat3x2 (left)
| *[out]* **dest** destination (result, mat3x2)
.. csv-table:: mat3x2 **(src)**
:header: "", "column 1", "column 2", "column 3"
"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]* **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 (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, 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 mat3x2 (m1) by mat2x3 (m2) and store in mat2 (dest).
.. code-block:: c
glm_mat3x2_mul(mat3x2, mat2x3, mat2);
Parameters:
| *[in]* **m1** mat3x2 (left)
| *[in]* **m2** mat2x3 (right)
| *[out]* **dest** destination (result, mat2)
.. csv-table:: mat3x2 **(m1)**
:header: "", "column 1", "column 2", "column 3"
"row 1", "a00", "a10", "a20"
"row 2", "a01", "a11", "a21"
.. csv-table:: mat2x3 **(m2)**
:header: "", "column 1", "column 2"
"row 1", "b00", "b10"
"row 2", "b01", "b11"
"row 3", "b02", "b12"
.. csv-table:: mat2x2 **(dest)**
:header: "", "column 1", "column 2"
"row 1", "a00 * b00 + a10 * b01 + a20 * b02", "a00 * b10 + a10 * b11 + a20 * b12"
"row 2", "a01 * b00 + a11 * b01 + a21 * b02", "a01 * b10 + a11 * b11 + a21 * b12"
.. c:function:: void glm_mat3x2_mulv(mat3x2 m, vec3 v, vec2 dest)
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)
.. 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) **(v)**
:header: "", "column 1"
"row 1", "v0"
"row 2", "v1"
"row 3", "v2"
.. 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 src, mat2x3 dest)
Transpose mat3x2 (src) and store in mat2x3 (dest).
Parameters:
| *[in]* **src** mat3x2 (left)
| *[out]* **dest** destination (result, mat2x3)
.. csv-table:: mat3x2 **(src)**
:header: "", "column 1", "column 2", "column 3"
"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** 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"

226
docs/source/mat3x4.rst Normal file
View File

@@ -0,0 +1,226 @@
.. default-domain:: C
mat3x4
======
Header: cglm/mat3x4.h
Table of contents (click to go):
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Macros:
1. GLM_MAT3X4_ZERO_INIT
#. GLM_MAT3X4_ZERO
Functions:
1. :c:func:`glm_mat3x4_copy`
#. :c:func:`glm_mat3x4_zero`
#. :c:func:`glm_mat3x4_make`
#. :c:func:`glm_mat3x4_mul`
#. :c:func:`glm_mat3x4_mulv`
#. :c:func:`glm_mat3x4_transpose`
#. :c:func:`glm_mat3x4_scale`
Represented
~~~~~~~~~~~
.. csv-table:: mat3x4
:header: "", "column 1", "column 2", "column 3"
"row 1", "m00", "m10", "m20"
"row 2", "m01", "m11", "m21"
"row 3", "m02", "m12", "m22"
"row 4", "m03", "m13", "m23"
Functions documentation
~~~~~~~~~~~~~~~~~~~~~~~
.. c:function:: void glm_mat3x4_copy(mat3x4 src, mat3x4 dest)
Copy mat3x4 (src) to mat3x4 (dest).
Parameters:
| *[in]* **src** mat3x4 (left)
| *[out]* **dest** destination (result, mat3x4)
.. 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:: 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 **(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"
"row 2", "a01 * b00 + a11 * b01 + a21 * b02", "a01 * b10 + a11 * b11 + a21 * b12", "a01 * b20 + a11 * b21 + a21 * b22", "a01 * b30 + a11 * b31 + a21 * b32"
"row 3", "a02 * b00 + a12 * b01 + a22 * b02", "a02 * b10 + a12 * b11 + a22 * b12", "a02 * b20 + a12 * b21 + a22 * b22", "a02 * b30 + a12 * b31 + a22 * b32"
"row 4", "a03 * b00 + a13 * b01 + a23 * b02", "a03 * b10 + a13 * b11 + a23 * b12", "a03 * b20 + a13 * b21 + a23 * b22", "a03 * b30 + a13 * b31 + a23 * b32"
.. c:function:: void glm_mat3x4_mulv(mat3x4 m, vec3 v, vec4 dest)
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)
.. csv-table:: mat3x4 **(m)**
:header: "", "column 1", "column 2", "column 3"
"row 1", "m00", "m10", "m20"
"row 2", "m01", "m11", "m21"
"row 3", "m02", "m12", "m22"
"row 4", "m03", "m13", "m23"
.. csv-table:: column vec3 (1x3) **(v)**
:header: "", "column 1"
"row 1", "v0"
"row 2", "v1"
"row 3", "v2"
.. csv-table:: column vec4 (1x4) **(dest)**
:header: "", "column 1"
"row 1", "m00 * v0 + m10 * v1 + m20 * v2"
"row 2", "m01 * v0 + m11 * v1 + m21 * v2"
"row 3", "m02 * v0 + m12 * v1 + m22 * v2"
"row 4", "m03 * v0 + m13 * v1 + m23 * v2"
.. c:function:: void glm_mat3x4_transpose(mat3x4 src, mat4x3 dest)
Transpose mat3x4 (src) and store in mat4x3 (dest).
Parameters:
| *[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 mat3x4 (m) by scalar constant (s).
Parameters:
| *[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

@@ -34,8 +34,8 @@ Functions:
#. :c:func:`glm_mat4_mulN`
#. :c:func:`glm_mat4_mulv`
#. :c:func:`glm_mat4_mulv3`
#. :c:func:`glm_mat3_trace`
#. :c:func:`glm_mat3_trace3`
#. :c:func:`glm_mat4_trace`
#. :c:func:`glm_mat4_trace3`
#. :c:func:`glm_mat4_quat`
#. :c:func:`glm_mat4_transpose_to`
#. :c:func:`glm_mat4_transpose`
@@ -47,6 +47,8 @@ Functions:
#. :c:func:`glm_mat4_swap_col`
#. :c:func:`glm_mat4_swap_row`
#. :c:func:`glm_mat4_rmc`
#. :c:func:`glm_mat4_make`
#. :c:func:`glm_mat4_textrans`
Functions documentation
~~~~~~~~~~~~~~~~~~~~~~~
@@ -69,7 +71,7 @@ Functions documentation
.. c:function:: void glm_mat4_identity(mat4 mat)
copy identity mat4 to mat, or makes mat to identiy
copy identity mat4 to mat, or makes mat to identity
Parameters:
| *[out]* **mat** matrix
@@ -118,6 +120,7 @@ Functions documentation
.. c:function:: void glm_mat4_mul(mat4 m1, mat4 m2, mat4 dest)
multiply m1 and m2 to dest
m1, m2 and dest matrices can be same matrix, it is possible to write this:
.. code-block:: c
@@ -141,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:
@@ -158,14 +161,19 @@ Functions documentation
| *[in]* **v** vec4 (right, column vector)
| *[out]* **dest** vec4 (result, column vector)
.. c:function:: void glm_mat4_mulv3(mat4 m, vec3 v, vec3 dest)
.. c:function:: void glm_mat4_mulv3(mat4 m, vec3 v, float last, vec3 dest)
multiply vector with mat4's mat3 part(rotation)
| multiply **vec3** with **mat4** and get **vec3** as result
|
| actually the result is **vec4**, after multiplication,
the last component is trimmed, if you need the result's last component
then don't use this function and consider to use **glm_mat4_mulv()**
Parameters:
| *[in]* **m** mat4 (left)
| *[in]* **v** vec3 (right, column vector)
| *[out]* **dest** vec3 (result, column vector)
| *[in]* **m** mat4(affine transform)
| *[in]* **v** vec3
| *[in]* **last** 4th item to make it vec4
| *[out]* **dest** result vector (vec3)
.. c:function:: void glm_mat4_trace(mat4 m)
@@ -207,7 +215,7 @@ Functions documentation
.. c:function:: void glm_mat4_transpose(mat4 m)
tranpose mat4 and store result in same matrix
transpose mat4 and store result in same matrix
Parameters:
| *[in]* **m** source
@@ -256,7 +264,7 @@ Functions documentation
| e.g Newton-Raphson. this should work faster than normal,
| to get more precise use glm_mat4_inv version.
| NOTE: You will lose precision, glm_mat4_inv is more accurate
.. note:: You will lose precision, glm_mat4_inv is more accurate
Parameters:
| *[in]* **mat** source
@@ -296,3 +304,25 @@ Functions documentation
Returns:
scalar value e.g. Matrix1x1
.. c:function:: void glm_mat4_make(const float * __restrict src, mat4 dest)
Create mat4 matrix from pointer
.. note:: **@src** must contain at least 16 elements.
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

201
docs/source/mat4x2.rst Normal file
View File

@@ -0,0 +1,201 @@
.. default-domain:: C
mat4x2
======
Header: cglm/mat4x2.h
Table of contents (click to go):
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Macros:
1. GLM_MAT4X2_ZERO_INIT
#. GLM_MAT4X2_ZERO
Functions:
1. :c:func:`glm_mat4x2_copy`
#. :c:func:`glm_mat4x2_zero`
#. :c:func:`glm_mat4x2_make`
#. :c:func:`glm_mat4x2_mul`
#. :c:func:`glm_mat4x2_mulv`
#. :c:func:`glm_mat4x2_transpose`
#. :c:func:`glm_mat4x2_scale`
Represented
~~~~~~~~~~~
.. csv-table:: mat4x2
:header: "", "column 1", "column 2", "column 3", "column4"
"row 1", "m00", "m10", "m20", "m30"
"row 2", "m01", "m11", "m21", "m31"
Functions documentation
~~~~~~~~~~~~~~~~~~~~~~~
.. c:function:: void glm_mat4x2_copy(mat4x2 src, mat4x2 dest)
Copy mat4x2 (src) to mat4x2 (dest).
Parameters:
| *[in]* **src** mat4x2 (left)
| *[out]* **dest** destination (result, mat4x2)
.. 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:: 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]* **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 (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, 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 mat4x2 (m1) by mat2x4 (m2) and store in mat2 (dest).
.. code-block:: c
glm_mat4x2_mul(mat4x2, mat2x4, mat2);
Parameters:
| *[in]* **m1** mat4x2 (left)
| *[in]* **m2** mat2x4 (right)
| *[out]* **dest** destination (result, mat2)
.. 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 **(m2)**
:header: "", "column 1", "column 2"
"row 1", "b00", "b10"
"row 2", "b01", "b11"
"row 3", "b02", "b12"
"row 4", "b03", "b13"
.. 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"
"row 2", "a01 * b00 + a11 * b01 + a21 * b02 + a31 * b03", "a01 * b10 + a11 * b11 + a21 * b12 + a31 * b13"
.. c:function:: void glm_mat4x2_mulv(mat4x2 m, vec4 v, vec2 dest)
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)
.. csv-table:: mat4x2 **(m)**
:header: "", "column 1", "column 2", "column 3", "column 4"
"row 1", "m00", "m10", "m20", "m30"
"row 2", "m01", "m11", "m21", "m31"
.. csv-table:: column vec4 (1x4) **(v)**
:header: "", "column 1"
"row 1", "v0"
"row 2", "v1"
"row 3", "v2"
"row 4", "v3"
.. 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 src, mat2x4 dest)
Transpose mat4x2 (src) and store in mat2x4 (dest).
Parameters:
| *[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 mat4x2 (m) by scalar constant (s).
Parameters:
| *[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"

217
docs/source/mat4x3.rst Normal file
View File

@@ -0,0 +1,217 @@
.. default-domain:: C
mat4x3
======
Header: cglm/mat4x3.h
Table of contents (click to go):
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Macros:
1. GLM_MAT4X3_ZERO_INIT
#. GLM_MAT4X3_ZERO
Functions:
1. :c:func:`glm_mat4x3_copy`
#. :c:func:`glm_mat4x3_zero`
#. :c:func:`glm_mat4x3_make`
#. :c:func:`glm_mat4x3_mul`
#. :c:func:`glm_mat4x3_mulv`
#. :c:func:`glm_mat4x3_transpose`
#. :c:func:`glm_mat4x3_scale`
Represented
~~~~~~~~~~~
.. csv-table:: mat4x3
: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"
Functions documentation
~~~~~~~~~~~~~~~~~~~~~~~
.. c:function:: void glm_mat4x3_copy(mat4x3 src, mat4x3 dest)
Copy mat4x3 (src) to mat4x3 (dest).
Parameters:
| *[in]* **src** mat4x3 (left)
| *[out]* **dest** destination (result, 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:: 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"
"row 2", "b01", "b11", "b21"
"row 3", "b02", "b12", "b22"
"row 4", "b03", "b13", "b23"
.. 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"
"row 2", "a01 * b00 + a11 * b01 + a21 * b02 + a31 * b03", "a01 * b10 + a11 * b11 + a21 * b12 + a31 * b13", "a01 * b20 + a11 * b21 + a21 * b22 + a31 * b23"
"row 3", "a02 * b00 + a12 * b01 + a22 * b02 + a32 * b03", "a02 * b10 + a12 * b11 + a22 * b12 + a32 * b13", "a02 * b20 + a12 * b21 + a22 * b22 + a32 * b23"
.. c:function:: void glm_mat4x3_mulv(mat4x3 m, vec4 v, vec3 dest)
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)
.. 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) **(v)**
:header: "", "column 1"
"row 1", "v0"
"row 2", "v1"
"row 3", "v2"
"row 4", "v3"
.. 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 src, mat3x4 dest)
Transpose mat4x3 (src) and store in mat3x4 (dest).
Parameters:
| *[in]* **src** mat4x3 (left)
| *[out]* **dest** destination (result, mat3x4)
.. 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 **(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** 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"

60
docs/source/noise.rst Normal file
View File

@@ -0,0 +1,60 @@
.. default-domain:: C
perlin
================================================================================
Header: cglm/noise.h
Classic Perlin noise implementation.
Based on the work of Stefan Gustavson and Ashima Arts on "webgl-noise":
https://github.com/stegu/webgl-noise
Following Stefan Gustavson's paper "Simplex noise demystified":
http://www.itn.liu.se/~stegu/simplexnoise/simplexnoise.pdf
Implementation based on glm::perlin function:
https://github.com/g-truc/glm/blob/master/glm/gtc/noise.inl
Table of contents (click to go):
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Functions:
1. :c:func:`glm_perlin_vec4`
#. :c:func:`glm_perlin_vec3`
#. :c:func:`glm_perlin_vec2`
Functions documentation
~~~~~~~~~~~~~~~~~~~~~~~
.. c:function:: float glm_perlin_vec4(vec4 point)
| Classic Perlin noise
Parameters:
| *[in]* **point** 4D point
Returns:
| noise value
.. c:function:: float glm_perlin_vec3(vec3 point)
| Classic Perlin noise
Parameters:
| *[in]* **point** 3D point
Returns:
| noise value
.. c:function:: float glm_perlin_vec2(vec2 point)
| Classic Perlin noise
Parameters:
| *[in]* **point** 2D point
Returns:
| noise value

View File

@@ -2,7 +2,7 @@ How to send vector or matrix to OpenGL like API
==================================================
*cglm*'s vector and matrix types are arrays. So you can send them directly to a
function which accecpts pointer. But you may got warnings for matrix because it is
function which accepts pointer. But you may got warnings for matrix because it is
two dimensional array.
Passing / Uniforming Matrix to OpenGL:
@@ -34,7 +34,7 @@ array of matrices:
/* ... */
glUniformMatrix4fv(location, count, GL_FALSE, matrix[0][0]);
1. Cast matrix to pointer
2. Cast matrix to pointer
--------------------------
.. code-block:: c
@@ -43,14 +43,14 @@ array of matrices:
/* ... */
glUniformMatrix4fv(location, count, GL_FALSE, (float *)matrix);
in this way, passing aray of matrices is same
in this way, passing array of matrices is same
Passing / Uniforming Vectors to OpenGL:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
You don't need to do extra thing when passing cglm vectors to OpengL or other APIs.
Because a function like **glUniform4fv** accepts vector as pointer. cglm's vectors
are array of floats. So you can pass it directly ot those functions:
are array of floats. So you can pass it directly to those functions:
.. code-block:: c

View File

@@ -1,45 +1,82 @@
.. default-domain:: C
Options
🛠️ Options
===============================================================================
A few options are provided via macros.
❗️ IMPORTANT ❗️
It's a good idea to set up your config macros in build settings like CMake, Xcode, or Visual Studio. This is especially important if you're using features like Modules in Xcode, where adding macros directly before the **cglm** headers might not work.
Alignment Option
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
As default, cglm requires types to be aligned. Alignment requirements:
By default, **cglm** requires types to be aligned with specific byte requirements:
vec3: 8 byte
vec4: 16 byte
mat4: 16 byte
versor: 16 byte
- vec3: 8 bytes
- vec4: 16 bytes
- mat4: 16 bytes (32 on AVX)
- versor: 16 bytes
By starting **v0.4.5** cglm provides an option to disable alignment requirement.
To enable this option define **CGLM_ALL_UNALIGNED** macro before all headers.
You can define it in Xcode, Visual Studio (or other IDEs) or you can also prefer
to define it in build system. If you use pre-compiled verisons then you
have to compile cglm with **CGLM_ALL_UNALIGNED** macro.
Starting with **v0.4.5**, **cglm** offers an option to relax these alignment requirements. To use this option, define the **CGLM_ALL_UNALIGNED** macro before including any headers. This definition can be made within Xcode, Visual Studio, other IDEs, or directly in your build system. If using pre-compiled versions of **cglm**, you'll need to compile them with the **CGLM_ALL_UNALIGNED** macro.
**VERY VERY IMPORTANT:** If you use cglm in multiple projects and
those projects are depends on each other, then
**NOTE:❗️** If you're using **cglm** across multiple interdependent projects:
| *ALWAYS* or *NEVER USE* **CGLM_ALL_UNALIGNED** macro in linked projects
- Always or never use the **CGLM_ALL_UNALIGNED** macro in all linked projects to avoid configuration conflicts. A **cglm** header from one project could require alignment, while a header from another might not, leading to **cglm** functions accessing invalid memory locations.
if you do not know what you are doing. Because a cglm header included
via 'project A' may force types to be aligned and another cglm header
included via 'project B' may not require alignment. In this case
cglm functions will read from and write to **INVALID MEMORY LOCATIONs**.
- **Key Point:** Maintain the same **cglm** configuration across all your projects. For example, if you activate **CGLM_ALL_UNALIGNED** in one project, ensure it's set in the others too.
ALWAYS USE SAME CONFIGURATION / OPTION for **cglm** if you have multiple projects.
**❗NOTE:❗️**
For instance if you set CGLM_ALL_UNALIGNED in a project then set it in other projects too
While **CGLM_ALL_UNALIGNED** allows for flexibility in alignment, it doesn't override C's fundamental alignment rules. For example, an array like *vec4* decays to a pointer (float*) in functions, which must adhere to the alignment requirements of a float pointer (4 bytes). This adherence is crucial because **cglm** directly dereferences these pointers instead of copying data, and failing to meet alignment requirements can lead to unpredictable errors, such as crashes.
You can use `CGLM_ALIGN` and `CGLM_ALIGN_MAT` macros for aligning local variables or struct members. However, when dealing with dynamic memory allocation or custom memory locations, you'll need to ensure alignment requirements are met appropriately for those cases
Clipspace Option[s]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
By starting **v0.8.3** cglm provides options to switch between clipspace configurations.
Clipspace related files are located at `include/cglm/[struct]/clipspace.h` but
these are included in related files like `cam.h`. If you don't want to change your existing
clipspace configuration and want to use different clipspace function like `glm_lookat_zo` or `glm_lookat_lh_zo`...
then you can include individual headers or just define `CGLM_CLIPSPACE_INCLUDE_ALL` which will include all headers for you.
1. **CGLM_CLIPSPACE_INCLUDE_ALL**
2. **CGLM_FORCE_DEPTH_ZERO_TO_ONE**
3. **CGLM_FORCE_LEFT_HANDED**
1. **CGLM_CLIPSPACE_INCLUDE_ALL**:
By defining this macro, **cglm** will include all clipspace functions for you by just using
`#include cglm/cglm.h` or `#include cglm/struct.h` or `#include cglm/call.h`
Otherwise you need to include header you want manually e.g. `#include cglm/clipspace/view_rh_zo.h`
2. **CGLM_FORCE_DEPTH_ZERO_TO_ONE**
This is similar to **GLM**'s **GLM_FORCE_DEPTH_ZERO_TO_ONE** option.
This will set clip space between 0 to 1 which makes **cglm** Vulkan, Metal friendly.
You can use functions like `glm_lookat_lh_zo()` individually. By setting **CGLM_FORCE_DEPTH_ZERO_TO_ONE**
functions in cam.h for instance will use `_zo` versions.
3. **CGLM_FORCE_LEFT_HANDED**
Force **cglm** to use the left handed coordinate system by default, currently **cglm** uses right handed coordinate system as default,
you can change this behavior with this option.
**VERY VERY IMPORTANT:**
Be careful if you include **cglm** in multiple projects.
SSE and SSE2 Shuffle Option
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
**_mm_shuffle_ps** generates **shufps** instruction even if registers are same.
You can force it to generate **pshufd** instruction by defining
**CGLM_USE_INT_DOMAIN** macro. As default it is not defined.
**CGLM_NO_INT_DOMAIN** macro. As default it is not defined.
SSE3 and SSE4 Dot Product Options
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -50,3 +87,46 @@ You have to extra options for dot product: **CGLM_SSE4_DOT** and **CGLM_SSE3_DOT
- If **SSE3** is enabled then you can define **CGLM_SSE3_DOT** to force cglm to use **_mm_hadd_ps** instructions.
otherwise cglm will use custom cglm's hadd functions which are optimized too.
Struct API Options
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
To configure the Struct API namespace, you can define the following macros before including the cglm/struct.h header:
- **CGLM_OMIT_NS_FROM_STRUCT_API**: omits CGLM_STRUCT_API_NS (`glms_`) namespace completely if there is sub namespace e.g `mat4_`, `vec4_` ... DEFAULT is not defined
- **CGLM_STRUCT_API_NS**: define name space for struct api, DEFAULT is **glms**
- **CGLM_STRUCT_API_NAME_SUFFIX**: define name suffix, DEFAULT is **empty** e.g defining it as #define CGLM_STRUCT_API_NAME_SUFFIX s will add s suffix to mat4_mul -> mat4s_mul
Print Options
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1. **CGLM_DEFINE_PRINTS**
2. **CGLM_NO_PRINTS_NOOP** (use CGLM_DEFINE_PRINTS)
Inline prints are only enabled in **DEBUG** mode or if **CGLM_DEFINE_PRINTS** is defined.
**glmc_** versions will always print too.
Because **cglm** tried to enable print functions in debug mode and disable them in
release/production mode to eliminate printing costs when we do not need them.
**cglm** checks **DEBUG** or **_DEBUG** macros to test debug mode, if these are not working for you then you can use
**CGLM_DEFINE_PRINTS** to force enable, or create a PR to introduce new macro to test against debugging mode.
If DEBUG mode is not enabled then print functions will be emptied to eliminate print function calls.
You can disable this feature too by defining **CGLM_DEFINE_PRINTS** macro top of cglm header
or in project/build settings...
3. **CGLM_PRINT_PRECISION** 5
precision.
4. **CGLM_PRINT_MAX_TO_SHORT** 1e5
if a number is greater than this value then %g will be used, since this is shorten print you won't be able to see high precision.
5. **CGLM_PRINT_COLOR** "\033[36m"
6. **CGLM_PRINT_COLOR_RESET** "\033[0m"
You can disable colorful print output by defining **CGLM_PRINT_COLOR** and **CGLM_PRINT_COLOR_RESET** as empty macro.
Because some terminals may not support colors.

View File

@@ -21,14 +21,14 @@ Functions:
Functions documentation
~~~~~~~~~~~~~~~~~~~~~~~
.. c:function:: void glm_unprojecti(vec3 pos, mat4 invMat, vec4 vp, vec3 dest)
.. c:function:: void glm_unprojecti(vec3 pos, mat4 invMat, vec4 vp, vec3 dest)
| maps the specified viewport coordinates into specified space [1]
the matrix should contain projection matrix.
if you don't have ( and don't want to have ) an inverse matrix then use
glm_unproject version. You may use existing inverse of matrix in somewhere
else, this is why glm_unprojecti exists to save save inversion cost
:c:func:`glm_unproject` version. You may use existing inverse of matrix in somewhere
else, this is why **glm_unprojecti** exists to save inversion cost
[1] space:
- if m = invProj: View Space
@@ -57,7 +57,7 @@ Functions documentation
| maps the specified viewport coordinates into specified space [1]
the matrix should contain projection matrix.
this is same as glm_unprojecti except this function get inverse matrix for
this is same as :c:func:`glm_unprojecti` except this function get inverse matrix for
you.
[1] space:
@@ -80,7 +80,7 @@ Functions documentation
| *[in]* **vp** viewport as [x, y, width, height]
| *[out]* **dest** unprojected coordinates
.. c:function:: void glm_project(vec3 pos, mat4 m, vec4 vp, vec3 dest)
.. c:function:: void glm_project(vec3 pos, mat4 m, vec4 vp, vec3 dest)
| map object coordinates to window coordinates
@@ -91,12 +91,29 @@ Functions documentation
glm_mat4_mul(proj, view, viewProj);
glm_mat4_mul(viewProj, model, MVP);
this could be useful for gettng a bbox which fits with view frustum and
object bounding boxes. In this case you crop view frustum box with objects
box
Parameters:
| *[in]* **pos** object coordinates
| *[in]* **m** MVP matrix
| *[in]* **vp** viewport as [x, y, width, height]
| *[out]* **dest** projected coordinates
.. c:function:: float glm_project_z(vec3 pos, mat4 m)
| map object's z coordinate to window coordinates
this is same as :c:func:`glm_project` except this function projects only Z coordinate
which reduces a few calculations and parameters.
Computing MVP:
.. code-block:: c
glm_mat4_mul(proj, view, viewProj);
glm_mat4_mul(viewProj, model, MVP);
Parameters:
| *[in]* **pos** object coordinates
| *[in]* **m** MVP matrix
Returns:
projected z coordinate

View File

@@ -11,9 +11,9 @@ Header: cglm/quat.h
What you can do with quaternions with existing functions is (Some of them):
- You can rotate transform matrix using quaterion
- You can rotate vector using quaterion
- You can create view matrix using quaterion
- You can rotate transform matrix using quaternion
- You can rotate vector using quaternion
- You can create view matrix using quaternion
- You can create a lookrotation (from source point to dest)
Table of contents (click to go):
@@ -32,6 +32,7 @@ Functions:
#. :c:func:`glm_quat`
#. :c:func:`glm_quatv`
#. :c:func:`glm_quat_copy`
#. :c:func:`glm_quat_from_vecs`
#. :c:func:`glm_quat_norm`
#. :c:func:`glm_quat_normalize`
#. :c:func:`glm_quat_normalize_to`
@@ -52,7 +53,9 @@ Functions:
#. :c:func:`glm_quat_mat3`
#. :c:func:`glm_quat_mat3t`
#. :c:func:`glm_quat_lerp`
#. :c:func:`glm_quat_nlerp`
#. :c:func:`glm_quat_slerp`
#. :c:func:`glm_quat_slerp_longest`
#. :c:func:`glm_quat_look`
#. :c:func:`glm_quat_for`
#. :c:func:`glm_quat_forp`
@@ -60,6 +63,7 @@ Functions:
#. :c:func:`glm_quat_rotate`
#. :c:func:`glm_quat_rotate_at`
#. :c:func:`glm_quat_rotate_atm`
#. :c:func:`glm_quat_make`
Functions documentation
~~~~~~~~~~~~~~~~~~~~~~~
@@ -122,6 +126,20 @@ Functions documentation
| *[in]* **q** source quaternion
| *[out]* **dest** destination quaternion
.. c:function:: void glm_quat_from_vecs(vec3 a, vec3 b, versor dest)
| compute unit quaternion needed to rotate a into b
References:
* `Finding quaternion representing the rotation from one vector to another <https://stackoverflow.com/a/11741520/183120>`_
* `Quaternion from two vectors <http://lolengine.net/blog/2014/02/24/quaternion-from-two-vectors-final>`_
* `Angle between vectors <http://www.euclideanspace.com/maths/algebra/vectors/angleBetween/minorlogic.htm>`_
Parameters:
| *[in]* **a** unit vector
| *[in]* **b** unit vector
| *[in]* **dest** unit quaternion
.. c:function:: float glm_quat_norm(versor q)
| returns norm (magnitude) of quaternion
@@ -304,6 +322,25 @@ Functions documentation
| *[in]* **t** interpolant (amount) clamped between 0 and 1
| *[out]* **dest** result quaternion
.. c:function:: void glm_quat_nlerp(versor q, versor r, float t, versor dest)
| interpolates between two quaternions
| taking the shortest rotation path using
| normalized linear interpolation (NLERP)
| This is a cheaper alternative to slerp; most games use nlerp
| for animations as it visually makes little difference.
References:
* `Understanding Slerp, Then Not Using it <http://number-none.com/product/Understanding%20Slerp,%20Then%20Not%20Using%20It>`_
* `Lerp, Slerp and Nlerp <https://keithmaggio.wordpress.com/2011/02/15/math-magician-lerp-slerp-and-nlerp/>`_
Parameters:
| *[in]* **from** from
| *[in]* **to** to
| *[in]* **t** interpolant (amount) clamped between 0 and 1
| *[out]* **dest** result quaternion
.. c:function:: void glm_quat_slerp(versor q, versor r, float t, versor dest)
| interpolates between two quaternions
@@ -315,6 +352,17 @@ Functions documentation
| *[in]* **t** interpolant (amount) clamped between 0 and 1
| *[out]* **dest** result quaternion
.. c:function:: void glm_quat_slerp_longest(versor q, versor r, float t, versor dest)
| interpolates between two quaternions
| using spherical linear interpolation (SLERP) and always takes the longest path
Parameters:
| *[in]* **from** from
| *[in]* **to** to
| *[in]* **t** interpolant (amount) clamped between 0 and 1
| *[out]* **dest** result quaternion
.. c:function:: void glm_quat_look(vec3 eye, versor ori, mat4 dest)
| creates view matrix using quaternion as camera orientation
@@ -324,26 +372,24 @@ Functions documentation
| *[in]* **ori** orientation in world space as quaternion
| *[out]* **dest** result matrix
.. c:function:: void glm_quat_for(vec3 dir, vec3 fwd, vec3 up, versor dest)
.. c:function:: void glm_quat_for(vec3 dir, vec3 up, versor dest)
| creates look rotation quaternion
Parameters:
| *[in]* **dir** direction to look
| *[in]* **fwd** forward vector
| *[in]* **up** up vector
| *[out]* **dest** result matrix
.. c:function:: void glm_quat_forp(vec3 from, vec3 to, vec3 fwd, vec3 up, versor dest)
.. c:function:: void glm_quat_forp(vec3 from, vec3 to, vec3 up, versor dest)
| creates look rotation quaternion using source and destination positions p suffix stands for position
| creates look rotation quaternion using source and destination positions p suffix stands for position
| this is similar to glm_quat_for except this computes direction for glm_quat_for for you.
Parameters:
| *[in]* **from** source point
| *[in]* **to** destination point
| *[in]* **fwd** forward vector
| *[in]* **up** up vector
| *[out]* **dest** result matrix
@@ -376,7 +422,7 @@ Functions documentation
| *[in]* **q** quaternion
| *[in]* **pivot** pivot
.. c:function:: void glm_quat_rotate(mat4 m, versor q, mat4 dest)
.. c:function:: void glm_quat_rotate_atm(mat4 m, versor q, vec3 pivot)
| rotate NEW transform matrix using quaternion at pivot point
| this creates rotation matrix, it assumes you don't have a matrix
@@ -387,3 +433,13 @@ Functions documentation
| *[in, out]* **m** existing transform matrix to rotate
| *[in]* **q** quaternion
| *[in]* **pivot** pivot
.. c:function:: void glm_quat_make(const float * __restrict src, versor dest)
Create quaternion from pointer
.. note:: **@src** must contain at least 4 elements. cglm store quaternions as [x, y, z, w].
Parameters:
| *[in]* **src** pointer to an array of floats
| *[out]* **dest** destination quaternion

69
docs/source/ray.rst Normal file
View File

@@ -0,0 +1,69 @@
.. default-domain:: C
ray
====
Header: cglm/ray.h
This is for collision-checks used by ray-tracers and the like.
Table of contents (click to go):
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Functions:
1. :c:func:`glm_ray_triangle`
#. :c:func:`glm_ray_sphere`
#. :c:func:`glm_ray_at`
Functions documentation
~~~~~~~~~~~~~~~~~~~~~~~
.. c:function:: bool glm_ray_triangle(vec3 origin, vec3 direction, vec3 v0, vec3 v1, vec3 v2, float *d)
MöllerTrumbore ray-triangle intersection algorithm
Parameters:
| *[in]* **origin** origin of ray
| *[in]* **direction** direction of ray
| *[in]* **v0** first vertex of triangle
| *[in]* **v1** second vertex of triangle
| *[in]* **v2** third vertex of triangle
| *[in, out]* **d** float pointer to save distance to intersection
| *[out]* **intersection** whether there is intersection
.. c:function:: bool glm_ray_sphere(vec3 origin, vec3 dir, vec4 s, float * __restrict t1, float * __restrict t2)
ray sphere intersection
returns false if there is no intersection if true:
- t1 > 0, t2 > 0: ray intersects the sphere at t1 and t2 both ahead of the origin
- t1 < 0, t2 > 0: ray starts inside the sphere, exits at t2
- t1 < 0, t2 < 0: no intersection ahead of the ray ( returns false )
- the caller can check if the intersection points (t1 and t2) fall within a
specific range (for example, tmin < t1, t2 < tmax) to determine if the
intersections are within a desired segment of the ray
Parameters:
| *[in]* **origin** ray origin
| *[in]* **dir** normalized ray direction
| *[in]* **s** sphere [center.x, center.y, center.z, radii]
| *[out]* **t1** near point1 (closer to origin)
| *[out]* **t2** far point2 (farther from origin)
Return:
| whether there is intersection
.. c:function:: bool glm_ray_at(vec3 orig, vec3 dir, float t, vec3 point)
point using t by 𝐏(𝑡)=𝐀+𝑡𝐛
Parameters:
| *[in]* **origin** ray origin
| *[in]* **dir** ray direction
| *[out]* **t** parameter
| *[out]* **point** point at t
Return:
| point at t

View File

@@ -9,7 +9,7 @@ Header: cglm/sphere.h
Sphere Representation in cglm is *vec4*: **[center.x, center.y, center.z, radii]**
You can call any vec3 function by pasing sphere. Because first three elements
You can call any vec3 function by passing sphere. Because first three elements
defines center of sphere.
Table of contents (click to go):

View File

@@ -0,0 +1,12 @@
@media screen {
/* content column
*
* RTD theme's default is 800px as max width for the content, but we have
* tables with tons of columns, which need the full width of the view-port.
*
* Comment from yocto project theme_overrides.css
*/
.wy-nav-content{ max-width: none; }
}

View File

@@ -3,30 +3,30 @@
Troubleshooting
================================================================================
It is possible that sometimes you may get crashes or wrong results.
It is possible that you may sometimes get crashes or wrong results.
Follow these topics
Memory Allocation:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Again, **cglm** doesn't alloc any memory on heap.
cglm functions works like memcpy; it copies data from src,
makes calculations then copy the result to dest.
Recall that **cglm** does not alloc any memory on the heap.
cglm functions work like memcpy; they copy data from src,
make calculations, then copy the result to dest.
You are responsible for allocation of **src** and **dest** parameters.
Alignment:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
**vec4** and **mat4** types requires 16 byte alignment.
These types are marked with align attribute to let compiler know about this
**vec4** and **mat4** types require 16 byte alignment.
These types are marked with the align attribute to let the compiler know about this
requirement.
But since MSVC (Windows) throws the error:
Since MSVC (Windows) throws this error:
**"formal parameter with requested alignment of 16 won't be aligned"**
The alignment attribute has been commented for MSVC
The alignment attribute has been commented out for MSVC
.. code-block:: c
@@ -37,48 +37,61 @@ The alignment attribute has been commented for MSVC
#endif.
So MSVC may not know about alignment requirements when creating variables.
The interesting thing is that, if I remember correctly Visual Studio 2017
The interesting thing is that, if I remember correctly, Visual Studio 2017
doesn't throw the above error. So we may uncomment that line for Visual Studio 2017,
you may do it yourself.
**This MSVC issue is still in TODOs.**
**UPDATE:** By starting v0.4.5 cglm provides an option to disable alignment requirement.
Also alignment is disabled for older msvc verisons as default. Now alignment is only required in Visual Studio 2017 version 15.6+ if CGLM_ALL_UNALIGNED macro is not defined.
**UPDATE:** Starting with v0.4.5, cglm provides an option to disable the alignment requirement.
Also, alignment is disabled for older msvc versions by default. Now alignment is only required in Visual Studio 2017 version 15.6+ if the CGLM_ALL_UNALIGNED macro is not defined.
Crashes, Invalid Memory Access:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Probably you are trying to write to invalid memory location.
Most likely, you are trying to write to an invalid memory location.
You may used wrong function for what you want to do.
You may have used a wrong function for what you want to do.
For instance you may called **glm_vec4_** functions for **vec3** data type.
It will try to write 32 byte but since **vec3** is 24 byte it should throw
memory access error or exit the app without saying anything.
For example, you may have called a **glm_vec4_** function for a **vec3** data type.
It will try to write 32 bytes, but since **vec3** is 24 bytes, it should throw
a memory access error or exit the app without saying anything.
**UPDATE - IMPORTANT:**
| On MSVC or some other compilers, if alignment is enabled (default) then double check alignment requirements if you got a crash.
| If you send GLM_VEC4_ONE or similar macros directly to a function, it may be crashed.
| Because compiler may not apply alignment as defined on **typedef** to that macro while passing it (on stack) to a function.
| If you send GLM_VEC4_ONE or similar macros directly to a function, it may crash.
| Because the compiler may not apply alignment as defined on **typedef** to that macro while passing it (on stack) to a function.
Wrong Results:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Again, you may used wrong function.
Again, you may have used a wrong function.
For instance if you use **glm_normalize()** or **glm_vec3_normalize()** for **vec4**,
it will assume that passed param is **vec3** and will normalize it for **vec3**.
Since you need to **vec4** to be normalized in your case, you will get wrong results.
For instance if you use **glm_normalize()** or **glm_vec3_normalize()** for a **vec4**,
it will assume that the passed param is a **vec3**, and will normalize it for **vec3**.
Since you need a **vec4** to be normalized in your case, you will get wrong results.
Accessing vec4 type with vec3 functions is valid, you will not get any error, exception or crash.
Accessing a vec4 type with vec3 functions is valid, you will not get any error, exception or crash.
You only get wrong results if you don't know what you are doing!
So be carefull, when your IDE (Xcode, Visual Studio ...) tried to autocomplete function names, READ IT :)
So be careful, when your IDE (Xcode, Visual Studio ...) tries to autocomplete function names, READ IT :)
**Also implementation may be wrong please let us know by creating an issue on Github.**
**Also implementation may be wrong, please let us know by creating an issue on Github.**
BAD_ACCESS : Thread 1: EXC_BAD_ACCESS (code=EXC_I386_GPFLT) or Similar Errors/Crashes
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This is a similar issue with alignment. For instance if you compiled **cglm** with
AVX (**-mavx**, intentionally or not) and if you use **cglm** in an environment that doesn't
support AVX (or if AVX is disabled intentionally) e.g. environment that max support SSE2/3/4,
then you probably get **BAD ACCESS** or similar...
Because if you compile **cglm** with AVX it aligns **mat4** with 32 byte boundary,
and your project aligns that as a 16 byte boundary...
Check alignment, supported vector extension, or simd in **cglm** and linked projects...
Other Issues?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

View File

@@ -23,6 +23,7 @@ Functions:
#. :c:func:`glm_max`
#. :c:func:`glm_clamp`
#. :c:func:`glm_lerp`
#. :c:func:`glm_swapf`
Functions documentation
~~~~~~~~~~~~~~~~~~~~~~~
@@ -67,14 +68,14 @@ Functions documentation
.. c:function:: void glm_make_rad(float *degm)
| convert exsisting degree to radians. this will override degrees value
| convert existing degree to radians. this will override degrees value
Parameters:
| *[in, out]* **deg** pointer to angle in degrees
.. c:function:: void glm_make_deg(float *rad)
| convert exsisting radians to degree. this will override radians value
| convert existing radians to degree. this will override radians value
Parameters:
| *[in, out]* **rad** pointer to angle in radians
@@ -146,7 +147,7 @@ Functions documentation
| *[in]* **b** b
Returns:
true if a and b equals
true if a and b are equal
.. c:function:: float glm_percent(float from, float to, float current)
@@ -158,7 +159,7 @@ Functions documentation
| *[in]* **current** value between from and to values
Returns:
clamped normalized percent (0-100 in 0-1)
percentage of current value
.. c:function:: float glm_percentc(float from, float to, float current)
@@ -171,3 +172,11 @@ Functions documentation
Returns:
clamped normalized percent (0-100 in 0-1)
.. c:function:: void glm_swapf(float *a, float *b)
swap two float values
Parameters:
| *[in]* **a** float 1
| *[in]* **b** float 2

161
docs/source/vec2-ext.rst Normal file
View File

@@ -0,0 +1,161 @@
.. default-domain:: C
vec2 extra
==========
Header: cglm/vec2-ext.h
There are some functions are in called in extra header. These are called extra
because they are not used like other functions in vec2.h in the future some of
these functions ma be moved to vec2 header.
Table of contents (click to go):
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Functions:
1. :c:func:`glm_vec2_fill`
#. :c:func:`glm_vec2_eq`
#. :c:func:`glm_vec2_eq_eps`
#. :c:func:`glm_vec2_eq_all`
#. :c:func:`glm_vec2_eqv`
#. :c:func:`glm_vec2_eqv_eps`
#. :c:func:`glm_vec2_max`
#. :c:func:`glm_vec2_min`
#. :c:func:`glm_vec2_isnan`
#. :c:func:`glm_vec2_isinf`
#. :c:func:`glm_vec2_isvalid`
#. :c:func:`glm_vec2_sign`
#. :c:func:`glm_vec2_abs`
#. :c:func:`glm_vec2_fract`
#. :c:func:`glm_vec2_floor`
#. :c:func:`glm_vec2_sqrt`
Functions documentation
~~~~~~~~~~~~~~~~~~~~~~~
.. c:function:: void glm_vec2_fill(vec2 v, float val)
fill a vector with specified value
Parameters:
| *[in,out]* **dest** destination
| *[in]* **val** value
.. c:function:: bool glm_vec2_eq(vec2 v, float val)
check if vector is equal to value (without epsilon)
Parameters:
| *[in]* **v** vector
| *[in]* **val** value
.. c:function:: bool glm_vec2_eq_eps(vec2 v, float val)
check if vector is equal to value (with epsilon)
Parameters:
| *[in]* **v** vector
| *[in]* **val** value
.. c:function:: bool glm_vec2_eq_all(vec2 v)
check if vectors members are equal (without epsilon)
Parameters:
| *[in]* **v** vector
.. c:function:: bool glm_vec2_eqv(vec2 v1, vec2 v2)
check if vector is equal to another (without epsilon) vector
Parameters:
| *[in]* **vec** vector 1
| *[in]* **vec** vector 2
.. c:function:: bool glm_vec2_eqv_eps(vec2 v1, vec2 v2)
check if vector is equal to another (with epsilon)
Parameters:
| *[in]* **v1** vector1
| *[in]* **v2** vector2
.. c:function:: float glm_vec2_max(vec2 v)
max value of vector
Parameters:
| *[in]* **v** vector
.. c:function:: float glm_vec2_min(vec2 v)
min value of vector
Parameters:
| *[in]* **v** vector
.. c:function:: bool glm_vec2_isnan(vec2 v)
| check if one of items is NaN (not a number)
| you should only use this in DEBUG mode or very critical asserts
Parameters:
| *[in]* **v** vector
.. c:function:: bool glm_vec2_isinf(vec2 v)
| check if one of items is INFINITY
| you should only use this in DEBUG mode or very critical asserts
Parameters:
| *[in]* **v** vector
.. c:function:: bool glm_vec2_isvalid(vec2 v)
| check if all items are valid number
| you should only use this in DEBUG mode or very critical asserts
Parameters:
| *[in]* **v** vector
.. c:function:: void glm_vec2_sign(vec2 v, vec2 dest)
get sign of 32 bit float as +1, -1, 0
Parameters:
| *[in]* **v** vector
| *[out]* **dest** sign vector (only keeps signs as -1, 0, -1)
.. c:function:: void glm_vec2_abs(vec2 v, vec2 dest)
absolute value of each vector item
Parameters:
| *[in]* **v** vector
| *[out]* **dest** destination vector
.. c:function:: void glm_vec2_fract(vec2 v, vec2 dest)
get fractional part of each vector item
Parameters:
| *[in]* **v** vector
| *[out]* **dest** destination vector
.. c:function:: void glm_vec2_floor(vec2 v, vec2 dest)
floor value of each vector item
Parameters:
| *[in]* **v** vector
| *[out]* **dest** destination vector
.. c:function:: void glm_vec2_sqrt(vec2 v, vec2 dest)
square root of each vector item
Parameters:
| *[in]* **v** vector
| *[out]* **dest** destination vector (sqrt(v))

424
docs/source/vec2.rst Normal file
View File

@@ -0,0 +1,424 @@
.. default-domain:: C
vec2
====
Header: cglm/vec2.h
Table of contents (click to go):
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Macros:
1. GLM_VEC2_ONE_INIT
#. GLM_VEC2_ZERO_INIT
#. GLM_VEC2_ONE
#. GLM_VEC2_ZERO
Functions:
1. :c:func:`glm_vec2`
#. :c:func:`glm_vec2_copy`
#. :c:func:`glm_vec2_zero`
#. :c:func:`glm_vec2_one`
#. :c:func:`glm_vec2_dot`
#. :c:func:`glm_vec2_cross`
#. :c:func:`glm_vec2_norm2`
#. :c:func:`glm_vec2_norm`
#. :c:func:`glm_vec2_add`
#. :c:func:`glm_vec2_adds`
#. :c:func:`glm_vec2_sub`
#. :c:func:`glm_vec2_subs`
#. :c:func:`glm_vec2_mul`
#. :c:func:`glm_vec2_scale`
#. :c:func:`glm_vec2_scale_as`
#. :c:func:`glm_vec2_div`
#. :c:func:`glm_vec2_divs`
#. :c:func:`glm_vec2_addadd`
#. :c:func:`glm_vec2_subadd`
#. :c:func:`glm_vec2_muladd`
#. :c:func:`glm_vec2_muladds`
#. :c:func:`glm_vec2_maxadd`
#. :c:func:`glm_vec2_minadd`
#. :c:func:`glm_vec2_negate`
#. :c:func:`glm_vec2_negate_to`
#. :c:func:`glm_vec2_normalize`
#. :c:func:`glm_vec2_normalize_to`
#. :c:func:`glm_vec2_rotate`
#. :c:func:`glm_vec2_center`
#. :c:func:`glm_vec2_distance2`
#. :c:func:`glm_vec2_distance`
#. :c:func:`glm_vec2_maxv`
#. :c:func:`glm_vec2_minv`
#. :c:func:`glm_vec2_clamp`
#. :c:func:`glm_vec2_lerp`
#. :c:func:`glm_vec2_make`
#. :c:func:`glm_vec2_reflect`
#. :c:func:`glm_vec2_refract`
Functions documentation
~~~~~~~~~~~~~~~~~~~~~~~
.. c:function:: void glm_vec2(float * v, vec2 dest)
init vec2 using vec3 or vec4
Parameters:
| *[in]* **v** vector
| *[out]* **dest** destination
.. c:function:: void glm_vec2_copy(vec2 a, vec2 dest)
copy all members of [a] to [dest]
Parameters:
| *[in]* **a** source
| *[out]* **dest** destination
.. c:function:: void glm_vec2_zero(vec2 v)
makes all members 0.0f (zero)
Parameters:
| *[in, out]* **v** vector
.. c:function:: void glm_vec2_one(vec2 v)
makes all members 1.0f (one)
Parameters:
| *[in, out]* **v** vector
.. c:function:: float glm_vec2_dot(vec2 a, vec2 b)
dot product of vec2
Parameters:
| *[in]* **a** vector1
| *[in]* **b** vector2
Returns:
dot product
.. c:function:: void glm_vec2_cross(vec2 a, vec2 b, vec2 d)
cross product of two vector (RH)
| ref: http://allenchou.net/2013/07/cross-product-of-2d-vectors/
Parameters:
| *[in]* **a** vector 1
| *[in]* **b** vector 2
| *[out]* **dest** destination
Returns:
Z component of cross product
.. c:function:: float glm_vec2_norm2(vec2 v)
norm * norm (magnitude) of vector
we can use this func instead of calling norm * norm, because it would call
sqrtf function twice but with this func we can avoid func call, maybe this is
not good name for this func
Parameters:
| *[in]* **v** vector
Returns:
square of norm / magnitude
.. c:function:: float glm_vec2_norm(vec2 vec)
| euclidean norm (magnitude), also called L2 norm
| this will give magnitude of vector in euclidean space
Parameters:
| *[in]* **vec** vector
.. c:function:: void glm_vec2_add(vec2 a, vec2 b, vec2 dest)
add a vector to b vector store result in dest
Parameters:
| *[in]* **a** vector1
| *[in]* **b** vector2
| *[out]* **dest** destination vector
.. c:function:: void glm_vec2_adds(vec2 a, float s, vec2 dest)
add scalar to v vector store result in dest (d = v + vec(s))
Parameters:
| *[in]* **v** vector
| *[in]* **s** scalar
| *[out]* **dest** destination vector
.. c:function:: void glm_vec2_sub(vec2 v1, vec2 v2, vec2 dest)
subtract b vector from a vector store result in dest (d = v1 - v2)
Parameters:
| *[in]* **a** vector1
| *[in]* **b** vector2
| *[out]* **dest** destination vector
.. c:function:: void glm_vec2_subs(vec2 v, float s, vec2 dest)
subtract scalar from v vector store result in dest (d = v - vec(s))
Parameters:
| *[in]* **v** vector
| *[in]* **s** scalar
| *[out]* **dest** destination vector
.. c:function:: void glm_vec2_mul(vec2 a, vec2 b, vec2 d)
multiply two vector (component-wise multiplication)
Parameters:
| *[in]* **a** vector
| *[in]* **b** scalar
| *[out]* **d** result = (a[0] * b[0], a[1] * b[1], a[2] * b[2])
.. c:function:: void glm_vec2_scale(vec2 v, float s, vec2 dest)
multiply/scale vec2 vector with scalar: result = v * s
Parameters:
| *[in]* **v** vector
| *[in]* **s** scalar
| *[out]* **dest** destination vector
.. c:function:: void glm_vec2_scale_as(vec2 v, float s, vec2 dest)
make vec2 vector scale as specified: result = unit(v) * s
Parameters:
| *[in]* **v** vector
| *[in]* **s** scalar
| *[out]* **dest** destination vector
.. c:function:: void glm_vec2_div(vec2 a, vec2 b, vec2 dest)
div vector with another component-wise division: d = a / b
Parameters:
| *[in]* **a** vector 1
| *[in]* **b** vector 2
| *[out]* **dest** result = (a[0] / b[0], a[1] / b[1], a[2] / b[2])
.. c:function:: void glm_vec2_divs(vec2 v, float s, vec2 dest)
div vector with scalar: d = v / s
Parameters:
| *[in]* **v** vector
| *[in]* **s** scalar
| *[out]* **dest** result = (a[0] / s, a[1] / s, a[2] / s])
.. c:function:: void glm_vec2_addadd(vec2 a, vec2 b, vec2 dest)
| add two vectors and add result to sum
| it applies += operator so dest must be initialized
Parameters:
| *[in]* **a** vector 1
| *[in]* **b** vector 2
| *[out]* **dest** dest += (a + b)
.. c:function:: void glm_vec2_subadd(vec2 a, vec2 b, vec2 dest)
| sub two vectors and add result to sum
| it applies += operator so dest must be initialized
Parameters:
| *[in]* **a** vector 1
| *[in]* **b** vector 2
| *[out]* **dest** dest += (a - b)
.. c:function:: void glm_vec2_muladd(vec2 a, vec2 b, vec2 dest)
| mul two vectors and add result to sum
| it applies += operator so dest must be initialized
Parameters:
| *[in]* **a** vector 1
| *[in]* **b** vector 2
| *[out]* **dest** dest += (a * b)
.. c:function:: void glm_vec2_muladds(vec2 a, float s, vec2 dest)
| mul vector with scalar and add result to sum
| it applies += operator so dest must be initialized
Parameters:
| *[in]* **a** vector
| *[in]* **s** scalar
| *[out]* **dest** dest += (a * b)
.. c:function:: void glm_vec2_maxadd(vec2 a, vec2 b, vec2 dest)
| add max of two vector to result/dest
| it applies += operator so dest must be initialized
Parameters:
| *[in]* **a** vector 1
| *[in]* **b** vector 2
| *[out]* **dest** dest += (a * b)
.. c:function:: void glm_vec2_minadd(vec2 a, vec2 b, vec2 dest)
| add min of two vector to result/dest
| it applies += operator so dest must be initialized
Parameters:
| *[in]* **a** vector 1
| *[in]* **b** vector 2
| *[out]* **dest** dest += (a * b)
.. c:function:: void glm_vec2_negate(vec2 v)
negate vector components
Parameters:
| *[in, out]* **v** vector
.. c:function:: void glm_vec2_negate_to(vec2 v, vec2 dest)
negate vector components and store result in dest
Parameters:
| *[in]* **v** vector
| *[out]* **dest** negated vector
.. c:function:: void glm_vec2_normalize(vec2 v)
normalize vec2 and store result in same vec
Parameters:
| *[in, out]* **v** vector
.. c:function:: void glm_vec2_normalize_to(vec2 vec, vec2 dest)
normalize vec2 to dest
Parameters:
| *[in]* **vec** source
| *[out]* **dest** destination
.. c:function:: void glm_vec2_rotate(vec2 v, float angle, vec2 dest)
rotate vec2 around axis by angle using Rodrigues' rotation formula
Parameters:
| *[in]* **v** vector
| *[in]* **axis** axis vector
| *[out]* **dest** destination
.. c:function:: void glm_vec2_center(vec2 v1, vec2 v2, vec2 dest)
find center point of two vector
Parameters:
| *[in]* **v1** vector1
| *[in]* **v2** vector2
| *[out]* **dest** center point
.. c:function:: float glm_vec2_distance2(vec2 v1, vec2 v2)
squared distance between two vectors
Parameters:
| *[in]* **mat** vector1
| *[in]* **row1** vector2
Returns:
| squared distance (distance * distance)
.. c:function:: float glm_vec2_distance(vec2 v1, vec2 v2)
distance between two vectors
Parameters:
| *[in]* **mat** vector1
| *[in]* **row1** vector2
Returns:
| distance
.. c:function:: void glm_vec2_maxv(vec2 v1, vec2 v2, vec2 dest)
max values of vectors
Parameters:
| *[in]* **v1** vector1
| *[in]* **v2** vector2
| *[out]* **dest** destination
.. c:function:: void glm_vec2_minv(vec2 v1, vec2 v2, vec2 dest)
min values of vectors
Parameters:
| *[in]* **v1** vector1
| *[in]* **v2** vector2
| *[out]* **dest** destination
.. c:function:: void glm_vec2_clamp(vec2 v, float minVal, float maxVal)
constrain a value to lie between two further values
Parameters:
| *[in, out]* **v** vector
| *[in]* **minVal** minimum value
| *[in]* **maxVal** maximum value
.. c:function:: void glm_vec2_lerp(vec2 from, vec2 to, float t, vec2 dest)
linear interpolation between two vector
| formula: from + s * (to - from)
Parameters:
| *[in]* **from** from value
| *[in]* **to** to value
| *[in]* **t** interpolant (amount) clamped between 0 and 1
| *[out]* **dest** destination
.. c:function:: void glm_vec2_make(const float * __restrict src, vec2 dest)
Create two dimensional vector from pointer
.. note:: **@src** must contain at least 2 elements.
Parameters:
| *[in]* **src** pointer to an array of floats
| *[out]* **dest** destination vector
.. c:function:: void glm_vec2_reflect(vec2 v, vec2 n, vec2 dest)
Reflection vector using an incident ray and a surface normal
Parameters:
| *[in]* **v** incident vector
| *[in]* **n** *❗️ normalized ❗️* normal vector
| *[out]* **dest** destination: reflection result
.. c:function:: bool glm_vec2_refract(vec2 v, vec2 n, float eta, vec2 dest)
Computes refraction vector for an incident vector and a surface normal.
Calculates the refraction vector based on Snell's law. If total internal reflection
occurs (angle too great given eta), dest is set to zero and returns false.
Otherwise, computes refraction vector, stores it in dest, and returns true.
Parameters:
| *[in]* **v** *❗️ normalized ❗️* incident vector
| *[in]* **n** *❗️ normalized ❗️* normal vector
| *[in]* **eta** ratio of indices of refraction (incident/transmitted)
| *[out]* **dest** refraction vector if refraction occurs; zero vector otherwise
Returns:
returns true if refraction occurs; false if total internal reflection occurs.

View File

@@ -27,6 +27,9 @@ Functions:
#. :c:func:`glm_vec3_isinf`
#. :c:func:`glm_vec3_isvalid`
#. :c:func:`glm_vec3_sign`
#. :c:func:`glm_vec3_abs`
#. :c:func:`glm_vec3_fract`
#. :c:func:`glm_vec3_floor`
#. :c:func:`glm_vec3_sqrt`
Functions documentation
@@ -49,6 +52,14 @@ Functions documentation
| *[in]* **val** value
| *[out]* **dest** destination
.. c:function:: void glm_vec3_fill(vec3 v, float val)
fill a vector with specified value
Parameters:
| *[out]* **v** vector
| *[in]* **val** value
.. c:function:: bool glm_vec3_eq(vec3 v, float val)
check if vector is equal to value (without epsilon)
@@ -134,6 +145,30 @@ Functions documentation
| *[in]* **v** vector
| *[out]* **dest** sign vector (only keeps signs as -1, 0, -1)
.. c:function:: void glm_vec3_abs(vec3 v, vec3 dest)
absolute value of each vector item
Parameters:
| *[in]* **v** vector
| *[out]* **dest** destination vector
.. c:function:: void glm_vec3_fract(vec3 v, vec3 dest)
fractional part of each vector item
Parameters:
| *[in]* **v** vector
| *[out]* **dest** destination vector
.. c:function:: void glm_vec3_floor(vec3 v, vec3 dest)
floor of each vector item
Parameters:
| *[in]* **v** vector
| *[out]* **dest** destination vector
.. c:function:: void glm_vec3_sqrt(vec3 v, vec3 dest)
square root of each vector item

View File

@@ -13,7 +13,7 @@ Header: cglm/vec3.h
We mostly use vectors in graphics math, to make writing code faster
and easy to read, some *vec3* functions are aliased in global namespace.
For instance :c:func:`glm_dot` is alias of :c:func:`glm_vec3_dot`,
alias means inline wrapper here. There is no call verison of alias functions
alias means inline wrapper here. There is no call version of alias functions
There are also functions for rotating *vec3* vector. **_m4**, **_m3** prefixes
rotate *vec3* with matrix.
@@ -79,6 +79,10 @@ Functions:
#. :c:func:`glm_vec3_ortho`
#. :c:func:`glm_vec3_clamp`
#. :c:func:`glm_vec3_lerp`
#. :c:func:`glm_vec3_make`
#. :c:func:`glm_vec3_faceforward`
#. :c:func:`glm_vec3_reflect`
#. :c:func:`glm_vec3_refract`
Functions documentation
~~~~~~~~~~~~~~~~~~~~~~~
@@ -147,7 +151,7 @@ Functions documentation
norm * norm (magnitude) of vector
we can use this func instead of calling norm * norm, because it would call
sqrtf fuction twice but with this func we can avoid func call, maybe this is
sqrtf function twice but with this func we can avoid func call, maybe this is
not good name for this func
Parameters:
@@ -308,7 +312,7 @@ Functions documentation
.. c:function:: void glm_vec3_flipsign(vec3 v)
**DEPRACATED!**
**DEPRECATED!**
use :c:func:`glm_vec3_negate`
@@ -317,7 +321,7 @@ Functions documentation
.. c:function:: void glm_vec3_flipsign_to(vec3 v, vec3 dest)
**DEPRACATED!**
**DEPRECATED!**
use :c:func:`glm_vec3_negate_to`
@@ -327,7 +331,7 @@ Functions documentation
.. c:function:: void glm_vec3_inv(vec3 v)
**DEPRACATED!**
**DEPRECATED!**
use :c:func:`glm_vec3_negate`
@@ -336,7 +340,7 @@ Functions documentation
.. c:function:: void glm_vec3_inv_to(vec3 v, vec3 dest)
**DEPRACATED!**
**DEPRECATED!**
use :c:func:`glm_vec3_negate_to`
@@ -376,7 +380,7 @@ Functions documentation
.. c:function:: float glm_vec3_angle(vec3 v1, vec3 v2)
angle betwen two vector
angle between two vector
Parameters:
| *[in]* **v1** vector1
@@ -392,7 +396,7 @@ Functions documentation
Parameters:
| *[in, out]* **v** vector
| *[in]* **axis** axis vector (will be normalized)
| *[out]* **angle** angle (radians)
| *[in]* **angle** angle (radians)
.. c:function:: void glm_vec3_rotate_m4(mat4 m, vec3 v, vec3 dest)
@@ -435,8 +439,8 @@ Functions documentation
squared distance between two vectors
Parameters:
| *[in]* **mat** vector1
| *[in]* **row1** vector2
| *[in]* **v1** vector1
| *[in]* **v2** vector2
Returns:
| squared distance (distance * distance)
@@ -446,8 +450,8 @@ Functions documentation
distance between two vectors
Parameters:
| *[in]* **mat** vector1
| *[in]* **row1** vector2
| *[in]* **v1** vector1
| *[in]* **v2** vector2
Returns:
| distance
@@ -474,8 +478,11 @@ Functions documentation
possible orthogonal/perpendicular vector
References:
* `On picking an orthogonal vector (and combing coconuts) <http://lolengine.net/blog/2013/09/21/picking-orthogonal-vector-combing-coconuts>`_
Parameters:
| *[in]* **mat** vector
| *[in]* **v** vector
| *[out]* **dest** orthogonal/perpendicular vector
.. c:function:: void glm_vec3_clamp(vec3 v, float minVal, float maxVal)
@@ -498,3 +505,50 @@ Functions documentation
| *[in]* **to** to value
| *[in]* **t** interpolant (amount) clamped between 0 and 1
| *[out]* **dest** destination
.. c:function:: void glm_vec3_make(const float * __restrict src, vec3 dest)
Create three dimensional vector from pointer
.. note::: **@src** must contain at least 3 elements.
Parameters:
| *[in]* **src** pointer to an array of floats
| *[out]* **dest** destination vector
.. c:function:: void glm_vec3_faceforward(vec3 n, vec3 v, vec3 nref, vec3 dest)
A vector pointing in the same direction as another
Parameters:
| *[in]* **n** vector to orient
| *[in]* **v** incident vector
| *[in]* **nref** reference vector
| *[out]* **dest** destination: oriented vector, pointing away from the surface.
.. c:function:: void glm_vec3_reflect(vec3 v, vec3 n, vec3 dest)
Reflection vector using an incident ray and a surface normal
Parameters:
| *[in]* **v** incident vector
| *[in]* **n** *❗️ normalized ❗️* normal vector
| *[out]* **dest** destination: reflection result
.. c:function:: bool glm_vec3_refract(vec3 v, vec3 n, float eta, vec3 dest)
Computes refraction vector for an incident vector and a surface normal.
Calculates the refraction vector based on Snell's law. If total internal reflection
occurs (angle too great given eta), dest is set to zero and returns false.
Otherwise, computes refraction vector, stores it in dest, and returns true.
Parameters:
| *[in]* **v** *❗️ normalized ❗️* incident vector
| *[in]* **n** *❗️ normalized ❗️* normal vector
| *[in]* **eta** ratio of indices of refraction (incident/transmitted)
| *[out]* **dest** refraction vector if refraction occurs; zero vector otherwise
Returns:
returns true if refraction occurs; false if total internal reflection occurs.

View File

@@ -23,6 +23,15 @@ Functions:
#. :c:func:`glm_vec4_eqv_eps`
#. :c:func:`glm_vec4_max`
#. :c:func:`glm_vec4_min`
#. :c:func:`glm_vec4_isnan`
#. :c:func:`glm_vec4_isinf`
#. :c:func:`glm_vec4_isvalid`
#. :c:func:`glm_vec4_sign`
#. :c:func:`glm_vec4_abs`
#. :c:func:`glm_vec4_fract`
#. :c:func:`glm_vec4_floor`
#. :c:func:`glm_vec4_sqrt`
Functions documentation
~~~~~~~~~~~~~~~~~~~~~~~
@@ -129,6 +138,30 @@ Functions documentation
| *[in]* **v** vector
| *[out]* **dest** sign vector (only keeps signs as -1, 0, -1)
.. c:function:: void glm_vec4_abs(vec4 v, vec4 dest)
absolute value of each vector item
Parameters:
| *[in]* **v** vector
| *[out]* **dest** destination vector (abs(v))
.. c:function:: void glm_vec4_fract(vec4 v, vec4 dest)
fractional part of each vector item
Parameters:
| *[in]* **v** vector
| *[out]* **dest** destination vector (fract(v))
.. c:function:: void glm_vec4_floor(vec4 v, vec4 dest)
floor of each vector item
Parameters:
| *[in]* **v** vector
| *[out]* **dest** destination vector (floor(v))
.. c:function:: void glm_vec4_sqrt(vec4 v, vec4 dest)
square root of each vector item

View File

@@ -59,6 +59,9 @@ Functions:
#. :c:func:`glm_vec4_clamp`
#. :c:func:`glm_vec4_lerp`
#. :c:func:`glm_vec4_cubic`
#. :c:func:`glm_vec4_make`
#. :c:func:`glm_vec4_reflect`
#. :c:func:`glm_vec4_refract`
Functions documentation
~~~~~~~~~~~~~~~~~~~~~~~
@@ -107,6 +110,13 @@ Functions documentation
Parameters:
| *[in, out]* **v** vector
.. c:function:: void glm_vec4_one(vec4 v)
makes all members one
Parameters:
| *[in, out]* **v** vector
.. c:function:: float glm_vec4_dot(vec4 a, vec4 b)
dot product of vec4
@@ -123,7 +133,7 @@ Functions documentation
norm * norm (magnitude) of vector
we can use this func instead of calling norm * norm, because it would call
sqrtf fuction twice but with this func we can avoid func call, maybe this is
sqrtf function twice but with this func we can avoid func call, maybe this is
not good name for this func
Parameters:
@@ -283,7 +293,7 @@ Functions documentation
.. c:function:: void glm_vec4_flipsign(vec4 v)
**DEPRACATED!**
**DEPRECATED!**
use :c:func:`glm_vec4_negate`
@@ -292,7 +302,7 @@ Functions documentation
.. c:function:: void glm_vec4_flipsign_to(vec4 v, vec4 dest)
**DEPRACATED!**
**DEPRECATED!**
use :c:func:`glm_vec4_negate_to`
@@ -302,7 +312,7 @@ Functions documentation
.. c:function:: void glm_vec4_inv(vec4 v)
**DEPRACATED!**
**DEPRECATED!**
use :c:func:`glm_vec4_negate`
@@ -311,7 +321,7 @@ Functions documentation
.. c:function:: void glm_vec4_inv_to(vec4 v, vec4 dest)
**DEPRACATED!**
**DEPRECATED!**
use :c:func:`glm_vec4_negate_to`
@@ -406,3 +416,43 @@ Functions documentation
Parameters:
| *[in]* **s** parameter
| *[out]* **dest** destination
.. c:function:: void glm_vec4_make(const float * __restrict src, vec4 dest)
Create four dimensional vector from pointer
.. note:: **@src** must contain at least 4 elements.
Parameters:
| *[in]* **src** pointer to an array of floats
| *[out]* **dest** destination vector
.. c:function:: bool glm_vec4_reflect(vec4 v, vec4 n, vec4 dest)
Reflection vector using an incident ray and a surface normal
Parameters:
| *[in]* **v** incident vector
| *[in]* **n** *❗️ normalized ❗️* normal vector
| *[out]* **dest** destination: reflection result
.. c:function:: bool glm_vec4_refract(vec4 v, vec4 n, float eta, vec4 dest)
computes refraction vector for an incident vector and a surface normal.
Calculates the refraction vector based on Snell's law. If total internal reflection
occurs (angle too great given eta), dest is set to zero and returns false.
Otherwise, computes refraction vector, stores it in dest, and returns true.
This implementation does not explicitly preserve the 'w' component of the
incident vector 'I' in the output 'dest', users requiring the preservation of
the 'w' component should manually adjust 'dest' after calling this function.
Parameters:
| *[in]* **v** *❗️ normalized ❗️* incident vector
| *[in]* **n** *❗️ normalized ❗️* normal vector
| *[in]* **eta** ratio of indices of refraction (incident/transmitted)
| *[out]* **dest** refraction vector if refraction occurs; zero vector otherwise
Returns:
returns true if refraction occurs; false if total internal reflection occurs.

15
docs/source/version.rst Normal file
View File

@@ -0,0 +1,15 @@
.. default-domain:: C
version
================================================================================
Header: cglm/version.h
**cglm** uses semantic versioning (http://semver.org) which is MAJOR.MINOR.PATCH
| **CGLM_VERSION_MAJOR** is major number of the version.
| **CGLM_VERSION_MINOR** is minor number of the version.
| **CGLM_VERSION_PATCH** is patch number of the version.
every release increases these numbers. You can check existing version by
including `cglm/version.h`

270
include/cglm/aabb2d.h Normal file
View File

@@ -0,0 +1,270 @@
/*
* Copyright (c), Recep Aslantas.
*
* MIT License (MIT), http://opensource.org/licenses/MIT
* Full license can be found in the LICENSE file
*/
#ifndef cglm_aabb2d_h
#define cglm_aabb2d_h
#include "common.h"
#include "vec2.h"
#include "util.h"
/* DEPRECATED! use _diag */
#define glm_aabb2d_size(aabb) glm_aabb2d_diag(aabb)
/*!
* @brief make [aabb] zero
*
* @param[in, out] aabb aabb
*/
CGLM_INLINE
void
glm_aabb2d_zero(vec2 aabb[2]) {
glm_vec2_zero(aabb[0]);
glm_vec2_zero(aabb[1]);
}
/*!
* @brief copy all members of [aabb] to [dest]
*
* @param[in] aabb source
* @param[out] dest destination
*/
CGLM_INLINE
void
glm_aabb2d_copy(vec2 aabb[2], vec2 dest[2]) {
glm_vec2_copy(aabb[0], dest[0]);
glm_vec2_copy(aabb[1], dest[1]);
}
/*!
* @brief apply transform to Axis-Aligned Bounding aabb
*
* @param[in] aabb bounding aabb
* @param[in] m transform matrix
* @param[out] dest transformed bounding aabb
*/
CGLM_INLINE
void
glm_aabb2d_transform(vec2 aabb[2], mat3 m, vec2 dest[2]) {
vec2 v[2], xa, xb, ya, yb;
glm_vec2_scale(m[0], aabb[0][0], xa);
glm_vec2_scale(m[0], aabb[1][0], xb);
glm_vec2_scale(m[1], aabb[0][1], ya);
glm_vec2_scale(m[1], aabb[1][1], yb);
/* translation + min(xa, xb) + min(ya, yb) */
glm_vec2(m[2], v[0]);
glm_vec2_minadd(xa, xb, v[0]);
glm_vec2_minadd(ya, yb, v[0]);
/* translation + max(xa, xb) + max(ya, yb) */
glm_vec2(m[2], v[1]);
glm_vec2_maxadd(xa, xb, v[1]);
glm_vec2_maxadd(ya, yb, v[1]);
glm_vec2_copy(v[0], dest[0]);
glm_vec2_copy(v[1], dest[1]);
}
/*!
* @brief merges two AABB bounding aabb and creates new one
*
* two aabb must be in same space, if one of aabb is in different space then
* you should consider to convert it's space by glm_aabb_space
*
* @param[in] aabb1 bounding aabb 1
* @param[in] aabb2 bounding aabb 2
* @param[out] dest merged bounding aabb
*/
CGLM_INLINE
void
glm_aabb2d_merge(vec2 aabb1[2], vec2 aabb2[2], vec2 dest[2]) {
dest[0][0] = glm_min(aabb1[0][0], aabb2[0][0]);
dest[0][1] = glm_min(aabb1[0][1], aabb2[0][1]);
dest[1][0] = glm_max(aabb1[1][0], aabb2[1][0]);
dest[1][1] = glm_max(aabb1[1][1], aabb2[1][1]);
}
/*!
* @brief crops a bounding aabb with another one.
*
* this could be useful for getting a baabb which fits with view frustum and
* object bounding aabbes. In this case you crop view frustum aabb with objects
* aabb
*
* @param[in] aabb bounding aabb 1
* @param[in] cropAabb crop aabb
* @param[out] dest cropped bounding aabb
*/
CGLM_INLINE
void
glm_aabb2d_crop(vec2 aabb[2], vec2 cropAabb[2], vec2 dest[2]) {
dest[0][0] = glm_max(aabb[0][0], cropAabb[0][0]);
dest[0][1] = glm_max(aabb[0][1], cropAabb[0][1]);
dest[1][0] = glm_min(aabb[1][0], cropAabb[1][0]);
dest[1][1] = glm_min(aabb[1][1], cropAabb[1][1]);
}
/*!
* @brief crops a bounding aabb with another one.
*
* this could be useful for getting a baabb which fits with view frustum and
* object bounding aabbes. In this case you crop view frustum aabb with objects
* aabb
*
* @param[in] aabb bounding aabb
* @param[in] cropAabb crop aabb
* @param[in] clampAabb minimum aabb
* @param[out] dest cropped bounding aabb
*/
CGLM_INLINE
void
glm_aabb2d_crop_until(vec2 aabb[2],
vec2 cropAabb[2],
vec2 clampAabb[2],
vec2 dest[2]) {
glm_aabb2d_crop(aabb, cropAabb, dest);
glm_aabb2d_merge(clampAabb, dest, dest);
}
/*!
* @brief invalidate AABB min and max values
*
* @param[in, out] aabb bounding aabb
*/
CGLM_INLINE
void
glm_aabb2d_invalidate(vec2 aabb[2]) {
glm_vec2_fill(aabb[0], FLT_MAX);
glm_vec2_fill(aabb[1], -FLT_MAX);
}
/*!
* @brief check if AABB is valid or not
*
* @param[in] aabb bounding aabb
*/
CGLM_INLINE
bool
glm_aabb2d_isvalid(vec2 aabb[2]) {
return glm_vec2_max(aabb[0]) != FLT_MAX
&& glm_vec2_min(aabb[1]) != -FLT_MAX;
}
/*!
* @brief distance between of min and max
*
* @param[in] aabb bounding aabb
*/
CGLM_INLINE
float
glm_aabb2d_diag(vec2 aabb[2]) {
return glm_vec2_distance(aabb[0], aabb[1]);
}
/*!
* @brief size of aabb
*
* @param[in] aabb bounding aabb
* @param[out] dest size
*/
CGLM_INLINE
void
glm_aabb2d_sizev(vec2 aabb[2], vec2 dest) {
glm_vec2_sub(aabb[1], aabb[0], dest);
}
/*!
* @brief radius of sphere which surrounds AABB
*
* @param[in] aabb bounding aabb
*/
CGLM_INLINE
float
glm_aabb2d_radius(vec2 aabb[2]) {
return glm_aabb2d_diag(aabb) * 0.5f;
}
/*!
* @brief computes center point of AABB
*
* @param[in] aabb bounding aabb
* @param[out] dest center of bounding aabb
*/
CGLM_INLINE
void
glm_aabb2d_center(vec2 aabb[2], vec2 dest) {
glm_vec2_center(aabb[0], aabb[1], dest);
}
/*!
* @brief check if two AABB intersects
*
* @param[in] aabb bounding aabb
* @param[in] other other bounding aabb
*/
CGLM_INLINE
bool
glm_aabb2d_aabb(vec2 aabb[2], vec2 other[2]) {
return (aabb[0][0] <= other[1][0] && aabb[1][0] >= other[0][0])
&& (aabb[0][1] <= other[1][1] && aabb[1][1] >= other[0][1]);
}
/*!
* @brief check if AABB intersects with a circle
*
* Circle Representation in cglm: [center.x, center.y, radii]
*
* @param[in] aabb solid bounding aabb
* @param[in] c solid circle
*/
CGLM_INLINE
bool
glm_aabb2d_circle(vec2 aabb[2], vec3 c) {
float dmin;
int a, b;
a = (c[0] < aabb[0][0]) + (c[0] > aabb[1][0]);
b = (c[1] < aabb[0][1]) + (c[1] > aabb[1][1]);
dmin = glm_pow2((c[0] - aabb[!(a - 1)][0]) * (a != 0))
+ glm_pow2((c[1] - aabb[!(b - 1)][1]) * (b != 0));
return dmin <= glm_pow2(c[2]);
}
/*!
* @brief check if point is inside of AABB
*
* @param[in] aabb bounding aabb
* @param[in] point point
*/
CGLM_INLINE
bool
glm_aabb2d_point(vec2 aabb[2], vec2 point) {
return (point[0] >= aabb[0][0] && point[0] <= aabb[1][0])
&& (point[1] >= aabb[0][1] && point[1] <= aabb[1][1]);
}
/*!
* @brief check if AABB contains other AABB
*
* @param[in] aabb bounding aabb
* @param[in] other other bounding aabb
*/
CGLM_INLINE
bool
glm_aabb2d_contains(vec2 aabb[2], vec2 other[2]) {
return (aabb[0][0] <= other[0][0] && aabb[1][0] >= other[1][0])
&& (aabb[0][1] <= other[0][1] && aabb[1][1] >= other[1][1]);
}
#endif /* cglm_aabb2d_h */

View File

@@ -8,6 +8,7 @@
/*
Functions:
CGLM_INLINE void glm_mul(mat4 m1, mat4 m2, mat4 dest);
CGLM_INLINE void glm_mul_rot(mat4 m1, mat4 m2, mat4 dest);
CGLM_INLINE void glm_inv_tr(mat4 mat);
*/
@@ -26,6 +27,14 @@
# include "simd/avx/affine.h"
#endif
#ifdef CGLM_NEON_FP
# include "simd/neon/affine.h"
#endif
#ifdef CGLM_SIMD_WASM
# include "simd/wasm/affine.h"
#endif
/*!
* @brief this is similar to glm_mat4_mul but specialized to affine transform
*
@@ -45,10 +54,14 @@
CGLM_INLINE
void
glm_mul(mat4 m1, mat4 m2, mat4 dest) {
#ifdef __AVX__
#if defined(__wasm__) && defined(__wasm_simd128__)
glm_mul_wasm(m1, m2, dest);
#elif defined(__AVX__)
glm_mul_avx(m1, m2, dest);
#elif defined( __SSE__ ) || defined( __SSE2__ )
glm_mul_sse2(m1, m2, dest);
#elif defined(CGLM_NEON_FP)
glm_mul_neon(m1, m2, dest);
#else
float a00 = m1[0][0], a01 = m1[0][1], a02 = m1[0][2], a03 = m1[0][3],
a10 = m1[1][0], a11 = m1[1][1], a12 = m1[1][2], a13 = m1[1][3],
@@ -101,8 +114,12 @@ glm_mul(mat4 m1, mat4 m2, mat4 dest) {
CGLM_INLINE
void
glm_mul_rot(mat4 m1, mat4 m2, mat4 dest) {
#if defined( __SSE__ ) || defined( __SSE2__ )
#if defined(__wasm__) && defined(__wasm_simd128__)
glm_mul_rot_wasm(m1, m2, dest);
#elif defined( __SSE__ ) || defined( __SSE2__ )
glm_mul_rot_sse2(m1, m2, dest);
#elif defined(CGLM_NEON_FP)
glm_mul_rot_neon(m1, m2, dest);
#else
float a00 = m1[0][0], a01 = m1[0][1], a02 = m1[0][2], a03 = m1[0][3],
a10 = m1[1][0], a11 = m1[1][1], a12 = m1[1][2], a13 = m1[1][3],
@@ -148,8 +165,12 @@ glm_mul_rot(mat4 m1, mat4 m2, mat4 dest) {
CGLM_INLINE
void
glm_inv_tr(mat4 mat) {
#if defined( __SSE__ ) || defined( __SSE2__ )
#if defined(__wasm__) && defined(__wasm_simd128__)
glm_inv_tr_wasm(mat);
#elif defined( __SSE__ ) || defined( __SSE2__ )
glm_inv_tr_sse2(mat);
#elif defined(CGLM_NEON_FP)
glm_inv_tr_neon(mat);
#else
CGLM_ALIGN_MAT mat3 r;
CGLM_ALIGN(8) vec3 t;

247
include/cglm/affine-post.h Normal file
View File

@@ -0,0 +1,247 @@
/*
* Copyright (c), Recep Aslantas.
*
* MIT License (MIT), http://opensource.org/licenses/MIT
* Full license can be found in the LICENSE file
*/
#ifndef cglm_affine_post_h
#define cglm_affine_post_h
/*
Functions:
CGLM_INLINE void glm_translated_to(mat4 m, vec3 v, mat4 dest);
CGLM_INLINE void glm_translated(mat4 m, vec3 v);
CGLM_INLINE void glm_translated_x(mat4 m, float to);
CGLM_INLINE void glm_translated_y(mat4 m, float to);
CGLM_INLINE void glm_translated_z(mat4 m, float to);
CGLM_INLINE void glm_rotated_x(mat4 m, float angle, mat4 dest);
CGLM_INLINE void glm_rotated_y(mat4 m, float angle, mat4 dest);
CGLM_INLINE void glm_rotated_z(mat4 m, float angle, mat4 dest);
CGLM_INLINE void glm_rotated(mat4 m, float angle, vec3 axis);
CGLM_INLINE void glm_rotated_at(mat4 m, vec3 pivot, float angle, vec3 axis);
CGLM_INLINE void glm_spinned(mat4 m, float angle, vec3 axis);
*/
#include "common.h"
#include "util.h"
#include "vec3.h"
#include "vec4.h"
#include "mat4.h"
#include "affine-mat.h"
/*!
* @brief translate existing transform matrix by v vector
* and stores 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, z]
*/
CGLM_INLINE
void
glm_translated(mat4 m, vec3 v) {
glm_vec3_add(m[3], v, m[3]);
}
/*!
* @brief translate existing transform matrix by v vector
* and store result in dest
*
* source matrix will remain same
*
* this is POST transform, applies to existing transform as last transform
*
* @param[in] m affine transform
* @param[in] v translate vector [x, y, z]
* @param[out] dest translated matrix
*/
CGLM_INLINE
void
glm_translated_to(mat4 m, vec3 v, mat4 dest) {
glm_mat4_copy(m, dest);
glm_translated(dest, v);
}
/*!
* @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_translated_x(mat4 m, float x) {
m[3][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_translated_y(mat4 m, float y) {
m[3][1] += y;
}
/*!
* @brief translate existing transform matrix by z factor
*
* this is POST transform, applies to existing transform as last transform
*
* @param[in, out] m affine transform
* @param[in] z z factor
*/
CGLM_INLINE
void
glm_translated_z(mat4 m, float z) {
m[3][2] += z;
}
/*!
* @brief rotate existing transform matrix around X axis by angle
* and store result in dest
*
* this is POST transform, applies to existing transform as last transform
*
* @param[in] m affine transform
* @param[in] angle angle (radians)
* @param[out] dest rotated matrix
*/
CGLM_INLINE
void
glm_rotated_x(mat4 m, float angle, mat4 dest) {
CGLM_ALIGN_MAT mat4 t = GLM_MAT4_IDENTITY_INIT;
float c, s;
c = cosf(angle);
s = sinf(angle);
t[1][1] = c;
t[1][2] = s;
t[2][1] = -s;
t[2][2] = c;
glm_mul_rot(t, m, dest);
}
/*!
* @brief rotate existing transform matrix around Y axis by angle
* and store result in dest
*
* this is POST transform, applies to existing transform as last transform
*
* @param[in] m affine transform
* @param[in] angle angle (radians)
* @param[out] dest rotated matrix
*/
CGLM_INLINE
void
glm_rotated_y(mat4 m, float angle, mat4 dest) {
CGLM_ALIGN_MAT mat4 t = GLM_MAT4_IDENTITY_INIT;
float c, s;
c = cosf(angle);
s = sinf(angle);
t[0][0] = c;
t[0][2] = -s;
t[2][0] = s;
t[2][2] = c;
glm_mul_rot(t, m, dest);
}
/*!
* @brief rotate existing transform matrix around Z axis by angle
* and store result in dest
*
* this is POST transform, applies to existing transform as last transform
*
* @param[in] m affine transform
* @param[in] angle angle (radians)
* @param[out] dest rotated matrix
*/
CGLM_INLINE
void
glm_rotated_z(mat4 m, float angle, mat4 dest) {
CGLM_ALIGN_MAT mat4 t = GLM_MAT4_IDENTITY_INIT;
float c, s;
c = cosf(angle);
s = sinf(angle);
t[0][0] = c;
t[0][1] = s;
t[1][0] = -s;
t[1][1] = c;
glm_mul_rot(t, m, dest);
}
/*!
* @brief rotate existing transform matrix around given axis by angle
*
* this is POST transform, applies to existing transform as last transform
*
* @param[in, out] m affine transform
* @param[in] angle angle (radians)
* @param[in] axis axis
*/
CGLM_INLINE
void
glm_rotated(mat4 m, float angle, vec3 axis) {
CGLM_ALIGN_MAT mat4 rot;
glm_rotate_make(rot, angle, axis);
glm_mul_rot(rot, m, m);
}
/*!
* @brief rotate existing transform
* around given axis by angle at given pivot point (rotation center)
*
* this is POST transform, applies to existing transform as last transform
*
* @param[in, out] m affine transform
* @param[in] pivot rotation center
* @param[in] angle angle (radians)
* @param[in] axis axis
*/
CGLM_INLINE
void
glm_rotated_at(mat4 m, vec3 pivot, float angle, vec3 axis) {
CGLM_ALIGN(8) vec3 pivotInv;
glm_vec3_negate_to(pivot, pivotInv);
glm_translated(m, pivot);
glm_rotated(m, angle, axis);
glm_translated(m, pivotInv);
}
/*!
* @brief rotate existing transform matrix around given axis by angle around self (doesn't affected by position)
*
* this is POST transform, applies to existing transform as last transform
*
* @param[in, out] m affine transform
* @param[in] angle angle (radians)
* @param[in] axis axis
*/
CGLM_INLINE
void
glm_spinned(mat4 m, float angle, vec3 axis) {
CGLM_ALIGN_MAT mat4 rot;
glm_rotate_atm(rot, m[3], angle, axis);
glm_mat4_mul(rot, m, m);
}
#endif /* cglm_affine_post_h */

304
include/cglm/affine-pre.h Normal file
View File

@@ -0,0 +1,304 @@
/*
* Copyright (c), Recep Aslantas.
*
* MIT License (MIT), http://opensource.org/licenses/MIT
* Full license can be found in the LICENSE file
*/
#ifndef cglm_affine_pre_h
#define cglm_affine_pre_h
/*
Functions:
CGLM_INLINE void glm_translate_to(mat4 m, vec3 v, mat4 dest);
CGLM_INLINE void glm_translate(mat4 m, vec3 v);
CGLM_INLINE void glm_translate_x(mat4 m, float to);
CGLM_INLINE void glm_translate_y(mat4 m, float to);
CGLM_INLINE void glm_translate_z(mat4 m, float to);
CGLM_INLINE void glm_rotate_x(mat4 m, float angle, mat4 dest);
CGLM_INLINE void glm_rotate_y(mat4 m, float angle, mat4 dest);
CGLM_INLINE void glm_rotate_z(mat4 m, float angle, mat4 dest);
CGLM_INLINE void glm_rotate(mat4 m, float angle, vec3 axis);
CGLM_INLINE void glm_rotate_at(mat4 m, vec3 pivot, float angle, vec3 axis);
CGLM_INLINE void glm_rotate_atm(mat4 m, vec3 pivot, float angle, vec3 axis);
CGLM_INLINE void glm_spin(mat4 m, float angle, vec3 axis);
*/
#include "common.h"
#include "util.h"
#include "vec3.h"
#include "vec4.h"
#include "mat4.h"
#include "affine-mat.h"
/*!
* @brief translate existing transform matrix by v vector
* and stores result in same matrix
*
* @param[in, out] m affine transform
* @param[in] v translate vector [x, y, z]
*/
CGLM_INLINE
void
glm_translate(mat4 m, vec3 v) {
#if defined(CGLM_SIMD)
glmm_128 m0, m1, m2, m3;
m0 = glmm_load(m[0]);
m1 = glmm_load(m[1]);
m2 = glmm_load(m[2]);
m3 = glmm_load(m[3]);
glmm_store(m[3],
glmm_fmadd(m0, glmm_set1(v[0]),
glmm_fmadd(m1, glmm_set1(v[1]),
glmm_fmadd(m2, glmm_set1(v[2]), m3))));
#else
glm_vec4_muladds(m[0], v[0], m[3]);
glm_vec4_muladds(m[1], v[1], m[3]);
glm_vec4_muladds(m[2], v[2], m[3]);
#endif
}
/*!
* @brief translate existing transform matrix by v vector
* and store result in dest
*
* source matrix will remain same
*
* @param[in] m affine transform
* @param[in] v translate vector [x, y, z]
* @param[out] dest translated matrix
*/
CGLM_INLINE
void
glm_translate_to(mat4 m, vec3 v, mat4 dest) {
glm_mat4_copy(m, dest);
glm_translate(dest, v);
}
/*!
* @brief translate existing transform matrix by x factor
*
* @param[in, out] m affine transform
* @param[in] x x factor
*/
CGLM_INLINE
void
glm_translate_x(mat4 m, float x) {
#if defined(CGLM_SIMD)
glmm_store(m[3], glmm_fmadd(glmm_load(m[0]), glmm_set1(x), glmm_load(m[3])));
#else
vec4 v1;
glm_vec4_scale(m[0], x, v1);
glm_vec4_add(v1, m[3], m[3]);
#endif
}
/*!
* @brief translate existing transform matrix by y factor
*
* @param[in, out] m affine transform
* @param[in] y y factor
*/
CGLM_INLINE
void
glm_translate_y(mat4 m, float y) {
#if defined(CGLM_SIMD)
glmm_store(m[3], glmm_fmadd(glmm_load(m[1]), glmm_set1(y), glmm_load(m[3])));
#else
vec4 v1;
glm_vec4_scale(m[1], y, v1);
glm_vec4_add(v1, m[3], m[3]);
#endif
}
/*!
* @brief translate existing transform matrix by z factor
*
* @param[in, out] m affine transform
* @param[in] z z factor
*/
CGLM_INLINE
void
glm_translate_z(mat4 m, float z) {
#if defined(CGLM_SIMD)
glmm_store(m[3], glmm_fmadd(glmm_load(m[2]), glmm_set1(z), glmm_load(m[3])));
#else
vec4 v1;
glm_vec4_scale(m[2], z, v1);
glm_vec4_add(v1, m[3], m[3]);
#endif
}
/*!
* @brief rotate existing transform matrix around X axis by angle
* and store result in dest
*
* @param[in] m affine transform
* @param[in] angle angle (radians)
* @param[out] dest rotated matrix
*/
CGLM_INLINE
void
glm_rotate_x(mat4 m, float angle, mat4 dest) {
CGLM_ALIGN_MAT mat4 t = GLM_MAT4_IDENTITY_INIT;
float c, s;
c = cosf(angle);
s = sinf(angle);
t[1][1] = c;
t[1][2] = s;
t[2][1] = -s;
t[2][2] = c;
glm_mul_rot(m, t, dest);
}
/*!
* @brief rotate existing transform matrix around Y axis by angle
* and store result in dest
*
* @param[in] m affine transform
* @param[in] angle angle (radians)
* @param[out] dest rotated matrix
*/
CGLM_INLINE
void
glm_rotate_y(mat4 m, float angle, mat4 dest) {
CGLM_ALIGN_MAT mat4 t = GLM_MAT4_IDENTITY_INIT;
float c, s;
c = cosf(angle);
s = sinf(angle);
t[0][0] = c;
t[0][2] = -s;
t[2][0] = s;
t[2][2] = c;
glm_mul_rot(m, t, dest);
}
/*!
* @brief rotate existing transform matrix around Z axis by angle
* and store result in dest
*
* @param[in] m affine transform
* @param[in] angle angle (radians)
* @param[out] dest rotated matrix
*/
CGLM_INLINE
void
glm_rotate_z(mat4 m, float angle, mat4 dest) {
CGLM_ALIGN_MAT mat4 t = GLM_MAT4_IDENTITY_INIT;
float c, s;
c = cosf(angle);
s = sinf(angle);
t[0][0] = c;
t[0][1] = s;
t[1][0] = -s;
t[1][1] = c;
glm_mul_rot(m, t, dest);
}
/*!
* @brief rotate existing transform matrix
* around given axis by angle at ORIGIN (0,0,0)
*
* **❗IMPORTANT ❗️**
*
* If you need to rotate object around itself e.g. center of object or at
* some point [of object] then `glm_rotate_at()` would be better choice to do so.
*
* Even if object's model transform is identity, rotation may not be around
* center of object if object does not lay out at ORIGIN perfectly.
*
* Using `glm_rotate_at()` with center of bounding shape ( AABB, Sphere ... )
* would be an easy option to rotate around object if object is not at origin.
*
* One another option to rotate around itself at any point is `glm_spin()`
* which is perfect if only rotating around model position is desired e.g. not
* specific point on model for instance center of geometry or center of mass,
* again if geometry is not perfectly centered at origin at identity transform,
* rotation may not be around geometry.
*
* @param[in, out] m affine transform
* @param[in] angle angle (radians)
* @param[in] axis axis
*/
CGLM_INLINE
void
glm_rotate(mat4 m, float angle, vec3 axis) {
CGLM_ALIGN_MAT mat4 rot;
glm_rotate_make(rot, angle, axis);
glm_mul_rot(m, rot, m);
}
/*!
* @brief rotate existing transform
* around given axis by angle at given pivot point (rotation center)
*
* @param[in, out] m affine transform
* @param[in] pivot rotation center
* @param[in] angle angle (radians)
* @param[in] axis axis
*/
CGLM_INLINE
void
glm_rotate_at(mat4 m, vec3 pivot, float angle, vec3 axis) {
CGLM_ALIGN(8) vec3 pivotInv;
glm_vec3_negate_to(pivot, pivotInv);
glm_translate(m, pivot);
glm_rotate(m, angle, axis);
glm_translate(m, pivotInv);
}
/*!
* @brief creates NEW rotation matrix by angle and axis at given point
*
* this creates rotation matrix, it assumes you don't have a matrix
*
* this should work faster than glm_rotate_at because it reduces
* one glm_translate.
*
* @param[out] m affine transform
* @param[in] pivot rotation center
* @param[in] angle angle (radians)
* @param[in] axis axis
*/
CGLM_INLINE
void
glm_rotate_atm(mat4 m, vec3 pivot, float angle, vec3 axis) {
CGLM_ALIGN(8) vec3 pivotInv;
glm_vec3_negate_to(pivot, pivotInv);
glm_translate_make(m, pivot);
glm_rotate(m, angle, axis);
glm_translate(m, pivotInv);
}
/*!
* @brief rotate existing transform matrix
* around given axis by angle around self (doesn't affected by position)
*
* @param[in, out] m affine transform
* @param[in] angle angle (radians)
* @param[in] axis axis
*/
CGLM_INLINE
void
glm_spin(mat4 m, float angle, vec3 axis) {
CGLM_ALIGN_MAT mat4 rot;
glm_rotate_atm(rot, m[3], angle, axis);
glm_mat4_mul(m, rot, m);
}
#endif /* cglm_affine_pre_h */

View File

@@ -24,6 +24,7 @@
CGLM_INLINE void glm_rotate(mat4 m, float angle, vec3 axis);
CGLM_INLINE void glm_rotate_at(mat4 m, vec3 pivot, float angle, vec3 axis);
CGLM_INLINE void glm_rotate_atm(mat4 m, vec3 pivot, float angle, vec3 axis);
CGLM_INLINE void glm_spin(mat4 m, float angle, vec3 axis);
CGLM_INLINE void glm_decompose_scalev(mat4 m, vec3 s);
CGLM_INLINE bool glm_uniscaled(mat4 m);
CGLM_INLINE void glm_decompose_rs(mat4 m, mat4 r, vec3 s);
@@ -40,130 +41,10 @@
#include "mat4.h"
#include "affine-mat.h"
CGLM_INLINE
void
glm_mat4_mul(mat4 m1, mat4 m2, mat4 dest);
/*!
* @brief translate existing transform matrix by v vector
* and stores result in same matrix
*
* @param[in, out] m affine transfrom
* @param[in] v translate vector [x, y, z]
*/
CGLM_INLINE
void
glm_translate(mat4 m, vec3 v) {
#if defined( __SSE__ ) || defined( __SSE2__ )
glmm_store(m[3],
_mm_add_ps(_mm_add_ps(_mm_mul_ps(glmm_load(m[0]),
_mm_set1_ps(v[0])),
_mm_mul_ps(glmm_load(m[1]),
_mm_set1_ps(v[1]))),
_mm_add_ps(_mm_mul_ps(glmm_load(m[2]),
_mm_set1_ps(v[2])),
glmm_load(m[3]))))
;
#else
vec4 v1, v2, v3;
glm_vec4_scale(m[0], v[0], v1);
glm_vec4_scale(m[1], v[1], v2);
glm_vec4_scale(m[2], v[2], v3);
glm_vec4_add(v1, m[3], m[3]);
glm_vec4_add(v2, m[3], m[3]);
glm_vec4_add(v3, m[3], m[3]);
#endif
}
/*!
* @brief translate existing transform matrix by v vector
* and store result in dest
*
* source matrix will remain same
*
* @param[in] m affine transfrom
* @param[in] v translate vector [x, y, z]
* @param[out] dest translated matrix
*/
CGLM_INLINE
void
glm_translate_to(mat4 m, vec3 v, mat4 dest) {
glm_mat4_copy(m, dest);
glm_translate(dest, v);
}
/*!
* @brief translate existing transform matrix by x factor
*
* @param[in, out] m affine transfrom
* @param[in] x x factor
*/
CGLM_INLINE
void
glm_translate_x(mat4 m, float x) {
#if defined( __SSE__ ) || defined( __SSE2__ )
glmm_store(m[3],
_mm_add_ps(_mm_mul_ps(glmm_load(m[0]),
_mm_set1_ps(x)),
glmm_load(m[3])))
;
#else
vec4 v1;
glm_vec4_scale(m[0], x, v1);
glm_vec4_add(v1, m[3], m[3]);
#endif
}
/*!
* @brief translate existing transform matrix by y factor
*
* @param[in, out] m affine transfrom
* @param[in] y y factor
*/
CGLM_INLINE
void
glm_translate_y(mat4 m, float y) {
#if defined( __SSE__ ) || defined( __SSE2__ )
glmm_store(m[3],
_mm_add_ps(_mm_mul_ps(glmm_load(m[1]),
_mm_set1_ps(y)),
glmm_load(m[3])))
;
#else
vec4 v1;
glm_vec4_scale(m[1], y, v1);
glm_vec4_add(v1, m[3], m[3]);
#endif
}
/*!
* @brief translate existing transform matrix by z factor
*
* @param[in, out] m affine transfrom
* @param[in] z z factor
*/
CGLM_INLINE
void
glm_translate_z(mat4 m, float z) {
#if defined( __SSE__ ) || defined( __SSE2__ )
glmm_store(m[3],
_mm_add_ps(_mm_mul_ps(glmm_load(m[2]),
_mm_set1_ps(z)),
glmm_load(m[3])))
;
#else
vec4 v1;
glm_vec4_scale(m[2], z, v1);
glm_vec4_add(v1, m[3], m[3]);
#endif
}
/*!
* @brief creates NEW translate transform matrix by v vector
*
* @param[out] m affine transfrom
* @param[out] m affine transform
* @param[in] v translate vector [x, y, z]
*/
CGLM_INLINE
@@ -177,7 +58,7 @@ glm_translate_make(mat4 m, vec3 v) {
* @brief scale existing transform matrix by v vector
* and store result in dest
*
* @param[in] m affine transfrom
* @param[in] m affine transform
* @param[in] v scale vector [x, y, z]
* @param[out] dest scaled matrix
*/
@@ -194,7 +75,7 @@ glm_scale_to(mat4 m, vec3 v, mat4 dest) {
/*!
* @brief creates NEW scale matrix by v vector
*
* @param[out] m affine transfrom
* @param[out] m affine transform
* @param[in] v scale vector [x, y, z]
*/
CGLM_INLINE
@@ -210,7 +91,7 @@ glm_scale_make(mat4 m, vec3 v) {
* @brief scales existing transform matrix by v vector
* and stores result in same matrix
*
* @param[in, out] m affine transfrom
* @param[in, out] m affine transform
* @param[in] v scale vector [x, y, z]
*/
CGLM_INLINE
@@ -223,7 +104,7 @@ glm_scale(mat4 m, vec3 v) {
* @brief applies uniform scale to existing transform matrix v = [s, s, s]
* and stores result in same matrix
*
* @param[in, out] m affine transfrom
* @param[in, out] m affine transform
* @param[in] s scale factor
*/
CGLM_INLINE
@@ -233,87 +114,12 @@ glm_scale_uni(mat4 m, float s) {
glm_scale_to(m, v, m);
}
/*!
* @brief rotate existing transform matrix around X axis by angle
* and store result in dest
*
* @param[in] m affine transfrom
* @param[in] angle angle (radians)
* @param[out] dest rotated matrix
*/
CGLM_INLINE
void
glm_rotate_x(mat4 m, float angle, mat4 dest) {
CGLM_ALIGN_MAT mat4 t = GLM_MAT4_IDENTITY_INIT;
float c, s;
c = cosf(angle);
s = sinf(angle);
t[1][1] = c;
t[1][2] = s;
t[2][1] = -s;
t[2][2] = c;
glm_mul_rot(m, t, dest);
}
/*!
* @brief rotate existing transform matrix around Y axis by angle
* and store result in dest
*
* @param[in] m affine transfrom
* @param[in] angle angle (radians)
* @param[out] dest rotated matrix
*/
CGLM_INLINE
void
glm_rotate_y(mat4 m, float angle, mat4 dest) {
CGLM_ALIGN_MAT mat4 t = GLM_MAT4_IDENTITY_INIT;
float c, s;
c = cosf(angle);
s = sinf(angle);
t[0][0] = c;
t[0][2] = -s;
t[2][0] = s;
t[2][2] = c;
glm_mul_rot(m, t, dest);
}
/*!
* @brief rotate existing transform matrix around Z axis by angle
* and store result in dest
*
* @param[in] m affine transfrom
* @param[in] angle angle (radians)
* @param[out] dest rotated matrix
*/
CGLM_INLINE
void
glm_rotate_z(mat4 m, float angle, mat4 dest) {
CGLM_ALIGN_MAT mat4 t = GLM_MAT4_IDENTITY_INIT;
float c, s;
c = cosf(angle);
s = sinf(angle);
t[0][0] = c;
t[0][1] = s;
t[1][0] = -s;
t[1][1] = c;
glm_mul_rot(m, t, dest);
}
/*!
* @brief creates NEW rotation matrix by angle and axis
*
* axis will be normalized so you don't need to normalize it
*
* @param[out] m affine transfrom
* @param[out] m affine transform
* @param[in] angle angle (radians)
* @param[in] axis axis
*/
@@ -341,67 +147,6 @@ glm_rotate_make(mat4 m, float angle, vec3 axis) {
m[3][3] = 1.0f;
}
/*!
* @brief rotate existing transform matrix around given axis by angle
*
* @param[in, out] m affine transfrom
* @param[in] angle angle (radians)
* @param[in] axis axis
*/
CGLM_INLINE
void
glm_rotate(mat4 m, float angle, vec3 axis) {
CGLM_ALIGN_MAT mat4 rot;
glm_rotate_make(rot, angle, axis);
glm_mul_rot(m, rot, m);
}
/*!
* @brief rotate existing transform
* around given axis by angle at given pivot point (rotation center)
*
* @param[in, out] m affine transfrom
* @param[in] pivot rotation center
* @param[in] angle angle (radians)
* @param[in] axis axis
*/
CGLM_INLINE
void
glm_rotate_at(mat4 m, vec3 pivot, float angle, vec3 axis) {
CGLM_ALIGN(8) vec3 pivotInv;
glm_vec3_negate_to(pivot, pivotInv);
glm_translate(m, pivot);
glm_rotate(m, angle, axis);
glm_translate(m, pivotInv);
}
/*!
* @brief creates NEW rotation matrix by angle and axis at given point
*
* this creates rotation matrix, it assumes you don't have a matrix
*
* this should work faster than glm_rotate_at because it reduces
* one glm_translate.
*
* @param[out] m affine transfrom
* @param[in] pivot rotation center
* @param[in] angle angle (radians)
* @param[in] axis axis
*/
CGLM_INLINE
void
glm_rotate_atm(mat4 m, vec3 pivot, float angle, vec3 axis) {
CGLM_ALIGN(8) vec3 pivotInv;
glm_vec3_negate_to(pivot, pivotInv);
glm_translate_make(m, pivot);
glm_rotate(m, angle, axis);
glm_translate(m, pivotInv);
}
/*!
* @brief decompose scale vector
*
@@ -459,7 +204,7 @@ glm_decompose_rs(mat4 m, mat4 r, vec3 s) {
glm_vec4_scale(r[1], 1.0f/s[1], r[1]);
glm_vec4_scale(r[2], 1.0f/s[2], r[2]);
/* Note from Apple Open Source (asume that the matrix is orthonormal):
/* Note from Apple Open Source (assume that the matrix is orthonormal):
check for a coordinate system flip. If the determinant
is -1, then negate the matrix and the scaling factors. */
glm_vec3_cross(m[0], m[1], v);
@@ -475,7 +220,7 @@ glm_decompose_rs(mat4 m, mat4 r, vec3 s) {
* @brief decompose affine transform, TODO: extract shear factors.
* DON'T pass projected matrix here
*
* @param[in] m affine transfrom
* @param[in] m affine transform
* @param[out] t translation vector
* @param[out] r rotation matrix (mat4)
* @param[out] s scaling vector [X, Y, Z]
@@ -487,4 +232,7 @@ glm_decompose(mat4 m, vec4 t, mat4 r, vec3 s) {
glm_decompose_rs(m, r, s);
}
#include "affine-pre.h"
#include "affine-post.h"
#endif /* cglm_affine_h */

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

268
include/cglm/affine2d.h Normal file
View File

@@ -0,0 +1,268 @@
/*
* Copyright (c), Recep Aslantas.
*
* MIT License (MIT), http://opensource.org/licenses/MIT
* Full license can be found in the LICENSE file
*/
/*
Functions:
CGLM_INLINE void glm_translate2d(mat3 m, vec2 v)
CGLM_INLINE void glm_translate2d_to(mat3 m, vec2 v, mat3 dest)
CGLM_INLINE void glm_translate2d_x(mat3 m, float x)
CGLM_INLINE void glm_translate2d_y(mat3 m, float y)
CGLM_INLINE void glm_translate2d_make(mat3 m, vec2 v)
CGLM_INLINE void glm_scale2d_to(mat3 m, vec2 v, mat3 dest)
CGLM_INLINE void glm_scale2d_make(mat3 m, vec2 v)
CGLM_INLINE void glm_scale2d(mat3 m, vec2 v)
CGLM_INLINE void glm_scale2d_uni(mat3 m, float s)
CGLM_INLINE void glm_rotate2d_make(mat3 m, float angle)
CGLM_INLINE void glm_rotate2d(mat3 m, float angle)
CGLM_INLINE void glm_rotate2d_to(mat3 m, float angle, mat3 dest)
*/
#ifndef cglm_affine2d_h
#define cglm_affine2d_h
#include "common.h"
#include "util.h"
#include "vec2.h"
#include "mat3.h"
/*!
* @brief translate existing 2d transform matrix by v vector
* and stores result in same matrix
*
* @param[in, out] m affine transform
* @param[in] v translate vector [x, y]
*/
CGLM_INLINE
void
glm_translate2d(mat3 m, vec2 v) {
m[2][0] = m[0][0] * v[0] + m[1][0] * v[1] + m[2][0];
m[2][1] = m[0][1] * v[0] + m[1][1] * v[1] + m[2][1];
m[2][2] = m[0][2] * v[0] + m[1][2] * v[1] + m[2][2];
}
/*!
* @brief translate existing 2d transform matrix by v vector
* and store result in dest
*
* source matrix will remain same
*
* @param[in] m affine transform
* @param[in] v translate vector [x, y]
* @param[out] dest translated matrix
*/
CGLM_INLINE
void
glm_translate2d_to(mat3 m, vec2 v, mat3 dest) {
glm_mat3_copy(m, dest);
glm_translate2d(dest, v);
}
/*!
* @brief translate existing 2d transform matrix by x factor
*
* @param[in, out] m affine transform
* @param[in] x x factor
*/
CGLM_INLINE
void
glm_translate2d_x(mat3 m, float x) {
m[2][0] = m[0][0] * x + m[2][0];
m[2][1] = m[0][1] * x + m[2][1];
m[2][2] = m[0][2] * x + m[2][2];
}
/*!
* @brief translate existing 2d transform matrix by y factor
*
* @param[in, out] m affine transform
* @param[in] y y factor
*/
CGLM_INLINE
void
glm_translate2d_y(mat3 m, float y) {
m[2][0] = m[1][0] * y + m[2][0];
m[2][1] = m[1][1] * y + m[2][1];
m[2][2] = m[1][2] * y + m[2][2];
}
/*!
* @brief creates NEW translate 2d transform matrix by v vector
*
* @param[out] m affine transform
* @param[in] v translate vector [x, y]
*/
CGLM_INLINE
void
glm_translate2d_make(mat3 m, vec2 v) {
glm_mat3_identity(m);
m[2][0] = v[0];
m[2][1] = v[1];
}
/*!
* @brief scale existing 2d transform matrix by v vector
* and store result in dest
*
* @param[in] m affine transform
* @param[in] v scale vector [x, y]
* @param[out] dest scaled matrix
*/
CGLM_INLINE
void
glm_scale2d_to(mat3 m, vec2 v, mat3 dest) {
dest[0][0] = m[0][0] * v[0];
dest[0][1] = m[0][1] * v[0];
dest[0][2] = m[0][2] * v[0];
dest[1][0] = m[1][0] * v[1];
dest[1][1] = m[1][1] * v[1];
dest[1][2] = m[1][2] * v[1];
dest[2][0] = m[2][0];
dest[2][1] = m[2][1];
dest[2][2] = m[2][2];
}
/*!
* @brief creates NEW 2d scale matrix by v vector
*
* @param[out] m affine transform
* @param[in] v scale vector [x, y]
*/
CGLM_INLINE
void
glm_scale2d_make(mat3 m, vec2 v) {
glm_mat3_identity(m);
m[0][0] = v[0];
m[1][1] = v[1];
}
/*!
* @brief scales existing 2d transform matrix by v vector
* and stores result in same matrix
*
* @param[in, out] m affine transform
* @param[in] v scale vector [x, y]
*/
CGLM_INLINE
void
glm_scale2d(mat3 m, vec2 v) {
m[0][0] = m[0][0] * v[0];
m[0][1] = m[0][1] * v[0];
m[0][2] = m[0][2] * v[0];
m[1][0] = m[1][0] * v[1];
m[1][1] = m[1][1] * v[1];
m[1][2] = m[1][2] * v[1];
}
/*!
* @brief applies uniform scale to existing 2d transform matrix v = [s, s]
* and stores result in same matrix
*
* @param[in, out] m affine transform
* @param[in] s scale factor
*/
CGLM_INLINE
void
glm_scale2d_uni(mat3 m, float s) {
m[0][0] = m[0][0] * s;
m[0][1] = m[0][1] * s;
m[0][2] = m[0][2] * s;
m[1][0] = m[1][0] * s;
m[1][1] = m[1][1] * s;
m[1][2] = m[1][2] * s;
}
/*!
* @brief creates NEW rotation matrix by angle around Z axis
*
* @param[out] m affine transform
* @param[in] angle angle (radians)
*/
CGLM_INLINE
void
glm_rotate2d_make(mat3 m, float angle) {
float c, s;
s = sinf(angle);
c = cosf(angle);
m[0][0] = c;
m[0][1] = s;
m[0][2] = 0;
m[1][0] = -s;
m[1][1] = c;
m[1][2] = 0;
m[2][0] = 0.0f;
m[2][1] = 0.0f;
m[2][2] = 1.0f;
}
/*!
* @brief rotate existing 2d transform matrix around Z axis by angle
* and store result in same matrix
*
* @param[in, out] m affine transform
* @param[in] angle angle (radians)
*/
CGLM_INLINE
void
glm_rotate2d(mat3 m, float angle) {
float m00 = m[0][0], m10 = m[1][0],
m01 = m[0][1], m11 = m[1][1],
m02 = m[0][2], m12 = m[1][2];
float c, s;
s = sinf(angle);
c = cosf(angle);
m[0][0] = m00 * c + m10 * s;
m[0][1] = m01 * c + m11 * s;
m[0][2] = m02 * c + m12 * s;
m[1][0] = m00 * -s + m10 * c;
m[1][1] = m01 * -s + m11 * c;
m[1][2] = m02 * -s + m12 * c;
}
/*!
* @brief rotate existing 2d transform matrix around Z axis by angle
* and store result in dest
*
* @param[in] m affine transform
* @param[in] angle angle (radians)
* @param[out] dest destination
*/
CGLM_INLINE
void
glm_rotate2d_to(mat3 m, float angle, mat3 dest) {
float m00 = m[0][0], m10 = m[1][0],
m01 = m[0][1], m11 = m[1][1],
m02 = m[0][2], m12 = m[1][2];
float c, s;
s = sinf(angle);
c = cosf(angle);
dest[0][0] = m00 * c + m10 * s;
dest[0][1] = m01 * c + m11 * s;
dest[0][2] = m02 * c + m12 * s;
dest[1][0] = m00 * -s + m10 * c;
dest[1][1] = m01 * -s + m11 * c;
dest[1][2] = m02 * -s + m12 * c;
dest[2][0] = m[2][0];
dest[2][1] = m[2][1];
dest[2][2] = m[2][2];
}
#endif /* cglm_affine2d_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

@@ -23,7 +23,7 @@
#define GLM_HERMITE_MAT ((mat4)GLM_HERMITE_MAT_INIT)
#define CGLM_DECASTEL_EPS 1e-9f
#define CGLM_DECASTEL_MAX 1000.0f
#define CGLM_DECASTEL_MAX 1000
#define CGLM_DECASTEL_SMALL 1e-20f
/*!

View File

@@ -75,7 +75,7 @@ glm_aabb_merge(vec3 box1[2], vec3 box2[2], vec3 dest[2]) {
/*!
* @brief crops a bounding box with another one.
*
* this could be useful for gettng a bbox which fits with view frustum and
* this could be useful for getting a bbox which fits with view frustum and
* object bounding boxes. In this case you crop view frustum box with objects
* box
*
@@ -98,13 +98,13 @@ glm_aabb_crop(vec3 box[2], vec3 cropBox[2], vec3 dest[2]) {
/*!
* @brief crops a bounding box with another one.
*
* this could be useful for gettng a bbox which fits with view frustum and
* this could be useful for getting a bbox which fits with view frustum and
* object bounding boxes. In this case you crop view frustum box with objects
* box
*
* @param[in] box bounding box
* @param[in] cropBox crop box
* @param[in] clampBox miniumum box
* @param[in] clampBox minimum box
* @param[out] dest cropped bounding box
*/
CGLM_INLINE
@@ -228,6 +228,8 @@ glm_aabb_aabb(vec3 box[2], vec3 other[2]) {
* https://github.com/erich666/GraphicsGems/blob/master/gems/BoxSphere.c
* Solid Box - Solid Sphere test.
*
* Sphere Representation in cglm: [center.x, center.y, center.z, radii]
*
* @param[in] box solid bounding box
* @param[in] s solid sphere
*/
@@ -237,13 +239,13 @@ glm_aabb_sphere(vec3 box[2], vec4 s) {
float dmin;
int a, b, c;
a = s[0] >= box[0][0];
b = s[1] >= box[0][1];
c = s[2] >= box[0][2];
a = (s[0] < box[0][0]) + (s[0] > box[1][0]);
b = (s[1] < box[0][1]) + (s[1] > box[1][1]);
c = (s[2] < box[0][2]) + (s[2] > box[1][2]);
dmin = glm_pow2(s[0] - box[a][0])
+ glm_pow2(s[1] - box[b][1])
+ glm_pow2(s[2] - box[c][2]);
dmin = glm_pow2((s[0] - box[!(a - 1)][0]) * (a != 0))
+ glm_pow2((s[1] - box[!(b - 1)][1]) * (b != 0))
+ glm_pow2((s[2] - box[!(c - 1)][2]) * (c != 0));
return dmin <= glm_pow2(s[3]);
}

View File

@@ -12,16 +12,29 @@ extern "C" {
#endif
#include "cglm.h"
#include "call/vec2.h"
#include "call/vec3.h"
#include "call/vec4.h"
#include "call/mat4.h"
#include "call/ivec2.h"
#include "call/ivec3.h"
#include "call/ivec4.h"
#include "call/mat2.h"
#include "call/mat2x3.h"
#include "call/mat2x4.h"
#include "call/mat3.h"
#include "call/mat3x2.h"
#include "call/mat3x4.h"
#include "call/mat4.h"
#include "call/mat4x2.h"
#include "call/mat4x3.h"
#include "call/affine.h"
#include "call/cam.h"
#include "call/quat.h"
#include "call/euler.h"
#include "call/plane.h"
#include "call/noise.h"
#include "call/frustum.h"
#include "call/aabb2d.h"
#include "call/box.h"
#include "call/io.h"
#include "call/project.h"
@@ -29,6 +42,8 @@ extern "C" {
#include "call/ease.h"
#include "call/curve.h"
#include "call/bezier.h"
#include "call/ray.h"
#include "call/affine2d.h"
#ifdef __cplusplus
}

View File

@@ -0,0 +1,89 @@
/*
* Copyright (c), Recep Aslantas.
*
* MIT License (MIT), http://opensource.org/licenses/MIT
* Full license can be found in the LICENSE file
*/
#ifndef cglmc_aabb2d_h
#define cglmc_aabb2d_h
#ifdef __cplusplus
extern "C" {
#endif
#include "../cglm.h"
/* DEPRECATED! use _diag */
#define glmc_aabb2d_size(aabb) glmc_aabb2d_diag(aabb)
CGLM_EXPORT
void
glmc_aabb2d_zero(vec2 aabb[2]);
CGLM_EXPORT
void
glmc_aabb2d_copy(vec2 aabb[2], vec2 dest[2]);
CGLM_EXPORT
void
glmc_aabb2d_transform(vec2 aabb[2], mat3 m, vec2 dest[2]);
CGLM_EXPORT
void
glmc_aabb2d_merge(vec2 aabb1[2], vec2 aabb2[2], vec2 dest[2]);
CGLM_EXPORT
void
glmc_aabb2d_crop(vec2 aabb[2], vec2 cropAabb[2], vec2 dest[2]);
CGLM_EXPORT
void
glmc_aabb2d_crop_until(vec2 aabb[2],
vec2 cropAabb[2],
vec2 clampAabb[2],
vec2 dest[2]);
CGLM_EXPORT
void
glmc_aabb2d_invalidate(vec2 aabb[2]);
CGLM_EXPORT
bool
glmc_aabb2d_isvalid(vec2 aabb[2]);
CGLM_EXPORT
float
glmc_aabb2d_diag(vec2 aabb[2]);
CGLM_EXPORT
void
glmc_aabb2d_sizev(vec2 aabb[2], vec2 dest);
CGLM_EXPORT
float
glmc_aabb2d_radius(vec2 aabb[2]);
CGLM_EXPORT
void
glmc_aabb2d_center(vec2 aabb[2], vec2 dest);
CGLM_EXPORT
bool
glmc_aabb2d_aabb(vec2 aabb[2], vec2 other[2]);
CGLM_EXPORT
bool
glmc_aabb2d_point(vec2 aabb[2], vec2 point);
CGLM_EXPORT
bool
glmc_aabb2d_contains(vec2 aabb[2], vec2 other[2]);
CGLM_EXPORT
bool
glmc_aabb2d_circle(vec2 aabb[2], vec3 s);
#ifdef __cplusplus
}
#endif
#endif /* cglmc_aabb2d_h */

View File

@@ -81,6 +81,10 @@ CGLM_EXPORT
void
glmc_rotate_atm(mat4 m, vec3 pivot, float angle, vec3 axis);
CGLM_EXPORT
void
glmc_spin(mat4 m, float angle, vec3 axis);
CGLM_EXPORT
void
glmc_decompose_scalev(mat4 m, vec3 s);
@@ -97,6 +101,52 @@ CGLM_EXPORT
void
glmc_decompose(mat4 m, vec4 t, mat4 r, vec3 s);
/* affine-post */
CGLM_EXPORT
void
glmc_translated(mat4 m, vec3 v);
CGLM_EXPORT
void
glmc_translated_to(mat4 m, vec3 v, mat4 dest);
CGLM_EXPORT
void
glmc_translated_x(mat4 m, float x);
CGLM_EXPORT
void
glmc_translated_y(mat4 m, float y);
CGLM_EXPORT
void
glmc_translated_z(mat4 m, float z);
CGLM_EXPORT
void
glmc_rotated_x(mat4 m, float angle, mat4 dest);
CGLM_EXPORT
void
glmc_rotated_y(mat4 m, float angle, mat4 dest);
CGLM_EXPORT
void
glmc_rotated_z(mat4 m, float angle, mat4 dest);
CGLM_EXPORT
void
glmc_rotated(mat4 m, float angle, vec3 axis);
CGLM_EXPORT
void
glmc_rotated_at(mat4 m, vec3 pivot, float angle, vec3 axis);
CGLM_EXPORT
void
glmc_spinned(mat4 m, float angle, vec3 axis);
/* affine-mat */
CGLM_EXPORT

View File

@@ -0,0 +1,67 @@
/*
* Copyright (c), Recep Aslantas.
*
* MIT License (MIT), http://opensource.org/licenses/MIT
* Full license can be found in the LICENSE file
*/
#ifndef cglmc_affine2d_h
#define cglmc_affine2d_h
#ifdef __cplusplus
extern "C" {
#endif
#include "../cglm.h"
CGLM_EXPORT
void
glmc_translate2d_make(mat3 m, vec2 v);
CGLM_EXPORT
void
glmc_translate2d_to(mat3 m, vec2 v, mat3 dest);
CGLM_EXPORT
void
glmc_translate2d(mat3 m, vec2 v);
CGLM_EXPORT
void
glmc_translate2d_x(mat3 m, float to);
CGLM_EXPORT
void
glmc_translate2d_y(mat3 m, float to);
CGLM_EXPORT
void
glmc_scale2d_to(mat3 m, vec2 v, mat3 dest);
CGLM_EXPORT
void
glmc_scale2d_make(mat3 m, vec2 v);
CGLM_EXPORT
void
glmc_scale2d(mat3 m, vec2 v);
CGLM_EXPORT
void
glmc_scale2d_uni(mat3 m, float s);
CGLM_EXPORT
void
glmc_rotate2d_make(mat3 m, float angle);
CGLM_EXPORT
void
glmc_rotate2d(mat3 m, float angle);
CGLM_EXPORT
void
glmc_rotate2d_to(mat3 m, float angle, mat3 dest);
#ifdef __cplusplus
}
#endif
#endif /* cglmc_affine2d_h */

View File

@@ -76,4 +76,3 @@ glmc_aabb_sphere(vec3 box[2], vec4 s);
}
#endif
#endif /* cglmc_box_h */

View File

@@ -15,23 +15,17 @@ extern "C" {
CGLM_EXPORT
void
glmc_frustum(float left,
float right,
float bottom,
float top,
float nearVal,
float farVal,
mat4 dest);
glmc_frustum(float left, float right,
float bottom, float top,
float nearZ, float farZ,
mat4 dest);
CGLM_EXPORT
void
glmc_ortho(float left,
float right,
float bottom,
float top,
float nearVal,
float farVal,
mat4 dest);
glmc_ortho(float left, float right,
float bottom, float top,
float nearZ, float farZ,
mat4 dest);
CGLM_EXPORT
void
@@ -55,11 +49,11 @@ glmc_ortho_default_s(float aspect, float size, mat4 dest);
CGLM_EXPORT
void
glmc_perspective(float fovy,
float aspect,
float nearVal,
float farVal,
mat4 dest);
glmc_perspective(float fovy, float aspect, float nearZ, float farZ, mat4 dest);
CGLM_EXPORT
void
glmc_perspective_infinite(float fovy, float aspect, float nearZ, mat4 dest);
CGLM_EXPORT
void
@@ -69,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);
@@ -88,8 +86,8 @@ glmc_look_anyup(vec3 eye, vec3 dir, mat4 dest);
CGLM_EXPORT
void
glmc_persp_decomp(mat4 proj,
float * __restrict nearVal,
float * __restrict farVal,
float * __restrict nearZ,
float * __restrict farZ,
float * __restrict top,
float * __restrict bottom,
float * __restrict left,
@@ -114,16 +112,16 @@ glmc_persp_decomp_y(mat4 proj,
CGLM_EXPORT
void
glmc_persp_decomp_z(mat4 proj,
float * __restrict nearVal,
float * __restrict farVal);
float * __restrict nearZ,
float * __restrict farZ);
CGLM_EXPORT
void
glmc_persp_decomp_far(mat4 proj, float * __restrict farVal);
glmc_persp_decomp_far(mat4 proj, float * __restrict farZ);
CGLM_EXPORT
void
glmc_persp_decomp_near(mat4 proj, float * __restrict nearVal);
glmc_persp_decomp_near(mat4 proj, float * __restrict nearZ);
CGLM_EXPORT
float

View File

@@ -0,0 +1,46 @@
/*
* Copyright (c), Recep Aslantas.
*
* MIT License (MIT), http://opensource.org/licenses/MIT
* Full license can be found in the LICENSE file
*/
#ifndef cglmc_ortho_lh_no_h
#define cglmc_ortho_lh_no_h
#ifdef __cplusplus
extern "C" {
#endif
#include "../../cglm.h"
CGLM_EXPORT
void
glmc_ortho_lh_no(float left, float right,
float bottom, float top,
float nearZ, float farZ,
mat4 dest);
CGLM_EXPORT
void
glmc_ortho_aabb_lh_no(vec3 box[2], mat4 dest);
CGLM_EXPORT
void
glmc_ortho_aabb_p_lh_no(vec3 box[2], float padding, mat4 dest);
CGLM_EXPORT
void
glmc_ortho_aabb_pz_lh_no(vec3 box[2], float padding, mat4 dest);
CGLM_EXPORT
void
glmc_ortho_default_lh_no(float aspect, mat4 dest);
CGLM_EXPORT
void
glmc_ortho_default_s_lh_no(float aspect, float size, mat4 dest);
#ifdef __cplusplus
}
#endif
#endif /* cglmc_ortho_lh_no_h */

View File

@@ -0,0 +1,46 @@
/*
* Copyright (c), Recep Aslantas.
*
* MIT License (MIT), http://opensource.org/licenses/MIT
* Full license can be found in the LICENSE file
*/
#ifndef cglmc_ortho_lh_zo_h
#define cglmc_ortho_lh_zo_h
#ifdef __cplusplus
extern "C" {
#endif
#include "../../cglm.h"
CGLM_EXPORT
void
glmc_ortho_lh_zo(float left, float right,
float bottom, float top,
float nearZ, float farZ,
mat4 dest);
CGLM_EXPORT
void
glmc_ortho_aabb_lh_zo(vec3 box[2], mat4 dest);
CGLM_EXPORT
void
glmc_ortho_aabb_p_lh_zo(vec3 box[2], float padding, mat4 dest);
CGLM_EXPORT
void
glmc_ortho_aabb_pz_lh_zo(vec3 box[2], float padding, mat4 dest);
CGLM_EXPORT
void
glmc_ortho_default_lh_zo(float aspect, mat4 dest);
CGLM_EXPORT
void
glmc_ortho_default_s_lh_zo(float aspect, float size, mat4 dest);
#ifdef __cplusplus
}
#endif
#endif /* cglmc_ortho_lh_zo_h */

View File

@@ -0,0 +1,46 @@
/*
* Copyright (c), Recep Aslantas.
*
* MIT License (MIT), http://opensource.org/licenses/MIT
* Full license can be found in the LICENSE file
*/
#ifndef cglmc_ortho_rh_no_h
#define cglmc_ortho_rh_no_h
#ifdef __cplusplus
extern "C" {
#endif
#include "../../cglm.h"
CGLM_EXPORT
void
glmc_ortho_rh_no(float left, float right,
float bottom, float top,
float nearZ, float farZ,
mat4 dest);
CGLM_EXPORT
void
glmc_ortho_aabb_rh_no(vec3 box[2], mat4 dest);
CGLM_EXPORT
void
glmc_ortho_aabb_p_rh_no(vec3 box[2], float padding, mat4 dest);
CGLM_EXPORT
void
glmc_ortho_aabb_pz_rh_no(vec3 box[2], float padding, mat4 dest);
CGLM_EXPORT
void
glmc_ortho_default_rh_no(float aspect, mat4 dest);
CGLM_EXPORT
void
glmc_ortho_default_s_rh_no(float aspect, float size, mat4 dest);
#ifdef __cplusplus
}
#endif
#endif /* cglmc_ortho_rh_no_h */

View File

@@ -0,0 +1,46 @@
/*
* Copyright (c), Recep Aslantas.
*
* MIT License (MIT), http://opensource.org/licenses/MIT
* Full license can be found in the LICENSE file
*/
#ifndef cglmc_ortho_rh_zo_h
#define cglmc_ortho_rh_zo_h
#ifdef __cplusplus
extern "C" {
#endif
#include "../../cglm.h"
CGLM_EXPORT
void
glmc_ortho_rh_zo(float left, float right,
float bottom, float top,
float nearZ, float farZ,
mat4 dest);
CGLM_EXPORT
void
glmc_ortho_aabb_rh_zo(vec3 box[2], mat4 dest);
CGLM_EXPORT
void
glmc_ortho_aabb_p_rh_zo(vec3 box[2], float padding, mat4 dest);
CGLM_EXPORT
void
glmc_ortho_aabb_pz_rh_zo(vec3 box[2], float padding, mat4 dest);
CGLM_EXPORT
void
glmc_ortho_default_rh_zo(float aspect, mat4 dest);
CGLM_EXPORT
void
glmc_ortho_default_s_rh_zo(float aspect, float size, mat4 dest);
#ifdef __cplusplus
}
#endif
#endif /* cglmc_ortho_rh_zo_h */

View File

@@ -0,0 +1,91 @@
/*
* Copyright (c), Recep Aslantas.
*
* MIT License (MIT), http://opensource.org/licenses/MIT
* Full license can be found in the LICENSE file
*/
#ifndef cglmc_persp_lh_no_h
#define cglmc_persp_lh_no_h
#ifdef __cplusplus
extern "C" {
#endif
#include "../../cglm.h"
CGLM_EXPORT
void
glmc_frustum_lh_no(float left, float right,
float bottom, float top,
float nearZ, float farZ,
mat4 dest);
CGLM_EXPORT
void
glmc_perspective_lh_no(float fovy,
float aspect,
float nearVal,
float farVal,
mat4 dest);
CGLM_EXPORT
void
glmc_perspective_resize_lh_no(float aspect, mat4 proj);
CGLM_EXPORT
void
glmc_persp_move_far_lh_no(mat4 proj, float deltaFar);
CGLM_EXPORT
void
glmc_persp_decomp_lh_no(mat4 proj,
float * __restrict nearZ, float * __restrict farZ,
float * __restrict top, float * __restrict bottom,
float * __restrict left, float * __restrict right);
CGLM_EXPORT
void
glmc_persp_decompv_lh_no(mat4 proj, float dest[6]);
CGLM_EXPORT
void
glmc_persp_decomp_x_lh_no(mat4 proj,
float * __restrict left,
float * __restrict right);
CGLM_EXPORT
void
glmc_persp_decomp_y_lh_no(mat4 proj,
float * __restrict top,
float * __restrict bottom);
CGLM_EXPORT
void
glmc_persp_decomp_z_lh_no(mat4 proj,
float * __restrict nearZ,
float * __restrict farZ);
CGLM_EXPORT
void
glmc_persp_decomp_far_lh_no(mat4 proj, float * __restrict farZ);
CGLM_EXPORT
void
glmc_persp_decomp_near_lh_no(mat4 proj, float * __restrict nearZ);
CGLM_EXPORT
void
glmc_persp_sizes_lh_no(mat4 proj, float fovy, vec4 dest);
CGLM_EXPORT
float
glmc_persp_fovy_lh_no(mat4 proj);
CGLM_EXPORT
float
glmc_persp_aspect_lh_no(mat4 proj);
#ifdef __cplusplus
}
#endif
#endif /* cglmc_persp_lh_no_h */

View File

@@ -0,0 +1,91 @@
/*
* Copyright (c), Recep Aslantas.
*
* MIT License (MIT), http://opensource.org/licenses/MIT
* Full license can be found in the LICENSE file
*/
#ifndef cglmc_persp_lh_zo_h
#define cglmc_persp_lh_zo_h
#ifdef __cplusplus
extern "C" {
#endif
#include "../../cglm.h"
CGLM_EXPORT
void
glmc_frustum_lh_zo(float left, float right,
float bottom, float top,
float nearZ, float farZ,
mat4 dest);
CGLM_EXPORT
void
glmc_perspective_lh_zo(float fovy,
float aspect,
float nearVal,
float farVal,
mat4 dest);
CGLM_EXPORT
void
glmc_perspective_resize_lh_zo(float aspect, mat4 proj);
CGLM_EXPORT
void
glmc_persp_move_far_lh_zo(mat4 proj, float deltaFar);
CGLM_EXPORT
void
glmc_persp_decomp_lh_zo(mat4 proj,
float * __restrict nearZ, float * __restrict farZ,
float * __restrict top, float * __restrict bottom,
float * __restrict left, float * __restrict right);
CGLM_EXPORT
void
glmc_persp_decompv_lh_zo(mat4 proj, float dest[6]);
CGLM_EXPORT
void
glmc_persp_decomp_x_lh_zo(mat4 proj,
float * __restrict left,
float * __restrict right);
CGLM_EXPORT
void
glmc_persp_decomp_y_lh_zo(mat4 proj,
float * __restrict top,
float * __restrict bottom);
CGLM_EXPORT
void
glmc_persp_decomp_z_lh_zo(mat4 proj,
float * __restrict nearZ,
float * __restrict farZ);
CGLM_EXPORT
void
glmc_persp_decomp_far_lh_zo(mat4 proj, float * __restrict farZ);
CGLM_EXPORT
void
glmc_persp_decomp_near_lh_zo(mat4 proj, float * __restrict nearZ);
CGLM_EXPORT
void
glmc_persp_sizes_lh_zo(mat4 proj, float fovy, vec4 dest);
CGLM_EXPORT
float
glmc_persp_fovy_lh_zo(mat4 proj);
CGLM_EXPORT
float
glmc_persp_aspect_lh_zo(mat4 proj);
#ifdef __cplusplus
}
#endif
#endif /* cglmc_persp_lh_zo_h */

View File

@@ -0,0 +1,91 @@
/*
* Copyright (c), Recep Aslantas.
*
* MIT License (MIT), http://opensource.org/licenses/MIT
* Full license can be found in the LICENSE file
*/
#ifndef cglmc_persp_rh_no_h
#define cglmc_persp_rh_no_h
#ifdef __cplusplus
extern "C" {
#endif
#include "../../cglm.h"
CGLM_EXPORT
void
glmc_frustum_rh_no(float left, float right,
float bottom, float top,
float nearZ, float farZ,
mat4 dest);
CGLM_EXPORT
void
glmc_perspective_rh_no(float fovy,
float aspect,
float nearVal,
float farVal,
mat4 dest);
CGLM_EXPORT
void
glmc_perspective_resize_rh_no(float aspect, mat4 proj);
CGLM_EXPORT
void
glmc_persp_move_far_rh_no(mat4 proj, float deltaFar);
CGLM_EXPORT
void
glmc_persp_decomp_rh_no(mat4 proj,
float * __restrict nearZ, float * __restrict farZ,
float * __restrict top, float * __restrict bottom,
float * __restrict left, float * __restrict right);
CGLM_EXPORT
void
glmc_persp_decompv_rh_no(mat4 proj, float dest[6]);
CGLM_EXPORT
void
glmc_persp_decomp_x_rh_no(mat4 proj,
float * __restrict left,
float * __restrict right);
CGLM_EXPORT
void
glmc_persp_decomp_y_rh_no(mat4 proj,
float * __restrict top,
float * __restrict bottom);
CGLM_EXPORT
void
glmc_persp_decomp_z_rh_no(mat4 proj,
float * __restrict nearZ,
float * __restrict farZ);
CGLM_EXPORT
void
glmc_persp_decomp_far_rh_no(mat4 proj, float * __restrict farZ);
CGLM_EXPORT
void
glmc_persp_decomp_near_rh_no(mat4 proj, float * __restrict nearZ);
CGLM_EXPORT
void
glmc_persp_sizes_rh_no(mat4 proj, float fovy, vec4 dest);
CGLM_EXPORT
float
glmc_persp_fovy_rh_no(mat4 proj);
CGLM_EXPORT
float
glmc_persp_aspect_rh_no(mat4 proj);
#ifdef __cplusplus
}
#endif
#endif /* cglmc_persp_rh_no_h */

View File

@@ -0,0 +1,91 @@
/*
* Copyright (c), Recep Aslantas.
*
* MIT License (MIT), http://opensource.org/licenses/MIT
* Full license can be found in the LICENSE file
*/
#ifndef cglmc_persp_rh_zo_h
#define cglmc_persp_rh_zo_h
#ifdef __cplusplus
extern "C" {
#endif
#include "../../cglm.h"
CGLM_EXPORT
void
glmc_frustum_rh_zo(float left, float right,
float bottom, float top,
float nearZ, float farZ,
mat4 dest);
CGLM_EXPORT
void
glmc_perspective_rh_zo(float fovy,
float aspect,
float nearVal,
float farVal,
mat4 dest);
CGLM_EXPORT
void
glmc_perspective_resize_rh_zo(float aspect, mat4 proj);
CGLM_EXPORT
void
glmc_persp_move_far_rh_zo(mat4 proj, float deltaFar);
CGLM_EXPORT
void
glmc_persp_decomp_rh_zo(mat4 proj,
float * __restrict nearZ, float * __restrict farZ,
float * __restrict top, float * __restrict bottom,
float * __restrict left, float * __restrict right);
CGLM_EXPORT
void
glmc_persp_decompv_rh_zo(mat4 proj, float dest[6]);
CGLM_EXPORT
void
glmc_persp_decomp_x_rh_zo(mat4 proj,
float * __restrict left,
float * __restrict right);
CGLM_EXPORT
void
glmc_persp_decomp_y_rh_zo(mat4 proj,
float * __restrict top,
float * __restrict bottom);
CGLM_EXPORT
void
glmc_persp_decomp_z_rh_zo(mat4 proj,
float * __restrict nearZ,
float * __restrict farZ);
CGLM_EXPORT
void
glmc_persp_decomp_far_rh_zo(mat4 proj, float * __restrict farZ);
CGLM_EXPORT
void
glmc_persp_decomp_near_rh_zo(mat4 proj, float * __restrict nearZ);
CGLM_EXPORT
void
glmc_persp_sizes_rh_zo(mat4 proj, float fovy, vec4 dest);
CGLM_EXPORT
float
glmc_persp_fovy_rh_zo(mat4 proj);
CGLM_EXPORT
float
glmc_persp_aspect_rh_zo(mat4 proj);
#ifdef __cplusplus
}
#endif
#endif /* cglmc_persp_rh_zo_h */

View File

@@ -0,0 +1,31 @@
/*
* Copyright (c), Recep Aslantas.
*
* MIT License (MIT), http://opensource.org/licenses/MIT
* Full license can be found in the LICENSE file
*/
#ifndef cglmc_project_no_h
#define cglmc_project_no_h
#ifdef __cplusplus
extern "C" {
#endif
#include "../../cglm.h"
CGLM_EXPORT
void
glmc_unprojecti_no(vec3 pos, mat4 invMat, vec4 vp, vec3 dest);
CGLM_EXPORT
void
glmc_project_no(vec3 pos, mat4 m, vec4 vp, vec3 dest);
CGLM_EXPORT
float
glmc_project_z_no(vec3 pos, mat4 m);
#ifdef __cplusplus
}
#endif
#endif /* cglmc_project_no_h */

View File

@@ -0,0 +1,31 @@
/*
* Copyright (c), Recep Aslantas.
*
* MIT License (MIT), http://opensource.org/licenses/MIT
* Full license can be found in the LICENSE file
*/
#ifndef cglmc_project_zo_h
#define cglmc_project_zo_h
#ifdef __cplusplus
extern "C" {
#endif
#include "../../cglm.h"
CGLM_EXPORT
void
glmc_unprojecti_zo(vec3 pos, mat4 invMat, vec4 vp, vec3 dest);
CGLM_EXPORT
void
glmc_project_zo(vec3 pos, mat4 m, vec4 vp, vec3 dest);
CGLM_EXPORT
float
glmc_project_z_zo(vec3 pos, mat4 m);
#ifdef __cplusplus
}
#endif
#endif /* cglmc_project_zo_h */

View File

@@ -0,0 +1,31 @@
/*
* Copyright (c), Recep Aslantas.
*
* MIT License (MIT), http://opensource.org/licenses/MIT
* Full license can be found in the LICENSE file
*/
#ifndef cglmc_view_lh_no_h
#define cglmc_view_lh_no_h
#ifdef __cplusplus
extern "C" {
#endif
#include "../../cglm.h"
CGLM_EXPORT
void
glmc_lookat_lh_no(vec3 eye, vec3 center, vec3 up, mat4 dest);
CGLM_EXPORT
void
glmc_look_lh_no(vec3 eye, vec3 dir, vec3 up, mat4 dest);
CGLM_EXPORT
void
glmc_look_anyup_lh_no(vec3 eye, vec3 dir, mat4 dest);
#ifdef __cplusplus
}
#endif
#endif /* cglmc_view_lh_no_h */

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