mirror of
https://github.com/recp/cglm.git
synced 2026-02-17 03:39:05 +00:00
Compare commits
141 Commits
werror
...
win32_intr
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a682b9e6cf | ||
|
|
bca93a379d | ||
|
|
34f0d59f5a | ||
|
|
c878161518 | ||
|
|
3b1d4fc546 | ||
|
|
5be1c2f059 | ||
|
|
67ce1519c5 | ||
|
|
86743c98e5 | ||
|
|
015e859075 | ||
|
|
3a2a26e5a4 | ||
|
|
1ccd9af866 | ||
|
|
aa20b8ae7f | ||
|
|
fa6244c42b | ||
|
|
c998d0186a | ||
|
|
a94861dd5d | ||
|
|
040926999a | ||
|
|
40cfbe9717 | ||
|
|
d820410435 | ||
|
|
39c0c1e784 | ||
|
|
4c9b32324d | ||
|
|
921ab6640b | ||
|
|
7701a1a789 | ||
|
|
46aaf250fa | ||
|
|
42b5e834d1 | ||
|
|
732a403112 | ||
|
|
559a6588c8 | ||
|
|
8277473202 | ||
|
|
97575bdcd6 | ||
|
|
bc2a918ad0 | ||
|
|
8ebcc3aceb | ||
|
|
d341478342 | ||
|
|
7e4383cb3d | ||
|
|
b45657f673 | ||
|
|
e24675c6e0 | ||
|
|
2e6e4a9a44 | ||
|
|
4f88a027bc | ||
|
|
673263265b | ||
|
|
dd9235dfee | ||
|
|
4c4a69ddfe | ||
|
|
d6139559b6 | ||
|
|
2eb9a67a3a | ||
|
|
8a1d1cf35d | ||
|
|
fee2b7d344 | ||
|
|
865faad116 | ||
|
|
7ccf199066 | ||
|
|
047138321c | ||
|
|
75b99ef87d | ||
|
|
036fd4848b | ||
|
|
666d692dfb | ||
|
|
ec3796973e | ||
|
|
45f2fff22f | ||
|
|
4ee6aea037 | ||
|
|
2f7dbad6a8 | ||
|
|
5ae0cd4618 | ||
|
|
23d03ffe6c | ||
|
|
c5694c5c17 | ||
|
|
d67ac97323 | ||
|
|
05ea35ffec | ||
|
|
05d45872a3 | ||
|
|
c431bbf190 | ||
|
|
340292c0fb | ||
|
|
2106f9ebcb | ||
|
|
c1d78d835b | ||
|
|
de80b8325f | ||
|
|
7061df0066 | ||
|
|
eb73e4123b | ||
|
|
22140d8e1b | ||
|
|
39602ef4d7 | ||
|
|
abb71a8e32 | ||
|
|
f8b6573de8 | ||
|
|
15f29e05eb | ||
|
|
7696374f1e | ||
|
|
44d103fa00 | ||
|
|
c29f077bed | ||
|
|
2a975a7d0a | ||
|
|
049db64a0f | ||
|
|
e71694bb57 | ||
|
|
8754158fbe | ||
|
|
e1a0892097 | ||
|
|
9b26aff466 | ||
|
|
24e417107b | ||
|
|
009405adcd | ||
|
|
0b2006dd47 | ||
|
|
1fdc1c8675 | ||
|
|
6e1d6d505b | ||
|
|
45cf4710c4 | ||
|
|
056b28e4da | ||
|
|
c6e58bd44a | ||
|
|
a81c0f076a | ||
|
|
ab684b7c66 | ||
|
|
53bde05bd9 | ||
|
|
58a4b47830 | ||
|
|
1bfa53f44c | ||
|
|
d93b46bab7 | ||
|
|
9efc255451 | ||
|
|
9484155c98 | ||
|
|
509078817c | ||
|
|
126f809dae | ||
|
|
e0e7e380e5 | ||
|
|
d3169b12a7 | ||
|
|
9d0c9fdb87 | ||
|
|
f496146bce | ||
|
|
54632ecce5 | ||
|
|
61478d2563 | ||
|
|
cdd4d0e83e | ||
|
|
54dfc4b4f0 | ||
|
|
f6cb3ba31a | ||
|
|
da51741c50 | ||
|
|
a5d8e61c2b | ||
|
|
f0f7b67ef4 | ||
|
|
eece0b7bc9 | ||
|
|
37d20f7da8 | ||
|
|
006e4ffbdf | ||
|
|
aa37c1aa74 | ||
|
|
0fb9e73ec1 | ||
|
|
129287b809 | ||
|
|
2724620d83 | ||
|
|
4d5653b1f6 | ||
|
|
dbb85f24c8 | ||
|
|
6e9e91be05 | ||
|
|
1e077fd125 | ||
|
|
cb4a1b2677 | ||
|
|
924db3307e | ||
|
|
e9df003e56 | ||
|
|
3d292c3a2e | ||
|
|
4bb7e778c4 | ||
|
|
2df26c0ecf | ||
|
|
5193b50133 | ||
|
|
ef8954ccbc | ||
|
|
91b40eb7eb | ||
|
|
82892085b3 | ||
|
|
e09cf11f1c | ||
|
|
8966f296ac | ||
|
|
4e44e74d48 | ||
|
|
f817c4cbb0 | ||
|
|
dd6a0b3175 | ||
|
|
1401af4c34 | ||
|
|
fe7471e8f8 | ||
|
|
1ca261b118 | ||
|
|
6317ed90e7 | ||
|
|
3b683cf28c |
4
.github/workflows/cmake-wasm.yml
vendored
4
.github/workflows/cmake-wasm.yml
vendored
@@ -23,7 +23,7 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Downloading wasi-sdk
|
- name: Downloading wasi-sdk
|
||||||
run: |
|
run: |
|
||||||
@@ -64,7 +64,7 @@ jobs:
|
|||||||
C_FLAGS: ['', '-msimd128', '-msse -msse2 -msimd128', '-msse -msse2 -msse3 -msse4 -msimd128']
|
C_FLAGS: ['', '-msimd128', '-msse -msse2 -msimd128', '-msse -msse2 -msse3 -msse4 -msimd128']
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v4
|
||||||
- name: Setup emsdk
|
- name: Setup emsdk
|
||||||
uses: mymindstorm/setup-emsdk@v12
|
uses: mymindstorm/setup-emsdk@v12
|
||||||
|
|
||||||
|
|||||||
79
.github/workflows/meson-wasm.yml
vendored
Normal file
79
.github/workflows/meson-wasm.yml
vendored
Normal 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
|
||||||
39
.readthedocs.yaml
Normal file
39
.readthedocs.yaml
Normal 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
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
cmake_minimum_required(VERSION 3.8.2)
|
cmake_minimum_required(VERSION 3.8.2)
|
||||||
project(cglm
|
project(cglm
|
||||||
VERSION 0.9.1
|
VERSION 0.9.3
|
||||||
HOMEPAGE_URL https://github.com/recp/cglm
|
HOMEPAGE_URL https://github.com/recp/cglm
|
||||||
DESCRIPTION "OpenGL Mathematics (glm) for C"
|
DESCRIPTION "OpenGL Mathematics (glm) for C"
|
||||||
LANGUAGES C
|
LANGUAGES C
|
||||||
@@ -79,8 +79,14 @@ add_library(${PROJECT_NAME}
|
|||||||
src/vec4.c
|
src/vec4.c
|
||||||
src/ivec4.c
|
src/ivec4.c
|
||||||
src/mat2.c
|
src/mat2.c
|
||||||
|
src/mat2x3.c
|
||||||
|
src/mat2x4.c
|
||||||
src/mat3.c
|
src/mat3.c
|
||||||
|
src/mat3x2.c
|
||||||
|
src/mat3x4.c
|
||||||
src/mat4.c
|
src/mat4.c
|
||||||
|
src/mat4x2.c
|
||||||
|
src/mat4x3.c
|
||||||
src/plane.c
|
src/plane.c
|
||||||
src/frustum.c
|
src/frustum.c
|
||||||
src/box.c
|
src/box.c
|
||||||
|
|||||||
44
Makefile.am
44
Makefile.am
@@ -42,8 +42,14 @@ cglm_HEADERS = include/cglm/version.h \
|
|||||||
include/cglm/cam.h \
|
include/cglm/cam.h \
|
||||||
include/cglm/io.h \
|
include/cglm/io.h \
|
||||||
include/cglm/mat4.h \
|
include/cglm/mat4.h \
|
||||||
|
include/cglm/mat4x2.h \
|
||||||
|
include/cglm/mat4x3.h \
|
||||||
include/cglm/mat3.h \
|
include/cglm/mat3.h \
|
||||||
|
include/cglm/mat3x2.h \
|
||||||
|
include/cglm/mat3x4.h \
|
||||||
include/cglm/mat2.h \
|
include/cglm/mat2.h \
|
||||||
|
include/cglm/mat2x3.h \
|
||||||
|
include/cglm/mat2x4.h \
|
||||||
include/cglm/affine-pre.h \
|
include/cglm/affine-pre.h \
|
||||||
include/cglm/affine-post.h \
|
include/cglm/affine-post.h \
|
||||||
include/cglm/affine.h \
|
include/cglm/affine.h \
|
||||||
@@ -63,6 +69,7 @@ cglm_HEADERS = include/cglm/version.h \
|
|||||||
include/cglm/plane.h \
|
include/cglm/plane.h \
|
||||||
include/cglm/frustum.h \
|
include/cglm/frustum.h \
|
||||||
include/cglm/box.h \
|
include/cglm/box.h \
|
||||||
|
include/cglm/aabb2d.h \
|
||||||
include/cglm/color.h \
|
include/cglm/color.h \
|
||||||
include/cglm/project.h \
|
include/cglm/project.h \
|
||||||
include/cglm/sphere.h \
|
include/cglm/sphere.h \
|
||||||
@@ -94,8 +101,14 @@ cglm_clipspace_HEADERS = include/cglm/clipspace/persp.h \
|
|||||||
|
|
||||||
cglm_calldir=$(includedir)/cglm/call
|
cglm_calldir=$(includedir)/cglm/call
|
||||||
cglm_call_HEADERS = include/cglm/call/mat4.h \
|
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/mat3.h \
|
||||||
|
include/cglm/call/mat3x2.h \
|
||||||
|
include/cglm/call/mat3x4.h \
|
||||||
include/cglm/call/mat2.h \
|
include/cglm/call/mat2.h \
|
||||||
|
include/cglm/call/mat2x3.h \
|
||||||
|
include/cglm/call/mat2x4.h \
|
||||||
include/cglm/call/vec2.h \
|
include/cglm/call/vec2.h \
|
||||||
include/cglm/call/vec3.h \
|
include/cglm/call/vec3.h \
|
||||||
include/cglm/call/vec4.h \
|
include/cglm/call/vec4.h \
|
||||||
@@ -137,7 +150,8 @@ cglm_call_clipspace_HEADERS = include/cglm/call/clipspace/persp_lh_no.h \
|
|||||||
cglm_simddir=$(includedir)/cglm/simd
|
cglm_simddir=$(includedir)/cglm/simd
|
||||||
cglm_simd_HEADERS = include/cglm/simd/intrin.h \
|
cglm_simd_HEADERS = include/cglm/simd/intrin.h \
|
||||||
include/cglm/simd/x86.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_sse2dir=$(includedir)/cglm/simd/sse2
|
||||||
cglm_simd_sse2_HEADERS = include/cglm/simd/sse2/affine.h \
|
cglm_simd_sse2_HEADERS = include/cglm/simd/sse2/affine.h \
|
||||||
@@ -156,10 +170,27 @@ cglm_simd_neon_HEADERS = include/cglm/simd/neon/affine.h \
|
|||||||
include/cglm/simd/neon/mat4.h \
|
include/cglm/simd/neon/mat4.h \
|
||||||
include/cglm/simd/neon/quat.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_structdir=$(includedir)/cglm/struct
|
||||||
cglm_struct_HEADERS = include/cglm/struct/mat4.h \
|
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/mat3.h \
|
||||||
|
include/cglm/struct/mat3x2.h \
|
||||||
|
include/cglm/struct/mat3x4.h \
|
||||||
include/cglm/struct/mat2.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-pre.h \
|
||||||
include/cglm/struct/affine-post.h \
|
include/cglm/struct/affine-post.h \
|
||||||
include/cglm/struct/affine-mat.h \
|
include/cglm/struct/affine-mat.h \
|
||||||
@@ -178,6 +209,7 @@ cglm_struct_HEADERS = include/cglm/struct/mat4.h \
|
|||||||
include/cglm/struct/plane.h \
|
include/cglm/struct/plane.h \
|
||||||
include/cglm/struct/frustum.h \
|
include/cglm/struct/frustum.h \
|
||||||
include/cglm/struct/box.h \
|
include/cglm/struct/box.h \
|
||||||
|
include/cglm/struct/aabb2d.h \
|
||||||
include/cglm/struct/project.h \
|
include/cglm/struct/project.h \
|
||||||
include/cglm/struct/sphere.h \
|
include/cglm/struct/sphere.h \
|
||||||
include/cglm/struct/color.h \
|
include/cglm/struct/color.h \
|
||||||
@@ -199,6 +231,10 @@ cglm_struct_clipspace_HEADERS = include/cglm/struct/clipspace/persp_lh_no.h \
|
|||||||
include/cglm/struct/clipspace/project_no.h \
|
include/cglm/struct/clipspace/project_no.h \
|
||||||
include/cglm/struct/clipspace/project_zo.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=\
|
libcglm_la_SOURCES=\
|
||||||
src/euler.c \
|
src/euler.c \
|
||||||
src/affine.c \
|
src/affine.c \
|
||||||
@@ -212,8 +248,14 @@ libcglm_la_SOURCES=\
|
|||||||
src/vec4.c \
|
src/vec4.c \
|
||||||
src/ivec4.c \
|
src/ivec4.c \
|
||||||
src/mat2.c \
|
src/mat2.c \
|
||||||
|
src/mat2x3.c \
|
||||||
|
src/mat2x4.c \
|
||||||
src/mat3.c \
|
src/mat3.c \
|
||||||
|
src/mat3x2.c \
|
||||||
|
src/mat3x4.c \
|
||||||
src/mat4.c \
|
src/mat4.c \
|
||||||
|
src/mat4x2.c \
|
||||||
|
src/mat4x3.c \
|
||||||
src/plane.c \
|
src/plane.c \
|
||||||
src/frustum.c \
|
src/frustum.c \
|
||||||
src/box.c \
|
src/box.c \
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ Pod::Spec.new do |s|
|
|||||||
|
|
||||||
# Description
|
# Description
|
||||||
s.name = "cglm"
|
s.name = "cglm"
|
||||||
s.version = "0.9.0"
|
s.version = "0.9.2"
|
||||||
s.summary = "📽 Highly Optimized Graphics Math (glm) for C"
|
s.summary = "📽 Highly Optimized Graphics Math (glm) for C"
|
||||||
s.description = <<-DESC
|
s.description = <<-DESC
|
||||||
cglm is math library for graphics programming for C. 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.
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
#*****************************************************************************
|
#*****************************************************************************
|
||||||
|
|
||||||
AC_PREREQ([2.69])
|
AC_PREREQ([2.69])
|
||||||
AC_INIT([cglm], [0.9.1], [info@recp.me])
|
AC_INIT([cglm], [0.9.3], [info@recp.me])
|
||||||
AM_INIT_AUTOMAKE([-Wall foreign subdir-objects serial-tests])
|
AM_INIT_AUTOMAKE([-Wall foreign subdir-objects serial-tests])
|
||||||
|
|
||||||
# Don't use the default cflags (-O2 -g), we set ours manually in Makefile.am.
|
# Don't use the default cflags (-O2 -g), we set ours manually in Makefile.am.
|
||||||
|
|||||||
4
docs/requirements.txt
Normal file
4
docs/requirements.txt
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
# Defining the exact version will make sure things don't break
|
||||||
|
sphinx==5.3.0
|
||||||
|
sphinx_rtd_theme==1.1.1
|
||||||
|
readthedocs-sphinx-search==0.1.1
|
||||||
173
docs/source/aabb2d.rst
Normal file
173
docs/source/aabb2d.rst
Normal file
@@ -0,0 +1,173 @@
|
|||||||
|
.. 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):
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
Functions:
|
||||||
|
|
||||||
|
1. :c:func:`glm_aabb2d_copy`
|
||||||
|
#. :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_size`
|
||||||
|
#. :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_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 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]* **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 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]* **aabb** bounding box
|
||||||
|
| *[in]* **cropAabb** crop box
|
||||||
|
| *[in]* **clampAabb** miniumum 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_size(vec2 aabb[2])
|
||||||
|
|
||||||
|
| distance between of min and max
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
| *[in]* **aabb** bounding box
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
distance between min - max
|
||||||
|
|
||||||
|
.. 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
|
||||||
|
|
||||||
@@ -46,8 +46,14 @@ Follow the :doc:`build` documentation for this
|
|||||||
quat
|
quat
|
||||||
euler
|
euler
|
||||||
mat2
|
mat2
|
||||||
|
mat2x3
|
||||||
|
mat2x4
|
||||||
mat3
|
mat3
|
||||||
|
mat3x2
|
||||||
|
mat3x4
|
||||||
mat4
|
mat4
|
||||||
|
mat4x2
|
||||||
|
mat4x3
|
||||||
vec2
|
vec2
|
||||||
vec2-ext
|
vec2-ext
|
||||||
vec3
|
vec3
|
||||||
|
|||||||
@@ -62,9 +62,9 @@ author = u'Recep Aslantas'
|
|||||||
# built documents.
|
# built documents.
|
||||||
#
|
#
|
||||||
# The short X.Y version.
|
# The short X.Y version.
|
||||||
version = u'0.9.1'
|
version = u'0.9.2'
|
||||||
# The full version, including alpha/beta/rc tags.
|
# The full version, including alpha/beta/rc tags.
|
||||||
release = u'0.9.1'
|
release = u'0.9.2'
|
||||||
|
|
||||||
# The language for content autogenerated by Sphinx. Refer to documentation
|
# The language for content autogenerated by Sphinx. Refer to documentation
|
||||||
# for a list of supported languages.
|
# for a list of supported languages.
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ Features
|
|||||||
* inline or pre-compiled function call
|
* inline or pre-compiled function call
|
||||||
* frustum (extract view frustum planes, corners...)
|
* frustum (extract view frustum planes, corners...)
|
||||||
* bounding box (AABB in Frustum (culling), crop, merge...)
|
* bounding box (AABB in Frustum (culling), crop, merge...)
|
||||||
|
* 2d bounding box (crop, merge...)
|
||||||
* bounding sphere
|
* bounding sphere
|
||||||
* project, unproject
|
* project, unproject
|
||||||
* easing functions
|
* easing functions
|
||||||
|
|||||||
@@ -53,8 +53,11 @@ Functions:
|
|||||||
1. :c:func:`glm_mat4_print`
|
1. :c:func:`glm_mat4_print`
|
||||||
#. :c:func:`glm_mat3_print`
|
#. :c:func:`glm_mat3_print`
|
||||||
#. :c:func:`glm_vec4_print`
|
#. :c:func:`glm_vec4_print`
|
||||||
|
#. :c:func:`glm_ivec4_print`
|
||||||
#. :c:func:`glm_vec3_print`
|
#. :c:func:`glm_vec3_print`
|
||||||
#. :c:func:`glm_ivec3_print`
|
#. :c:func:`glm_ivec3_print`
|
||||||
|
#. :c:func:`glm_vec2_print`
|
||||||
|
#. :c:func:`glm_ivec2_print`
|
||||||
#. :c:func:`glm_versor_print`
|
#. :c:func:`glm_versor_print`
|
||||||
#. :c:func:`glm_aabb_print`
|
#. :c:func:`glm_aabb_print`
|
||||||
|
|
||||||
@@ -63,7 +66,7 @@ Functions documentation
|
|||||||
|
|
||||||
.. c:function:: void glm_mat4_print(mat4 matrix, FILE * __restrict ostream)
|
.. c:function:: void glm_mat4_print(mat4 matrix, FILE * __restrict ostream)
|
||||||
|
|
||||||
| print mat4 to given stream
|
| print matrix to given stream
|
||||||
|
|
||||||
Parameters:
|
Parameters:
|
||||||
| *[in]* **matrix** matrix
|
| *[in]* **matrix** matrix
|
||||||
@@ -71,7 +74,7 @@ Functions documentation
|
|||||||
|
|
||||||
.. c:function:: void glm_mat3_print(mat3 matrix, FILE * __restrict ostream)
|
.. c:function:: void glm_mat3_print(mat3 matrix, FILE * __restrict ostream)
|
||||||
|
|
||||||
| print mat3 to given stream
|
| print matrix to given stream
|
||||||
|
|
||||||
Parameters:
|
Parameters:
|
||||||
| *[in]* **matrix** matrix
|
| *[in]* **matrix** matrix
|
||||||
@@ -79,7 +82,15 @@ Functions documentation
|
|||||||
|
|
||||||
.. c:function:: void glm_vec4_print(vec4 vec, FILE * __restrict ostream)
|
.. 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:
|
Parameters:
|
||||||
| *[in]* **vec** vector
|
| *[in]* **vec** vector
|
||||||
@@ -87,7 +98,7 @@ Functions documentation
|
|||||||
|
|
||||||
.. c:function:: void glm_vec3_print(vec3 vec, FILE * __restrict ostream)
|
.. c:function:: void glm_vec3_print(vec3 vec, FILE * __restrict ostream)
|
||||||
|
|
||||||
| print vec3 to given stream
|
| print vector to given stream
|
||||||
|
|
||||||
Parameters:
|
Parameters:
|
||||||
| *[in]* **vec** vector
|
| *[in]* **vec** vector
|
||||||
@@ -95,12 +106,29 @@ Functions documentation
|
|||||||
|
|
||||||
.. c:function:: void glm_ivec3_print(ivec3 vec, FILE * __restrict ostream)
|
.. c:function:: void glm_ivec3_print(ivec3 vec, FILE * __restrict ostream)
|
||||||
|
|
||||||
| print ivec3 to given stream
|
| print vector to given stream
|
||||||
|
|
||||||
Parameters:
|
Parameters:
|
||||||
| *[in]* **vec** vector
|
| *[in]* **vec** vector
|
||||||
| *[in]* **ostream** FILE to write
|
| *[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)
|
.. c:function:: void glm_versor_print(versor vec, FILE * __restrict ostream)
|
||||||
|
|
||||||
| print quaternion to given stream
|
| print quaternion to given stream
|
||||||
|
|||||||
@@ -143,6 +143,31 @@ Functions documentation
|
|||||||
Returns:
|
Returns:
|
||||||
distance
|
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)
|
.. c:function:: void glm_ivec2_maxv(ivec2 a, ivec2 b, ivec2 dest)
|
||||||
|
|
||||||
set each member of dest to greater of vector a and b
|
set each member of dest to greater of vector a and b
|
||||||
|
|||||||
@@ -29,6 +29,9 @@ Functions:
|
|||||||
#. :c:func:`glm_ivec3_scale`
|
#. :c:func:`glm_ivec3_scale`
|
||||||
#. :c:func:`glm_ivec3_distance2`
|
#. :c:func:`glm_ivec3_distance2`
|
||||||
#. :c:func:`glm_ivec3_distance`
|
#. :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_maxv`
|
||||||
#. :c:func:`glm_ivec3_minv`
|
#. :c:func:`glm_ivec3_minv`
|
||||||
#. :c:func:`glm_ivec3_clamp`
|
#. :c:func:`glm_ivec3_clamp`
|
||||||
@@ -143,6 +146,30 @@ Functions documentation
|
|||||||
Returns:
|
Returns:
|
||||||
distance
|
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)
|
.. c:function:: void glm_ivec3_maxv(ivec3 a, ivec3 b, ivec3 dest)
|
||||||
|
|
||||||
set each member of dest to greater of vector a and b
|
set each member of dest to greater of vector a and b
|
||||||
|
|||||||
@@ -65,11 +65,12 @@ Functions documentation
|
|||||||
make given matrix zero
|
make given matrix zero
|
||||||
|
|
||||||
Parameters:
|
Parameters:
|
||||||
| *[in,out]* **mat** matrix to
|
| *[in,out]* **mat** matrix
|
||||||
|
|
||||||
.. c:function:: void glm_mat2_mul(mat2 m1, mat2 m2, mat2 dest)
|
.. c:function:: void glm_mat2_mul(mat2 m1, mat2 m2, mat2 dest)
|
||||||
|
|
||||||
multiply m1 and m2 to dest
|
multiply m1 and m2 to dest
|
||||||
|
|
||||||
m1, m2 and dest matrices can be same matrix, it is possible to write this:
|
m1, m2 and dest matrices can be same matrix, it is possible to write this:
|
||||||
|
|
||||||
.. code-block:: c
|
.. code-block:: c
|
||||||
@@ -101,7 +102,7 @@ Functions documentation
|
|||||||
|
|
||||||
.. c:function:: void glm_mat2_mulv(mat2 m, vec2 v, vec2 dest)
|
.. c:function:: void glm_mat2_mulv(mat2 m, vec2 v, vec2 dest)
|
||||||
|
|
||||||
multiply mat4 with vec4 (column vector) and store in dest vector
|
multiply mat2 with vec2 (column vector) and store in dest vector
|
||||||
|
|
||||||
Parameters:
|
Parameters:
|
||||||
| *[in]* **mat** mat2 (left)
|
| *[in]* **mat** mat2 (left)
|
||||||
@@ -113,8 +114,8 @@ Functions documentation
|
|||||||
multiply matrix with scalar
|
multiply matrix with scalar
|
||||||
|
|
||||||
Parameters:
|
Parameters:
|
||||||
| *[in, out]* **mat** matrix
|
| *[in, out]* **m** matrix
|
||||||
| *[in]* **dest** scalar
|
| *[in]* **s** scalar
|
||||||
|
|
||||||
.. c:function:: float glm_mat2_det(mat2 mat)
|
.. c:function:: float glm_mat2_det(mat2 mat)
|
||||||
|
|
||||||
@@ -183,7 +184,7 @@ Functions documentation
|
|||||||
|
|
||||||
Create mat2 matrix from pointer
|
Create mat2 matrix from pointer
|
||||||
|
|
||||||
| NOTE: **@src** must contain 4 elements.
|
| NOTE: **@src** must contain at least 4 elements.
|
||||||
|
|
||||||
Parameters:
|
Parameters:
|
||||||
| *[in]* **src** pointer to an array of floats
|
| *[in]* **src** pointer to an array of floats
|
||||||
|
|||||||
90
docs/source/mat2x3.rst
Normal file
90
docs/source/mat2x3.rst
Normal file
@@ -0,0 +1,90 @@
|
|||||||
|
.. 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`
|
||||||
|
|
||||||
|
Functions documentation
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
.. c:function:: void glm_mat2x3_copy(mat2x3 mat, mat2x3 dest)
|
||||||
|
|
||||||
|
copy mat2x3 to another one (dest).
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
| *[in]* **mat** source
|
||||||
|
| *[out]* **dest** destination
|
||||||
|
|
||||||
|
.. c:function:: void glm_mat2x3_zero(mat2x3 mat)
|
||||||
|
|
||||||
|
make given matrix zero
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
| *[in,out]* **mat** matrix
|
||||||
|
|
||||||
|
.. c:function:: void glm_mat2x3_make(float * __restrict src, mat2x3 dest)
|
||||||
|
|
||||||
|
Create mat2x3 matrix from pointer
|
||||||
|
|
||||||
|
| NOTE: **@src** must contain at least 6 elements.
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
| *[in]* **src** pointer to an array of floats
|
||||||
|
| *[out]* **dest** destination matrix2x3
|
||||||
|
|
||||||
|
.. c:function:: void glm_mat2x3_mul(mat2x3 m1, mat3x2 m2, mat2 dest)
|
||||||
|
|
||||||
|
multiply m1 and m2 to dest
|
||||||
|
|
||||||
|
.. code-block:: c
|
||||||
|
|
||||||
|
glm_mat2x3_mul(mat2x3, mat3x2, mat2);
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
| *[in]* **m1** left matrix (mat2x3)
|
||||||
|
| *[in]* **m2** right matrix (mat3x2)
|
||||||
|
| *[out]* **dest** destination matrix (mat2)
|
||||||
|
|
||||||
|
.. c:function:: void glm_mat2x3_mulv(mat2x3 m, vec3 v, vec2 dest)
|
||||||
|
|
||||||
|
multiply mat2x3 with vec3 (column vector) and store in dest vector
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
| *[in]* **m** mat2x3 (left)
|
||||||
|
| *[in]* **v** vec3 (right, column vector)
|
||||||
|
| *[out]* **dest** destination (result, column vector)
|
||||||
|
|
||||||
|
.. c:function:: void glm_mat2x3_transpose(mat2x3 m, mat3x2 dest)
|
||||||
|
|
||||||
|
transpose matrix and store in dest
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
| *[in]* **m** matrix
|
||||||
|
| *[out]* **dest** destination
|
||||||
|
|
||||||
|
.. c:function:: void glm_mat2x3_scale(mat2x3 m, float s)
|
||||||
|
|
||||||
|
multiply matrix with scalar
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
| *[in, out]* **m** matrix
|
||||||
|
| *[in]* **s** scalar
|
||||||
90
docs/source/mat2x4.rst
Normal file
90
docs/source/mat2x4.rst
Normal file
@@ -0,0 +1,90 @@
|
|||||||
|
.. 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`
|
||||||
|
|
||||||
|
Functions documentation
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
.. c:function:: void glm_mat2x4_copy(mat2x4 mat, mat2x4 dest)
|
||||||
|
|
||||||
|
copy mat2x4 to another one (dest).
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
| *[in]* **mat** source
|
||||||
|
| *[out]* **dest** destination
|
||||||
|
|
||||||
|
.. c:function:: void glm_mat2x4_zero(mat2x4 mat)
|
||||||
|
|
||||||
|
make given matrix zero
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
| *[in,out]* **mat** matrix
|
||||||
|
|
||||||
|
.. c:function:: void glm_mat2x4_make(float * __restrict src, mat2x4 dest)
|
||||||
|
|
||||||
|
Create mat2x4 matrix from pointer
|
||||||
|
|
||||||
|
| NOTE: **@src** must contain at least 8 elements.
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
| *[in]* **src** pointer to an array of floats
|
||||||
|
| *[out]* **dest** destination matrix2x4
|
||||||
|
|
||||||
|
.. c:function:: void glm_mat2x4_mul(mat2x4 m1, mat4x2 m2, mat2 dest)
|
||||||
|
|
||||||
|
multiply m1 and m2 to dest
|
||||||
|
|
||||||
|
.. code-block:: c
|
||||||
|
|
||||||
|
glm_mat2x4_mul(mat2x4, mat4x2, mat2);
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
| *[in]* **m1** left matrix (mat2x4)
|
||||||
|
| *[in]* **m2** right matrix (mat4x2)
|
||||||
|
| *[out]* **dest** destination matrix (mat2)
|
||||||
|
|
||||||
|
.. c:function:: void glm_mat2x4_mulv(mat2x4 m, vec4 v, vec2 dest)
|
||||||
|
|
||||||
|
multiply mat2x4 with vec4 (column vector) and store in dest vector
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
| *[in]* **m** mat2x4 (left)
|
||||||
|
| *[in]* **v** vec4 (right, column vector)
|
||||||
|
| *[out]* **dest** destination (result, column vector)
|
||||||
|
|
||||||
|
.. c:function:: void glm_mat2x4_transpose(mat2x4 m, mat4x2 dest)
|
||||||
|
|
||||||
|
transpose matrix and store in dest
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
| *[in]* **m** matrix
|
||||||
|
| *[out]* **dest** destination
|
||||||
|
|
||||||
|
.. c:function:: void glm_mat2x4_scale(mat2x4 m, float s)
|
||||||
|
|
||||||
|
multiply matrix with scalar
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
| *[in, out]* **m** matrix
|
||||||
|
| *[in]* **s** scalar
|
||||||
@@ -72,6 +72,7 @@ Functions documentation
|
|||||||
.. c:function:: void glm_mat3_mul(mat3 m1, mat3 m2, mat3 dest)
|
.. c:function:: void glm_mat3_mul(mat3 m1, mat3 m2, mat3 dest)
|
||||||
|
|
||||||
multiply m1 and m2 to dest
|
multiply m1 and m2 to dest
|
||||||
|
|
||||||
m1, m2 and dest matrices can be same matrix, it is possible to write this:
|
m1, m2 and dest matrices can be same matrix, it is possible to write this:
|
||||||
|
|
||||||
.. code-block:: c
|
.. code-block:: c
|
||||||
@@ -103,10 +104,10 @@ Functions documentation
|
|||||||
|
|
||||||
.. c:function:: void glm_mat3_mulv(mat3 m, vec3 v, vec3 dest)
|
.. c:function:: void glm_mat3_mulv(mat3 m, vec3 v, vec3 dest)
|
||||||
|
|
||||||
multiply mat4 with vec4 (column vector) and store in dest vector
|
multiply mat3 with vec3 (column vector) and store in dest vector
|
||||||
|
|
||||||
Parameters:
|
Parameters:
|
||||||
| *[in]* **mat** mat3 (left)
|
| *[in]* **m** mat3 (left)
|
||||||
| *[in]* **v** vec3 (right, column vector)
|
| *[in]* **v** vec3 (right, column vector)
|
||||||
| *[out]* **dest** destination (result, column vector)
|
| *[out]* **dest** destination (result, column vector)
|
||||||
|
|
||||||
@@ -123,8 +124,8 @@ Functions documentation
|
|||||||
multiply matrix with scalar
|
multiply matrix with scalar
|
||||||
|
|
||||||
Parameters:
|
Parameters:
|
||||||
| *[in, out]* **mat** matrix
|
| *[in, out]* **m** matrix
|
||||||
| *[in]* **dest** scalar
|
| *[in]* **s** scalar
|
||||||
|
|
||||||
.. c:function:: float glm_mat3_det(mat3 mat)
|
.. c:function:: float glm_mat3_det(mat3 mat)
|
||||||
|
|
||||||
@@ -193,7 +194,7 @@ Functions documentation
|
|||||||
|
|
||||||
Create mat3 matrix from pointer
|
Create mat3 matrix from pointer
|
||||||
|
|
||||||
| NOTE: **@src** must contain 9 elements.
|
| NOTE: **@src** must contain at least 9 elements.
|
||||||
|
|
||||||
Parameters:
|
Parameters:
|
||||||
| *[in]* **src** pointer to an array of floats
|
| *[in]* **src** pointer to an array of floats
|
||||||
|
|||||||
89
docs/source/mat3x2.rst
Normal file
89
docs/source/mat3x2.rst
Normal file
@@ -0,0 +1,89 @@
|
|||||||
|
.. 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`
|
||||||
|
|
||||||
|
Functions documentation
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
.. c:function:: void glm_mat3x2_copy(mat3x2 mat, mat3x2 dest)
|
||||||
|
|
||||||
|
copy mat3x2 to another one (dest).
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
| *[in]* **mat** source
|
||||||
|
| *[out]* **dest** destination
|
||||||
|
|
||||||
|
.. c:function:: void glm_mat3x2_zero(mat3x2 mat)
|
||||||
|
|
||||||
|
make given matrix zero
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
| *[in,out]* **mat** matrix
|
||||||
|
|
||||||
|
.. c:function:: void glm_mat3x2_make(float * __restrict src, mat3x2 dest)
|
||||||
|
|
||||||
|
Create mat3x2 matrix from pointer
|
||||||
|
|
||||||
|
| NOTE: **@src** must contain at least 6 elements.
|
||||||
|
Parameters:
|
||||||
|
| *[in]* **src** pointer to an array of floats
|
||||||
|
| *[out]* **dest** destination matrix3x2
|
||||||
|
|
||||||
|
.. c:function:: void glm_mat3x2_mul(mat3x2 m1, mat2x3 m2, mat3 dest)
|
||||||
|
|
||||||
|
multiply m1 and m2 to dest
|
||||||
|
|
||||||
|
.. code-block:: c
|
||||||
|
|
||||||
|
glm_mat3x2_mul(mat3x2, mat2x3, mat3);
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
| *[in]* **m1** left matrix (mat3x2)
|
||||||
|
| *[in]* **m2** right matrix (mat2x3)
|
||||||
|
| *[out]* **dest** destination matrix (mat3)
|
||||||
|
|
||||||
|
.. c:function:: void glm_mat3x2_mulv(mat3x2 m, vec2 v, vec3 dest)
|
||||||
|
|
||||||
|
multiply mat3x2 with vec2 (column vector) and store in dest vector
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
| *[in]* **m** mat3x2 (left)
|
||||||
|
| *[in]* **v** vec3 (right, column vector)
|
||||||
|
| *[out]* **dest** destination (result, column vector)
|
||||||
|
|
||||||
|
.. c:function:: void glm_mat3x2_transpose(mat3x2 m, mat2x3 dest)
|
||||||
|
|
||||||
|
transpose matrix and store in dest
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
| *[in]* **m** matrix
|
||||||
|
| *[out]* **dest** destination
|
||||||
|
|
||||||
|
.. c:function:: void glm_mat3x2_scale(mat3x2 m, float s)
|
||||||
|
|
||||||
|
multiply matrix with scalar
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
| *[in, out]* **m** matrix
|
||||||
|
| *[in]* **s** scalar
|
||||||
89
docs/source/mat3x4.rst
Normal file
89
docs/source/mat3x4.rst
Normal file
@@ -0,0 +1,89 @@
|
|||||||
|
.. 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`
|
||||||
|
|
||||||
|
Functions documentation
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
.. c:function:: void glm_mat3x4_copy(mat3x4 mat, mat3x4 dest)
|
||||||
|
|
||||||
|
copy mat3x4 to another one (dest).
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
| *[in]* **mat** source
|
||||||
|
| *[out]* **dest** destination
|
||||||
|
|
||||||
|
.. c:function:: void glm_mat3x4_zero(mat3x4 mat)
|
||||||
|
|
||||||
|
make given matrix zero
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
| *[in,out]* **mat** matrix
|
||||||
|
|
||||||
|
.. c:function:: void glm_mat3x4_make(float * __restrict src, mat3x4 dest)
|
||||||
|
|
||||||
|
Create mat3x4 matrix from pointer
|
||||||
|
|
||||||
|
| NOTE: **@src** must contain at least 12 elements.
|
||||||
|
Parameters:
|
||||||
|
| *[in]* **src** pointer to an array of floats
|
||||||
|
| *[out]* **dest** destination matrix3x4
|
||||||
|
|
||||||
|
.. c:function:: void glm_mat3x4_mul(mat3x4 m1, mat4x3 m2, mat3 dest)
|
||||||
|
|
||||||
|
multiply m1 and m2 to dest
|
||||||
|
|
||||||
|
.. code-block:: c
|
||||||
|
|
||||||
|
glm_mat3x4_mul(mat3x4, mat4x3, mat3);
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
| *[in]* **m1** left matrix (mat3x4)
|
||||||
|
| *[in]* **m2** right matrix (mat4x3)
|
||||||
|
| *[out]* **dest** destination matrix (mat3)
|
||||||
|
|
||||||
|
.. c:function:: void glm_mat3x4_mulv(mat3x4 m, vec4 v, vec3 dest)
|
||||||
|
|
||||||
|
multiply mat3x4 with vec4 (column vector) and store in dest vector
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
| *[in]* **m** mat3x4 (left)
|
||||||
|
| *[in]* **v** vec4 (right, column vector)
|
||||||
|
| *[out]* **dest** destination (result, column vector)
|
||||||
|
|
||||||
|
.. c:function:: void glm_mat3x4_transpose(mat3x4 m, mat4x3 dest)
|
||||||
|
|
||||||
|
transpose matrix and store in dest
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
| *[in]* **m** matrix
|
||||||
|
| *[out]* **dest** destination
|
||||||
|
|
||||||
|
.. c:function:: void glm_mat3x4_scale(mat3x4 m, float s)
|
||||||
|
|
||||||
|
multiply matrix with scalar
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
| *[in, out]* **m** matrix
|
||||||
|
| *[in]* **s** scalar
|
||||||
@@ -119,6 +119,7 @@ Functions documentation
|
|||||||
.. c:function:: void glm_mat4_mul(mat4 m1, mat4 m2, mat4 dest)
|
.. c:function:: void glm_mat4_mul(mat4 m1, mat4 m2, mat4 dest)
|
||||||
|
|
||||||
multiply m1 and m2 to dest
|
multiply m1 and m2 to dest
|
||||||
|
|
||||||
m1, m2 and dest matrices can be same matrix, it is possible to write this:
|
m1, m2 and dest matrices can be same matrix, it is possible to write this:
|
||||||
|
|
||||||
.. code-block:: c
|
.. code-block:: c
|
||||||
@@ -157,7 +158,6 @@ Functions documentation
|
|||||||
Parameters:
|
Parameters:
|
||||||
| *[in]* **m** mat4 (left)
|
| *[in]* **m** mat4 (left)
|
||||||
| *[in]* **v** vec4 (right, column vector)
|
| *[in]* **v** vec4 (right, column vector)
|
||||||
| *[in]* **last** 4th item to make it vec4
|
|
||||||
| *[out]* **dest** vec4 (result, column vector)
|
| *[out]* **dest** vec4 (result, column vector)
|
||||||
|
|
||||||
.. c:function:: void glm_mat4_mulv3(mat4 m, vec3 v, float last, vec3 dest)
|
.. c:function:: void glm_mat4_mulv3(mat4 m, vec3 v, float last, vec3 dest)
|
||||||
@@ -308,7 +308,7 @@ Functions documentation
|
|||||||
|
|
||||||
Create mat4 matrix from pointer
|
Create mat4 matrix from pointer
|
||||||
|
|
||||||
| NOTE: **@src** must contain 16 elements.
|
| NOTE: **@src** must contain at least 16 elements.
|
||||||
|
|
||||||
Parameters:
|
Parameters:
|
||||||
| *[in]* **src** pointer to an array of floats
|
| *[in]* **src** pointer to an array of floats
|
||||||
|
|||||||
89
docs/source/mat4x2.rst
Normal file
89
docs/source/mat4x2.rst
Normal file
@@ -0,0 +1,89 @@
|
|||||||
|
.. 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`
|
||||||
|
|
||||||
|
Functions documentation
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
.. c:function:: void glm_mat4x2_copy(mat4x2 mat, mat4x2 dest)
|
||||||
|
|
||||||
|
copy mat4x2 to another one (dest).
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
| *[in]* **mat** source
|
||||||
|
| *[out]* **dest** destination
|
||||||
|
|
||||||
|
.. c:function:: void glm_mat4x2_zero(mat4x2 mat)
|
||||||
|
|
||||||
|
make given matrix zero
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
| *[in,out]* **mat** matrix
|
||||||
|
|
||||||
|
.. c:function:: void glm_mat4x2_make(float * __restrict src, mat4x2 dest)
|
||||||
|
|
||||||
|
Create mat4x2 matrix from pointer
|
||||||
|
|
||||||
|
| NOTE: **@src** must contain at least 8 elements.
|
||||||
|
Parameters:
|
||||||
|
| *[in]* **src** pointer to an array of floats
|
||||||
|
| *[out]* **dest** destination matrix4x2
|
||||||
|
|
||||||
|
.. c:function:: void glm_mat4x2_mul(mat4x2 m1, mat2x4 m2, mat4 dest)
|
||||||
|
|
||||||
|
multiply m1 and m2 to dest
|
||||||
|
|
||||||
|
.. code-block:: c
|
||||||
|
|
||||||
|
glm_mat4x2_mul(mat4x2, mat2x4, mat4);
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
| *[in]* **m1** left matrix (mat4x2)
|
||||||
|
| *[in]* **m2** right matrix (mat2x4)
|
||||||
|
| *[out]* **dest** destination matrix (mat4)
|
||||||
|
|
||||||
|
.. c:function:: void glm_mat4x2_mulv(mat4x2 m, vec2 v, vec4 dest)
|
||||||
|
|
||||||
|
multiply mat4x2 with vec2 (column vector) and store in dest vector
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
| *[in]* **m** mat4x2 (left)
|
||||||
|
| *[in]* **v** vec2 (right, column vector)
|
||||||
|
| *[out]* **dest** destination (result, column vector)
|
||||||
|
|
||||||
|
.. c:function:: void glm_mat4x2_transpose(mat4x2 m, mat2x4 dest)
|
||||||
|
|
||||||
|
transpose matrix and store in dest
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
| *[in]* **m** matrix
|
||||||
|
| *[out]* **dest** destination
|
||||||
|
|
||||||
|
.. c:function:: void glm_mat4x2_scale(mat4x2 m, float s)
|
||||||
|
|
||||||
|
multiply matrix with scalar
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
| *[in, out]* **m** matrix
|
||||||
|
| *[in]* **s** scalar
|
||||||
89
docs/source/mat4x3.rst
Normal file
89
docs/source/mat4x3.rst
Normal file
@@ -0,0 +1,89 @@
|
|||||||
|
.. 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`
|
||||||
|
|
||||||
|
Functions documentation
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
.. c:function:: void glm_mat4x3_copy(mat4x3 mat, mat4x3 dest)
|
||||||
|
|
||||||
|
copy mat4x3 to another one (dest).
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
| *[in]* **mat** source
|
||||||
|
| *[out]* **dest** destination
|
||||||
|
|
||||||
|
.. c:function:: void glm_mat4x3_zero(mat4x3 mat)
|
||||||
|
|
||||||
|
make given matrix zero
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
| *[in,out]* **mat** matrix
|
||||||
|
|
||||||
|
.. c:function:: void glm_mat4x3_make(float * __restrict src, mat4x3 dest)
|
||||||
|
|
||||||
|
Create mat4x3 matrix from pointer
|
||||||
|
|
||||||
|
| NOTE: **@src** must contain at least 12 elements.
|
||||||
|
Parameters:
|
||||||
|
| *[in]* **src** pointer to an array of floats
|
||||||
|
| *[out]* **dest** destination matrix4x3
|
||||||
|
|
||||||
|
.. c:function:: void glm_mat4x3_mul(mat4x3 m1, mat3x4 m2, mat4 dest)
|
||||||
|
|
||||||
|
multiply m1 and m2 to dest
|
||||||
|
|
||||||
|
.. code-block:: c
|
||||||
|
|
||||||
|
glm_mat4x3_mul(mat4x3, mat3x4, mat4);
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
| *[in]* **m1** left matrix (mat4x3)
|
||||||
|
| *[in]* **m2** right matrix (mat3x4)
|
||||||
|
| *[out]* **dest** destination matrix (mat4)
|
||||||
|
|
||||||
|
.. c:function:: void glm_mat4x3_mulv(mat4x3 m, vec3 v, vec4 dest)
|
||||||
|
|
||||||
|
multiply mat4x3 with vec3 (column vector) and store in dest vector
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
| *[in]* **m** mat4x3 (left)
|
||||||
|
| *[in]* **v** vec3 (right, column vector)
|
||||||
|
| *[out]* **dest** destination (result, column vector)
|
||||||
|
|
||||||
|
.. c:function:: void glm_mat4x3_transpose(mat4x3 m, mat3x4 dest)
|
||||||
|
|
||||||
|
transpose matrix and store in dest
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
| *[in]* **m** matrix
|
||||||
|
| *[out]* **dest** destination
|
||||||
|
|
||||||
|
.. c:function:: void glm_mat4x3_scale(mat4x3 m, float s)
|
||||||
|
|
||||||
|
multiply matrix with scalar
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
| *[in, out]* **m** matrix
|
||||||
|
| *[in]* **s** scalar
|
||||||
@@ -3,30 +3,30 @@
|
|||||||
Troubleshooting
|
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
|
Follow these topics
|
||||||
|
|
||||||
Memory Allocation:
|
Memory Allocation:
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
Again, **cglm** doesn't alloc any memory on heap.
|
Recall that **cglm** does not alloc any memory on the heap.
|
||||||
cglm functions works like memcpy; it copies data from src,
|
cglm functions work like memcpy; they copy data from src,
|
||||||
makes calculations then copy the result to dest.
|
make calculations, then copy the result to dest.
|
||||||
|
|
||||||
You are responsible for allocation of **src** and **dest** parameters.
|
You are responsible for allocation of **src** and **dest** parameters.
|
||||||
|
|
||||||
Alignment:
|
Alignment:
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
**vec4** and **mat4** types requires 16 byte alignment.
|
**vec4** and **mat4** types require 16 byte alignment.
|
||||||
These types are marked with align attribute to let compiler know about this
|
These types are marked with the align attribute to let the compiler know about this
|
||||||
requirement.
|
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"**
|
**"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
|
.. code-block:: c
|
||||||
|
|
||||||
@@ -37,61 +37,61 @@ The alignment attribute has been commented for MSVC
|
|||||||
#endif.
|
#endif.
|
||||||
|
|
||||||
So MSVC may not know about alignment requirements when creating variables.
|
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,
|
doesn't throw the above error. So we may uncomment that line for Visual Studio 2017,
|
||||||
you may do it yourself.
|
you may do it yourself.
|
||||||
|
|
||||||
**This MSVC issue is still in TODOs.**
|
**This MSVC issue is still in TODOs.**
|
||||||
|
|
||||||
**UPDATE:** By starting v0.4.5 cglm provides an option to disable alignment requirement.
|
**UPDATE:** Starting with v0.4.5, cglm provides an option to disable the 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.
|
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:
|
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.
|
For example, you may have called a **glm_vec4_** function for a **vec3** data type.
|
||||||
It will try to write 32 byte but since **vec3** is 24 byte it should throw
|
It will try to write 32 bytes, but since **vec3** is 24 bytes, it should throw
|
||||||
memory access error or exit the app without saying anything.
|
a memory access error or exit the app without saying anything.
|
||||||
|
|
||||||
**UPDATE - IMPORTANT:**
|
**UPDATE - IMPORTANT:**
|
||||||
|
|
||||||
| On MSVC or some other compilers, if alignment is enabled (default) then double check alignment requirements if you got a crash.
|
| 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.
|
| If you send GLM_VEC4_ONE or similar macros directly to a function, it may crash.
|
||||||
| Because compiler may not apply alignment as defined on **typedef** to that macro while passing it (on stack) to a function.
|
| Because the compiler may not apply alignment as defined on **typedef** to that macro while passing it (on stack) to a function.
|
||||||
|
|
||||||
Wrong Results:
|
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**,
|
For instance if you use **glm_normalize()** or **glm_vec3_normalize()** for a **vec4**,
|
||||||
it will assume that passed param is **vec3** and will normalize it for **vec3**.
|
it will assume that the passed param is a **vec3**, and will normalize it for **vec3**.
|
||||||
Since you need to **vec4** to be normalized in your case, you will get wrong results.
|
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!
|
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
|
BAD_ACCESS : Thread 1: EXC_BAD_ACCESS (code=EXC_I386_GPFLT) or Similar Errors/Crashes
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
This is similar issue with alignment. For instance if you compiled **cglm** with
|
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
|
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,
|
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...
|
then you probably get **BAD ACCESS** or similar...
|
||||||
|
|
||||||
Because if you compile **cglm** with AVX it aligns **mat4** with 32 byte boundary,
|
Because if you compile **cglm** with AVX it aligns **mat4** with 32 byte boundary,
|
||||||
and your project aligns that as 16 byte boundary...
|
and your project aligns that as a 16 byte boundary...
|
||||||
|
|
||||||
Check alignment, supported vector extension or simd in **cglm** and linked projects...
|
Check alignment, supported vector extension, or simd in **cglm** and linked projects...
|
||||||
|
|
||||||
Other Issues?
|
Other Issues?
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ Functions:
|
|||||||
#. :c:func:`glm_vec2_normalize`
|
#. :c:func:`glm_vec2_normalize`
|
||||||
#. :c:func:`glm_vec2_normalize_to`
|
#. :c:func:`glm_vec2_normalize_to`
|
||||||
#. :c:func:`glm_vec2_rotate`
|
#. :c:func:`glm_vec2_rotate`
|
||||||
|
#. :c:func:`glm_vec2_center`
|
||||||
#. :c:func:`glm_vec2_distance2`
|
#. :c:func:`glm_vec2_distance2`
|
||||||
#. :c:func:`glm_vec2_distance`
|
#. :c:func:`glm_vec2_distance`
|
||||||
#. :c:func:`glm_vec2_maxv`
|
#. :c:func:`glm_vec2_maxv`
|
||||||
@@ -314,6 +315,15 @@ Functions documentation
|
|||||||
| *[in]* **axis** axis vector
|
| *[in]* **axis** axis vector
|
||||||
| *[out]* **dest** destination
|
| *[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)
|
.. c:function:: float glm_vec2_distance2(vec2 v1, vec2 v2)
|
||||||
|
|
||||||
squared distance between two vectors
|
squared distance between two vectors
|
||||||
|
|||||||
@@ -50,6 +50,14 @@ Functions documentation
|
|||||||
| *[in]* **val** value
|
| *[in]* **val** value
|
||||||
| *[out]* **dest** destination
|
| *[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)
|
.. c:function:: bool glm_vec3_eq(vec3 v, float val)
|
||||||
|
|
||||||
check if vector is equal to value (without epsilon)
|
check if vector is equal to value (without epsilon)
|
||||||
|
|||||||
245
include/cglm/aabb2d.h
Normal file
245
include/cglm/aabb2d.h
Normal file
@@ -0,0 +1,245 @@
|
|||||||
|
/*
|
||||||
|
* 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 "vec4.h"
|
||||||
|
#include "util.h"
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @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 gettng 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 gettng 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 miniumum 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_size(vec2 aabb[2]) {
|
||||||
|
return glm_vec2_distance(aabb[0], aabb[1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief radius of sphere which surrounds AABB
|
||||||
|
*
|
||||||
|
* @param[in] aabb bounding aabb
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
float
|
||||||
|
glm_aabb2d_radius(vec2 aabb[2]) {
|
||||||
|
return glm_aabb2d_size(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 */
|
||||||
|
|
||||||
@@ -19,14 +19,21 @@ extern "C" {
|
|||||||
#include "call/ivec3.h"
|
#include "call/ivec3.h"
|
||||||
#include "call/ivec4.h"
|
#include "call/ivec4.h"
|
||||||
#include "call/mat2.h"
|
#include "call/mat2.h"
|
||||||
|
#include "call/mat2x3.h"
|
||||||
|
#include "call/mat2x4.h"
|
||||||
#include "call/mat3.h"
|
#include "call/mat3.h"
|
||||||
|
#include "call/mat3x2.h"
|
||||||
|
#include "call/mat3x4.h"
|
||||||
#include "call/mat4.h"
|
#include "call/mat4.h"
|
||||||
|
#include "call/mat4x2.h"
|
||||||
|
#include "call/mat4x3.h"
|
||||||
#include "call/affine.h"
|
#include "call/affine.h"
|
||||||
#include "call/cam.h"
|
#include "call/cam.h"
|
||||||
#include "call/quat.h"
|
#include "call/quat.h"
|
||||||
#include "call/euler.h"
|
#include "call/euler.h"
|
||||||
#include "call/plane.h"
|
#include "call/plane.h"
|
||||||
#include "call/frustum.h"
|
#include "call/frustum.h"
|
||||||
|
#include "call/aabb2d.h"
|
||||||
#include "call/box.h"
|
#include "call/box.h"
|
||||||
#include "call/io.h"
|
#include "call/io.h"
|
||||||
#include "call/project.h"
|
#include "call/project.h"
|
||||||
|
|||||||
80
include/cglm/call/aabb2d.h
Normal file
80
include/cglm/call/aabb2d.h
Normal file
@@ -0,0 +1,80 @@
|
|||||||
|
/*
|
||||||
|
* 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"
|
||||||
|
|
||||||
|
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_size(vec2 aabb[2]);
|
||||||
|
|
||||||
|
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 */
|
||||||
|
|
||||||
|
|
||||||
@@ -49,6 +49,31 @@ CGLM_EXPORT
|
|||||||
void
|
void
|
||||||
glmc_euler_by_order(vec3 angles, glm_euler_seq axis, mat4 dest);
|
glmc_euler_by_order(vec3 angles, glm_euler_seq axis, mat4 dest);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_euler_xyz_quat(vec3 angles, versor dest);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_euler_xzy_quat(vec3 angles, versor dest);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_euler_yxz_quat(vec3 angles, versor dest);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_euler_yzx_quat(vec3 angles, versor dest);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_euler_zxy_quat(vec3 angles, versor dest);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_euler_zyx_quat(vec3 angles, versor dest);
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -53,6 +53,70 @@ CGLM_EXPORT
|
|||||||
void
|
void
|
||||||
glmc_ivec2_scale(ivec2 v, int s, ivec2 dest);
|
glmc_ivec2_scale(ivec2 v, int s, ivec2 dest);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_ivec2_addadd(ivec2 a, ivec2 b, ivec2 dest);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_ivec2_addadds(ivec2 a, int s, ivec2 dest);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_ivec2_subadd(ivec2 a, ivec2 b, ivec2 dest);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_ivec2_subadds(ivec2 a, int s, ivec2 dest);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_ivec2_muladd(ivec2 a, ivec2 b, ivec2 dest);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_ivec2_muladds(ivec2 a, int s, ivec2 dest);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_ivec2_maxadd(ivec2 a, ivec2 b, ivec2 dest);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_ivec2_minadd(ivec2 a, ivec2 b, ivec2 dest);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_ivec2_subsub(ivec2 a, ivec2 b, ivec2 dest);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_ivec2_subsubs(ivec2 a, int s, ivec2 dest);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_ivec2_addsub(ivec2 a, ivec2 b, ivec2 dest);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_ivec2_addsubs(ivec2 a, int s, ivec2 dest);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_ivec2_mulsub(ivec2 a, ivec2 b, ivec2 dest);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_ivec2_mulsubs(ivec2 a, int s, ivec2 dest);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_ivec2_maxsub(ivec2 a, ivec2 b, ivec2 dest);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_ivec2_minsub(ivec2 a, ivec2 b, ivec2 dest);
|
||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
int
|
int
|
||||||
glmc_ivec2_distance2(ivec2 a, ivec2 b);
|
glmc_ivec2_distance2(ivec2 a, ivec2 b);
|
||||||
@@ -61,6 +125,18 @@ CGLM_EXPORT
|
|||||||
float
|
float
|
||||||
glmc_ivec2_distance(ivec2 a, ivec2 b);
|
glmc_ivec2_distance(ivec2 a, ivec2 b);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_ivec2_fill(ivec2 v, int val);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
bool
|
||||||
|
glmc_ivec2_eq(ivec2 v, int val);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
bool
|
||||||
|
glmc_ivec2_eqv(ivec2 a, ivec2 b);
|
||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
void
|
void
|
||||||
glmc_ivec2_maxv(ivec2 a, ivec2 b, ivec2 dest);
|
glmc_ivec2_maxv(ivec2 a, ivec2 b, ivec2 dest);
|
||||||
|
|||||||
@@ -53,6 +53,70 @@ CGLM_EXPORT
|
|||||||
void
|
void
|
||||||
glmc_ivec3_scale(ivec3 v, int s, ivec3 dest);
|
glmc_ivec3_scale(ivec3 v, int s, ivec3 dest);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_ivec3_addadd(ivec3 a, ivec3 b, ivec3 dest);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_ivec3_addadds(ivec3 a, int s, ivec3 dest);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_ivec3_subadd(ivec3 a, ivec3 b, ivec3 dest);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_ivec3_subadds(ivec3 a, int s, ivec3 dest);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_ivec3_muladd(ivec3 a, ivec3 b, ivec3 dest);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_ivec3_muladds(ivec3 a, int s, ivec3 dest);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_ivec3_maxadd(ivec3 a, ivec3 b, ivec3 dest);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_ivec3_minadd(ivec3 a, ivec3 b, ivec3 dest);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_ivec3_subsub(ivec3 a, ivec3 b, ivec3 dest);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_ivec3_subsubs(ivec3 a, int s, ivec3 dest);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_ivec3_addsub(ivec3 a, ivec3 b, ivec3 dest);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_ivec3_addsubs(ivec3 a, int s, ivec3 dest);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_ivec3_mulsub(ivec3 a, ivec3 b, ivec3 dest);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_ivec3_mulsubs(ivec3 a, int s, ivec3 dest);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_ivec3_maxsub(ivec3 a, ivec3 b, ivec3 dest);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_ivec3_minsub(ivec3 a, ivec3 b, ivec3 dest);
|
||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
int
|
int
|
||||||
glmc_ivec3_distance2(ivec3 a, ivec3 b);
|
glmc_ivec3_distance2(ivec3 a, ivec3 b);
|
||||||
@@ -61,6 +125,18 @@ CGLM_EXPORT
|
|||||||
float
|
float
|
||||||
glmc_ivec3_distance(ivec3 a, ivec3 b);
|
glmc_ivec3_distance(ivec3 a, ivec3 b);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_ivec3_fill(ivec3 v, int val);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
bool
|
||||||
|
glmc_ivec3_eq(ivec3 v, int val);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
bool
|
||||||
|
glmc_ivec3_eqv(ivec3 a, ivec3 b);
|
||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
void
|
void
|
||||||
glmc_ivec3_maxv(ivec3 a, ivec3 b, ivec3 dest);
|
glmc_ivec3_maxv(ivec3 a, ivec3 b, ivec3 dest);
|
||||||
|
|||||||
@@ -53,6 +53,70 @@ CGLM_EXPORT
|
|||||||
void
|
void
|
||||||
glmc_ivec4_scale(ivec4 v, int s, ivec4 dest);
|
glmc_ivec4_scale(ivec4 v, int s, ivec4 dest);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_ivec4_addadd(ivec4 a, ivec4 b, ivec4 dest);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_ivec4_addadds(ivec4 a, int s, ivec4 dest);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_ivec4_subadd(ivec4 a, ivec4 b, ivec4 dest);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_ivec4_subadds(ivec4 a, int s, ivec4 dest);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_ivec4_muladd(ivec4 a, ivec4 b, ivec4 dest);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_ivec4_muladds(ivec4 a, int s, ivec4 dest);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_ivec4_maxadd(ivec4 a, ivec4 b, ivec4 dest);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_ivec4_minadd(ivec4 a, ivec4 b, ivec4 dest);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_ivec4_subsub(ivec4 a, ivec4 b, ivec4 dest);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_ivec4_subsubs(ivec4 a, int s, ivec4 dest);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_ivec4_addsub(ivec4 a, ivec4 b, ivec4 dest);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_ivec4_addsubs(ivec4 a, int s, ivec4 dest);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_ivec4_mulsub(ivec4 a, ivec4 b, ivec4 dest);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_ivec4_mulsubs(ivec4 a, int s, ivec4 dest);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_ivec4_maxsub(ivec4 a, ivec4 b, ivec4 dest);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_ivec4_minsub(ivec4 a, ivec4 b, ivec4 dest);
|
||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
int
|
int
|
||||||
glmc_ivec4_distance2(ivec4 a, ivec4 b);
|
glmc_ivec4_distance2(ivec4 a, ivec4 b);
|
||||||
|
|||||||
47
include/cglm/call/mat2x3.h
Normal file
47
include/cglm/call/mat2x3.h
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c), Recep Aslantas.
|
||||||
|
*
|
||||||
|
* MIT License (MIT), http://opensource.org/licenses/MIT
|
||||||
|
* Full license can be found in the LICENSE file
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef cglmc_mat2x3_h
|
||||||
|
#define cglmc_mat2x3_h
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "../cglm.h"
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_mat2x3_copy(mat2x3 mat, mat2x3 dest);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_mat2x3_zero(mat2x3 mat);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_mat2x3_make(float * __restrict src, mat2x3 dest);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_mat2x3_mul(mat2x3 m1, mat3x2 m2, mat2 dest);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_mat2x3_mulv(mat2x3 m, vec3 v, vec2 dest);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_mat2x3_transpose(mat2x3 m, mat3x2 dest);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_mat2x3_scale(mat2x3 m, float s);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif /* cglmc_mat2x3_h */
|
||||||
47
include/cglm/call/mat2x4.h
Normal file
47
include/cglm/call/mat2x4.h
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c), Recep Aslantas.
|
||||||
|
*
|
||||||
|
* MIT License (MIT), http://opensource.org/licenses/MIT
|
||||||
|
* Full license can be found in the LICENSE file
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef cglmc_mat2x4_h
|
||||||
|
#define cglmc_mat2x4_h
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "../cglm.h"
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_mat2x4_copy(mat2x4 mat, mat2x4 dest);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_mat2x4_zero(mat2x4 mat);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_mat2x4_make(float * __restrict src, mat2x4 dest);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_mat2x4_mul(mat2x4 m1, mat4x2 m2, mat2 dest);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_mat2x4_mulv(mat2x4 m, vec4 v, vec2 dest);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_mat2x4_transpose(mat2x4 m, mat4x2 dest);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_mat2x4_scale(mat2x4 m, float s);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif /* cglmc_mat2x4_h */
|
||||||
47
include/cglm/call/mat3x2.h
Normal file
47
include/cglm/call/mat3x2.h
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c), Recep Aslantas.
|
||||||
|
*
|
||||||
|
* MIT License (MIT), http://opensource.org/licenses/MIT
|
||||||
|
* Full license can be found in the LICENSE file
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef cglmc_mat3x2_h
|
||||||
|
#define cglmc_mat3x2_h
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "../cglm.h"
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_mat3x2_copy(mat3x2 mat, mat3x2 dest);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_mat3x2_zero(mat3x2 mat);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_mat3x2_make(float * __restrict src, mat3x2 dest);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_mat3x2_mul(mat3x2 m1, mat2x3 m2, mat3 dest);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_mat3x2_mulv(mat3x2 m, vec2 v, vec3 dest);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_mat3x2_transpose(mat3x2 m, mat2x3 dest);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_mat3x2_scale(mat3x2 m, float s);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif /* cglmc_mat3x2_h */
|
||||||
47
include/cglm/call/mat3x4.h
Normal file
47
include/cglm/call/mat3x4.h
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c), Recep Aslantas.
|
||||||
|
*
|
||||||
|
* MIT License (MIT), http://opensource.org/licenses/MIT
|
||||||
|
* Full license can be found in the LICENSE file
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef cglmc_mat3x4_h
|
||||||
|
#define cglmc_mat3x4_h
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "../cglm.h"
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_mat3x4_copy(mat3x4 mat, mat3x4 dest);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_mat3x4_zero(mat3x4 mat);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_mat3x4_make(float * __restrict src, mat3x4 dest);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_mat3x4_mul(mat3x4 m1, mat4x3 m2, mat3 dest);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_mat3x4_mulv(mat3x4 m, vec4 v, vec3 dest);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_mat3x4_transpose(mat3x4 m, mat4x3 dest);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_mat3x4_scale(mat3x4 m, float s);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif /* cglmc_mat3x4_h */
|
||||||
47
include/cglm/call/mat4x2.h
Normal file
47
include/cglm/call/mat4x2.h
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c), Recep Aslantas.
|
||||||
|
*
|
||||||
|
* MIT License (MIT), http://opensource.org/licenses/MIT
|
||||||
|
* Full license can be found in the LICENSE file
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef cglmc_mat4x2_h
|
||||||
|
#define cglmc_mat4x2_h
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "../cglm.h"
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_mat4x2_copy(mat4x2 mat, mat4x2 dest);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_mat4x2_zero(mat4x2 mat);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_mat4x2_make(float * __restrict src, mat4x2 dest);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_mat4x2_mul(mat4x2 m1, mat2x4 m2, mat4 dest);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_mat4x2_mulv(mat4x2 m, vec2 v, vec4 dest);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_mat4x2_transpose(mat4x2 m, mat2x4 dest);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_mat4x2_scale(mat4x2 m, float s);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif /* cglmc_mat4x2_h */
|
||||||
47
include/cglm/call/mat4x3.h
Normal file
47
include/cglm/call/mat4x3.h
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c), Recep Aslantas.
|
||||||
|
*
|
||||||
|
* MIT License (MIT), http://opensource.org/licenses/MIT
|
||||||
|
* Full license can be found in the LICENSE file
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef cglmc_mat4x3_h
|
||||||
|
#define cglmc_mat4x3_h
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "../cglm.h"
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_mat4x3_copy(mat4x3 mat, mat4x3 dest);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_mat4x3_zero(mat4x3 mat);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_mat4x3_make(float * __restrict src, mat4x3 dest);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_mat4x3_mul(mat4x3 m1, mat3x4 m2, mat4 dest);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_mat4x3_mulv(mat4x3 m, vec3 v, vec4 dest);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_mat4x3_transpose(mat4x3 m, mat3x4 dest);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_mat4x3_scale(mat4x3 m, float s);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif /* cglmc_mat4x3_h */
|
||||||
@@ -105,6 +105,30 @@ CGLM_EXPORT
|
|||||||
void
|
void
|
||||||
glmc_vec2_minadd(vec2 a, vec2 b, vec2 dest);
|
glmc_vec2_minadd(vec2 a, vec2 b, vec2 dest);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_vec2_subsub(vec2 a, vec2 b, vec2 dest);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_vec2_addsub(vec2 a, vec2 b, vec2 dest);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_vec2_mulsub(vec2 a, vec2 b, vec2 dest);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_vec2_mulsubs(vec2 a, float s, vec2 dest);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_vec2_maxsub(vec2 a, vec2 b, vec2 dest);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_vec2_minsub(vec2 a, vec2 b, vec2 dest);
|
||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
void
|
void
|
||||||
glmc_vec2_negate_to(vec2 v, vec2 dest);
|
glmc_vec2_negate_to(vec2 v, vec2 dest);
|
||||||
@@ -125,6 +149,10 @@ CGLM_EXPORT
|
|||||||
void
|
void
|
||||||
glmc_vec2_rotate(vec2 v, float angle, vec2 dest);
|
glmc_vec2_rotate(vec2 v, float angle, vec2 dest);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_vec2_center(vec2 a, vec2 b, vec2 dest);
|
||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
float
|
float
|
||||||
glmc_vec2_distance2(vec2 a, vec2 b);
|
glmc_vec2_distance2(vec2 a, vec2 b);
|
||||||
|
|||||||
@@ -132,6 +132,30 @@ CGLM_EXPORT
|
|||||||
void
|
void
|
||||||
glmc_vec3_minadd(vec3 a, vec3 b, vec3 dest);
|
glmc_vec3_minadd(vec3 a, vec3 b, vec3 dest);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_vec3_subsub(vec3 a, vec3 b, vec3 dest);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_vec3_addsub(vec3 a, vec3 b, vec3 dest);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_vec3_mulsub(vec3 a, vec3 b, vec3 dest);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_vec3_mulsubs(vec3 a, float s, vec3 dest);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_vec3_maxsub(vec3 a, vec3 b, vec3 dest);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_vec3_minsub(vec3 a, vec3 b, vec3 dest);
|
||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
void
|
void
|
||||||
glmc_vec3_negate(vec3 v);
|
glmc_vec3_negate(vec3 v);
|
||||||
|
|||||||
@@ -133,6 +133,30 @@ CGLM_EXPORT
|
|||||||
void
|
void
|
||||||
glmc_vec4_minadd(vec4 a, vec4 b, vec4 dest);
|
glmc_vec4_minadd(vec4 a, vec4 b, vec4 dest);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_vec4_subsub(vec4 a, vec4 b, vec4 dest);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_vec4_addsub(vec4 a, vec4 b, vec4 dest);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_vec4_mulsub(vec4 a, vec4 b, vec4 dest);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_vec4_mulsubs(vec4 a, float s, vec4 dest);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_vec4_maxsub(vec4 a, vec4 b, vec4 dest);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_vec4_minsub(vec4 a, vec4 b, vec4 dest);
|
||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
void
|
void
|
||||||
glmc_vec4_negate(vec4 v);
|
glmc_vec4_negate(vec4 v);
|
||||||
|
|||||||
@@ -16,14 +16,21 @@
|
|||||||
#include "ivec3.h"
|
#include "ivec3.h"
|
||||||
#include "ivec4.h"
|
#include "ivec4.h"
|
||||||
#include "mat4.h"
|
#include "mat4.h"
|
||||||
|
#include "mat4x2.h"
|
||||||
|
#include "mat4x3.h"
|
||||||
#include "mat3.h"
|
#include "mat3.h"
|
||||||
|
#include "mat3x2.h"
|
||||||
|
#include "mat3x4.h"
|
||||||
#include "mat2.h"
|
#include "mat2.h"
|
||||||
|
#include "mat2x3.h"
|
||||||
|
#include "mat2x4.h"
|
||||||
#include "affine.h"
|
#include "affine.h"
|
||||||
#include "cam.h"
|
#include "cam.h"
|
||||||
#include "frustum.h"
|
#include "frustum.h"
|
||||||
#include "quat.h"
|
#include "quat.h"
|
||||||
#include "euler.h"
|
#include "euler.h"
|
||||||
#include "plane.h"
|
#include "plane.h"
|
||||||
|
#include "aabb2d.h"
|
||||||
#include "box.h"
|
#include "box.h"
|
||||||
#include "color.h"
|
#include "color.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|||||||
@@ -30,6 +30,12 @@
|
|||||||
CGLM_INLINE void glm_euler_by_order(vec3 angles,
|
CGLM_INLINE void glm_euler_by_order(vec3 angles,
|
||||||
glm_euler_seq ord,
|
glm_euler_seq ord,
|
||||||
mat4 dest);
|
mat4 dest);
|
||||||
|
CGLM_INLINE void glm_euler_xyz_quat(vec3 angles, versor dest);
|
||||||
|
CGLM_INLINE void glm_euler_xzy_quat(vec3 angles, versor dest);
|
||||||
|
CGLM_INLINE void glm_euler_yxz_quat(vec3 angles, versor dest);
|
||||||
|
CGLM_INLINE void glm_euler_yzx_quat(vec3 angles, versor dest);
|
||||||
|
CGLM_INLINE void glm_euler_zxy_quat(vec3 angles, versor dest);
|
||||||
|
CGLM_INLINE void glm_euler_zyx_quat(vec3 angles, versor dest);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef cglm_euler_h
|
#ifndef cglm_euler_h
|
||||||
@@ -37,6 +43,47 @@
|
|||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
|
||||||
|
#ifdef CGLM_FORCE_LEFT_HANDED
|
||||||
|
# include "handed/euler_to_quat_lh.h"
|
||||||
|
#else
|
||||||
|
# include "handed/euler_to_quat_rh.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef CGLM_CLIPSPACE_INCLUDE_ALL
|
||||||
|
# if CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_LH_ZO
|
||||||
|
# include "clipspace/ortho_lh_zo.h"
|
||||||
|
# include "clipspace/persp_lh_zo.h"
|
||||||
|
# include "clipspace/view_lh_zo.h"
|
||||||
|
# elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_LH_NO
|
||||||
|
# include "clipspace/ortho_lh_no.h"
|
||||||
|
# include "clipspace/persp_lh_no.h"
|
||||||
|
# include "clipspace/view_lh_no.h"
|
||||||
|
# elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_RH_ZO
|
||||||
|
# include "clipspace/ortho_rh_zo.h"
|
||||||
|
# include "clipspace/persp_rh_zo.h"
|
||||||
|
# include "clipspace/view_rh_zo.h"
|
||||||
|
# elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_RH_NO
|
||||||
|
# include "clipspace/ortho_rh_no.h"
|
||||||
|
# include "clipspace/persp_rh_no.h"
|
||||||
|
# include "clipspace/view_rh_no.h"
|
||||||
|
# endif
|
||||||
|
#else
|
||||||
|
# include "clipspace/ortho_lh_zo.h"
|
||||||
|
# include "clipspace/persp_lh_zo.h"
|
||||||
|
# include "clipspace/ortho_lh_no.h"
|
||||||
|
# include "clipspace/persp_lh_no.h"
|
||||||
|
# include "clipspace/ortho_rh_zo.h"
|
||||||
|
# include "clipspace/persp_rh_zo.h"
|
||||||
|
# include "clipspace/ortho_rh_no.h"
|
||||||
|
# include "clipspace/persp_rh_no.h"
|
||||||
|
# include "clipspace/view_lh_zo.h"
|
||||||
|
# include "clipspace/view_lh_no.h"
|
||||||
|
# include "clipspace/view_rh_zo.h"
|
||||||
|
# include "clipspace/view_rh_no.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* if you have axis order like vec3 orderVec = [0, 1, 2] or [0, 2, 1]...
|
* if you have axis order like vec3 orderVec = [0, 1, 2] or [0, 2, 1]...
|
||||||
* vector then you can convert it to this enum by doing this:
|
* vector then you can convert it to this enum by doing this:
|
||||||
@@ -188,7 +235,6 @@ glm_euler_xzy(vec3 angles, mat4 dest) {
|
|||||||
dest[3][3] = 1.0f;
|
dest[3][3] = 1.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief build rotation matrix from euler angles
|
* @brief build rotation matrix from euler angles
|
||||||
*
|
*
|
||||||
@@ -448,4 +494,108 @@ glm_euler_by_order(vec3 angles, glm_euler_seq ord, mat4 dest) {
|
|||||||
dest[3][3] = 1.0f;
|
dest[3][3] = 1.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief creates NEW quaternion using rotation angles and does
|
||||||
|
* rotations in x y z order (roll pitch yaw)
|
||||||
|
*
|
||||||
|
* @param[in] angles angles x y z (radians)
|
||||||
|
* @param[out] dest quaternion
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
void
|
||||||
|
glm_euler_xyz_quat(vec3 angles, versor dest) {
|
||||||
|
#ifdef CGLM_FORCE_LEFT_HANDED
|
||||||
|
glm_euler_xyz_quat_lh(angles, dest);
|
||||||
|
#else
|
||||||
|
glm_euler_xyz_quat_rh(angles, dest);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief creates NEW quaternion using rotation angles and does
|
||||||
|
* rotations in x z y order (roll yaw pitch)
|
||||||
|
*
|
||||||
|
* @param[in] angles angles x y z (radians)
|
||||||
|
* @param[out] dest quaternion
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
void
|
||||||
|
glm_euler_xzy_quat(vec3 angles, versor dest) {
|
||||||
|
#ifdef CGLM_FORCE_LEFT_HANDED
|
||||||
|
glm_euler_xzy_quat_lh(angles, dest);
|
||||||
|
#else
|
||||||
|
glm_euler_xzy_quat_rh(angles, dest);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief creates NEW quaternion using rotation angles and does
|
||||||
|
* rotations in y x z order (pitch roll yaw)
|
||||||
|
*
|
||||||
|
* @param[in] angles angles x y z (radians)
|
||||||
|
* @param[out] dest quaternion
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
void
|
||||||
|
glm_euler_yxz_quat(vec3 angles, versor dest) {
|
||||||
|
#ifdef CGLM_FORCE_LEFT_HANDED
|
||||||
|
glm_euler_yxz_quat_lh(angles, dest);
|
||||||
|
#else
|
||||||
|
glm_euler_yxz_quat_rh(angles, dest);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief creates NEW quaternion using rotation angles and does
|
||||||
|
* rotations in y z x order (pitch yaw roll)
|
||||||
|
*
|
||||||
|
* @param[in] angles angles x y z (radians)
|
||||||
|
* @param[out] dest quaternion
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
void
|
||||||
|
glm_euler_yzx_quat(vec3 angles, versor dest) {
|
||||||
|
#ifdef CGLM_FORCE_LEFT_HANDED
|
||||||
|
glm_euler_yzx_quat_lh(angles, dest);
|
||||||
|
#else
|
||||||
|
glm_euler_yzx_quat_rh(angles, dest);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief creates NEW quaternion using rotation angles and does
|
||||||
|
* rotations in z x y order (yaw roll pitch)
|
||||||
|
*
|
||||||
|
* @param[in] angles angles x y z (radians)
|
||||||
|
* @param[out] dest quaternion
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
void
|
||||||
|
glm_euler_zxy_quat(vec3 angles, versor dest) {
|
||||||
|
#ifdef CGLM_FORCE_LEFT_HANDED
|
||||||
|
glm_euler_zxy_quat_lh(angles, dest);
|
||||||
|
#else
|
||||||
|
glm_euler_zxy_quat_rh(angles, dest);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief creates NEW quaternion using rotation angles and does
|
||||||
|
* rotations in z y x order (yaw pitch roll)
|
||||||
|
*
|
||||||
|
* @param[in] angles angles x y z (radians)
|
||||||
|
* @param[out] dest quaternion
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
void
|
||||||
|
glm_euler_zyx_quat(vec3 angles, versor dest) {
|
||||||
|
#ifdef CGLM_FORCE_LEFT_HANDED
|
||||||
|
glm_euler_zyx_quat_lh(angles, dest);
|
||||||
|
#else
|
||||||
|
glm_euler_zyx_quat_rh(angles, dest);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif /* cglm_euler_h */
|
#endif /* cglm_euler_h */
|
||||||
|
|||||||
167
include/cglm/handed/euler_to_quat_lh.h
Normal file
167
include/cglm/handed/euler_to_quat_lh.h
Normal file
@@ -0,0 +1,167 @@
|
|||||||
|
/*
|
||||||
|
* 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_euler_xyz_quat_lh(vec3 angles, versor dest);
|
||||||
|
CGLM_INLINE void glm_euler_xzy_quat_lh(vec3 angles, versor dest);
|
||||||
|
CGLM_INLINE void glm_euler_yxz_quat_lh(vec3 angles, versor dest);
|
||||||
|
CGLM_INLINE void glm_euler_yzx_quat_lh(vec3 angles, versor dest);
|
||||||
|
CGLM_INLINE void glm_euler_zxy_quat_lh(vec3 angles, versor dest);
|
||||||
|
CGLM_INLINE void glm_euler_zyx_quat_lh(vec3 angles, versor dest);
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
Things to note:
|
||||||
|
The only difference between euler to quat rh vs lh is that the zsin part is negative
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef cglm_euler_to_quat_lh_h
|
||||||
|
#define cglm_euler_to_quat_lh_h
|
||||||
|
|
||||||
|
#include "../common.h"
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief creates NEW quaternion using rotation angles and does
|
||||||
|
* rotations in x y z order in left hand (roll pitch yaw)
|
||||||
|
*
|
||||||
|
* @param[in] angles angles x y z (radians)
|
||||||
|
* @param[out] dest quaternion
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
void
|
||||||
|
glm_euler_xyz_quat_lh(vec3 angles, versor dest) {
|
||||||
|
float xc, yc, zc,
|
||||||
|
xs, ys, zs;
|
||||||
|
|
||||||
|
xs = sinf(angles[0] * 0.5f); xc = cosf(angles[0] * 0.5f);
|
||||||
|
ys = sinf(angles[1] * 0.5f); yc = cosf(angles[1] * 0.5f);
|
||||||
|
zs = -sinf(angles[2] * 0.5f); zc = cosf(angles[2] * 0.5f);
|
||||||
|
|
||||||
|
dest[0] = xc * ys * zs + xs * yc * zc;
|
||||||
|
dest[1] = xc * ys * zc - xs * yc * zs;
|
||||||
|
dest[2] = xc * yc * zs + xs * ys * zc;
|
||||||
|
dest[3] = xc * yc * zc - xs * ys * zs;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief creates NEW quaternion using rotation angles and does
|
||||||
|
* rotations in x z y order in left hand (roll yaw pitch)
|
||||||
|
*
|
||||||
|
* @param[in] angles angles x y z (radians)
|
||||||
|
* @param[out] dest quaternion
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
void
|
||||||
|
glm_euler_xzy_quat_lh(vec3 angles, versor dest) {
|
||||||
|
float xc, yc, zc,
|
||||||
|
xs, ys, zs;
|
||||||
|
|
||||||
|
xs = sinf(angles[0] * 0.5f); xc = cosf(angles[0] * 0.5f);
|
||||||
|
ys = sinf(angles[1] * 0.5f); yc = cosf(angles[1] * 0.5f);
|
||||||
|
zs = -sinf(angles[2] * 0.5f); zc = cosf(angles[2] * 0.5f);
|
||||||
|
|
||||||
|
dest[0] = -xc * zs * ys + xs * zc * yc;
|
||||||
|
dest[1] = xc * zc * ys - xs * zs * yc;
|
||||||
|
dest[2] = xc * zs * yc + xs * zc * ys;
|
||||||
|
dest[3] = xc * zc * yc + xs * zs * ys;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief creates NEW quaternion using rotation angles and does
|
||||||
|
* rotations in y x z order in left hand (pitch roll yaw)
|
||||||
|
*
|
||||||
|
* @param[in] angles angles x y z (radians)
|
||||||
|
* @param[out] dest quaternion
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
void
|
||||||
|
glm_euler_yxz_quat_lh(vec3 angles, versor dest) {
|
||||||
|
float xc, yc, zc,
|
||||||
|
xs, ys, zs;
|
||||||
|
|
||||||
|
xs = sinf(angles[0] * 0.5f); xc = cosf(angles[0] * 0.5f);
|
||||||
|
ys = sinf(angles[1] * 0.5f); yc = cosf(angles[1] * 0.5f);
|
||||||
|
zs = -sinf(angles[2] * 0.5f); zc = cosf(angles[2] * 0.5f);
|
||||||
|
|
||||||
|
dest[0] = yc * xs * zc + ys * xc * zs;
|
||||||
|
dest[1] = -yc * xs * zs + ys * xc * zc;
|
||||||
|
dest[2] = yc * xc * zs - ys * xs * zc;
|
||||||
|
dest[3] = yc * xc * zc + ys * xs * zs;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief creates NEW quaternion using rotation angles and does
|
||||||
|
* rotations in y z x order in left hand (pitch yaw roll)
|
||||||
|
*
|
||||||
|
* @param[in] angles angles x y z (radians)
|
||||||
|
* @param[out] dest quaternion
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
void
|
||||||
|
glm_euler_yzx_quat_lh(vec3 angles, versor dest) {
|
||||||
|
float xc, yc, zc,
|
||||||
|
xs, ys, zs;
|
||||||
|
|
||||||
|
xs = sinf(angles[0] * 0.5f); xc = cosf(angles[0] * 0.5f);
|
||||||
|
ys = sinf(angles[1] * 0.5f); yc = cosf(angles[1] * 0.5f);
|
||||||
|
zs = -sinf(angles[2] * 0.5f); zc = cosf(angles[2] * 0.5f);
|
||||||
|
|
||||||
|
dest[0] = yc * zc * xs + ys * zs * xc;
|
||||||
|
dest[1] = yc * zs * xs + ys * zc * xc;
|
||||||
|
dest[2] = yc * zs * xc - ys * zc * xs;
|
||||||
|
dest[3] = yc * zc * xc - ys * zs * xs;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief creates NEW quaternion using rotation angles and does
|
||||||
|
* rotations in z x y order in left hand (yaw roll pitch)
|
||||||
|
*
|
||||||
|
* @param[in] angles angles x y z (radians)
|
||||||
|
* @param[out] dest quaternion
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
void
|
||||||
|
glm_euler_zxy_quat_lh(vec3 angles, versor dest) {
|
||||||
|
float xc, yc, zc,
|
||||||
|
xs, ys, zs;
|
||||||
|
|
||||||
|
xs = sinf(angles[0] * 0.5f); xc = cosf(angles[0] * 0.5f);
|
||||||
|
ys = sinf(angles[1] * 0.5f); yc = cosf(angles[1] * 0.5f);
|
||||||
|
zs = -sinf(angles[2] * 0.5f); zc = cosf(angles[2] * 0.5f);
|
||||||
|
|
||||||
|
dest[0] = zc * xs * yc - zs * xc * ys;
|
||||||
|
dest[1] = zc * xc * ys + zs * xs * yc;
|
||||||
|
dest[2] = zc * xs * ys + zs * xc * yc;
|
||||||
|
dest[3] = zc * xc * yc - zs * xs * ys;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief creates NEW quaternion using rotation angles and does
|
||||||
|
* rotations in z y x order in left hand (yaw pitch roll)
|
||||||
|
*
|
||||||
|
* @param[in] angles angles x y z (radians)
|
||||||
|
* @param[out] dest quaternion
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
void
|
||||||
|
glm_euler_zyx_quat_lh(vec3 angles, versor dest) {
|
||||||
|
float xc, yc, zc,
|
||||||
|
xs, ys, zs;
|
||||||
|
|
||||||
|
xs = sinf(angles[0] * 0.5f); xc = cosf(angles[0] * 0.5f);
|
||||||
|
ys = sinf(angles[1] * 0.5f); yc = cosf(angles[1] * 0.5f);
|
||||||
|
zs = -sinf(angles[2] * 0.5f); zc = cosf(angles[2] * 0.5f);
|
||||||
|
|
||||||
|
dest[0] = zc * yc * xs - zs * ys * xc;
|
||||||
|
dest[1] = zc * ys * xc + zs * yc * xs;
|
||||||
|
dest[2] = -zc * ys * xs + zs * yc * xc;
|
||||||
|
dest[3] = zc * yc * xc + zs * ys * xs;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /*cglm_euler_to_quat_lh_h*/
|
||||||
170
include/cglm/handed/euler_to_quat_rh.h
Normal file
170
include/cglm/handed/euler_to_quat_rh.h
Normal file
@@ -0,0 +1,170 @@
|
|||||||
|
/*
|
||||||
|
* 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_euler_xyz_quat_rh(vec3 angles, versor dest);
|
||||||
|
CGLM_INLINE void glm_euler_xzy_quat_rh(vec3 angles, versor dest);
|
||||||
|
CGLM_INLINE void glm_euler_yxz_quat_rh(vec3 angles, versor dest);
|
||||||
|
CGLM_INLINE void glm_euler_yzx_quat_rh(vec3 angles, versor dest);
|
||||||
|
CGLM_INLINE void glm_euler_zxy_quat_rh(vec3 angles, versor dest);
|
||||||
|
CGLM_INLINE void glm_euler_zyx_quat_rh(vec3 angles, versor dest);
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
Things to note:
|
||||||
|
The only difference between euler to quat rh vs lh is that the zsin part is negative
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef cglm_euler_to_quat_rh_h
|
||||||
|
#define cglm_euler_to_quat_rh_h
|
||||||
|
|
||||||
|
#include "../common.h"
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief creates NEW quaternion using rotation angles and does
|
||||||
|
* rotations in x y z order in right hand (roll pitch yaw)
|
||||||
|
*
|
||||||
|
* @param[in] angles angles x y z (radians)
|
||||||
|
* @param[out] dest quaternion
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
void
|
||||||
|
glm_euler_xyz_quat_rh(vec3 angles, versor dest) {
|
||||||
|
float xc, yc, zc,
|
||||||
|
xs, ys, zs;
|
||||||
|
|
||||||
|
xs = sinf(angles[0] * 0.5f); xc = cosf(angles[0] * 0.5f);
|
||||||
|
ys = sinf(angles[1] * 0.5f); yc = cosf(angles[1] * 0.5f);
|
||||||
|
zs = sinf(angles[2] * 0.5f); zc = cosf(angles[2] * 0.5f);
|
||||||
|
|
||||||
|
dest[0] = xc * ys * zs + xs * yc * zc;
|
||||||
|
dest[1] = xc * ys * zc - xs * yc * zs;
|
||||||
|
dest[2] = xc * yc * zs + xs * ys * zc;
|
||||||
|
dest[3] = xc * yc * zc - xs * ys * zs;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief creates NEW quaternion using rotation angles and does
|
||||||
|
* rotations in x z y order in right hand (roll yaw pitch)
|
||||||
|
*
|
||||||
|
* @param[in] angles angles x y z (radians)
|
||||||
|
* @param[out] dest quaternion
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
void
|
||||||
|
glm_euler_xzy_quat_rh(vec3 angles, versor dest) {
|
||||||
|
float xc, yc, zc,
|
||||||
|
xs, ys, zs;
|
||||||
|
|
||||||
|
xs = sinf(angles[0] * 0.5f); xc = cosf(angles[0] * 0.5f);
|
||||||
|
ys = sinf(angles[1] * 0.5f); yc = cosf(angles[1] * 0.5f);
|
||||||
|
zs = sinf(angles[2] * 0.5f); zc = cosf(angles[2] * 0.5f);
|
||||||
|
|
||||||
|
dest[0] = -xc * zs * ys + xs * zc * yc;
|
||||||
|
dest[1] = xc * zc * ys - xs * zs * yc;
|
||||||
|
dest[2] = xc * zs * yc + xs * zc * ys;
|
||||||
|
dest[3] = xc * zc * yc + xs * zs * ys;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief creates NEW quaternion using rotation angles and does
|
||||||
|
* rotations in y x z order in right hand (pitch roll yaw)
|
||||||
|
*
|
||||||
|
* @param[in] angles angles x y z (radians)
|
||||||
|
* @param[out] dest quaternion
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
void
|
||||||
|
glm_euler_yxz_quat_rh(vec3 angles, versor dest) {
|
||||||
|
float xc, yc, zc,
|
||||||
|
xs, ys, zs;
|
||||||
|
|
||||||
|
xs = sinf(angles[0] * 0.5f); xc = cosf(angles[0] * 0.5f);
|
||||||
|
ys = sinf(angles[1] * 0.5f); yc = cosf(angles[1] * 0.5f);
|
||||||
|
zs = sinf(angles[2] * 0.5f); zc = cosf(angles[2] * 0.5f);
|
||||||
|
|
||||||
|
dest[0] = yc * xs * zc + ys * xc * zs;
|
||||||
|
dest[1] = -yc * xs * zs + ys * xc * zc;
|
||||||
|
dest[2] = yc * xc * zs - ys * xs * zc;
|
||||||
|
dest[3] = yc * xc * zc + ys * xs * zs;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief creates NEW quaternion using rotation angles and does
|
||||||
|
* rotations in y z x order in right hand (pitch yaw roll)
|
||||||
|
*
|
||||||
|
* @param[in] angles angles x y z (radians)
|
||||||
|
* @param[out] dest quaternion
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
void
|
||||||
|
glm_euler_yzx_quat_rh(vec3 angles, versor dest) {
|
||||||
|
float xc, yc, zc,
|
||||||
|
xs, ys, zs;
|
||||||
|
|
||||||
|
xs = sinf(angles[0] * 0.5f); xc = cosf(angles[0] * 0.5f);
|
||||||
|
ys = sinf(angles[1] * 0.5f); yc = cosf(angles[1] * 0.5f);
|
||||||
|
zs = sinf(angles[2] * 0.5f); zc = cosf(angles[2] * 0.5f);
|
||||||
|
|
||||||
|
dest[0] = yc * zc * xs + ys * zs * xc;
|
||||||
|
dest[1] = yc * zs * xs + ys * zc * xc;
|
||||||
|
dest[2] = yc * zs * xc - ys * zc * xs;
|
||||||
|
dest[3] = yc * zc * xc - ys * zs * xs;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief creates NEW quaternion using rotation angles and does
|
||||||
|
* rotations in z x y order in right hand (yaw roll pitch)
|
||||||
|
*
|
||||||
|
* @param[in] angles angles x y z (radians)
|
||||||
|
* @param[out] dest quaternion
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
void
|
||||||
|
glm_euler_zxy_quat_rh(vec3 angles, versor dest) {
|
||||||
|
float xc, yc, zc,
|
||||||
|
xs, ys, zs;
|
||||||
|
|
||||||
|
xs = sinf(angles[0] * 0.5f); xc = cosf(angles[0] * 0.5f);
|
||||||
|
ys = sinf(angles[1] * 0.5f); yc = cosf(angles[1] * 0.5f);
|
||||||
|
zs = sinf(angles[2] * 0.5f); zc = cosf(angles[2] * 0.5f);
|
||||||
|
|
||||||
|
dest[0] = zc * xs * yc - zs * xc * ys;
|
||||||
|
dest[1] = zc * xc * ys + zs * xs * yc;
|
||||||
|
dest[2] = zc * xs * ys + zs * xc * yc;
|
||||||
|
dest[3] = zc * xc * yc - zs * xs * ys;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief creates NEW quaternion using rotation angles and does
|
||||||
|
* rotations in z y x order in right hand (yaw pitch roll)
|
||||||
|
*
|
||||||
|
* @param[in] angles angles x y z (radians)
|
||||||
|
* @param[out] dest quaternion
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
void
|
||||||
|
glm_euler_zyx_quat_rh(vec3 angles, versor dest) {
|
||||||
|
float xc, yc, zc,
|
||||||
|
xs, ys, zs;
|
||||||
|
|
||||||
|
xs = sinf(angles[0] * 0.5f); xc = cosf(angles[0] * 0.5f);
|
||||||
|
ys = sinf(angles[1] * 0.5f); yc = cosf(angles[1] * 0.5f);
|
||||||
|
zs = sinf(angles[2] * 0.5f); zc = cosf(angles[2] * 0.5f);
|
||||||
|
|
||||||
|
dest[0] = zc * yc * xs - zs * ys * xc;
|
||||||
|
dest[1] = zc * ys * xc + zs * yc * xs;
|
||||||
|
dest[2] = -zc * ys * xs + zs * yc * xc;
|
||||||
|
dest[3] = zc * yc * xc + zs * ys * xs;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#endif /*cglm_euler_to_quat_rh_h*/
|
||||||
@@ -10,8 +10,11 @@
|
|||||||
CGLM_INLINE void glm_mat4_print(mat4 matrix, FILE *ostream);
|
CGLM_INLINE void glm_mat4_print(mat4 matrix, FILE *ostream);
|
||||||
CGLM_INLINE void glm_mat3_print(mat3 matrix, FILE *ostream);
|
CGLM_INLINE void glm_mat3_print(mat3 matrix, FILE *ostream);
|
||||||
CGLM_INLINE void glm_vec4_print(vec4 vec, FILE *ostream);
|
CGLM_INLINE void glm_vec4_print(vec4 vec, FILE *ostream);
|
||||||
|
CGLM_INLINE void glm_ivec4_print(ivec4 vec, FILE *ostream);
|
||||||
CGLM_INLINE void glm_vec3_print(vec3 vec, FILE *ostream);
|
CGLM_INLINE void glm_vec3_print(vec3 vec, FILE *ostream);
|
||||||
CGLM_INLINE void glm_ivec3_print(ivec3 vec, FILE *ostream);
|
CGLM_INLINE void glm_ivec3_print(ivec3 vec, FILE *ostream);
|
||||||
|
CGLM_INLINE void glm_vec2_print(vec2 vec, FILE *ostream);
|
||||||
|
CGLM_INLINE void glm_ivec2_print(ivec2 vec, FILE *ostream);
|
||||||
CGLM_INLINE void glm_versor_print(versor vec, FILE *ostream);
|
CGLM_INLINE void glm_versor_print(versor vec, FILE *ostream);
|
||||||
CGLM_INLINE void glm_arch_print(FILE *ostream);
|
CGLM_INLINE void glm_arch_print(FILE *ostream);
|
||||||
*/
|
*/
|
||||||
@@ -261,6 +264,24 @@ glm_vec4_print(vec4 vec,
|
|||||||
#undef m
|
#undef m
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CGLM_INLINE
|
||||||
|
void
|
||||||
|
glm_ivec4_print(ivec4 vec,
|
||||||
|
FILE * __restrict ostream) {
|
||||||
|
int i;
|
||||||
|
|
||||||
|
#define m 4
|
||||||
|
|
||||||
|
fprintf(ostream, "Vector (int%d): " CGLM_PRINT_COLOR "\n (", m);
|
||||||
|
|
||||||
|
for (i = 0; i < m; i++)
|
||||||
|
fprintf(ostream, " % d", vec[i]);
|
||||||
|
|
||||||
|
fprintf(ostream, " )" CGLM_PRINT_COLOR_RESET "\n\n");
|
||||||
|
|
||||||
|
#undef m
|
||||||
|
}
|
||||||
|
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
void
|
void
|
||||||
glm_vec3_print(vec3 vec,
|
glm_vec3_print(vec3 vec,
|
||||||
@@ -323,6 +344,24 @@ glm_vec2_print(vec2 vec,
|
|||||||
#undef m
|
#undef m
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CGLM_INLINE
|
||||||
|
void
|
||||||
|
glm_ivec2_print(ivec2 vec,
|
||||||
|
FILE * __restrict ostream) {
|
||||||
|
int i;
|
||||||
|
|
||||||
|
#define m 2
|
||||||
|
|
||||||
|
fprintf(ostream, "Vector (int%d): " CGLM_PRINT_COLOR "\n (", m);
|
||||||
|
|
||||||
|
for (i = 0; i < m; i++)
|
||||||
|
fprintf(ostream, " % d", vec[i]);
|
||||||
|
|
||||||
|
fprintf(ostream, " )" CGLM_PRINT_COLOR_RESET "\n\n");
|
||||||
|
|
||||||
|
#undef m
|
||||||
|
}
|
||||||
|
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
void
|
void
|
||||||
glm_versor_print(versor vec,
|
glm_versor_print(versor vec,
|
||||||
@@ -387,9 +426,11 @@ glm_aabb_print(vec3 bbox[2],
|
|||||||
#define glm_mat3_print(v, s) (void)v; (void)s;
|
#define glm_mat3_print(v, s) (void)v; (void)s;
|
||||||
#define glm_mat2_print(v, s) (void)v; (void)s;
|
#define glm_mat2_print(v, s) (void)v; (void)s;
|
||||||
#define glm_vec4_print(v, s) (void)v; (void)s;
|
#define glm_vec4_print(v, s) (void)v; (void)s;
|
||||||
|
#define glm_ivec4_print(v, s) (void)v; (void)s;
|
||||||
#define glm_vec3_print(v, s) (void)v; (void)s;
|
#define glm_vec3_print(v, s) (void)v; (void)s;
|
||||||
#define glm_ivec3_print(v, s) (void)v; (void)s;
|
#define glm_ivec3_print(v, s) (void)v; (void)s;
|
||||||
#define glm_vec2_print(v, s) (void)v; (void)s;
|
#define glm_vec2_print(v, s) (void)v; (void)s;
|
||||||
|
#define glm_ivec2_print(v, s) (void)v; (void)s;
|
||||||
#define glm_versor_print(v, s) (void)v; (void)s;
|
#define glm_versor_print(v, s) (void)v; (void)s;
|
||||||
#define glm_aabb_print(v, t, s) (void)v; (void)t; (void)s;
|
#define glm_aabb_print(v, t, s) (void)v; (void)t; (void)s;
|
||||||
#define glm_arch_print(s) (void)s;
|
#define glm_arch_print(s) (void)s;
|
||||||
|
|||||||
@@ -23,8 +23,27 @@
|
|||||||
CGLM_INLINE void glm_ivec2_subs(ivec2 v, int s, ivec2 dest)
|
CGLM_INLINE void glm_ivec2_subs(ivec2 v, int s, ivec2 dest)
|
||||||
CGLM_INLINE void glm_ivec2_mul(ivec2 a, ivec2 b, ivec2 dest)
|
CGLM_INLINE void glm_ivec2_mul(ivec2 a, ivec2 b, ivec2 dest)
|
||||||
CGLM_INLINE void glm_ivec2_scale(ivec2 v, int s, ivec2 dest)
|
CGLM_INLINE void glm_ivec2_scale(ivec2 v, int s, ivec2 dest)
|
||||||
|
CGLM_INLINE void glm_ivec2_addadd(ivec2 a, ivec2 b, ivec2 dest)
|
||||||
|
CGLM_INLINE void glm_ivec2_addadds(ivec2 a, int s, ivec2 dest)
|
||||||
|
CGLM_INLINE void glm_ivec2_subadd(ivec2 a, ivec2 b, ivec2 dest)
|
||||||
|
CGLM_INLINE void glm_ivec2_subadds(ivec2 a, int s, ivec2 dest)
|
||||||
|
CGLM_INLINE void glm_ivec2_muladd(ivec2 a, ivec2 b, ivec2 dest)
|
||||||
|
CGLM_INLINE void glm_ivec2_muladds(ivec2 a, int s, ivec2 dest)
|
||||||
|
CGLM_INLINE void glm_ivec2_maxadd(ivec2 a, ivec2 b, ivec2 dest)
|
||||||
|
CGLM_INLINE void glm_ivec2_minadd(ivec2 a, ivec2 b, ivec2 dest)
|
||||||
|
CGLM_INLINE void glm_ivec2_subsub(ivec2 a, ivec2 b, ivec2 dest)
|
||||||
|
CGLM_INLINE void glm_ivec2_subsubs(ivec2 a, int s, ivec2 dest)
|
||||||
|
CGLM_INLINE void glm_ivec2_addsub(ivec2 a, ivec2 b, ivec2 dest)
|
||||||
|
CGLM_INLINE void glm_ivec2_addsubs(ivec2 a, int s, ivec2 dest)
|
||||||
|
CGLM_INLINE void glm_ivec2_mulsub(ivec2 a, ivec2 b, ivec2 dest)
|
||||||
|
CGLM_INLINE void glm_ivec2_mulsubs(ivec2 a, int s, ivec2 dest)
|
||||||
|
CGLM_INLINE void glm_ivec2_maxsub(ivec2 a, ivec2 b, ivec2 dest)
|
||||||
|
CGLM_INLINE void glm_ivec2_minsub(ivec2 a, ivec2 b, ivec2 dest)
|
||||||
CGLM_INLINE int glm_ivec2_distance2(ivec2 a, ivec2 b)
|
CGLM_INLINE int glm_ivec2_distance2(ivec2 a, ivec2 b)
|
||||||
CGLM_INLINE float glm_ivec2_distance(ivec2 a, ivec2 b)
|
CGLM_INLINE float glm_ivec2_distance(ivec2 a, ivec2 b)
|
||||||
|
CGLM_INLINE void glm_ivec2_fill(ivec2 v, int val);
|
||||||
|
CGLM_INLINE bool glm_ivec2_eq(ivec2 v, int val);
|
||||||
|
CGLM_INLINE bool glm_ivec2_eqv(ivec2 a, ivec2 b);
|
||||||
CGLM_INLINE void glm_ivec2_maxv(ivec2 a, ivec2 b, ivec2 dest)
|
CGLM_INLINE void glm_ivec2_maxv(ivec2 a, ivec2 b, ivec2 dest)
|
||||||
CGLM_INLINE void glm_ivec2_minv(ivec2 a, ivec2 b, ivec2 dest)
|
CGLM_INLINE void glm_ivec2_minv(ivec2 a, ivec2 b, ivec2 dest)
|
||||||
CGLM_INLINE void glm_ivec2_clamp(ivec2 v, int minVal, int maxVal)
|
CGLM_INLINE void glm_ivec2_clamp(ivec2 v, int minVal, int maxVal)
|
||||||
@@ -35,6 +54,7 @@
|
|||||||
#define cglm_ivec2_h
|
#define cglm_ivec2_h
|
||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
#include "util.h"
|
||||||
|
|
||||||
#define GLM_IVEC2_ONE_INIT {1, 1}
|
#define GLM_IVEC2_ONE_INIT {1, 1}
|
||||||
#define GLM_IVEC2_ZERO_INIT {0, 0}
|
#define GLM_IVEC2_ZERO_INIT {0, 0}
|
||||||
@@ -174,6 +194,262 @@ glm_ivec2_scale(ivec2 v, int s, ivec2 dest) {
|
|||||||
dest[1] = v[1] * s;
|
dest[1] = v[1] * s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief add vector [a] with vector [b] and add result to vector [dest]
|
||||||
|
*
|
||||||
|
* applies += operator so dest must be initialized
|
||||||
|
*
|
||||||
|
* @param[in] a first vector
|
||||||
|
* @param[in] b second vector
|
||||||
|
* @param[out] dest dest += (a + b)
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
void
|
||||||
|
glm_ivec2_addadd(ivec2 a, ivec2 b, ivec2 dest) {
|
||||||
|
dest[0] += a[0] + b[0];
|
||||||
|
dest[1] += a[1] + b[1];
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief add scalar [s] onto vector [a] and add result to vector [dest]
|
||||||
|
*
|
||||||
|
* applies += operator so dest must be initialized
|
||||||
|
*
|
||||||
|
* @param[in] a vector
|
||||||
|
* @param[in] s scalar
|
||||||
|
* @param[out] dest dest += (a + s)
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
void
|
||||||
|
glm_ivec2_addadds(ivec2 a, int s, ivec2 dest) {
|
||||||
|
dest[0] += a[0] + s;
|
||||||
|
dest[1] += a[1] + s;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief subtract vector [a] from vector [b] and add result to [dest]
|
||||||
|
*
|
||||||
|
* applies += operator so dest must be initialized
|
||||||
|
*
|
||||||
|
* @param[in] a first vector
|
||||||
|
* @param[in] b second vector
|
||||||
|
* @param[out] dest dest += (a - b)
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
void
|
||||||
|
glm_ivec2_subadd(ivec2 a, ivec2 b, ivec2 dest) {
|
||||||
|
dest[0] += a[0] - b[0];
|
||||||
|
dest[1] += a[1] - b[1];
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief subtract scalar [s] from vector [a] and add result to [dest]
|
||||||
|
*
|
||||||
|
* applies += operator so dest must be initialized
|
||||||
|
*
|
||||||
|
* @param[in] a first
|
||||||
|
* @param[in] s scalar
|
||||||
|
* @param[out] dest dest += (a - s)
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
void
|
||||||
|
glm_ivec2_subadds(ivec2 a, int s, ivec2 dest) {
|
||||||
|
dest[0] += a[0] - s;
|
||||||
|
dest[1] += a[1] - s;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief multiply vector [a] with vector [b] and add result to [dest]
|
||||||
|
*
|
||||||
|
* applies += operator so dest must be initialized
|
||||||
|
*
|
||||||
|
* @param[in] a first vector
|
||||||
|
* @param[in] b second vector
|
||||||
|
* @param[out] dest dest += (a * b)
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
void
|
||||||
|
glm_ivec2_muladd(ivec2 a, ivec2 b, ivec2 dest) {
|
||||||
|
dest[0] += a[0] * b[0];
|
||||||
|
dest[1] += a[1] * b[1];
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief multiply vector [a] with scalar [s] and add result to [dest]
|
||||||
|
*
|
||||||
|
* applies += operator so dest must be initialized
|
||||||
|
*
|
||||||
|
* @param[in] a vector
|
||||||
|
* @param[in] s scalar
|
||||||
|
* @param[out] dest dest += (a * s)
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
void
|
||||||
|
glm_ivec2_muladds(ivec2 a, int s, ivec2 dest) {
|
||||||
|
dest[0] += a[0] * s;
|
||||||
|
dest[1] += a[1] * s;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief add maximum of vector [a] and vector [b] to vector [dest]
|
||||||
|
*
|
||||||
|
* applies += operator so dest must be initialized
|
||||||
|
*
|
||||||
|
* @param[in] a first vector
|
||||||
|
* @param[in] b second vector
|
||||||
|
* @param[out] dest dest += max(a, b)
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
void
|
||||||
|
glm_ivec2_maxadd(ivec2 a, ivec2 b, ivec2 dest) {
|
||||||
|
dest[0] += glm_imax(a[0], b[0]);
|
||||||
|
dest[1] += glm_imax(a[1], b[1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief add minimum of vector [a] and vector [b] to vector [dest]
|
||||||
|
*
|
||||||
|
* applies += operator so dest must be initialized
|
||||||
|
*
|
||||||
|
* @param[in] a first vector
|
||||||
|
* @param[in] b second vector
|
||||||
|
* @param[out] dest dest += min(a, b)
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
void
|
||||||
|
glm_ivec2_minadd(ivec2 a, ivec2 b, ivec2 dest) {
|
||||||
|
dest[0] += glm_imin(a[0], b[0]);
|
||||||
|
dest[1] += glm_imin(a[1], b[1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief subtract vector [a] from vector [b] and subtract result from [dest]
|
||||||
|
*
|
||||||
|
* applies -= operator so dest must be initialized
|
||||||
|
*
|
||||||
|
* @param[in] a first vector
|
||||||
|
* @param[in] b second vector
|
||||||
|
* @param[out] dest dest -= (a - b)
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
void
|
||||||
|
glm_ivec2_subsub(ivec2 a, ivec2 b, ivec2 dest) {
|
||||||
|
dest[0] -= a[0] - b[0];
|
||||||
|
dest[1] -= a[1] - b[1];
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief subtract scalar [s] from vector [a] and subtract result from [dest]
|
||||||
|
*
|
||||||
|
* applies -= operator so dest must be initialized
|
||||||
|
*
|
||||||
|
* @param[in] a vector
|
||||||
|
* @param[in] s scalar
|
||||||
|
* @param[out] dest dest -= (a - s)
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
void
|
||||||
|
glm_ivec2_subsubs(ivec2 a, int s, ivec2 dest) {
|
||||||
|
dest[0] -= a[0] - s;
|
||||||
|
dest[1] -= a[1] - s;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief add vector [a] to vector [b] and subtract the result from [dest]
|
||||||
|
*
|
||||||
|
* applies -= operator so dest must be initialized
|
||||||
|
*
|
||||||
|
* @param[in] a vector
|
||||||
|
* @param[in] b scalar
|
||||||
|
* @param[out] dest dest -= (a + b)
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
void
|
||||||
|
glm_ivec2_addsub(ivec2 a, ivec2 b, ivec2 dest) {
|
||||||
|
dest[0] -= a[0] + b[0];
|
||||||
|
dest[1] -= a[1] + b[1];
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief add scalar [s] to vector [a] and subtract the result from [dest]
|
||||||
|
*
|
||||||
|
* applies -= operator so dest must be initialized
|
||||||
|
*
|
||||||
|
* @param[in] a vector
|
||||||
|
* @param[in] s scalar
|
||||||
|
* @param[out] dest dest -= (a + b)
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
void
|
||||||
|
glm_ivec2_addsubs(ivec2 a, int s, ivec2 dest) {
|
||||||
|
dest[0] -= a[0] + s;
|
||||||
|
dest[1] -= a[1] + s;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief multiply vector [a] and vector [b] and subtract the result from [dest]
|
||||||
|
*
|
||||||
|
* applies -= operator so dest must be initialized
|
||||||
|
*
|
||||||
|
* @param[in] a vector
|
||||||
|
* @param[in] b scalar
|
||||||
|
* @param[out] dest dest -= (a * b)
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
void
|
||||||
|
glm_ivec2_mulsub(ivec2 a, ivec2 b, ivec2 dest) {
|
||||||
|
dest[0] -= a[0] * b[0];
|
||||||
|
dest[1] -= a[1] * b[1];
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief multiply vector [a] with scalar [s] and subtract the result from [dest]
|
||||||
|
*
|
||||||
|
* applies -= operator so dest must be initialized
|
||||||
|
*
|
||||||
|
* @param[in] a vector
|
||||||
|
* @param[in] s scalar
|
||||||
|
* @param[out] dest dest -= (a * s)
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
void
|
||||||
|
glm_ivec2_mulsubs(ivec2 a, int s, ivec2 dest) {
|
||||||
|
dest[0] -= a[0] * s;
|
||||||
|
dest[1] -= a[1] * s;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief subtract maximum of vector [a] and vector [b] from vector [dest]
|
||||||
|
*
|
||||||
|
* applies += operator so dest must be initialized
|
||||||
|
*
|
||||||
|
* @param[in] a first vector
|
||||||
|
* @param[in] b second vector
|
||||||
|
* @param[out] dest dest -= max(a, b)
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
void
|
||||||
|
glm_ivec2_maxsub(ivec2 a, ivec2 b, ivec2 dest) {
|
||||||
|
dest[0] -= glm_imax(a[0], b[0]);
|
||||||
|
dest[1] -= glm_imax(a[1], b[1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief subtract minimum of vector [a] and vector [b] from vector [dest]
|
||||||
|
*
|
||||||
|
* applies -= operator so dest must be initialized
|
||||||
|
*
|
||||||
|
* @param[in] a first vector
|
||||||
|
* @param[in] b second vector
|
||||||
|
* @param[out] dest dest -= min(a, b)
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
void
|
||||||
|
glm_ivec2_minsub(ivec2 a, ivec2 b, ivec2 dest) {
|
||||||
|
dest[0] -= glm_imin(a[0], b[0]);
|
||||||
|
dest[1] -= glm_imin(a[1], b[1]);
|
||||||
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief squared distance between two vectors
|
* @brief squared distance between two vectors
|
||||||
*
|
*
|
||||||
@@ -203,6 +479,44 @@ glm_ivec2_distance(ivec2 a, ivec2 b) {
|
|||||||
return sqrtf((float)glm_ivec2_distance2(a, b));
|
return sqrtf((float)glm_ivec2_distance2(a, b));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief fill a vector with specified value
|
||||||
|
*
|
||||||
|
* @param[out] v dest
|
||||||
|
* @param[in] val value
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
void
|
||||||
|
glm_ivec2_fill(ivec2 v, int val) {
|
||||||
|
v[0] = v[1] = val;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief check if vector is equal to value
|
||||||
|
*
|
||||||
|
* @param[in] v vector
|
||||||
|
* @param[in] val value
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
bool
|
||||||
|
glm_ivec2_eq(ivec2 v, int val) {
|
||||||
|
return v[0] == val && v[0] == v[1];
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief check if vector is equal to another
|
||||||
|
*
|
||||||
|
* @param[in] a vector
|
||||||
|
* @param[in] b vector
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
bool
|
||||||
|
glm_ivec2_eqv(ivec2 a, ivec2 b) {
|
||||||
|
return a[0] == b[0]
|
||||||
|
&& a[1] == b[1];
|
||||||
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief set each member of dest to greater of vector a and b
|
* @brief set each member of dest to greater of vector a and b
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -23,8 +23,27 @@
|
|||||||
CGLM_INLINE void glm_ivec3_subs(ivec3 v, int s, ivec3 dest)
|
CGLM_INLINE void glm_ivec3_subs(ivec3 v, int s, ivec3 dest)
|
||||||
CGLM_INLINE void glm_ivec3_mul(ivec3 a, ivec3 b, ivec3 dest)
|
CGLM_INLINE void glm_ivec3_mul(ivec3 a, ivec3 b, ivec3 dest)
|
||||||
CGLM_INLINE void glm_ivec3_scale(ivec3 v, int s, ivec3 dest)
|
CGLM_INLINE void glm_ivec3_scale(ivec3 v, int s, ivec3 dest)
|
||||||
|
CGLM_INLINE void glm_ivec3_addadd(ivec3 a, ivec3 b, ivec3 dest)
|
||||||
|
CGLM_INLINE void glm_ivec3_addadds(ivec3 a, int s, ivec3 dest)
|
||||||
|
CGLM_INLINE void glm_ivec3_subadd(ivec3 a, ivec3 b, ivec3 dest)
|
||||||
|
CGLM_INLINE void glm_ivec3_subadds(ivec3 a, int s, ivec3 dest)
|
||||||
|
CGLM_INLINE void glm_ivec3_muladd(ivec3 a, ivec3 b, ivec3 dest)
|
||||||
|
CGLM_INLINE void glm_ivec3_muladds(ivec3 a, int s, ivec3 dest)
|
||||||
|
CGLM_INLINE void glm_ivec3_maxadd(ivec3 a, ivec3 b, ivec3 dest)
|
||||||
|
CGLM_INLINE void glm_ivec3_minadd(ivec3 a, ivec3 b, ivec3 dest)
|
||||||
|
CGLM_INLINE void glm_ivec3_subsub(ivec3 a, ivec3 b, ivec3 dest)
|
||||||
|
CGLM_INLINE void glm_ivec3_subsubs(ivec3 a, int s, ivec3 dest)
|
||||||
|
CGLM_INLINE void glm_ivec3_addsub(ivec3 a, ivec3 b, ivec3 dest)
|
||||||
|
CGLM_INLINE void glm_ivec3_addsubs(ivec3 a, int s, ivec3 dest)
|
||||||
|
CGLM_INLINE void glm_ivec3_mulsub(ivec3 a, ivec3 b, ivec3 dest)
|
||||||
|
CGLM_INLINE void glm_ivec3_mulsubs(ivec3 a, int s, ivec3 dest)
|
||||||
|
CGLM_INLINE void glm_ivec3_maxsub(ivec3 a, ivec3 b, ivec3 dest)
|
||||||
|
CGLM_INLINE void glm_ivec3_minsub(ivec3 a, ivec3 b, ivec3 dest)
|
||||||
CGLM_INLINE int glm_ivec3_distance2(ivec3 a, ivec3 b)
|
CGLM_INLINE int glm_ivec3_distance2(ivec3 a, ivec3 b)
|
||||||
CGLM_INLINE float glm_ivec3_distance(ivec3 a, ivec3 b)
|
CGLM_INLINE float glm_ivec3_distance(ivec3 a, ivec3 b)
|
||||||
|
CGLM_INLINE void glm_ivec3_fill(ivec3 v, int val);
|
||||||
|
CGLM_INLINE bool glm_ivec3_eq(ivec3 v, int val);
|
||||||
|
CGLM_INLINE bool glm_ivec3_eqv(ivec3 a, ivec3 b);
|
||||||
CGLM_INLINE void glm_ivec3_maxv(ivec3 a, ivec3 b, ivec3 dest)
|
CGLM_INLINE void glm_ivec3_maxv(ivec3 a, ivec3 b, ivec3 dest)
|
||||||
CGLM_INLINE void glm_ivec3_minv(ivec3 a, ivec3 b, ivec3 dest)
|
CGLM_INLINE void glm_ivec3_minv(ivec3 a, ivec3 b, ivec3 dest)
|
||||||
CGLM_INLINE void glm_ivec3_clamp(ivec3 v, int minVal, int maxVal)
|
CGLM_INLINE void glm_ivec3_clamp(ivec3 v, int minVal, int maxVal)
|
||||||
@@ -35,6 +54,7 @@
|
|||||||
#define cglm_ivec3_h
|
#define cglm_ivec3_h
|
||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
#include "util.h"
|
||||||
|
|
||||||
#define GLM_IVEC3_ONE_INIT {1, 1, 1}
|
#define GLM_IVEC3_ONE_INIT {1, 1, 1}
|
||||||
#define GLM_IVEC3_ZERO_INIT {0, 0, 0}
|
#define GLM_IVEC3_ZERO_INIT {0, 0, 0}
|
||||||
@@ -182,6 +202,278 @@ glm_ivec3_scale(ivec3 v, int s, ivec3 dest) {
|
|||||||
dest[2] = v[2] * s;
|
dest[2] = v[2] * s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief add vector [a] with vector [b] and add result to vector [dest]
|
||||||
|
*
|
||||||
|
* applies += operator so dest must be initialized
|
||||||
|
*
|
||||||
|
* @param[in] a first vector
|
||||||
|
* @param[in] b second vector
|
||||||
|
* @param[out] dest dest += (a + b)
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
void
|
||||||
|
glm_ivec3_addadd(ivec3 a, ivec3 b, ivec3 dest) {
|
||||||
|
dest[0] += a[0] + b[0];
|
||||||
|
dest[1] += a[1] + b[1];
|
||||||
|
dest[2] += a[2] + b[2];
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief add scalar [s] onto vector [a] and add result to vector [dest]
|
||||||
|
*
|
||||||
|
* applies += operator so dest must be initialized
|
||||||
|
*
|
||||||
|
* @param[in] a vector
|
||||||
|
* @param[in] s scalar
|
||||||
|
* @param[out] dest dest += (a + s)
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
void
|
||||||
|
glm_ivec3_addadds(ivec3 a, int s, ivec3 dest) {
|
||||||
|
dest[0] += a[0] + s;
|
||||||
|
dest[1] += a[1] + s;
|
||||||
|
dest[2] += a[2] + s;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief subtract vector [a] from vector [b] and add result to [dest]
|
||||||
|
*
|
||||||
|
* applies += operator so dest must be initialized
|
||||||
|
*
|
||||||
|
* @param[in] a first vector
|
||||||
|
* @param[in] b second vector
|
||||||
|
* @param[out] dest dest += (a - b)
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
void
|
||||||
|
glm_ivec3_subadd(ivec3 a, ivec3 b, ivec3 dest) {
|
||||||
|
dest[0] += a[0] - b[0];
|
||||||
|
dest[1] += a[1] - b[1];
|
||||||
|
dest[2] += a[2] - b[2];
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief subtract scalar [s] from vector [a] and add result to [dest]
|
||||||
|
*
|
||||||
|
* applies += operator so dest must be initialized
|
||||||
|
*
|
||||||
|
* @param[in] a first
|
||||||
|
* @param[in] s scalar
|
||||||
|
* @param[out] dest dest += (a - s)
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
void
|
||||||
|
glm_ivec3_subadds(ivec3 a, int s, ivec3 dest) {
|
||||||
|
dest[0] += a[0] - s;
|
||||||
|
dest[1] += a[1] - s;
|
||||||
|
dest[2] += a[2] - s;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief multiply vector [a] with vector [b] and add result to [dest]
|
||||||
|
*
|
||||||
|
* applies += operator so dest must be initialized
|
||||||
|
*
|
||||||
|
* @param[in] a first vector
|
||||||
|
* @param[in] b second vector
|
||||||
|
* @param[out] dest dest += (a * b)
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
void
|
||||||
|
glm_ivec3_muladd(ivec3 a, ivec3 b, ivec3 dest) {
|
||||||
|
dest[0] += a[0] * b[0];
|
||||||
|
dest[1] += a[1] * b[1];
|
||||||
|
dest[2] += a[2] * b[2];
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief multiply vector [a] with scalar [s] and add result to [dest]
|
||||||
|
*
|
||||||
|
* applies += operator so dest must be initialized
|
||||||
|
*
|
||||||
|
* @param[in] a vector
|
||||||
|
* @param[in] s scalar
|
||||||
|
* @param[out] dest dest += (a * s)
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
void
|
||||||
|
glm_ivec3_muladds(ivec3 a, int s, ivec3 dest) {
|
||||||
|
dest[0] += a[0] * s;
|
||||||
|
dest[1] += a[1] * s;
|
||||||
|
dest[2] += a[2] * s;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief add maximum of vector [a] and vector [b] to vector [dest]
|
||||||
|
*
|
||||||
|
* applies += operator so dest must be initialized
|
||||||
|
*
|
||||||
|
* @param[in] a first vector
|
||||||
|
* @param[in] b second vector
|
||||||
|
* @param[out] dest dest += max(a, b)
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
void
|
||||||
|
glm_ivec3_maxadd(ivec3 a, ivec3 b, ivec3 dest) {
|
||||||
|
dest[0] += glm_imax(a[0], b[0]);
|
||||||
|
dest[1] += glm_imax(a[1], b[1]);
|
||||||
|
dest[2] += glm_imax(a[2], b[2]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief add minimum of vector [a] and vector [b] to vector [dest]
|
||||||
|
*
|
||||||
|
* applies += operator so dest must be initialized
|
||||||
|
*
|
||||||
|
* @param[in] a first vector
|
||||||
|
* @param[in] b second vector
|
||||||
|
* @param[out] dest dest += min(a, b)
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
void
|
||||||
|
glm_ivec3_minadd(ivec3 a, ivec3 b, ivec3 dest) {
|
||||||
|
dest[0] += glm_imin(a[0], b[0]);
|
||||||
|
dest[1] += glm_imin(a[1], b[1]);
|
||||||
|
dest[2] += glm_imin(a[2], b[2]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief subtract vector [a] from vector [b] and subtract result from [dest]
|
||||||
|
*
|
||||||
|
* applies -= operator so dest must be initialized
|
||||||
|
*
|
||||||
|
* @param[in] a first vector
|
||||||
|
* @param[in] b second vector
|
||||||
|
* @param[out] dest dest -= (a - b)
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
void
|
||||||
|
glm_ivec3_subsub(ivec3 a, ivec3 b, ivec3 dest) {
|
||||||
|
dest[0] -= a[0] - b[0];
|
||||||
|
dest[1] -= a[1] - b[1];
|
||||||
|
dest[2] -= a[2] - b[2];
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief subtract scalar [s] from vector [a] and subtract result from [dest]
|
||||||
|
*
|
||||||
|
* applies -= operator so dest must be initialized
|
||||||
|
*
|
||||||
|
* @param[in] a vector
|
||||||
|
* @param[in] s scalar
|
||||||
|
* @param[out] dest dest -= (a - s)
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
void
|
||||||
|
glm_ivec3_subsubs(ivec3 a, int s, ivec3 dest) {
|
||||||
|
dest[0] -= a[0] - s;
|
||||||
|
dest[1] -= a[1] - s;
|
||||||
|
dest[2] -= a[2] - s;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief add vector [a] to vector [b] and subtract the result from [dest]
|
||||||
|
*
|
||||||
|
* applies -= operator so dest must be initialized
|
||||||
|
*
|
||||||
|
* @param[in] a vector
|
||||||
|
* @param[in] b scalar
|
||||||
|
* @param[out] dest dest -= (a + b)
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
void
|
||||||
|
glm_ivec3_addsub(ivec3 a, ivec3 b, ivec3 dest) {
|
||||||
|
dest[0] -= a[0] + b[0];
|
||||||
|
dest[1] -= a[1] + b[1];
|
||||||
|
dest[2] -= a[2] + b[2];
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief add scalar [s] to vector [a] and subtract the result from [dest]
|
||||||
|
*
|
||||||
|
* applies -= operator so dest must be initialized
|
||||||
|
*
|
||||||
|
* @param[in] a vector
|
||||||
|
* @param[in] s scalar
|
||||||
|
* @param[out] dest dest -= (a + b)
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
void
|
||||||
|
glm_ivec3_addsubs(ivec3 a, int s, ivec3 dest) {
|
||||||
|
dest[0] -= a[0] + s;
|
||||||
|
dest[1] -= a[1] + s;
|
||||||
|
dest[2] -= a[2] + s;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief multiply vector [a] and vector [b] and subtract the result from [dest]
|
||||||
|
*
|
||||||
|
* applies -= operator so dest must be initialized
|
||||||
|
*
|
||||||
|
* @param[in] a vector
|
||||||
|
* @param[in] b scalar
|
||||||
|
* @param[out] dest dest -= (a * b)
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
void
|
||||||
|
glm_ivec3_mulsub(ivec3 a, ivec3 b, ivec3 dest) {
|
||||||
|
dest[0] -= a[0] * b[0];
|
||||||
|
dest[1] -= a[1] * b[1];
|
||||||
|
dest[2] -= a[2] * b[2];
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief multiply vector [a] with scalar [s] and subtract the result from [dest]
|
||||||
|
*
|
||||||
|
* applies -= operator so dest must be initialized
|
||||||
|
*
|
||||||
|
* @param[in] a vector
|
||||||
|
* @param[in] s scalar
|
||||||
|
* @param[out] dest dest -= (a * s)
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
void
|
||||||
|
glm_ivec3_mulsubs(ivec3 a, int s, ivec3 dest) {
|
||||||
|
dest[0] -= a[0] * s;
|
||||||
|
dest[1] -= a[1] * s;
|
||||||
|
dest[2] -= a[2] * s;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief subtract maximum of vector [a] and vector [b] from vector [dest]
|
||||||
|
*
|
||||||
|
* applies += operator so dest must be initialized
|
||||||
|
*
|
||||||
|
* @param[in] a first vector
|
||||||
|
* @param[in] b second vector
|
||||||
|
* @param[out] dest dest -= max(a, b)
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
void
|
||||||
|
glm_ivec3_maxsub(ivec3 a, ivec3 b, ivec3 dest) {
|
||||||
|
dest[0] -= glm_imax(a[0], b[0]);
|
||||||
|
dest[1] -= glm_imax(a[1], b[1]);
|
||||||
|
dest[2] -= glm_imax(a[2], b[2]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief subtract minimum of vector [a] and vector [b] from vector [dest]
|
||||||
|
*
|
||||||
|
* applies -= operator so dest must be initialized
|
||||||
|
*
|
||||||
|
* @param[in] a first vector
|
||||||
|
* @param[in] b second vector
|
||||||
|
* @param[out] dest dest -= min(a, b)
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
void
|
||||||
|
glm_ivec3_minsub(ivec3 a, ivec3 b, ivec3 dest) {
|
||||||
|
dest[0] -= glm_imin(a[0], b[0]);
|
||||||
|
dest[1] -= glm_imin(a[1], b[1]);
|
||||||
|
dest[2] -= glm_imin(a[2], b[2]);
|
||||||
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief squared distance between two vectors
|
* @brief squared distance between two vectors
|
||||||
*
|
*
|
||||||
@@ -212,6 +504,44 @@ glm_ivec3_distance(ivec3 a, ivec3 b) {
|
|||||||
return sqrtf((float)glm_ivec3_distance2(a, b));
|
return sqrtf((float)glm_ivec3_distance2(a, b));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief fill a vector with specified value
|
||||||
|
*
|
||||||
|
* @param[out] v dest
|
||||||
|
* @param[in] val value
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
void
|
||||||
|
glm_ivec3_fill(ivec3 v, int val) {
|
||||||
|
v[0] = v[1] = v[2] = val;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief check if vector is equal to value
|
||||||
|
*
|
||||||
|
* @param[in] v vector
|
||||||
|
* @param[in] val value
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
bool
|
||||||
|
glm_ivec3_eq(ivec3 v, int val) {
|
||||||
|
return v[0] == val && v[0] == v[1] && v[0] == v[2];
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief check if vector is equal to another
|
||||||
|
*
|
||||||
|
* @param[in] a vector
|
||||||
|
* @param[in] b vector
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
bool
|
||||||
|
glm_ivec3_eqv(ivec3 a, ivec3 b) {
|
||||||
|
return a[0] == b[0]
|
||||||
|
&& a[1] == b[1]
|
||||||
|
&& a[2] == b[2];
|
||||||
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief set each member of dest to greater of vector a and b
|
* @brief set each member of dest to greater of vector a and b
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -23,6 +23,22 @@
|
|||||||
CGLM_INLINE void glm_ivec4_subs(ivec4 v, int s, ivec4 dest)
|
CGLM_INLINE void glm_ivec4_subs(ivec4 v, int s, ivec4 dest)
|
||||||
CGLM_INLINE void glm_ivec4_mul(ivec4 a, ivec4 b, ivec4 dest)
|
CGLM_INLINE void glm_ivec4_mul(ivec4 a, ivec4 b, ivec4 dest)
|
||||||
CGLM_INLINE void glm_ivec4_scale(ivec4 v, int s, ivec4 dest)
|
CGLM_INLINE void glm_ivec4_scale(ivec4 v, int s, ivec4 dest)
|
||||||
|
CGLM_INLINE void glm_ivec4_addadd(ivec4 a, ivec4 b, ivec4 dest)
|
||||||
|
CGLM_INLINE void glm_ivec4_addadds(ivec4 a, int s, ivec4 dest)
|
||||||
|
CGLM_INLINE void glm_ivec4_subadd(ivec4 a, ivec4 b, ivec4 dest)
|
||||||
|
CGLM_INLINE void glm_ivec4_subadds(ivec4 a, int s, ivec4 dest)
|
||||||
|
CGLM_INLINE void glm_ivec4_muladd(ivec4 a, ivec4 b, ivec4 dest)
|
||||||
|
CGLM_INLINE void glm_ivec4_muladds(ivec4 a, int s, ivec4 dest)
|
||||||
|
CGLM_INLINE void glm_ivec4_maxadd(ivec4 a, ivec4 b, ivec4 dest)
|
||||||
|
CGLM_INLINE void glm_ivec4_minadd(ivec4 a, ivec4 b, ivec4 dest)
|
||||||
|
CGLM_INLINE void glm_ivec4_subsub(ivec4 a, ivec4 b, ivec4 dest)
|
||||||
|
CGLM_INLINE void glm_ivec4_subsubs(ivec4 a, int s, ivec4 dest)
|
||||||
|
CGLM_INLINE void glm_ivec4_addsub(ivec4 a, ivec4 b, ivec4 dest)
|
||||||
|
CGLM_INLINE void glm_ivec4_addsubs(ivec4 a, int s, ivec4 dest)
|
||||||
|
CGLM_INLINE void glm_ivec4_mulsub(ivec4 a, ivec4 b, ivec4 dest)
|
||||||
|
CGLM_INLINE void glm_ivec4_mulsubs(ivec4 a, int s, ivec4 dest)
|
||||||
|
CGLM_INLINE void glm_ivec4_maxsub(ivec4 a, ivec4 b, ivec4 dest)
|
||||||
|
CGLM_INLINE void glm_ivec4_minsub(ivec4 a, ivec4 b, ivec4 dest)
|
||||||
CGLM_INLINE int glm_ivec4_distance2(ivec4 a, ivec4 b)
|
CGLM_INLINE int glm_ivec4_distance2(ivec4 a, ivec4 b)
|
||||||
CGLM_INLINE float glm_ivec4_distance(ivec4 a, ivec4 b)
|
CGLM_INLINE float glm_ivec4_distance(ivec4 a, ivec4 b)
|
||||||
CGLM_INLINE void glm_ivec4_maxv(ivec4 a, ivec4 b, ivec4 dest)
|
CGLM_INLINE void glm_ivec4_maxv(ivec4 a, ivec4 b, ivec4 dest)
|
||||||
@@ -35,6 +51,7 @@
|
|||||||
#define cglm_ivec4_h
|
#define cglm_ivec4_h
|
||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
#include "util.h"
|
||||||
|
|
||||||
#define GLM_IVEC4_ONE_INIT {1, 1, 1, 1}
|
#define GLM_IVEC4_ONE_INIT {1, 1, 1, 1}
|
||||||
#define GLM_IVEC4_ZERO_INIT {0, 0, 0, 0}
|
#define GLM_IVEC4_ZERO_INIT {0, 0, 0, 0}
|
||||||
@@ -191,6 +208,294 @@ glm_ivec4_scale(ivec4 v, int s, ivec4 dest) {
|
|||||||
dest[3] = v[3] * s;
|
dest[3] = v[3] * s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief add vector [a] with vector [b] and add result to vector [dest]
|
||||||
|
*
|
||||||
|
* applies += operator so dest must be initialized
|
||||||
|
*
|
||||||
|
* @param[in] a first vector
|
||||||
|
* @param[in] b second vector
|
||||||
|
* @param[out] dest dest += (a + b)
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
void
|
||||||
|
glm_ivec4_addadd(ivec4 a, ivec4 b, ivec4 dest) {
|
||||||
|
dest[0] += a[0] + b[0];
|
||||||
|
dest[1] += a[1] + b[1];
|
||||||
|
dest[2] += a[2] + b[2];
|
||||||
|
dest[3] += a[3] + b[3];
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief add scalar [s] onto vector [a] and add result to vector [dest]
|
||||||
|
*
|
||||||
|
* applies += operator so dest must be initialized
|
||||||
|
*
|
||||||
|
* @param[in] a vector
|
||||||
|
* @param[in] s scalar
|
||||||
|
* @param[out] dest dest += (a + s)
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
void
|
||||||
|
glm_ivec4_addadds(ivec4 a, int s, ivec4 dest) {
|
||||||
|
dest[0] += a[0] + s;
|
||||||
|
dest[1] += a[1] + s;
|
||||||
|
dest[2] += a[2] + s;
|
||||||
|
dest[3] += a[3] + s;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief subtract vector [a] from vector [b] and add result to [dest]
|
||||||
|
*
|
||||||
|
* applies += operator so dest must be initialized
|
||||||
|
*
|
||||||
|
* @param[in] a first vector
|
||||||
|
* @param[in] b second vector
|
||||||
|
* @param[out] dest dest += (a - b)
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
void
|
||||||
|
glm_ivec4_subadd(ivec4 a, ivec4 b, ivec4 dest) {
|
||||||
|
dest[0] += a[0] - b[0];
|
||||||
|
dest[1] += a[1] - b[1];
|
||||||
|
dest[2] += a[2] - b[2];
|
||||||
|
dest[3] += a[3] - b[3];
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief subtract scalar [s] from vector [a] and add result to [dest]
|
||||||
|
*
|
||||||
|
* applies += operator so dest must be initialized
|
||||||
|
*
|
||||||
|
* @param[in] a first
|
||||||
|
* @param[in] s scalar
|
||||||
|
* @param[out] dest dest += (a - s)
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
void
|
||||||
|
glm_ivec4_subadds(ivec4 a, int s, ivec4 dest) {
|
||||||
|
dest[0] += a[0] - s;
|
||||||
|
dest[1] += a[1] - s;
|
||||||
|
dest[2] += a[2] - s;
|
||||||
|
dest[3] += a[3] - s;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief multiply vector [a] with vector [b] and add result to [dest]
|
||||||
|
*
|
||||||
|
* applies += operator so dest must be initialized
|
||||||
|
*
|
||||||
|
* @param[in] a first vector
|
||||||
|
* @param[in] b second vector
|
||||||
|
* @param[out] dest dest += (a * b)
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
void
|
||||||
|
glm_ivec4_muladd(ivec4 a, ivec4 b, ivec4 dest) {
|
||||||
|
dest[0] += a[0] * b[0];
|
||||||
|
dest[1] += a[1] * b[1];
|
||||||
|
dest[2] += a[2] * b[2];
|
||||||
|
dest[3] += a[3] * b[3];
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief multiply vector [a] with scalar [s] and add result to [dest]
|
||||||
|
*
|
||||||
|
* applies += operator so dest must be initialized
|
||||||
|
*
|
||||||
|
* @param[in] a vector
|
||||||
|
* @param[in] s scalar
|
||||||
|
* @param[out] dest dest += (a * s)
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
void
|
||||||
|
glm_ivec4_muladds(ivec4 a, int s, ivec4 dest) {
|
||||||
|
dest[0] += a[0] * s;
|
||||||
|
dest[1] += a[1] * s;
|
||||||
|
dest[2] += a[2] * s;
|
||||||
|
dest[3] += a[3] * s;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief add maximum of vector [a] and vector [b] to vector [dest]
|
||||||
|
*
|
||||||
|
* applies += operator so dest must be initialized
|
||||||
|
*
|
||||||
|
* @param[in] a first vector
|
||||||
|
* @param[in] b second vector
|
||||||
|
* @param[out] dest dest += max(a, b)
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
void
|
||||||
|
glm_ivec4_maxadd(ivec4 a, ivec4 b, ivec4 dest) {
|
||||||
|
dest[0] += glm_imax(a[0], b[0]);
|
||||||
|
dest[1] += glm_imax(a[1], b[1]);
|
||||||
|
dest[2] += glm_imax(a[2], b[2]);
|
||||||
|
dest[3] += glm_imax(a[3], b[3]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief add minimum of vector [a] and vector [b] to vector [dest]
|
||||||
|
*
|
||||||
|
* applies += operator so dest must be initialized
|
||||||
|
*
|
||||||
|
* @param[in] a first vector
|
||||||
|
* @param[in] b second vector
|
||||||
|
* @param[out] dest dest += min(a, b)
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
void
|
||||||
|
glm_ivec4_minadd(ivec4 a, ivec4 b, ivec4 dest) {
|
||||||
|
dest[0] += glm_imin(a[0], b[0]);
|
||||||
|
dest[1] += glm_imin(a[1], b[1]);
|
||||||
|
dest[2] += glm_imin(a[2], b[2]);
|
||||||
|
dest[3] += glm_imin(a[3], b[3]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief subtract vector [a] from vector [b] and subtract result from [dest]
|
||||||
|
*
|
||||||
|
* applies -= operator so dest must be initialized
|
||||||
|
*
|
||||||
|
* @param[in] a first vector
|
||||||
|
* @param[in] b second vector
|
||||||
|
* @param[out] dest dest -= (a - b)
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
void
|
||||||
|
glm_ivec4_subsub(ivec4 a, ivec4 b, ivec4 dest) {
|
||||||
|
dest[0] -= a[0] - b[0];
|
||||||
|
dest[1] -= a[1] - b[1];
|
||||||
|
dest[2] -= a[2] - b[2];
|
||||||
|
dest[3] -= a[3] - b[3];
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief subtract scalar [s] from vector [a] and subtract result from [dest]
|
||||||
|
*
|
||||||
|
* applies -= operator so dest must be initialized
|
||||||
|
*
|
||||||
|
* @param[in] a vector
|
||||||
|
* @param[in] s scalar
|
||||||
|
* @param[out] dest dest -= (a - s)
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
void
|
||||||
|
glm_ivec4_subsubs(ivec4 a, int s, ivec4 dest) {
|
||||||
|
dest[0] -= a[0] - s;
|
||||||
|
dest[1] -= a[1] - s;
|
||||||
|
dest[2] -= a[2] - s;
|
||||||
|
dest[3] -= a[3] - s;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief add vector [a] to vector [b] and subtract the result from [dest]
|
||||||
|
*
|
||||||
|
* applies -= operator so dest must be initialized
|
||||||
|
*
|
||||||
|
* @param[in] a vector
|
||||||
|
* @param[in] b scalar
|
||||||
|
* @param[out] dest dest -= (a + b)
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
void
|
||||||
|
glm_ivec4_addsub(ivec4 a, ivec4 b, ivec4 dest) {
|
||||||
|
dest[0] -= a[0] + b[0];
|
||||||
|
dest[1] -= a[1] + b[1];
|
||||||
|
dest[2] -= a[2] + b[2];
|
||||||
|
dest[3] -= a[3] + b[3];
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief add scalar [s] to vector [a] and subtract the result from [dest]
|
||||||
|
*
|
||||||
|
* applies -= operator so dest must be initialized
|
||||||
|
*
|
||||||
|
* @param[in] a vector
|
||||||
|
* @param[in] s scalar
|
||||||
|
* @param[out] dest dest -= (a + b)
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
void
|
||||||
|
glm_ivec4_addsubs(ivec4 a, int s, ivec4 dest) {
|
||||||
|
dest[0] -= a[0] + s;
|
||||||
|
dest[1] -= a[1] + s;
|
||||||
|
dest[2] -= a[2] + s;
|
||||||
|
dest[3] -= a[3] + s;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief multiply vector [a] and vector [b] and subtract the result from [dest]
|
||||||
|
*
|
||||||
|
* applies -= operator so dest must be initialized
|
||||||
|
*
|
||||||
|
* @param[in] a vector
|
||||||
|
* @param[in] b scalar
|
||||||
|
* @param[out] dest dest -= (a * b)
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
void
|
||||||
|
glm_ivec4_mulsub(ivec4 a, ivec4 b, ivec4 dest) {
|
||||||
|
dest[0] -= a[0] * b[0];
|
||||||
|
dest[1] -= a[1] * b[1];
|
||||||
|
dest[2] -= a[2] * b[2];
|
||||||
|
dest[3] -= a[3] * b[3];
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief multiply vector [a] with scalar [s] and subtract the result from [dest]
|
||||||
|
*
|
||||||
|
* applies -= operator so dest must be initialized
|
||||||
|
*
|
||||||
|
* @param[in] a vector
|
||||||
|
* @param[in] s scalar
|
||||||
|
* @param[out] dest dest -= (a * s)
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
void
|
||||||
|
glm_ivec4_mulsubs(ivec4 a, int s, ivec4 dest) {
|
||||||
|
dest[0] -= a[0] * s;
|
||||||
|
dest[1] -= a[1] * s;
|
||||||
|
dest[2] -= a[2] * s;
|
||||||
|
dest[3] -= a[3] * s;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief subtract maximum of vector [a] and vector [b] from vector [dest]
|
||||||
|
*
|
||||||
|
* applies += operator so dest must be initialized
|
||||||
|
*
|
||||||
|
* @param[in] a first vector
|
||||||
|
* @param[in] b second vector
|
||||||
|
* @param[out] dest dest -= max(a, b)
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
void
|
||||||
|
glm_ivec4_maxsub(ivec4 a, ivec4 b, ivec4 dest) {
|
||||||
|
dest[0] -= glm_imax(a[0], b[0]);
|
||||||
|
dest[1] -= glm_imax(a[1], b[1]);
|
||||||
|
dest[2] -= glm_imax(a[2], b[2]);
|
||||||
|
dest[3] -= glm_imax(a[3], b[3]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief subtract minimum of vector [a] and vector [b] from vector [dest]
|
||||||
|
*
|
||||||
|
* applies -= operator so dest must be initialized
|
||||||
|
*
|
||||||
|
* @param[in] a first vector
|
||||||
|
* @param[in] b second vector
|
||||||
|
* @param[out] dest dest -= min(a, b)
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
void
|
||||||
|
glm_ivec4_minsub(ivec4 a, ivec4 b, ivec4 dest) {
|
||||||
|
dest[0] -= glm_imin(a[0], b[0]);
|
||||||
|
dest[1] -= glm_imin(a[1], b[1]);
|
||||||
|
dest[2] -= glm_imin(a[2], b[2]);
|
||||||
|
dest[3] -= glm_imin(a[3], b[3]);
|
||||||
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief squared distance between two vectors
|
* @brief squared distance between two vectors
|
||||||
*
|
*
|
||||||
|
|||||||
154
include/cglm/mat2x3.h
Normal file
154
include/cglm/mat2x3.h
Normal file
@@ -0,0 +1,154 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c), Recep Aslantas.
|
||||||
|
*
|
||||||
|
* MIT License (MIT), http://opensource.org/licenses/MIT
|
||||||
|
* Full license can be found in the LICENSE file
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
Macros:
|
||||||
|
GLM_MAT2X3_ZERO_INIT
|
||||||
|
GLM_MAT2X3_ZERO
|
||||||
|
|
||||||
|
Functions:
|
||||||
|
CGLM_INLINE void glm_mat2x3_copy(mat2x3 mat, mat2x3 dest);
|
||||||
|
CGLM_INLINE void glm_mat2x3_zero(mat2x3 mat);
|
||||||
|
CGLM_INLINE void glm_mat2x3_make(float * __restrict src, mat2x3 dest);
|
||||||
|
CGLM_INLINE void glm_mat2x3_mul(mat2x3 m1, mat3x2 m2, mat2 dest);
|
||||||
|
CGLM_INLINE void glm_mat2x3_mulv(mat2x3 m, vec3 v, vec2 dest);
|
||||||
|
CGLM_INLINE void glm_mat2x3_transpose(mat2x3 m, mat3x2 dest);
|
||||||
|
CGLM_INLINE void glm_mat2x3_scale(mat2x3 m, float s);
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef cglm_mat2x3_h
|
||||||
|
#define cglm_mat2x3_h
|
||||||
|
|
||||||
|
#include "common.h"
|
||||||
|
|
||||||
|
#define GLM_MAT2X3_ZERO_INIT {{0.0f, 0.0f, 0.0f}, {0.0f, 0.0f, 0.0f}}
|
||||||
|
|
||||||
|
/* for C only */
|
||||||
|
#define GLM_MAT2X3_ZERO GLM_MAT2X3_ZERO_INIT
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief copy all members of [mat] to [dest]
|
||||||
|
*
|
||||||
|
* @param[in] mat source
|
||||||
|
* @param[out] dest destination
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
void
|
||||||
|
glm_mat2x3_copy(mat2x3 mat, mat2x3 dest) {
|
||||||
|
dest[0][0] = mat[0][0];
|
||||||
|
dest[0][1] = mat[0][1];
|
||||||
|
dest[0][2] = mat[0][2];
|
||||||
|
|
||||||
|
dest[1][0] = mat[1][0];
|
||||||
|
dest[1][1] = mat[1][1];
|
||||||
|
dest[1][2] = mat[1][2];
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief make given matrix zero.
|
||||||
|
*
|
||||||
|
* @param[in, out] mat matrix
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
void
|
||||||
|
glm_mat2x3_zero(mat2x3 mat) {
|
||||||
|
CGLM_ALIGN_MAT mat2x3 t = GLM_MAT2X3_ZERO_INIT;
|
||||||
|
glm_mat2x3_copy(t, mat);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Create mat2x3 matrix from pointer
|
||||||
|
*
|
||||||
|
* @param[in] src pointer to an array of floats
|
||||||
|
* @param[out] dest matrix
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
void
|
||||||
|
glm_mat2x3_make(float * __restrict src, mat2x3 dest) {
|
||||||
|
dest[0][0] = src[0];
|
||||||
|
dest[0][1] = src[1];
|
||||||
|
dest[0][2] = src[2];
|
||||||
|
|
||||||
|
dest[1][0] = src[3];
|
||||||
|
dest[1][1] = src[4];
|
||||||
|
dest[1][2] = src[5];
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief multiply m1 and m2 to dest
|
||||||
|
*
|
||||||
|
* @code
|
||||||
|
* glm_mat2x3_mul(mat2x3, mat3x2, mat2);
|
||||||
|
* @endcode
|
||||||
|
*
|
||||||
|
* @param[in] m1 left matrix (mat2x3)
|
||||||
|
* @param[in] m2 right matrix (mat3x2)
|
||||||
|
* @param[out] dest destination matrix (mat2)
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
void
|
||||||
|
glm_mat2x3_mul(mat2x3 m1, mat3x2 m2, mat2 dest) {
|
||||||
|
float a00 = m1[0][0], a01 = m1[0][1], a02 = m1[0][2],
|
||||||
|
a10 = m1[1][0], a11 = m1[1][1], a12 = m1[1][2],
|
||||||
|
|
||||||
|
b00 = m2[0][0], b01 = m2[0][1],
|
||||||
|
b10 = m2[1][0], b11 = m2[1][1],
|
||||||
|
b20 = m2[2][0], b21 = m2[2][1];
|
||||||
|
|
||||||
|
dest[0][0] = a00 * b00 + a01 * b10 + a02 * b20;
|
||||||
|
dest[0][1] = a00 * b01 + a01 * b11 + a02 * b21;
|
||||||
|
|
||||||
|
dest[1][0] = a10 * b00 + a11 * b10 + a12 * b20;
|
||||||
|
dest[1][1] = a10 * b01 + a11 * b11 + a12 * b21;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief multiply matrix with column vector and store in dest vector
|
||||||
|
*
|
||||||
|
* @param[in] m matrix (left)
|
||||||
|
* @param[in] v vector (right, column vector)
|
||||||
|
* @param[out] dest result vector
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
void
|
||||||
|
glm_mat2x3_mulv(mat2x3 m, vec3 v, vec2 dest) {
|
||||||
|
float v0 = v[0], v1 = v[1], v2 = v[2];
|
||||||
|
|
||||||
|
dest[0] = m[0][0] * v0 + m[0][1] * v1 + m[0][2] * v2;
|
||||||
|
dest[1] = m[1][0] * v0 + m[1][1] * v1 + m[1][2] * v2;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief transpose matrix and store in dest
|
||||||
|
*
|
||||||
|
* @param[in] m matrix
|
||||||
|
* @param[out] dest result
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
void
|
||||||
|
glm_mat2x3_transpose(mat2x3 m, mat3x2 dest) {
|
||||||
|
dest[0][0] = m[0][0]; dest[0][1] = m[1][0];
|
||||||
|
dest[1][0] = m[0][1]; dest[1][1] = m[1][1];
|
||||||
|
dest[2][0] = m[0][2]; dest[2][1] = m[1][2];
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief scale (multiply with scalar) matrix
|
||||||
|
*
|
||||||
|
* multiply matrix with scalar
|
||||||
|
*
|
||||||
|
* @param[in, out] m matrix
|
||||||
|
* @param[in] s scalar
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
void
|
||||||
|
glm_mat2x3_scale(mat2x3 m, float s) {
|
||||||
|
m[0][0] *= s; m[0][1] *= s; m[0][2] *= s;
|
||||||
|
m[1][0] *= s; m[1][1] *= s; m[1][2] *= s;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
154
include/cglm/mat2x4.h
Normal file
154
include/cglm/mat2x4.h
Normal file
@@ -0,0 +1,154 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c), Recep Aslantas.
|
||||||
|
*
|
||||||
|
* MIT License (MIT), http://opensource.org/licenses/MIT
|
||||||
|
* Full license can be found in the LICENSE file
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
Macros:
|
||||||
|
GLM_MAT2X4_ZERO_INIT
|
||||||
|
GLM_MAT2X4_ZERO
|
||||||
|
|
||||||
|
Functions:
|
||||||
|
CGLM_INLINE void glm_mat2x4_copy(mat2x4 mat, mat2x4 dest);
|
||||||
|
CGLM_INLINE void glm_mat2x4_zero(mat2x4 mat);
|
||||||
|
CGLM_INLINE void glm_mat2x4_make(float * __restrict src, mat2x4 dest);
|
||||||
|
CGLM_INLINE void glm_mat2x4_mul(mat2x4 m1, mat4x2 m2, mat2 dest);
|
||||||
|
CGLM_INLINE void glm_mat2x4_mulv(mat2x4 m, vec4 v, vec2 dest);
|
||||||
|
CGLM_INLINE void glm_mat2x4_transpose(mat2x4 m, mat4x2 dest);
|
||||||
|
CGLM_INLINE void glm_mat2x4_scale(mat2x4 m, float s);
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef cglm_mat2x4_h
|
||||||
|
#define cglm_mat2x4_h
|
||||||
|
|
||||||
|
#include "common.h"
|
||||||
|
#include "vec4.h"
|
||||||
|
|
||||||
|
#define GLM_MAT2X4_ZERO_INIT {{0.0f, 0.0f, 0.0f, 0.0f}, {0.0f, 0.0f, 0.0f, 0.0f}}
|
||||||
|
|
||||||
|
/* for C only */
|
||||||
|
#define GLM_MAT2X4_ZERO GLM_MAT2X4_ZERO_INIT
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief copy all members of [mat] to [dest]
|
||||||
|
*
|
||||||
|
* @param[in] mat source
|
||||||
|
* @param[out] dest destination
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
void
|
||||||
|
glm_mat2x4_copy(mat2x4 mat, mat2x4 dest) {
|
||||||
|
glm_vec4_ucopy(mat[0], dest[0]);
|
||||||
|
glm_vec4_ucopy(mat[1], dest[1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief make given matrix zero.
|
||||||
|
*
|
||||||
|
* @param[in, out] mat matrix
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
void
|
||||||
|
glm_mat2x4_zero(mat2x4 mat) {
|
||||||
|
CGLM_ALIGN_MAT mat2x4 t = GLM_MAT2X4_ZERO_INIT;
|
||||||
|
glm_mat2x4_copy(t, mat);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Create mat2x4 matrix from pointer
|
||||||
|
*
|
||||||
|
* @param[in] src pointer to an array of floats
|
||||||
|
* @param[out] dest matrix
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
void
|
||||||
|
glm_mat2x4_make(float * __restrict src, mat2x4 dest) {
|
||||||
|
dest[0][0] = src[0];
|
||||||
|
dest[0][1] = src[1];
|
||||||
|
dest[0][2] = src[2];
|
||||||
|
dest[0][3] = src[3];
|
||||||
|
|
||||||
|
dest[1][0] = src[4];
|
||||||
|
dest[1][1] = src[5];
|
||||||
|
dest[1][2] = src[6];
|
||||||
|
dest[1][3] = src[7];
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief multiply m1 and m2 to dest
|
||||||
|
*
|
||||||
|
* @code
|
||||||
|
* glm_mat2x4_mul(mat2x4, mat4x2, mat2);
|
||||||
|
* @endcode
|
||||||
|
*
|
||||||
|
* @param[in] m1 left matrix (mat2x4)
|
||||||
|
* @param[in] m2 right matrix (mat4x2)
|
||||||
|
* @param[out] dest destination matrix (mat2)
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
void
|
||||||
|
glm_mat2x4_mul(mat2x4 m1, mat4x2 m2, mat2 dest) {
|
||||||
|
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],
|
||||||
|
|
||||||
|
b00 = m2[0][0], b01 = m2[0][1],
|
||||||
|
b10 = m2[1][0], b11 = m2[1][1],
|
||||||
|
b20 = m2[2][0], b21 = m2[2][1],
|
||||||
|
b30 = m2[3][0], b31 = m2[3][1];
|
||||||
|
|
||||||
|
dest[0][0] = a00 * b00 + a01 * b10 + a02 * b20 + a03 * b30;
|
||||||
|
dest[0][1] = a00 * b01 + a01 * b11 + a02 * b21 + a03 * b31;
|
||||||
|
|
||||||
|
dest[1][0] = a10 * b00 + a11 * b10 + a12 * b20 + a13 * b30;
|
||||||
|
dest[1][1] = a10 * b01 + a11 * b11 + a12 * b21 + a13 * b31;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief multiply matrix with column vector and store in dest vector
|
||||||
|
*
|
||||||
|
* @param[in] m matrix (left)
|
||||||
|
* @param[in] v vector (right, column vector)
|
||||||
|
* @param[out] dest result vector
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
void
|
||||||
|
glm_mat2x4_mulv(mat2x4 m, vec4 v, vec2 dest) {
|
||||||
|
float v0 = v[0], v1 = v[1], v2 = v[2], v3 = v[3];
|
||||||
|
|
||||||
|
dest[0] = m[0][0] * v0 + m[0][1] * v1 + m[0][2] * v2 + m[0][3] * v3;
|
||||||
|
dest[1] = m[1][0] * v0 + m[1][1] * v1 + m[1][2] * v2 + m[1][3] * v3;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief transpose matrix and store in dest
|
||||||
|
*
|
||||||
|
* @param[in] m matrix
|
||||||
|
* @param[out] dest result
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
void
|
||||||
|
glm_mat2x4_transpose(mat2x4 m, mat4x2 dest) {
|
||||||
|
dest[0][0] = m[0][0]; dest[0][1] = m[1][0];
|
||||||
|
dest[1][0] = m[0][1]; dest[1][1] = m[1][1];
|
||||||
|
dest[2][0] = m[0][2]; dest[2][1] = m[1][2];
|
||||||
|
dest[3][0] = m[0][3]; dest[3][1] = m[1][3];
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief scale (multiply with scalar) matrix
|
||||||
|
*
|
||||||
|
* multiply matrix with scalar
|
||||||
|
*
|
||||||
|
* @param[in, out] m matrix
|
||||||
|
* @param[in] s scalar
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
void
|
||||||
|
glm_mat2x4_scale(mat2x4 m, float s) {
|
||||||
|
m[0][0] *= s; m[0][1] *= s; m[0][2] *= s; m[0][3] *= s;
|
||||||
|
m[1][0] *= s; m[1][1] *= s; m[1][2] *= s; m[1][3] *= s;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
162
include/cglm/mat3x2.h
Normal file
162
include/cglm/mat3x2.h
Normal file
@@ -0,0 +1,162 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c), Recep Aslantas.
|
||||||
|
*
|
||||||
|
* MIT License (MIT), http://opensource.org/licenses/MIT
|
||||||
|
* Full license can be found in the LICENSE file
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
Macros:
|
||||||
|
GLM_MAT3X2_ZERO_INIT
|
||||||
|
GLM_MAT3X2_ZERO
|
||||||
|
|
||||||
|
Functions:
|
||||||
|
CGLM_INLINE void glm_mat3x2_copy(mat3x2 mat, mat3x2 dest);
|
||||||
|
CGLM_INLINE void glm_mat3x2_zero(mat3x2 mat);
|
||||||
|
CGLM_INLINE void glm_mat3x2_make(float * __restrict src, mat3x2 dest);
|
||||||
|
CGLM_INLINE void glm_mat3x2_mul(mat3x2 m1, mat2x3 m2, mat3 dest);
|
||||||
|
CGLM_INLINE void glm_mat3x2_mulv(mat3x2 m, vec2 v, vec3 dest);
|
||||||
|
CGLM_INLINE void glm_mat3x2_transpose(mat3x2 m, mat2x3 dest);
|
||||||
|
CGLM_INLINE void glm_mat3x2_scale(mat3x2 m, float s);
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef cglm_mat3x2_h
|
||||||
|
#define cglm_mat3x2_h
|
||||||
|
|
||||||
|
#include "common.h"
|
||||||
|
|
||||||
|
#define GLM_MAT3X2_ZERO_INIT {{0.0f, 0.0f}, {0.0f, 0.0f}, {0.0f, 0.0f}}
|
||||||
|
|
||||||
|
/* for C only */
|
||||||
|
#define GLM_MAT3X2_ZERO GLM_MAT3X2_ZERO_INIT
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief copy all members of [mat] to [dest]
|
||||||
|
*
|
||||||
|
* @param[in] mat source
|
||||||
|
* @param[out] dest destination
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
void
|
||||||
|
glm_mat3x2_copy(mat3x2 mat, mat3x2 dest) {
|
||||||
|
dest[0][0] = mat[0][0];
|
||||||
|
dest[0][1] = mat[0][1];
|
||||||
|
|
||||||
|
dest[1][0] = mat[1][0];
|
||||||
|
dest[1][1] = mat[1][1];
|
||||||
|
|
||||||
|
dest[2][0] = mat[2][0];
|
||||||
|
dest[2][1] = mat[2][1];
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief make given matrix zero.
|
||||||
|
*
|
||||||
|
* @param[in, out] mat matrix
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
void
|
||||||
|
glm_mat3x2_zero(mat3x2 mat) {
|
||||||
|
CGLM_ALIGN_MAT mat3x2 t = GLM_MAT3X2_ZERO_INIT;
|
||||||
|
glm_mat3x2_copy(t, mat);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Create mat3x2 matrix from pointer
|
||||||
|
*
|
||||||
|
* @param[in] src pointer to an array of floats
|
||||||
|
* @param[out] dest matrix
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
void
|
||||||
|
glm_mat3x2_make(float * __restrict src, mat3x2 dest) {
|
||||||
|
dest[0][0] = src[0];
|
||||||
|
dest[0][1] = src[1];
|
||||||
|
|
||||||
|
dest[1][0] = src[2];
|
||||||
|
dest[1][1] = src[3];
|
||||||
|
|
||||||
|
dest[2][0] = src[4];
|
||||||
|
dest[2][1] = src[5];
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief multiply m1 and m2 to dest
|
||||||
|
*
|
||||||
|
* @code
|
||||||
|
* glm_mat3x2_mul(mat3x2, mat2x3, mat3);
|
||||||
|
* @endcode
|
||||||
|
*
|
||||||
|
* @param[in] m1 left matrix (mat3x2)
|
||||||
|
* @param[in] m2 right matrix (mat2x3)
|
||||||
|
* @param[out] dest destination matrix (mat3)
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
void
|
||||||
|
glm_mat3x2_mul(mat3x2 m1, mat2x3 m2, mat3 dest) {
|
||||||
|
float a00 = m1[0][0], a01 = m1[0][1],
|
||||||
|
a10 = m1[1][0], a11 = m1[1][1],
|
||||||
|
a20 = m1[2][0], a21 = m1[2][1],
|
||||||
|
|
||||||
|
b00 = m2[0][0], b01 = m2[0][1], b02 = m2[0][2],
|
||||||
|
b10 = m2[1][0], b11 = m2[1][1], b12 = m2[1][2];
|
||||||
|
|
||||||
|
dest[0][0] = a00 * b00 + a01 * b10;
|
||||||
|
dest[0][1] = a00 * b01 + a01 * b11;
|
||||||
|
dest[0][2] = a00 * b02 + a01 * b12;
|
||||||
|
|
||||||
|
dest[1][0] = a10 * b00 + a11 * b10;
|
||||||
|
dest[1][1] = a10 * b01 + a11 * b11;
|
||||||
|
dest[1][2] = a10 * b02 + a11 * b12;
|
||||||
|
|
||||||
|
dest[2][0] = a20 * b00 + a21 * b10;
|
||||||
|
dest[2][1] = a20 * b01 + a21 * b11;
|
||||||
|
dest[2][2] = a20 * b02 + a21 * b12;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief multiply matrix with column vector and store in dest vector
|
||||||
|
*
|
||||||
|
* @param[in] m matrix (left)
|
||||||
|
* @param[in] v vector (right, column vector)
|
||||||
|
* @param[out] dest result vector
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
void
|
||||||
|
glm_mat3x2_mulv(mat3x2 m, vec2 v, vec3 dest) {
|
||||||
|
float v0 = v[0], v1 = v[1];
|
||||||
|
|
||||||
|
dest[0] = m[0][0] * v0 + m[0][1] * v1;
|
||||||
|
dest[1] = m[1][0] * v0 + m[1][1] * v1;
|
||||||
|
dest[2] = m[2][0] * v0 + m[2][1] * v1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief transpose matrix and store in dest
|
||||||
|
*
|
||||||
|
* @param[in] m matrix
|
||||||
|
* @param[out] dest result
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
void
|
||||||
|
glm_mat3x2_transpose(mat3x2 m, mat2x3 dest) {
|
||||||
|
dest[0][0] = m[0][0]; dest[0][1] = m[1][0]; dest[0][2] = m[2][0];
|
||||||
|
dest[1][0] = m[0][1]; dest[1][1] = m[1][1]; dest[1][2] = m[2][1];
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief scale (multiply with scalar) matrix
|
||||||
|
*
|
||||||
|
* multiply matrix with scalar
|
||||||
|
*
|
||||||
|
* @param[in, out] m matrix
|
||||||
|
* @param[in] s scalar
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
void
|
||||||
|
glm_mat3x2_scale(mat3x2 m, float s) {
|
||||||
|
m[0][0] *= s; m[0][1] *= s; m[1][0] *= s;
|
||||||
|
m[1][1] *= s; m[2][0] *= s; m[2][1] *= s;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
171
include/cglm/mat3x4.h
Normal file
171
include/cglm/mat3x4.h
Normal file
@@ -0,0 +1,171 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c), Recep Aslantas.
|
||||||
|
*
|
||||||
|
* MIT License (MIT), http://opensource.org/licenses/MIT
|
||||||
|
* Full license can be found in the LICENSE file
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
Macros:
|
||||||
|
GLM_MAT3X4_ZERO_INIT
|
||||||
|
GLM_MAT3X4_ZERO
|
||||||
|
|
||||||
|
Functions:
|
||||||
|
CGLM_INLINE void glm_mat3x4_copy(mat3x4 mat, mat3x4 dest);
|
||||||
|
CGLM_INLINE void glm_mat3x4_zero(mat3x4 mat);
|
||||||
|
CGLM_INLINE void glm_mat3x4_make(float * __restrict src, mat3x4 dest);
|
||||||
|
CGLM_INLINE void glm_mat3x4_mul(mat3x4 m1, mat4x3 m2, mat3 dest);
|
||||||
|
CGLM_INLINE void glm_mat3x4_mulv(mat3x4 m, vec4 v, vec3 dest);
|
||||||
|
CGLM_INLINE void glm_mat3x4_transpose(mat3x4 m, mat4x3 dest);
|
||||||
|
CGLM_INLINE void glm_mat3x4_scale(mat3x4 m, float s);
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef cglm_mat3x4_h
|
||||||
|
#define cglm_mat3x4_h
|
||||||
|
|
||||||
|
#include "common.h"
|
||||||
|
|
||||||
|
#define GLM_MAT3X4_ZERO_INIT {{0.0f, 0.0f, 0.0f, 0.0f}, \
|
||||||
|
{0.0f, 0.0f, 0.0f, 0.0f}, \
|
||||||
|
{0.0f, 0.0f, 0.0f, 0.0f}}
|
||||||
|
|
||||||
|
/* for C only */
|
||||||
|
#define GLM_MAT3X4_ZERO GLM_MAT3X4_ZERO_INIT
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief copy all members of [mat] to [dest]
|
||||||
|
*
|
||||||
|
* @param[in] mat source
|
||||||
|
* @param[out] dest destination
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
void
|
||||||
|
glm_mat3x4_copy(mat3x4 mat, mat3x4 dest) {
|
||||||
|
glm_vec4_ucopy(mat[0], dest[0]);
|
||||||
|
glm_vec4_ucopy(mat[1], dest[1]);
|
||||||
|
glm_vec4_ucopy(mat[2], dest[2]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief make given matrix zero.
|
||||||
|
*
|
||||||
|
* @param[in, out] mat matrix
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
void
|
||||||
|
glm_mat3x4_zero(mat3x4 mat) {
|
||||||
|
CGLM_ALIGN_MAT mat3x4 t = GLM_MAT3X4_ZERO_INIT;
|
||||||
|
glm_mat3x4_copy(t, mat);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Create mat3x4 matrix from pointer
|
||||||
|
*
|
||||||
|
* @param[in] src pointer to an array of floats
|
||||||
|
* @param[out] dest matrix
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
void
|
||||||
|
glm_mat3x4_make(float * __restrict src, mat3x4 dest) {
|
||||||
|
dest[0][0] = src[0];
|
||||||
|
dest[0][1] = src[1];
|
||||||
|
dest[0][2] = src[2];
|
||||||
|
dest[0][3] = src[3];
|
||||||
|
|
||||||
|
dest[1][0] = src[4];
|
||||||
|
dest[1][1] = src[5];
|
||||||
|
dest[1][2] = src[6];
|
||||||
|
dest[1][3] = src[7];
|
||||||
|
|
||||||
|
dest[2][0] = src[8];
|
||||||
|
dest[2][1] = src[9];
|
||||||
|
dest[2][2] = src[10];
|
||||||
|
dest[2][3] = src[11];
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief multiply m1 and m2 to dest
|
||||||
|
*
|
||||||
|
* @code
|
||||||
|
* glm_mat3x4_mul(mat3x4, mat4x3, mat3);
|
||||||
|
* @endcode
|
||||||
|
*
|
||||||
|
* @param[in] m1 left matrix (mat3x4)
|
||||||
|
* @param[in] m2 right matrix (mat4x3)
|
||||||
|
* @param[out] dest destination matrix (mat3)
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
void
|
||||||
|
glm_mat3x4_mul(mat3x4 m1, mat4x3 m2, mat3 dest) {
|
||||||
|
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],
|
||||||
|
a20 = m1[2][0], a21 = m1[2][1], a22 = m1[2][2], a23 = m1[2][3],
|
||||||
|
|
||||||
|
b00 = m2[0][0], b01 = m2[0][1], b02 = m2[0][2],
|
||||||
|
b10 = m2[1][0], b11 = m2[1][1], b12 = m2[1][2],
|
||||||
|
b20 = m2[2][0], b21 = m2[2][1], b22 = m2[2][2],
|
||||||
|
b30 = m2[3][0], b31 = m2[3][1], b32 = m2[3][2];
|
||||||
|
|
||||||
|
dest[0][0] = a00 * b00 + a01 * b10 + a02 * b20 + a03 * b30;
|
||||||
|
dest[0][1] = a00 * b01 + a01 * b11 + a02 * b21 + a03 * b31;
|
||||||
|
dest[0][2] = a00 * b02 + a01 * b12 + a02 * b22 + a03 * b32;
|
||||||
|
|
||||||
|
dest[1][0] = a10 * b00 + a11 * b10 + a12 * b20 + a13 * b30;
|
||||||
|
dest[1][1] = a10 * b01 + a11 * b11 + a12 * b21 + a13 * b31;
|
||||||
|
dest[1][2] = a10 * b02 + a11 * b12 + a12 * b22 + a13 * b32;
|
||||||
|
|
||||||
|
dest[2][0] = a20 * b00 + a21 * b10 + a22 * b20 + a23 * b30;
|
||||||
|
dest[2][1] = a20 * b01 + a21 * b11 + a22 * b21 + a23 * b31;
|
||||||
|
dest[2][2] = a20 * b02 + a21 * b12 + a22 * b22 + a23 * b32;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief multiply matrix with column vector and store in dest vector
|
||||||
|
*
|
||||||
|
* @param[in] m matrix (left)
|
||||||
|
* @param[in] v vector (right, column vector)
|
||||||
|
* @param[out] dest result vector
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
void
|
||||||
|
glm_mat3x4_mulv(mat3x4 m, vec4 v, vec3 dest) {
|
||||||
|
float v0 = v[0], v1 = v[1], v2 = v[2], v3 = v[3];
|
||||||
|
|
||||||
|
dest[0] = m[0][0] * v0 + m[0][1] * v1 + m[0][2] * v2 + m[0][3] * v3;
|
||||||
|
dest[1] = m[1][0] * v0 + m[1][1] * v1 + m[1][2] * v2 + m[1][3] * v3;
|
||||||
|
dest[2] = m[2][0] * v0 + m[2][1] * v1 + m[2][2] * v2 + m[2][3] * v3;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief transpose matrix and store in dest
|
||||||
|
*
|
||||||
|
* @param[in] m matrix
|
||||||
|
* @param[out] dest result
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
void
|
||||||
|
glm_mat3x4_transpose(mat3x4 m, mat4x3 dest) {
|
||||||
|
dest[0][0] = m[0][0]; dest[0][1] = m[1][0]; dest[0][2] = m[2][0];
|
||||||
|
dest[1][0] = m[0][1]; dest[1][1] = m[1][1]; dest[1][2] = m[2][1];
|
||||||
|
dest[2][0] = m[0][2]; dest[2][1] = m[1][2]; dest[2][2] = m[2][2];
|
||||||
|
dest[3][0] = m[0][3]; dest[3][1] = m[1][3]; dest[3][2] = m[2][3];
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief scale (multiply with scalar) matrix
|
||||||
|
*
|
||||||
|
* multiply matrix with scalar
|
||||||
|
*
|
||||||
|
* @param[in, out] m matrix
|
||||||
|
* @param[in] s scalar
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
void
|
||||||
|
glm_mat3x4_scale(mat3x4 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;
|
||||||
|
m[0][2] *= s; m[1][2] *= s; m[2][2] *= s;
|
||||||
|
m[0][3] *= s; m[1][3] *= s; m[2][3] *= s;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
184
include/cglm/mat4x2.h
Normal file
184
include/cglm/mat4x2.h
Normal file
@@ -0,0 +1,184 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c), Recep Aslantas.
|
||||||
|
*
|
||||||
|
* MIT License (MIT), http://opensource.org/licenses/MIT
|
||||||
|
* Full license can be found in the LICENSE file
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
Macros:
|
||||||
|
GLM_MAT4X2_ZERO_INIT
|
||||||
|
GLM_MAT4X2_ZERO
|
||||||
|
|
||||||
|
Functions:
|
||||||
|
CGLM_INLINE void glm_mat4x2_copy(mat4x2 mat, mat4x2 dest);
|
||||||
|
CGLM_INLINE void glm_mat4x2_zero(mat4x2 mat);
|
||||||
|
CGLM_INLINE void glm_mat4x2_make(float * __restrict src, mat4x2 dest);
|
||||||
|
CGLM_INLINE void glm_mat4x2_mul(mat4x2 m1, mat2x4 m2, mat4 dest);
|
||||||
|
CGLM_INLINE void glm_mat4x2_mulv(mat4x2 m, vec2 v, vec4 dest);
|
||||||
|
CGLM_INLINE void glm_mat4x2_transpose(mat4x2 m, mat2x4 dest);
|
||||||
|
CGLM_INLINE void glm_mat4x2_scale(mat4x2 m, float s);
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef cglm_mat4x2_h
|
||||||
|
#define cglm_mat4x2_h
|
||||||
|
|
||||||
|
#include "common.h"
|
||||||
|
|
||||||
|
#define GLM_MAT4X2_ZERO_INIT {{0.0f, 0.0f}, {0.0f, 0.0f}, {0.0f, 0.0f}, {0.0f, 0.0f}}
|
||||||
|
|
||||||
|
/* for C only */
|
||||||
|
#define GLM_MAT4X2_ZERO GLM_MAT4X2_ZERO_INIT
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief copy all members of [mat] to [dest]
|
||||||
|
*
|
||||||
|
* @param[in] mat source
|
||||||
|
* @param[out] dest destination
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
void
|
||||||
|
glm_mat4x2_copy(mat4x2 mat, mat4x2 dest) {
|
||||||
|
dest[0][0] = mat[0][0];
|
||||||
|
dest[0][1] = mat[0][1];
|
||||||
|
|
||||||
|
dest[1][0] = mat[1][0];
|
||||||
|
dest[1][1] = mat[1][1];
|
||||||
|
|
||||||
|
dest[2][0] = mat[2][0];
|
||||||
|
dest[2][1] = mat[2][1];
|
||||||
|
|
||||||
|
dest[3][0] = mat[3][0];
|
||||||
|
dest[3][1] = mat[3][1];
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief make given matrix zero.
|
||||||
|
*
|
||||||
|
* @param[in, out] mat matrix
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
void
|
||||||
|
glm_mat4x2_zero(mat4x2 mat) {
|
||||||
|
CGLM_ALIGN_MAT mat4x2 t = GLM_MAT4X2_ZERO_INIT;
|
||||||
|
glm_mat4x2_copy(t, mat);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Create mat4x2 matrix from pointer
|
||||||
|
*
|
||||||
|
* @param[in] src pointer to an array of floats
|
||||||
|
* @param[out] dest matrix
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
void
|
||||||
|
glm_mat4x2_make(float * __restrict src, mat4x2 dest) {
|
||||||
|
dest[0][0] = src[0];
|
||||||
|
dest[0][1] = src[1];
|
||||||
|
|
||||||
|
dest[1][0] = src[2];
|
||||||
|
dest[1][1] = src[3];
|
||||||
|
|
||||||
|
dest[2][0] = src[4];
|
||||||
|
dest[2][1] = src[5];
|
||||||
|
|
||||||
|
dest[3][0] = src[6];
|
||||||
|
dest[3][1] = src[7];
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief multiply m1 and m2 to dest
|
||||||
|
*
|
||||||
|
* @code
|
||||||
|
* glm_mat4x2_mul(mat4x2, mat2x4, mat4);
|
||||||
|
* @endcode
|
||||||
|
*
|
||||||
|
* @param[in] m1 left matrix (mat4x2)
|
||||||
|
* @param[in] m2 right matrix (mat2x4)
|
||||||
|
* @param[out] dest destination matrix (mat4)
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
void
|
||||||
|
glm_mat4x2_mul(mat4x2 m1, mat2x4 m2, mat4 dest) {
|
||||||
|
float a00 = m1[0][0], a01 = m1[0][1],
|
||||||
|
a10 = m1[1][0], a11 = m1[1][1],
|
||||||
|
a20 = m1[2][0], a21 = m1[2][1],
|
||||||
|
a30 = m1[3][0], a31 = m1[3][1],
|
||||||
|
|
||||||
|
b00 = m2[0][0], b01 = m2[0][1], b02 = m2[0][2], b03 = m2[0][3],
|
||||||
|
b10 = m2[1][0], b11 = m2[1][1], b12 = m2[1][2], b13 = m2[1][3];
|
||||||
|
|
||||||
|
dest[0][0] = a00 * b00 + a01 * b10;
|
||||||
|
dest[0][1] = a00 * b01 + a01 * b11;
|
||||||
|
dest[0][2] = a00 * b02 + a01 * b12;
|
||||||
|
dest[0][3] = a00 * b03 + a01 * b13;
|
||||||
|
|
||||||
|
dest[1][0] = a10 * b00 + a11 * b10;
|
||||||
|
dest[1][1] = a10 * b01 + a11 * b11;
|
||||||
|
dest[1][2] = a10 * b02 + a11 * b12;
|
||||||
|
dest[1][3] = a10 * b03 + a11 * b13;
|
||||||
|
|
||||||
|
dest[2][0] = a20 * b00 + a21 * b10;
|
||||||
|
dest[2][1] = a20 * b01 + a21 * b11;
|
||||||
|
dest[2][2] = a20 * b02 + a21 * b12;
|
||||||
|
dest[2][3] = a20 * b03 + a21 * b13;
|
||||||
|
|
||||||
|
dest[3][0] = a30 * b00 + a31 * b10;
|
||||||
|
dest[3][1] = a30 * b01 + a31 * b11;
|
||||||
|
dest[3][2] = a30 * b02 + a31 * b12;
|
||||||
|
dest[3][3] = a30 * b03 + a31 * b13;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief multiply matrix with column vector and store in dest vector
|
||||||
|
*
|
||||||
|
* @param[in] m matrix (left)
|
||||||
|
* @param[in] v vector (right, column vector)
|
||||||
|
* @param[out] dest result vector
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
void
|
||||||
|
glm_mat4x2_mulv(mat4x2 m, vec2 v, vec4 dest) {
|
||||||
|
float v0 = v[0], v1 = v[1];
|
||||||
|
|
||||||
|
dest[0] = m[0][0] * v0 + m[0][1] * v1;
|
||||||
|
dest[1] = m[1][0] * v0 + m[1][1] * v1;
|
||||||
|
dest[2] = m[2][0] * v0 + m[2][1] * v1;
|
||||||
|
dest[3] = m[3][0] * v0 + m[3][1] * v1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief transpose matrix and store in dest
|
||||||
|
*
|
||||||
|
* @param[in] m matrix
|
||||||
|
* @param[out] dest result
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
void
|
||||||
|
glm_mat4x2_transpose(mat4x2 m, mat2x4 dest) {
|
||||||
|
dest[0][0] = m[0][0];
|
||||||
|
dest[0][1] = m[1][0];
|
||||||
|
dest[0][2] = m[2][0];
|
||||||
|
dest[0][3] = m[3][0];
|
||||||
|
dest[1][0] = m[0][1];
|
||||||
|
dest[1][1] = m[1][1];
|
||||||
|
dest[1][2] = m[2][1];
|
||||||
|
dest[1][3] = m[3][1];
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief scale (multiply with scalar) matrix
|
||||||
|
*
|
||||||
|
* multiply matrix with scalar
|
||||||
|
*
|
||||||
|
* @param[in, out] m matrix
|
||||||
|
* @param[in] s scalar
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
void
|
||||||
|
glm_mat4x2_scale(mat4x2 m, float s) {
|
||||||
|
m[0][0] *= s; m[0][1] *= s; m[1][0] *= s; m[1][1] *= s;
|
||||||
|
m[2][0] *= s; m[2][1] *= s; m[3][0] *= s; m[3][1] *= s;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
201
include/cglm/mat4x3.h
Normal file
201
include/cglm/mat4x3.h
Normal file
@@ -0,0 +1,201 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c), Recep Aslantas.
|
||||||
|
*
|
||||||
|
* MIT License (MIT), http://opensource.org/licenses/MIT
|
||||||
|
* Full license can be found in the LICENSE file
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
Macros:
|
||||||
|
GLM_MAT4X3_ZERO_INIT
|
||||||
|
GLM_MAT4X3_ZERO
|
||||||
|
|
||||||
|
Functions:
|
||||||
|
CGLM_INLINE void glm_mat4x3_copy(mat4x3 mat, mat4x3 dest);
|
||||||
|
CGLM_INLINE void glm_mat4x3_zero(mat4x3 mat);
|
||||||
|
CGLM_INLINE void glm_mat4x3_make(float * __restrict src, mat4x3 dest);
|
||||||
|
CGLM_INLINE void glm_mat4x3_mul(mat4x3 m1, mat3x4 m2, mat4 dest);
|
||||||
|
CGLM_INLINE void glm_mat4x3_mulv(mat4x3 m, vec3 v, vec4 dest);
|
||||||
|
CGLM_INLINE void glm_mat4x3_transpose(mat4x3 m, mat3x4 dest);
|
||||||
|
CGLM_INLINE void glm_mat4x3_scale(mat4x3 m, float s);
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef cglm_mat4x3_h
|
||||||
|
#define cglm_mat4x3_h
|
||||||
|
|
||||||
|
#include "common.h"
|
||||||
|
|
||||||
|
#define GLM_MAT4X3_ZERO_INIT {{0.0f, 0.0f, 0.0f}, {0.0f, 0.0f, 0.0f}, \
|
||||||
|
{0.0f, 0.0f, 0.0f}, {0.0f, 0.0f, 0.0f}}
|
||||||
|
|
||||||
|
/* for C only */
|
||||||
|
#define GLM_MAT4X3_ZERO GLM_MAT4X3_ZERO_INIT
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief copy all members of [mat] to [dest]
|
||||||
|
*
|
||||||
|
* @param[in] mat source
|
||||||
|
* @param[out] dest destination
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
void
|
||||||
|
glm_mat4x3_copy(mat4x3 mat, mat4x3 dest) {
|
||||||
|
dest[0][0] = mat[0][0];
|
||||||
|
dest[0][1] = mat[0][1];
|
||||||
|
dest[0][2] = mat[0][2];
|
||||||
|
|
||||||
|
dest[1][0] = mat[1][0];
|
||||||
|
dest[1][1] = mat[1][1];
|
||||||
|
dest[1][2] = mat[1][2];
|
||||||
|
|
||||||
|
dest[2][0] = mat[2][0];
|
||||||
|
dest[2][1] = mat[2][1];
|
||||||
|
dest[2][2] = mat[2][2];
|
||||||
|
|
||||||
|
dest[3][0] = mat[3][0];
|
||||||
|
dest[3][1] = mat[3][1];
|
||||||
|
dest[3][2] = mat[3][2];
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief make given matrix zero.
|
||||||
|
*
|
||||||
|
* @param[in, out] mat matrix
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
void
|
||||||
|
glm_mat4x3_zero(mat4x3 mat) {
|
||||||
|
CGLM_ALIGN_MAT mat4x3 t = GLM_MAT4X3_ZERO_INIT;
|
||||||
|
glm_mat4x3_copy(t, mat);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Create mat4x3 matrix from pointer
|
||||||
|
*
|
||||||
|
* @param[in] src pointer to an array of floats
|
||||||
|
* @param[out] dest matrix
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
void
|
||||||
|
glm_mat4x3_make(float * __restrict src, mat4x3 dest) {
|
||||||
|
dest[0][0] = src[0];
|
||||||
|
dest[0][1] = src[1];
|
||||||
|
dest[0][2] = src[2];
|
||||||
|
|
||||||
|
dest[1][0] = src[3];
|
||||||
|
dest[1][1] = src[4];
|
||||||
|
dest[1][2] = src[5];
|
||||||
|
|
||||||
|
dest[2][0] = src[6];
|
||||||
|
dest[2][1] = src[7];
|
||||||
|
dest[2][2] = src[8];
|
||||||
|
|
||||||
|
dest[3][0] = src[9];
|
||||||
|
dest[3][1] = src[10];
|
||||||
|
dest[3][2] = src[11];
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief multiply m1 and m2 to dest
|
||||||
|
*
|
||||||
|
* @code
|
||||||
|
* glm_mat4x3_mul(mat4x3, mat3x4, mat4);
|
||||||
|
* @endcode
|
||||||
|
*
|
||||||
|
* @param[in] m1 left matrix (mat4x3)
|
||||||
|
* @param[in] m2 right matrix (mat3x4)
|
||||||
|
* @param[out] dest destination matrix (mat4)
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
void
|
||||||
|
glm_mat4x3_mul(mat4x3 m1, mat3x4 m2, mat4 dest) {
|
||||||
|
float a00 = m1[0][0], a01 = m1[0][1], a02 = m1[0][2],
|
||||||
|
a10 = m1[1][0], a11 = m1[1][1], a12 = m1[1][2],
|
||||||
|
a20 = m1[2][0], a21 = m1[2][1], a22 = m1[2][2],
|
||||||
|
a30 = m1[3][0], a31 = m1[3][1], a32 = m1[3][2],
|
||||||
|
|
||||||
|
b00 = m2[0][0], b01 = m2[0][1], b02 = m2[0][2], b03 = m2[0][3],
|
||||||
|
b10 = m2[1][0], b11 = m2[1][1], b12 = m2[1][2], b13 = m2[1][3],
|
||||||
|
b20 = m2[2][0], b21 = m2[2][1], b22 = m2[2][2], b23 = m2[2][3];
|
||||||
|
|
||||||
|
dest[0][0] = a00 * b00 + a01 * b10 + a02 * b20;
|
||||||
|
dest[0][1] = a00 * b01 + a01 * b11 + a02 * b21;
|
||||||
|
dest[0][2] = a00 * b02 + a01 * b12 + a02 * b22;
|
||||||
|
dest[0][3] = a00 * b03 + a01 * b13 + a02 * b23;
|
||||||
|
|
||||||
|
dest[1][0] = a10 * b00 + a11 * b10 + a12 * b20;
|
||||||
|
dest[1][1] = a10 * b01 + a11 * b11 + a12 * b21;
|
||||||
|
dest[1][2] = a10 * b02 + a11 * b12 + a12 * b22;
|
||||||
|
dest[1][3] = a10 * b03 + a11 * b13 + a12 * b23;
|
||||||
|
|
||||||
|
dest[2][0] = a20 * b00 + a21 * b10 + a22 * b20;
|
||||||
|
dest[2][1] = a20 * b01 + a21 * b11 + a22 * b21;
|
||||||
|
dest[2][2] = a20 * b02 + a21 * b12 + a22 * b22;
|
||||||
|
dest[2][3] = a20 * b03 + a21 * b13 + a22 * b23;
|
||||||
|
|
||||||
|
dest[3][0] = a30 * b00 + a31 * b10 + a32 * b20;
|
||||||
|
dest[3][1] = a30 * b01 + a31 * b11 + a32 * b21;
|
||||||
|
dest[3][2] = a30 * b02 + a31 * b12 + a32 * b22;
|
||||||
|
dest[3][3] = a30 * b03 + a31 * b13 + a32 * b23;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief multiply matrix with column vector and store in dest vector
|
||||||
|
*
|
||||||
|
* @param[in] m matrix (left)
|
||||||
|
* @param[in] v vector (right, column vector)
|
||||||
|
* @param[out] dest result vector
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
void
|
||||||
|
glm_mat4x3_mulv(mat4x3 m, vec3 v, vec4 dest) {
|
||||||
|
float v0 = v[0], v1 = v[1], v2 = v[2];
|
||||||
|
|
||||||
|
dest[0] = m[0][0] * v0 + m[0][1] * v1 + m[0][2] * v2;
|
||||||
|
dest[1] = m[1][0] * v0 + m[1][1] * v1 + m[1][2] * v2;
|
||||||
|
dest[2] = m[2][0] * v0 + m[2][1] * v1 + m[2][2] * v2;
|
||||||
|
dest[3] = m[3][0] * v0 + m[3][1] * v1 + m[3][2] * v2;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief transpose matrix and store in dest
|
||||||
|
*
|
||||||
|
* @param[in] m matrix
|
||||||
|
* @param[out] dest result
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
void
|
||||||
|
glm_mat4x3_transpose(mat4x3 m, mat3x4 dest) {
|
||||||
|
dest[0][0] = m[0][0];
|
||||||
|
dest[0][1] = m[1][0];
|
||||||
|
dest[0][2] = m[2][0];
|
||||||
|
dest[0][3] = m[3][0];
|
||||||
|
|
||||||
|
dest[1][0] = m[0][1];
|
||||||
|
dest[1][1] = m[1][1];
|
||||||
|
dest[1][2] = m[2][1];
|
||||||
|
dest[1][3] = m[3][1];
|
||||||
|
|
||||||
|
dest[2][0] = m[0][2];
|
||||||
|
dest[2][1] = m[1][2];
|
||||||
|
dest[2][2] = m[2][2];
|
||||||
|
dest[2][3] = m[3][2];
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief scale (multiply with scalar) matrix
|
||||||
|
*
|
||||||
|
* multiply matrix with scalar
|
||||||
|
*
|
||||||
|
* @param[in, out] m matrix
|
||||||
|
* @param[in] s scalar
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
void
|
||||||
|
glm_mat4x3_scale(mat4x3 m, float s) {
|
||||||
|
m[0][0] *= s; m[0][1] *= s; m[0][2] *= s; m[1][0] *= s;
|
||||||
|
m[1][1] *= s; m[1][2] *= s; m[2][0] *= s; m[2][1] *= s;
|
||||||
|
m[2][2] *= s; m[3][0] *= s; m[3][1] *= s; m[3][2] *= s;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -258,7 +258,7 @@ glm_quat_normalize_to(versor q, versor dest) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
glmm_store(dest, wasm_f32x4_div(x0, wasm_f32x4_sqrt(xdot)));
|
glmm_store(dest, wasm_f32x4_div(x0, wasm_f32x4_sqrt(xdot)));
|
||||||
#elif defined( __SSE2__ ) || defined( __SSE2__ )
|
#elif defined( __SSE__ ) || defined( __SSE2__ )
|
||||||
__m128 xdot, x0;
|
__m128 xdot, x0;
|
||||||
float dot;
|
float dot;
|
||||||
|
|
||||||
|
|||||||
@@ -174,11 +174,7 @@ glmm_fnmadd(float32x4_t a, float32x4_t b, float32x4_t c) {
|
|||||||
static inline
|
static inline
|
||||||
float32x4_t
|
float32x4_t
|
||||||
glmm_fmsub(float32x4_t a, float32x4_t b, float32x4_t c) {
|
glmm_fmsub(float32x4_t a, float32x4_t b, float32x4_t c) {
|
||||||
#if CGLM_ARM64
|
return glmm_fmadd(a, b, vnegq_f32(c));
|
||||||
return vfmsq_f32(c, a, b);
|
|
||||||
#else
|
|
||||||
return vmlsq_f32(c, a, b);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline
|
static inline
|
||||||
|
|||||||
@@ -63,7 +63,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* ARM Neon */
|
/* ARM Neon */
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32) && defined(_MSC_VER)
|
||||||
/* TODO: non-ARM stuff already inported, will this be better option */
|
/* TODO: non-ARM stuff already inported, will this be better option */
|
||||||
/* # include <intrin.h> */
|
/* # include <intrin.h> */
|
||||||
|
|
||||||
|
|||||||
@@ -17,8 +17,14 @@ extern "C" {
|
|||||||
#include "struct/vec3.h"
|
#include "struct/vec3.h"
|
||||||
#include "struct/vec4.h"
|
#include "struct/vec4.h"
|
||||||
#include "struct/mat2.h"
|
#include "struct/mat2.h"
|
||||||
|
#include "struct/mat2x3.h"
|
||||||
|
#include "struct/mat2x4.h"
|
||||||
#include "struct/mat3.h"
|
#include "struct/mat3.h"
|
||||||
|
#include "struct/mat3x2.h"
|
||||||
|
#include "struct/mat3x4.h"
|
||||||
#include "struct/mat4.h"
|
#include "struct/mat4.h"
|
||||||
|
#include "struct/mat4x2.h"
|
||||||
|
#include "struct/mat4x3.h"
|
||||||
#include "struct/affine.h"
|
#include "struct/affine.h"
|
||||||
#include "struct/frustum.h"
|
#include "struct/frustum.h"
|
||||||
#include "struct/plane.h"
|
#include "struct/plane.h"
|
||||||
|
|||||||
235
include/cglm/struct/aabb2d.h
Normal file
235
include/cglm/struct/aabb2d.h
Normal file
@@ -0,0 +1,235 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c), Recep Aslantas.
|
||||||
|
*
|
||||||
|
* MIT License (MIT), http://opensource.org/licenses/MIT
|
||||||
|
* Full license can be found in the LICENSE file
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef cglms_aabb2ds_h
|
||||||
|
#define cglms_aabb2ds_h
|
||||||
|
|
||||||
|
#include "../common.h"
|
||||||
|
#include "../types-struct.h"
|
||||||
|
#include "../aabb2d.h"
|
||||||
|
#include "vec2.h"
|
||||||
|
#include "vec4.h"
|
||||||
|
#include "mat4.h"
|
||||||
|
|
||||||
|
/* api definition */
|
||||||
|
#define glms_aabb2d_(NAME) CGLM_STRUCTAPI(aabb, NAME)
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief apply transform to Axis-Aligned Bounding Box
|
||||||
|
*
|
||||||
|
* @param[in] aabb bounding box
|
||||||
|
* @param[in] m transform matrix
|
||||||
|
* @param[out] dest transformed bounding box
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
void
|
||||||
|
glms_aabb2d_(transform)(vec2s aabb[2], mat3s m, vec2s dest[2]) {
|
||||||
|
vec2 rawAabb[2];
|
||||||
|
vec2 rawDest[2];
|
||||||
|
|
||||||
|
glms_vec2_(unpack)(rawAabb, aabb, 2);
|
||||||
|
glm_aabb2d_transform(rawAabb, m.raw, rawDest);
|
||||||
|
glms_vec2_(pack)(dest, rawDest, 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief merges two AABB bounding box and creates new one
|
||||||
|
*
|
||||||
|
* two box must be in same space, if one of box is in different space then
|
||||||
|
* you should consider to convert it's space by glm_box_space
|
||||||
|
*
|
||||||
|
* @param[in] aabb1 bounding box 1
|
||||||
|
* @param[in] aabb2 bounding box 2
|
||||||
|
* @param[out] dest merged bounding box
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
void
|
||||||
|
glms_aabb2d_(merge)(vec2s aabb1[2], vec2s aabb2[2], vec2s dest[2]) {
|
||||||
|
vec2 rawAabb1[2];
|
||||||
|
vec2 rawAabb2[2];
|
||||||
|
vec2 rawDest[2];
|
||||||
|
|
||||||
|
glms_vec2_(unpack)(rawAabb1, aabb1, 2);
|
||||||
|
glms_vec2_(unpack)(rawAabb2, aabb2, 2);
|
||||||
|
glm_aabb2d_merge(rawAabb1, rawAabb2, rawDest);
|
||||||
|
glms_vec2_(pack)(dest, rawDest, 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief crops a bounding box with another one.
|
||||||
|
*
|
||||||
|
* 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
|
||||||
|
*
|
||||||
|
* @param[in] aabb bounding box 1
|
||||||
|
* @param[in] cropAabb crop box
|
||||||
|
* @param[out] dest cropped bounding box
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
void
|
||||||
|
glms_aabb2d_(crop)(vec2s aabb[2], vec2s cropAabb[2], vec2s dest[2]) {
|
||||||
|
vec2 rawAabb[2];
|
||||||
|
vec2 rawCropAabb[2];
|
||||||
|
vec2 rawDest[2];
|
||||||
|
|
||||||
|
glms_vec2_(unpack)(rawAabb, aabb, 2);
|
||||||
|
glms_vec2_(unpack)(rawCropAabb, cropAabb, 2);
|
||||||
|
glm_aabb2d_crop(rawAabb, rawCropAabb, rawDest);
|
||||||
|
glms_vec2_(pack)(dest, rawDest, 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief crops a bounding box with another one.
|
||||||
|
*
|
||||||
|
* 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
|
||||||
|
*
|
||||||
|
* @param[in] aabb bounding box
|
||||||
|
* @param[in] cropAabb crop box
|
||||||
|
* @param[in] clampAabb miniumum box
|
||||||
|
* @param[out] dest cropped bounding box
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
void
|
||||||
|
glms_aabb2d_(crop_until)(vec2s aabb[2],
|
||||||
|
vec2s cropAabb[2],
|
||||||
|
vec2s clampAabb[2],
|
||||||
|
vec2s dest[2]) {
|
||||||
|
glms_aabb2d_(crop)(aabb, cropAabb, dest);
|
||||||
|
glms_aabb2d_(merge)(clampAabb, dest, dest);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief invalidate AABB min and max values
|
||||||
|
*
|
||||||
|
* @param[in, out] aabb bounding box
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
void
|
||||||
|
glms_aabb2d_(invalidate)(vec2s box[2]) {
|
||||||
|
box[0] = glms_vec2_(fill)(FLT_MAX);
|
||||||
|
box[1] = glms_vec2_(fill)(-FLT_MAX);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief check if AABB is valid or not
|
||||||
|
*
|
||||||
|
* @param[in] aabb bounding box
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
bool
|
||||||
|
glms_aabb2d_(isvalid)(vec2s aabb[2]) {
|
||||||
|
vec2 rawAabb[2];
|
||||||
|
glms_vec2_(unpack)(rawAabb, aabb, 2);
|
||||||
|
return glm_aabb2d_isvalid(rawAabb);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief distance between of min and max
|
||||||
|
*
|
||||||
|
* @param[in] aabb bounding box
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
float
|
||||||
|
glms_aabb2d_(size)(vec2s aabb[2]) {
|
||||||
|
return glm_vec2_distance(aabb[0].raw, aabb[1].raw);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief radius of sphere which surrounds AABB
|
||||||
|
*
|
||||||
|
* @param[in] aabb bounding box
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
float
|
||||||
|
glms_aabb2d_(radius)(vec2s aabb[2]) {
|
||||||
|
return glms_aabb2d_(size)(aabb) * 0.5f;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief computes center point of AABB
|
||||||
|
*
|
||||||
|
* @param[in] aabb bounding box
|
||||||
|
* @returns center of bounding box
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
vec2s
|
||||||
|
glms_aabb2d_(center)(vec2s aabb[2]) {
|
||||||
|
return glms_vec2_(center)(aabb[0], aabb[1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief check if two AABB intersects
|
||||||
|
*
|
||||||
|
* @param[in] aabb bounding box
|
||||||
|
* @param[in] other other bounding box
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
bool
|
||||||
|
glms_aabb2d_(aabb)(vec2s aabb[2], vec2s other[2]) {
|
||||||
|
vec2 rawAabb[2];
|
||||||
|
vec2 rawOther[2];
|
||||||
|
|
||||||
|
glms_vec2_(unpack)(rawAabb, aabb, 2);
|
||||||
|
glms_vec2_(unpack)(rawOther, other, 2);
|
||||||
|
return glm_aabb2d_aabb(rawAabb, rawOther);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief check if AABB intersects with a circle
|
||||||
|
*
|
||||||
|
* https://github.com/erich666/GraphicsGems/blob/master/gems/BoxSphere.c
|
||||||
|
* Solid Box - Solid Sphere test.
|
||||||
|
*
|
||||||
|
* @param[in] aabb solid bounding box
|
||||||
|
* @param[in] s solid sphere
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
bool
|
||||||
|
glms_aabb2d_(circle)(vec2s aabb[2], vec3s c) {
|
||||||
|
vec2 rawAabb[2];
|
||||||
|
|
||||||
|
glms_vec2_(unpack)(rawAabb, aabb, 2);
|
||||||
|
return glm_aabb2d_circle(rawAabb, c.raw);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief check if point is inside of AABB
|
||||||
|
*
|
||||||
|
* @param[in] aabb bounding box
|
||||||
|
* @param[in] point point
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
bool
|
||||||
|
glms_aabb2d_(point)(vec2s aabb[2], vec2s point) {
|
||||||
|
vec2 rawAabb[2];
|
||||||
|
|
||||||
|
glms_vec2_(unpack)(rawAabb, aabb, 2);
|
||||||
|
return glm_aabb2d_point(rawAabb, point.raw);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief check if AABB contains other AABB
|
||||||
|
*
|
||||||
|
* @param[in] box bounding box
|
||||||
|
* @param[in] other other bounding box
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
bool
|
||||||
|
glms_aabb2d_(contains)(vec2s aabb[2], vec2s other[2]) {
|
||||||
|
vec2 rawAabb[2];
|
||||||
|
vec2 rawOther[2];
|
||||||
|
|
||||||
|
glms_vec2_(unpack)(rawAabb, aabb, 2);
|
||||||
|
glms_vec2_(unpack)(rawOther, other, 2);
|
||||||
|
return glm_aabb2d_contains(rawAabb, rawOther);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* cglms_aabb2ds_h */
|
||||||
|
|
||||||
@@ -22,7 +22,7 @@
|
|||||||
CGLM_INLINE mat4s glms_rotate_make(float angle, vec3s axis);
|
CGLM_INLINE mat4s glms_rotate_make(float angle, vec3s axis);
|
||||||
CGLM_INLINE mat4s glms_rotate(mat4s m, float angle, vec3s axis);
|
CGLM_INLINE mat4s glms_rotate(mat4s m, float angle, vec3s axis);
|
||||||
CGLM_INLINE mat4s glms_rotate_at(mat4s m, vec3s pivot, float angle, vec3s axis);
|
CGLM_INLINE mat4s glms_rotate_at(mat4s m, vec3s pivot, float angle, vec3s axis);
|
||||||
CGLM_INLINE mat4s glms_rotate_atm(mat4s m, vec3s pivot, float angle, vec3s axis);
|
CGLM_INLINE mat4s glms_rotate_atm(vec3s pivot, float angle, vec3s axis);
|
||||||
CGLM_INLINE mat4s glms_spin(mat4s m, float angle, vec3s axis);
|
CGLM_INLINE mat4s glms_spin(mat4s m, float angle, vec3s axis);
|
||||||
CGLM_INLINE vec3s glms_decompose_scalev(mat4s m);
|
CGLM_INLINE vec3s glms_decompose_scalev(mat4s m);
|
||||||
CGLM_INLINE bool glms_uniscaled(mat4s m);
|
CGLM_INLINE bool glms_uniscaled(mat4s m);
|
||||||
@@ -125,7 +125,6 @@ glms_rotate_make(float angle, vec3s axis) {
|
|||||||
* this should work faster than glm_rotate_at because it reduces
|
* this should work faster than glm_rotate_at because it reduces
|
||||||
* one glm_translate.
|
* one glm_translate.
|
||||||
*
|
*
|
||||||
* @param[in] m affine transfrom
|
|
||||||
* @param[in] pivot rotation center
|
* @param[in] pivot rotation center
|
||||||
* @param[in] angle angle (radians)
|
* @param[in] angle angle (radians)
|
||||||
* @param[in] axis axis
|
* @param[in] axis axis
|
||||||
@@ -133,7 +132,8 @@ glms_rotate_make(float angle, vec3s axis) {
|
|||||||
*/
|
*/
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
mat4s
|
mat4s
|
||||||
glms_rotate_atm(mat4s m, vec3s pivot, float angle, vec3s axis) {
|
glms_rotate_atm(vec3s pivot, float angle, vec3s axis) {
|
||||||
|
mat4s m;
|
||||||
glm_rotate_atm(m.raw, pivot.raw, angle, axis.raw);
|
glm_rotate_atm(m.raw, pivot.raw, angle, axis.raw);
|
||||||
return m;
|
return m;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,6 +24,8 @@
|
|||||||
#include "../../types-struct.h"
|
#include "../../types-struct.h"
|
||||||
#include "../../plane.h"
|
#include "../../plane.h"
|
||||||
#include "../../cam.h"
|
#include "../../cam.h"
|
||||||
|
#include "../vec3.h"
|
||||||
|
#include "../../clipspace/ortho_lh_no.h"
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief set up orthographic projection matrix
|
* @brief set up orthographic projection matrix
|
||||||
|
|||||||
@@ -24,6 +24,8 @@
|
|||||||
#include "../../types-struct.h"
|
#include "../../types-struct.h"
|
||||||
#include "../../plane.h"
|
#include "../../plane.h"
|
||||||
#include "../../cam.h"
|
#include "../../cam.h"
|
||||||
|
#include "../vec3.h"
|
||||||
|
#include "../../clipspace/ortho_lh_zo.h"
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief set up orthographic projection matrix
|
* @brief set up orthographic projection matrix
|
||||||
|
|||||||
@@ -24,6 +24,8 @@
|
|||||||
#include "../../types-struct.h"
|
#include "../../types-struct.h"
|
||||||
#include "../../plane.h"
|
#include "../../plane.h"
|
||||||
#include "../../cam.h"
|
#include "../../cam.h"
|
||||||
|
#include "../vec3.h"
|
||||||
|
#include "../../clipspace/ortho_rh_no.h"
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief set up orthographic projection matrix
|
* @brief set up orthographic projection matrix
|
||||||
|
|||||||
@@ -24,6 +24,8 @@
|
|||||||
#include "../../types-struct.h"
|
#include "../../types-struct.h"
|
||||||
#include "../../plane.h"
|
#include "../../plane.h"
|
||||||
#include "../../cam.h"
|
#include "../../cam.h"
|
||||||
|
#include "../vec3.h"
|
||||||
|
#include "../../clipspace/ortho_rh_zo.h"
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief set up orthographic projection matrix
|
* @brief set up orthographic projection matrix
|
||||||
|
|||||||
@@ -39,6 +39,7 @@
|
|||||||
#include "../../types-struct.h"
|
#include "../../types-struct.h"
|
||||||
#include "../../plane.h"
|
#include "../../plane.h"
|
||||||
#include "../../cam.h"
|
#include "../../cam.h"
|
||||||
|
#include "../../clipspace/persp_lh_no.h"
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief set up perspective peprojection matrix
|
* @brief set up perspective peprojection matrix
|
||||||
|
|||||||
@@ -39,6 +39,7 @@
|
|||||||
#include "../../types-struct.h"
|
#include "../../types-struct.h"
|
||||||
#include "../../plane.h"
|
#include "../../plane.h"
|
||||||
#include "../../cam.h"
|
#include "../../cam.h"
|
||||||
|
#include "../../clipspace/persp_lh_zo.h"
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief set up perspective peprojection matrix
|
* @brief set up perspective peprojection matrix
|
||||||
|
|||||||
@@ -39,6 +39,7 @@
|
|||||||
#include "../../types-struct.h"
|
#include "../../types-struct.h"
|
||||||
#include "../../plane.h"
|
#include "../../plane.h"
|
||||||
#include "../../cam.h"
|
#include "../../cam.h"
|
||||||
|
#include "../../clipspace/persp_rh_no.h"
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief set up perspective peprojection matrix
|
* @brief set up perspective peprojection matrix
|
||||||
|
|||||||
@@ -39,6 +39,7 @@
|
|||||||
#include "../../types-struct.h"
|
#include "../../types-struct.h"
|
||||||
#include "../../plane.h"
|
#include "../../plane.h"
|
||||||
#include "../../cam.h"
|
#include "../../cam.h"
|
||||||
|
#include "../../clipspace/persp_rh_zo.h"
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief set up perspective peprojection matrix
|
* @brief set up perspective peprojection matrix
|
||||||
|
|||||||
@@ -7,8 +7,9 @@
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
Functions:
|
Functions:
|
||||||
CGLM_INLINE vec3s glms_unprojecti_no(vec3s pos, mat4s invMat, vec4s vp, vec3 dest)
|
CGLM_INLINE vec3s glms_unprojecti_no(vec3s pos, mat4s invMat, vec4s vp)
|
||||||
CGLM_INLINE vec3s glms_project_no(vec3s pos, mat4s m, vec4s vp, vec3s dest)
|
CGLM_INLINE vec3s glms_project_no(vec3s pos, mat4s m, vec4s vp)
|
||||||
|
CGLM_INLINE float glms_project_z_no(vec3s v, mat4s m)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef cglms_project_no_h
|
#ifndef cglms_project_no_h
|
||||||
@@ -18,6 +19,7 @@
|
|||||||
#include "../../types-struct.h"
|
#include "../../types-struct.h"
|
||||||
#include "../../plane.h"
|
#include "../../plane.h"
|
||||||
#include "../../cam.h"
|
#include "../../cam.h"
|
||||||
|
#include "../../clipspace/project_no.h"
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief maps the specified viewport coordinates into specified space [1]
|
* @brief maps the specified viewport coordinates into specified space [1]
|
||||||
@@ -48,7 +50,7 @@
|
|||||||
*/
|
*/
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
vec3s
|
vec3s
|
||||||
glms_unprojecti_no(vec3s pos, mat4s invMat, vec4s vp, vec3 dest) {
|
glms_unprojecti_no(vec3s pos, mat4s invMat, vec4s vp) {
|
||||||
vec3s dest;
|
vec3s dest;
|
||||||
glm_unprojecti_no(pos.raw, invMat.raw, vp.raw, dest.raw);
|
glm_unprojecti_no(pos.raw, invMat.raw, vp.raw, dest.raw);
|
||||||
return dest;
|
return dest;
|
||||||
@@ -69,7 +71,7 @@ glms_unprojecti_no(vec3s pos, mat4s invMat, vec4s vp, vec3 dest) {
|
|||||||
*/
|
*/
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
vec3s
|
vec3s
|
||||||
glms_project_no(vec3s pos, mat4s m, vec4s vp, vec3s dest) {
|
glms_project_no(vec3s pos, mat4s m, vec4s vp) {
|
||||||
vec3s dest;
|
vec3s dest;
|
||||||
glm_project_no(pos.raw, m.raw, vp.raw, dest.raw);
|
glm_project_no(pos.raw, m.raw, vp.raw, dest.raw);
|
||||||
return dest;
|
return dest;
|
||||||
@@ -88,7 +90,7 @@ glms_project_no(vec3s pos, mat4s m, vec4s vp, vec3s dest) {
|
|||||||
* @returns projected z coordinate
|
* @returns projected z coordinate
|
||||||
*/
|
*/
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
vec3s
|
float
|
||||||
glms_project_z_no(vec3s v, mat4s m) {
|
glms_project_z_no(vec3s v, mat4s m) {
|
||||||
return glm_project_z_no(v.raw, m.raw);
|
return glm_project_z_no(v.raw, m.raw);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,8 +7,9 @@
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
Functions:
|
Functions:
|
||||||
CGLM_INLINE vec3s glms_unprojecti_no(vec3s pos, mat4s invMat, vec4s vp, vec3 dest)
|
CGLM_INLINE vec3s glms_unprojecti_no(vec3s pos, mat4s invMat, vec4s vp)
|
||||||
CGLM_INLINE vec3s glms_project_no(vec3s pos, mat4s m, vec4s vp, vec3s dest)
|
CGLM_INLINE vec3s glms_project_no(vec3s pos, mat4s m, vec4s vp)
|
||||||
|
CGLM_INLINE float glms_project_z_zo(vec3s v, mat4s m)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef cglms_project_zo_h
|
#ifndef cglms_project_zo_h
|
||||||
@@ -18,6 +19,7 @@
|
|||||||
#include "../../types-struct.h"
|
#include "../../types-struct.h"
|
||||||
#include "../../plane.h"
|
#include "../../plane.h"
|
||||||
#include "../../cam.h"
|
#include "../../cam.h"
|
||||||
|
#include "../../clipspace/project_zo.h"
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief maps the specified viewport coordinates into specified space [1]
|
* @brief maps the specified viewport coordinates into specified space [1]
|
||||||
@@ -48,7 +50,7 @@
|
|||||||
*/
|
*/
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
vec3s
|
vec3s
|
||||||
glms_unprojecti_zo(vec3s pos, mat4s invMat, vec4s vp, vec3 dest) {
|
glms_unprojecti_zo(vec3s pos, mat4s invMat, vec4s vp) {
|
||||||
vec3s dest;
|
vec3s dest;
|
||||||
glm_unprojecti_zo(pos.raw, invMat.raw, vp.raw, dest.raw);
|
glm_unprojecti_zo(pos.raw, invMat.raw, vp.raw, dest.raw);
|
||||||
return dest;
|
return dest;
|
||||||
@@ -69,7 +71,7 @@ glms_unprojecti_zo(vec3s pos, mat4s invMat, vec4s vp, vec3 dest) {
|
|||||||
*/
|
*/
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
vec3s
|
vec3s
|
||||||
glms_project_zo(vec3s pos, mat4s m, vec4s vp, vec3 dest) {
|
glms_project_zo(vec3s pos, mat4s m, vec4s vp) {
|
||||||
vec3s dest;
|
vec3s dest;
|
||||||
glm_project_zo(pos.raw, m.raw, vp.raw, dest.raw);
|
glm_project_zo(pos.raw, m.raw, vp.raw, dest.raw);
|
||||||
return dest;
|
return dest;
|
||||||
@@ -88,7 +90,7 @@ glms_project_zo(vec3s pos, mat4s m, vec4s vp, vec3 dest) {
|
|||||||
* @returns projected z coordinate
|
* @returns projected z coordinate
|
||||||
*/
|
*/
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
vec3s
|
float
|
||||||
glms_project_z_zo(vec3s v, mat4s m) {
|
glms_project_z_zo(vec3s v, mat4s m) {
|
||||||
return glm_project_z_zo(v.raw, m.raw);
|
return glm_project_z_zo(v.raw, m.raw);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,6 +19,7 @@
|
|||||||
#include "../../types-struct.h"
|
#include "../../types-struct.h"
|
||||||
#include "../../plane.h"
|
#include "../../plane.h"
|
||||||
#include "../../cam.h"
|
#include "../../cam.h"
|
||||||
|
#include "../../clipspace/view_lh_no.h"
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief set up view matrix
|
* @brief set up view matrix
|
||||||
|
|||||||
@@ -19,6 +19,7 @@
|
|||||||
#include "../../types-struct.h"
|
#include "../../types-struct.h"
|
||||||
#include "../../plane.h"
|
#include "../../plane.h"
|
||||||
#include "../../cam.h"
|
#include "../../cam.h"
|
||||||
|
#include "../../clipspace/view_lh_zo.h"
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief set up view matrix
|
* @brief set up view matrix
|
||||||
|
|||||||
@@ -19,6 +19,7 @@
|
|||||||
#include "../../types-struct.h"
|
#include "../../types-struct.h"
|
||||||
#include "../../plane.h"
|
#include "../../plane.h"
|
||||||
#include "../../cam.h"
|
#include "../../cam.h"
|
||||||
|
#include "../../clipspace/view_rh_no.h"
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief set up view matrix
|
* @brief set up view matrix
|
||||||
|
|||||||
@@ -19,6 +19,7 @@
|
|||||||
#include "../../types-struct.h"
|
#include "../../types-struct.h"
|
||||||
#include "../../plane.h"
|
#include "../../plane.h"
|
||||||
#include "../../cam.h"
|
#include "../../cam.h"
|
||||||
|
#include "../../clipspace/view_rh_zo.h"
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief set up view matrix
|
* @brief set up view matrix
|
||||||
|
|||||||
@@ -26,6 +26,12 @@
|
|||||||
CGLM_INLINE mat4s glms_euler_zxy(vec3s angles)
|
CGLM_INLINE mat4s glms_euler_zxy(vec3s angles)
|
||||||
CGLM_INLINE mat4s glms_euler_zyx(vec3s angles)
|
CGLM_INLINE mat4s glms_euler_zyx(vec3s angles)
|
||||||
CGLM_INLINE mat4s glms_euler_by_order(vec3s angles, glm_euler_seq ord)
|
CGLM_INLINE mat4s glms_euler_by_order(vec3s angles, glm_euler_seq ord)
|
||||||
|
CGLM_INLINE versors glms_euler_xyz_quat(vec3s angles)
|
||||||
|
CGLM_INLINE versors glms_euler_xzy_quat(vec3s angles)
|
||||||
|
CGLM_INLINE versors glms_euler_yxz_quat(vec3s angles)
|
||||||
|
CGLM_INLINE versors glms_euler_yzx_quat(vec3s angles)
|
||||||
|
CGLM_INLINE versors glms_euler_zxy_quat(vec3s angles)
|
||||||
|
CGLM_INLINE versors glms_euler_zyx_quat(vec3s angles)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef cglms_euler_h
|
#ifndef cglms_euler_h
|
||||||
@@ -149,4 +155,95 @@ glms_euler_by_order(vec3s angles, glm_euler_seq ord) {
|
|||||||
return dest;
|
return dest;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief creates NEW quaternion using rotation angles and does
|
||||||
|
* rotations in x y z order (roll pitch yaw)
|
||||||
|
*
|
||||||
|
* @param[in] angles angles x y z (radians)
|
||||||
|
* @returns quaternion
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
versors
|
||||||
|
glms_euler_xyz_quat(vec3s angles) {
|
||||||
|
versors dest;
|
||||||
|
glm_euler_xyz_quat(angles.raw, dest.raw);
|
||||||
|
return dest;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief creates NEW quaternion using rotation angles and does
|
||||||
|
* rotations in x z y order (roll yaw pitch)
|
||||||
|
*
|
||||||
|
* @param[in] angles angles x y z (radians)
|
||||||
|
* @returns quaternion
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
versors
|
||||||
|
glms_euler_xzy_quat(vec3s angles) {
|
||||||
|
versors dest;
|
||||||
|
glm_euler_xzy_quat(angles.raw, dest.raw);
|
||||||
|
return dest;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief creates NEW quaternion using rotation angles and does
|
||||||
|
* rotations in y x z order (pitch roll yaw)
|
||||||
|
*
|
||||||
|
* @param[in] angles angles x y z (radians)
|
||||||
|
* @returns quaternion
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
versors
|
||||||
|
glms_euler_yxz_quat(vec3s angles) {
|
||||||
|
versors dest;
|
||||||
|
glm_euler_yxz_quat(angles.raw, dest.raw);
|
||||||
|
return dest;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief creates NEW quaternion using rotation angles and does
|
||||||
|
* rotations in y z x order (pitch yaw roll)
|
||||||
|
*
|
||||||
|
* @param[in] angles angles x y z (radians)
|
||||||
|
* @returns quaternion
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
versors
|
||||||
|
glms_euler_yzx_quat(vec3s angles) {
|
||||||
|
versors dest;
|
||||||
|
glm_euler_yzx_quat(angles.raw, dest.raw);
|
||||||
|
return dest;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief creates NEW quaternion using rotation angles and does
|
||||||
|
* rotations in z x y order (yaw roll pitch)
|
||||||
|
*
|
||||||
|
* @param[in] angles angles x y z (radians)
|
||||||
|
* @returns quaternion
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
versors
|
||||||
|
glms_euler_zxy_quat(vec3s angles) {
|
||||||
|
versors dest;
|
||||||
|
glm_euler_zxy_quat(angles.raw, dest.raw);
|
||||||
|
return dest;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief creates NEW quaternion using rotation angles and does
|
||||||
|
* rotations in z y x order (yaw pitch roll)
|
||||||
|
*
|
||||||
|
* @param[in] angles angles x y z (radians)
|
||||||
|
* @returns quaternion
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
versors
|
||||||
|
glms_euler_zyx_quat(vec3s angles) {
|
||||||
|
versors dest;
|
||||||
|
glm_euler_zyx_quat(angles.raw, dest.raw);
|
||||||
|
return dest;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif /* cglms_euler_h */
|
#endif /* cglms_euler_h */
|
||||||
|
|||||||
115
include/cglm/struct/handed/euler_to_quat_lh.h
Normal file
115
include/cglm/struct/handed/euler_to_quat_lh.h
Normal file
@@ -0,0 +1,115 @@
|
|||||||
|
/*
|
||||||
|
* 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 glms_euler_xyz_quat_lh(vec3 angles, versor dest);
|
||||||
|
CGLM_INLINE void glms_euler_xzy_quat_lh(vec3 angles, versor dest);
|
||||||
|
CGLM_INLINE void glms_euler_yxz_quat_lh(vec3 angles, versor dest);
|
||||||
|
CGLM_INLINE void glms_euler_yzx_quat_lh(vec3 angles, versor dest);
|
||||||
|
CGLM_INLINE void glms_euler_zxy_quat_lh(vec3 angles, versor dest);
|
||||||
|
CGLM_INLINE void glms_euler_zyx_quat_lh(vec3 angles, versor dest);
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef cglms_euler_to_quat_lh_h
|
||||||
|
#define cglms_euler_to_quat_lh_h
|
||||||
|
|
||||||
|
#include "../common.h"
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief creates NEW quaternion using rotation angles and does
|
||||||
|
* rotations in x y z order in left hand (roll pitch yaw)
|
||||||
|
*
|
||||||
|
* @param[in] angles angles x y z (radians)
|
||||||
|
* @param[out] dest quaternion
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
versors
|
||||||
|
glms_euler_xyz_quat_lh(vec3s angles) {
|
||||||
|
versors dest;
|
||||||
|
glm_euler_xyz_quat_lh(angles.raw, dest.raw);
|
||||||
|
return dest;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief creates NEW quaternion using rotation angles and does
|
||||||
|
* rotations in x z y order in left hand (roll yaw pitch)
|
||||||
|
*
|
||||||
|
* @param[in] angles angles x y z (radians)
|
||||||
|
* @param[out] dest quaternion
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
versors
|
||||||
|
glms_euler_xzy_quat_lh(vec3s angles) {
|
||||||
|
versors dest;
|
||||||
|
glm_euler_xzy_quat_lh(angles.raw, dest.raw);
|
||||||
|
return dest;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief creates NEW quaternion using rotation angles and does
|
||||||
|
* rotations in y x z order in left hand (pitch roll yaw)
|
||||||
|
*
|
||||||
|
* @param[in] angles angles x y z (radians)
|
||||||
|
* @param[out] dest quaternion
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
versors
|
||||||
|
glms_euler_yxz_quat_lh(vec3s angles) {
|
||||||
|
versors dest;
|
||||||
|
glm_euler_yxz_quat_lh(angles.raw, dest.raw);
|
||||||
|
return dest;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief creates NEW quaternion using rotation angles and does
|
||||||
|
* rotations in y z x order in left hand (pitch yaw roll)
|
||||||
|
*
|
||||||
|
* @param[in] angles angles x y z (radians)
|
||||||
|
* @param[out] dest quaternion
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
versors
|
||||||
|
glms_euler_yzx_quat_lh(vec3s angles) {
|
||||||
|
versors dest;
|
||||||
|
glm_euler_yzx_quat_lh(angles.raw, dest.raw);
|
||||||
|
return dest;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief creates NEW quaternion using rotation angles and does
|
||||||
|
* rotations in z x y order in left hand (yaw roll pitch)
|
||||||
|
*
|
||||||
|
* @param[in] angles angles x y z (radians)
|
||||||
|
* @param[out] dest quaternion
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
versors
|
||||||
|
glms_euler_zxy_quat_lh(vec3s angles) {
|
||||||
|
versors dest;
|
||||||
|
glm_euler_zxy_quat_lh(angles.raw, dest.raw);
|
||||||
|
return dest;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief creates NEW quaternion using rotation angles and does
|
||||||
|
* rotations in z y x order in left hand (yaw pitch roll)
|
||||||
|
*
|
||||||
|
* @param[in] angles angles x y z (radians)
|
||||||
|
* @param[out] dest quaternion
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
versors
|
||||||
|
glms_euler_zyx_quat_lh(vec3s angles) {
|
||||||
|
versors dest;
|
||||||
|
glm_euler_zyx_quat_lh(angles.raw, dest.raw);
|
||||||
|
return dest;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* cglms_euler_to_quat_lh_h */
|
||||||
115
include/cglm/struct/handed/euler_to_quat_rh.h
Normal file
115
include/cglm/struct/handed/euler_to_quat_rh.h
Normal file
@@ -0,0 +1,115 @@
|
|||||||
|
/*
|
||||||
|
* 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 glms_euler_xyz_quat_rh(vec3 angles, versor dest);
|
||||||
|
CGLM_INLINE void glms_euler_xzy_quat_rh(vec3 angles, versor dest);
|
||||||
|
CGLM_INLINE void glms_euler_yxz_quat_rh(vec3 angles, versor dest);
|
||||||
|
CGLM_INLINE void glms_euler_yzx_quat_rh(vec3 angles, versor dest);
|
||||||
|
CGLM_INLINE void glms_euler_zxy_quat_rh(vec3 angles, versor dest);
|
||||||
|
CGLM_INLINE void glms_euler_zyx_quat_rh(vec3 angles, versor dest);
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef cglms_euler_to_quat_rh_h
|
||||||
|
#define cglms_euler_to_quat_rh_h
|
||||||
|
|
||||||
|
#include "../common.h"
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief creates NEW quaternion using rotation angles and does
|
||||||
|
* rotations in x y z order in right hand (roll pitch yaw)
|
||||||
|
*
|
||||||
|
* @param[in] angles angles x y z (radians)
|
||||||
|
* @param[out] dest quaternion
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
versors
|
||||||
|
glms_euler_xyz_quat_rh(vec3s angles) {
|
||||||
|
versors dest;
|
||||||
|
glm_euler_xyz_quat_rh(angles.raw, dest.raw);
|
||||||
|
return dest;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief creates NEW quaternion using rotation angles and does
|
||||||
|
* rotations in x z y order in right hand (roll yaw pitch)
|
||||||
|
*
|
||||||
|
* @param[in] angles angles x y z (radians)
|
||||||
|
* @param[out] dest quaternion
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
versors
|
||||||
|
glms_euler_xzy_quat_rh(vec3s angles) {
|
||||||
|
versors dest;
|
||||||
|
glm_euler_xzy_quat_rh(angles.raw, dest.raw);
|
||||||
|
return dest;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief creates NEW quaternion using rotation angles and does
|
||||||
|
* rotations in y x z order in right hand (pitch roll yaw)
|
||||||
|
*
|
||||||
|
* @param[in] angles angles x y z (radians)
|
||||||
|
* @param[out] dest quaternion
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
versors
|
||||||
|
glms_euler_yxz_quat_rh(vec3s angles) {
|
||||||
|
versors dest;
|
||||||
|
glm_euler_yxz_quat_rh(angles.raw, dest.raw);
|
||||||
|
return dest;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief creates NEW quaternion using rotation angles and does
|
||||||
|
* rotations in y z x order in right hand (pitch yaw roll)
|
||||||
|
*
|
||||||
|
* @param[in] angles angles x y z (radians)
|
||||||
|
* @param[out] dest quaternion
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
versors
|
||||||
|
glms_euler_yzx_quat_rh(vec3s angles) {
|
||||||
|
versors dest;
|
||||||
|
glm_euler_yzx_quat_rh(angles.raw, dest.raw);
|
||||||
|
return dest;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief creates NEW quaternion using rotation angles and does
|
||||||
|
* rotations in z x y order in right hand (yaw roll pitch)
|
||||||
|
*
|
||||||
|
* @param[in] angles angles x y z (radians)
|
||||||
|
* @param[out] dest quaternion
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
versors
|
||||||
|
glms_euler_zxy_quat_rh(vec3s angles) {
|
||||||
|
versors dest;
|
||||||
|
glm_euler_zxy_quat_rh(angles.raw, dest.raw);
|
||||||
|
return dest;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief creates NEW quaternion using rotation angles and does
|
||||||
|
* rotations in z y x order in right hand (yaw pitch roll)
|
||||||
|
*
|
||||||
|
* @param[in] angles angles x y z (radians)
|
||||||
|
* @param[out] dest quaternion
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
versors
|
||||||
|
glms_euler_zyx_quat_rh(vec3s angles) {
|
||||||
|
versors dest;
|
||||||
|
glm_euler_zyx_quat_rh(angles.raw, dest.raw);
|
||||||
|
return dest;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* cglms_euler_to_quat_rh_h */
|
||||||
@@ -12,6 +12,8 @@
|
|||||||
CGLM_INLINE void glm_vec4_print(vec4 vec, FILE *ostream);
|
CGLM_INLINE void glm_vec4_print(vec4 vec, FILE *ostream);
|
||||||
CGLM_INLINE void glm_vec3_print(vec3 vec, FILE *ostream);
|
CGLM_INLINE void glm_vec3_print(vec3 vec, FILE *ostream);
|
||||||
CGLM_INLINE void glm_ivec3_print(ivec3 vec, FILE *ostream);
|
CGLM_INLINE void glm_ivec3_print(ivec3 vec, FILE *ostream);
|
||||||
|
CGLM_INLINE void glm_ivec3_print(ivec3 vec, FILE *ostream);
|
||||||
|
|
||||||
CGLM_INLINE void glm_versor_print(versor vec, FILE *ostream);
|
CGLM_INLINE void glm_versor_print(versor vec, FILE *ostream);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|||||||
@@ -27,7 +27,7 @@
|
|||||||
CGLM_INLINE void glms_mat2_swap_col(mat2 mat, int col1, int col2)
|
CGLM_INLINE void glms_mat2_swap_col(mat2 mat, int col1, int col2)
|
||||||
CGLM_INLINE void glms_mat2_swap_row(mat2 mat, int row1, int row2)
|
CGLM_INLINE void glms_mat2_swap_row(mat2 mat, int row1, int row2)
|
||||||
CGLM_INLINE float glms_mat2_rmc(vec2 r, mat2 m, vec2 c)
|
CGLM_INLINE float glms_mat2_rmc(vec2 r, mat2 m, vec2 c)
|
||||||
CGLM_INLINE float glms_mat42_make(float * __restrict src);
|
CGLM_INLINE mat2s glms_mat2_make(float * __restrict src);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef cglms_mat2_h
|
#ifndef cglms_mat2_h
|
||||||
@@ -44,8 +44,8 @@
|
|||||||
#define GLMS_MAT2_ZERO_INIT {GLM_MAT2_ZERO_INIT}
|
#define GLMS_MAT2_ZERO_INIT {GLM_MAT2_ZERO_INIT}
|
||||||
|
|
||||||
/* for C only */
|
/* for C only */
|
||||||
#define GLMS_MAT2_IDENTITY ((mat3s)GLMS_MAT2_IDENTITY_INIT)
|
#define GLMS_MAT2_IDENTITY ((mat2s)GLMS_MAT2_IDENTITY_INIT)
|
||||||
#define GLMS_MAT2_ZERO ((mat3s)GLMS_MAT2_ZERO_INIT)
|
#define GLMS_MAT2_ZERO ((mat2s)GLMS_MAT2_ZERO_INIT)
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief make given matrix identity. It is identical with below,
|
* @brief make given matrix identity. It is identical with below,
|
||||||
@@ -108,13 +108,13 @@ glms_mat2_(zero)(void) {
|
|||||||
*
|
*
|
||||||
* @code
|
* @code
|
||||||
* mat2 m = GLM_MAT2_IDENTITY_INIT;
|
* mat2 m = GLM_MAT2_IDENTITY_INIT;
|
||||||
* glm_mat2_mul(m, m, m);
|
* r = glms_mat2_mul(m, m);
|
||||||
* @endcode
|
* @endcode
|
||||||
*
|
*
|
||||||
* @param[in] m1 left matrix
|
* @param[in] m1 left matrix
|
||||||
* @param[in] m2 right matrix
|
* @param[in] m2 right matrix
|
||||||
*
|
*
|
||||||
* @returns matrix
|
* @returns destination matrix
|
||||||
*/
|
*/
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
mat2s
|
mat2s
|
||||||
|
|||||||
127
include/cglm/struct/mat2x3.h
Normal file
127
include/cglm/struct/mat2x3.h
Normal file
@@ -0,0 +1,127 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c), Recep Aslantas.
|
||||||
|
*
|
||||||
|
* MIT License (MIT), http://opensource.org/licenses/MIT
|
||||||
|
* Full license can be found in the LICENSE file
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
Macros:
|
||||||
|
GLMS_MAT2X3_ZERO_INIT
|
||||||
|
GLMS_MAT2X3_ZERO
|
||||||
|
|
||||||
|
Functions:
|
||||||
|
CGLM_INLINE mat2x3s glms_mat2x3_zero(void);
|
||||||
|
CGLM_INLINE mat2x3s glms_mat2x3_make(float * __restrict src);
|
||||||
|
CGLM_INLINE mat2s glms_mat2x3_mul(mat2x3s m1, mat3x2s m2);
|
||||||
|
CGLM_INLINE vec2s glms_mat2x3_mulv(mat2x3s m, vec3s v);
|
||||||
|
CGLM_INLINE mat3x2s glms_mat2x3_transpose(mat2x3s m);
|
||||||
|
CGLM_INLINE mat2x3s glms_mat2x3_scale(mat2x3s m, float s);
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef cglms_mat2x3_h
|
||||||
|
#define cglms_mat2x3_h
|
||||||
|
|
||||||
|
#include "../common.h"
|
||||||
|
#include "../types-struct.h"
|
||||||
|
#include "../mat2x3.h"
|
||||||
|
|
||||||
|
/* api definition */
|
||||||
|
#define glms_mat2x3_(NAME) CGLM_STRUCTAPI(mat2x3, NAME)
|
||||||
|
|
||||||
|
#define GLMS_MAT2X3_ZERO_INIT {GLM_MAT2X3_ZERO_INIT}
|
||||||
|
|
||||||
|
/* for C only */
|
||||||
|
#define GLMS_MAT2X3_ZERO ((mat2x3s)GLMS_MAT2X3_ZERO_INIT)
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief make given matrix zero.
|
||||||
|
*
|
||||||
|
* @param[in, out] mat matrix
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
mat2x3s
|
||||||
|
glms_mat2x3_(zero)(void) {
|
||||||
|
mat2x3s r;
|
||||||
|
glm_mat2x3_zero(r.raw);
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Create mat2x3 matrix from pointer
|
||||||
|
*
|
||||||
|
* @param[in] src pointer to an array of floats
|
||||||
|
* @return constructed matrix from raw pointer
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
mat2x3s
|
||||||
|
glms_mat2x3_(make)(float * __restrict src) {
|
||||||
|
mat2x3s r;
|
||||||
|
glm_mat2x3_make(src, r.raw);
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief multiply m1 and m2 to dest
|
||||||
|
*
|
||||||
|
* @code
|
||||||
|
* r = glms_mat2x3_mul(mat2x3s, mat3x2s);
|
||||||
|
* @endcode
|
||||||
|
*
|
||||||
|
* @param[in] m1 left matrix (mat2x3s)
|
||||||
|
* @param[in] m2 right matrix (mat3x2s)
|
||||||
|
* @returns destination matrix (mat2s)
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
mat2s
|
||||||
|
glms_mat2x3_(mul)(mat2x3s m1, mat3x2s m2) {
|
||||||
|
mat2s r;
|
||||||
|
glm_mat2x3_mul(m1.raw, m2.raw, r.raw);
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief multiply matrix with column vector and store in dest vector
|
||||||
|
*
|
||||||
|
* @param[in] m matrix (left)
|
||||||
|
* @param[in] v vector (right, column vector)
|
||||||
|
* @param[out] dest result vector
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
vec2s
|
||||||
|
glms_mat2x3_(mulv)(mat2x3s m, vec3s v) {
|
||||||
|
vec2s r;
|
||||||
|
glm_mat2x3_mulv(m.raw, v.raw, r.raw);
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief transpose matrix and store in dest
|
||||||
|
*
|
||||||
|
* @param[in] m matrix
|
||||||
|
* @param[out] dest result
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
mat3x2s
|
||||||
|
glms_mat2x3_(transpose)(mat2x3s m) {
|
||||||
|
mat3x2s r;
|
||||||
|
glm_mat2x3_transpose(m.raw, r.raw);
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief scale (multiply with scalar) matrix
|
||||||
|
*
|
||||||
|
* multiply matrix with scalar
|
||||||
|
*
|
||||||
|
* @param[in, out] m matrix
|
||||||
|
* @param[in] s scalar
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
mat2x3s
|
||||||
|
glms_mat2x3_(scale)(mat2x3s m, float s) {
|
||||||
|
glm_mat2x3_scale(m.raw, s);
|
||||||
|
return m;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* cglms_mat2x3_h */
|
||||||
127
include/cglm/struct/mat2x4.h
Normal file
127
include/cglm/struct/mat2x4.h
Normal file
@@ -0,0 +1,127 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c), Recep Aslantas.
|
||||||
|
*
|
||||||
|
* MIT License (MIT), http://opensource.org/licenses/MIT
|
||||||
|
* Full license can be found in the LICENSE file
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
Macros:
|
||||||
|
GLMS_MAT2X4_ZERO_INIT
|
||||||
|
GLMS_MAT2X4_ZERO
|
||||||
|
|
||||||
|
Functions:
|
||||||
|
CGLM_INLINE mat2x4s glms_mat2x4_zero(void);
|
||||||
|
CGLM_INLINE mat2x4s glms_mat2x4_make(float * __restrict src);
|
||||||
|
CGLM_INLINE mat2s glms_mat2x4_mul(mat2x4s m1, mat4x2s m2);
|
||||||
|
CGLM_INLINE vec2s glms_mat2x4_mulv(mat2x4s m, vec4s v);
|
||||||
|
CGLM_INLINE mat4x2s glms_mat2x4_transpose(mat2x4s m);
|
||||||
|
CGLM_INLINE mat2x4s glms_mat2x4_scale(mat2x4s m, float s);
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef cglms_mat2x4_h
|
||||||
|
#define cglms_mat2x4_h
|
||||||
|
|
||||||
|
#include "../common.h"
|
||||||
|
#include "../types-struct.h"
|
||||||
|
#include "../mat2x4.h"
|
||||||
|
|
||||||
|
/* api definition */
|
||||||
|
#define glms_mat2x4_(NAME) CGLM_STRUCTAPI(mat2x4, NAME)
|
||||||
|
|
||||||
|
#define GLMS_MAT2X4_ZERO_INIT {GLM_MAT2X4_ZERO_INIT}
|
||||||
|
|
||||||
|
/* for C only */
|
||||||
|
#define GLMS_MAT2X4_ZERO ((mat2x4s)GLMS_MAT2X4_ZERO_INIT)
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief make given matrix zero.
|
||||||
|
*
|
||||||
|
* @param[in, out] mat matrix
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
mat2x4s
|
||||||
|
glms_mat2x4_(zero)(void) {
|
||||||
|
mat2x4s r;
|
||||||
|
glm_mat2x4_zero(r.raw);
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Create mat2x4 matrix from pointer
|
||||||
|
*
|
||||||
|
* @param[in] src pointer to an array of floats
|
||||||
|
* @return constructed matrix from raw pointer
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
mat2x4s
|
||||||
|
glms_mat2x4_(make)(float * __restrict src) {
|
||||||
|
mat2x4s r;
|
||||||
|
glm_mat2x4_make(src, r.raw);
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief multiply m1 and m2 to dest
|
||||||
|
*
|
||||||
|
* @code
|
||||||
|
* r = glms_mat2x4_mul(mat2x4s, mat4x2s);
|
||||||
|
* @endcode
|
||||||
|
*
|
||||||
|
* @param[in] m1 left matrix (mat2x4s)
|
||||||
|
* @param[in] m2 right matrix (mat4x2s)
|
||||||
|
* @returns destination matrix (mat2s)
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
mat2s
|
||||||
|
glms_mat2x4_(mul)(mat2x4s m1, mat4x2s m2) {
|
||||||
|
mat2s r;
|
||||||
|
glm_mat2x4_mul(m1.raw, m2.raw, r.raw);
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief multiply matrix with column vector and store in dest vector
|
||||||
|
*
|
||||||
|
* @param[in] m matrix (left)
|
||||||
|
* @param[in] v vector (right, column vector)
|
||||||
|
* @param[out] dest result vector
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
vec2s
|
||||||
|
glms_mat2x4_(mulv)(mat2x4s m, vec4s v) {
|
||||||
|
vec2s r;
|
||||||
|
glm_mat2x4_mulv(m.raw, v.raw, r.raw);
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief transpose matrix and store in dest
|
||||||
|
*
|
||||||
|
* @param[in] m matrix
|
||||||
|
* @param[out] dest result
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
mat4x2s
|
||||||
|
glms_mat2x4_(transpose)(mat2x4s m) {
|
||||||
|
mat4x2s r;
|
||||||
|
glm_mat2x4_transpose(m.raw, r.raw);
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief scale (multiply with scalar) matrix
|
||||||
|
*
|
||||||
|
* multiply matrix with scalar
|
||||||
|
*
|
||||||
|
* @param[in, out] m matrix
|
||||||
|
* @param[in] s scalar
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
mat2x4s
|
||||||
|
glms_mat2x4_(scale)(mat2x4s m, float s) {
|
||||||
|
glm_mat2x4_scale(m.raw, s);
|
||||||
|
return m;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* cglms_mat2x4_h */
|
||||||
@@ -28,7 +28,7 @@
|
|||||||
CGLM_INLINE mat3s glms_mat3_swap_col(mat3s mat, int col1, int col2);
|
CGLM_INLINE mat3s glms_mat3_swap_col(mat3s mat, int col1, int col2);
|
||||||
CGLM_INLINE mat3s glms_mat3_swap_row(mat3s mat, int row1, int row2);
|
CGLM_INLINE mat3s glms_mat3_swap_row(mat3s mat, int row1, int row2);
|
||||||
CGLM_INLINE float glms_mat3_rmc(vec3s r, mat3s m, vec3s c);
|
CGLM_INLINE float glms_mat3_rmc(vec3s r, mat3s m, vec3s c);
|
||||||
CGLM_INLINE float glms_mat3_make(float * __restrict src);
|
CGLM_INLINE mat3s glms_mat3_make(float * __restrict src);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef cglms_mat3s_h
|
#ifndef cglms_mat3s_h
|
||||||
@@ -124,12 +124,12 @@ glms_mat3_(zero)(void) {
|
|||||||
*
|
*
|
||||||
* @code
|
* @code
|
||||||
* mat3 m = GLM_MAT3_IDENTITY_INIT;
|
* mat3 m = GLM_MAT3_IDENTITY_INIT;
|
||||||
* glm_mat3_mul(m, m, m);
|
* r = glms_mat3_mul(m, m);
|
||||||
* @endcode
|
* @endcode
|
||||||
*
|
*
|
||||||
* @param[in] m1 left matrix
|
* @param[in] m1 left matrix
|
||||||
* @param[in] m2 right matrix
|
* @param[in] m2 right matrix
|
||||||
* @returns destination matrix
|
* @returns destination matrix
|
||||||
*/
|
*/
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
mat3s
|
mat3s
|
||||||
|
|||||||
127
include/cglm/struct/mat3x2.h
Normal file
127
include/cglm/struct/mat3x2.h
Normal file
@@ -0,0 +1,127 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c), Recep Aslantas.
|
||||||
|
*
|
||||||
|
* MIT License (MIT), http://opensource.org/licenses/MIT
|
||||||
|
* Full license can be found in the LICENSE file
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
Macros:
|
||||||
|
GLMS_MAT3X2_ZERO_INIT
|
||||||
|
GLMS_MAT3X2_ZERO
|
||||||
|
|
||||||
|
Functions:
|
||||||
|
CGLM_INLINE mat3x2s glms_mat3x2_zero(void);
|
||||||
|
CGLM_INLINE mat3x2s glms_mat3x2_make(float * __restrict src);
|
||||||
|
CGLM_INLINE mat3s glms_mat3x2_mul(mat3x2s m1, mat2x3s m2);
|
||||||
|
CGLM_INLINE vec3s glms_mat3x2_mulv(mat3x2s m, vec2s v);
|
||||||
|
CGLM_INLINE mat2x3s glms_mat3x2_transpose(mat3x2s m);
|
||||||
|
CGLM_INLINE mat3x2s glms_mat3x2_scale(mat3x2s m, float s);
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef cglms_mat3x2_h
|
||||||
|
#define cglms_mat3x2_h
|
||||||
|
|
||||||
|
#include "../common.h"
|
||||||
|
#include "../types-struct.h"
|
||||||
|
#include "../mat3x2.h"
|
||||||
|
|
||||||
|
/* api definition */
|
||||||
|
#define glms_mat3x2_(NAME) CGLM_STRUCTAPI(mat3x2, NAME)
|
||||||
|
|
||||||
|
#define GLMS_MAT3X2_ZERO_INIT {GLM_MAT3X2_ZERO_INIT}
|
||||||
|
|
||||||
|
/* for C only */
|
||||||
|
#define GLMS_MAT3X2_ZERO ((mat3x2s)GLMS_MAT3X2_ZERO_INIT)
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief make given matrix zero.
|
||||||
|
*
|
||||||
|
* @param[in, out] mat matrix
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
mat3x2s
|
||||||
|
glms_mat3x2_(zero)(void) {
|
||||||
|
mat3x2s r;
|
||||||
|
glm_mat3x2_zero(r.raw);
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Create mat3x2 matrix from pointer
|
||||||
|
*
|
||||||
|
* @param[in] src pointer to an array of floats
|
||||||
|
* @return constructed matrix from raw pointer
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
mat3x2s
|
||||||
|
glms_mat3x2_(make)(float * __restrict src) {
|
||||||
|
mat3x2s r;
|
||||||
|
glm_mat3x2_make(src, r.raw);
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief multiply m1 and m2 to dest
|
||||||
|
*
|
||||||
|
* @code
|
||||||
|
* r = glms_mat3x2_mul(mat3x2s, mat2x3s);
|
||||||
|
* @endcode
|
||||||
|
*
|
||||||
|
* @param[in] m1 left matrix (mat3x2s)
|
||||||
|
* @param[in] m2 right matrix (mat2x3s)
|
||||||
|
* @returns destination matrix (mat3s)
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
mat3s
|
||||||
|
glms_mat3x2_(mul)(mat3x2s m1, mat2x3s m2) {
|
||||||
|
mat3s r;
|
||||||
|
glm_mat3x2_mul(m1.raw, m2.raw, r.raw);
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief multiply matrix with column vector and store in dest vector
|
||||||
|
*
|
||||||
|
* @param[in] m matrix (left)
|
||||||
|
* @param[in] v vector (right, column vector)
|
||||||
|
* @param[out] dest result vector
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
vec3s
|
||||||
|
glms_mat3x2_(mulv)(mat3x2s m, vec2s v) {
|
||||||
|
vec3s r;
|
||||||
|
glm_mat3x2_mulv(m.raw, v.raw, r.raw);
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief transpose matrix and store in dest
|
||||||
|
*
|
||||||
|
* @param[in] m matrix
|
||||||
|
* @param[out] dest result
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
mat2x3s
|
||||||
|
glms_mat3x2_(transpose)(mat3x2s m) {
|
||||||
|
mat2x3s r;
|
||||||
|
glm_mat3x2_transpose(m.raw, r.raw);
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief scale (multiply with scalar) matrix
|
||||||
|
*
|
||||||
|
* multiply matrix with scalar
|
||||||
|
*
|
||||||
|
* @param[in, out] m matrix
|
||||||
|
* @param[in] s scalar
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
mat3x2s
|
||||||
|
glms_mat3x2_(scale)(mat3x2s m, float s) {
|
||||||
|
glm_mat3x2_scale(m.raw, s);
|
||||||
|
return m;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* cglms_mat3x2_h */
|
||||||
127
include/cglm/struct/mat3x4.h
Normal file
127
include/cglm/struct/mat3x4.h
Normal file
@@ -0,0 +1,127 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c), Recep Aslantas.
|
||||||
|
*
|
||||||
|
* MIT License (MIT), http://opensource.org/licenses/MIT
|
||||||
|
* Full license can be found in the LICENSE file
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
Macros:
|
||||||
|
GLMS_MAT3X4_ZERO_INIT
|
||||||
|
GLMS_MAT3X4_ZERO
|
||||||
|
|
||||||
|
Functions:
|
||||||
|
CGLM_INLINE mat3x4s glms_mat3x4_zero(void);
|
||||||
|
CGLM_INLINE mat3x4s glms_mat3x4_make(float * __restrict src);
|
||||||
|
CGLM_INLINE mat3s glms_mat3x4_mul(mat3x4s m1, mat4x3s m2);
|
||||||
|
CGLM_INLINE vec3s glms_mat3x4_mulv(mat3x4s m, vec4s v);
|
||||||
|
CGLM_INLINE mat4x3s glms_mat3x4_transpose(mat3x4s m);
|
||||||
|
CGLM_INLINE mat3x4s glms_mat3x4_scale(mat3x4s m, float s);
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef cglms_mat3x4_h
|
||||||
|
#define cglms_mat3x4_h
|
||||||
|
|
||||||
|
#include "../common.h"
|
||||||
|
#include "../types-struct.h"
|
||||||
|
#include "../mat3x4.h"
|
||||||
|
|
||||||
|
/* api definition */
|
||||||
|
#define glms_mat3x4_(NAME) CGLM_STRUCTAPI(mat3x4, NAME)
|
||||||
|
|
||||||
|
#define GLMS_MAT3X4_ZERO_INIT {GLM_MAT3X4_ZERO_INIT}
|
||||||
|
|
||||||
|
/* for C only */
|
||||||
|
#define GLMS_MAT3X4_ZERO ((mat3x4s)GLMS_MAT3X4_ZERO_INIT)
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief make given matrix zero.
|
||||||
|
*
|
||||||
|
* @param[in, out] mat matrix
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
mat3x4s
|
||||||
|
glms_mat3x4_(zero)(void) {
|
||||||
|
mat3x4s r;
|
||||||
|
glm_mat3x4_zero(r.raw);
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Create mat3x4 matrix from pointer
|
||||||
|
*
|
||||||
|
* @param[in] src pointer to an array of floats
|
||||||
|
* @return constructed matrix from raw pointer
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
mat3x4s
|
||||||
|
glms_mat3x4_(make)(float * __restrict src) {
|
||||||
|
mat3x4s r;
|
||||||
|
glm_mat3x4_make(src, r.raw);
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief multiply m1 and m2 to dest
|
||||||
|
*
|
||||||
|
* @code
|
||||||
|
* r = glms_mat3x4_mul(mat3x4s, mat4x3s);
|
||||||
|
* @endcode
|
||||||
|
*
|
||||||
|
* @param[in] m1 left matrix (mat3x4s)
|
||||||
|
* @param[in] m2 right matrix (mat4x3s)
|
||||||
|
* @returns destination matrix (mat3s)
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
mat3s
|
||||||
|
glms_mat3x4_(mul)(mat3x4s m1, mat4x3s m2) {
|
||||||
|
mat3s r;
|
||||||
|
glm_mat3x4_mul(m1.raw, m2.raw, r.raw);
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief multiply matrix with column vector and store in dest vector
|
||||||
|
*
|
||||||
|
* @param[in] m matrix (left)
|
||||||
|
* @param[in] v vector (right, column vector)
|
||||||
|
* @param[out] dest result vector
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
vec3s
|
||||||
|
glms_mat3x4_(mulv)(mat3x4s m, vec4s v) {
|
||||||
|
vec3s r;
|
||||||
|
glm_mat3x4_mulv(m.raw, v.raw, r.raw);
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief transpose matrix and store in dest
|
||||||
|
*
|
||||||
|
* @param[in] m matrix
|
||||||
|
* @param[out] dest result
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
mat4x3s
|
||||||
|
glms_mat3x4_(transpose)(mat3x4s m) {
|
||||||
|
mat4x3s r;
|
||||||
|
glm_mat3x4_transpose(m.raw, r.raw);
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief scale (multiply with scalar) matrix
|
||||||
|
*
|
||||||
|
* multiply matrix with scalar
|
||||||
|
*
|
||||||
|
* @param[in, out] m matrix
|
||||||
|
* @param[in] s scalar
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
mat3x4s
|
||||||
|
glms_mat3x4_(scale)(mat3x4s m, float s) {
|
||||||
|
glm_mat3x4_scale(m.raw, s);
|
||||||
|
return m;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* cglms_mat3x4_h */
|
||||||
@@ -25,7 +25,7 @@
|
|||||||
CGLM_INLINE mat4s glms_mat4_zero(void);
|
CGLM_INLINE mat4s glms_mat4_zero(void);
|
||||||
CGLM_INLINE mat3s glms_mat4_pick3(mat4s mat);
|
CGLM_INLINE mat3s glms_mat4_pick3(mat4s mat);
|
||||||
CGLM_INLINE mat3s glms_mat4_pick3t(mat4s mat);
|
CGLM_INLINE mat3s glms_mat4_pick3t(mat4s mat);
|
||||||
CGLM_INLINE mat4s glms_mat4_ins3(mat3s mat);
|
CGLM_INLINE mat4s glms_mat4_ins3(mat3s mat, mat4s dest);
|
||||||
CGLM_INLINE mat4s glms_mat4_mul(mat4s m1, mat4s m2);
|
CGLM_INLINE mat4s glms_mat4_mul(mat4s m1, mat4s m2);
|
||||||
CGLM_INLINE mat4s glms_mat4_mulN(mat4s * __restrict matrices[], uint32_t len);
|
CGLM_INLINE mat4s glms_mat4_mulN(mat4s * __restrict matrices[], uint32_t len);
|
||||||
CGLM_INLINE vec4s glms_mat4_mulv(mat4s m, vec4s v);
|
CGLM_INLINE vec4s glms_mat4_mulv(mat4s m, vec4s v);
|
||||||
@@ -42,7 +42,7 @@
|
|||||||
CGLM_INLINE mat4s glms_mat4_swap_col(mat4s mat, int col1, int col2);
|
CGLM_INLINE mat4s glms_mat4_swap_col(mat4s mat, int col1, int col2);
|
||||||
CGLM_INLINE mat4s glms_mat4_swap_row(mat4s mat, int row1, int row2);
|
CGLM_INLINE mat4s glms_mat4_swap_row(mat4s mat, int row1, int row2);
|
||||||
CGLM_INLINE float glms_mat4_rmc(vec4s r, mat4s m, vec4s c);
|
CGLM_INLINE float glms_mat4_rmc(vec4s r, mat4s m, vec4s c);
|
||||||
CGLM_INLINE float glms_mat4_make(float * __restrict src);
|
CGLM_INLINE mat4s glms_mat4_make(float * __restrict src);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef cglms_mat4s_h
|
#ifndef cglms_mat4s_h
|
||||||
@@ -183,14 +183,14 @@ glms_mat4_(pick3t)(mat4s mat) {
|
|||||||
* @brief copy mat3 to mat4's upper-left
|
* @brief copy mat3 to mat4's upper-left
|
||||||
*
|
*
|
||||||
* @param[in] mat source
|
* @param[in] mat source
|
||||||
|
* @param[in] dest destination
|
||||||
* @returns destination
|
* @returns destination
|
||||||
*/
|
*/
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
mat4s
|
mat4s
|
||||||
glms_mat4_(ins3)(mat3s mat) {
|
glms_mat4_(ins3)(mat3s mat, mat4s dest) {
|
||||||
mat4s r;
|
glm_mat4_ins3(mat.raw, dest.raw);
|
||||||
glm_mat4_ins3(mat.raw, r.raw);
|
return dest;
|
||||||
return r;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@@ -200,12 +200,12 @@ glms_mat4_(ins3)(mat3s mat) {
|
|||||||
*
|
*
|
||||||
* @code
|
* @code
|
||||||
* mat4 m = GLM_MAT4_IDENTITY_INIT;
|
* mat4 m = GLM_MAT4_IDENTITY_INIT;
|
||||||
* glm_mat4_mul(m, m, m);
|
* r = glms_mat4_mul(m, m);
|
||||||
* @endcode
|
* @endcode
|
||||||
*
|
*
|
||||||
* @param[in] m1 left matrix
|
* @param[in] m1 left matrix
|
||||||
* @param[in] m2 right matrix
|
* @param[in] m2 right matrix
|
||||||
* @returns destination matrix
|
* @returns destination matrix
|
||||||
*/
|
*/
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
mat4s
|
mat4s
|
||||||
|
|||||||
128
include/cglm/struct/mat4x2.h
Normal file
128
include/cglm/struct/mat4x2.h
Normal file
@@ -0,0 +1,128 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c), Recep Aslantas.
|
||||||
|
*
|
||||||
|
* MIT License (MIT), http://opensource.org/licenses/MIT
|
||||||
|
* Full license can be found in the LICENSE file
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
Macros:
|
||||||
|
GLMS_MAT4X2_ZERO_INIT
|
||||||
|
GLMS_MAT4X2_ZERO
|
||||||
|
|
||||||
|
Functions:
|
||||||
|
CGLM_INLINE mat4x2s glms_mat4x2_zero(void);
|
||||||
|
CGLM_INLINE mat4x2s glms_mat4x2_make(float * __restrict src);
|
||||||
|
CGLM_INLINE mat4s glms_mat4x2_mul(mat4x2s m1, mat2x4s m2);
|
||||||
|
CGLM_INLINE vec4s glms_mat4x2_mulv(mat4x2s m, vec2s v);
|
||||||
|
CGLM_INLINE mat2x4s glms_mat4x2_transpose(mat4x2s m);
|
||||||
|
CGLM_INLINE mat4x2s glms_mat4x2_scale(mat4x2s m, float s);
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef cglms_mat4x2_h
|
||||||
|
#define cglms_mat4x2_h
|
||||||
|
|
||||||
|
#include "../common.h"
|
||||||
|
#include "../types-struct.h"
|
||||||
|
#include "../mat4x2.h"
|
||||||
|
|
||||||
|
/* api definition */
|
||||||
|
#define glms_mat4x2_(NAME) CGLM_STRUCTAPI(mat4x2, NAME)
|
||||||
|
|
||||||
|
#define GLMS_MAT4X2_ZERO_INIT {GLM_MAT4X2_ZERO_INIT}
|
||||||
|
|
||||||
|
/* for C only */
|
||||||
|
#define GLMS_MAT4X2_ZERO ((mat4x2s)GLMS_MAT4X2_ZERO_INIT)
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief make given matrix zero.
|
||||||
|
*
|
||||||
|
* @param[in, out] mat matrix
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
mat4x2s
|
||||||
|
glms_mat4x2_(zero)(void) {
|
||||||
|
mat4x2s r;
|
||||||
|
glm_mat4x2_zero(r.raw);
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Create mat4x2 matrix from pointer
|
||||||
|
*
|
||||||
|
* @param[in] src pointer to an array of floats
|
||||||
|
* @return constructed matrix from raw pointer
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
mat4x2s
|
||||||
|
glms_mat4x2_(make)(float * __restrict src) {
|
||||||
|
mat4x2s r;
|
||||||
|
glm_mat4x2_make(src, r.raw);
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief multiply m1 and m2 to dest
|
||||||
|
*
|
||||||
|
* @code
|
||||||
|
* r = glms_mat4x2_mul(mat4x2s, mat2x4s);
|
||||||
|
* @endcode
|
||||||
|
*
|
||||||
|
* @param[in] m1 left matrix (mat4x2s)
|
||||||
|
* @param[in] m2 right matrix (mat2x4s)
|
||||||
|
* @returns destination matrix (mat4s)
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
mat4s
|
||||||
|
glms_mat4x2_(mul)(mat4x2s m1, mat2x4s m2) {
|
||||||
|
mat4s r;
|
||||||
|
glm_mat4x2_mul(m1.raw, m2.raw, r.raw);
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief multiply matrix with column vector and store in dest vector
|
||||||
|
*
|
||||||
|
* @param[in] m matrix (left)
|
||||||
|
* @param[in] v vector (right, column vector)
|
||||||
|
* @param[out] dest result vector
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
vec4s
|
||||||
|
glms_mat4x2_(mulv)(mat4x2s m, vec2s v) {
|
||||||
|
vec4s r;
|
||||||
|
glm_mat4x2_mulv(m.raw, v.raw, r.raw);
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief transpose matrix and store in dest
|
||||||
|
*
|
||||||
|
* @param[in] m matrix
|
||||||
|
* @param[out] dest result
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
mat2x4s
|
||||||
|
glms_mat4x2_(transpose)(mat4x2s m) {
|
||||||
|
mat2x4s r;
|
||||||
|
glm_mat4x2_transpose(m.raw, r.raw);
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief scale (multiply with scalar) matrix
|
||||||
|
*
|
||||||
|
* multiply matrix with scalar
|
||||||
|
*
|
||||||
|
* @param[in, out] m matrix
|
||||||
|
* @param[in] s scalar
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
mat4x2s
|
||||||
|
glms_mat4x2_(scale)(mat4x2s m, float s) {
|
||||||
|
glm_mat4x2_scale(m.raw, s);
|
||||||
|
return m;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* cglms_mat4x2_h */
|
||||||
127
include/cglm/struct/mat4x3.h
Normal file
127
include/cglm/struct/mat4x3.h
Normal file
@@ -0,0 +1,127 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c), Recep Aslantas.
|
||||||
|
*
|
||||||
|
* MIT License (MIT), http://opensource.org/licenses/MIT
|
||||||
|
* Full license can be found in the LICENSE file
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
Macros:
|
||||||
|
GLMS_MAT4X3_ZERO_INIT
|
||||||
|
GLMS_MAT4X3_ZERO
|
||||||
|
|
||||||
|
Functions:
|
||||||
|
CGLM_INLINE mat4x3s glms_mat4x3_zero(void);
|
||||||
|
CGLM_INLINE mat4x3s glms_mat4x3_make(float * __restrict src);
|
||||||
|
CGLM_INLINE mat4s glms_mat4x3_mul(mat4x3s m1, mat3x4s m2);
|
||||||
|
CGLM_INLINE vec4s glms_mat4x3_mulv(mat4x3s m, vec3s v);
|
||||||
|
CGLM_INLINE mat3x4s glms_mat4x3_transpose(mat4x3s m);
|
||||||
|
CGLM_INLINE mat4x3s glms_mat4x3_scale(mat4x3s m, float s);
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef cglms_mat4x3_h
|
||||||
|
#define cglms_mat4x3_h
|
||||||
|
|
||||||
|
#include "../common.h"
|
||||||
|
#include "../types-struct.h"
|
||||||
|
#include "../mat4x3.h"
|
||||||
|
|
||||||
|
/* api definition */
|
||||||
|
#define glms_mat4x3_(NAME) CGLM_STRUCTAPI(mat4x3, NAME)
|
||||||
|
|
||||||
|
#define GLMS_MAT4X3_ZERO_INIT {GLM_MAT4X3_ZERO_INIT}
|
||||||
|
|
||||||
|
/* for C only */
|
||||||
|
#define GLMS_MAT4X3_ZERO ((mat4x3s)GLMS_MAT4X3_ZERO_INIT)
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief make given matrix zero.
|
||||||
|
*
|
||||||
|
* @param[in, out] mat matrix
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
mat4x3s
|
||||||
|
glms_mat4x3_(zero)(void) {
|
||||||
|
mat4x3s r;
|
||||||
|
glm_mat4x3_zero(r.raw);
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Create mat4x3 matrix from pointer
|
||||||
|
*
|
||||||
|
* @param[in] src pointer to an array of floats
|
||||||
|
* @return constructed matrix from raw pointer
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
mat4x3s
|
||||||
|
glms_mat4x3_(make)(float * __restrict src) {
|
||||||
|
mat4x3s r;
|
||||||
|
glm_mat4x3_make(src, r.raw);
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief multiply m1 and m2 to dest
|
||||||
|
*
|
||||||
|
* @code
|
||||||
|
* r = glms_mat4x3_mul(mat4x3s, mat3x4s);
|
||||||
|
* @endcode
|
||||||
|
*
|
||||||
|
* @param[in] m1 left matrix (mat4x3s)
|
||||||
|
* @param[in] m2 right matrix (mat3x4s)
|
||||||
|
* @returns destination matrix (mat4s)
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
mat4s
|
||||||
|
glms_mat4x3_(mul)(mat4x3s m1, mat3x4s m2) {
|
||||||
|
mat4s r;
|
||||||
|
glm_mat4x3_mul(m1.raw, m2.raw, r.raw);
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief multiply matrix with column vector and store in dest vector
|
||||||
|
*
|
||||||
|
* @param[in] m matrix (left)
|
||||||
|
* @param[in] v vector (right, column vector)
|
||||||
|
* @param[out] dest result vector
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
vec4s
|
||||||
|
glms_mat4x3_(mulv)(mat4x3s m, vec3s v) {
|
||||||
|
vec4s r;
|
||||||
|
glm_mat4x3_mulv(m.raw, v.raw, r.raw);
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief transpose matrix and store in dest
|
||||||
|
*
|
||||||
|
* @param[in] m matrix
|
||||||
|
* @param[out] dest result
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
mat3x4s
|
||||||
|
glms_mat4x3_(transpose)(mat4x3s m) {
|
||||||
|
mat3x4s r;
|
||||||
|
glm_mat4x3_transpose(m.raw, r.raw);
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief scale (multiply with scalar) matrix
|
||||||
|
*
|
||||||
|
* multiply matrix with scalar
|
||||||
|
*
|
||||||
|
* @param[in, out] m matrix
|
||||||
|
* @param[in] s scalar
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
mat4x3s
|
||||||
|
glms_mat4x3_(scale)(mat4x3s m, float s) {
|
||||||
|
glm_mat4x3_scale(m.raw, s);
|
||||||
|
return m;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* cglms_mat4x3_h */
|
||||||
@@ -15,6 +15,17 @@
|
|||||||
#include "vec4.h"
|
#include "vec4.h"
|
||||||
#include "mat4.h"
|
#include "mat4.h"
|
||||||
|
|
||||||
|
#ifndef CGLM_CLIPSPACE_INCLUDE_ALL
|
||||||
|
# if CGLM_CONFIG_CLIP_CONTROL & CGLM_CLIP_CONTROL_ZO_BIT
|
||||||
|
# include "clipspace/project_zo.h"
|
||||||
|
# elif CGLM_CONFIG_CLIP_CONTROL & CGLM_CLIP_CONTROL_NO_BIT
|
||||||
|
# include "clipspace/project_no.h"
|
||||||
|
# endif
|
||||||
|
#else
|
||||||
|
# include "clipspace/project_zo.h"
|
||||||
|
# include "clipspace/project_no.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief maps the specified viewport coordinates into specified space [1]
|
* @brief maps the specified viewport coordinates into specified space [1]
|
||||||
* the matrix should contain projection matrix.
|
* the matrix should contain projection matrix.
|
||||||
@@ -68,6 +79,9 @@ glms_unprojecti(vec3s pos, mat4s invMat, vec4s vp) {
|
|||||||
* glm_mat4_mul(proj, view, viewProj);
|
* glm_mat4_mul(proj, view, viewProj);
|
||||||
* glm_mat4_mul(viewProj, model, MVP);
|
* glm_mat4_mul(viewProj, model, MVP);
|
||||||
*
|
*
|
||||||
|
* or in struct api:
|
||||||
|
* MVP = mat4_mul(mat4_mul(proj, view), model)
|
||||||
|
*
|
||||||
* @param[in] pos point/position in viewport coordinates
|
* @param[in] pos point/position in viewport coordinates
|
||||||
* @param[in] m matrix (see brief)
|
* @param[in] m matrix (see brief)
|
||||||
* @param[in] vp viewport as [x, y, width, height]
|
* @param[in] vp viewport as [x, y, width, height]
|
||||||
@@ -88,6 +102,9 @@ glms_unproject(vec3s pos, mat4s m, vec4s vp) {
|
|||||||
* glm_mat4_mul(proj, view, viewProj);
|
* glm_mat4_mul(proj, view, viewProj);
|
||||||
* glm_mat4_mul(viewProj, model, MVP);
|
* glm_mat4_mul(viewProj, model, MVP);
|
||||||
*
|
*
|
||||||
|
* or in struct api:
|
||||||
|
* MVP = mat4_mul(mat4_mul(proj, view), model)
|
||||||
|
*
|
||||||
* @param[in] pos object coordinates
|
* @param[in] pos object coordinates
|
||||||
* @param[in] m MVP matrix
|
* @param[in] m MVP matrix
|
||||||
* @param[in] vp viewport as [x, y, width, height]
|
* @param[in] vp viewport as [x, y, width, height]
|
||||||
@@ -101,6 +118,31 @@ glms_project(vec3s pos, mat4s m, vec4s vp) {
|
|||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief map object's z coordinate to window coordinates
|
||||||
|
*
|
||||||
|
* Computing MVP:
|
||||||
|
* glm_mat4_mul(proj, view, viewProj);
|
||||||
|
* glm_mat4_mul(viewProj, model, MVP);
|
||||||
|
*
|
||||||
|
* or in struct api:
|
||||||
|
* MVP = mat4_mul(mat4_mul(proj, view), model)
|
||||||
|
*
|
||||||
|
* @param[in] v object coordinates
|
||||||
|
* @param[in] m MVP matrix
|
||||||
|
*
|
||||||
|
* @returns projected z coordinate
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
float
|
||||||
|
glms_project_z(vec3s v, mat4s m) {
|
||||||
|
#if CGLM_CONFIG_CLIP_CONTROL & CGLM_CLIP_CONTROL_ZO_BIT
|
||||||
|
return glms_project_z_zo(v, m);
|
||||||
|
#elif CGLM_CONFIG_CLIP_CONTROL & CGLM_CLIP_CONTROL_NO_BIT
|
||||||
|
return glms_project_z_no(v, m);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief define a picking region
|
* @brief define a picking region
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -37,9 +37,16 @@
|
|||||||
CGLM_INLINE vec2s glms_vec2_muladds(vec2s a, float s, vec2s dest)
|
CGLM_INLINE vec2s glms_vec2_muladds(vec2s a, float s, vec2s dest)
|
||||||
CGLM_INLINE vec2s glms_vec2_maxadd(vec2s a, vec2s b, vec2s dest)
|
CGLM_INLINE vec2s glms_vec2_maxadd(vec2s a, vec2s b, vec2s dest)
|
||||||
CGLM_INLINE vec2s glms_vec2_minadd(vec2s a, vec2s b, vec2s dest)
|
CGLM_INLINE vec2s glms_vec2_minadd(vec2s a, vec2s b, vec2s dest)
|
||||||
|
CGLM_INLINE vec2s glms_vec2_subsub(vec2s a, vec2s b, vec2s dest)
|
||||||
|
CGLM_INLINE vec2s glms_vec2_addsub(vec2s a, vec2s b, vec2s dest)
|
||||||
|
CGLM_INLINE vec2s glms_vec2_mulsub(vec2s a, vec2s b, vec2s dest)
|
||||||
|
CGLM_INLINE vec2s glms_vec2_mulsubs(vec2s a, float s, vec2s dest)
|
||||||
|
CGLM_INLINE vec2s glms_vec2_maxsub(vec2s a, vec2s b, vec2s dest)
|
||||||
|
CGLM_INLINE vec2s glms_vec2_minsub(vec2s a, vec2s b, vec2s dest)
|
||||||
CGLM_INLINE vec2s glms_vec2_negate(vec2s v)
|
CGLM_INLINE vec2s glms_vec2_negate(vec2s v)
|
||||||
CGLM_INLINE vec2s glms_vec2_normalize(vec2s v)
|
CGLM_INLINE vec2s glms_vec2_normalize(vec2s v)
|
||||||
CGLM_INLINE vec2s glms_vec2_rotate(vec2s v, float angle, vec2s axis)
|
CGLM_INLINE vec2s glms_vec2_rotate(vec2s v, float angle, vec2s axis)
|
||||||
|
CGLM_INLINE vec2s glms_vec2_center(vec2s a, vec2s b)
|
||||||
CGLM_INLINE float glms_vec2_distance(vec2s a, vec2s b)
|
CGLM_INLINE float glms_vec2_distance(vec2s a, vec2s b)
|
||||||
CGLM_INLINE float glms_vec2_distance2(vec2s a, vec2s b)
|
CGLM_INLINE float glms_vec2_distance2(vec2s a, vec2s b)
|
||||||
CGLM_INLINE vec2s glms_vec2_maxv(vec2s a, vec2s b)
|
CGLM_INLINE vec2s glms_vec2_maxv(vec2s a, vec2s b)
|
||||||
@@ -429,6 +436,102 @@ glms_vec2_(minadd)(vec2s a, vec2s b, vec2s dest) {
|
|||||||
return dest;
|
return dest;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief sub two vectors and sub result to dest
|
||||||
|
*
|
||||||
|
* it applies -= operator so dest must be initialized
|
||||||
|
*
|
||||||
|
* @param[in] a vector 1
|
||||||
|
* @param[in] b vector 2
|
||||||
|
* @returns dest -= (a - b)
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
vec2s
|
||||||
|
glms_vec2_(subsub)(vec2s a, vec2s b, vec2s dest) {
|
||||||
|
glm_vec2_subsub(a.raw, b.raw, dest.raw);
|
||||||
|
return dest;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief add two vectors and sub result to dest
|
||||||
|
*
|
||||||
|
* it applies -= operator so dest must be initialized
|
||||||
|
*
|
||||||
|
* @param[in] a vector 1
|
||||||
|
* @param[in] b vector 2
|
||||||
|
* @returns dest -= (a + b)
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
vec2s
|
||||||
|
glms_vec2_(addsub)(vec2s a, vec2s b, vec2s dest) {
|
||||||
|
glm_vec2_addsub(a.raw, b.raw, dest.raw);
|
||||||
|
return dest;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief mul two vectors and sub result to dest
|
||||||
|
*
|
||||||
|
* it applies -= operator so dest must be initialized
|
||||||
|
*
|
||||||
|
* @param[in] a vector 1
|
||||||
|
* @param[in] b vector 2
|
||||||
|
* @returns dest -= (a * b)
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
vec2s
|
||||||
|
glms_vec2_(mulsub)(vec2s a, vec2s b, vec2s dest) {
|
||||||
|
glm_vec2_mulsub(a.raw, b.raw, dest.raw);
|
||||||
|
return dest;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief mul vector with scalar and sub result to dest
|
||||||
|
*
|
||||||
|
* it applies -= operator so dest must be initialized
|
||||||
|
*
|
||||||
|
* @param[in] a vector
|
||||||
|
* @param[in] s scalar
|
||||||
|
* @returns dest -= (a * b)
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
vec2s
|
||||||
|
glms_vec2_(mulsubs)(vec2s a, float s, vec2s dest) {
|
||||||
|
glm_vec2_mulsubs(a.raw, s, dest.raw);
|
||||||
|
return dest;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief sub max of two vectors to dest
|
||||||
|
*
|
||||||
|
* it applies += operator so dest must be initialized
|
||||||
|
*
|
||||||
|
* @param[in] a vector 1
|
||||||
|
* @param[in] b vector 2
|
||||||
|
* @returns dest -= max(a, b)
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
vec2s
|
||||||
|
glms_vec2_(maxsub)(vec2s a, vec2s b, vec2s dest) {
|
||||||
|
glm_vec2_maxsub(a.raw, b.raw, dest.raw);
|
||||||
|
return dest;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief sub min of two vectors to dest
|
||||||
|
*
|
||||||
|
* it applies -= operator so dest must be initialized
|
||||||
|
*
|
||||||
|
* @param[in] a vector 1
|
||||||
|
* @param[in] b vector 2
|
||||||
|
* @returns dest -= min(a, b)
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
vec2s
|
||||||
|
glms_vec2_(minsub)(vec2s a, vec2s b, vec2s dest) {
|
||||||
|
glm_vec2_minsub(a.raw, b.raw, dest.raw);
|
||||||
|
return dest;
|
||||||
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief negate vector components
|
* @brief negate vector components
|
||||||
*
|
*
|
||||||
@@ -470,6 +573,21 @@ glms_vec2_(rotate)(vec2s v, float angle) {
|
|||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief find center point of two vector
|
||||||
|
*
|
||||||
|
* @param[in] a vector1
|
||||||
|
* @param[in] b vector2
|
||||||
|
* @returns center point
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
vec2s
|
||||||
|
glms_vec2_(center)(vec2s a, vec2s b) {
|
||||||
|
vec2s r;
|
||||||
|
glm_vec2_center(a.raw, b.raw, r.raw);
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief distance between two vectors
|
* @brief distance between two vectors
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -41,9 +41,14 @@
|
|||||||
CGLM_INLINE vec3s glms_vec3_muladds(vec3s a, float s, vec3s dest);
|
CGLM_INLINE vec3s glms_vec3_muladds(vec3s a, float s, vec3s dest);
|
||||||
CGLM_INLINE vec3s glms_vec3_maxadd(vec3s a, vec3s b, vec3s dest);
|
CGLM_INLINE vec3s glms_vec3_maxadd(vec3s a, vec3s b, vec3s dest);
|
||||||
CGLM_INLINE vec3s glms_vec3_minadd(vec3s a, vec3s b, vec3s dest);
|
CGLM_INLINE vec3s glms_vec3_minadd(vec3s a, vec3s b, vec3s dest);
|
||||||
|
CGLM_INLINE vec3s glms_vec3_subsub(vec3s a, vec3s b, vec3s dest);
|
||||||
|
CGLM_INLINE vec3s glms_vec3_addsub(vec3s a, vec3s b, vec3s dest);
|
||||||
|
CGLM_INLINE vec3s glms_vec3_mulsub(vec3s a, vec3s b, vec3s dest);
|
||||||
|
CGLM_INLINE vec3s glms_vec3_mulsubs(vec3s a, float s, vec3s dest);
|
||||||
|
CGLM_INLINE vec3s glms_vec3_maxsub(vec3s a, vec3s b, vec3s dest);
|
||||||
|
CGLM_INLINE vec3s glms_vec3_minsub(vec3s a, vec3s b, vec3s dest);
|
||||||
CGLM_INLINE vec3s glms_vec3_flipsign(vec3s v);
|
CGLM_INLINE vec3s glms_vec3_flipsign(vec3s v);
|
||||||
CGLM_INLINE vec3s glms_vec3_negate(vec3s v);
|
CGLM_INLINE vec3s glms_vec3_negate(vec3s v);
|
||||||
CGLM_INLINE vec3s glms_vec3_inv(vec3s v);
|
|
||||||
CGLM_INLINE vec3s glms_vec3_normalize(vec3s v);
|
CGLM_INLINE vec3s glms_vec3_normalize(vec3s v);
|
||||||
CGLM_INLINE vec3s glms_vec3_cross(vec3s a, vec3s b);
|
CGLM_INLINE vec3s glms_vec3_cross(vec3s a, vec3s b);
|
||||||
CGLM_INLINE vec3s glms_vec3_crossn(vec3s a, vec3s b);
|
CGLM_INLINE vec3s glms_vec3_crossn(vec3s a, vec3s b);
|
||||||
@@ -485,6 +490,102 @@ glms_vec3_(minadd)(vec3s a, vec3s b, vec3s dest) {
|
|||||||
return dest;
|
return dest;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief sub two vectors and sub result to dest
|
||||||
|
*
|
||||||
|
* it applies -= operator so dest must be initialized
|
||||||
|
*
|
||||||
|
* @param[in] a vector 1
|
||||||
|
* @param[in] b vector 2
|
||||||
|
* @returns dest -= (a - b)
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
vec3s
|
||||||
|
glms_vec3_(subsub)(vec3s a, vec3s b, vec3s dest) {
|
||||||
|
glm_vec3_subsub(a.raw, b.raw, dest.raw);
|
||||||
|
return dest;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief add two vectors and sub result to dest
|
||||||
|
*
|
||||||
|
* it applies -= operator so dest must be initialized
|
||||||
|
*
|
||||||
|
* @param[in] a vector 1
|
||||||
|
* @param[in] b vector 2
|
||||||
|
* @returns dest -= (a + b)
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
vec3s
|
||||||
|
glms_vec3_(addsub)(vec3s a, vec3s b, vec3s dest) {
|
||||||
|
glm_vec3_addsub(a.raw, b.raw, dest.raw);
|
||||||
|
return dest;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief mul two vectors and sub result to dest
|
||||||
|
*
|
||||||
|
* it applies -= operator so dest must be initialized
|
||||||
|
*
|
||||||
|
* @param[in] a vector 1
|
||||||
|
* @param[in] b vector 2
|
||||||
|
* @returns dest -= (a * b)
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
vec3s
|
||||||
|
glms_vec3_(mulsub)(vec3s a, vec3s b, vec3s dest) {
|
||||||
|
glm_vec3_mulsub(a.raw, b.raw, dest.raw);
|
||||||
|
return dest;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief mul vector with scalar and sub result to dest
|
||||||
|
*
|
||||||
|
* it applies -= operator so dest must be initialized
|
||||||
|
*
|
||||||
|
* @param[in] a vector
|
||||||
|
* @param[in] s scalar
|
||||||
|
* @returns dest -= (a * b)
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
vec3s
|
||||||
|
glms_vec3_(mulsubs)(vec3s a, float s, vec3s dest) {
|
||||||
|
glm_vec3_mulsubs(a.raw, s, dest.raw);
|
||||||
|
return dest;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief sub max of two vectors to dest
|
||||||
|
*
|
||||||
|
* it applies -= operator so dest must be initialized
|
||||||
|
*
|
||||||
|
* @param[in] a vector 1
|
||||||
|
* @param[in] b vector 2
|
||||||
|
* @returns dest -= max(a, b)
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
vec3s
|
||||||
|
glms_vec3_(maxsub)(vec3s a, vec3s b, vec3s dest) {
|
||||||
|
glm_vec3_maxsub(a.raw, b.raw, dest.raw);
|
||||||
|
return dest;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief sub min of two vectors to dest
|
||||||
|
*
|
||||||
|
* it applies -= operator so dest must be initialized
|
||||||
|
*
|
||||||
|
* @param[in] a vector 1
|
||||||
|
* @param[in] b vector 2
|
||||||
|
* @returns dest -= min(a, b)
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
vec3s
|
||||||
|
glms_vec3_(minsub)(vec3s a, vec3s b, vec3s dest) {
|
||||||
|
glm_vec3_minsub(a.raw, b.raw, dest.raw);
|
||||||
|
return dest;
|
||||||
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief negate vector components and store result in dest
|
* @brief negate vector components and store result in dest
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -41,8 +41,13 @@
|
|||||||
CGLM_INLINE vec4s glms_vec4_muladds(vec4s a, float s, vec4s dest);
|
CGLM_INLINE vec4s glms_vec4_muladds(vec4s a, float s, vec4s dest);
|
||||||
CGLM_INLINE vec4s glms_vec4_maxadd(vec4s a, vec4s b, vec4s dest);
|
CGLM_INLINE vec4s glms_vec4_maxadd(vec4s a, vec4s b, vec4s dest);
|
||||||
CGLM_INLINE vec4s glms_vec4_minadd(vec4s a, vec4s b, vec4s dest);
|
CGLM_INLINE vec4s glms_vec4_minadd(vec4s a, vec4s b, vec4s dest);
|
||||||
|
CGLM_INLINE vec4s glms_vec4_subsub(vec4s a, vec4s b, vec4s dest);
|
||||||
|
CGLM_INLINE vec4s glms_vec4_addsub(vec4s a, vec4s b, vec4s dest);
|
||||||
|
CGLM_INLINE vec4s glms_vec4_mulsub(vec4s a, vec4s b, vec4s dest);
|
||||||
|
CGLM_INLINE vec4s glms_vec4_mulsubs(vec4s a, float s, vec4s dest);
|
||||||
|
CGLM_INLINE vec4s glms_vec4_maxsub(vec4s a, vec4s b, vec4s dest);
|
||||||
|
CGLM_INLINE vec4s glms_vec4_minsub(vec4s a, vec4s b, vec4s dest);
|
||||||
CGLM_INLINE vec4s glms_vec4_negate(vec4s v);
|
CGLM_INLINE vec4s glms_vec4_negate(vec4s v);
|
||||||
CGLM_INLINE vec4s glms_vec4_inv(vec4s v);
|
|
||||||
CGLM_INLINE vec4s glms_vec4_normalize(vec4s v);
|
CGLM_INLINE vec4s glms_vec4_normalize(vec4s v);
|
||||||
CGLM_INLINE float glms_vec4_distance(vec4s a, vec4s b);
|
CGLM_INLINE float glms_vec4_distance(vec4s a, vec4s b);
|
||||||
CGLM_INLINE float glms_vec4_distance2(vec4s a, vec4s b);
|
CGLM_INLINE float glms_vec4_distance2(vec4s a, vec4s b);
|
||||||
@@ -514,6 +519,102 @@ glms_vec4_(minadd)(vec4s a, vec4s b, vec4s dest) {
|
|||||||
return dest;
|
return dest;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief sub two vectors and sub result to dest
|
||||||
|
*
|
||||||
|
* it applies -= operator so dest must be initialized
|
||||||
|
*
|
||||||
|
* @param[in] a vector 1
|
||||||
|
* @param[in] b vector 2
|
||||||
|
* @returns dest -= (a + b)
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
vec4s
|
||||||
|
glms_vec4_(subsub)(vec4s a, vec4s b, vec4s dest) {
|
||||||
|
glm_vec4_subsub(a.raw, b.raw, dest.raw);
|
||||||
|
return dest;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief add two vectors and sub result to dest
|
||||||
|
*
|
||||||
|
* it applies -= operator so dest must be initialized
|
||||||
|
*
|
||||||
|
* @param[in] a vector 1
|
||||||
|
* @param[in] b vector 2
|
||||||
|
* @returns dest -= (a + b)
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
vec4s
|
||||||
|
glms_vec4_(addsub)(vec4s a, vec4s b, vec4s dest) {
|
||||||
|
glm_vec4_addsub(a.raw, b.raw, dest.raw);
|
||||||
|
return dest;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief mul two vectors and sub result to dest
|
||||||
|
*
|
||||||
|
* it applies -= operator so dest must be initialized
|
||||||
|
*
|
||||||
|
* @param[in] a vector 1
|
||||||
|
* @param[in] b vector 2
|
||||||
|
* @returns dest -= (a * b)
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
vec4s
|
||||||
|
glms_vec4_(mulsub)(vec4s a, vec4s b, vec4s dest) {
|
||||||
|
glm_vec4_mulsub(a.raw, b.raw, dest.raw);
|
||||||
|
return dest;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief mul vector with scalar and sub result to dest
|
||||||
|
*
|
||||||
|
* it applies -= operator so dest must be initialized
|
||||||
|
*
|
||||||
|
* @param[in] a vector
|
||||||
|
* @param[in] s scalar
|
||||||
|
* @returns dest -= (a * b)
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
vec4s
|
||||||
|
glms_vec4_(mulsubs)(vec4s a, float s, vec4s dest) {
|
||||||
|
glm_vec4_mulsubs(a.raw, s, dest.raw);
|
||||||
|
return dest;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief sub max of two vectors to dest
|
||||||
|
*
|
||||||
|
* it applies -= operator so dest must be initialized
|
||||||
|
*
|
||||||
|
* @param[in] a vector 1
|
||||||
|
* @param[in] b vector 2
|
||||||
|
* @returns dest -= max(a, b)
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
vec4s
|
||||||
|
glms_vec4_(maxsub)(vec4s a, vec4s b, vec4s dest) {
|
||||||
|
glm_vec4_maxsub(a.raw, b.raw, dest.raw);
|
||||||
|
return dest;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief sub min of two vectors to dest
|
||||||
|
*
|
||||||
|
* it applies -= operator so dest must be initialized
|
||||||
|
*
|
||||||
|
* @param[in] a vector 1
|
||||||
|
* @param[in] b vector 2
|
||||||
|
* @returns dest -= min(a, b)
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
vec4s
|
||||||
|
glms_vec4_(minsub)(vec4s a, vec4s b, vec4s dest) {
|
||||||
|
glm_vec4_minsub(a.raw, b.raw, dest.raw);
|
||||||
|
return dest;
|
||||||
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief negate vector components and store result in dest
|
* @brief negate vector components and store result in dest
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -197,6 +197,28 @@ typedef union mat2s {
|
|||||||
#endif
|
#endif
|
||||||
} mat2s;
|
} mat2s;
|
||||||
|
|
||||||
|
typedef union mat2x3s {
|
||||||
|
mat2x3 raw;
|
||||||
|
vec3s col[2]; /* [col (2), row (3)] */
|
||||||
|
#if CGLM_USE_ANONYMOUS_STRUCT
|
||||||
|
struct {
|
||||||
|
float m00, m01, m02;
|
||||||
|
float m10, m11, m12;
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
} mat2x3s;
|
||||||
|
|
||||||
|
typedef union mat2x4s {
|
||||||
|
mat2x4 raw;
|
||||||
|
vec4s col[2]; /* [col (2), row (4)] */
|
||||||
|
#if CGLM_USE_ANONYMOUS_STRUCT
|
||||||
|
struct {
|
||||||
|
float m00, m01, m02, m03;
|
||||||
|
float m10, m11, m12, m13;
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
} mat2x4s;
|
||||||
|
|
||||||
typedef union mat3s {
|
typedef union mat3s {
|
||||||
mat3 raw;
|
mat3 raw;
|
||||||
vec3s col[3];
|
vec3s col[3];
|
||||||
@@ -209,6 +231,30 @@ typedef union mat3s {
|
|||||||
#endif
|
#endif
|
||||||
} mat3s;
|
} mat3s;
|
||||||
|
|
||||||
|
typedef union mat3x2s {
|
||||||
|
mat3x2 raw;
|
||||||
|
vec2s col[3]; /* [col (3), row (2)] */
|
||||||
|
#if CGLM_USE_ANONYMOUS_STRUCT
|
||||||
|
struct {
|
||||||
|
float m00, m01;
|
||||||
|
float m10, m11;
|
||||||
|
float m20, m21;
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
} mat3x2s;
|
||||||
|
|
||||||
|
typedef union mat3x4s {
|
||||||
|
mat3x4 raw;
|
||||||
|
vec4s col[3]; /* [col (3), row (4)] */
|
||||||
|
#if CGLM_USE_ANONYMOUS_STRUCT
|
||||||
|
struct {
|
||||||
|
float m00, m01, m02, m03;
|
||||||
|
float m10, m11, m12, m13;
|
||||||
|
float m20, m21, m22, m23;
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
} mat3x4s;
|
||||||
|
|
||||||
typedef union CGLM_ALIGN_MAT mat4s {
|
typedef union CGLM_ALIGN_MAT mat4s {
|
||||||
mat4 raw;
|
mat4 raw;
|
||||||
vec4s col[4];
|
vec4s col[4];
|
||||||
@@ -222,4 +268,30 @@ typedef union CGLM_ALIGN_MAT mat4s {
|
|||||||
#endif
|
#endif
|
||||||
} mat4s;
|
} mat4s;
|
||||||
|
|
||||||
|
typedef union mat4x2s {
|
||||||
|
mat4x2 raw;
|
||||||
|
vec2s col[4]; /* [col (4), row (2)] */
|
||||||
|
#if CGLM_USE_ANONYMOUS_STRUCT
|
||||||
|
struct {
|
||||||
|
float m00, m01;
|
||||||
|
float m10, m11;
|
||||||
|
float m20, m21;
|
||||||
|
float m30, m31;
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
} mat4x2s;
|
||||||
|
|
||||||
|
typedef union mat4x3s {
|
||||||
|
mat4x3 raw;
|
||||||
|
vec3s col[4]; /* [col (4), row (3)] */
|
||||||
|
#if CGLM_USE_ANONYMOUS_STRUCT
|
||||||
|
struct {
|
||||||
|
float m00, m01, m02;
|
||||||
|
float m10, m11, m12;
|
||||||
|
float m20, m21, m22;
|
||||||
|
float m30, m31, m32;
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
} mat4x3s;
|
||||||
|
|
||||||
#endif /* cglm_types_struct_h */
|
#endif /* cglm_types_struct_h */
|
||||||
|
|||||||
@@ -8,6 +8,10 @@
|
|||||||
#ifndef cglm_types_h
|
#ifndef cglm_types_h
|
||||||
#define cglm_types_h
|
#define cglm_types_h
|
||||||
|
|
||||||
|
#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L)
|
||||||
|
# include <stdalign.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(_MSC_VER)
|
#if defined(_MSC_VER)
|
||||||
/* do not use alignment for older visual studio versions */
|
/* do not use alignment for older visual studio versions */
|
||||||
# if _MSC_VER < 1913 /* Visual Studio 2017 version 15.6 */
|
# if _MSC_VER < 1913 /* Visual Studio 2017 version 15.6 */
|
||||||
@@ -32,31 +36,59 @@
|
|||||||
# define CGLM_ALIGN_MAT CGLM_ALIGN(16)
|
# define CGLM_ALIGN_MAT CGLM_ALIGN(16)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(__has_builtin)
|
#ifndef CGLM_HAVE_BUILTIN_ASSUME_ALIGNED
|
||||||
# if __has_builtin(__builtin_assume_aligned)
|
|
||||||
# define CGLM_ASSUME_ALIGNED(expr, alignment) \
|
# if defined(__has_builtin)
|
||||||
__builtin_assume_aligned((expr), (alignment))
|
# if __has_builtin(__builtin_assume_aligned)
|
||||||
# else
|
# define CGLM_HAVE_BUILTIN_ASSUME_ALIGNED 1
|
||||||
# define CGLM_ASSUME_ALIGNED(expr, alignment) (expr)
|
# endif
|
||||||
|
# elif defined(__GNUC__) && defined(__GNUC_MINOR__)
|
||||||
|
# if __GNUC__ >= 4 && __GNUC_MINOR__ >= 7
|
||||||
|
# define CGLM_HAVE_BUILTIN_ASSUME_ALIGNED 1
|
||||||
|
# endif
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
|
# ifndef CGLM_HAVE_BUILTIN_ASSUME_ALIGNED
|
||||||
|
# define CGLM_HAVE_BUILTIN_ASSUME_ALIGNED 0
|
||||||
|
# endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if CGLM_HAVE_BUILTIN_ASSUME_ALIGNED
|
||||||
|
# define CGLM_ASSUME_ALIGNED(expr, alignment) \
|
||||||
|
__builtin_assume_aligned((expr), (alignment))
|
||||||
#else
|
#else
|
||||||
# define CGLM_ASSUME_ALIGNED(expr, alignment) (expr)
|
# define CGLM_ASSUME_ALIGNED(expr, alignment) (expr)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define CGLM_CASTPTR_ASSUME_ALIGNED(expr, type) \
|
#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L)
|
||||||
((type*)CGLM_ASSUME_ALIGNED((expr), __alignof__(type)))
|
# define CGLM_CASTPTR_ASSUME_ALIGNED(expr, type) \
|
||||||
|
((type*)CGLM_ASSUME_ALIGNED((expr), alignof(type)))
|
||||||
|
#elif defined(_MSC_VER)
|
||||||
|
# define CGLM_CASTPTR_ASSUME_ALIGNED(expr, type) \
|
||||||
|
((type*)CGLM_ASSUME_ALIGNED((expr), __alignof(type)))
|
||||||
|
#else
|
||||||
|
# define CGLM_CASTPTR_ASSUME_ALIGNED(expr, type) \
|
||||||
|
((type*)CGLM_ASSUME_ALIGNED((expr), __alignof__(type)))
|
||||||
|
#endif
|
||||||
|
|
||||||
typedef int ivec2[2];
|
typedef int ivec2[2];
|
||||||
typedef int ivec3[3];
|
typedef int ivec3[3];
|
||||||
typedef int ivec4[4];
|
typedef int ivec4[4];
|
||||||
|
|
||||||
typedef float vec2[2];
|
typedef float vec2[2];
|
||||||
typedef float vec3[3];
|
typedef float vec3[3];
|
||||||
typedef CGLM_ALIGN_IF(16) float vec4[4];
|
typedef CGLM_ALIGN_IF(16) float vec4[4];
|
||||||
typedef vec4 versor; /* |x, y, z, w| -> w is the last */
|
typedef vec4 versor; /* |x, y, z, w| -> w is the last */
|
||||||
typedef vec3 mat3[3];
|
typedef vec3 mat3[3];
|
||||||
|
typedef vec2 mat3x2[3]; /* [col (3), row (2)] */
|
||||||
|
typedef vec4 mat3x4[3]; /* [col (3), row (4)] */
|
||||||
typedef CGLM_ALIGN_IF(16) vec2 mat2[2];
|
typedef CGLM_ALIGN_IF(16) vec2 mat2[2];
|
||||||
|
typedef vec3 mat2x3[2]; /* [col (2), row (3)] */
|
||||||
|
typedef vec4 mat2x4[2]; /* [col (2), row (4)] */
|
||||||
typedef CGLM_ALIGN_MAT vec4 mat4[4];
|
typedef CGLM_ALIGN_MAT vec4 mat4[4];
|
||||||
|
typedef vec2 mat4x2[4]; /* [col (4), row (2)] */
|
||||||
|
typedef vec3 mat4x3[4]; /* [col (4), row (3)] */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Important: cglm stores quaternion as [x, y, z, w] in memory since v0.4.0
|
Important: cglm stores quaternion as [x, y, z, w] in memory since v0.4.0
|
||||||
|
|||||||
@@ -147,6 +147,38 @@ glm_max(float a, float b) {
|
|||||||
return b;
|
return b;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief find minimum of given two values
|
||||||
|
*
|
||||||
|
* @param[in] a number 1
|
||||||
|
* @param[in] b number 2
|
||||||
|
*
|
||||||
|
* @return smallest of the two values
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
int
|
||||||
|
glm_imin(int a, int b) {
|
||||||
|
if (a < b)
|
||||||
|
return a;
|
||||||
|
return b;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief find maximum of given two values
|
||||||
|
*
|
||||||
|
* @param[in] a number 1
|
||||||
|
* @param[in] b number 2
|
||||||
|
*
|
||||||
|
* @return largest of the two values
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
int
|
||||||
|
glm_imax(int a, int b) {
|
||||||
|
if (a > b)
|
||||||
|
return a;
|
||||||
|
return b;
|
||||||
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief clamp a number between min and max
|
* @brief clamp a number between min and max
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -36,11 +36,18 @@
|
|||||||
CGLM_INLINE void glm_vec2_muladds(vec2 a, float s, vec2 dest)
|
CGLM_INLINE void glm_vec2_muladds(vec2 a, float s, vec2 dest)
|
||||||
CGLM_INLINE void glm_vec2_maxadd(vec2 a, vec2 b, vec2 dest)
|
CGLM_INLINE void glm_vec2_maxadd(vec2 a, vec2 b, vec2 dest)
|
||||||
CGLM_INLINE void glm_vec2_minadd(vec2 a, vec2 b, vec2 dest)
|
CGLM_INLINE void glm_vec2_minadd(vec2 a, vec2 b, vec2 dest)
|
||||||
|
CGLM_INLINE void glm_vec2_subsub(vec2 a, vec2 b, vec2 dest)
|
||||||
|
CGLM_INLINE void glm_vec2_addsub(vec2 a, vec2 b, vec2 dest)
|
||||||
|
CGLM_INLINE void glm_vec2_mulsub(vec2 a, vec2 b, vec2 dest)
|
||||||
|
CGLM_INLINE void glm_vec2_mulsubs(vec2 a, float s, vec2 dest)
|
||||||
|
CGLM_INLINE void glm_vec2_maxsub(vec2 a, vec2 b, vec2 dest)
|
||||||
|
CGLM_INLINE void glm_vec2_minsub(vec2 a, vec2 b, vec2 dest)
|
||||||
CGLM_INLINE void glm_vec2_negate_to(vec2 v, vec2 dest)
|
CGLM_INLINE void glm_vec2_negate_to(vec2 v, vec2 dest)
|
||||||
CGLM_INLINE void glm_vec2_negate(vec2 v)
|
CGLM_INLINE void glm_vec2_negate(vec2 v)
|
||||||
CGLM_INLINE void glm_vec2_normalize(vec2 v)
|
CGLM_INLINE void glm_vec2_normalize(vec2 v)
|
||||||
CGLM_INLINE void glm_vec2_normalize_to(vec2 vec, vec2 dest)
|
CGLM_INLINE void glm_vec2_normalize_to(vec2 vec, vec2 dest)
|
||||||
CGLM_INLINE void glm_vec2_rotate(vec2 v, float angle, vec2 dest)
|
CGLM_INLINE void glm_vec2_rotate(vec2 v, float angle, vec2 dest)
|
||||||
|
CGLM_INLINE void glm_vec2_center(vec2 a, vec2 b, vec2 dest)
|
||||||
CGLM_INLINE float glm_vec2_distance2(vec2 a, vec2 b)
|
CGLM_INLINE float glm_vec2_distance2(vec2 a, vec2 b)
|
||||||
CGLM_INLINE float glm_vec2_distance(vec2 a, vec2 b)
|
CGLM_INLINE float glm_vec2_distance(vec2 a, vec2 b)
|
||||||
CGLM_INLINE void glm_vec2_maxv(vec2 v1, vec2 v2, vec2 dest)
|
CGLM_INLINE void glm_vec2_maxv(vec2 v1, vec2 v2, vec2 dest)
|
||||||
@@ -402,6 +409,102 @@ glm_vec2_minadd(vec2 a, vec2 b, vec2 dest) {
|
|||||||
dest[1] += glm_min(a[1], b[1]);
|
dest[1] += glm_min(a[1], b[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief sub two vectors and sub result to dest
|
||||||
|
*
|
||||||
|
* it applies -= operator so dest must be initialized
|
||||||
|
*
|
||||||
|
* @param[in] a vector 1
|
||||||
|
* @param[in] b vector 2
|
||||||
|
* @param[out] dest dest -= (a - b)
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
void
|
||||||
|
glm_vec2_subsub(vec2 a, vec2 b, vec2 dest) {
|
||||||
|
dest[0] -= a[0] - b[0];
|
||||||
|
dest[1] -= a[1] - b[1];
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief add two vectors and sub result to dest
|
||||||
|
*
|
||||||
|
* it applies -= operator so dest must be initialized
|
||||||
|
*
|
||||||
|
* @param[in] a vector 1
|
||||||
|
* @param[in] b vector 2
|
||||||
|
* @param[out] dest dest -= (a + b)
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
void
|
||||||
|
glm_vec2_addsub(vec2 a, vec2 b, vec2 dest) {
|
||||||
|
dest[0] -= a[0] + b[0];
|
||||||
|
dest[1] -= a[1] + b[1];
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief mul two vectors and sub result to dest
|
||||||
|
*
|
||||||
|
* it applies -= operator so dest must be initialized
|
||||||
|
*
|
||||||
|
* @param[in] a vector 1
|
||||||
|
* @param[in] b vector 2
|
||||||
|
* @param[out] dest dest -= (a * b)
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
void
|
||||||
|
glm_vec2_mulsub(vec2 a, vec2 b, vec2 dest) {
|
||||||
|
dest[0] -= a[0] * b[0];
|
||||||
|
dest[1] -= a[1] * b[1];
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief mul vector with scalar and sub result to sum
|
||||||
|
*
|
||||||
|
* it applies -= operator so dest must be initialized
|
||||||
|
*
|
||||||
|
* @param[in] a vector
|
||||||
|
* @param[in] s scalar
|
||||||
|
* @param[out] dest dest -= (a * b)
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
void
|
||||||
|
glm_vec2_mulsubs(vec2 a, float s, vec2 dest) {
|
||||||
|
dest[0] -= a[0] * s;
|
||||||
|
dest[1] -= a[1] * s;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief sub max of two vectors to result/dest
|
||||||
|
*
|
||||||
|
* it applies -= operator so dest must be initialized
|
||||||
|
*
|
||||||
|
* @param[in] a vector 1
|
||||||
|
* @param[in] b vector 2
|
||||||
|
* @param[out] dest dest -= max(a, b)
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
void
|
||||||
|
glm_vec2_maxsub(vec2 a, vec2 b, vec2 dest) {
|
||||||
|
dest[0] -= glm_max(a[0], b[0]);
|
||||||
|
dest[1] -= glm_max(a[1], b[1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief sub min of two vectors to result/dest
|
||||||
|
*
|
||||||
|
* it applies -= operator so dest must be initialized
|
||||||
|
*
|
||||||
|
* @param[in] a vector 1
|
||||||
|
* @param[in] b vector 2
|
||||||
|
* @param[out] dest dest -= min(a, b)
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
void
|
||||||
|
glm_vec2_minsub(vec2 a, vec2 b, vec2 dest) {
|
||||||
|
dest[0] -= glm_min(a[0], b[0]);
|
||||||
|
dest[1] -= glm_min(a[1], b[1]);
|
||||||
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief negate vector components and store result in dest
|
* @brief negate vector components and store result in dest
|
||||||
*
|
*
|
||||||
@@ -493,6 +596,20 @@ glm_vec2_rotate(vec2 v, float angle, vec2 dest) {
|
|||||||
dest[1] = s * x1 + c * y1;
|
dest[1] = s * x1 + c * y1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief find center point of two vector
|
||||||
|
*
|
||||||
|
* @param[in] a vector1
|
||||||
|
* @param[in] b vector2
|
||||||
|
* @param[out] dest center point
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
void
|
||||||
|
glm_vec2_center(vec2 a, vec2 b, vec2 dest) {
|
||||||
|
glm_vec2_add(a, b, dest);
|
||||||
|
glm_vec2_scale(dest, 0.5f, dest);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief squared distance between two vectors
|
* @brief squared distance between two vectors
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -40,6 +40,12 @@
|
|||||||
CGLM_INLINE void glm_vec3_muladds(vec3 a, float s, vec3 dest);
|
CGLM_INLINE void glm_vec3_muladds(vec3 a, float s, vec3 dest);
|
||||||
CGLM_INLINE void glm_vec3_maxadd(vec3 a, vec3 b, vec3 dest);
|
CGLM_INLINE void glm_vec3_maxadd(vec3 a, vec3 b, vec3 dest);
|
||||||
CGLM_INLINE void glm_vec3_minadd(vec3 a, vec3 b, vec3 dest);
|
CGLM_INLINE void glm_vec3_minadd(vec3 a, vec3 b, vec3 dest);
|
||||||
|
CGLM_INLINE void glm_vec3_subsub(vec3 a, vec3 b, vec3 dest);
|
||||||
|
CGLM_INLINE void glm_vec3_addsub(vec3 a, vec3 b, vec3 dest);
|
||||||
|
CGLM_INLINE void glm_vec3_mulsub(vec3 a, vec3 b, vec3 dest);
|
||||||
|
CGLM_INLINE void glm_vec3_mulsubs(vec3 a, float s, vec3 dest);
|
||||||
|
CGLM_INLINE void glm_vec3_maxsub(vec3 a, vec3 b, vec3 dest);
|
||||||
|
CGLM_INLINE void glm_vec3_minsub(vec3 a, vec3 b, vec3 dest);
|
||||||
CGLM_INLINE void glm_vec3_flipsign(vec3 v);
|
CGLM_INLINE void glm_vec3_flipsign(vec3 v);
|
||||||
CGLM_INLINE void glm_vec3_flipsign_to(vec3 v, vec3 dest);
|
CGLM_INLINE void glm_vec3_flipsign_to(vec3 v, vec3 dest);
|
||||||
CGLM_INLINE void glm_vec3_negate_to(vec3 v, vec3 dest);
|
CGLM_INLINE void glm_vec3_negate_to(vec3 v, vec3 dest);
|
||||||
@@ -503,6 +509,108 @@ glm_vec3_minadd(vec3 a, vec3 b, vec3 dest) {
|
|||||||
dest[2] += glm_min(a[2], b[2]);
|
dest[2] += glm_min(a[2], b[2]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief sub two vectors and sub result to dest
|
||||||
|
*
|
||||||
|
* it applies += operator so dest must be initialized
|
||||||
|
*
|
||||||
|
* @param[in] a vector 1
|
||||||
|
* @param[in] b vector 2
|
||||||
|
* @param[out] dest dest -= (a - b)
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
void
|
||||||
|
glm_vec3_subsub(vec3 a, vec3 b, vec3 dest) {
|
||||||
|
dest[0] -= a[0] - b[0];
|
||||||
|
dest[1] -= a[1] - b[1];
|
||||||
|
dest[2] -= a[2] - b[2];
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief add two vectors and sub result to dest
|
||||||
|
*
|
||||||
|
* it applies += operator so dest must be initialized
|
||||||
|
*
|
||||||
|
* @param[in] a vector 1
|
||||||
|
* @param[in] b vector 2
|
||||||
|
* @param[out] dest dest -= (a + b)
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
void
|
||||||
|
glm_vec3_addsub(vec3 a, vec3 b, vec3 dest) {
|
||||||
|
dest[0] -= a[0] + b[0];
|
||||||
|
dest[1] -= a[1] + b[1];
|
||||||
|
dest[2] -= a[2] + b[2];
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief mul two vectors and sub result to dest
|
||||||
|
*
|
||||||
|
* it applies -= operator so dest must be initialized
|
||||||
|
*
|
||||||
|
* @param[in] a vector 1
|
||||||
|
* @param[in] b vector 2
|
||||||
|
* @param[out] dest dest -= (a * b)
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
void
|
||||||
|
glm_vec3_mulsub(vec3 a, vec3 b, vec3 dest) {
|
||||||
|
dest[0] -= a[0] * b[0];
|
||||||
|
dest[1] -= a[1] * b[1];
|
||||||
|
dest[2] -= a[2] * b[2];
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief mul vector with scalar and sub result to dest
|
||||||
|
*
|
||||||
|
* it applies -= operator so dest must be initialized
|
||||||
|
*
|
||||||
|
* @param[in] a vector
|
||||||
|
* @param[in] s scalar
|
||||||
|
* @param[out] dest dest -= (a * b)
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
void
|
||||||
|
glm_vec3_mulsubs(vec3 a, float s, vec3 dest) {
|
||||||
|
dest[0] -= a[0] * s;
|
||||||
|
dest[1] -= a[1] * s;
|
||||||
|
dest[2] -= a[2] * s;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief sub max of two vectors to result/dest
|
||||||
|
*
|
||||||
|
* it applies -= operator so dest must be initialized
|
||||||
|
*
|
||||||
|
* @param[in] a vector 1
|
||||||
|
* @param[in] b vector 2
|
||||||
|
* @param[out] dest dest -= max(a, b)
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
void
|
||||||
|
glm_vec3_maxsub(vec3 a, vec3 b, vec3 dest) {
|
||||||
|
dest[0] -= glm_max(a[0], b[0]);
|
||||||
|
dest[1] -= glm_max(a[1], b[1]);
|
||||||
|
dest[2] -= glm_max(a[2], b[2]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief sub min of two vectors to result/dest
|
||||||
|
*
|
||||||
|
* it applies -= operator so dest must be initialized
|
||||||
|
*
|
||||||
|
* @param[in] a vector 1
|
||||||
|
* @param[in] b vector 2
|
||||||
|
* @param[out] dest dest -= min(a, b)
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
void
|
||||||
|
glm_vec3_minsub(vec3 a, vec3 b, vec3 dest) {
|
||||||
|
dest[0] -= glm_min(a[0], b[0]);
|
||||||
|
dest[1] -= glm_min(a[1], b[1]);
|
||||||
|
dest[2] -= glm_min(a[2], b[2]);
|
||||||
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief negate vector components and store result in dest
|
* @brief negate vector components and store result in dest
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -223,7 +223,7 @@ glm_vec4_isvalid(vec4 v) {
|
|||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
void
|
void
|
||||||
glm_vec4_sign(vec4 v, vec4 dest) {
|
glm_vec4_sign(vec4 v, vec4 dest) {
|
||||||
#if defined( __SSE2__ ) || defined( __SSE2__ )
|
#if defined( __SSE__ ) || defined( __SSE2__ )
|
||||||
__m128 x0, x1, x2, x3, x4;
|
__m128 x0, x1, x2, x3, x4;
|
||||||
|
|
||||||
x0 = glmm_load(v);
|
x0 = glmm_load(v);
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user