mirror of
https://github.com/recp/cglm.git
synced 2026-02-17 03:39:05 +00:00
Compare commits
101 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
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 |
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.2
|
||||||
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
|
||||||
|
|||||||
20
Makefile.am
20
Makefile.am
@@ -69,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 \
|
||||||
@@ -149,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 \
|
||||||
@@ -168,6 +170,17 @@ 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/mat4x2.h \
|
||||||
@@ -196,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 \
|
||||||
@@ -217,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 \
|
||||||
|
|||||||
@@ -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.1"
|
||||||
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.2], [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
|
||||||
|
|
||||||
@@ -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
|
||||||
|
|||||||
@@ -55,16 +55,14 @@ Functions documentation
|
|||||||
|
|
||||||
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:
|
|
||||||
|
|
||||||
.. code-block:: c
|
.. code-block:: c
|
||||||
|
|
||||||
glm_mat2x3_mul(m, m, m);
|
glm_mat2x3_mul(mat2x3, mat3x2, mat2);
|
||||||
|
|
||||||
Parameters:
|
Parameters:
|
||||||
| *[in]* **m1** left matrix
|
| *[in]* **m1** left matrix (mat2x3)
|
||||||
| *[in]* **m2** right matrix
|
| *[in]* **m2** right matrix (mat3x2)
|
||||||
| *[out]* **dest** destination matrix
|
| *[out]* **dest** destination matrix (mat2)
|
||||||
|
|
||||||
.. c:function:: void glm_mat2x3_mulv(mat2x3 m, vec3 v, vec2 dest)
|
.. c:function:: void glm_mat2x3_mulv(mat2x3 m, vec3 v, vec2 dest)
|
||||||
|
|
||||||
|
|||||||
@@ -55,16 +55,14 @@ Functions documentation
|
|||||||
|
|
||||||
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:
|
|
||||||
|
|
||||||
.. code-block:: c
|
.. code-block:: c
|
||||||
|
|
||||||
glm_mat2x4_mul(m, m, m);
|
glm_mat2x4_mul(mat2x4, mat4x2, mat2);
|
||||||
|
|
||||||
Parameters:
|
Parameters:
|
||||||
| *[in]* **m1** left matrix
|
| *[in]* **m1** left matrix (mat2x4)
|
||||||
| *[in]* **m2** right matrix
|
| *[in]* **m2** right matrix (mat4x2)
|
||||||
| *[out]* **dest** destination matrix
|
| *[out]* **dest** destination matrix (mat2)
|
||||||
|
|
||||||
.. c:function:: void glm_mat2x4_mulv(mat2x4 m, vec4 v, vec2 dest)
|
.. c:function:: void glm_mat2x4_mulv(mat2x4 m, vec4 v, vec2 dest)
|
||||||
|
|
||||||
|
|||||||
@@ -54,16 +54,14 @@ Functions documentation
|
|||||||
|
|
||||||
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:
|
|
||||||
|
|
||||||
.. code-block:: c
|
.. code-block:: c
|
||||||
|
|
||||||
glm_mat3x2_mul(m, m, m);
|
glm_mat3x2_mul(mat3x2, mat2x3, mat3);
|
||||||
|
|
||||||
Parameters:
|
Parameters:
|
||||||
| *[in]* **m1** left matrix
|
| *[in]* **m1** left matrix (mat3x2)
|
||||||
| *[in]* **m2** right matrix
|
| *[in]* **m2** right matrix (mat2x3)
|
||||||
| *[out]* **dest** destination matrix
|
| *[out]* **dest** destination matrix (mat3)
|
||||||
|
|
||||||
.. c:function:: void glm_mat3x2_mulv(mat3x2 m, vec2 v, vec3 dest)
|
.. c:function:: void glm_mat3x2_mulv(mat3x2 m, vec2 v, vec3 dest)
|
||||||
|
|
||||||
|
|||||||
@@ -54,16 +54,14 @@ Functions documentation
|
|||||||
|
|
||||||
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:
|
|
||||||
|
|
||||||
.. code-block:: c
|
.. code-block:: c
|
||||||
|
|
||||||
glm_mat3x4_mul(m, m, m);
|
glm_mat3x4_mul(mat3x4, mat4x3, mat3);
|
||||||
|
|
||||||
Parameters:
|
Parameters:
|
||||||
| *[in]* **m1** left matrix
|
| *[in]* **m1** left matrix (mat3x4)
|
||||||
| *[in]* **m2** right matrix
|
| *[in]* **m2** right matrix (mat4x3)
|
||||||
| *[out]* **dest** destination matrix
|
| *[out]* **dest** destination matrix (mat3)
|
||||||
|
|
||||||
.. c:function:: void glm_mat3x4_mulv(mat3x4 m, vec4 v, vec3 dest)
|
.. c:function:: void glm_mat3x4_mulv(mat3x4 m, vec4 v, vec3 dest)
|
||||||
|
|
||||||
|
|||||||
@@ -54,16 +54,14 @@ Functions documentation
|
|||||||
|
|
||||||
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:
|
|
||||||
|
|
||||||
.. code-block:: c
|
.. code-block:: c
|
||||||
|
|
||||||
glm_mat4x2_mul(m, m, m);
|
glm_mat4x2_mul(mat4x2, mat2x4, mat4);
|
||||||
|
|
||||||
Parameters:
|
Parameters:
|
||||||
| *[in]* **m1** left matrix
|
| *[in]* **m1** left matrix (mat4x2)
|
||||||
| *[in]* **m2** right matrix
|
| *[in]* **m2** right matrix (mat2x4)
|
||||||
| *[out]* **dest** destination matrix
|
| *[out]* **dest** destination matrix (mat4)
|
||||||
|
|
||||||
.. c:function:: void glm_mat4x2_mulv(mat4x2 m, vec2 v, vec4 dest)
|
.. c:function:: void glm_mat4x2_mulv(mat4x2 m, vec2 v, vec4 dest)
|
||||||
|
|
||||||
|
|||||||
@@ -54,16 +54,14 @@ Functions documentation
|
|||||||
|
|
||||||
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:
|
|
||||||
|
|
||||||
.. code-block:: c
|
.. code-block:: c
|
||||||
|
|
||||||
glm_mat4x3_mul(m, m, m);
|
glm_mat4x3_mul(mat4x3, mat3x4, mat4);
|
||||||
|
|
||||||
Parameters:
|
Parameters:
|
||||||
| *[in]* **m1** left matrix
|
| *[in]* **m1** left matrix (mat4x3)
|
||||||
| *[in]* **m2** right matrix
|
| *[in]* **m2** right matrix (mat3x4)
|
||||||
| *[out]* **dest** destination matrix
|
| *[out]* **dest** destination matrix (mat4)
|
||||||
|
|
||||||
.. c:function:: void glm_mat4x3_mulv(mat4x3 m, vec3 v, vec4 dest)
|
.. c:function:: void glm_mat4x3_mulv(mat4x3 m, vec3 v, vec4 dest)
|
||||||
|
|
||||||
|
|||||||
@@ -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 */
|
||||||
|
|
||||||
@@ -33,6 +33,7 @@ extern "C" {
|
|||||||
#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);
|
||||||
|
|||||||
@@ -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);
|
||||||
|
|||||||
@@ -30,6 +30,7 @@
|
|||||||
#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
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -81,15 +81,13 @@ glm_mat2x3_make(float * __restrict src, mat2x3 dest) {
|
|||||||
/*!
|
/*!
|
||||||
* @brief multiply m1 and m2 to dest
|
* @brief multiply m1 and m2 to dest
|
||||||
*
|
*
|
||||||
* m1, m2 and dest matrices can be same matrix, it is possible to write this:
|
|
||||||
*
|
|
||||||
* @code
|
* @code
|
||||||
* glm_mat2x3_mul(m, m, m);
|
* glm_mat2x3_mul(mat2x3, mat3x2, mat2);
|
||||||
* @endcode
|
* @endcode
|
||||||
*
|
*
|
||||||
* @param[in] m1 left matrix
|
* @param[in] m1 left matrix (mat2x3)
|
||||||
* @param[in] m2 right matrix
|
* @param[in] m2 right matrix (mat3x2)
|
||||||
* @param[out] dest destination matrix
|
* @param[out] dest destination matrix (mat2)
|
||||||
*/
|
*/
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
void
|
void
|
||||||
|
|||||||
@@ -79,15 +79,13 @@ glm_mat2x4_make(float * __restrict src, mat2x4 dest) {
|
|||||||
/*!
|
/*!
|
||||||
* @brief multiply m1 and m2 to dest
|
* @brief multiply m1 and m2 to dest
|
||||||
*
|
*
|
||||||
* m1, m2 and dest matrices can be same matrix, it is possible to write this:
|
|
||||||
*
|
|
||||||
* @code
|
* @code
|
||||||
* glm_mat2x4_mul(m, m, m);
|
* glm_mat2x4_mul(mat2x4, mat4x2, mat2);
|
||||||
* @endcode
|
* @endcode
|
||||||
*
|
*
|
||||||
* @param[in] m1 left matrix
|
* @param[in] m1 left matrix (mat2x4)
|
||||||
* @param[in] m2 right matrix
|
* @param[in] m2 right matrix (mat4x2)
|
||||||
* @param[out] dest destination matrix
|
* @param[out] dest destination matrix (mat2)
|
||||||
*/
|
*/
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
void
|
void
|
||||||
|
|||||||
@@ -83,15 +83,13 @@ glm_mat3x2_make(float * __restrict src, mat3x2 dest) {
|
|||||||
/*!
|
/*!
|
||||||
* @brief multiply m1 and m2 to dest
|
* @brief multiply m1 and m2 to dest
|
||||||
*
|
*
|
||||||
* m1, m2 and dest matrices can be same matrix, it is possible to write this:
|
|
||||||
*
|
|
||||||
* @code
|
* @code
|
||||||
* glm_mat3x2_mul(m, m, m);
|
* glm_mat3x2_mul(mat3x2, mat2x3, mat3);
|
||||||
* @endcode
|
* @endcode
|
||||||
*
|
*
|
||||||
* @param[in] m1 left matrix
|
* @param[in] m1 left matrix (mat3x2)
|
||||||
* @param[in] m2 right matrix
|
* @param[in] m2 right matrix (mat2x3)
|
||||||
* @param[out] dest destination matrix
|
* @param[out] dest destination matrix (mat3)
|
||||||
*/
|
*/
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
void
|
void
|
||||||
|
|||||||
@@ -86,15 +86,13 @@ glm_mat3x4_make(float * __restrict src, mat3x4 dest) {
|
|||||||
/*!
|
/*!
|
||||||
* @brief multiply m1 and m2 to dest
|
* @brief multiply m1 and m2 to dest
|
||||||
*
|
*
|
||||||
* m1, m2 and dest matrices can be same matrix, it is possible to write this:
|
|
||||||
*
|
|
||||||
* @code
|
* @code
|
||||||
* glm_mat3x4_mul(m, m, m);
|
* glm_mat3x4_mul(mat3x4, mat4x3, mat3);
|
||||||
* @endcode
|
* @endcode
|
||||||
*
|
*
|
||||||
* @param[in] m1 left matrix
|
* @param[in] m1 left matrix (mat3x4)
|
||||||
* @param[in] m2 right matrix
|
* @param[in] m2 right matrix (mat4x3)
|
||||||
* @param[out] dest destination matrix
|
* @param[out] dest destination matrix (mat3)
|
||||||
*/
|
*/
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
void
|
void
|
||||||
|
|||||||
@@ -89,15 +89,13 @@ glm_mat4x2_make(float * __restrict src, mat4x2 dest) {
|
|||||||
/*!
|
/*!
|
||||||
* @brief multiply m1 and m2 to dest
|
* @brief multiply m1 and m2 to dest
|
||||||
*
|
*
|
||||||
* m1, m2 and dest matrices can be same matrix, it is possible to write this:
|
|
||||||
*
|
|
||||||
* @code
|
* @code
|
||||||
* glm_mat4x2_mul(m, m, m);
|
* glm_mat4x2_mul(mat4x2, mat2x4, mat4);
|
||||||
* @endcode
|
* @endcode
|
||||||
*
|
*
|
||||||
* @param[in] m1 left matrix
|
* @param[in] m1 left matrix (mat4x2)
|
||||||
* @param[in] m2 right matrix
|
* @param[in] m2 right matrix (mat2x4)
|
||||||
* @param[out] dest destination matrix
|
* @param[out] dest destination matrix (mat4)
|
||||||
*/
|
*/
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
void
|
void
|
||||||
|
|||||||
@@ -98,15 +98,13 @@ glm_mat4x3_make(float * __restrict src, mat4x3 dest) {
|
|||||||
/*!
|
/*!
|
||||||
* @brief multiply m1 and m2 to dest
|
* @brief multiply m1 and m2 to dest
|
||||||
*
|
*
|
||||||
* m1, m2 and dest matrices can be same matrix, it is possible to write this:
|
|
||||||
*
|
|
||||||
* @code
|
* @code
|
||||||
* glm_mat4x3_mul(m, m, m);
|
* glm_mat4x3_mul(mat4x3, mat3x4, mat4);
|
||||||
* @endcode
|
* @endcode
|
||||||
*
|
*
|
||||||
* @param[in] m1 left matrix
|
* @param[in] m1 left matrix (mat4x3)
|
||||||
* @param[in] m2 right matrix
|
* @param[in] m2 right matrix (mat3x4)
|
||||||
* @param[out] dest destination matrix
|
* @param[out] dest destination matrix (mat4)
|
||||||
*/
|
*/
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
void
|
void
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
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);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -64,15 +64,13 @@ glms_mat2x3_(make)(float * __restrict src) {
|
|||||||
/*!
|
/*!
|
||||||
* @brief multiply m1 and m2 to dest
|
* @brief multiply m1 and m2 to dest
|
||||||
*
|
*
|
||||||
* m1, m2 and dest matrices can be same matrix, it is possible to write this:
|
|
||||||
*
|
|
||||||
* @code
|
* @code
|
||||||
* glm_mat2x3_mul(m, m, m);
|
* r = glms_mat2x3_mul(mat2x3s, mat3x2s);
|
||||||
* @endcode
|
* @endcode
|
||||||
*
|
*
|
||||||
* @param[in] m1 left matrix
|
* @param[in] m1 left matrix (mat2x3s)
|
||||||
* @param[in] m2 right matrix
|
* @param[in] m2 right matrix (mat3x2s)
|
||||||
* @param[out] dest destination matrix
|
* @returns destination matrix (mat2s)
|
||||||
*/
|
*/
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
mat2s
|
mat2s
|
||||||
|
|||||||
@@ -64,15 +64,13 @@ glms_mat2x4_(make)(float * __restrict src) {
|
|||||||
/*!
|
/*!
|
||||||
* @brief multiply m1 and m2 to dest
|
* @brief multiply m1 and m2 to dest
|
||||||
*
|
*
|
||||||
* m1, m2 and dest matrices can be same matrix, it is possible to write this:
|
|
||||||
*
|
|
||||||
* @code
|
* @code
|
||||||
* glm_mat2x4_mul(m, m, m);
|
* r = glms_mat2x4_mul(mat2x4s, mat4x2s);
|
||||||
* @endcode
|
* @endcode
|
||||||
*
|
*
|
||||||
* @param[in] m1 left matrix
|
* @param[in] m1 left matrix (mat2x4s)
|
||||||
* @param[in] m2 right matrix
|
* @param[in] m2 right matrix (mat4x2s)
|
||||||
* @param[out] dest destination matrix
|
* @returns destination matrix (mat2s)
|
||||||
*/
|
*/
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
mat2s
|
mat2s
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -64,15 +64,13 @@ glms_mat3x2_(make)(float * __restrict src) {
|
|||||||
/*!
|
/*!
|
||||||
* @brief multiply m1 and m2 to dest
|
* @brief multiply m1 and m2 to dest
|
||||||
*
|
*
|
||||||
* m1, m2 and dest matrices can be same matrix, it is possible to write this:
|
|
||||||
*
|
|
||||||
* @code
|
* @code
|
||||||
* glm_mat3x2_mul(m, m, m);
|
* r = glms_mat3x2_mul(mat3x2s, mat2x3s);
|
||||||
* @endcode
|
* @endcode
|
||||||
*
|
*
|
||||||
* @param[in] m1 left matrix
|
* @param[in] m1 left matrix (mat3x2s)
|
||||||
* @param[in] m2 right matrix
|
* @param[in] m2 right matrix (mat2x3s)
|
||||||
* @param[out] dest destination matrix
|
* @returns destination matrix (mat3s)
|
||||||
*/
|
*/
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
mat3s
|
mat3s
|
||||||
|
|||||||
@@ -64,15 +64,13 @@ glms_mat3x4_(make)(float * __restrict src) {
|
|||||||
/*!
|
/*!
|
||||||
* @brief multiply m1 and m2 to dest
|
* @brief multiply m1 and m2 to dest
|
||||||
*
|
*
|
||||||
* m1, m2 and dest matrices can be same matrix, it is possible to write this:
|
|
||||||
*
|
|
||||||
* @code
|
* @code
|
||||||
* glm_mat3x4_mul(m, m, m);
|
* r = glms_mat3x4_mul(mat3x4s, mat4x3s);
|
||||||
* @endcode
|
* @endcode
|
||||||
*
|
*
|
||||||
* @param[in] m1 left matrix
|
* @param[in] m1 left matrix (mat3x4s)
|
||||||
* @param[in] m2 right matrix
|
* @param[in] m2 right matrix (mat4x3s)
|
||||||
* @param[out] dest destination matrix
|
* @returns destination matrix (mat3s)
|
||||||
*/
|
*/
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
mat3s
|
mat3s
|
||||||
|
|||||||
@@ -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);
|
||||||
@@ -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
|
||||||
|
|||||||
@@ -65,15 +65,13 @@ glms_mat4x2_(make)(float * __restrict src) {
|
|||||||
/*!
|
/*!
|
||||||
* @brief multiply m1 and m2 to dest
|
* @brief multiply m1 and m2 to dest
|
||||||
*
|
*
|
||||||
* m1, m2 and dest matrices can be same matrix, it is possible to write this:
|
|
||||||
*
|
|
||||||
* @code
|
* @code
|
||||||
* glm_mat4x2_mul(m, m, m);
|
* r = glms_mat4x2_mul(mat4x2s, mat2x4s);
|
||||||
* @endcode
|
* @endcode
|
||||||
*
|
*
|
||||||
* @param[in] m1 left matrix
|
* @param[in] m1 left matrix (mat4x2s)
|
||||||
* @param[in] m2 right matrix
|
* @param[in] m2 right matrix (mat2x4s)
|
||||||
* @param[out] dest destination matrix
|
* @returns destination matrix (mat4s)
|
||||||
*/
|
*/
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
mat4s
|
mat4s
|
||||||
|
|||||||
@@ -64,15 +64,13 @@ glms_mat4x3_(make)(float * __restrict src) {
|
|||||||
/*!
|
/*!
|
||||||
* @brief multiply m1 and m2 to dest
|
* @brief multiply m1 and m2 to dest
|
||||||
*
|
*
|
||||||
* m1, m2 and dest matrices can be same matrix, it is possible to write this:
|
|
||||||
*
|
|
||||||
* @code
|
* @code
|
||||||
* glm_mat4x3_mul(m, m, m);
|
* r = glms_mat4x3_mul(mat4x3s, mat3x4s);
|
||||||
* @endcode
|
* @endcode
|
||||||
*
|
*
|
||||||
* @param[in] m1 left matrix
|
* @param[in] m1 left matrix (mat4x3s)
|
||||||
* @param[in] m2 right matrix
|
* @param[in] m2 right matrix (mat3x4s)
|
||||||
* @param[out] dest destination matrix
|
* @returns destination matrix (mat4s)
|
||||||
*/
|
*/
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
mat4s
|
mat4s
|
||||||
|
|||||||
@@ -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
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -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 */
|
||||||
@@ -57,8 +61,16 @@
|
|||||||
# 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];
|
||||||
|
|||||||
@@ -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);
|
||||||
|
|||||||
@@ -39,6 +39,12 @@
|
|||||||
CGLM_INLINE void glm_vec4_muladds(vec4 a, float s, vec4 dest);
|
CGLM_INLINE void glm_vec4_muladds(vec4 a, float s, vec4 dest);
|
||||||
CGLM_INLINE void glm_vec4_maxadd(vec4 a, vec4 b, vec4 dest);
|
CGLM_INLINE void glm_vec4_maxadd(vec4 a, vec4 b, vec4 dest);
|
||||||
CGLM_INLINE void glm_vec4_minadd(vec4 a, vec4 b, vec4 dest);
|
CGLM_INLINE void glm_vec4_minadd(vec4 a, vec4 b, vec4 dest);
|
||||||
|
CGLM_INLINE void glm_vec4_subsub(vec4 a, vec4 b, vec4 dest);
|
||||||
|
CGLM_INLINE void glm_vec4_addsub(vec4 a, vec4 b, vec4 dest);
|
||||||
|
CGLM_INLINE void glm_vec4_mulsub(vec4 a, vec4 b, vec4 dest);
|
||||||
|
CGLM_INLINE void glm_vec4_mulsubs(vec4 a, float s, vec4 dest);
|
||||||
|
CGLM_INLINE void glm_vec4_maxsub(vec4 a, vec4 b, vec4 dest);
|
||||||
|
CGLM_INLINE void glm_vec4_minsub(vec4 a, vec4 b, vec4 dest);
|
||||||
CGLM_INLINE void glm_vec4_negate(vec4 v);
|
CGLM_INLINE void glm_vec4_negate(vec4 v);
|
||||||
CGLM_INLINE void glm_vec4_inv(vec4 v);
|
CGLM_INLINE void glm_vec4_inv(vec4 v);
|
||||||
CGLM_INLINE void glm_vec4_inv_to(vec4 v, vec4 dest);
|
CGLM_INLINE void glm_vec4_inv_to(vec4 v, vec4 dest);
|
||||||
@@ -649,7 +655,7 @@ glm_vec4_maxadd(vec4 a, vec4 b, vec4 dest) {
|
|||||||
#if defined(__wasm__) && defined(__wasm_simd128__)
|
#if defined(__wasm__) && defined(__wasm_simd128__)
|
||||||
glmm_store(dest, wasm_f32x4_add(
|
glmm_store(dest, wasm_f32x4_add(
|
||||||
glmm_load(dest),
|
glmm_load(dest),
|
||||||
wasm_f32x4_max(glmm_load(a), glmm_load(b))));
|
wasm_f32x4_pmax(glmm_load(a), glmm_load(b))));
|
||||||
#elif defined( __SSE__ ) || defined( __SSE2__ )
|
#elif defined( __SSE__ ) || defined( __SSE2__ )
|
||||||
glmm_store(dest, _mm_add_ps(glmm_load(dest),
|
glmm_store(dest, _mm_add_ps(glmm_load(dest),
|
||||||
_mm_max_ps(glmm_load(a),
|
_mm_max_ps(glmm_load(a),
|
||||||
@@ -681,7 +687,7 @@ glm_vec4_minadd(vec4 a, vec4 b, vec4 dest) {
|
|||||||
#if defined(__wasm__) && defined(__wasm_simd128__)
|
#if defined(__wasm__) && defined(__wasm_simd128__)
|
||||||
glmm_store(dest, wasm_f32x4_add(
|
glmm_store(dest, wasm_f32x4_add(
|
||||||
glmm_load(dest),
|
glmm_load(dest),
|
||||||
wasm_f32x4_min(glmm_load(a), glmm_load(b))));
|
wasm_f32x4_pmin(glmm_load(a), glmm_load(b))));
|
||||||
#elif defined( __SSE__ ) || defined( __SSE2__ )
|
#elif defined( __SSE__ ) || defined( __SSE2__ )
|
||||||
glmm_store(dest, _mm_add_ps(glmm_load(dest),
|
glmm_store(dest, _mm_add_ps(glmm_load(dest),
|
||||||
_mm_min_ps(glmm_load(a),
|
_mm_min_ps(glmm_load(a),
|
||||||
@@ -698,6 +704,178 @@ glm_vec4_minadd(vec4 a, vec4 b, vec4 dest) {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @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_vec4_subsub(vec4 a, vec4 b, vec4 dest) {
|
||||||
|
#if defined(__wasm__) && defined(__wasm_simd128__)
|
||||||
|
glmm_store(dest, wasm_f32x4_sub(
|
||||||
|
glmm_load(dest),
|
||||||
|
wasm_f32x4_sub(glmm_load(a), glmm_load(b))));
|
||||||
|
#elif defined( __SSE__ ) || defined( __SSE2__ )
|
||||||
|
glmm_store(dest, _mm_sub_ps(glmm_load(dest),
|
||||||
|
_mm_sub_ps(glmm_load(a),
|
||||||
|
glmm_load(b))));
|
||||||
|
#elif defined(CGLM_NEON_FP)
|
||||||
|
vst1q_f32(dest, vsubq_f32(vld1q_f32(dest),
|
||||||
|
vsubq_f32(vld1q_f32(a),
|
||||||
|
vld1q_f32(b))));
|
||||||
|
#else
|
||||||
|
dest[0] -= a[0] - b[0];
|
||||||
|
dest[1] -= a[1] - b[1];
|
||||||
|
dest[2] -= a[2] - b[2];
|
||||||
|
dest[3] -= a[3] - b[3];
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @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_vec4_addsub(vec4 a, vec4 b, vec4 dest) {
|
||||||
|
#if defined(__wasm__) && defined(__wasm_simd128__)
|
||||||
|
glmm_store(dest, wasm_f32x4_sub(
|
||||||
|
glmm_load(dest),
|
||||||
|
wasm_f32x4_add(glmm_load(a), glmm_load(b))));
|
||||||
|
#elif defined( __SSE__ ) || defined( __SSE2__ )
|
||||||
|
glmm_store(dest, _mm_sub_ps(glmm_load(dest),
|
||||||
|
_mm_add_ps(glmm_load(a),
|
||||||
|
glmm_load(b))));
|
||||||
|
#elif defined(CGLM_NEON_FP)
|
||||||
|
vst1q_f32(dest, vsubq_f32(vld1q_f32(dest),
|
||||||
|
vaddq_f32(vld1q_f32(a),
|
||||||
|
vld1q_f32(b))));
|
||||||
|
#else
|
||||||
|
dest[0] -= a[0] + b[0];
|
||||||
|
dest[1] -= a[1] + b[1];
|
||||||
|
dest[2] -= a[2] + b[2];
|
||||||
|
dest[3] -= a[3] + b[3];
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @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_vec4_mulsub(vec4 a, vec4 b, vec4 dest) {
|
||||||
|
#if defined(CGLM_SIMD)
|
||||||
|
glmm_store(dest, glmm_fnmadd(glmm_load(a), glmm_load(b), glmm_load(dest)));
|
||||||
|
#else
|
||||||
|
dest[0] -= a[0] * b[0];
|
||||||
|
dest[1] -= a[1] * b[1];
|
||||||
|
dest[2] -= a[2] * b[2];
|
||||||
|
dest[3] -= a[3] * b[3];
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @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_vec4_mulsubs(vec4 a, float s, vec4 dest) {
|
||||||
|
#if defined(CGLM_SIMD)
|
||||||
|
glmm_store(dest, glmm_fnmadd(glmm_load(a), glmm_set1(s), glmm_load(dest)));
|
||||||
|
#else
|
||||||
|
dest[0] -= a[0] * s;
|
||||||
|
dest[1] -= a[1] * s;
|
||||||
|
dest[2] -= a[2] * s;
|
||||||
|
dest[3] -= a[3] * s;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @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
|
||||||
|
* @param[out] dest dest -= max(a, b)
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
void
|
||||||
|
glm_vec4_maxsub(vec4 a, vec4 b, vec4 dest) {
|
||||||
|
#if defined(__wasm__) && defined(__wasm_simd128__)
|
||||||
|
glmm_store(dest, wasm_f32x4_sub(
|
||||||
|
glmm_load(dest),
|
||||||
|
wasm_f32x4_pmax(glmm_load(a), glmm_load(b))));
|
||||||
|
#elif defined( __SSE__ ) || defined( __SSE2__ )
|
||||||
|
glmm_store(dest, _mm_sub_ps(glmm_load(dest),
|
||||||
|
_mm_max_ps(glmm_load(a),
|
||||||
|
glmm_load(b))));
|
||||||
|
#elif defined(CGLM_NEON_FP)
|
||||||
|
vst1q_f32(dest, vsubq_f32(vld1q_f32(dest),
|
||||||
|
vmaxq_f32(vld1q_f32(a),
|
||||||
|
vld1q_f32(b))));
|
||||||
|
#else
|
||||||
|
dest[0] -= glm_max(a[0], b[0]);
|
||||||
|
dest[1] -= glm_max(a[1], b[1]);
|
||||||
|
dest[2] -= glm_max(a[2], b[2]);
|
||||||
|
dest[3] -= glm_max(a[3], b[3]);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @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
|
||||||
|
* @param[out] dest dest -= min(a, b)
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
void
|
||||||
|
glm_vec4_minsub(vec4 a, vec4 b, vec4 dest) {
|
||||||
|
#if defined(__wasm__) && defined(__wasm_simd128__)
|
||||||
|
glmm_store(dest, wasm_f32x4_sub(
|
||||||
|
glmm_load(dest),
|
||||||
|
wasm_f32x4_pmin(glmm_load(a), glmm_load(b))));
|
||||||
|
#elif defined( __SSE__ ) || defined( __SSE2__ )
|
||||||
|
glmm_store(dest, _mm_sub_ps(glmm_load(dest),
|
||||||
|
_mm_min_ps(glmm_load(a),
|
||||||
|
glmm_load(b))));
|
||||||
|
#elif defined(CGLM_NEON_FP)
|
||||||
|
vst1q_f32(dest, vsubq_f32(vld1q_f32(dest),
|
||||||
|
vminq_f32(vld1q_f32(a),
|
||||||
|
vld1q_f32(b))));
|
||||||
|
#else
|
||||||
|
dest[0] -= glm_min(a[0], b[0]);
|
||||||
|
dest[1] -= glm_min(a[1], b[1]);
|
||||||
|
dest[2] -= glm_min(a[2], b[2]);
|
||||||
|
dest[3] -= glm_min(a[3], b[3]);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief negate vector components and store result in dest
|
* @brief negate vector components and store result in dest
|
||||||
*
|
*
|
||||||
@@ -854,7 +1032,7 @@ CGLM_INLINE
|
|||||||
void
|
void
|
||||||
glm_vec4_maxv(vec4 a, vec4 b, vec4 dest) {
|
glm_vec4_maxv(vec4 a, vec4 b, vec4 dest) {
|
||||||
#if defined(__wasm__) && defined(__wasm_simd128__)
|
#if defined(__wasm__) && defined(__wasm_simd128__)
|
||||||
glmm_store(dest, wasm_f32x4_max(glmm_load(a), glmm_load(b)));
|
glmm_store(dest, wasm_f32x4_pmax(glmm_load(a), glmm_load(b)));
|
||||||
#elif defined( __SSE__ ) || defined( __SSE2__ )
|
#elif defined( __SSE__ ) || defined( __SSE2__ )
|
||||||
glmm_store(dest, _mm_max_ps(glmm_load(a), glmm_load(b)));
|
glmm_store(dest, _mm_max_ps(glmm_load(a), glmm_load(b)));
|
||||||
#elif defined(CGLM_NEON_FP)
|
#elif defined(CGLM_NEON_FP)
|
||||||
@@ -878,7 +1056,7 @@ CGLM_INLINE
|
|||||||
void
|
void
|
||||||
glm_vec4_minv(vec4 a, vec4 b, vec4 dest) {
|
glm_vec4_minv(vec4 a, vec4 b, vec4 dest) {
|
||||||
#if defined(__wasm__) && defined(__wasm_simd128__)
|
#if defined(__wasm__) && defined(__wasm_simd128__)
|
||||||
glmm_store(dest, wasm_f32x4_min(glmm_load(a), glmm_load(b)));
|
glmm_store(dest, wasm_f32x4_pmin(glmm_load(a), glmm_load(b)));
|
||||||
#elif defined( __SSE__ ) || defined( __SSE2__ )
|
#elif defined( __SSE__ ) || defined( __SSE2__ )
|
||||||
glmm_store(dest, _mm_min_ps(glmm_load(a), glmm_load(b)));
|
glmm_store(dest, _mm_min_ps(glmm_load(a), glmm_load(b)));
|
||||||
#elif defined(CGLM_NEON_FP)
|
#elif defined(CGLM_NEON_FP)
|
||||||
@@ -902,8 +1080,8 @@ CGLM_INLINE
|
|||||||
void
|
void
|
||||||
glm_vec4_clamp(vec4 v, float minVal, float maxVal) {
|
glm_vec4_clamp(vec4 v, float minVal, float maxVal) {
|
||||||
#if defined(__wasm__) && defined(__wasm_simd128__)
|
#if defined(__wasm__) && defined(__wasm_simd128__)
|
||||||
glmm_store(v, wasm_f32x4_min(
|
glmm_store(v, wasm_f32x4_pmin(
|
||||||
wasm_f32x4_max(glmm_load(v), wasm_f32x4_splat(minVal)),
|
wasm_f32x4_pmax(glmm_load(v), wasm_f32x4_splat(minVal)),
|
||||||
wasm_f32x4_splat(maxVal)));
|
wasm_f32x4_splat(maxVal)));
|
||||||
#elif defined( __SSE__ ) || defined( __SSE2__ )
|
#elif defined( __SSE__ ) || defined( __SSE2__ )
|
||||||
glmm_store(v, _mm_min_ps(_mm_max_ps(glmm_load(v), _mm_set1_ps(minVal)),
|
glmm_store(v, _mm_min_ps(_mm_max_ps(glmm_load(v), _mm_set1_ps(minVal)),
|
||||||
|
|||||||
@@ -10,6 +10,6 @@
|
|||||||
|
|
||||||
#define CGLM_VERSION_MAJOR 0
|
#define CGLM_VERSION_MAJOR 0
|
||||||
#define CGLM_VERSION_MINOR 9
|
#define CGLM_VERSION_MINOR 9
|
||||||
#define CGLM_VERSION_PATCH 1
|
#define CGLM_VERSION_PATCH 2
|
||||||
|
|
||||||
#endif /* cglm_version_h */
|
#endif /* cglm_version_h */
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
project('cglm', 'c',
|
project('cglm', 'c',
|
||||||
version : '0.9.1',
|
version : '0.9.2',
|
||||||
license : 'mit',
|
license : 'mit',
|
||||||
default_options : [
|
default_options : [
|
||||||
'c_std=c11',
|
'c_std=c11',
|
||||||
@@ -87,7 +87,8 @@ cglm_lib = library('cglm',
|
|||||||
dependencies : cglm_deps,
|
dependencies : cglm_deps,
|
||||||
c_args : [ build_args, cglm_args ],
|
c_args : [ build_args, cglm_args ],
|
||||||
version : meson.project_version(),
|
version : meson.project_version(),
|
||||||
soversion : '0'
|
soversion : '0',
|
||||||
|
build_by_default: not meson.is_subproject()
|
||||||
)
|
)
|
||||||
|
|
||||||
cglm_dep = declare_dependency(
|
cglm_dep = declare_dependency(
|
||||||
|
|||||||
96
src/aabb2d.c
Normal file
96
src/aabb2d.c
Normal file
@@ -0,0 +1,96 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c), Recep Aslantas.
|
||||||
|
*
|
||||||
|
* MIT License (MIT), http://opensource.org/licenses/MIT
|
||||||
|
* Full license can be found in the LICENSE file
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "../include/cglm/cglm.h"
|
||||||
|
#include "../include/cglm/call.h"
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_aabb2d_copy(vec2 aabb[2], vec2 dest[2]) {
|
||||||
|
glm_aabb2d_copy(aabb, dest);
|
||||||
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_aabb2d_transform(vec2 aabb[2], mat3 m, vec2 dest[2]) {
|
||||||
|
glm_aabb2d_transform(aabb, m, dest);
|
||||||
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_aabb2d_merge(vec2 aabb1[2], vec2 aabb2[2], vec2 dest[2]) {
|
||||||
|
glm_aabb2d_merge(aabb1, aabb2, dest);
|
||||||
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_aabb2d_crop(vec2 aabb[2], vec2 cropAabb[2], vec2 dest[2]) {
|
||||||
|
glm_aabb2d_crop(aabb, cropAabb, dest);
|
||||||
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_aabb2d_crop_until(vec2 aabb[2],
|
||||||
|
vec2 cropAabb[2],
|
||||||
|
vec2 clampAabb[2],
|
||||||
|
vec2 dest[2]) {
|
||||||
|
glm_aabb2d_crop_until(aabb, cropAabb, clampAabb, dest);
|
||||||
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_aabb2d_invalidate(vec2 aabb[2]) {
|
||||||
|
glm_aabb2d_invalidate(aabb);
|
||||||
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
bool
|
||||||
|
glmc_aabb2d_isvalid(vec2 aabb[2]) {
|
||||||
|
return glm_aabb2d_isvalid(aabb);
|
||||||
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
float
|
||||||
|
glmc_aabb2d_size(vec2 aabb[2]) {
|
||||||
|
return glm_aabb2d_size(aabb);
|
||||||
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
float
|
||||||
|
glmc_aabb2d_radius(vec2 aabb[2]) {
|
||||||
|
return glm_aabb2d_radius(aabb);
|
||||||
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_aabb2d_center(vec2 aabb[2], vec2 dest) {
|
||||||
|
glm_aabb2d_center(aabb, dest);
|
||||||
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
bool
|
||||||
|
glmc_aabb2d_aabb(vec2 aabb[2], vec2 other[2]) {
|
||||||
|
return glm_aabb2d_aabb(aabb, other);
|
||||||
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
bool
|
||||||
|
glmc_aabb2d_point(vec2 aabb[2], vec2 point) {
|
||||||
|
return glm_aabb2d_point(aabb, point);
|
||||||
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
bool
|
||||||
|
glmc_aabb2d_contains(vec2 aabb[2], vec2 other[2]) {
|
||||||
|
return glm_aabb2d_contains(aabb, other);
|
||||||
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
bool
|
||||||
|
glmc_aabb2d_circle(vec2 aabb[2], vec3 s) {
|
||||||
|
return glm_aabb2d_circle(aabb, s);
|
||||||
|
}
|
||||||
37
src/euler.c
37
src/euler.c
@@ -61,3 +61,40 @@ 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) {
|
||||||
glm_euler_by_order(angles, axis, dest);
|
glm_euler_by_order(angles, axis, dest);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_euler_xyz_quat(vec3 angles, versor dest) {
|
||||||
|
glm_euler_xyz_quat(angles, dest);
|
||||||
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_euler_xzy_quat(vec3 angles, versor dest) {
|
||||||
|
glm_euler_xzy_quat(angles, dest);
|
||||||
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_euler_yxz_quat(vec3 angles, versor dest) {
|
||||||
|
glm_euler_yxz_quat(angles, dest);
|
||||||
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_euler_yzx_quat(vec3 angles, versor dest) {
|
||||||
|
glm_euler_yzx_quat(angles, dest);
|
||||||
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_euler_zxy_quat(vec3 angles, versor dest) {
|
||||||
|
glm_euler_zxy_quat(angles, dest);
|
||||||
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_euler_zyx_quat(vec3 angles, versor dest) {
|
||||||
|
glm_euler_zyx_quat(angles, dest);
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
114
src/ivec2.c
114
src/ivec2.c
@@ -68,6 +68,102 @@ glmc_ivec2_scale(ivec2 v, int s, ivec2 dest) {
|
|||||||
glm_ivec2_scale(v, s, dest);
|
glm_ivec2_scale(v, s, dest);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_ivec2_addadd(ivec2 a, ivec2 b, ivec2 dest) {
|
||||||
|
glm_ivec2_addadd(a, b, dest);
|
||||||
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_ivec2_addadds(ivec2 a, int s, ivec2 dest) {
|
||||||
|
glm_ivec2_addadds(a, s, dest);
|
||||||
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_ivec2_subadd(ivec2 a, ivec2 b, ivec2 dest) {
|
||||||
|
glm_ivec2_subadd(a, b, dest);
|
||||||
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_ivec2_subadds(ivec2 a, int s, ivec2 dest) {
|
||||||
|
glm_ivec2_subadds(a, s, dest);
|
||||||
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_ivec2_muladd(ivec2 a, ivec2 b, ivec2 dest) {
|
||||||
|
glm_ivec2_muladd(a, b, dest);
|
||||||
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_ivec2_muladds(ivec2 a, int s, ivec2 dest) {
|
||||||
|
glm_ivec2_muladds(a, s, dest);
|
||||||
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_ivec2_maxadd(ivec2 a, ivec2 b, ivec2 dest) {
|
||||||
|
glm_ivec2_maxadd(a, b, dest);
|
||||||
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_ivec2_minadd(ivec2 a, ivec2 b, ivec2 dest) {
|
||||||
|
glm_ivec2_minadd(a, b, dest);
|
||||||
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_ivec2_subsub(ivec2 a, ivec2 b, ivec2 dest) {
|
||||||
|
glm_ivec2_subsub(a, b, dest);
|
||||||
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_ivec2_subsubs(ivec2 a, int s, ivec2 dest) {
|
||||||
|
glm_ivec2_subsubs(a, s, dest);
|
||||||
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_ivec2_addsub(ivec2 a, ivec2 b, ivec2 dest) {
|
||||||
|
glm_ivec2_addsub(a, b, dest);
|
||||||
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_ivec2_addsubs(ivec2 a, int s, ivec2 dest) {
|
||||||
|
glm_ivec2_addsubs(a, s, dest);
|
||||||
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_ivec2_mulsub(ivec2 a, ivec2 b, ivec2 dest) {
|
||||||
|
glm_ivec2_mulsub(a, b, dest);
|
||||||
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_ivec2_mulsubs(ivec2 a, int s, ivec2 dest) {
|
||||||
|
glm_ivec2_mulsubs(a, s, dest);
|
||||||
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_ivec2_maxsub(ivec2 a, ivec2 b, ivec2 dest) {
|
||||||
|
glm_ivec2_maxsub(a, b, dest);
|
||||||
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_ivec2_minsub(ivec2 a, ivec2 b, ivec2 dest) {
|
||||||
|
glm_ivec2_minsub(a, b, dest);
|
||||||
|
}
|
||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
int
|
int
|
||||||
glmc_ivec2_distance2(ivec2 a, ivec2 b) {
|
glmc_ivec2_distance2(ivec2 a, ivec2 b) {
|
||||||
@@ -80,6 +176,24 @@ glmc_ivec2_distance(ivec2 a, ivec2 b) {
|
|||||||
return glm_ivec2_distance(a, b);
|
return glm_ivec2_distance(a, b);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_ivec2_fill(ivec2 v, int val) {
|
||||||
|
glm_ivec2_fill(v, val);
|
||||||
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
bool
|
||||||
|
glmc_ivec2_eq(ivec2 v, int val) {
|
||||||
|
return glm_ivec2_eq(v, val);
|
||||||
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
bool
|
||||||
|
glmc_ivec2_eqv(ivec2 a, ivec2 b) {
|
||||||
|
return glm_ivec2_eqv(a, 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) {
|
||||||
|
|||||||
114
src/ivec3.c
114
src/ivec3.c
@@ -68,6 +68,102 @@ glmc_ivec3_scale(ivec3 v, int s, ivec3 dest) {
|
|||||||
glm_ivec3_scale(v, s, dest);
|
glm_ivec3_scale(v, s, dest);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_ivec3_addadd(ivec3 a, ivec3 b, ivec3 dest) {
|
||||||
|
glm_ivec3_addadd(a, b, dest);
|
||||||
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_ivec3_addadds(ivec3 a, int s, ivec3 dest) {
|
||||||
|
glm_ivec3_addadds(a, s, dest);
|
||||||
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_ivec3_subadd(ivec3 a, ivec3 b, ivec3 dest) {
|
||||||
|
glm_ivec3_subadd(a, b, dest);
|
||||||
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_ivec3_subadds(ivec3 a, int s, ivec3 dest) {
|
||||||
|
glm_ivec3_subadds(a, s, dest);
|
||||||
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_ivec3_muladd(ivec3 a, ivec3 b, ivec3 dest) {
|
||||||
|
glm_ivec3_muladd(a, b, dest);
|
||||||
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_ivec3_muladds(ivec3 a, int s, ivec3 dest) {
|
||||||
|
glm_ivec3_muladds(a, s, dest);
|
||||||
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_ivec3_maxadd(ivec3 a, ivec3 b, ivec3 dest) {
|
||||||
|
glm_ivec3_maxadd(a, b, dest);
|
||||||
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_ivec3_minadd(ivec3 a, ivec3 b, ivec3 dest) {
|
||||||
|
glm_ivec3_minadd(a, b, dest);
|
||||||
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_ivec3_subsub(ivec3 a, ivec3 b, ivec3 dest) {
|
||||||
|
glm_ivec3_subsub(a, b, dest);
|
||||||
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_ivec3_subsubs(ivec3 a, int s, ivec3 dest) {
|
||||||
|
glm_ivec3_subsubs(a, s, dest);
|
||||||
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_ivec3_addsub(ivec3 a, ivec3 b, ivec3 dest) {
|
||||||
|
glm_ivec3_addsub(a, b, dest);
|
||||||
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_ivec3_addsubs(ivec3 a, int s, ivec3 dest) {
|
||||||
|
glm_ivec3_addsubs(a, s, dest);
|
||||||
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_ivec3_mulsub(ivec3 a, ivec3 b, ivec3 dest) {
|
||||||
|
glm_ivec3_mulsub(a, b, dest);
|
||||||
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_ivec3_mulsubs(ivec3 a, int s, ivec3 dest) {
|
||||||
|
glm_ivec3_mulsubs(a, s, dest);
|
||||||
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_ivec3_maxsub(ivec3 a, ivec3 b, ivec3 dest) {
|
||||||
|
glm_ivec3_maxsub(a, b, dest);
|
||||||
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_ivec3_minsub(ivec3 a, ivec3 b, ivec3 dest) {
|
||||||
|
glm_ivec3_minsub(a, b, dest);
|
||||||
|
}
|
||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
int
|
int
|
||||||
glmc_ivec3_distance2(ivec3 a, ivec3 b) {
|
glmc_ivec3_distance2(ivec3 a, ivec3 b) {
|
||||||
@@ -80,6 +176,24 @@ glmc_ivec3_distance(ivec3 a, ivec3 b) {
|
|||||||
return glm_ivec3_distance(a, b);
|
return glm_ivec3_distance(a, b);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_ivec3_fill(ivec3 v, int val) {
|
||||||
|
glm_ivec3_fill(v, val);
|
||||||
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
bool
|
||||||
|
glmc_ivec3_eq(ivec3 v, int val) {
|
||||||
|
return glm_ivec3_eq(v, val);
|
||||||
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
bool
|
||||||
|
glmc_ivec3_eqv(ivec3 a, ivec3 b) {
|
||||||
|
return glm_ivec3_eqv(a, 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) {
|
||||||
|
|||||||
96
src/ivec4.c
96
src/ivec4.c
@@ -68,6 +68,102 @@ glmc_ivec4_scale(ivec4 v, int s, ivec4 dest) {
|
|||||||
glm_ivec4_scale(v, s, dest);
|
glm_ivec4_scale(v, s, dest);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_ivec4_addadd(ivec4 a, ivec4 b, ivec4 dest) {
|
||||||
|
glm_ivec4_addadd(a, b, dest);
|
||||||
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_ivec4_addadds(ivec4 a, int s, ivec4 dest) {
|
||||||
|
glm_ivec4_addadds(a, s, dest);
|
||||||
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_ivec4_subadd(ivec4 a, ivec4 b, ivec4 dest) {
|
||||||
|
glm_ivec4_subadd(a, b, dest);
|
||||||
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_ivec4_subadds(ivec4 a, int s, ivec4 dest) {
|
||||||
|
glm_ivec4_subadds(a, s, dest);
|
||||||
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_ivec4_muladd(ivec4 a, ivec4 b, ivec4 dest) {
|
||||||
|
glm_ivec4_muladd(a, b, dest);
|
||||||
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_ivec4_muladds(ivec4 a, int s, ivec4 dest) {
|
||||||
|
glm_ivec4_muladds(a, s, dest);
|
||||||
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_ivec4_maxadd(ivec4 a, ivec4 b, ivec4 dest) {
|
||||||
|
glm_ivec4_maxadd(a, b, dest);
|
||||||
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_ivec4_minadd(ivec4 a, ivec4 b, ivec4 dest) {
|
||||||
|
glm_ivec4_minadd(a, b, dest);
|
||||||
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_ivec4_subsub(ivec4 a, ivec4 b, ivec4 dest) {
|
||||||
|
glm_ivec4_subsub(a, b, dest);
|
||||||
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_ivec4_subsubs(ivec4 a, int s, ivec4 dest) {
|
||||||
|
glm_ivec4_subsubs(a, s, dest);
|
||||||
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_ivec4_addsub(ivec4 a, ivec4 b, ivec4 dest) {
|
||||||
|
glm_ivec4_addsub(a, b, dest);
|
||||||
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_ivec4_addsubs(ivec4 a, int s, ivec4 dest) {
|
||||||
|
glm_ivec4_addsubs(a, s, dest);
|
||||||
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_ivec4_mulsub(ivec4 a, ivec4 b, ivec4 dest) {
|
||||||
|
glm_ivec4_mulsub(a, b, dest);
|
||||||
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_ivec4_mulsubs(ivec4 a, int s, ivec4 dest) {
|
||||||
|
glm_ivec4_mulsubs(a, s, dest);
|
||||||
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_ivec4_maxsub(ivec4 a, ivec4 b, ivec4 dest) {
|
||||||
|
glm_ivec4_maxsub(a, b, dest);
|
||||||
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_ivec4_minsub(ivec4 a, ivec4 b, ivec4 dest) {
|
||||||
|
glm_ivec4_minsub(a, b, dest);
|
||||||
|
}
|
||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
int
|
int
|
||||||
glmc_ivec4_distance2(ivec4 a, ivec4 b) {
|
glmc_ivec4_distance2(ivec4 a, ivec4 b) {
|
||||||
|
|||||||
61
src/vec2.c
61
src/vec2.c
@@ -14,6 +14,24 @@ glmc_vec2(float * __restrict v, vec2 dest) {
|
|||||||
glm_vec2(v, dest);
|
glm_vec2(v, dest);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_vec2_fill(vec2 v, float val) {
|
||||||
|
glm_vec2_fill(v, val);
|
||||||
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
bool
|
||||||
|
glmc_vec2_eq(vec2 v, float val) {
|
||||||
|
return glm_vec2_eq(v, val);
|
||||||
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
bool
|
||||||
|
glmc_vec2_eqv(vec2 a, vec2 b) {
|
||||||
|
return glm_vec2_eqv(a, b);
|
||||||
|
}
|
||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
void
|
void
|
||||||
glmc_vec2_copy(vec2 a, vec2 dest) {
|
glmc_vec2_copy(vec2 a, vec2 dest) {
|
||||||
@@ -146,6 +164,43 @@ glmc_vec2_minadd(vec2 a, vec2 b, vec2 dest) {
|
|||||||
glm_vec2_minadd(a, b, dest);
|
glm_vec2_minadd(a, b, dest);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_vec2_subsub(vec2 a, vec2 b, vec2 dest) {
|
||||||
|
glm_vec2_subsub(a, b, dest);
|
||||||
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_vec2_addsub(vec2 a, vec2 b, vec2 dest) {
|
||||||
|
glm_vec2_addsub(a, b, dest);
|
||||||
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_vec2_mulsub(vec2 a, vec2 b, vec2 dest) {
|
||||||
|
glm_vec2_mulsub(a, b, dest);
|
||||||
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_vec2_mulsubs(vec2 a, float s, vec2 dest) {
|
||||||
|
glm_vec2_mulsubs(a, s, dest);
|
||||||
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_vec2_maxsub(vec2 a, vec2 b, vec2 dest) {
|
||||||
|
glm_vec2_maxsub(a, b, dest);
|
||||||
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_vec2_minsub(vec2 a, vec2 b, vec2 dest) {
|
||||||
|
glm_vec2_minsub(a, b, dest);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
void
|
void
|
||||||
glmc_vec2_negate_to(vec2 v, vec2 dest) {
|
glmc_vec2_negate_to(vec2 v, vec2 dest) {
|
||||||
@@ -176,6 +231,12 @@ glmc_vec2_rotate(vec2 v, float angle, vec2 dest) {
|
|||||||
glm_vec2_rotate(v, angle, dest);
|
glm_vec2_rotate(v, angle, dest);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_vec2_center(vec2 a, vec2 b, vec2 dest) {
|
||||||
|
glm_vec2_center(a, b, dest);
|
||||||
|
}
|
||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
float
|
float
|
||||||
glmc_vec2_distance2(vec2 a, vec2 b) {
|
glmc_vec2_distance2(vec2 a, vec2 b) {
|
||||||
|
|||||||
36
src/vec3.c
36
src/vec3.c
@@ -176,6 +176,42 @@ glmc_vec3_minadd(vec3 a, vec3 b, vec3 dest) {
|
|||||||
glm_vec3_minadd(a, b, dest);
|
glm_vec3_minadd(a, b, dest);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_vec3_subsub(vec3 a, vec3 b, vec3 dest) {
|
||||||
|
glm_vec3_subsub(a, b, dest);
|
||||||
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_vec3_addsub(vec3 a, vec3 b, vec3 dest) {
|
||||||
|
glm_vec3_addsub(a, b, dest);
|
||||||
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_vec3_mulsub(vec3 a, vec3 b, vec3 dest) {
|
||||||
|
glm_vec3_mulsub(a, b, dest);
|
||||||
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_vec3_mulsubs(vec3 a, float s, vec3 dest) {
|
||||||
|
glm_vec3_mulsubs(a, s, dest);
|
||||||
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_vec3_maxsub(vec3 a, vec3 b, vec3 dest) {
|
||||||
|
glm_vec3_maxsub(a, b, dest);
|
||||||
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_vec3_minsub(vec3 a, vec3 b, vec3 dest) {
|
||||||
|
glm_vec3_minsub(a, b, dest);
|
||||||
|
}
|
||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
void
|
void
|
||||||
glmc_vec3_negate(vec3 v) {
|
glmc_vec3_negate(vec3 v) {
|
||||||
|
|||||||
36
src/vec4.c
36
src/vec4.c
@@ -176,6 +176,42 @@ glmc_vec4_minadd(vec4 a, vec4 b, vec4 dest) {
|
|||||||
glm_vec4_minadd(a, b, dest);
|
glm_vec4_minadd(a, b, dest);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_vec4_subsub(vec4 a, vec4 b, vec4 dest) {
|
||||||
|
glm_vec4_subsub(a, b, dest);
|
||||||
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_vec4_addsub(vec4 a, vec4 b, vec4 dest) {
|
||||||
|
glm_vec4_addsub(a, b, dest);
|
||||||
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_vec4_mulsub(vec4 a, vec4 b, vec4 dest) {
|
||||||
|
glm_vec4_mulsub(a, b, dest);
|
||||||
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_vec4_mulsubs(vec4 a, float s, vec4 dest) {
|
||||||
|
glm_vec4_mulsubs(a, s, dest);
|
||||||
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_vec4_maxsub(vec4 a, vec4 b, vec4 dest) {
|
||||||
|
glm_vec4_maxsub(a, b, dest);
|
||||||
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_vec4_minsub(vec4 a, vec4 b, vec4 dest) {
|
||||||
|
glm_vec4_minsub(a, b, dest);
|
||||||
|
}
|
||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
void
|
void
|
||||||
glmc_vec4_negate(vec4 v) {
|
glmc_vec4_negate(vec4 v) {
|
||||||
|
|||||||
495
test/src/test_euler_to_quat_lh.h
Normal file
495
test/src/test_euler_to_quat_lh.h
Normal file
@@ -0,0 +1,495 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c), Recep Aslantas.
|
||||||
|
*
|
||||||
|
* MIT License (MIT), http://opensource.org/licenses/MIT
|
||||||
|
* Full license can be found in the LICENSE file
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "test_common.h"
|
||||||
|
#include "../../include/cglm/handed/euler_to_quat_lh.h"
|
||||||
|
|
||||||
|
TEST_IMPL(GLM_PREFIX, euler_xyz_quat_lh) {
|
||||||
|
vec3 axis_x = {1.0f, 0.0f, 0.0f};
|
||||||
|
vec3 axis_y = {0.0f, 1.0f, 0.0f};
|
||||||
|
vec3 axis_z = {0.0f, 0.0f,-1.0f};
|
||||||
|
|
||||||
|
/* random angles for testing */
|
||||||
|
vec3 angles;
|
||||||
|
|
||||||
|
/* quaternion representations for rotations */
|
||||||
|
versor rot_x, rot_y, rot_z;
|
||||||
|
|
||||||
|
versor expected;
|
||||||
|
versor result;
|
||||||
|
versor tmp;
|
||||||
|
|
||||||
|
/* 100 randomized tests */
|
||||||
|
for (int i = 0; i < 100; i++) {
|
||||||
|
test_rand_vec3(angles);
|
||||||
|
|
||||||
|
/* create the rotation quaternions using the angles and axises */
|
||||||
|
glm_quatv(rot_x, angles[0], axis_x);
|
||||||
|
glm_quatv(rot_y, angles[1], axis_y);
|
||||||
|
glm_quatv(rot_z, angles[2], axis_z);
|
||||||
|
|
||||||
|
/* apply the rotations to a unit quaternion in xyz order */
|
||||||
|
glm_quat_identity(expected);
|
||||||
|
|
||||||
|
glm_quat_copy(expected, tmp);
|
||||||
|
glm_quat_mul(tmp, rot_x, expected);
|
||||||
|
glm_quat_copy(expected, tmp);
|
||||||
|
glm_quat_mul(tmp, rot_y, expected);
|
||||||
|
glm_quat_copy(expected, tmp);
|
||||||
|
glm_quat_mul(tmp, rot_z, expected);
|
||||||
|
|
||||||
|
glm_euler_xyz_quat_lh(angles, result);
|
||||||
|
|
||||||
|
/* verify if the magnitude of the quaternion stays 1 */
|
||||||
|
ASSERT(test_eq(glm_quat_norm(result), 1.0f))
|
||||||
|
|
||||||
|
/* verify that it acts the same as rotating by 3 axis quaternions */
|
||||||
|
ASSERTIFY(test_assert_quat_eq(result, expected))
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Start gimbal lock tests */
|
||||||
|
for (float x = -90.0f; x <= 90.0f; x += 90.0f) {
|
||||||
|
for (float y = -90.0f; y <= 90.0f; y += 90.0f) {
|
||||||
|
for (float z = -90.0f; z <= 90.0f; z += 90.0f) {
|
||||||
|
angles[0] = x;
|
||||||
|
angles[1] = y;
|
||||||
|
angles[2] = z;
|
||||||
|
|
||||||
|
/* create the rotation quaternions using the angles and axises */
|
||||||
|
glm_quatv(rot_x, angles[0], axis_x);
|
||||||
|
glm_quatv(rot_y, angles[1], axis_y);
|
||||||
|
glm_quatv(rot_z, angles[2], axis_z);
|
||||||
|
|
||||||
|
/* apply the rotations to a unit quaternion in xyz order */
|
||||||
|
glm_quat_identity(expected);
|
||||||
|
|
||||||
|
glm_quat_copy(expected, tmp);
|
||||||
|
glm_quat_mul(tmp, rot_x, expected);
|
||||||
|
glm_quat_copy(expected, tmp);
|
||||||
|
glm_quat_mul(tmp, rot_y, expected);
|
||||||
|
glm_quat_copy(expected, tmp);
|
||||||
|
glm_quat_mul(tmp, rot_z, expected);
|
||||||
|
|
||||||
|
/* use my function to get the quaternion */
|
||||||
|
glm_euler_xyz_quat_lh(angles, result);
|
||||||
|
|
||||||
|
/* verify if the magnitude of the quaternion stays 1 */
|
||||||
|
ASSERT(test_eq(glm_quat_norm(result), 1.0f))
|
||||||
|
|
||||||
|
/* verify that it acts the same as rotating by 3 axis quaternions */
|
||||||
|
ASSERTIFY(test_assert_quat_eq(result, expected))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
TEST_SUCCESS
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_IMPL(GLM_PREFIX, euler_xzy_quat_lh) {
|
||||||
|
vec3 axis_x = {1.0f, 0.0f, 0.0f};
|
||||||
|
vec3 axis_y = {0.0f, 1.0f, 0.0f};
|
||||||
|
vec3 axis_z = {0.0f, 0.0f,-1.0f};
|
||||||
|
|
||||||
|
/* random angles for testing */
|
||||||
|
vec3 angles;
|
||||||
|
|
||||||
|
/* quaternion representations for rotations */
|
||||||
|
versor rot_x, rot_y, rot_z;
|
||||||
|
|
||||||
|
versor expected;
|
||||||
|
versor result;
|
||||||
|
versor tmp;
|
||||||
|
|
||||||
|
/* 100 randomized tests */
|
||||||
|
for (int i = 0; i < 100; i++) {
|
||||||
|
test_rand_vec3(angles);
|
||||||
|
|
||||||
|
/* create the rotation quaternions using the angles and axises */
|
||||||
|
glm_quatv(rot_x, angles[0], axis_x);
|
||||||
|
glm_quatv(rot_y, angles[1], axis_y);
|
||||||
|
glm_quatv(rot_z, angles[2], axis_z);
|
||||||
|
|
||||||
|
/* apply the rotations to a unit quaternion in xzy order */
|
||||||
|
glm_quat_identity(expected);
|
||||||
|
|
||||||
|
glm_quat_copy(expected, tmp);
|
||||||
|
glm_quat_mul(tmp, rot_x, expected);
|
||||||
|
glm_quat_copy(expected, tmp);
|
||||||
|
glm_quat_mul(tmp, rot_z, expected);
|
||||||
|
glm_quat_copy(expected, tmp);
|
||||||
|
glm_quat_mul(tmp, rot_y, expected);
|
||||||
|
|
||||||
|
glm_euler_xzy_quat_lh(angles, result);
|
||||||
|
|
||||||
|
/* verify if the magnitude of the quaternion stays 1 */
|
||||||
|
ASSERT(test_eq(glm_quat_norm(result), 1.0f))
|
||||||
|
|
||||||
|
/* verify that it acts the same as rotating by 3 axis quaternions */
|
||||||
|
ASSERTIFY(test_assert_quat_eq(result, expected))
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Start gimbal lock tests */
|
||||||
|
for (float x = -90.0f; x <= 90.0f; x += 90.0f) {
|
||||||
|
for (float y = -90.0f; y <= 90.0f; y += 90.0f) {
|
||||||
|
for (float z = -90.0f; z <= 90.0f; z += 90.0f) {
|
||||||
|
angles[0] = x;
|
||||||
|
angles[1] = y;
|
||||||
|
angles[2] = z;
|
||||||
|
|
||||||
|
/* create the rotation quaternions using the angles and axises */
|
||||||
|
glm_quatv(rot_x, angles[0], axis_x);
|
||||||
|
glm_quatv(rot_y, angles[1], axis_y);
|
||||||
|
glm_quatv(rot_z, angles[2], axis_z);
|
||||||
|
|
||||||
|
/* apply the rotations to a unit quaternion in xzy order */
|
||||||
|
glm_quat_identity(expected);
|
||||||
|
|
||||||
|
glm_quat_copy(expected, tmp);
|
||||||
|
glm_quat_mul(tmp, rot_x, expected);
|
||||||
|
glm_quat_copy(expected, tmp);
|
||||||
|
glm_quat_mul(tmp, rot_z, expected);
|
||||||
|
glm_quat_copy(expected, tmp);
|
||||||
|
glm_quat_mul(tmp, rot_y, expected);
|
||||||
|
|
||||||
|
/* use my function to get the quaternion */
|
||||||
|
glm_euler_xzy_quat_lh(angles, result);
|
||||||
|
|
||||||
|
/* verify if the magnitude of the quaternion stays 1 */
|
||||||
|
ASSERT(test_eq(glm_quat_norm(result), 1.0f))
|
||||||
|
|
||||||
|
/* verify that it acts the same as rotating by 3 axis quaternions */
|
||||||
|
ASSERTIFY(test_assert_quat_eq(result, expected))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
TEST_SUCCESS
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_IMPL(GLM_PREFIX, euler_yxz_quat_lh) {
|
||||||
|
vec3 axis_x = {1.0f, 0.0f, 0.0f};
|
||||||
|
vec3 axis_y = {0.0f, 1.0f, 0.0f};
|
||||||
|
vec3 axis_z = {0.0f, 0.0f,-1.0f};
|
||||||
|
|
||||||
|
/* random angles for testing */
|
||||||
|
vec3 angles;
|
||||||
|
|
||||||
|
/* quaternion representations for rotations */
|
||||||
|
versor rot_x, rot_y, rot_z;
|
||||||
|
|
||||||
|
versor expected;
|
||||||
|
versor result;
|
||||||
|
versor tmp;
|
||||||
|
|
||||||
|
/* 100 randomized tests */
|
||||||
|
for (int i = 0; i < 100; i++) {
|
||||||
|
test_rand_vec3(angles);
|
||||||
|
|
||||||
|
/* create the rotation quaternions using the angles and axises */
|
||||||
|
glm_quatv(rot_x, angles[0], axis_x);
|
||||||
|
glm_quatv(rot_y, angles[1], axis_y);
|
||||||
|
glm_quatv(rot_z, angles[2], axis_z);
|
||||||
|
|
||||||
|
/* apply the rotations to a unit quaternion in yxz order */
|
||||||
|
glm_quat_identity(expected);
|
||||||
|
|
||||||
|
glm_quat_copy(expected, tmp);
|
||||||
|
glm_quat_mul(tmp, rot_y, expected);
|
||||||
|
glm_quat_copy(expected, tmp);
|
||||||
|
glm_quat_mul(tmp, rot_x, expected);
|
||||||
|
glm_quat_copy(expected, tmp);
|
||||||
|
glm_quat_mul(tmp, rot_z, expected);
|
||||||
|
|
||||||
|
glm_euler_yxz_quat_lh(angles, result);
|
||||||
|
|
||||||
|
/* verify if the magnitude of the quaternion stays 1 */
|
||||||
|
ASSERT(test_eq(glm_quat_norm(result), 1.0f))
|
||||||
|
|
||||||
|
/* verify that it acts the same as rotating by 3 axis quaternions */
|
||||||
|
ASSERTIFY(test_assert_quat_eq(result, expected))
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Start gimbal lock tests */
|
||||||
|
for (float x = -90.0f; x <= 90.0f; x += 90.0f) {
|
||||||
|
for (float y = -90.0f; y <= 90.0f; y += 90.0f) {
|
||||||
|
for (float z = -90.0f; z <= 90.0f; z += 90.0f) {
|
||||||
|
angles[0] = x;
|
||||||
|
angles[1] = y;
|
||||||
|
angles[2] = z;
|
||||||
|
|
||||||
|
/* create the rotation quaternions using the angles and axises */
|
||||||
|
glm_quatv(rot_x, angles[0], axis_x);
|
||||||
|
glm_quatv(rot_y, angles[1], axis_y);
|
||||||
|
glm_quatv(rot_z, angles[2], axis_z);
|
||||||
|
|
||||||
|
/* apply the rotations to a unit quaternion in yxz order */
|
||||||
|
glm_quat_identity(expected);
|
||||||
|
|
||||||
|
glm_quat_copy(expected, tmp);
|
||||||
|
glm_quat_mul(tmp, rot_y, expected);
|
||||||
|
glm_quat_copy(expected, tmp);
|
||||||
|
glm_quat_mul(tmp, rot_x, expected);
|
||||||
|
glm_quat_copy(expected, tmp);
|
||||||
|
glm_quat_mul(tmp, rot_z, expected);
|
||||||
|
|
||||||
|
/* use my function to get the quaternion */
|
||||||
|
glm_euler_yxz_quat_lh(angles, result);
|
||||||
|
|
||||||
|
/* verify if the magnitude of the quaternion stays 1 */
|
||||||
|
ASSERT(test_eq(glm_quat_norm(result), 1.0f))
|
||||||
|
|
||||||
|
ASSERTIFY(test_assert_quat_eq(result, expected))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
TEST_SUCCESS
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_IMPL(GLM_PREFIX, euler_yzx_quat_lh) {
|
||||||
|
vec3 axis_x = {1.0f, 0.0f, 0.0f};
|
||||||
|
vec3 axis_y = {0.0f, 1.0f, 0.0f};
|
||||||
|
vec3 axis_z = {0.0f, 0.0f,-1.0f};
|
||||||
|
|
||||||
|
/* random angles for testing */
|
||||||
|
vec3 angles;
|
||||||
|
|
||||||
|
/* quaternion representations for rotations */
|
||||||
|
versor rot_x, rot_y, rot_z;
|
||||||
|
|
||||||
|
versor expected;
|
||||||
|
versor result;
|
||||||
|
versor tmp;
|
||||||
|
|
||||||
|
/* 100 randomized tests */
|
||||||
|
for (int i = 0; i < 100; i++) {
|
||||||
|
test_rand_vec3(angles);
|
||||||
|
|
||||||
|
/* create the rotation quaternions using the angles and axises */
|
||||||
|
glm_quatv(rot_x, angles[0], axis_x);
|
||||||
|
glm_quatv(rot_y, angles[1], axis_y);
|
||||||
|
glm_quatv(rot_z, angles[2], axis_z);
|
||||||
|
|
||||||
|
/* apply the rotations to a unit quaternion in yzx order */
|
||||||
|
glm_quat_identity(expected);
|
||||||
|
|
||||||
|
glm_quat_copy(expected, tmp);
|
||||||
|
glm_quat_mul(tmp, rot_y, expected);
|
||||||
|
glm_quat_copy(expected, tmp);
|
||||||
|
glm_quat_mul(tmp, rot_z, expected);
|
||||||
|
glm_quat_copy(expected, tmp);
|
||||||
|
glm_quat_mul(tmp, rot_x, expected);
|
||||||
|
|
||||||
|
glm_euler_yzx_quat_lh(angles, result);
|
||||||
|
|
||||||
|
/* verify if the magnitude of the quaternion stays 1 */
|
||||||
|
ASSERT(test_eq(glm_quat_norm(result), 1.0f))
|
||||||
|
|
||||||
|
/* verify that it acts the same as rotating by 3 axis quaternions */
|
||||||
|
ASSERTIFY(test_assert_quat_eq(result, expected))
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Start gimbal lock tests */
|
||||||
|
for (float x = -90.0f; x <= 90.0f; x += 90.0f) {
|
||||||
|
for (float y = -90.0f; y <= 90.0f; y += 90.0f) {
|
||||||
|
for (float z = -90.0f; z <= 90.0f; z += 90.0f) {
|
||||||
|
angles[0] = x;
|
||||||
|
angles[1] = y;
|
||||||
|
angles[2] = z;
|
||||||
|
|
||||||
|
/* create the rotation quaternions using the angles and axises */
|
||||||
|
glm_quatv(rot_x, angles[0], axis_x);
|
||||||
|
glm_quatv(rot_y, angles[1], axis_y);
|
||||||
|
glm_quatv(rot_z, angles[2], axis_z);
|
||||||
|
|
||||||
|
/* apply the rotations to a unit quaternion in yzx order */
|
||||||
|
glm_quat_identity(expected);
|
||||||
|
|
||||||
|
glm_quat_copy(expected, tmp);
|
||||||
|
glm_quat_mul(tmp, rot_y, expected);
|
||||||
|
glm_quat_copy(expected, tmp);
|
||||||
|
glm_quat_mul(tmp, rot_z, expected);
|
||||||
|
glm_quat_copy(expected, tmp);
|
||||||
|
glm_quat_mul(tmp, rot_x, expected);
|
||||||
|
|
||||||
|
/* use my function to get the quaternion */
|
||||||
|
glm_euler_yzx_quat_lh(angles, result);
|
||||||
|
|
||||||
|
/* verify if the magnitude of the quaternion stays 1 */
|
||||||
|
ASSERT(test_eq(glm_quat_norm(result), 1.0f))
|
||||||
|
|
||||||
|
ASSERTIFY(test_assert_quat_eq(result, expected))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
TEST_SUCCESS
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_IMPL(GLM_PREFIX, euler_zxy_quat_lh) {
|
||||||
|
vec3 axis_x = {1.0f, 0.0f, 0.0f};
|
||||||
|
vec3 axis_y = {0.0f, 1.0f, 0.0f};
|
||||||
|
vec3 axis_z = {0.0f, 0.0f,-1.0f};
|
||||||
|
|
||||||
|
/* random angles for testing */
|
||||||
|
vec3 angles;
|
||||||
|
|
||||||
|
/* quaternion representations for rotations */
|
||||||
|
versor rot_x, rot_y, rot_z;
|
||||||
|
|
||||||
|
versor expected;
|
||||||
|
versor result;
|
||||||
|
versor tmp;
|
||||||
|
|
||||||
|
/* 100 randomized tests */
|
||||||
|
for (int i = 0; i < 100; i++) {
|
||||||
|
test_rand_vec3(angles);
|
||||||
|
|
||||||
|
/* create the rotation quaternions using the angles and axises */
|
||||||
|
glm_quatv(rot_x, angles[0], axis_x);
|
||||||
|
glm_quatv(rot_y, angles[1], axis_y);
|
||||||
|
glm_quatv(rot_z, angles[2], axis_z);
|
||||||
|
|
||||||
|
/* apply the rotations to a unit quaternion in zxy order */
|
||||||
|
glm_quat_identity(expected);
|
||||||
|
|
||||||
|
glm_quat_copy(expected, tmp);
|
||||||
|
glm_quat_mul(tmp, rot_z, expected);
|
||||||
|
glm_quat_copy(expected, tmp);
|
||||||
|
glm_quat_mul(tmp, rot_x, expected);
|
||||||
|
glm_quat_copy(expected, tmp);
|
||||||
|
glm_quat_mul(tmp, rot_y, expected);
|
||||||
|
|
||||||
|
glm_euler_zxy_quat_lh(angles, result);
|
||||||
|
|
||||||
|
/* verify if the magnitude of the quaternion stays 1 */
|
||||||
|
ASSERT(test_eq(glm_quat_norm(result), 1.0f))
|
||||||
|
|
||||||
|
/* verify that it acts the same as rotating by 3 axis quaternions */
|
||||||
|
ASSERTIFY(test_assert_quat_eq(result, expected))
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Start gimbal lock tests */
|
||||||
|
for (float x = -90.0f; x <= 90.0f; x += 90.0f) {
|
||||||
|
for (float y = -90.0f; y <= 90.0f; y += 90.0f) {
|
||||||
|
for (float z = -90.0f; z <= 90.0f; z += 90.0f) {
|
||||||
|
angles[0] = x;
|
||||||
|
angles[1] = y;
|
||||||
|
angles[2] = z;
|
||||||
|
|
||||||
|
/* create the rotation quaternions using the angles and axises */
|
||||||
|
glm_quatv(rot_x, angles[0], axis_x);
|
||||||
|
glm_quatv(rot_y, angles[1], axis_y);
|
||||||
|
glm_quatv(rot_z, angles[2], axis_z);
|
||||||
|
|
||||||
|
/* apply the rotations to a unit quaternion in zxy order */
|
||||||
|
glm_quat_identity(expected);
|
||||||
|
|
||||||
|
glm_quat_copy(expected, tmp);
|
||||||
|
glm_quat_mul(tmp, rot_z, expected);
|
||||||
|
glm_quat_copy(expected, tmp);
|
||||||
|
glm_quat_mul(tmp, rot_x, expected);
|
||||||
|
glm_quat_copy(expected, tmp);
|
||||||
|
glm_quat_mul(tmp, rot_y, expected);
|
||||||
|
|
||||||
|
/* use my function to get the quaternion */
|
||||||
|
glm_euler_zxy_quat_lh(angles, result);
|
||||||
|
|
||||||
|
/* verify if the magnitude of the quaternion stays 1 */
|
||||||
|
ASSERT(test_eq(glm_quat_norm(result), 1.0f))
|
||||||
|
|
||||||
|
/* verify that it acts the same as rotating by 3 axis quaternions */
|
||||||
|
ASSERTIFY(test_assert_quat_eq(result, expected))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
TEST_SUCCESS
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_IMPL(GLM_PREFIX, euler_zyx_quat_lh) {
|
||||||
|
vec3 axis_x = {1.0f, 0.0f, 0.0f};
|
||||||
|
vec3 axis_y = {0.0f, 1.0f, 0.0f};
|
||||||
|
vec3 axis_z = {0.0f, 0.0f,-1.0f};
|
||||||
|
|
||||||
|
/* random angles for testing */
|
||||||
|
vec3 angles;
|
||||||
|
|
||||||
|
/* quaternion representations for rotations */
|
||||||
|
versor rot_x, rot_y, rot_z;
|
||||||
|
|
||||||
|
versor expected;
|
||||||
|
versor result;
|
||||||
|
versor tmp;
|
||||||
|
|
||||||
|
/* 100 randomized tests */
|
||||||
|
for (int i = 0; i < 100; i++) {
|
||||||
|
test_rand_vec3(angles);
|
||||||
|
|
||||||
|
/* create the rotation quaternions using the angles and axises */
|
||||||
|
glm_quatv(rot_x, angles[0], axis_x);
|
||||||
|
glm_quatv(rot_y, angles[1], axis_y);
|
||||||
|
glm_quatv(rot_z, angles[2], axis_z);
|
||||||
|
|
||||||
|
/* apply the rotations to a unit quaternion in zyx order */
|
||||||
|
glm_quat_identity(expected);
|
||||||
|
|
||||||
|
glm_quat_copy(expected, tmp);
|
||||||
|
glm_quat_mul(tmp, rot_z, expected);
|
||||||
|
glm_quat_copy(expected, tmp);
|
||||||
|
glm_quat_mul(tmp, rot_y, expected);
|
||||||
|
glm_quat_copy(expected, tmp);
|
||||||
|
glm_quat_mul(tmp, rot_x, expected);
|
||||||
|
|
||||||
|
glm_euler_zyx_quat_lh(angles, result);
|
||||||
|
|
||||||
|
/* verify if the magnitude of the quaternion stays 1 */
|
||||||
|
ASSERT(test_eq(glm_quat_norm(result), 1.0f))
|
||||||
|
|
||||||
|
/* verify that it acts the same as rotating by 3 axis quaternions */
|
||||||
|
ASSERTIFY(test_assert_quat_eq(result, expected))
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Start gimbal lock tests */
|
||||||
|
for (float x = -90.0f; x <= 90.0f; x += 90.0f) {
|
||||||
|
for (float y = -90.0f; y <= 90.0f; y += 90.0f) {
|
||||||
|
for (float z = -90.0f; z <= 90.0f; z += 90.0f) {
|
||||||
|
angles[0] = x;
|
||||||
|
angles[1] = y;
|
||||||
|
angles[2] = z;
|
||||||
|
|
||||||
|
/* create the rotation quaternions using the angles and axises */
|
||||||
|
glm_quatv(rot_x, angles[0], axis_x);
|
||||||
|
glm_quatv(rot_y, angles[1], axis_y);
|
||||||
|
glm_quatv(rot_z, angles[2], axis_z);
|
||||||
|
|
||||||
|
/* apply the rotations to a unit quaternion in xyz order */
|
||||||
|
glm_quat_identity(expected);
|
||||||
|
|
||||||
|
glm_quat_copy(expected, tmp);
|
||||||
|
glm_quat_mul(tmp, rot_z, expected);
|
||||||
|
glm_quat_copy(expected, tmp);
|
||||||
|
glm_quat_mul(tmp, rot_y, expected);
|
||||||
|
glm_quat_copy(expected, tmp);
|
||||||
|
glm_quat_mul(tmp, rot_x, expected);
|
||||||
|
|
||||||
|
/* use my function to get the quaternion */
|
||||||
|
glm_euler_zyx_quat_lh(angles, result);
|
||||||
|
|
||||||
|
/* verify if the magnitude of the quaternion stays 1 */
|
||||||
|
ASSERT(test_eq(glm_quat_norm(result), 1.0f))
|
||||||
|
|
||||||
|
/* verify that it acts the same as rotating by 3 axis quaternions */
|
||||||
|
ASSERTIFY(test_assert_quat_eq(result, expected))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
TEST_SUCCESS
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
575
test/src/test_euler_to_quat_rh.h
Normal file
575
test/src/test_euler_to_quat_rh.h
Normal file
@@ -0,0 +1,575 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c), Recep Aslantas.
|
||||||
|
*
|
||||||
|
* MIT License (MIT), http://opensource.org/licenses/MIT
|
||||||
|
* Full license can be found in the LICENSE file
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "test_common.h"
|
||||||
|
#include "../../include/cglm/handed/euler_to_quat_rh.h"
|
||||||
|
|
||||||
|
TEST_IMPL(GLM_PREFIX, euler_xyz_quat_rh) {
|
||||||
|
vec3 axis_x = {1.0f, 0.0f, 0.0f};
|
||||||
|
vec3 axis_y = {0.0f, 1.0f, 0.0f};
|
||||||
|
vec3 axis_z = {0.0f, 0.0f, 1.0f};
|
||||||
|
|
||||||
|
/* random angles for testing */
|
||||||
|
vec3 angles;
|
||||||
|
|
||||||
|
/* quaternion representations for rotations */
|
||||||
|
versor rot_x, rot_y, rot_z;
|
||||||
|
|
||||||
|
versor expected;
|
||||||
|
versor result;
|
||||||
|
versor tmp;
|
||||||
|
|
||||||
|
mat4 expected_mat4;
|
||||||
|
|
||||||
|
/* 100 randomized tests */
|
||||||
|
for (int i = 0; i < 100; i++) {
|
||||||
|
test_rand_vec3(angles);
|
||||||
|
|
||||||
|
/* create the rotation quaternions using the angles and axises */
|
||||||
|
glm_quatv(rot_x, angles[0], axis_x);
|
||||||
|
glm_quatv(rot_y, angles[1], axis_y);
|
||||||
|
glm_quatv(rot_z, angles[2], axis_z);
|
||||||
|
|
||||||
|
/* apply the rotations to a unit quaternion in xyz order */
|
||||||
|
glm_quat_identity(expected);
|
||||||
|
|
||||||
|
glm_quat_copy(expected, tmp);
|
||||||
|
glm_quat_mul(tmp, rot_x, expected);
|
||||||
|
glm_quat_copy(expected, tmp);
|
||||||
|
glm_quat_mul(tmp, rot_y, expected);
|
||||||
|
glm_quat_copy(expected, tmp);
|
||||||
|
glm_quat_mul(tmp, rot_z, expected);
|
||||||
|
|
||||||
|
glm_euler_xyz_quat_rh(angles, result);
|
||||||
|
|
||||||
|
/* verify if the magnitude of the quaternion stays 1 */
|
||||||
|
ASSERT(test_eq(glm_quat_norm(result), 1.0f))
|
||||||
|
|
||||||
|
/* verify that it acts the same as rotating by 3 axis quaternions */
|
||||||
|
ASSERTIFY(test_assert_quat_eq(result, expected))
|
||||||
|
|
||||||
|
/* verify that it acts the same as glm_euler_by_order */
|
||||||
|
glm_euler_by_order(angles, GLM_EULER_XYZ, expected_mat4);
|
||||||
|
glm_mat4_quat(expected_mat4, expected);
|
||||||
|
|
||||||
|
ASSERTIFY(test_assert_quat_eq_abs(result, expected));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Start gimbal lock tests */
|
||||||
|
for (float x = -90.0f; x <= 90.0f; x += 90.0f) {
|
||||||
|
for (float y = -90.0f; y <= 90.0f; y += 90.0f) {
|
||||||
|
for (float z = -90.0f; z <= 90.0f; z += 90.0f) {
|
||||||
|
angles[0] = x;
|
||||||
|
angles[1] = y;
|
||||||
|
angles[2] = z;
|
||||||
|
|
||||||
|
/* create the rotation quaternions using the angles and axises */
|
||||||
|
glm_quatv(rot_x, angles[0], axis_x);
|
||||||
|
glm_quatv(rot_y, angles[1], axis_y);
|
||||||
|
glm_quatv(rot_z, angles[2], axis_z);
|
||||||
|
|
||||||
|
/* apply the rotations to a unit quaternion in xyz order */
|
||||||
|
glm_quat_identity(expected);
|
||||||
|
|
||||||
|
glm_quat_copy(expected, tmp);
|
||||||
|
glm_quat_mul(tmp, rot_x, expected);
|
||||||
|
glm_quat_copy(expected, tmp);
|
||||||
|
glm_quat_mul(tmp, rot_y, expected);
|
||||||
|
glm_quat_copy(expected, tmp);
|
||||||
|
glm_quat_mul(tmp, rot_z, expected);
|
||||||
|
|
||||||
|
/* use my function to get the quaternion */
|
||||||
|
glm_euler_xyz_quat_rh(angles, result);
|
||||||
|
|
||||||
|
/* verify if the magnitude of the quaternion stays 1 */
|
||||||
|
ASSERT(test_eq(glm_quat_norm(result), 1.0f))
|
||||||
|
|
||||||
|
ASSERTIFY(test_assert_quat_eq(result, expected))
|
||||||
|
|
||||||
|
/* verify that it acts the same as glm_euler_by_order */
|
||||||
|
glm_euler_by_order(angles, GLM_EULER_XYZ, expected_mat4);
|
||||||
|
glm_mat4_quat(expected_mat4, expected);
|
||||||
|
|
||||||
|
ASSERTIFY(test_assert_quat_eq_abs(result, expected));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
TEST_SUCCESS
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_IMPL(GLM_PREFIX, euler_xzy_quat_rh) {
|
||||||
|
vec3 axis_x = {1.0f, 0.0f, 0.0f};
|
||||||
|
vec3 axis_y = {0.0f, 1.0f, 0.0f};
|
||||||
|
vec3 axis_z = {0.0f, 0.0f, 1.0f};
|
||||||
|
|
||||||
|
/* random angles for testing */
|
||||||
|
vec3 angles;
|
||||||
|
|
||||||
|
/* quaternion representations for rotations */
|
||||||
|
versor rot_x, rot_y, rot_z;
|
||||||
|
|
||||||
|
versor expected;
|
||||||
|
versor result;
|
||||||
|
versor tmp;
|
||||||
|
|
||||||
|
mat4 expected_mat4;
|
||||||
|
|
||||||
|
/* 100 randomized tests */
|
||||||
|
for (int i = 0; i < 100; i++) {
|
||||||
|
test_rand_vec3(angles);
|
||||||
|
|
||||||
|
/* create the rotation quaternions using the angles and axises */
|
||||||
|
glm_quatv(rot_x, angles[0], axis_x);
|
||||||
|
glm_quatv(rot_y, angles[1], axis_y);
|
||||||
|
glm_quatv(rot_z, angles[2], axis_z);
|
||||||
|
|
||||||
|
/* apply the rotations to a unit quaternion in xzy order */
|
||||||
|
glm_quat_identity(expected);
|
||||||
|
|
||||||
|
glm_quat_copy(expected, tmp);
|
||||||
|
glm_quat_mul(tmp, rot_x, expected);
|
||||||
|
glm_quat_copy(expected, tmp);
|
||||||
|
glm_quat_mul(tmp, rot_z, expected);
|
||||||
|
glm_quat_copy(expected, tmp);
|
||||||
|
glm_quat_mul(tmp, rot_y, expected);
|
||||||
|
|
||||||
|
glm_euler_xzy_quat_rh(angles, result);
|
||||||
|
|
||||||
|
/* verify if the magnitude of the quaternion stays 1 */
|
||||||
|
ASSERT(test_eq(glm_quat_norm(result), 1.0f))
|
||||||
|
|
||||||
|
/* verify that it acts the same as rotating by 3 axis quaternions */
|
||||||
|
ASSERTIFY(test_assert_quat_eq(result, expected))
|
||||||
|
|
||||||
|
/* verify that it acts the same as glm_euler_by_order */
|
||||||
|
glm_euler_by_order(angles, GLM_EULER_XZY, expected_mat4);
|
||||||
|
glm_mat4_quat(expected_mat4, expected);
|
||||||
|
|
||||||
|
ASSERTIFY(test_assert_quat_eq_abs(result, expected));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Start gimbal lock tests */
|
||||||
|
for (float x = -90.0f; x <= 90.0f; x += 90.0f) {
|
||||||
|
for (float y = -90.0f; y <= 90.0f; y += 90.0f) {
|
||||||
|
for (float z = -90.0f; z <= 90.0f; z += 90.0f) {
|
||||||
|
angles[0] = x;
|
||||||
|
angles[1] = y;
|
||||||
|
angles[2] = z;
|
||||||
|
|
||||||
|
/* create the rotation quaternions using the angles and axises */
|
||||||
|
glm_quatv(rot_x, angles[0], axis_x);
|
||||||
|
glm_quatv(rot_y, angles[1], axis_y);
|
||||||
|
glm_quatv(rot_z, angles[2], axis_z);
|
||||||
|
|
||||||
|
/* apply the rotations to a unit quaternion in xzy order */
|
||||||
|
glm_quat_identity(expected);
|
||||||
|
|
||||||
|
glm_quat_copy(expected, tmp);
|
||||||
|
glm_quat_mul(tmp, rot_x, expected);
|
||||||
|
glm_quat_copy(expected, tmp);
|
||||||
|
glm_quat_mul(tmp, rot_z, expected);
|
||||||
|
glm_quat_copy(expected, tmp);
|
||||||
|
glm_quat_mul(tmp, rot_y, expected);
|
||||||
|
|
||||||
|
/* use my function to get the quaternion */
|
||||||
|
glm_euler_xzy_quat_rh(angles, result);
|
||||||
|
|
||||||
|
/* verify if the magnitude of the quaternion stays 1 */
|
||||||
|
ASSERT(test_eq(glm_quat_norm(result), 1.0f))
|
||||||
|
|
||||||
|
ASSERTIFY(test_assert_quat_eq(result, expected))
|
||||||
|
|
||||||
|
/* verify that it acts the same as glm_euler_by_order */
|
||||||
|
glm_euler_by_order(angles, GLM_EULER_XZY, expected_mat4);
|
||||||
|
glm_mat4_quat(expected_mat4, expected);
|
||||||
|
|
||||||
|
ASSERTIFY(test_assert_quat_eq_abs(result, expected));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
TEST_SUCCESS
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_IMPL(GLM_PREFIX, euler_yxz_quat_rh) {
|
||||||
|
vec3 axis_x = {1.0f, 0.0f, 0.0f};
|
||||||
|
vec3 axis_y = {0.0f, 1.0f, 0.0f};
|
||||||
|
vec3 axis_z = {0.0f, 0.0f, 1.0f};
|
||||||
|
|
||||||
|
/* random angles for testing */
|
||||||
|
vec3 angles;
|
||||||
|
|
||||||
|
/* quaternion representations for rotations */
|
||||||
|
versor rot_x, rot_y, rot_z;
|
||||||
|
|
||||||
|
versor expected;
|
||||||
|
versor result;
|
||||||
|
versor tmp;
|
||||||
|
|
||||||
|
mat4 expected_mat4;
|
||||||
|
|
||||||
|
/* 100 randomized tests */
|
||||||
|
for (int i = 0; i < 100; i++) {
|
||||||
|
test_rand_vec3(angles);
|
||||||
|
|
||||||
|
/* create the rotation quaternions using the angles and axises */
|
||||||
|
glm_quatv(rot_x, angles[0], axis_x);
|
||||||
|
glm_quatv(rot_y, angles[1], axis_y);
|
||||||
|
glm_quatv(rot_z, angles[2], axis_z);
|
||||||
|
|
||||||
|
/* apply the rotations to a unit quaternion in yxz order */
|
||||||
|
glm_quat_identity(expected);
|
||||||
|
|
||||||
|
glm_quat_copy(expected, tmp);
|
||||||
|
glm_quat_mul(tmp, rot_y, expected);
|
||||||
|
glm_quat_copy(expected, tmp);
|
||||||
|
glm_quat_mul(tmp, rot_x, expected);
|
||||||
|
glm_quat_copy(expected, tmp);
|
||||||
|
glm_quat_mul(tmp, rot_z, expected);
|
||||||
|
|
||||||
|
glm_euler_yxz_quat_rh(angles, result);
|
||||||
|
|
||||||
|
/* verify if the magnitude of the quaternion stays 1 */
|
||||||
|
ASSERT(test_eq(glm_quat_norm(result), 1.0f))
|
||||||
|
|
||||||
|
/* verify that it acts the same as rotating by 3 axis quaternions */
|
||||||
|
ASSERTIFY(test_assert_quat_eq(result, expected))
|
||||||
|
|
||||||
|
/* verify that it acts the same as glm_euler_by_order */
|
||||||
|
glm_euler_by_order(angles, GLM_EULER_YXZ, expected_mat4);
|
||||||
|
glm_mat4_quat(expected_mat4, expected);
|
||||||
|
|
||||||
|
ASSERTIFY(test_assert_quat_eq_abs(result, expected));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Start gimbal lock tests */
|
||||||
|
for (float x = -90.0f; x <= 90.0f; x += 90.0f) {
|
||||||
|
for (float y = -90.0f; y <= 90.0f; y += 90.0f) {
|
||||||
|
for (float z = -90.0f; z <= 90.0f; z += 90.0f) {
|
||||||
|
angles[0] = x;
|
||||||
|
angles[1] = y;
|
||||||
|
angles[2] = z;
|
||||||
|
|
||||||
|
/* create the rotation quaternions using the angles and axises */
|
||||||
|
glm_quatv(rot_x, angles[0], axis_x);
|
||||||
|
glm_quatv(rot_y, angles[1], axis_y);
|
||||||
|
glm_quatv(rot_z, angles[2], axis_z);
|
||||||
|
|
||||||
|
/* apply the rotations to a unit quaternion in yxz order */
|
||||||
|
glm_quat_identity(expected);
|
||||||
|
|
||||||
|
glm_quat_copy(expected, tmp);
|
||||||
|
glm_quat_mul(tmp, rot_y, expected);
|
||||||
|
glm_quat_copy(expected, tmp);
|
||||||
|
glm_quat_mul(tmp, rot_x, expected);
|
||||||
|
glm_quat_copy(expected, tmp);
|
||||||
|
glm_quat_mul(tmp, rot_z, expected);
|
||||||
|
|
||||||
|
/* use my function to get the quaternion */
|
||||||
|
glm_euler_yxz_quat_rh(angles, result);
|
||||||
|
|
||||||
|
/* verify if the magnitude of the quaternion stays 1 */
|
||||||
|
ASSERT(test_eq(glm_quat_norm(result), 1.0f))
|
||||||
|
|
||||||
|
ASSERTIFY(test_assert_quat_eq(result, expected))
|
||||||
|
|
||||||
|
/* verify that it acts the same as glm_euler_by_order */
|
||||||
|
glm_euler_by_order(angles, GLM_EULER_YXZ, expected_mat4);
|
||||||
|
glm_mat4_quat(expected_mat4, expected);
|
||||||
|
|
||||||
|
ASSERTIFY(test_assert_quat_eq_abs(result, expected));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
TEST_SUCCESS
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_IMPL(GLM_PREFIX, euler_yzx_quat_rh) {
|
||||||
|
vec3 axis_x = {1.0f, 0.0f, 0.0f};
|
||||||
|
vec3 axis_y = {0.0f, 1.0f, 0.0f};
|
||||||
|
vec3 axis_z = {0.0f, 0.0f, 1.0f};
|
||||||
|
|
||||||
|
/* random angles for testing */
|
||||||
|
vec3 angles;
|
||||||
|
|
||||||
|
/* quaternion representations for rotations */
|
||||||
|
versor rot_x, rot_y, rot_z;
|
||||||
|
|
||||||
|
versor expected;
|
||||||
|
versor result;
|
||||||
|
versor tmp;
|
||||||
|
|
||||||
|
mat4 expected_mat4;
|
||||||
|
|
||||||
|
/* 100 randomized tests */
|
||||||
|
for (int i = 0; i < 100; i++) {
|
||||||
|
test_rand_vec3(angles);
|
||||||
|
|
||||||
|
/* create the rotation quaternions using the angles and axises */
|
||||||
|
glm_quatv(rot_x, angles[0], axis_x);
|
||||||
|
glm_quatv(rot_y, angles[1], axis_y);
|
||||||
|
glm_quatv(rot_z, angles[2], axis_z);
|
||||||
|
|
||||||
|
/* apply the rotations to a unit quaternion in yzx order */
|
||||||
|
glm_quat_identity(expected);
|
||||||
|
|
||||||
|
glm_quat_copy(expected, tmp);
|
||||||
|
glm_quat_mul(tmp, rot_y, expected);
|
||||||
|
glm_quat_copy(expected, tmp);
|
||||||
|
glm_quat_mul(tmp, rot_z, expected);
|
||||||
|
glm_quat_copy(expected, tmp);
|
||||||
|
glm_quat_mul(tmp, rot_x, expected);
|
||||||
|
|
||||||
|
glm_euler_yzx_quat_rh(angles, result);
|
||||||
|
|
||||||
|
/* verify if the magnitude of the quaternion stays 1 */
|
||||||
|
ASSERT(test_eq(glm_quat_norm(result), 1.0f))
|
||||||
|
|
||||||
|
/* verify that it acts the same as rotating by 3 axis quaternions */
|
||||||
|
ASSERTIFY(test_assert_quat_eq(result, expected))
|
||||||
|
|
||||||
|
/* verify that it acts the same as glm_euler_by_order */
|
||||||
|
glm_euler_by_order(angles, GLM_EULER_YZX, expected_mat4);
|
||||||
|
glm_mat4_quat(expected_mat4, expected);
|
||||||
|
|
||||||
|
ASSERTIFY(test_assert_quat_eq_abs(result, expected));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Start gimbal lock tests */
|
||||||
|
for (float x = -90.0f; x <= 90.0f; x += 90.0f) {
|
||||||
|
for (float y = -90.0f; y <= 90.0f; y += 90.0f) {
|
||||||
|
for (float z = -90.0f; z <= 90.0f; z += 90.0f) {
|
||||||
|
angles[0] = x;
|
||||||
|
angles[1] = y;
|
||||||
|
angles[2] = z;
|
||||||
|
|
||||||
|
/* create the rotation quaternions using the angles and axises */
|
||||||
|
glm_quatv(rot_x, angles[0], axis_x);
|
||||||
|
glm_quatv(rot_y, angles[1], axis_y);
|
||||||
|
glm_quatv(rot_z, angles[2], axis_z);
|
||||||
|
|
||||||
|
/* apply the rotations to a unit quaternion in yzx order */
|
||||||
|
glm_quat_identity(expected);
|
||||||
|
|
||||||
|
glm_quat_copy(expected, tmp);
|
||||||
|
glm_quat_mul(tmp, rot_y, expected);
|
||||||
|
glm_quat_copy(expected, tmp);
|
||||||
|
glm_quat_mul(tmp, rot_z, expected);
|
||||||
|
glm_quat_copy(expected, tmp);
|
||||||
|
glm_quat_mul(tmp, rot_x, expected);
|
||||||
|
|
||||||
|
/* use my function to get the quaternion */
|
||||||
|
glm_euler_yzx_quat_rh(angles, result);
|
||||||
|
|
||||||
|
/* verify if the magnitude of the quaternion stays 1 */
|
||||||
|
ASSERT(test_eq(glm_quat_norm(result), 1.0f))
|
||||||
|
|
||||||
|
ASSERTIFY(test_assert_quat_eq(result, expected))
|
||||||
|
|
||||||
|
/* verify that it acts the same as glm_euler_by_order */
|
||||||
|
glm_euler_by_order(angles, GLM_EULER_YZX, expected_mat4);
|
||||||
|
glm_mat4_quat(expected_mat4, expected);
|
||||||
|
|
||||||
|
ASSERTIFY(test_assert_quat_eq_abs(result, expected));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
TEST_SUCCESS
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_IMPL(GLM_PREFIX, euler_zxy_quat_rh) {
|
||||||
|
vec3 axis_x = {1.0f, 0.0f, 0.0f};
|
||||||
|
vec3 axis_y = {0.0f, 1.0f, 0.0f};
|
||||||
|
vec3 axis_z = {0.0f, 0.0f, 1.0f};
|
||||||
|
|
||||||
|
/* random angles for testing */
|
||||||
|
vec3 angles;
|
||||||
|
|
||||||
|
/* quaternion representations for rotations */
|
||||||
|
versor rot_x, rot_y, rot_z;
|
||||||
|
|
||||||
|
versor expected;
|
||||||
|
versor result;
|
||||||
|
versor tmp;
|
||||||
|
|
||||||
|
mat4 expected_mat4;
|
||||||
|
|
||||||
|
/* 100 randomized tests */
|
||||||
|
for (int i = 0; i < 100; i++) {
|
||||||
|
test_rand_vec3(angles);
|
||||||
|
|
||||||
|
/* create the rotation quaternions using the angles and axises */
|
||||||
|
glm_quatv(rot_x, angles[0], axis_x);
|
||||||
|
glm_quatv(rot_y, angles[1], axis_y);
|
||||||
|
glm_quatv(rot_z, angles[2], axis_z);
|
||||||
|
|
||||||
|
/* apply the rotations to a unit quaternion in zxy order */
|
||||||
|
glm_quat_identity(expected);
|
||||||
|
|
||||||
|
glm_quat_copy(expected, tmp);
|
||||||
|
glm_quat_mul(tmp, rot_z, expected);
|
||||||
|
glm_quat_copy(expected, tmp);
|
||||||
|
glm_quat_mul(tmp, rot_x, expected);
|
||||||
|
glm_quat_copy(expected, tmp);
|
||||||
|
glm_quat_mul(tmp, rot_y, expected);
|
||||||
|
|
||||||
|
glm_euler_zxy_quat_rh(angles, result);
|
||||||
|
|
||||||
|
/* verify if the magnitude of the quaternion stays 1 */
|
||||||
|
ASSERT(test_eq(glm_quat_norm(result), 1.0f))
|
||||||
|
|
||||||
|
/* verify that it acts the same as rotating by 3 axis quaternions */
|
||||||
|
ASSERTIFY(test_assert_quat_eq(result, expected))
|
||||||
|
|
||||||
|
/* verify that it acts the same as glm_euler_by_order */
|
||||||
|
glm_euler_by_order(angles, GLM_EULER_ZXY, expected_mat4);
|
||||||
|
glm_mat4_quat(expected_mat4, expected);
|
||||||
|
|
||||||
|
ASSERTIFY(test_assert_quat_eq_abs(result, expected));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Start gimbal lock tests */
|
||||||
|
for (float x = -90.0f; x <= 90.0f; x += 90.0f) {
|
||||||
|
for (float y = -90.0f; y <= 90.0f; y += 90.0f) {
|
||||||
|
for (float z = -90.0f; z <= 90.0f; z += 90.0f) {
|
||||||
|
angles[0] = x;
|
||||||
|
angles[1] = y;
|
||||||
|
angles[2] = z;
|
||||||
|
|
||||||
|
/* create the rotation quaternions using the angles and axises */
|
||||||
|
glm_quatv(rot_x, angles[0], axis_x);
|
||||||
|
glm_quatv(rot_y, angles[1], axis_y);
|
||||||
|
glm_quatv(rot_z, angles[2], axis_z);
|
||||||
|
|
||||||
|
/* apply the rotations to a unit quaternion in zxy order */
|
||||||
|
glm_quat_identity(expected);
|
||||||
|
|
||||||
|
glm_quat_copy(expected, tmp);
|
||||||
|
glm_quat_mul(tmp, rot_z, expected);
|
||||||
|
glm_quat_copy(expected, tmp);
|
||||||
|
glm_quat_mul(tmp, rot_x, expected);
|
||||||
|
glm_quat_copy(expected, tmp);
|
||||||
|
glm_quat_mul(tmp, rot_y, expected);
|
||||||
|
|
||||||
|
/* use my function to get the quaternion */
|
||||||
|
glm_euler_zxy_quat_rh(angles, result);
|
||||||
|
|
||||||
|
/* verify if the magnitude of the quaternion stays 1 */
|
||||||
|
ASSERT(test_eq(glm_quat_norm(result), 1.0f))
|
||||||
|
|
||||||
|
ASSERTIFY(test_assert_quat_eq(result, expected))
|
||||||
|
|
||||||
|
/* verify that it acts the same as glm_euler_by_order */
|
||||||
|
glm_euler_by_order(angles, GLM_EULER_ZXY, expected_mat4);
|
||||||
|
glm_mat4_quat(expected_mat4, expected);
|
||||||
|
|
||||||
|
ASSERTIFY(test_assert_quat_eq_abs(result, expected));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
TEST_SUCCESS
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_IMPL(GLM_PREFIX, euler_zyx_quat_rh) {
|
||||||
|
vec3 axis_x = {1.0f, 0.0f, 0.0f};
|
||||||
|
vec3 axis_y = {0.0f, 1.0f, 0.0f};
|
||||||
|
vec3 axis_z = {0.0f, 0.0f, 1.0f};
|
||||||
|
|
||||||
|
/* random angles for testing */
|
||||||
|
vec3 angles;
|
||||||
|
|
||||||
|
/* quaternion representations for rotations */
|
||||||
|
versor rot_x, rot_y, rot_z;
|
||||||
|
|
||||||
|
versor expected;
|
||||||
|
versor result;
|
||||||
|
versor tmp;
|
||||||
|
|
||||||
|
mat4 expected_mat4;
|
||||||
|
|
||||||
|
/* 100 randomized tests */
|
||||||
|
for (int i = 0; i < 100; i++) {
|
||||||
|
test_rand_vec3(angles);
|
||||||
|
|
||||||
|
/* create the rotation quaternions using the angles and axises */
|
||||||
|
glm_quatv(rot_x, angles[0], axis_x);
|
||||||
|
glm_quatv(rot_y, angles[1], axis_y);
|
||||||
|
glm_quatv(rot_z, angles[2], axis_z);
|
||||||
|
|
||||||
|
/* apply the rotations to a unit quaternion in zyx order */
|
||||||
|
glm_quat_identity(expected);
|
||||||
|
|
||||||
|
glm_quat_copy(expected, tmp);
|
||||||
|
glm_quat_mul(tmp, rot_z, expected);
|
||||||
|
glm_quat_copy(expected, tmp);
|
||||||
|
glm_quat_mul(tmp, rot_y, expected);
|
||||||
|
glm_quat_copy(expected, tmp);
|
||||||
|
glm_quat_mul(tmp, rot_x, expected);
|
||||||
|
|
||||||
|
glm_euler_zyx_quat_rh(angles, result);
|
||||||
|
|
||||||
|
/* verify if the magnitude of the quaternion stays 1 */
|
||||||
|
ASSERT(test_eq(glm_quat_norm(result), 1.0f))
|
||||||
|
|
||||||
|
/* verify that it acts the same as rotating by 3 axis quaternions */
|
||||||
|
ASSERTIFY(test_assert_quat_eq(result, expected))
|
||||||
|
|
||||||
|
/* verify that it acts the same as glm_euler_by_order */
|
||||||
|
glm_euler_by_order(angles, GLM_EULER_ZYX, expected_mat4);
|
||||||
|
glm_mat4_quat(expected_mat4, expected);
|
||||||
|
|
||||||
|
ASSERTIFY(test_assert_quat_eq_abs(result, expected));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Start gimbal lock tests */
|
||||||
|
for (float x = -90.0f; x <= 90.0f; x += 90.0f) {
|
||||||
|
for (float y = -90.0f; y <= 90.0f; y += 90.0f) {
|
||||||
|
for (float z = -90.0f; z <= 90.0f; z += 90.0f) {
|
||||||
|
angles[0] = x;
|
||||||
|
angles[1] = y;
|
||||||
|
angles[2] = z;
|
||||||
|
|
||||||
|
/* create the rotation quaternions using the angles and axises */
|
||||||
|
glm_quatv(rot_x, angles[0], axis_x);
|
||||||
|
glm_quatv(rot_y, angles[1], axis_y);
|
||||||
|
glm_quatv(rot_z, angles[2], axis_z);
|
||||||
|
|
||||||
|
/* apply the rotations to a unit quaternion in xyz order */
|
||||||
|
glm_quat_identity(expected);
|
||||||
|
|
||||||
|
glm_quat_copy(expected, tmp);
|
||||||
|
glm_quat_mul(tmp, rot_z, expected);
|
||||||
|
glm_quat_copy(expected, tmp);
|
||||||
|
glm_quat_mul(tmp, rot_y, expected);
|
||||||
|
glm_quat_copy(expected, tmp);
|
||||||
|
glm_quat_mul(tmp, rot_x, expected);
|
||||||
|
|
||||||
|
/* use my function to get the quaternion */
|
||||||
|
glm_euler_zyx_quat_rh(angles, result);
|
||||||
|
|
||||||
|
/* verify if the magnitude of the quaternion stays 1 */
|
||||||
|
ASSERT(test_eq(glm_quat_norm(result), 1.0f))
|
||||||
|
|
||||||
|
ASSERTIFY(test_assert_quat_eq(result, expected))
|
||||||
|
|
||||||
|
/* verify that it acts the same as glm_euler_by_order */
|
||||||
|
glm_euler_by_order(angles, GLM_EULER_ZYX, expected_mat4);
|
||||||
|
glm_mat4_quat(expected_mat4, expected);
|
||||||
|
|
||||||
|
ASSERTIFY(test_assert_quat_eq_abs(result, expected));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
TEST_SUCCESS
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user