pax_global_header00006660000000000000000000000064147534445640014532gustar00rootroot0000000000000052 comment=144d1e7c29b3b0c6dede7917a0476cc95248559c cglm-0.9.6/000077500000000000000000000000001475344456400124705ustar00rootroot00000000000000cglm-0.9.6/.gitattributes000066400000000000000000000000301475344456400153540ustar00rootroot00000000000000*.h linguist-language=C cglm-0.9.6/.github/000077500000000000000000000000001475344456400140305ustar00rootroot00000000000000cglm-0.9.6/.github/FUNDING.yml000066400000000000000000000004351475344456400156470ustar00rootroot00000000000000# These are supported funding model platforms github: [recp] patreon: recp open_collective: cglm ko_fi: # Replace with a single Ko-fi username tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel custom: # Replace with a single custom sponsorship URL cglm-0.9.6/.github/workflows/000077500000000000000000000000001475344456400160655ustar00rootroot00000000000000cglm-0.9.6/.github/workflows/ci.yml000066400000000000000000000524711475344456400172140ustar00rootroot00000000000000name: CI on: push: branches: [ "master" ] pull_request: branches: [ "master" ] jobs: build_autotools: name: Autotools / ${{ matrix.os }} / ${{ matrix.simd }} runs-on: ${{ matrix.os }} strategy: fail-fast: false matrix: include: # x86/x64 builds - { os: macos-13, simd: none } - { os: macos-13, simd: sse } - { os: macos-13, simd: sse2 } - { os: macos-13, simd: sse3 } - { os: macos-13, simd: sse4 } - { os: macos-13, simd: avx } - { os: macos-13, simd: avx2 } - { os: macos-14, simd: none } - { os: macos-14, simd: sse } - { os: macos-14, simd: sse2 } - { os: macos-14, simd: sse3 } - { os: macos-14, simd: sse4 } - { os: macos-14, simd: avx } - { os: macos-14, simd: avx2 } - { os: ubuntu-22.04, simd: none } - { os: ubuntu-22.04, simd: sse } - { os: ubuntu-22.04, simd: sse2 } - { os: ubuntu-22.04, simd: sse3 } - { os: ubuntu-22.04, simd: sse4 } - { os: ubuntu-22.04, simd: avx } - { os: ubuntu-22.04, simd: avx2 } - { os: ubuntu-24.04, simd: none } - { os: ubuntu-24.04, simd: sse } - { os: ubuntu-24.04, simd: sse2 } - { os: ubuntu-24.04, simd: sse3 } - { os: ubuntu-24.04, simd: sse4 } - { os: ubuntu-24.04, simd: avx } - { os: ubuntu-24.04, simd: avx2 } # ARM64 builds - { os: ubuntu-latest-arm64, simd: neon } steps: - uses: actions/checkout@v4 - name: Install Autotools on macOS if: runner.os == 'macOS' run: brew upgrade && brew install autoconf automake libtool - name: Install Autotools on Ubuntu if: matrix.os == 'ubuntu-22.04' || matrix.os == 'ubuntu-24.04' run: sudo apt-get install -y autoconf automake libtool - name: Set SIMD flags run: | if [ "${{ matrix.simd }}" == "none" ]; then export CFLAGS="" elif [ "${{ matrix.simd }}" == "sse" ]; then export CFLAGS="-msse" elif [ "${{ matrix.simd }}" == "sse2" ]; then export CFLAGS="-msse2" elif [ "${{ matrix.simd }}" == "sse3" ]; then export CFLAGS="-msse3" elif [ "${{ matrix.simd }}" == "sse4" ]; then export CFLAGS="-msse4" elif [ "${{ matrix.simd }}" == "avx" ]; then export CFLAGS="-mavx" elif [ "${{ matrix.simd }}" == "avx2" ]; then export CFLAGS="-mavx2" elif [ "${{ matrix.simd }}" == "neon" ]; then export CFLAGS="-mfpu=neon" fi - name: Generate Autotools run: ./autogen.sh - name: Configure Autotools run: ./configure CFLAGS="$CFLAGS" - name: Build run: make - name: Test run: make check build_cmake_ios: name: CMake / iOS runs-on: macos-14 steps: - uses: actions/checkout@v4 - name: Configure CMake run: | cmake \ -B build \ -GXcode \ -DCMAKE_SYSTEM_NAME=iOS \ -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_ALLOWED=NO \ -DCGLM_STATIC=ON \ -DCGLM_USE_TEST=ON - name: Build run: cmake --build build build_cmake_ubuntu: name: CMake / ${{ matrix.target.os }} / ${{ matrix.target.cc }} / ${{ matrix.target.arch }} / ${{ matrix.target.simd }} runs-on: ${{ matrix.target.arch == 'arm64' && 'ubuntu-latest-arm64' || matrix.target.os }} strategy: fail-fast: false matrix: target: # GCC 11 builds - { os: ubuntu-20.04, cc: gcc-11, arch: x64, simd: none } - { os: ubuntu-20.04, cc: gcc-11, arch: x64, simd: sse } - { os: ubuntu-20.04, cc: gcc-11, arch: x64, simd: sse2 } - { os: ubuntu-20.04, cc: gcc-11, arch: x64, simd: sse3 } - { os: ubuntu-20.04, cc: gcc-11, arch: x64, simd: sse4 } - { os: ubuntu-20.04, cc: gcc-11, arch: x64, simd: avx } - { os: ubuntu-20.04, cc: gcc-11, arch: x64, simd: avx2 } # GCC 12 builds - { os: ubuntu-22.04, cc: gcc-12, arch: x64, simd: none } - { os: ubuntu-22.04, cc: gcc-12, arch: x64, simd: sse } - { os: ubuntu-22.04, cc: gcc-12, arch: x64, simd: sse2 } - { os: ubuntu-22.04, cc: gcc-12, arch: x64, simd: sse3 } - { os: ubuntu-22.04, cc: gcc-12, arch: x64, simd: sse4 } - { os: ubuntu-22.04, cc: gcc-12, arch: x64, simd: avx } - { os: ubuntu-22.04, cc: gcc-12, arch: x64, simd: avx2 } # GCC 13 builds - { os: ubuntu-24.04, cc: gcc-13, arch: x64, simd: none } - { os: ubuntu-24.04, cc: gcc-13, arch: x64, simd: sse } - { os: ubuntu-24.04, cc: gcc-13, arch: x64, simd: sse2 } - { os: ubuntu-24.04, cc: gcc-13, arch: x64, simd: sse3 } - { os: ubuntu-24.04, cc: gcc-13, arch: x64, simd: sse4 } - { os: ubuntu-24.04, cc: gcc-13, arch: x64, simd: avx } - { os: ubuntu-24.04, cc: gcc-13, arch: x64, simd: avx2 } # Clang 12 builds - { os: ubuntu-20.04, cc: clang-12, arch: x64, simd: none } - { os: ubuntu-20.04, cc: clang-12, arch: x64, simd: sse } - { os: ubuntu-20.04, cc: clang-12, arch: x64, simd: sse2 } - { os: ubuntu-20.04, cc: clang-12, arch: x64, simd: sse3 } - { os: ubuntu-20.04, cc: clang-12, arch: x64, simd: sse4 } - { os: ubuntu-20.04, cc: clang-12, arch: x64, simd: avx } - { os: ubuntu-20.04, cc: clang-12, arch: x64, simd: avx2 } # Clang 15 builds - { os: ubuntu-22.04, cc: clang-15, arch: x64, simd: none } - { os: ubuntu-22.04, cc: clang-15, arch: x64, simd: sse } - { os: ubuntu-22.04, cc: clang-15, arch: x64, simd: sse2 } - { os: ubuntu-22.04, cc: clang-15, arch: x64, simd: sse3 } - { os: ubuntu-22.04, cc: clang-15, arch: x64, simd: sse4 } - { os: ubuntu-22.04, cc: clang-15, arch: x64, simd: avx } - { os: ubuntu-22.04, cc: clang-15, arch: x64, simd: avx2 } # ARM64 builds - { os: ubuntu-latest, cc: gcc-12, arch: arm64, simd: neon } - { os: ubuntu-latest, cc: gcc-13, arch: arm64, simd: neon } # ARMv7 builds - { os: ubuntu-latest-arm64, cc: gcc-12, arch: armv7, simd: neon } - { os: ubuntu-latest-arm64, cc: gcc-12, arch: armv7, simd: none } steps: - uses: actions/checkout@v4 - name: Add Ubuntu Toolchain PPA if: matrix.target.os == 'ubuntu-20.04' run: | sudo apt-get update sudo apt-get install -y software-properties-common sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test sudo apt-get update - name: Install Compiler and Ninja run: | sudo apt-get install -y ${{ matrix.target.cc }} ninja-build - name: Set SIMD flags run: | if [ "${{ matrix.simd }}" == "none" ]; then export CFLAGS="" elif [ "${{ matrix.simd }}" == "sse" ]; then export CFLAGS="-msse" elif [ "${{ matrix.simd }}" == "sse2" ]; then export CFLAGS="-msse2" elif [ "${{ matrix.simd }}" == "sse3" ]; then export CFLAGS="-msse3" elif [ "${{ matrix.simd }}" == "sse4" ]; then export CFLAGS="-msse4" elif [ "${{ matrix.simd }}" == "avx" ]; then export CFLAGS="-mavx" elif [ "${{ matrix.simd }}" == "avx2" ]; then export CFLAGS="-mavx2" elif [ "${{ matrix.simd }}" == "neon" ]; then export CFLAGS="-mfpu=neon" fi - name: Configure CMake run: | if [ "${{ matrix.target.arch }}" == "armv7" ]; then # Build for ARMv7 neon_flags="" if [ "${{ matrix.simd }}" == "neon" ]; then neon_flags="-mfpu=neon -mfloat-abi=hard" fi cmake -B build -GNinja -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_C_COMPILER=${{ matrix.target.cc }} \ -DCMAKE_C_FLAGS="$CFLAGS -m32 -march=armv7-a ${neon_flags}" \ -DCGLM_STATIC=ON -DCGLM_USE_TEST=ON elif [ "${{ matrix.target.arch }}" == "arm64" ]; then # Build for ARM64 (AArch64) neon_flags="" if [ "${{ matrix.simd }}" == "neon" ]; then neon_flags="+simd" # Enable SIMD/NEON features on ARM64 else neon_flags="+nosimd" # Explicitly disable SIMD/NEON fi cmake -B build -GNinja -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_C_COMPILER=${{ matrix.target.cc }} \ -DCMAKE_C_FLAGS="$CFLAGS -march=armv8-a${neon_flags}" \ -DCGLM_STATIC=ON -DCGLM_USE_TEST=ON else # Normal build (x86/x64) cmake -B build -GNinja -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_C_COMPILER=${{ matrix.target.cc }} \ -DCMAKE_C_FLAGS="$CFLAGS" \ -DCGLM_STATIC=ON -DCGLM_USE_TEST=ON fi - name: Build run: cmake --build build - name: Test working-directory: build run: ./tests build_cmake_macos: name: CMake / ${{ matrix.os }} runs-on: ${{ matrix.os }} strategy: fail-fast: false matrix: os: [macos-13, macos-14] steps: - uses: actions/checkout@v4 - name: Install Ninja if: runner.os == 'macOS' run: brew upgrade && brew install ninja - name: Configure CMake run: | cmake \ -B build \ -GNinja \ -DCMAKE_BUILD_TYPE=Release \ -DCGLM_STATIC=ON \ -DCGLM_USE_TEST=ON - name: Build run: cmake --build build - name: Test working-directory: build run: ./tests build_cmake: name: CMake / ${{ matrix.os }} / ${{ matrix.simd }} runs-on: ${{ matrix.os }} strategy: fail-fast: false matrix: include: # x86/x64 builds - { os: macos-13, simd: none } - { os: macos-13, simd: sse } - { os: macos-13, simd: sse2 } - { os: macos-13, simd: sse3 } - { os: macos-13, simd: sse4 } - { os: macos-13, simd: avx } - { os: macos-13, simd: avx2 } - { os: macos-14, simd: none } - { os: macos-14, simd: sse } - { os: macos-14, simd: sse2 } - { os: macos-14, simd: sse3 } - { os: macos-14, simd: sse4 } - { os: macos-14, simd: avx } - { os: macos-14, simd: avx2 } - { os: windows-2022, simd: none } - { os: windows-2022, simd: sse } - { os: windows-2022, simd: sse2 } - { os: windows-2022, simd: sse3 } - { os: windows-2022, simd: sse4 } - { os: windows-2022, simd: avx } - { os: windows-2022, simd: avx2 } # ARM64 builds - { os: macos-14-arm64, simd: neon } steps: - uses: actions/checkout@v4 - name: Install Ninja on macOS if: runner.os == 'macOS' run: brew upgrade && brew install ninja - name: Set SIMD flags (Windows) if: runner.os == 'Windows' shell: pwsh run: | $simd = "${{ matrix.simd }}" if ($simd -eq "none") { $env:CFLAGS = "" } elseif ($simd -eq "sse") { $env:CFLAGS = "-arch:SSE" } elseif ($simd -eq "sse2") { $env:CFLAGS = "-arch:SSE2" } elseif ($simd -eq "sse3") { $env:CFLAGS = "-arch:SSE3" } elseif ($simd -eq "sse4") { $env:CFLAGS = "-arch:SSE4" } elseif ($simd -eq "avx") { $env:CFLAGS = "-arch:AVX" } elseif ($simd -eq "avx2") { $env:CFLAGS = "-arch:AVX2" } elseif ($simd -eq "neon") { $env:CFLAGS = "-arch:NEON" } - name: Set SIMD flags (Unix) if: runner.os != 'Windows' shell: bash run: | if [ "${{ matrix.simd }}" == "none" ]; then export CFLAGS="" elif [ "${{ matrix.simd }}" == "sse" ]; then export CFLAGS="-msse" elif [ "${{ matrix.simd }}" == "sse2" ]; then export CFLAGS="-msse2" elif [ "${{ matrix.simd }}" == "sse3" ]; then export CFLAGS="-msse3" elif [ "${{ matrix.simd }}" == "sse4" ]; then export CFLAGS="-msse4" elif [ "${{ matrix.simd }}" == "avx" ]; then export CFLAGS="-mavx" elif [ "${{ matrix.simd }}" == "avx2" ]; then export CFLAGS="-mavx2" elif [ "${{ matrix.simd }}" == "neon" ]; then export CFLAGS="-mfpu=neon" fi - name: Configure CMake (Windows) if: runner.os == 'Windows' shell: pwsh run: cmake -B build -G "Visual Studio 17 2022" -A x64 -T host=x64 -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_FLAGS="$env:CFLAGS" -DCGLM_STATIC=ON -DCGLM_USE_TEST=ON - name: Configure CMake (Unix) if: runner.os != 'Windows' shell: bash run: cmake -B build -GNinja -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_FLAGS="$CFLAGS" -DCGLM_STATIC=ON -DCGLM_USE_TEST=ON - name: Build run: cmake --build build - name: Test (Windows) if: runner.os == 'Windows' shell: pwsh working-directory: build run: .\Debug\tests.exe - name: Test (Unix) if: runner.os != 'Windows' shell: bash working-directory: build run: ./tests build_meson: name: Meson / ${{ matrix.os }} / ${{ matrix.simd }} runs-on: ${{ contains(matrix.os, 'arm64') && 'ubuntu-latest-arm64' || matrix.os }} strategy: fail-fast: false matrix: include: # x86/x64 builds - { os: macos-14, simd: none } - { os: macos-14, simd: sse } - { os: macos-14, simd: sse2 } - { os: macos-14, simd: sse3 } - { os: macos-14, simd: sse4 } - { os: macos-14, simd: avx } - { os: macos-14, simd: avx2 } - { os: ubuntu-22.04, simd: none } - { os: ubuntu-22.04, simd: sse } - { os: ubuntu-22.04, simd: sse2 } - { os: ubuntu-22.04, simd: sse3 } - { os: ubuntu-22.04, simd: sse4 } - { os: ubuntu-22.04, simd: avx } - { os: ubuntu-22.04, simd: avx2 } - { os: ubuntu-24.04, simd: none } - { os: ubuntu-24.04, simd: sse } - { os: ubuntu-24.04, simd: sse2 } - { os: ubuntu-24.04, simd: sse3 } - { os: ubuntu-24.04, simd: sse4 } - { os: ubuntu-24.04, simd: avx } - { os: ubuntu-24.04, simd: avx2 } - { os: windows-2022, simd: none } - { os: windows-2022, simd: sse } - { os: windows-2022, simd: sse2 } - { os: windows-2022, simd: sse3 } - { os: windows-2022, simd: sse4 } - { os: windows-2022, simd: avx } - { os: windows-2022, simd: avx2 } # ARM64 builds - { os: ubuntu-latest-arm64, simd: neon } steps: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 with: python-version: '3.12' cache: 'pip' - name: Install meson run: python3 -m pip install meson ninja - name: Set SIMD flags (Windows) if: runner.os == 'Windows' shell: pwsh run: | $simd = "${{ matrix.simd }}" if ($simd -eq "none") { $env:CFLAGS = "" } elseif ($simd -eq "sse") { $env:CFLAGS = "-arch:SSE" } elseif ($simd -eq "sse2") { $env:CFLAGS = "-arch:SSE2" } elseif ($simd -eq "sse3") { $env:CFLAGS = "-arch:SSE3" } elseif ($simd -eq "sse4") { $env:CFLAGS = "-arch:SSE4" } elseif ($simd -eq "avx") { $env:CFLAGS = "-arch:AVX" } elseif ($simd -eq "avx2") { $env:CFLAGS = "-arch:AVX2" } elseif ($simd -eq "neon") { $env:CFLAGS = "-arch:NEON" } - name: Set SIMD flags (Unix) if: runner.os != 'Windows' shell: bash run: | if [ "${{ matrix.simd }}" == "none" ]; then export CFLAGS="" elif [ "${{ matrix.simd }}" == "sse" ]; then export CFLAGS="-msse" elif [ "${{ matrix.simd }}" == "sse2" ]; then export CFLAGS="-msse2" elif [ "${{ matrix.simd }}" == "sse3" ]; then export CFLAGS="-msse3" elif [ "${{ matrix.simd }}" == "sse4" ]; then export CFLAGS="-msse4" elif [ "${{ matrix.simd }}" == "avx" ]; then export CFLAGS="-mavx" elif [ "${{ matrix.simd }}" == "avx2" ]; then export CFLAGS="-mavx2" elif [ "${{ matrix.simd }}" == "neon" ]; then export CFLAGS="-mfpu=neon" fi - name: Build with meson (Windows) if: runner.os == 'Windows' shell: pwsh run: | meson setup build -Dbuildtype=release --default-library=static -Dbuild_tests=true -Dc_args="$env:CFLAGS" meson test -C build - name: Build with meson (Unix) if: runner.os != 'Windows' shell: bash run: | meson setup build -Dbuildtype=release --default-library=static -Dbuild_tests=true -Dc_args="$CFLAGS" meson test -C build build_msbuild: name: MSBuild / Windows / ${{ matrix.simd }} runs-on: windows-2022 strategy: fail-fast: false matrix: simd: [none, sse, sse2, sse3, sse4, avx, avx2, neon] steps: - uses: actions/checkout@v4 - uses: microsoft/setup-msbuild@v2 - name: Retarget solution run: | vswhere -latest -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath $vsInstallPath = vswhere -latest -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath & "$vsInstallPath\Common7\IDE\devenv.com" cglm.sln /Upgrade - name: Set SIMD flags run: | if ($Env:SIMD -eq 'none') { $Env:CFLAGS="" } elseif ($Env:SIMD -eq 'sse') { $Env:CFLAGS="-arch:SSE" } elseif ($Env:SIMD -eq 'sse2') { $Env:CFLAGS="-arch:SSE2" } elseif ($Env:SIMD -eq 'sse3') { $Env:CFLAGS="-arch:SSE3" } elseif ($Env:SIMD -eq 'sse4') { $Env:CFLAGS="-arch:SSE4" } elseif ($Env:SIMD -eq 'avx') { $Env:CFLAGS="-arch:AVX" } elseif ($Env:SIMD -eq 'avx2') { $Env:CFLAGS="-arch:AVX2" } elseif ($Env:SIMD -eq 'neon') { $Env:CFLAGS="-arch:NEON" } - name: Build (x86) working-directory: win run: msbuild cglm.vcxproj /p:Configuration=Release /p:Platform=x86 /p:PlatformToolset=v143 /p:BuildInParallel=true /p:AdditionalOptions="$Env:CFLAGS" - name: Build (x64) working-directory: win run: msbuild cglm.vcxproj /p:Configuration=Release /p:Platform=x64 /p:PlatformToolset=v143 /p:BuildInParallel=true /p:AdditionalOptions="$Env:CFLAGS" build_documentation: name: Documentation runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 with: python-version: '3.12' - name: Install Dependencies working-directory: docs run: python3 -m pip install -r requirements.txt - name: Build working-directory: docs run: sphinx-build -W --keep-going source build build_swift: name: Swift ${{ matrix.swift }} / ${{ matrix.os }} runs-on: ${{ matrix.os }} strategy: fail-fast: false matrix: os: [macos-13, macos-14, ubuntu-22.04] # This has no test yet. steps: - uses: actions/checkout@v4 - name: Build run: swift build build_cmake_arm: name: CMake / ARM / ${{ matrix.os }} / ${{ matrix.arch }} / ${{ matrix.simd }} runs-on: ${{ matrix.os }} strategy: fail-fast: false matrix: include: # Linux ARM builds - os: ubuntu-latest-arm64 arch: arm64 simd: neon - os: ubuntu-latest-arm64 arch: armv7 simd: neon - os: ubuntu-latest-arm64 arch: armv7 simd: none # Windows ARM builds - os: windows-latest-arm64 arch: arm64 simd: neon - os: windows-latest-arm64 arch: arm simd: neon - os: windows-latest-arm64 arch: arm simd: none steps: - uses: actions/checkout@v4 - name: Configure CMake (Windows) if: runner.os == 'Windows' shell: pwsh run: | $flags = "" if ("${{ matrix.arch }}" -eq "arm") { $flags = "-m32 -march=armv7-a" if ("${{ matrix.simd }}" -eq "neon") { $flags += " -mfpu=neon" } } elseif ("${{ matrix.simd }}" -eq "neon") { $flags = "-march=armv8-a+simd" } cmake -B build -G "Visual Studio 17 2022" -A ${{ matrix.arch == 'arm64' && 'ARM64' || 'ARM' }} ` -DCMAKE_BUILD_TYPE=Release ` -DCMAKE_C_FLAGS="$flags" ` -DCGLM_STATIC=ON -DCGLM_USE_TEST=ON - name: Configure CMake (Unix) if: runner.os != 'Windows' shell: bash run: | flags="" if [ "${{ matrix.arch }}" = "armv7" ]; then flags="-m32 -march=armv7-a" if [ "${{ matrix.simd }}" = "neon" ]; then flags="$flags -mfpu=neon -mfloat-abi=hard" fi elif [ "${{ matrix.simd }}" = "neon" ]; then flags="-march=armv8-a+simd" fi cmake -B build -GNinja -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_C_FLAGS="$flags" \ -DCGLM_STATIC=ON -DCGLM_USE_TEST=ON - name: Build run: cmake --build build - name: Test working-directory: build run: ./tests cglm-0.9.6/.github/workflows/cmake-wasm.yml000066400000000000000000000123331475344456400206370ustar00rootroot00000000000000name: CMake WebAssembly on: push: branches: [ "master" ] pull_request: branches: [ "master" ] env: wasmtime_version: v7.0.0 wasmer_version: v3.1.1 jobs: build_wasi_sdk: strategy: matrix: BUILD_TYPE: [Release, Debug, RelWithDebInfo, MinSizeRel] C_FLAGS: ['', '-msimd128'] wasi_sdk_version: [19, 20] # The CMake configure and build commands are platform agnostic and should work equally well on Windows or Mac. # You can convert this to a matrix build if you need cross-platform coverage. # See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - name: Downloading wasi-sdk run: | cd ${{github.workspace}} wget --no-verbose https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-${{matrix.wasi_sdk_version}}/wasi-sdk-${{matrix.wasi_sdk_version}}.0-linux.tar.gz tar xf wasi-sdk-${{matrix.wasi_sdk_version}}.0-linux.tar.gz # Building a wasm library without needing to define a main(): # https://github.com/WebAssembly/wasi-sdk/issues/332 - name: Modify CMakeLists.txt for WASI run: | echo 'if (CMAKE_SYSTEM_NAME STREQUAL "WASI")' >> CMakeLists.txt echo ' target_link_options(${PROJECT_NAME} PRIVATE -mexec-model=reactor)' >> CMakeLists.txt echo 'endif()' >> CMakeLists.txt - name: Configure CMake # Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make. # See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type # Below suppress <<'clock' is deprecated: WASI lacks process-associated clocks; ...>> warns: # -D_WASI_EMULATED_PROCESS_CLOCKS" -DCMAKE_EXE_LINKER_FLAGS="-lwasi-emulated-process-clocks run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{matrix.BUILD_TYPE}} -DCMAKE_C_FLAGS="${{matrix.C_FLAGS}} -D_WASI_EMULATED_PROCESS_CLOCKS" -DCMAKE_EXE_LINKER_FLAGS="-lwasi-emulated-process-clocks" -DCMAKE_TOOLCHAIN_FILE=${{github.workspace}}/wasi-sdk-${{matrix.wasi_sdk_version}}.0/share/cmake/wasi-sdk.cmake -DWASI_SDK_PREFIX=${{github.workspace}}/wasi-sdk-${{matrix.wasi_sdk_version}}.0 -DCGLM_STATIC=ON -DCGLM_SHARED=OFF -DCGLM_USE_TEST=ON - name: Build # Build your program with the given configuration run: cmake --build ${{github.workspace}}/build --config ${{matrix.BUILD_TYPE}} - name: Test with wasmtime run: | cd ${{github.workspace}} ls -lh ${{github.workspace}}/build/ wget --no-verbose https://github.com/bytecodealliance/wasmtime/releases/download/${{env.wasmtime_version}}/wasmtime-${{env.wasmtime_version}}-x86_64-linux.tar.xz tar xf wasmtime-${{env.wasmtime_version}}-x86_64-linux.tar.xz ./wasmtime-${{env.wasmtime_version}}-x86_64-linux/wasmtime run --wasm-features simd ${{github.workspace}}/build/tests - name: Test with wasmer run: | cd ${{github.workspace}} mkdir wasmer cd wasmer wget --no-verbose https://github.com/wasmerio/wasmer/releases/download/${{env.wasmer_version}}/wasmer-linux-amd64.tar.gz tar xf wasmer-linux-amd64.tar.gz ./bin/wasmer run --enable-simd ${{github.workspace}}/build/tests build_emsdk: strategy: matrix: BUILD_TYPE: [Release, Debug, RelWithDebInfo, MinSizeRel] C_FLAGS: ['', '-msimd128', '-msse -msse2 -msimd128', '-msse -msse2 -msse3 -msse4 -msimd128'] runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - name: Setup emsdk uses: mymindstorm/setup-emsdk@v12 - name: Verify emsdk run: emcc -v - name: Configure CMake # Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make. # See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type run: emcmake cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{matrix.BUILD_TYPE}} -DCMAKE_C_FLAGS="${{matrix.C_FLAGS}}" -DCMAKE_EXE_LINKER_FLAGS="-s STANDALONE_WASM" -DCGLM_STATIC=ON -DCGLM_USE_TEST=ON - name: Build # Build your program with the given configuration run: cmake --build ${{github.workspace}}/build --config ${{matrix.BUILD_TYPE}} - name: Test with wasmtime run: | cd ${{github.workspace}} ls -lh ${{github.workspace}}/build/ wget --no-verbose https://github.com/bytecodealliance/wasmtime/releases/download/${{env.wasmtime_version}}/wasmtime-${{env.wasmtime_version}}-x86_64-linux.tar.xz tar xf wasmtime-${{env.wasmtime_version}}-x86_64-linux.tar.xz ./wasmtime-${{env.wasmtime_version}}-x86_64-linux/wasmtime run --wasm-features simd ${{github.workspace}}/build/tests.wasm - name: Test with wasmer run: | cd ${{github.workspace}} mkdir wasmer cd wasmer wget --no-verbose https://github.com/wasmerio/wasmer/releases/download/${{env.wasmer_version}}/wasmer-linux-amd64.tar.gz tar xf wasmer-linux-amd64.tar.gz ./bin/wasmer run --enable-simd ${{github.workspace}}/build/tests.wasm cglm-0.9.6/.github/workflows/meson-wasm.yml000066400000000000000000000046071475344456400207050ustar00rootroot00000000000000name: 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 cglm-0.9.6/.gitignore000066400000000000000000000015521475344456400144630ustar00rootroot00000000000000*.xcodeproj *.xcworkspace *.sln *.vcxproj *.vcxproj.* *.suo *.sdf *.opensdf ipch/ Debug/ Release/ .DS_Store .vs *.nupkg *.opendb packages.config /aclocal.m4 /ar-lib /autom4te.cache/ /compile /config.guess /config.log /config.status /config.sub /configure /depcomp /install-sh /ltmain.sh /missing /libtool /.libs/ .deps/ *.[oa] *.l[oa] Makefile Makefile.in m4/*.m4 .buildstamp .dirstamp packages/ .anjuta/* *.anjuta* config.h.* /config.h stamp* COPYING .idea/* *.VC.db cscope.* *-git-ignored-file.* test/*.trs test/test_* *.log test/.libs/* test/tests cglm_arm/* cglm_test_ios/* cglm_test_iosTests/* docs/build/* win/cglm_test_* * copy.* *.o *.obj *codeanalysis.*.xml *codeanalysis.xml *.lib *.tlog win/x64 win/x85 win/Debug cglm-test-ios* /cglm.pc test-driver Default-568h@2x.png build/ conftest.dir/* confdefs.h *.xcuserdatad .idea cmake-build-debug *.o.tmp xcode/* .vscodecglm-0.9.6/.readthedocs.yaml000066400000000000000000000021161475344456400157170ustar00rootroot00000000000000# 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.txtcglm-0.9.6/.travis.yml000066400000000000000000000020411475344456400145760ustar00rootroot00000000000000language: c os: - linux - osx arch: - amd64 - ppc64le - s390x - arm64 sudo: required dist: trusty compiler: - clang - gcc matrix: fast_finish: true exclude: # Skip GCC builds on macOS. - os: osx compiler: gcc include: # Additional GCC builds for code coverage. - os: linux compiler: gcc env: CODE_COVERAGE=ON cache: apt: true addons: apt: packages: - clang-3.6 - lcov branches: only: - master script: - sh ./autogen.sh - if [[ "$CC" == "gcc" && "$CODE_COVERAGE" == "ON" ]]; then ./configure CFLAGS="-ftest-coverage -fprofile-arcs -coverage"; else ./configure; fi - make - make check after_success: - if [[ "$CC" == "gcc" && "$CODE_COVERAGE" == "ON" ]]; then pip install --user cpp-coveralls && coveralls --build-root . --exclude lib --exclude test --gcov-options '\-lp' --verbose && bash <(curl -s https://codecov.io/bash); fi # after_failure: # - cat ./test-suite.log cglm-0.9.6/BUILDING.md000066400000000000000000000116261475344456400142150ustar00rootroot00000000000000# Building the library cglm can be built using one of the following build systems: ## CMake (All platforms) ```bash $ mkdir build $ cd build $ cmake .. # [Optional] -DCGLM_SHARED=ON $ make $ sudo make install # [Optional] ``` ### Options with defaults ```CMake option(CGLM_SHARED "Shared build" ON) option(CGLM_STATIC "Static build" OFF) option(CGLM_USE_C99 "" OFF) # C11 option(CGLM_USE_TEST "Enable Tests" OFF) # for make check - make test ``` ### Including in a CMake project #### Header only This requires no building or installation of cglm. * Example: ``` cmake cmake_minimum_required(VERSION 3.8.2) project() add_executable(${PROJECT_NAME} src/main.c) target_link_libraries(${LIBRARY_NAME} PRIVATE cglm_headers) add_subdirectory(external/cglm/ EXCLUDE_FROM_ALL) ``` #### Linked * Example: ```cmake cmake_minimum_required(VERSION 3.8.2) project() add_executable(${PROJECT_NAME} src/main.c) target_link_libraries(${LIBRARY_NAME} PRIVATE cglm) add_subdirectory(external/cglm/) # or you can use find_package to configure cglm ``` ### Using CMake to build for WebAssembly Since math functions like `sinf` are used, this can not be targeted at `wasm32-unknown-unknown`, one of [wasi-sdk](https://github.com/WebAssembly/wasi-sdk) or [emscripten](https://github.com/emscripten-core/emsdk) should be used. Should note that shared build is not yet supported for WebAssembly. For [simd128](https://github.com/WebAssembly/simd) support, add `-msimd128` to `CMAKE_C_FLAGS`, in command line `-DCMAKE_C_FLAGS="-msimd128"`. For tests, the cmake option `CGLM_USE_TEST` would still work, you'll need a wasi runtime for running tests, see our [ci config file](.github/workflows/cmake-wasm.yml) for a detailed example. #### WASI SDK ```bash $ cmake .. \ -DCMAKE_TOOLCHAIN_FILE=/path/to/wasi-sdk-19.0/share/cmake/wasi-sdk.cmake \ -DWASI_SDK_PREFIX=/path/to/wasi-sdk-19.0 ``` Where `/path/to/wasi-sdk-19.0/` is the path to extracted [wasi sdk](https://github.com/WebAssembly/wasi-sdk). In this case it would by default make a static build. #### Emscripten ```bash $ emcmake cmake .. \ -DCMAKE_EXE_LINKER_FLAGS="-s STANDALONE_WASM" \ -DCGLM_STATIC=ON ``` The `emcmake` here is the cmake wrapper for Emscripten from installed [emsdk](https://github.com/emscripten-core/emsdk). ## Meson (All platforms) ```bash $ meson build # [Optional] --default-library=static $ cd build $ ninja $ sudo ninja install # [Optional] ``` ### Options with Defaults: ```meson c_std=c11 buildtype=release default_library=shared build_tests=true # to run tests: ninja test ``` ### Including in a Meson project * Example: ```meson # Clone cglm or create a cglm.wrap under /subprojects project('name', 'c') cglm_dep = dependency('cglm', fallback : 'cglm', 'cglm_dep') executable('exe', 'src/main.c', dependencies : cglm_dep) ``` ## Swift (Swift Package Manager) Currently only default build options are supported. Add **cglm** dependency to your project: ```swift ... Package( ... dependencies: [ ... .package(url: "https://github.com/recp/cglm", .branch("master")), ] ... ) ``` Now add **cgml** as a dependency to your target. Product choices are: - **cglm** for inlined version of the library which can be linked only statically - **cglmc** for a compiled version of the library with no linking limitation ```swift ... .target( ... dependencies: [ ... .product(name: "cglm", package: "cglm"), ] ... ) ... ``` ## Unix (Autotools) ```bash $ sh autogen.sh $ ./configure $ make $ make check # [Optional] $ [sudo] make install # [Optional] ``` This will also install pkg-config files so you can use `pkg-config --cflags cglm` and `pkg-config --libs cglm` to retrieve compiler and linker flags. The files will be installed into the given prefix (usually `/usr/local` by default on Linux), but your pkg-config may not be configured to actually check there. You can figure out where it's looking by running `pkg-config --variable pc_path pkg-config` and change the path the files are installed to via `./configure --with-pkgconfigdir=/your/path`. Alternatively, you can add the prefix path to your `PKG_CONFIG_PATH` environment variable. ## Windows (MSBuild) Windows related build file and project files are located in `win` folder, make sure you are inside `cglm/win` folder. Code Analysis is enabled, so it may take awhile to build. ```Powershell $ cd win $ .\build.bat ``` if `msbuild` won't work (because of multi version VS) then try to build with `devenv`: ```Powershell $ devenv cglm.sln /Build Release ``` ### Running Tests on Windows You can see test project in same visual studio solution file. It is enough to run that project to run tests. # Building the documentation First you need install Sphinx: http://www.sphinx-doc.org/en/master/usage/installation.html then: ```bash $ cd docs $ sphinx-build source build ``` it will compile docs into build folder, you can run index.html inside that function.cglm-0.9.6/CMakeLists.txt000066400000000000000000000121051475344456400152270ustar00rootroot00000000000000cmake_minimum_required(VERSION 3.13) project(cglm VERSION 0.9.6 HOMEPAGE_URL https://github.com/recp/cglm DESCRIPTION "OpenGL Mathematics (glm) for C" LANGUAGES C ) set(CMAKE_C_STANDARD 11) set(CMAKE_C_STANDARD_REQUIRED YES) set(DEFAULT_BUILD_TYPE "Release") set(CGLM_BUILD) option(CGLM_SHARED "Shared build" ON) option(CGLM_STATIC "Static build" OFF) option(CGLM_USE_C99 "" OFF) option(CGLM_USE_TEST "Enable Tests" OFF) if(CMAKE_SYSTEM_NAME STREQUAL WASI) set(CGLM_STATIC ON CACHE BOOL "Static option" FORCE) set(CGLM_SHARED OFF CACHE BOOL "Shared option" FORCE) endif() if(NOT CGLM_STATIC AND CGLM_SHARED) set(CGLM_BUILD SHARED) else(CGLM_STATIC) set(CGLM_BUILD STATIC) endif() if(CGLM_USE_C99) set(CMAKE_C_STANDARD 99) endif() if(MSVC) add_definitions(-D_WINDOWS -D_USRDLL) if(NOT CMAKE_BUILD_TYPE MATCHES Debug) add_definitions(-DNDEBUG) add_compile_options(/W3 /Ox /Gy /Oi /TC) foreach(flag_var CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO) string(REGEX REPLACE "/RTC(su|[1su])" "" ${flag_var} "${${flag_var}}") endforeach(flag_var) endif() else() add_compile_options(-Wall) if(NOT CMAKE_BUILD_TYPE MATCHES Debug) add_compile_options(-O3) endif() endif() get_directory_property(hasParent PARENT_DIRECTORY) if(NOT hasParent AND NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) message(STATUS "Setting build type to '${DEFAULT_BUILD_TYPE}' as none was specified.") set(CMAKE_BUILD_TYPE "${DEFAULT_BUILD_TYPE}" CACHE STRING "Choose the type of build." FORCE) # Set the possible values of build type for cmake-gui set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo") endif() include(GNUInstallDirs) set(CPACK_PROJECT_NAME ${PROJECT_NAME}) set(CPACK_PROJECT_VERSION ${PROJECT_VERSION}) if(NOT CPack_CMake_INCLUDED) include(CPack) endif() # Target Start add_library(${PROJECT_NAME} ${CGLM_BUILD} src/euler.c src/affine.c src/io.c src/quat.c src/cam.c src/vec2.c src/ivec2.c src/vec3.c src/ivec3.c src/vec4.c src/ivec4.c src/mat2.c src/mat2x3.c src/mat2x4.c src/mat3.c src/mat3x2.c src/mat3x4.c src/mat4.c src/mat4x2.c src/mat4x3.c src/plane.c src/noise.c src/frustum.c src/box.c src/aabb2d.c src/project.c src/sphere.c src/ease.c src/curve.c src/bezier.c src/ray.c src/affine2d.c src/clipspace/ortho_lh_no.c src/clipspace/ortho_lh_zo.c src/clipspace/ortho_rh_no.c src/clipspace/ortho_rh_zo.c src/clipspace/persp_lh_no.c src/clipspace/persp_lh_zo.c src/clipspace/persp_rh_no.c src/clipspace/persp_rh_zo.c src/clipspace/view_lh_no.c src/clipspace/view_lh_zo.c src/clipspace/view_rh_no.c src/clipspace/view_rh_zo.c src/clipspace/project_no.c src/clipspace/project_zo.c ) if(CGLM_SHARED) add_definitions(-DCGLM_EXPORTS) else() target_compile_definitions(${PROJECT_NAME} PUBLIC -DCGLM_STATIC) endif() set_target_properties(${PROJECT_NAME} PROPERTIES VERSION ${PROJECT_VERSION} SOVERSION ${PROJECT_VERSION_MAJOR}) if(WIN32) # Because SOVERSION has no effect to file naming on Windows set_target_properties(${PROJECT_NAME} PROPERTIES RUNTIME_OUTPUT_NAME ${PROJECT_NAME}-${PROJECT_VERSION_MAJOR}) endif() target_include_directories(${PROJECT_NAME} PUBLIC $ $ PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src ) # Target for header-only usage add_library(${PROJECT_NAME}_headers INTERFACE) target_include_directories(${PROJECT_NAME}_headers INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/include) # Test Configuration if(CGLM_USE_TEST) include(CTest) enable_testing() add_subdirectory(test) endif() # Install install(TARGETS ${PROJECT_NAME} EXPORT ${PROJECT_NAME} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) install(DIRECTORY include/${PROJECT_NAME} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} PATTERN ".*" EXCLUDE) # Config export(TARGETS ${PROJECT_NAME} NAMESPACE ${PROJECT_NAME}:: FILE "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake" ) install(EXPORT ${PROJECT_NAME} FILE "${PROJECT_NAME}Config.cmake" NAMESPACE ${PROJECT_NAME}:: DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}) set(PACKAGE_NAME ${PROJECT_NAME}) set(prefix ${CMAKE_INSTALL_PREFIX}) set(exec_prefix ${CMAKE_INSTALL_PREFIX}) if (IS_ABSOLUTE "${CMAKE_INSTALL_INCLUDEDIR}") set(includedir "${CMAKE_INSTALL_INCLUDEDIR}") else() set(includedir "\${prefix}/${CMAKE_INSTALL_INCLUDEDIR}") endif() if (IS_ABSOLUTE "${CMAKE_INSTALL_LIBDIR}") set(libdir "${CMAKE_INSTALL_LIBDIR}") else() set(libdir "\${exec_prefix}/${CMAKE_INSTALL_LIBDIR}") endif() set(PACKAGE_VERSION "${PROJECT_VERSION}") configure_file(cglm.pc.in cglm.pc @ONLY) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/cglm.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) cglm-0.9.6/CONTRIBUTING.md000066400000000000000000000030401475344456400147160ustar00rootroot00000000000000# CONTRIBUTING Any contributions (code, documentation, ...) are welcome. # New Features - This library may not accept all new features, it is better to create an issue and get approval before coding - You must add test for every new feature - The feature must be compiled on both UNIX/POSIX systems (e.g. macos, linux...) and Windows # Code Style This library is written with C99, don't try to add C++ files (yes it can compiled into lib), if you have enough reason to add C++ files than create an issue and get approval before coding, - All functions must have `glm` prefix - Lines should be wrapped at 80 characters. - Don't invent new style for existing ones - Use C89 style comments (`/* comments */`) not C++ style comments (`// comments`) - Don't use TABs instead use 2 spaces for TABs - All indents must be 2 spaces, not 1 nor 4 space - All functions in `include` folder must be exported by `CGLM_EXPORT` and wrapped by `extern "C" {` for C++ - Crate new line for return type, attribs: ```C CGLM_INLINE void glm_mul(mat4 m1, mat4 m2, mat4 dest) ``` not acceptable: ```C CGLM_INLINE void glm_mul(mat4 m1, mat4 m2, mat4 dest) ``` - Variables must be declared at the top of a scope before usage: ```C int x; int y; x = y = 0; ``` not acceptable: ```C int x; x = 0; int y = 0; ``` - All files must retain same LICENSE statement - Code with warnings will not be accepted, please suppress them (not by disabling them) - Run code anaylysis before submitting pull requests, if you use Xcode you can enable Sanitizer in scheme, you can use valgrind in linux cglm-0.9.6/CREDITS000066400000000000000000000063221475344456400135130ustar00rootroot00000000000000This library [initially] used some [piece of] implementations (may include codes) from these open source projects/resources: 1. Initial Affine Transforms The original glm repo (g-truc), url: https://github.com/g-truc/glm LICENSE[S]: The Happy Bunny License (Modified MIT License) The MIT License Copyright (c) 2005 - 2016 G-Truc Creation FULL LICENSE: https://github.com/g-truc/glm/blob/master/copying.txt 2. Initial Quaternions Anton's OpenGL 4 Tutorials book source code: LICENSE: OpenGL 4 Example Code. Accompanies written series "Anton's OpenGL 4 Tutorials" Email: anton at antongerdelan dot net First version 27 Jan 2014 Copyright Dr Anton Gerdelan, Trinity College Dublin, Ireland. 3. Euler Angles David Eberly Geometric Tools, LLC http://www.geometrictools.com/ Copyright (c) 1998-2016. All Rights Reserved. Computing Euler angles from a rotation matrix (euler.pdf) Gregory G. Slabaugh 4. Extracting Planes Fast Extraction of Viewing Frustum Planes from the World-View-Projection Matrix Authors: Gil Gribb (ggribb@ravensoft.com) Klaus Hartmann (k_hartmann@osnabrueck.netsurf.de) 5. Transform AABB Transform Axis Aligned Bounding Boxes: http://dev.theomader.com/transform-bounding-boxes/ https://github.com/erich666/GraphicsGems/blob/master/gems/TransBox.c 6. Cull frustum http://www.txutxi.com/?p=584 http://old.cescg.org/CESCG-2002/DSykoraJJelinek/ 7. Quaternions Initial mat4_quat is borrowed from Apple's simd library 8. Vector Rotation using Quaternion https://gamedev.stackexchange.com/questions/28395/rotating-vector3-by-a-quaternion 9. Sphere AABB intersect https://github.com/erich666/GraphicsGems/blob/master/gems/BoxSphere.c 10. Horizontal add https://stackoverflow.com/questions/6996764/fastest-way-to-do-horizontal-float-vector-sum-on-x86 11. de casteljau implementation and comments https://forums.khronos.org/showthread.php/10264-Animations-in-1-4-1-release-notes-revision-A/page2?highlight=bezier https://forums.khronos.org/showthread.php/10644-Animation-Bezier-interpolation https://forums.khronos.org/showthread.php/10387-2D-Tangents-in-Bezier-Splines?p=34164&viewfull=1#post34164 https://forums.khronos.org/showthread.php/10651-Animation-TCB-Spline-Interpolation-in-COLLADA?highlight=bezier 12. vec2 cross product http://allenchou.net/2013/07/cross-product-of-2d-vectors/ 13. Ray triangle intersect Möller–Trumbore ray-triangle intersection algorithm, from "Fast, Minimum Storage Ray/Triangle Intersection" Authors: Thomas Möller (tompa@clarus.se) Ben Trumbore (wbt@graphics.cornell.edu) Link to paper: http://webserver2.tecgraf.puc-rio.br/~mgattass/cg/trbRR/Fast%20MinimumStorage%20RayTriangle%20Intersection.pdf 14. ARM NEON: Matrix Vector Multiplication https://stackoverflow.com/a/57793352/2676533 16. ARM NEON Div http://github.com/microsoft/DirectXMath 17. Pick Matrix glu project -> project.c 18. Ray sphere intersection RAY TRACING GEMS HIGH-QUALITY AND REAL-TIME RENDERING WITH DXR AND OTHER APIS CHAPTER 7 Precision Improvements for Ray/Sphere Intersection Eric Haines (1), Johannes Günther (2), and Tomas Akenine-Möller (1) (1) NVIDIA (2) Intel Wyman, C., and Haines, E. Getting Started with RTX Ray Tracing. https://github.com/NVIDIAGameWorks/GettingStartedWithRTXRayTracing cglm-0.9.6/LICENSE000066400000000000000000000021101475344456400134670ustar00rootroot00000000000000The MIT License (MIT) Copyright (c) 2015 Recep Aslantas Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. cglm-0.9.6/Makefile.am000066400000000000000000000316241475344456400145320ustar00rootroot00000000000000#****************************************************************************** # Copyright (c), Recep Aslantas. * # * # MIT License (MIT), http://opensource.org/licenses/MIT * # Full license can be found in the LICENSE file * # * #****************************************************************************** ACLOCAL_AMFLAGS = -I m4 AM_CFLAGS = -Wall \ -std=gnu11 \ -O3 \ -Wstrict-aliasing=2 \ -fstrict-aliasing lib_LTLIBRARIES = libcglm.la libcglm_la_LDFLAGS = -no-undefined -version-info 0:1:0 checkLDFLAGS = -L./.libs \ -lm \ -lcglm checkCFLAGS = $(AM_CFLAGS) \ -std=gnu11 \ -O3 \ -DCGLM_DEFINE_PRINTS \ -I./include check_PROGRAMS = test/tests TESTS = $(check_PROGRAMS) test_tests_LDFLAGS = $(checkLDFLAGS) test_tests_CFLAGS = $(checkCFLAGS) cglmdir=$(includedir)/cglm cglm_HEADERS = include/cglm/version.h \ include/cglm/common.h \ include/cglm/types.h \ include/cglm/types-struct.h \ include/cglm/cglm.h \ include/cglm/call.h \ include/cglm/struct.h \ include/cglm/cam.h \ include/cglm/io.h \ include/cglm/mat4.h \ include/cglm/mat4x2.h \ include/cglm/mat4x3.h \ include/cglm/mat3.h \ include/cglm/mat3x2.h \ include/cglm/mat3x4.h \ include/cglm/mat2.h \ include/cglm/mat2x3.h \ include/cglm/mat2x4.h \ include/cglm/affine-pre.h \ include/cglm/affine-post.h \ include/cglm/affine.h \ include/cglm/affine-mat.h \ include/cglm/vec2.h \ include/cglm/vec2-ext.h \ include/cglm/ivec2.h \ include/cglm/vec3.h \ include/cglm/vec3-ext.h \ include/cglm/ivec3.h \ include/cglm/vec4.h \ include/cglm/vec4-ext.h \ include/cglm/ivec4.h \ include/cglm/euler.h \ include/cglm/util.h \ include/cglm/quat.h \ include/cglm/plane.h \ include/cglm/noise.h \ include/cglm/frustum.h \ include/cglm/box.h \ include/cglm/aabb2d.h \ include/cglm/color.h \ include/cglm/project.h \ include/cglm/sphere.h \ include/cglm/ease.h \ include/cglm/curve.h \ include/cglm/bezier.h \ include/cglm/applesimd.h \ include/cglm/ray.h \ include/cglm/affine2d.h cglm_clipspacedir=$(includedir)/cglm/clipspace cglm_clipspace_HEADERS = include/cglm/clipspace/persp.h \ include/cglm/clipspace/persp_lh_no.h \ include/cglm/clipspace/persp_lh_zo.h \ include/cglm/clipspace/persp_rh_no.h \ include/cglm/clipspace/persp_rh_zo.h \ include/cglm/clipspace/ortho_lh_no.h \ include/cglm/clipspace/ortho_lh_zo.h \ include/cglm/clipspace/ortho_rh_no.h \ include/cglm/clipspace/ortho_rh_zo.h \ include/cglm/clipspace/view_lh.h \ include/cglm/clipspace/view_rh.h \ include/cglm/clipspace/view_lh_no.h \ include/cglm/clipspace/view_lh_zo.h \ include/cglm/clipspace/view_rh_no.h \ include/cglm/clipspace/view_rh_zo.h \ include/cglm/clipspace/project_no.h \ include/cglm/clipspace/project_zo.h cglm_calldir=$(includedir)/cglm/call cglm_call_HEADERS = include/cglm/call/mat4.h \ include/cglm/call/mat4x2.h \ include/cglm/call/mat4x3.h \ include/cglm/call/mat3.h \ include/cglm/call/mat3x2.h \ include/cglm/call/mat3x4.h \ include/cglm/call/mat2.h \ include/cglm/call/mat2x3.h \ include/cglm/call/mat2x4.h \ include/cglm/call/vec2.h \ include/cglm/call/vec3.h \ include/cglm/call/vec4.h \ include/cglm/call/ivec2.h \ include/cglm/call/ivec3.h \ include/cglm/call/ivec4.h \ include/cglm/call/io.h \ include/cglm/call/cam.h \ include/cglm/call/quat.h \ include/cglm/call/euler.h \ include/cglm/call/plane.h \ include/cglm/call/noise.h \ include/cglm/call/frustum.h \ include/cglm/call/box.h \ include/cglm/call/project.h \ include/cglm/call/sphere.h \ include/cglm/call/ease.h \ include/cglm/call/curve.h \ include/cglm/call/bezier.h \ include/cglm/call/ray.h \ include/cglm/call/affine.h \ include/cglm/call/affine2d.h \ include/cglm/call/aabb2d.h cglm_call_clipspacedir=$(includedir)/cglm/call/clipspace cglm_call_clipspace_HEADERS = include/cglm/call/clipspace/persp_lh_no.h \ include/cglm/call/clipspace/persp_lh_zo.h \ include/cglm/call/clipspace/persp_rh_no.h \ include/cglm/call/clipspace/persp_rh_zo.h \ include/cglm/call/clipspace/ortho_lh_no.h \ include/cglm/call/clipspace/ortho_lh_zo.h \ include/cglm/call/clipspace/ortho_rh_no.h \ include/cglm/call/clipspace/ortho_rh_zo.h \ include/cglm/call/clipspace/view_lh_no.h \ include/cglm/call/clipspace/view_lh_zo.h \ include/cglm/call/clipspace/view_rh_no.h \ include/cglm/call/clipspace/view_rh_zo.h \ include/cglm/call/clipspace/project_no.h \ include/cglm/call/clipspace/project_zo.h cglm_simddir=$(includedir)/cglm/simd cglm_simd_HEADERS = include/cglm/simd/intrin.h \ include/cglm/simd/x86.h \ include/cglm/simd/arm.h \ include/cglm/simd/wasm.h cglm_simd_sse2dir=$(includedir)/cglm/simd/sse2 cglm_simd_sse2_HEADERS = include/cglm/simd/sse2/affine.h \ include/cglm/simd/sse2/mat4.h \ include/cglm/simd/sse2/mat3.h \ include/cglm/simd/sse2/mat2.h \ include/cglm/simd/sse2/quat.h cglm_simd_avxdir=$(includedir)/cglm/simd/avx cglm_simd_avx_HEADERS = include/cglm/simd/avx/mat4.h \ include/cglm/simd/avx/affine.h cglm_simd_neondir=$(includedir)/cglm/simd/neon cglm_simd_neon_HEADERS = include/cglm/simd/neon/affine.h \ include/cglm/simd/neon/mat2.h \ include/cglm/simd/neon/mat4.h \ include/cglm/simd/neon/quat.h cglm_simd_wasmdir=$(includedir)/cglm/simd/wasm cglm_simd_wasm_HEADERS = include/cglm/simd/wasm/affine.h \ include/cglm/simd/wasm/mat2.h \ include/cglm/simd/wasm/mat3.h \ include/cglm/simd/wasm/mat4.h \ include/cglm/simd/wasm/quat.h cglm_handeddir=$(includedir)/cglm/handed cglm_handed_HEADERS = include/cglm/handed/euler_to_quat_lh.h \ include/cglm/handed/euler_to_quat_rh.h cglm_structdir=$(includedir)/cglm/struct cglm_struct_HEADERS = include/cglm/struct/mat4.h \ include/cglm/struct/mat4x2.h \ include/cglm/struct/mat4x3.h \ include/cglm/struct/mat3.h \ include/cglm/struct/mat3x2.h \ include/cglm/struct/mat3x4.h \ include/cglm/struct/mat2.h \ include/cglm/struct/mat2x3.h \ include/cglm/struct/mat2x4.h \ include/cglm/struct/affine-pre.h \ include/cglm/struct/affine-post.h \ include/cglm/struct/affine-mat.h \ include/cglm/struct/affine.h \ include/cglm/struct/affine2d.h \ include/cglm/struct/vec2.h \ include/cglm/struct/vec2-ext.h \ include/cglm/struct/ivec2.h \ include/cglm/struct/vec3.h \ include/cglm/struct/vec3-ext.h \ include/cglm/struct/ivec3.h \ include/cglm/struct/vec4.h \ include/cglm/struct/vec4-ext.h \ include/cglm/struct/ivec4.h \ include/cglm/struct/io.h \ include/cglm/struct/cam.h \ include/cglm/struct/quat.h \ include/cglm/struct/euler.h \ include/cglm/struct/plane.h \ include/cglm/struct/noise.h \ include/cglm/struct/frustum.h \ include/cglm/struct/box.h \ include/cglm/struct/aabb2d.h \ include/cglm/struct/project.h \ include/cglm/struct/sphere.h \ include/cglm/struct/color.h \ include/cglm/struct/curve.h \ include/cglm/struct/ray.h cglm_struct_clipspacedir=$(includedir)/cglm/struct/clipspace cglm_struct_clipspace_HEADERS = include/cglm/struct/clipspace/persp_lh_no.h \ include/cglm/struct/clipspace/persp_lh_zo.h \ include/cglm/struct/clipspace/persp_rh_no.h \ include/cglm/struct/clipspace/persp_rh_zo.h \ include/cglm/struct/clipspace/ortho_lh_no.h \ include/cglm/struct/clipspace/ortho_lh_zo.h \ include/cglm/struct/clipspace/ortho_rh_no.h \ include/cglm/struct/clipspace/ortho_rh_zo.h \ include/cglm/struct/clipspace/view_lh_no.h \ include/cglm/struct/clipspace/view_lh_zo.h \ include/cglm/struct/clipspace/view_rh_no.h \ include/cglm/struct/clipspace/view_rh_zo.h \ include/cglm/struct/clipspace/project_no.h \ include/cglm/struct/clipspace/project_zo.h cglm_struct_handeddir=$(includedir)/cglm/struct/handed cglm_struct_handed_HEADERS = include/cglm/struct/handed/euler_to_quat_lh.h \ include/cglm/struct/handed/euler_to_quat_rh.h libcglm_la_SOURCES=\ src/euler.c \ src/affine.c \ src/io.c \ src/quat.c \ src/cam.c \ src/vec2.c \ src/ivec2.c \ src/vec3.c \ src/ivec3.c \ src/vec4.c \ src/ivec4.c \ src/mat2.c \ src/mat2x3.c \ src/mat2x4.c \ src/mat3.c \ src/mat3x2.c \ src/mat3x4.c \ src/mat4.c \ src/mat4x2.c \ src/mat4x3.c \ src/plane.c \ src/noise.c \ src/frustum.c \ src/box.c \ src/project.c \ src/sphere.c \ src/ease.c \ src/curve.c \ src/bezier.c \ src/ray.c \ src/affine2d.c \ src/aabb2d.c \ src/clipspace/ortho_lh_no.c \ src/clipspace/ortho_lh_zo.c \ src/clipspace/ortho_rh_no.c \ src/clipspace/ortho_rh_zo.c \ src/clipspace/persp_lh_no.c \ src/clipspace/persp_lh_zo.c \ src/clipspace/persp_rh_no.c \ src/clipspace/persp_rh_zo.c \ src/clipspace/view_lh_no.c \ src/clipspace/view_lh_zo.c \ src/clipspace/view_rh_no.c \ src/clipspace/view_rh_zo.c \ src/clipspace/project_no.c \ src/clipspace/project_zo.c test_tests_SOURCES=\ test/runner.c \ test/src/test_common.c \ test/src/tests.c \ test/src/test_clamp.c \ test/src/test_euler.c \ test/src/test_bezier.c \ test/src/test_struct.c pkgconfig_DATA=cglm.pc # When running configure with --prefix, $VPATH references # the source directory that post-build.sh is in. When not # using a prefix, $VPATH will be unset, so we need to fall # back to using . to run the script. #export VPATH # all-local: # sh $${VPATH:-.}/post-build.sh cglm-0.9.6/Package.swift000066400000000000000000000020101475344456400150720ustar00rootroot00000000000000// swift-tools-version:5.2 import PackageDescription let package = Package( name: "cglm", products: [ .library(name: "cglm", type: .static, targets: ["cglmHeader"]), .library(name: "cglmc", targets: ["cglmCompiled"]), ], dependencies: [], targets: [ .target( name: "cglmCompiled", path: "./", exclude: [ "./docs", "./src/swift", "./include", "./test", "./win", ], sources: [ "./src", ], publicHeadersPath: "./include" ), .target( name: "cglmHeader", path: "./", exclude: [ "./docs", "./include", "./test", "./win", ], sources: [ "./src/swift", ], publicHeadersPath: "./include" ), ], cLanguageStandard: .c11 ) cglm-0.9.6/README.md000066400000000000000000000233601475344456400137530ustar00rootroot00000000000000# 🎥 OpenGL Mathematics (glm) for `C`


Build Status Documentation Status Codacy Badge Coverage Status Coverage Status

Sponsors on Open Collective Backers on Open Collective


A highly optimized 2D|3D math library. Also known as OpenGL Mathematics (glm) for C. cglm provides fast and ergonomic math functions to ease graphics programming. It is community friendly – feel free to report any bugs and issues you face.
If you're using C++, you might want to check out GLM

- Allocation-free - Header-only - SIMD-optimized - API-agnostic --- ### 📚 Documentation All functions and their parameters are documented above their declaration inside their corresponding headers.
Alternatively, you can read the complete documentation [here](http://cglm.readthedocs.io). ### 🔨 Building cglm can be used in it's entirety as a header-only library simply by including `cglm/cglm.h`. If you wish to link against it instead, it can be built using one of the supported build systems. Detailed information about building on individual platforms and build systems along with the instructions for building the documentation can be found in [BUILDING.md](./BUILDING.md). ### ✅ Usage #### Header-only Include the `cglm/cglm.h` header and use functions with the `glm_` prefix. ```c #include "cglm/cglm.h" // ... vec2 vector; glm_vec2_zero(vector); ``` #### Struct API Include `cglm/struct.h` and use `glms_`. ```c #include "cglm/struct.h" // ... vec2s vector = glms_vec2_zero(); ``` #### Linked Include `cglm/call.h` and use `glmc_`. ```c #include "cglm/call.h" // ... vec2 vector; glmc_vec2_zero(vector); ``` ### ❗ Alignment While cglm by default aligns what's necessary, it is possible to disable this by defining `CGLM_ALL_UNALIGNED`. If you're targeting machines with any kind of SIMD support, make sure that all `vec4`, `mat4` and `mat2` arguments you pass to cglm functions are aligned to prevent unexpected crashes, alternatively use the unaligned versions if present. ### Struct API The struct API works as follows (note the `s` suffix on types, `glms_` prefix on functions and `GLMS_` on constants): ```C #include mat4s mat = GLMS_MAT4_IDENTITY_INIT; mat4s inv = glms_mat4_inv(mat); ``` Struct functions generally take parameters *by copy* and *return* the results rather than taking pointers and writing to out parameters. That means your variables can usually be `const`, if you're into that. The types used are actually unions that allow access to the same data in multiple ways. One of these involves anonymous structures available since C11. MSVC supports them in earlier versions out of the box and GCC/Clang as well if you enable `-fms-extensions`. To explicitly enable anonymous structures `#define CGLM_USE_ANONYMOUS_STRUCT 1`, or `0` to disable them. For backwards compatibility, you can also `#define CGLM_NO_ANONYMOUS_STRUCT` to disable them. If you don't specify explicitly, cglm will attempt a best guess based on your compiler and C version. ### 📌 Migration notes: - `_dup` (duplicate) functions were renamed to `_copy`. For instance: `glm_vec_dup` -> `glm_vec3_copy`. - OpenGL related functions were dropped to make cglm API independent. - **[bugfix]** Euler angles had been previously implemented in reverse order (extrinsic). This was fixed to be intrinsic. - **[major change]** Starting with **v0.4.0**, quaternions are stored as [x, y, z, w]. Previously it was [w, x, y, z]. - **[api rename]** Starting with **v0.4.5**, `glm_simd_` functions are renamed to `glmm_`. - **[new option]** Starting with **v0.4.5**, alignment requirements can be disabled. Read more in the documentation. - **[major change]** Starting with **v0.5.0**, vec3 functions occupy the **glm_vec3_** namespace. This used to be **glm_vec_** in earlier versions. - **[major change]** Starting with **v0.5.1**, `vec3` and `mat3` types are not aligned by default. - **[major change]** Starting with **v0.7.3**, inline print functions are disabled by default in release mode to eliminate printing costs (see the Options chapter of the docs).
Colored output can be disabled (see documentation). - **[major change]** Starting with **v0.8.3**, alternate clipspace configurations are supported. The `CGLM_FORCE_DEPTH_ZERO_TO_ONE` and `CGLM_FORCE_LEFT_HANDED` flags are provided to control clip depth and handedness. This makes it easier to incorporate cglm into projects using graphics APIs such as Vulkan or Metal. See https://cglm.readthedocs.io/en/latest/opt.html#clipspace-option-s ### 🚀 Features - scalar and simd (sse, avx, neon...) optimizations - general purpose matrix operations (mat4, mat3) - chain matrix multiplication (square only) - general purpose vector operations (cross, dot, rotate, proj, angle...) - affine transformations - matrix decomposition (extract rotation, scaling factor) - optimized affine transform matrices (mul, rigid-body inverse) - camera (lookat) - projections (ortho, perspective) - quaternions - euler angles / yaw-pitch-roll to matrix - extract euler angles - frustum (extract view frustum planes, corners...) - bounding box (AABB in Frustum (culling), crop, merge...) - bounding sphere - project, unproject - easing functions - curves - curve interpolation helpers (SMC, deCasteljau...) - comversion helpers from cglm types to Apple's simd library to pass cglm types to Metal GL without packing them on both sides - ray intersection helpers ---
Like other graphics libraries (especially OpenGL), cglm uses column-major layout to keep matrices in memory.
 
While we might support row-major matrices in the future, currently if you need your matrices to be in row-major layout you have to transpose them.
--- cglm contains general purpose mat4 product and inverse functions but also provides optimized versions for affine transformations. If you want to multiply two affine transformation matrices you can use glm_mul instead of glm_mat4_mul and glm_inv_tr (ROT + TR) instead glm_mat4_inv. ```C /* multiplication */ mat4 modelMat; glm_mul(T, R, modelMat); /* othonormal rot + tr matrix inverse (rigid-body) */ glm_inv_tr(modelMat); ``` ## Contributors This project exists thanks to all the people who contribute. [[Contribute](CONTRIBUTING.md)] ## Backers Thank you to all our backers! 🙏 [[Become a backer](https://opencollective.com/cglm#backer)] ## Sponsors Support this project by becoming a sponsor. Your logo will show up here with a link to your website. [[Become a sponsor](https://opencollective.com/cglm#sponsor)] cglm-0.9.6/_config.yml000066400000000000000000000000331475344456400146130ustar00rootroot00000000000000theme: jekyll-theme-minimalcglm-0.9.6/autogen.sh000077500000000000000000000004671475344456400145000ustar00rootroot00000000000000#! /bin/sh # # Copyright (c), Recep Aslantas. # # MIT License (MIT), http://opensource.org/licenses/MIT # Full license can be found in the LICENSE file # cd $(dirname "$0") autoheader if [ "$(uname)" = "Darwin" ]; then glibtoolize else libtoolize fi aclocal -I m4 autoconf automake --add-missing --copy cglm-0.9.6/cglm.pc.in000066400000000000000000000004111475344456400143370ustar00rootroot00000000000000prefix=@prefix@ exec_prefix=@exec_prefix@ libdir=@libdir@ includedir=@includedir@ Name: @PACKAGE_NAME@ Description: OpenGL Mathematics (glm) for C URL: https://github.com/recp/cglm Version: @PACKAGE_VERSION@ Cflags: -I${includedir} Libs: -L${libdir} -lcglm @LIBS@ cglm-0.9.6/cglm.png000066400000000000000000013650461475344456400141370ustar00rootroot00000000000000PNG  IHDR֭ IDATx^U^2-3I:HY)*l?q]ܿe];"SXH/!@2d;os{yg23$gϽ>#                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 T @n =Dy2Or:"W[ Ih$QG.sߏt$@$@$@$@$PiHHHHf"@]ٞw%6i<ޠ,87D Ac8s$@$@$@$@B %N }ksf $    (I$@$@$@$@$P2V8,.K$@$@$@$@$0!PO3 @ad =@dZ`I3@$@$@$@$@%F_bewIHHHH`"iȇ?&?28e3L$@$@$@$@DԥtW    OʧHGHG&lܒ @)L$@$@$@$0 JcIW<yd΅#   ihcQHHHHd $LϝrLiuʥ:YeIHHHH@A͓HHHH@2-|>K)cDG2HHHHJ%yi    KG>B׼GZK$@$@$@$@@R8J# 1A@M|L#F!vԂO!=ԥ>& HHHf6ڠǗ#   (%8FHCm&N3bknKi+ zC$p4~iX$Q-֋/X)@5W@/n/g*8s}Gb.IKn;dϖȟ'un1HHH`P j wb:q2Щ'#pHHH xږ; V6HP Tzj<><^OrA׃iJ2.N?%S$#Xngw녃`b>M0,7Hۈn}kG_r+'  (:jCӮlھK$آ;D$@$@$@)?_Ǥ㵯3g8#Ϝ2`qȨ5%e;|OGGgf^.ذgB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&B~)̙ݍ fʘɱq cPOJu/Gφu~KqOx }9ϺnC#r",g/}o̽~qqr-FCBr$5s řA!jܫ^Kbo#%)$\F6$cOv8="=<4(G=-aZ]x;bGoٸi#~l300ת+YhghG\3 ^D@79 8,N> Q'"ZYQ8: I<{2omc:m)ju}dW͞c"u_)(.Yϯt;x-:.t9LEq/GI*/Y'}Ý; 3~_eyuU5 Ie8'000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000>IENDB`cglm-0.9.6/cglm.podspec000066400000000000000000000024101475344456400147660ustar00rootroot00000000000000Pod::Spec.new do |s| # Description s.name = "cglm" s.version = "0.9.5" s.summary = "📽 Highly Optimized Graphics Math (glm) for C" s.description = <<-DESC cglm is math library for graphics programming for C. See the documentation or README for all features. DESC s.documentation_url = "http://cglm.readthedocs.io" # Home s.homepage = "https://github.com/recp/cglm" s.license = { :type => "MIT", :file => "LICENSE" } s.author = { "Recep Aslantas" => "recp@acm.org" } # Sources s.source = { :git => "https://github.com/recp/cglm.git", :tag => "v#{s.version}" } s.source_files = "src", "include/cglm/**/*.h" s.public_header_files = "include", "include/cglm/**/*.h" s.exclude_files = "src/win/*", "src/dllmain.c", "src/**/*.h" s.preserve_paths = "include", "src" s.header_mappings_dir = "include" # Linking s.library = "m" # Configuration s.pod_target_xcconfig = { 'CLANG_ENABLE_MODULES' => 'NO', 'CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES' => 'YES', 'CLANG_WARN_DOCUMENTATION_COMMENTS' => 'NO', 'GCC_C_LANGUAGE_STANDARD' => 'gnu11', 'GCC_PREPROCESSOR_DEFINITIONS' => '$(inherited) GLM_TESTS_NO_COLORFUL_OUTPUT' } end cglm-0.9.6/configure.ac000066400000000000000000000040531475344456400147600ustar00rootroot00000000000000#***************************************************************************** # Copyright (c), Recep Aslantas. * # * # MIT License (MIT), http://opensource.org/licenses/MIT * # Full license can be found in the LICENSE file * # * #***************************************************************************** AC_PREREQ([2.69]) AC_INIT([cglm], [0.9.6], [info@recp.me]) AM_INIT_AUTOMAKE([-Wall foreign subdir-objects serial-tests]) # Don't use the default cflags (-O2 -g), we set ours manually in Makefile.am. : ${CFLAGS=""} AC_CONFIG_MACRO_DIR([m4]) AC_CONFIG_SRCDIR([src/]) AC_CONFIG_HEADERS([config.h]) # Dependencies for pkg-config. PKG_PROG_PKG_CONFIG # Ancient versions of pkg-config (such as the one used in Travis CI) # don't have this macro, so we need to do it manually. m4_ifdef([PKG_INSTALLDIR], [ PKG_INSTALLDIR ], [ AC_ARG_WITH([pkgconfigdir], [AS_HELP_STRING([--with-pkgconfigdir], [pkg-config installation directory ['${libdir}/pkgconfig']])],, [with_pkgconfigdir=]'${libdir}/pkgconfig') AC_SUBST([pkgconfigdir], [$with_pkgconfigdir]) ]) # Checks for programs. AC_PROG_CC AM_PROG_CC_C_O AC_PROG_INSTALL AM_PROG_AR AC_ENABLE_SHARED AC_ENABLE_STATIC LT_INIT # Checks for libraries. AC_CHECK_LIB([m], [floor]) m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) AC_SYS_LARGEFILE # Checks for header files. AC_CHECK_HEADERS([limits.h \ stddef.h \ stdint.h \ stdlib.h \ string.h ]) # Checks for typedefs, structures, and compiler characteristics. AC_CHECK_HEADER_STDBOOL AC_C_INLINE AC_TYPE_INT32_T AC_TYPE_INT64_T AC_TYPE_SIZE_T AC_TYPE_UINT16_T AC_TYPE_UINT32_T AC_TYPE_UINT64_T AC_TYPE_UINT8_T # Checks for library functions. AC_FUNC_ERROR_AT_LINE AC_CONFIG_FILES([Makefile cglm.pc]) AC_OUTPUT cglm-0.9.6/docs/000077500000000000000000000000001475344456400134205ustar00rootroot00000000000000cglm-0.9.6/docs/make.bat000077500000000000000000000014461475344456400150350ustar00rootroot00000000000000@ECHO OFF pushd %~dp0 REM Command file for Sphinx documentation if "%SPHINXBUILD%" == "" ( set SPHINXBUILD=python -msphinx ) set SOURCEDIR=source set BUILDDIR=build set SPHINXPROJ=cglm if "%1" == "" goto help %SPHINXBUILD% >NUL 2>NUL if errorlevel 9009 ( echo. echo.The Sphinx module was not found. Make sure you have Sphinx installed, echo.then set the SPHINXBUILD environment variable to point to the full echo.path of the 'sphinx-build' executable. Alternatively you may add the echo.Sphinx directory to PATH. echo. echo.If you don't have Sphinx installed, grab it from echo.http://sphinx-doc.org/ exit /b 1 ) %SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% goto end :help %SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% :end popd cglm-0.9.6/docs/requirements.txt000066400000000000000000000002061475344456400167020ustar00rootroot00000000000000# Defining the exact version will make sure things don't break sphinx==7.2.6 sphinx_rtd_theme==2.0.0 readthedocs-sphinx-search==0.3.2 cglm-0.9.6/docs/source/000077500000000000000000000000001475344456400147205ustar00rootroot00000000000000cglm-0.9.6/docs/source/aabb2d.rst000066400000000000000000000124521475344456400165710ustar00rootroot00000000000000.. default-domain:: C 2d axis aligned bounding box (AABB) ================================================================================ Header: cglm/aabb2d.h Some convenient functions provided for AABB. **Definition of aabb:** cglm defines an aabb as a two dimensional array of vec2's. The first element is the **min** point and the second one is the **max** point. If you have another type e.g. struct or even another representation then you must convert it before and after calling a cglm aabb2d function. Table of contents (click to go): ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Macros: 1. :c:func:`glm_aabb2d_size` Functions: 1. :c:func:`glm_aabb2d_copy` #. :c:func:`glm_aabb2d_zero` #. :c:func:`glm_aabb2d_transform` #. :c:func:`glm_aabb2d_merge` #. :c:func:`glm_aabb2d_crop` #. :c:func:`glm_aabb2d_crop_until` #. :c:func:`glm_aabb2d_invalidate` #. :c:func:`glm_aabb2d_isvalid` #. :c:func:`glm_aabb2d_diag` #. :c:func:`glm_aabb2d_sizev` #. :c:func:`glm_aabb2d_radius` #. :c:func:`glm_aabb2d_center` #. :c:func:`glm_aabb2d_aabb` #. :c:func:`glm_aabb2d_circle` #. :c:func:`glm_aabb2d_point` #. :c:func:`glm_aabb2d_contains` Functions documentation ~~~~~~~~~~~~~~~~~~~~~~~ .. c:function:: void glm_aabb2d_copy(vec2 aabb[2], vec2 dest[2]) | copy all members of [aabb] to [dest] Parameters: | *[in]* **aabb** bounding box | *[out]* **dest** destination .. c:function:: void glm_aabb2d_zero(vec2 aabb[2]) | makes all members of [aabb] 0.0f (zero) Parameters: | *[in, out]* **aabb** bounding box .. c:function:: void glm_aabb2d_transform(vec2 aabb[2], mat3 m, vec2 dest[2]) | apply transform to Axis-Aligned Bounding Box Parameters: | *[in]* **aabb** bounding box | *[in]* **m** transform matrix | *[out]* **dest** transformed bounding box .. c:function:: void glm_aabb2d_merge(vec2 aabb1[2], vec2 aabb2[2], vec2 dest[2]) | merges two AABB bounding box and creates new one two aabb must be in the same space Parameters: | *[in]* **aabb1** bounding box 1 | *[in]* **aabb2** bounding box 2 | *[out]* **dest** merged bounding box .. c:function:: void glm_aabb2d_crop(vec2 aabb[2], vec2 cropAabb[2], vec2 dest[2]) | crops a bounding box with another one. this could be useful for getting a bbox which fits with view frustum and object bounding boxes. In this case you crop view frustum box with objects box Parameters: | *[in]* **aabb** bounding box 1 | *[in]* **cropAabb** crop box | *[out]* **dest** cropped bounding box .. c:function:: void glm_aabb2d_crop_until(vec2 aabb[2], vec2 cropAabb[2], vec2 clampAabb[2], vec2 dest[2]) | crops a bounding box with another one. this could be useful for getting a bbox which fits with view frustum and object bounding boxes. In this case you crop view frustum box with objects box Parameters: | *[in]* **aabb** bounding box | *[in]* **cropAabb** crop box | *[in]* **clampAabb** minimum box | *[out]* **dest** cropped bounding box .. c:function:: void glm_aabb2d_invalidate(vec2 aabb[2]) | invalidate AABB min and max values | It fills *max* values with -FLT_MAX and *min* values with +FLT_MAX Parameters: | *[in, out]* **aabb** bounding box .. c:function:: bool glm_aabb2d_isvalid(vec2 aabb[2]) | check if AABB is valid or not Parameters: | *[in]* **aabb** bounding box Returns: returns true if aabb is valid otherwise false .. c:function:: float glm_aabb2d_diag(vec2 aabb[2]) | distance between min and max Parameters: | *[in]* **aabb** bounding box Returns: distance between min - max .. c:function:: void glm_aabb2d_sizev(vec2 aabb[2], vec2 dest) | size vector of aabb Parameters: | *[in]* **aabb** bounding box | *[out]* **dest** size vector Returns: size vector of aabb max - min .. c:function:: float glm_aabb2d_radius(vec2 aabb[2]) | radius of sphere which surrounds AABB Parameters: | *[in]* **aabb** bounding box .. c:function:: void glm_aabb2d_center(vec2 aabb[2], vec2 dest) | computes center point of AABB Parameters: | *[in]* **aabb** bounding box | *[out]* **dest** center of bounding box .. c:function:: bool glm_aabb2d_aabb(vec2 aabb[2], vec2 other[2]) | check if two AABB intersects Parameters: | *[in]* **aabb** bounding box | *[out]* **other** other bounding box .. c:function:: bool glm_aabb2d_circle(vec2 aabb[2], vec3 c) | check if AABB intersects with sphere | https://github.com/erich666/GraphicsGems/blob/master/gems/BoxSphere.c | Solid Box - Solid Sphere test. Parameters: | *[in]* **aabb** solid bounding box | *[out]* **c** solid circle .. c:function:: bool glm_aabb2d_point(vec2 aabb[2], vec2 point) | check if point is inside of AABB Parameters: | *[in]* **aabb** bounding box | *[out]* **point** point .. c:function:: bool glm_aabb2d_contains(vec2 aabb[2], vec2 other[2]) | check if AABB contains other AABB Parameters: | *[in]* **aabb** bounding box | *[out]* **other** other bounding box cglm-0.9.6/docs/source/affine-common.rst000066400000000000000000000072371475344456400202010ustar00rootroot00000000000000.. default-domain:: C 3D Affine Transforms (common) ================================================================================ Common transform functions. Table of contents (click to go): ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Functions: 1. :c:func:`glm_translate_make` #. :c:func:`glm_scale_to` #. :c:func:`glm_scale_make` #. :c:func:`glm_scale` #. :c:func:`glm_scale_uni` #. :c:func:`glm_rotate_make` #. :c:func:`glm_rotate_atm` #. :c:func:`glm_decompose_scalev` #. :c:func:`glm_uniscaled` #. :c:func:`glm_decompose_rs` #. :c:func:`glm_decompose` Functions documentation ~~~~~~~~~~~~~~~~~~~~~~~ .. c:function:: void glm_translate_make(mat4 m, vec3 v) creates NEW translate transform matrix by *v* vector. Parameters: | *[in, out]* **m** affine transform | *[in]* **v** translate vector [x, y, z] .. c:function:: void glm_scale_to(mat4 m, vec3 v, mat4 dest) scale existing transform matrix by *v* vector and store result in dest Parameters: | *[in]* **m** affine transform | *[in]* **v** scale vector [x, y, z] | *[out]* **dest** scaled matrix .. c:function:: void glm_scale_make(mat4 m, vec3 v) creates NEW scale matrix by v vector Parameters: | *[out]* **m** affine transform | *[in]* **v** scale vector [x, y, z] .. c:function:: void glm_scale(mat4 m, vec3 v) scales existing transform matrix by v vector and stores result in same matrix Parameters: | *[in, out]* **m** affine transform | *[in]* **v** scale vector [x, y, z] .. c:function:: void glm_scale_uni(mat4 m, float s) applies uniform scale to existing transform matrix v = [s, s, s] and stores result in same matrix Parameters: | *[in, out]* **m** affine transform | *[in]* **v** scale factor .. c:function:: void glm_rotate_make(mat4 m, float angle, vec3 axis) creates NEW rotation matrix by angle and axis, axis will be normalized so you don't need to normalize it Parameters: | *[out]* **m** affine transform | *[in]* **axis** angle (radians) | *[in]* **axis** axis .. c:function:: void glm_rotate_atm(mat4 m, vec3 pivot, float angle, vec3 axis) | creates NEW rotation matrix by angle and axis at given point | this creates rotation matrix, it assumes you don't have a matrix | this should work faster than glm_rotate_at because it reduces one glm_translate. Parameters: | *[in, out]* **m** affine transform | *[in]* **pivot** pivot, anchor point, rotation center | *[in]* **angle** angle (radians) | *[in]* **axis** axis .. c:function:: void glm_decompose_scalev(mat4 m, vec3 s) decompose scale vector Parameters: | *[in]* **m** affine transform | *[out]* **s** scale vector (Sx, Sy, Sz) .. c:function:: bool glm_uniscaled(mat4 m) returns true if matrix is uniform scaled. This is helpful for creating normal matrix. Parameters: | *[in]* **m** matrix .. c:function:: void glm_decompose_rs(mat4 m, mat4 r, vec3 s) decompose rotation matrix (mat4) and scale vector [Sx, Sy, Sz] DON'T pass projected matrix here Parameters: | *[in]* **m** affine transform | *[out]* **r** rotation matrix | *[out]* **s** scale matrix .. c:function:: void glm_decompose(mat4 m, vec4 t, mat4 r, vec3 s) decompose affine transform, TODO: extract shear factors. DON'T pass projected matrix here Parameters: | *[in]* **m** affine transform | *[out]* **t** translation vector | *[out]* **r** rotation matrix (mat4) | *[out]* **s** scaling vector [X, Y, Z] cglm-0.9.6/docs/source/affine-mat.rst000066400000000000000000000053661475344456400174730ustar00rootroot00000000000000.. default-domain:: C 3D Affine Transform Matrix (specialized functions) ================================================================================ Header: cglm/affine-mat.h We mostly use glm_mat4_* for 4x4 general and transform matrices. **cglm** provides optimized version of some functions. Because affine transform matrix is a known format, for instance all last item of first three columns is zero. You should be careful when using these functions. For instance :c:func:`glm_mul` assumes matrix will be this format: .. code-block:: text R R R X R R R Y R R R Z 0 0 0 W if you override zero values here then use :c:func:`glm_mat4_mul` version. You cannot use :c:func:`glm_mul` anymore. Same is also true for :c:func:`glm_inv_tr` if you only have rotation and translation then it will work as expected, otherwise you cannot use that. In the future it may accept scale factors too but currently it does not. Table of contents (click func go): ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Functions: 1. :c:func:`glm_mul` #. :c:func:`glm_mul_rot` #. :c:func:`glm_inv_tr` Functions documentation ~~~~~~~~~~~~~~~~~~~~~~~ .. c:function:: void glm_mul(mat4 m1, mat4 m2, mat4 dest) | this is similar to glm_mat4_mul but specialized to affine transform Matrix format should be: .. code-block:: text R R R X R R R Y R R R Z 0 0 0 W this reduces some multiplications. It should be faster than mat4_mul. if you are not sure about matrix format then DON'T use this! use mat4_mul Parameters: | *[in]* **m1** affine matrix 1 | *[in]* **m2** affine matrix 2 | *[out]* **dest** result matrix .. c:function:: void glm_mul_rot(mat4 m1, mat4 m2, mat4 dest) | this is similar to glm_mat4_mul but specialized to rotation matrix Right Matrix format should be (left is free): .. code-block:: text R R R 0 R R R 0 R R R 0 0 0 0 1 this reduces some multiplications. It should be faster than mat4_mul. if you are not sure about matrix format then DON'T use this! use mat4_mul Parameters: | *[in]* **m1** affine matrix 1 | *[in]* **m2** affine matrix 2 | *[out]* **dest** result matrix .. c:function:: void glm_inv_tr(mat4 mat) | inverse orthonormal rotation + translation matrix (ridig-body) .. code-block:: text X = | R T | X' = | R' -R'T | | 0 1 | | 0 1 | use this if you only have rotation + translation, this should work faster than :c:func:`glm_mat4_inv` Don't use this if your matrix includes other things e.g. scale, shear... Parameters: | *[in,out]* **mat** affine matrix cglm-0.9.6/docs/source/affine-post.rst000066400000000000000000000075161475344456400176760ustar00rootroot00000000000000.. default-domain:: C 3D Affine Transforms (post) ================================================================================ Post transform functions are similar to pre transform functions except order of application is reversed. Post transform functions are applied after the object is transformed with given (model matrix) transform. Table of contents (click to go): ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Functions: 1. :c:func:`glm_translated_to` #. :c:func:`glm_translated` #. :c:func:`glm_translated_x` #. :c:func:`glm_translated_y` #. :c:func:`glm_translated_z` #. :c:func:`glm_rotated_x` #. :c:func:`glm_rotated_y` #. :c:func:`glm_rotated_z` #. :c:func:`glm_rotated` #. :c:func:`glm_rotated_at` #. :c:func:`glm_spinned` Functions documentation ~~~~~~~~~~~~~~~~~~~~~~~ .. c:function:: void glm_translated_to(mat4 m, vec3 v, mat4 dest) translate existing transform matrix by *v* vector and store result in dest Parameters: | *[in]* **m** affine transform | *[in]* **v** translate vector [x, y, z] | *[out]* **dest** translated matrix .. c:function:: void glm_translated(mat4 m, vec3 v) translate existing transform matrix by *v* vector and stores result in same matrix Parameters: | *[in, out]* **m** affine transform | *[in]* **v** translate vector [x, y, z] .. c:function:: void glm_translated_x(mat4 m, float x) translate existing transform matrix by x factor Parameters: | *[in, out]* **m** affine transform | *[in]* **v** x factor .. c:function:: void glm_translated_y(mat4 m, float y) translate existing transform matrix by *y* factor Parameters: | *[in, out]* **m** affine transform | *[in]* **v** y factor .. c:function:: void glm_translated_z(mat4 m, float z) translate existing transform matrix by *z* factor Parameters: | *[in, out]* **m** affine transform | *[in]* **v** z factor .. c:function:: void glm_rotated_x(mat4 m, float angle, mat4 dest) rotate existing transform matrix around X axis by angle and store result in dest Parameters: | *[in]* **m** affine transform | *[in]* **angle** angle (radians) | *[out]* **dest** rotated matrix .. c:function:: void glm_rotated_y(mat4 m, float angle, mat4 dest) rotate existing transform matrix around Y axis by angle and store result in dest Parameters: | *[in]* **m** affine transform | *[in]* **angle** angle (radians) | *[out]* **dest** rotated matrix .. c:function:: void glm_rotated_z(mat4 m, float angle, mat4 dest) rotate existing transform matrix around Z axis by angle and store result in dest Parameters: | *[in]* **m** affine transform | *[in]* **angle** angle (radians) | *[out]* **dest** rotated matrix .. c:function:: void glm_rotated(mat4 m, float angle, vec3 axis) rotate existing transform matrix around Z axis by angle and axis Parameters: | *[in, out]* **m** affine transform | *[in]* **angle** angle (radians) | *[in]* **axis** axis .. c:function:: void glm_rotated_at(mat4 m, vec3 pivot, float angle, vec3 axis) rotate existing transform around given axis by angle at given pivot point (rotation center) Parameters: | *[in, out]* **m** affine transform | *[in]* **pivot** pivot, anchor point, rotation center | *[in]* **angle** angle (radians) | *[in]* **axis** axis .. c:function:: void glm_spinned(mat4 m, float angle, vec3 axis) | rotate existing transform matrix around given axis by angle around self (doesn't affected by position) Parameters: | *[in, out]* **m** affine transform | *[in]* **angle** angle (radians) | *[in]* **axis** axis cglm-0.9.6/docs/source/affine-pre.rst000066400000000000000000000115131475344456400174670ustar00rootroot00000000000000.. default-domain:: C 3D Affine Transforms (pre) ================================================================================ Pre transform functions which are regular transform functions. Table of contents (click to go): ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Functions: 1. :c:func:`glm_translate_to` #. :c:func:`glm_translate` #. :c:func:`glm_translate_x` #. :c:func:`glm_translate_y` #. :c:func:`glm_translate_z` #. :c:func:`glm_translate_make` #. :c:func:`glm_scale_to` #. :c:func:`glm_scale_make` #. :c:func:`glm_scale` #. :c:func:`glm_scale_uni` #. :c:func:`glm_rotate_x` #. :c:func:`glm_rotate_y` #. :c:func:`glm_rotate_z` #. :c:func:`glm_rotate_make` #. :c:func:`glm_rotate` #. :c:func:`glm_rotate_at` #. :c:func:`glm_rotate_atm` #. :c:func:`glm_decompose_scalev` #. :c:func:`glm_uniscaled` #. :c:func:`glm_decompose_rs` #. :c:func:`glm_decompose` #. :c:func:`glm_spin` Functions documentation ~~~~~~~~~~~~~~~~~~~~~~~ .. c:function:: void glm_translate_to(mat4 m, vec3 v, mat4 dest) translate existing transform matrix by *v* vector and store result in dest Parameters: | *[in]* **m** affine transform | *[in]* **v** translate vector [x, y, z] | *[out]* **dest** translated matrix .. c:function:: void glm_translate(mat4 m, vec3 v) translate existing transform matrix by *v* vector and stores result in same matrix Parameters: | *[in, out]* **m** affine transform | *[in]* **v** translate vector [x, y, z] .. c:function:: void glm_translate_x(mat4 m, float x) translate existing transform matrix by x factor Parameters: | *[in, out]* **m** affine transform | *[in]* **v** x factor .. c:function:: void glm_translate_y(mat4 m, float y) translate existing transform matrix by *y* factor Parameters: | *[in, out]* **m** affine transform | *[in]* **v** y factor .. c:function:: void glm_translate_z(mat4 m, float z) translate existing transform matrix by *z* factor Parameters: | *[in, out]* **m** affine transform | *[in]* **v** z factor .. c:function:: void glm_rotate_x(mat4 m, float angle, mat4 dest) rotate existing transform matrix around X axis by angle and store result in dest Parameters: | *[in]* **m** affine transform | *[in]* **angle** angle (radians) | *[out]* **dest** rotated matrix .. c:function:: void glm_rotate_y(mat4 m, float angle, mat4 dest) rotate existing transform matrix around Y axis by angle and store result in dest Parameters: | *[in]* **m** affine transform | *[in]* **angle** angle (radians) | *[out]* **dest** rotated matrix .. c:function:: void glm_rotate_z(mat4 m, float angle, mat4 dest) rotate existing transform matrix around Z axis by angle and store result in dest Parameters: | *[in]* **m** affine transform | *[in]* **angle** angle (radians) | *[out]* **dest** rotated matrix .. c:function:: void glm_rotate(mat4 m, float angle, vec3 axis) rotate existing transform matrix around given axis by angle at ORIGIN (0,0,0) **❗️IMPORTANT ❗️** If you need to rotate object around itself e.g. center of object or at some point [of object] then `glm_rotate_at()` would be better choice to do so. Even if object's model transform is identity, rotation may not be around center of object if object does not lay out at ORIGIN perfectly. Using `glm_rotate_at()` with center of bounding shape ( AABB, Sphere ... ) would be an easy option to rotate around object if object is not at origin. One another option to rotate around itself at any point is `glm_spin()` which is perfect if only rotating around model position is desired e.g. not specific point on model for instance center of geometry or center of mass, again if geometry is not perfectly centered at origin at identity transform, rotation may not be around geometry. Parameters: | *[in, out]* **m** affine transform | *[in]* **angle** angle (radians) | *[in]* **axis** axis .. c:function:: void glm_rotate_at(mat4 m, vec3 pivot, float angle, vec3 axis) rotate existing transform around given axis by angle at given pivot point (rotation center) Parameters: | *[in, out]* **m** affine transform | *[in]* **pivot** pivot, anchor point, rotation center | *[in]* **angle** angle (radians) | *[in]* **axis** axis .. c:function:: void glm_spin(mat4 m, float angle, vec3 axis) | rotate existing transform matrix around given axis by angle around self (doesn't affected by position) Parameters: | *[in, out]* **m** affine transform | *[in]* **angle** angle (radians) | *[in]* **axis** axis cglm-0.9.6/docs/source/affine.rst000066400000000000000000000161471475344456400167130ustar00rootroot00000000000000.. default-domain:: C 3D Affine Transforms ================================================================================ Header: cglm/affine.h Before starting, **cglm** provides two kind of transform functions; pre and post. Pre functions (`T' = Tnew * T`) are like `glm_translate`, `glm_rotate` which means it will translate the vector first and then apply the model transformation. Post functions (`T' = T * Tnew`) are like `glm_translated`, `glm_rotated` which means it will apply the model transformation first and then translate the vector. `glm_translate`, `glm_rotate` are pre functions and are similar to C++ **glm** which you are familiar with. In new versions of **cglm** we added `glm_translated`, `glm_rotated`... which are post functions, they are useful in some cases, e.g. append transform to existing transform (apply/append transform as last transform T' = T * Tnew). Post functions are named after pre functions with `ed` suffix, e.g. `glm_translate` -> `glm_translated`. So don't mix them up. Initialize Transform Matrices ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Functions with **_make** prefix expect you don't have a matrix and they create a matrix for you. You don't need to pass identity matrix. But other functions expect you have a matrix and you want to transform them. If you didn't have any existing matrix you have to initialize matrix to identity before sending to transform functions. There are also functions to decompose transform matrix. These functions can't decompose matrix after projected. Rotation Center ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Rotating functions uses origin as rotation center (pivot/anchor point), since scale factors are stored in rotation matrix, same may also true for scalling. cglm provides some functions for rotating around at given point e.g. **glm_rotate_at**, **glm_quat_rotate_at**. Use them or follow next section for algorithm ("Rotate or Scale around specific Point (Pivot Point / Anchor Point)"). Also **cglm** provides :c:func:`glm_spin` and :c:func:`glm_spinned` functions to rotate around itself. No need to give pivot. These functions are useful for rotating around center of object. Rotate or Scale around specific Point (Anchor Point) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ If you want to rotate model around arbitrary point follow these steps: 1. Move model from pivot point to origin: **translate(-pivot.x, -pivot.y, -pivot.z)** 2. Apply rotation (or scaling maybe) 3. Move model back from origin to pivot (reverse of step-1): **translate(pivot.x, pivot.y, pivot.z)** **glm_rotate_at**, **glm_quat_rotate_at** and their helper functions works that way. So if you use them you don't need to do these steps manually which are done by **cglm**. The implementation would be: .. code-block:: c :linenos: glm_translate(m, pivot); glm_rotate(m, angle, axis); glm_translate(m, pivotInv); /* pivotInv = -pivot */ or just: .. code-block:: c :linenos: glm_rotate_at(m, pivot, angle, axis); .. _TransformsOrder: Transforms Order ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ It is important to understand this part especially if you call transform functions multiple times `glm_translate`, `glm_rotate`, `glm_scale` and `glm_quat_rotate` and their helpers functions works like this (cglm provides reverse order as `ed` suffix e.g `glm_translated`, `glm_rotated` see post transforms): .. code-block:: c :linenos: TransformMatrix = TransformMatrix * TranslateMatrix; // glm_translate() TransformMatrix = TransformMatrix * RotateMatrix; // glm_rotate(), glm_quat_rotate() TransformMatrix = TransformMatrix * ScaleMatrix; // glm_scale() As you can see it is multiplied as right matrix. For instance what will happen if you call `glm_translate` twice? .. code-block:: c :linenos: glm_translate(transform, translate1); /* transform = transform * translate1 */ glm_translate(transform, translate2); /* transform = transform * translate2 */ glm_rotate(transform, angle, axis) /* transform = transform * rotation */ Now lets try to understand this: 1. You call translate using `translate1` and you expect it will be first transform because you call it first, do you? Result will be **`transform = transform * translate1`** 2. Then you call translate using `translate2` and you expect it will be second transform? Result will be **`transform = transform * translate2`**. Now lets expand transform, it was `transform * translate1` before second call. Now it is **`transform = transform * translate1 * translate2`**, now do you understand what I say? 3. After last call transform will be: **`transform = transform * translate1 * translate2 * rotation`** The order will be; **rotation will be applied first**, then **translate2** then **translate1** It is all about matrix multiplication order. It is similar to MVP matrix: `MVP = Projection * View * Model`, model will be applied first, then view then projection. **Confused?** In the end the last function call applied first in shaders. As alternative way, you can create transform matrices individually then combine manually, but don't forget that `glm_translate`, `glm_rotate`, `glm_scale`... are optimized and should be faster (an smaller assembly output) than manual multiplication .. code-block:: c :linenos: mat4 transform1, transform2, transform3, finalTransform; glm_translate_make(transform1, translate1); glm_translate_make(transform2, translate2); glm_rotate_make(transform3, angle, axis); /* first apply transform1, then transform2, thentransform3 */ glm_mat4_mulN((mat4 *[]){&transform3, &transform2, &transform1}, 3, finalTransform); /* if you don't want to use mulN, same as above */ glm_mat4_mul(transform3, transform2, finalTransform); glm_mat4_mul(finalTransform, transform1, finalTransform); Now transform1 will be applied first, then transform2 then transform3 Table of contents (click to go): ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Functions: 1. :c:func:`glm_translate_to` #. :c:func:`glm_translate` #. :c:func:`glm_translate_x` #. :c:func:`glm_translate_y` #. :c:func:`glm_translate_z` #. :c:func:`glm_translate_make` #. :c:func:`glm_scale_to` #. :c:func:`glm_scale_make` #. :c:func:`glm_scale` #. :c:func:`glm_scale_uni` #. :c:func:`glm_rotate_x` #. :c:func:`glm_rotate_y` #. :c:func:`glm_rotate_z` #. :c:func:`glm_rotate_make` #. :c:func:`glm_rotate` #. :c:func:`glm_rotate_at` #. :c:func:`glm_rotate_atm` #. :c:func:`glm_decompose_scalev` #. :c:func:`glm_uniscaled` #. :c:func:`glm_decompose_rs` #. :c:func:`glm_decompose` Post functions (**NEW**): 1. :c:func:`glm_translated_to` #. :c:func:`glm_translated` #. :c:func:`glm_translated_x` #. :c:func:`glm_translated_y` #. :c:func:`glm_translated_z` #. :c:func:`glm_rotated_x` #. :c:func:`glm_rotated_y` #. :c:func:`glm_rotated_z` #. :c:func:`glm_rotated` #. :c:func:`glm_rotated_at` #. :c:func:`glm_spinned` Functions documentation ~~~~~~~~~~~~~~~~~~~~~~~ .. toctree:: :maxdepth: 1 :caption: Affine categories: affine-common affine-pre affine-post cglm-0.9.6/docs/source/affine2d.rst000066400000000000000000000104521475344456400171320ustar00rootroot00000000000000.. default-domain:: C 2D Affine Transforms ================================================================================ Header: cglm/affine2d.h 2D Transforms uses `2d` suffix for naming. If there is no 2D suffix it is 3D function. Initialize Transform Matrices ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Functions with **_make** prefix expect you don't have a matrix and they create a matrix for you. You don't need to pass identity matrix. But other functions expect you have a matrix and you want to transform them. If you didn't have any existing matrix you have to initialize matrix to identity before sending to transform functions. Transforms Order ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ See :ref:`TransformsOrder` to read similar section. Table of contents (click to go): ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Functions: 1. :c:func:`glm_translate2d` #. :c:func:`glm_translate2d_to` #. :c:func:`glm_translate2d_x` #. :c:func:`glm_translate2d_y` #. :c:func:`glm_translate2d_make` #. :c:func:`glm_scale2d_to` #. :c:func:`glm_scale2d_make` #. :c:func:`glm_scale2d` #. :c:func:`glm_scale2d_uni` #. :c:func:`glm_rotate2d_make` #. :c:func:`glm_rotate2d` #. :c:func:`glm_rotate2d_to` .. c:function:: void glm_translate2d(mat3 m, vec2 v) translate existing 2d transform matrix by *v* vector and stores result in same matrix Parameters: | *[in, out]* **m** 2d affine transform | *[in]* **v** translate vector [x, y] .. c:function:: void glm_translate2d_to(mat3 m, vec2 v, mat3 dest) translate existing 2d transform matrix by *v* vector and store result in dest Parameters: | *[in]* **m** 2d affine transform | *[in]* **v** translate vector [x, y] | *[out]* **dest** translated matrix .. c:function:: void glm_translate2d_x(mat3 m, float x) translate existing 2d transform matrix by x factor Parameters: | *[in, out]* **m** 2d affine transform | *[in]* **x** x factor .. c:function:: void glm_translate2d_y(mat3 m, float y) translate existing 2d transform matrix by y factor Parameters: | *[in, out]* **m** 2d affine transform | *[in]* **y** y factor .. c:function:: void glm_translate2d_make(mat3 m, vec2 v) creates NEW translate 2d transform matrix by *v* vector Parameters: | *[in, out]* **m** affine transform | *[in]* **v** translate vector [x, y] .. c:function:: void glm_scale2d_to(mat3 m, vec2 v, mat3 dest) scale existing 2d transform matrix by *v* vector and store result in dest Parameters: | *[in]* **m** affine transform | *[in]* **v** scale vector [x, y] | *[out]* **dest** scaled matrix .. c:function:: void glm_scale2d_make(mat3 m, vec2 v) creates NEW 2d scale matrix by *v* vector Parameters: | *[in, out]* **m** affine transform | *[in]* **v** scale vector [x, y] .. c:function:: void glm_scale2d(mat3 m, vec2 v) scales existing 2d transform matrix by *v* vector and stores result in same matrix Parameters: | *[in, out]* **m** affine transform | *[in]* **v** translate vector [x, y] .. c:function:: void glm_scale2d_uni(mat3 m, float s) applies uniform scale to existing 2d transform matrix v = [s, s] and stores result in same matrix Parameters: | *[in, out]* **m** affine transform | *[in]* **s** scale factor .. c:function:: void glm_rotate2d_make(mat3 m, float angle) creates NEW rotation matrix by angle around *Z* axis Parameters: | *[in, out]* **m** affine transform | *[in]* **angle** angle (radians) .. c:function:: void glm_rotate2d(mat3 m, float angle) rotate existing 2d transform matrix around *Z* axis by angle and store result in same matrix Parameters: | *[in, out]* **m** affine transform | *[in]* **angle** angle (radians) .. c:function:: void glm_rotate2d_to(mat3 m, float angle, mat3 dest) rotate existing 2d transform matrix around *Z* axis by angle and store result in dest Parameters: | *[in]* **m** affine transform | *[in]* **angle** angle (radians) | *[out]* **dest** rotated matrixcglm-0.9.6/docs/source/api.rst000066400000000000000000000025571475344456400162340ustar00rootroot00000000000000📚 API documentation ================================ **cglm** provides a few APIs for similar functions. * 📦 **Inline API**: All functions are inline. You can include **cglm/cglm.h** header to use this API. This is the default API. `glm_` is namespace/prefix for this API. * 📦 **Call API**: All functions are not inline. You need to build *cglm* and link it to your project. You can include **cglm/call.h** header to use this API. `glmc_` is namespace/prefix for this API. And also there are also sub categories: * 📦 **Array API**: Types are raw arrays and functions takes array as argument. You can include **cglm/cglm.h** header to use this API. This is the default API. `glm_` is namespace/prefix for this API. * 📦 **Struct API**: Types are union/struct and functions takes struct as argument and return structs if needed. You can include **cglm/struct.h** header to use this API. This also includes **cglm/cglm.h** header.`glms_` is namespace/prefix for this API but your can omit or change it, see struct api docs. * 📦 **SIMD API**: SIMD functions and helpers. `glmm_` is namespace/prefix for this API. 📌 Since struct api and call api are built top of inline array api, follow inline array api docs for individual functions. .. toctree:: :maxdepth: 1 :caption: API documentations: api_inline_array api_struct api_call api_simd cglm-0.9.6/docs/source/api_call.rst000066400000000000000000000010031475344456400172100ustar00rootroot00000000000000Call API ================================ Call API is pre-built API for making calls from library. It is built on top of the array api. **glmc_** is the namespace for the call api. **c** stands for call. You need to built cglm to use call api. See build instructions (:doc:`build`) for more details. The functions except namespace **glmc_** are same as inline api. See ( :doc:`api_inline_array` ) for more details. 📌 In the future we can define option to forward inline functions or struct api to call api.cglm-0.9.6/docs/source/api_inline_array.rst000066400000000000000000000042211475344456400207560ustar00rootroot00000000000000Array API - Inline (Default) ======================================== This is the default API of *cglm*. All functions are forced to be inlined and struct api, call api uses this inline api to share implementation. 📌 Call api is also array api but it is not inlined. In the future there may be option to forward struct api to call api instead of inline api to reduce binary size if needed. 📌 **USE this API docs for similar functions in struct and call api** 📌 In struct api you can omit namespace e.g :code:`glms_vec3_dot` can be called as :code:`vec3_dot` in struct api, see :doc:`api_struct` to configure struct api for more details. 📌 In struct api functions can return struct/union 📌 In struct api you can access items like **.x**, **.y**, **.z**, **.w**, **.r**, **.g**, **.b**, **.a**, **.m00**, **m01**... Some functions may exist twice, once for their namespace and once for global namespace to make easier to write very common functions For instance, in general we use :code:`glm_vec3_dot` to get dot product of two **vec3**. Now we can also do this with :code:`glm_dot`, same for *_cross* and so on... The original function stays where it is, the function in global namespace of same name is just an alias, so there is no call version of those functions. e.g there is no func like :code:`glmc_dot` because *glm_dot* is just alias for :code:`glm_vec3_dot` By including **cglm/cglm.h** header you will include all inline version of functions. Since functions in this header[s] are inline you don't need to build or link *cglm* against your project. But by including **cglm/call.h** header you will include all *non-inline* version of functions. You need to build *cglm* and link it. Follow the :doc:`build` documentation for this .. toctree:: :maxdepth: 1 :caption: API categories: affine affine-mat affine2d cam frustum box aabb2d quat euler mat2 mat2x3 mat2x4 mat3 mat3x2 mat3x4 mat4 mat4x2 mat4x3 vec2 vec2-ext vec3 vec3-ext vec4 vec4-ext ivec2 ivec3 ivec4 color plane noise project util io call sphere curve bezier version ray cglm-0.9.6/docs/source/api_simd.rst000066400000000000000000000005521475344456400172410ustar00rootroot00000000000000SIMD API ================================ SIMD api is special api for SIMD operations. **glmm_** prefix is used for SIMD operations in cglm. It is used in many places in cglm. You can use it for your own SIMD operations too. In the future the api may be extended by time. Supported SIMD architectures ( may vary by time ) * SSE / SSE2 * AVX * NEON * WASM 128 cglm-0.9.6/docs/source/api_struct.rst000066400000000000000000000103371475344456400176330ustar00rootroot00000000000000Struct API ================================ Struct API is alternative API to array api to use **cglm** with improved type safety and easy to use. Since struct api is built top of array api, every struct API is not documented here. See array api documentation for more information for individual functions. By default struct api adds `s` suffix to every type name e.g. vec3s, mat4s, versors etc. Also struct api `s` suffix to namespace e.g. `glms_vec3_add`, `glms_mat4_mul` etc. By starting v0.9.0, struct api namespace is configurable. We can omit **glms_** namespace or even change it with custom name to move existing api integrations to **cglm** more easily... We can also add **s** to function names if we want e.g. `glms_vec3_add()` -> `vec3_add()` or `vec3s_add()`. By including **cglm/struct.h** header you will include all struct api. It will also include **cglm/cglm.h** too. Since struct apis are inline you don't need to build or link *cglm* against your project unless if you want to use pre-built call-api too. Struct API is built top of array api. So you can mix them. Use **.raw** union member to access raw array data to use it with array api. Unlike array api ([0], [1], [0][0] ...), it is also possible to use struct api with **.x**, **.y**, **.z**, **.w**, **.r**, **.g**, **.b**, **.a**, **.m00**, **m01**... accessors to access individual elements/properties of vectors and matrices. Struct API usage: ----------------- .. code-block:: c #include mat4s m1 = glms_mat4_identity(); /* init... */ mat4s m2 = glms_mat4_identity(); /* init... */ mat4s m3 = glms_mat4_mul(glms_mat4_mul(m1, m2), glms_mat4_mul(m3, m4)); vec3s v1 = { 1.0f, 0.0f, 0.0f }; vec3s v2 = { 0.0f, 1.0f, 0.0f }; vec4s v4 = { 0.0f, 1.0f, 0.0f, 0.0f }; vec4 v5a = { 0.0f, 1.0f, 0.0f, 0.0f }; mat4s m4 = glms_rotate(m3, M_PI_2, glms_vec3_cross(glms_vec3_add(v1, v6) glms_vec3_add(v1, v7))); v1.x = 1.0f; v1.y = 0.0f; v1.z = 0.0f; // or v1.raw[0] = 1.0f; v1.raw[1] = 0.0f; v1.raw[2] = 0.0f; /* use struct api with array api (mix them). */ /* use .raw to access array and use it with array api */ glm_vec4_add(m4.col[0].raw, v5a, m4.col[0].raw); glm_mat4_mulv(m4.raw, v4.raw, v5a); or omit `glms_` namespace completely (see options below): .. code-block:: c #define CGLM_OMIT_NS_FROM_STRUCT_API #include mat4s m1 = mat4_identity(); /* init... */ mat4s m2 = mat4_identity(); /* init... */ mat4s m3 = mat4_mul(mat4_mul(m1, m2), mat4_mul(m3, m4)); vec3s v1 = { 1.0f, 0.0f, 0.0f }; vec3s v2 = { 0.0f, 1.0f, 0.0f }; vec4s v4 = { 0.0f, 1.0f, 0.0f, 0.0f }; vec4 v5a = { 0.0f, 1.0f, 0.0f, 0.0f }; mat4s m4 = glms_rotate(m3, M_PI_2, vec3_cross(vec3_add(v1, v6) vec3_add(v1, v7))); v1.x = 1.0f; v1.y = 0.0f; v1.z = 0.0f; // or v1.raw[0] = 1.0f; v1.raw[1] = 0.0f; v1.raw[2] = 0.0f; /* use struct api with array api (mix them) */ glm_vec4_add(m4.col[0].raw, v5a, m4.col[0].raw); glm_mat4_mulv(m4.raw, v4.raw, v5a); Configuring the Struct API: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ To configure the Struct API namespace, you can define the following macros before including the cglm/struct.h header: - **CGLM_OMIT_NS_FROM_STRUCT_API**: omits CGLM_STRUCT_API_NS (`glms_`) namespace completely if there is sub namespace e.g `mat4_`, `vec4_` ... DEFAULT is not defined - **CGLM_STRUCT_API_NS**: define name space for struct api, DEFAULT is **glms** - **CGLM_STRUCT_API_NAME_SUFFIX**: define name suffix, DEFAULT is **empty** e.g defining it as #define CGLM_STRUCT_API_NAME_SUFFIX s will add s suffix to mat4_mul -> mat4s_mul ❗️ IMPORTANT ❗️ It's a good idea to set up your config macros in build settings like CMake, Xcode, or Visual Studio. This is especially important if you're using features like Modules in Xcode, where adding macros directly before the **cglm** headers might not work. Detailed documentation for Struct API: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Since struct api if built top of array api, see array api functions for more information about individual functions. cglm-0.9.6/docs/source/bezier.rst000066400000000000000000000042251475344456400167350ustar00rootroot00000000000000.. default-domain:: C Bezier ================================================================================ Header: cglm/bezier.h Common helpers for cubic bezier and similar curves. Table of contents (click to go): ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Functions: 1. :c:func:`glm_bezier` 2. :c:func:`glm_hermite` 3. :c:func:`glm_decasteljau` Functions documentation ~~~~~~~~~~~~~~~~~~~~~~~ .. c:function:: float glm_bezier(float s, float p0, float c0, float c1, float p1) | cubic bezier interpolation | formula: .. code-block:: text B(s) = P0*(1-s)^3 + 3*C0*s*(1-s)^2 + 3*C1*s^2*(1-s) + P1*s^3 | similar result using matrix: .. code-block:: text B(s) = glm_smc(t, GLM_BEZIER_MAT, (vec4){p0, c0, c1, p1}) | glm_eq(glm_smc(...), glm_bezier(...)) should return TRUE Parameters: | *[in]* **s** parameter between 0 and 1 | *[in]* **p0** begin point | *[in]* **c0** control point 1 | *[in]* **c1** control point 2 | *[in]* **p1** end point Returns: B(s) .. c:function:: float glm_hermite(float s, float p0, float t0, float t1, float p1) | cubic hermite interpolation | formula: .. code-block:: text H(s) = P0*(2*s^3 - 3*s^2 + 1) + T0*(s^3 - 2*s^2 + s) + P1*(-2*s^3 + 3*s^2) + T1*(s^3 - s^2) | similar result using matrix: .. code-block:: text H(s) = glm_smc(t, GLM_HERMITE_MAT, (vec4){p0, p1, c0, c1}) | glm_eq(glm_smc(...), glm_hermite(...)) should return TRUE Parameters: | *[in]* **s** parameter between 0 and 1 | *[in]* **p0** begin point | *[in]* **t0** tangent 1 | *[in]* **t1** tangent 2 | *[in]* **p1** end point Returns: B(s) .. c:function:: float glm_decasteljau(float prm, float p0, float c0, float c1, float p1) | iterative way to solve cubic equation Parameters: | *[in]* **prm** parameter between 0 and 1 | *[in]* **p0** begin point | *[in]* **c0** control point 1 | *[in]* **c1** control point 2 | *[in]* **p1** end point Returns: parameter to use in cubic equation cglm-0.9.6/docs/source/box.rst000066400000000000000000000122371475344456400162470ustar00rootroot00000000000000.. default-domain:: C axis aligned bounding box (AABB) ================================================================================ Header: cglm/box.h Some convenient functions provided for AABB. **Definition of box:** cglm defines box as two dimensional array of vec3. The first element is **min** point and the second one is **max** point. If you have another type e.g. struct or even another representation then you must convert it before and after call cglm box function. Table of contents (click to go): ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Functions: 1. :c:func:`glm_aabb_transform` #. :c:func:`glm_aabb_merge` #. :c:func:`glm_aabb_crop` #. :c:func:`glm_aabb_crop_until` #. :c:func:`glm_aabb_frustum` #. :c:func:`glm_aabb_invalidate` #. :c:func:`glm_aabb_isvalid` #. :c:func:`glm_aabb_size` #. :c:func:`glm_aabb_radius` #. :c:func:`glm_aabb_center` #. :c:func:`glm_aabb_aabb` #. :c:func:`glm_aabb_sphere` #. :c:func:`glm_aabb_point` #. :c:func:`glm_aabb_contains` Functions documentation ~~~~~~~~~~~~~~~~~~~~~~~ .. c:function:: void glm_aabb_transform(vec3 box[2], mat4 m, vec3 dest[2]) | apply transform to Axis-Aligned Bounding Box Parameters: | *[in]* **box** bounding box | *[in]* **m** transform matrix | *[out]* **dest** transformed bounding box .. c:function:: void glm_aabb_merge(vec3 box1[2], vec3 box2[2], vec3 dest[2]) | 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 Parameters: | *[in]* **box1** bounding box 1 | *[in]* **box2** bounding box 2 | *[out]* **dest** merged bounding box .. c:function:: void glm_aabb_crop(vec3 box[2], vec3 cropBox[2], vec3 dest[2]) | crops a bounding box with another one. this could be useful for getting a bbox which fits with view frustum and object bounding boxes. In this case you crop view frustum box with objects box Parameters: | *[in]* **box** bounding box 1 | *[in]* **cropBox** crop box | *[out]* **dest** cropped bounding box .. c:function:: void glm_aabb_crop_until(vec3 box[2], vec3 cropBox[2], vec3 clampBox[2], vec3 dest[2]) | crops a bounding box with another one. this could be useful for getting a bbox which fits with view frustum and object bounding boxes. In this case you crop view frustum box with objects box Parameters: | *[in]* **box** bounding box | *[in]* **cropBox** crop box | *[in]* **clampBox** minimum box | *[out]* **dest** cropped bounding box .. c:function:: bool glm_aabb_frustum(vec3 box[2], vec4 planes[6]) | check if AABB intersects with frustum planes this could be useful for frustum culling using AABB. OPTIMIZATION HINT: if planes order is similar to LEFT, RIGHT, BOTTOM, TOP, NEAR, FAR then this method should run even faster because it would only use two planes if object is not inside the two planes fortunately cglm extracts planes as this order! just pass what you got! Parameters: | *[in]* **box** bounding box | *[out]* **planes** frustum planes .. c:function:: void glm_aabb_invalidate(vec3 box[2]) | invalidate AABB min and max values | It fills *max* values with -FLT_MAX and *min* values with +FLT_MAX Parameters: | *[in, out]* **box** bounding box .. c:function:: bool glm_aabb_isvalid(vec3 box[2]) | check if AABB is valid or not Parameters: | *[in]* **box** bounding box Returns: returns true if aabb is valid otherwise false .. c:function:: float glm_aabb_size(vec3 box[2]) | distance between of min and max Parameters: | *[in]* **box** bounding box Returns: distance between min - max .. c:function:: float glm_aabb_radius(vec3 box[2]) | radius of sphere which surrounds AABB Parameters: | *[in]* **box** bounding box .. c:function:: void glm_aabb_center(vec3 box[2], vec3 dest) | computes center point of AABB Parameters: | *[in]* **box** bounding box | *[out]* **dest** center of bounding box .. c:function:: bool glm_aabb_aabb(vec3 box[2], vec3 other[2]) | check if two AABB intersects Parameters: | *[in]* **box** bounding box | *[out]* **other** other bounding box .. c:function:: bool glm_aabb_sphere(vec3 box[2], vec4 s) | check if AABB intersects with sphere | https://github.com/erich666/GraphicsGems/blob/master/gems/BoxSphere.c | Solid Box - Solid Sphere test. Parameters: | *[in]* **box** solid bounding box | *[out]* **s** solid sphere .. c:function:: bool glm_aabb_point(vec3 box[2], vec3 point) | check if point is inside of AABB Parameters: | *[in]* **box** bounding box | *[out]* **point** point .. c:function:: bool glm_aabb_contains(vec3 box[2], vec3 other[2]) | check if AABB contains other AABB Parameters: | *[in]* **box** bounding box | *[out]* **other** other bounding box cglm-0.9.6/docs/source/build.rst000066400000000000000000000073241475344456400165570ustar00rootroot00000000000000Build cglm ================================ | **cglm** does not have any external dependencies. .. note:: If you only need to inline versions, you don't need to build **cglm**, you don't need to link it to your program. Just import cglm to your project as dependency / external lib by copy-paste then use it as usual CMake (All platforms): ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .. code-block:: bash :linenos: $ mkdir build $ cd build $ cmake .. # [Optional] -DCGLM_SHARED=ON $ make $ sudo make install # [Optional] **make** will build cglm to **build** folder. If you don't want to install **cglm** to your system's folder you can get static and dynamic libs in this folder. **CMake Options:** .. code-block:: CMake :linenos: option(CGLM_SHARED "Shared build" ON) option(CGLM_STATIC "Static build" OFF) option(CGLM_USE_C99 "" OFF) # C11 option(CGLM_USE_TEST "Enable Tests" OFF) # for make check - make test **Use as header-only library with your CMake project example** This requires no building or installation of cglm. .. code-block:: CMake :linenos: cmake_minimum_required(VERSION 3.8.2) project() add_executable(${PROJECT_NAME} src/main.c) target_link_libraries(${LIBRARY_NAME} PRIVATE cglm_headers) add_subdirectory(external/cglm/ EXCLUDE_FROM_ALL) **Use with your CMake project example** .. code-block:: CMake :linenos: cmake_minimum_required(VERSION 3.8.2) project() add_executable(${PROJECT_NAME} src/main.c) target_link_libraries(${LIBRARY_NAME} PRIVATE cglm) add_subdirectory(external/cglm/) Meson (All platforms): ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .. code-block:: :linenos: $ meson build # [Optional] --default-library=static $ cd build $ ninja $ sudo ninja install # [Optional] **Meson Options:** .. code-block:: :linenos: c_std=c11 buildtype=release default_library=shared enable_tests=false # to run tests: ninja test **Use with your Meson project** .. code-block:: :linenos: # Clone cglm or create a cglm.wrap under /subprojects project('name', 'c') cglm_dep = dependency('cglm', fallback : 'cglm', 'cglm_dep') executable('exe', 'src/main.c', dependencies : cglm_dep) Unix (Autotools): ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .. code-block:: bash :linenos: $ sh autogen.sh $ ./configure $ make $ make check # run tests (optional) $ [sudo] make install # install to system (optional) **make** will build cglm to **.libs** sub folder in project folder. If you don't want to install **cglm** to your system's folder you can get static and dynamic libs in this folder. Windows (MSBuild): ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Windows related build files, project files are located in `win` folder, make sure you are inside in cglm/win folder. Code Analysis are enabled, it may take awhile to build. .. code-block:: bash :linenos: $ cd win $ .\build.bat if *msbuild* is not worked (because of multi versions of Visual Studio) then try to build with *devenv*: .. code-block:: bash :linenos: $ devenv cglm.sln /Build Release Currently tests are not available on Windows. Documentation (Sphinx): ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ **cglm** uses sphinx framework for documentation, it allows lot of formats for documentation. To see all options see sphinx build page: https://www.sphinx-doc.org/en/master/man/sphinx-build.html Example build: .. code-block:: bash :linenos: $ cd cglm/docs $ sphinx-build source build cglm-0.9.6/docs/source/call.rst000066400000000000000000000014071475344456400163670ustar00rootroot00000000000000.. default-domain:: C precompiled functions (call) ================================================================================ All functions in **glm_** namespace are forced to **inline**. Most functions also have pre-compiled version. Precompiled versions are in **glmc_** namespace. *c* in the namespace stands for "call". Since precompiled functions are just wrapper for inline versions, these functions are not documented individually. It would be duplicate documentation also it would be hard to sync documentation between inline and call version for me. By including **clgm/cglm.h** you include all inline versions. To get precompiled versions you need to include **cglm/call.h** header it also includes all call versions plus *clgm/cglm.h* (inline versions) cglm-0.9.6/docs/source/cam.rst000066400000000000000000000242621475344456400162200ustar00rootroot00000000000000.. default-domain:: C camera ====== Header: cglm/cam.h There are many convenient functions for camera. For instance :c:func:`glm_look` is just wrapper for :c:func:`glm_lookat`. Sometimes you only have direction instead of target, so that makes easy to build view matrix using direction. There is also :c:func:`glm_look_anyup` function which can help build view matrix without providing UP axis. It uses :c:func:`glm_vec3_ortho` to get a UP axis and builds view matrix. You can also *_default* versions of ortho and perspective to build projection fast if you don't care specific projection values. *_decomp* means decompose; these function can help to decompose projection matrices. .. note:: Be careful when working with high range (very small near, very large far) projection matrices. You may not get exact value you gave. **float** type cannot store very high precision so you will lose precision. Also your projection matrix will be inaccurate due to losing precision Table of contents (click to go): ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Functions: 1. :c:func:`glm_frustum` #. :c:func:`glm_ortho` #. :c:func:`glm_ortho_aabb` #. :c:func:`glm_ortho_aabb_p` #. :c:func:`glm_ortho_aabb_pz` #. :c:func:`glm_ortho_default` #. :c:func:`glm_ortho_default_s` #. :c:func:`glm_perspective` #. :c:func:`glm_persp_move_far` #. :c:func:`glm_perspective_default` #. :c:func:`glm_perspective_resize` #. :c:func:`glm_lookat` #. :c:func:`glm_look` #. :c:func:`glm_look_anyup` #. :c:func:`glm_persp_decomp` #. :c:func:`glm_persp_decompv` #. :c:func:`glm_persp_decomp_x` #. :c:func:`glm_persp_decomp_y` #. :c:func:`glm_persp_decomp_z` #. :c:func:`glm_persp_decomp_far` #. :c:func:`glm_persp_decomp_near` #. :c:func:`glm_persp_fovy` #. :c:func:`glm_persp_aspect` #. :c:func:`glm_persp_sizes` Functions documentation ~~~~~~~~~~~~~~~~~~~~~~~ .. c:function:: void glm_frustum(float left, float right, float bottom, float top, float nearVal, float farVal, mat4 dest) | set up perspective peprojection matrix Parameters: | *[in]* **left** viewport.left | *[in]* **right** viewport.right | *[in]* **bottom** viewport.bottom | *[in]* **top** viewport.top | *[in]* **nearVal** near clipping plane | *[in]* **farVal** far clipping plane | *[out]* **dest** result matrix .. c:function:: void glm_ortho(float left, float right, float bottom, float top, float nearVal, float farVal, mat4 dest) | set up orthographic projection matrix Parameters: | *[in]* **left** viewport.left | *[in]* **right** viewport.right | *[in]* **bottom** viewport.bottom | *[in]* **top** viewport.top | *[in]* **nearVal** near clipping plane | *[in]* **farVal** far clipping plane | *[out]* **dest** result matrix .. c:function:: void glm_ortho_aabb(vec3 box[2], mat4 dest) | set up orthographic projection matrix using bounding box | bounding box (AABB) must be in view space Parameters: | *[in]* **box** AABB | *[in]* **dest** result matrix .. c:function:: void glm_ortho_aabb_p(vec3 box[2], float padding, mat4 dest) | set up orthographic projection matrix using bounding box | bounding box (AABB) must be in view space this version adds padding to box Parameters: | *[in]* **box** AABB | *[in]* **padding** padding | *[out]* **dest** result matrix .. c:function:: void glm_ortho_aabb_pz(vec3 box[2], float padding, mat4 dest) | set up orthographic projection matrix using bounding box | bounding box (AABB) must be in view space this version adds Z padding to box Parameters: | *[in]* **box** AABB | *[in]* **padding** padding for near and far | *[out]* **dest** result matrix Returns: square of norm / magnitude .. c:function:: void glm_ortho_default(float aspect, mat4 dest) | set up unit orthographic projection matrix Parameters: | *[in]* **aspect** aspect ration ( width / height ) | *[out]* **dest** result matrix .. c:function:: void glm_ortho_default_s(float aspect, float size, mat4 dest) | set up orthographic projection matrix with given CUBE size Parameters: | *[in]* **aspect** aspect ration ( width / height ) | *[in]* **size** cube size | *[out]* **dest** result matrix .. c:function:: void glm_perspective(float fovy, float aspect, float nearVal, float farVal, mat4 dest) | set up perspective projection matrix Parameters: | *[in]* **fovy** field of view angle (in radians) | *[in]* **aspect** aspect ratio ( width / height ) | *[in]* **nearVal** near clipping plane | *[in]* **farVal** far clipping planes | *[out]* **dest** result matrix .. c:function:: void glm_persp_move_far(mat4 proj, float deltaFar) | extend perspective projection matrix's far distance | this function does not guarantee far >= near, be aware of that! Parameters: | *[in, out]* **proj** projection matrix to extend | *[in]* **deltaFar** distance from existing far (negative to shink) .. c:function:: void glm_perspective_default(float aspect, mat4 dest) | set up perspective projection matrix with default near/far and angle values Parameters: | *[in]* **aspect** aspect aspect ratio ( width / height ) | *[out]* **dest** result matrix .. c:function:: void glm_perspective_resize(float aspect, mat4 proj) | resize perspective matrix by aspect ratio ( width / height ) this makes very easy to resize proj matrix when window / viewport reized Parameters: | *[in]* **aspect** aspect ratio ( width / height ) | *[in, out]* **proj** perspective projection matrix .. c:function:: void glm_lookat(vec3 eye, vec3 center, vec3 up, mat4 dest) | set up view matrix .. note:: The UP vector must not be parallel to the line of sight from the eye point to the reference point. Parameters: | *[in]* **eye** eye vector | *[in]* **center** center vector | *[in]* **up** up vector | *[out]* **dest** result matrix .. c:function:: void glm_look(vec3 eye, vec3 dir, vec3 up, mat4 dest) | set up view matrix convenient wrapper for :c:func:`glm_lookat`: if you only have direction not target self then this might be useful. Because you need to get target from direction. .. note:: The UP vector must not be parallel to the line of sight from the eye point to the reference point. Parameters: | *[in]* **eye** eye vector | *[in]* **dir** direction vector | *[in]* **up** up vector | *[out]* **dest** result matrix .. c:function:: void glm_look_anyup(vec3 eye, vec3 dir, mat4 dest) | set up view matrix convenient wrapper for :c:func:`glm_look` if you only have direction and if you don't care what UP vector is then this might be useful to create view matrix Parameters: | *[in]* **eye** eye vector | *[in]* **dir** direction vector | *[out]* **dest** result matrix .. c:function:: void glm_persp_decomp(mat4 proj, float *nearVal, float *farVal, float *top, float *bottom, float *left, float *right) | decomposes frustum values of perspective projection. Parameters: | *[in]* **eye** perspective projection matrix | *[out]* **nearVal** near | *[out]* **farVal** far | *[out]* **top** top | *[out]* **bottom** bottom | *[out]* **left** left | *[out]* **right** right .. c:function:: void glm_persp_decompv(mat4 proj, float dest[6]) | decomposes frustum values of perspective projection. | this makes easy to get all values at once Parameters: | *[in]* **proj** perspective projection matrix | *[out]* **dest** array .. c:function:: void glm_persp_decomp_x(mat4 proj, float *left, float *right) | decomposes left and right values of perspective projection. | x stands for x axis (left / right axis) Parameters: | *[in]* **proj** perspective projection matrix | *[out]* **left** left | *[out]* **right** right .. c:function:: void glm_persp_decomp_y(mat4 proj, float *top, float *bottom) | decomposes top and bottom values of perspective projection. | y stands for y axis (top / bottom axis) Parameters: | *[in]* **proj** perspective projection matrix | *[out]* **top** top | *[out]* **bottom** bottom .. c:function:: void glm_persp_decomp_z(mat4 proj, float *nearVal, float *farVal) | decomposes near and far values of perspective projection. | z stands for z axis (near / far axis) Parameters: | *[in]* **proj** perspective projection matrix | *[out]* **nearVal** near | *[out]* **farVal** far .. c:function:: void glm_persp_decomp_far(mat4 proj, float * __restrict farVal) | decomposes far value of perspective projection. Parameters: | *[in]* **proj** perspective projection matrix | *[out]* **farVal** far .. c:function:: void glm_persp_decomp_near(mat4 proj, float * __restrict nearVal) | decomposes near value of perspective projection. Parameters: | *[in]* **proj** perspective projection matrix | *[out]* **nearVal** near .. c:function:: float glm_persp_fovy(mat4 proj) | returns field of view angle along the Y-axis (in radians) if you need to degrees, use glm_deg to convert it or use this: fovy_deg = glm_deg(glm_persp_fovy(projMatrix)) Parameters: | *[in]* **proj** perspective projection matrix Returns: | fovy in radians .. c:function:: float glm_persp_aspect(mat4 proj) | returns aspect ratio of perspective projection Parameters: | *[in]* **proj** perspective projection matrix .. c:function:: void glm_persp_sizes(mat4 proj, float fovy, vec4 dest) | returns sizes of near and far planes of perspective projection Parameters: | *[in]* **proj** perspective projection matrix | *[in]* **fovy** fovy (see brief) | *[out]* **dest** sizes order: [Wnear, Hnear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Cұ؛WC}+RoB#iJ)Rg!"Z_HᶩL@G굊yJNh=;O!\n_tC}xd%r"NljM@t2SDv !:3E儚@\Rs,D !Y\:KN^r z1HS! _uy=hUDʶv5)O@l2Q~Xm[W. jGa|xm/ohlؘ@.pRsM4yyYzu6y?Է-x\J4 ~wmؚ$G@EZ5zIbZ%wpg>Oe$g0005 d봱ujJO MnЮK]?B4[a:(0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000T LLL1ح_AyWR_;™%qⴕ TKbhAӂ5ݩCuftqvׅ V&oLL Wv0000J/(.8yT%RS+P+ &.M 95,v&H|W-vpJuP_Cdj&`&`&`&`&`u%`;D v]+ d?rQLL?~| +**EaaQF|#ruIQfiA9Y&`YE+É107k֬)ԩӉ( E{ 7nlcYJynzzĉp#Kd@>&M̙:ucƌ)Ϻ:Ai#P @CriU("PW [c%<ŊVPNOR0$c8l/:;uh&`&`&`&`&`&Kk#ޡdw& x%׹300000'V 100000oV|;000000z"`@;000000&`;׹300000'V 100000oV|;000000z"`@;00I`С;+++!)..~w̘1卓sK+Hlͥ;&`&P`7yk&`&(V5jZ&Mޑ|ɫEƝɜ&z۬Ydb\XҥrT&0z J\RQQhZcy7gLL,+&YQNDmp R .5DL8tl_A%D~000000000000000000000000000000000000000000000000000009F'LLr@EEEzJu/e}))׊͔n&`&`&@q\[[ )SˇQ z 7V&k <6o%zeƌS vL L07|AIkڴƓO>ym&IJ#4LLLhuS ;{3mnذ+Iz\]C LX*BNJ5~x6yLef&`&`&`hѢE۵0$\}_0 (GNcu?<6^EuLLLLLLꏀcLLLLLL<.\gLLLLLLX?֎LLLLLL XuLLLLLLꏀcLLLLLLMWf&`&P} k vy{'t߷,2Nm{000!`;w)50~Qǐa1Im<HY\///³Eᤘ jv{_E7aۻySH$Lϒp`gIA8&`&`G .w(G w{Gd@ ޽( v×S`&`&b{:;`ۻPCfۻR ML@.w#{Uv{\޽"h`7zGl&`&XDb[^^ѣW6;I fۻ׹Y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y(W)ۓ-7`bs=.H܏^L Bz-A;wNc n&3YƵactu q/M';w6[hws?;o/ EƎܫz1IT{+=Irn3Y}O)ZmõF0k4 (w7-J}90\Fo-ϸFLu>3xn: ~dĿ=4;V+Y]4&cq J'LL cP.d|QsEF'qO_Sտs}aĉZNh8Jx0_uLlB~ai$@>L^Dn])OkJ A!]& /$ƿ%VH3B>o/&+VZ}+QHK# &RvkLCaWDST֔MGv. K8>yiM':Mqڭ$ PF,xl]TYlKg 8'zΫRy%vşr-$f s*u䳘/a*&kZ 0w!&Yҧ$*hXDkŜ#}C:E{`g70,'C}Xf4X~ PYc"rn%\19 Mxow&PJMPq}Kӕ{h{0Up++L*@_RkrVo_MZ/°SQY(:"\ɄGu8iV";(ʝh_N' L:UVĆ]Ie8봙LYLa5 pߔGe6D/mo&`&uKxD֏6lΥ $G庐b˨|ؕ @: mҞmIENDB`cglm-0.9.6/docs/source/color.rst000066400000000000000000000015041475344456400165700ustar00rootroot00000000000000.. default-domain:: C color ================================================================================ Header: cglm/color.h Table of contents (click to go): ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Functions: 1. :c:func:`glm_luminance` Functions documentation ~~~~~~~~~~~~~~~~~~~~~~~ .. c:function:: float glm_luminance(vec3 rgb) | averages the color channels into one value This function uses formula in COLLADA 1.5 spec which is .. code-block:: text luminance = (color.r * 0.212671) + (color.g * 0.715160) + (color.b * 0.072169) It is based on the ISO/CIE color standards (see ITU-R Recommendation BT.709-4), that averages the color channels into one value Parameters: | *[in]* **rgb** RGB color cglm-0.9.6/docs/source/conf.py000066400000000000000000000136631475344456400162300ustar00rootroot00000000000000# -*- coding: utf-8 -*- # # cglm documentation build configuration file, created by # sphinx-quickstart on Tue Jun 6 20:31:05 2017. # # This file is execfile()d with the current directory set to its # containing dir. # # Note that not all possible configuration values are present in this # autogenerated file. # # All configuration values have a default; values that are commented out # serve to show the default. # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the # documentation root, use os.path.abspath to make it absolute, like shown here. # # import os # import sys # sys.path.insert(0, os.path.abspath('.')) # -- General configuration ------------------------------------------------ # If your documentation needs a minimal Sphinx version, state it here. # # needs_sphinx = '3.0' # Add any Sphinx extension module names here, as strings. They can be # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom # ones. extensions = [ 'sphinx.ext.doctest', 'sphinx.ext.todo', 'sphinx.ext.coverage', 'sphinx.ext.mathjax', 'sphinx.ext.ifconfig', 'sphinx.ext.viewcode', 'sphinx.ext.githubpages' ] # Add any paths that contain templates here, relative to this directory. templates_path = ['_templates'] # The suffix(es) of source filenames. # You can specify multiple suffix as a list of string: # # source_suffix = ['.rst', '.md'] source_suffix = '.rst' # The master toctree document. master_doc = 'index' # General information about the project. project = u'cglm' copyright = u'2017, Recep Aslantas' author = u'Recep Aslantas' # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the # built documents. # # The short X.Y version. version = u'0.9.6' # The full version, including alpha/beta/rc tags. release = u'0.9.6' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. # # This is also used if you do content translation via gettext catalogs. # Usually you set "language" from the command line for these cases. language = 'en' # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. # This patterns also effect to html_static_path and html_extra_path exclude_patterns = [] # The name of the Pygments (syntax highlighting) style to use. pygments_style = 'sphinx' # If true, `todo` and `todoList` produce output, else they produce nothing. todo_include_todos = False # -- Options for HTML output ---------------------------------------------- # The theme to use for HTML and HTML Help pages. See the documentation for # a list of builtin themes. # html_theme = 'sphinx_rtd_theme' pygments_style = 'monokai' # Theme options are theme-specific and customize the look and feel of a theme # further. For a list of options available for each theme, see the # documentation. # # html_theme_options = {} html_theme_options = { # 'github_banner': 'true', # 'github_button': 'true', # 'github_user': 'recp', # 'github_repo': 'cglm', # 'travis_button': 'true', # 'show_related': 'true', # 'fixed_sidebar': 'true' } # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, # so a file named "default.css" will overwrite the builtin "default.css". html_static_path = ['sphinx-static'] # Add customm CSS and JS files html_css_files = ['theme_overrides.css'] html_js_files = [] # -- Options for HTMLHelp output ------------------------------------------ # Output file base name for HTML help builder. htmlhelp_basename = 'cglmdoc' # -- Options for LaTeX output --------------------------------------------- latex_elements = { # The paper size ('letterpaper' or 'a4paper'). # # 'papersize': 'letterpaper', # The font size ('10pt', '11pt' or '12pt'). # # 'pointsize': '10pt', # Additional stuff for the LaTeX preamble. # # 'preamble': '', # Latex figure (float) alignment # # 'figure_align': 'htbp', } # Grouping the document tree into LaTeX files. List of tuples # (source start file, target name, title, # author, documentclass [howto, manual, or own class]). latex_documents = [ (master_doc, 'cglm.tex', u'cglm Documentation', u'Recep Aslantas', 'manual'), ] # -- Options for manual page output --------------------------------------- # One entry per manual page. List of tuples # (source start file, name, description, authors, manual section). man_pages = [ (master_doc, 'cglm', u'cglm Documentation', [author], 1) ] # -- Options for Texinfo output ------------------------------------------- # Grouping the document tree into Texinfo files. List of tuples # (source start file, target name, title, author, # dir menu entry, description, category) texinfo_documents = [ (master_doc, 'cglm', u'cglm Documentation', author, 'cglm', 'One line description of project.', 'Miscellaneous'), ] # -- Options for Epub output ------------------------------------------------- # Bibliographic Dublin Core info. epub_title = project epub_author = author epub_publisher = author epub_copyright = copyright # The unique identifier of the text. This can be a ISBN number # or the project homepage. # # epub_identifier = '' # A unique identification for the text. # # epub_uid = '' # A list of files that should not be packed into the epub file. epub_exclude_files = ['search.html'] # -- Extension configuration ------------------------------------------------- # -- Options for todo extension ---------------------------------------------- # If true, `todo` and `todoList` produce output, else they produce nothing. todo_include_todos = True # -- Options for the C domain ------------------------------------------------ c_id_attributes = ['__restrict'] cglm-0.9.6/docs/source/curve.rst000066400000000000000000000020521475344456400165750ustar00rootroot00000000000000.. default-domain:: C Curve ================================================================================ Header: cglm/curve.h Common helpers for common curves. For specific curve see its header/doc e.g bezier Table of contents (click to go): ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Functions: 1. :c:func:`glm_smc` Functions documentation ~~~~~~~~~~~~~~~~~~~~~~~ .. c:function:: float glm_smc(float s, mat4 m, vec4 c) | helper function to calculate **S** * **M** * **C** multiplication for curves | this function does not encourage you to use SMC, instead it is a helper if you use SMC. | if you want to specify S as vector then use more generic glm_mat4_rmc() func. | Example usage: .. code-block:: c Bs = glm_smc(s, GLM_BEZIER_MAT, (vec4){p0, c0, c1, p1}) Parameters: | *[in]* **s** parameter between 0 and 1 (this will be [s3, s2, s, 1]) | *[in]* **m** basis matrix | *[out]* **c** position/control vector Returns: scalar value e.g. Bs cglm-0.9.6/docs/source/euler.rst000066400000000000000000000126421475344456400165730ustar00rootroot00000000000000.. default-domain:: C euler angles ============ Header: cglm/euler.h You may wonder what **glm_euler_sq** type ( **_sq** stands for sequence ) and :c:func:`glm_euler_by_order` do. I used them to convert euler angles in one coordinate system to another. For instance if you have **Z_UP** euler angles and if you want to convert it to **Y_UP** axis then :c:func:`glm_euler_by_order` is your friend. For more information check :c:func:`glm_euler_order` documentation You must pass arrays as array, if you use C compiler then you can use something like this: .. code-block:: c float pitch, yaw, roll; mat4 rot; /* pitch = ...; yaw = ...; roll = ... */ glm_euler((vec3){pitch, yaw, roll}, rot); Rotation Conveniention ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Current *cglm*'s euler functions uses these convention: * Tait–Bryan angles (x-y-z convention) * Intrinsic rotations (pitch, yaw and roll). This is reserve order of extrinsic (elevation, heading and bank) rotation * Right hand rule (actually all rotations in *cglm* use **RH**) * All angles used in *cglm* are **RADIANS** not degrees **NOTE**: The default :c:func:`glm_euler` function is the short name of :c:func:`glm_euler_xyz` this is why you can't see :c:func:`glm_euler_xyz`. When you see an euler function which doesn't have any X, Y, Z suffix then assume that uses **_xyz** (or instead it accept order as parameter). If rotation doesn't work properly, your options: 1. If you use (or paste) degrees convert it to radians before calling an euler function .. code-block:: c float pitch, yaw, roll; mat4 rot; /* pitch = degrees; yaw = degrees; roll = degrees */ glm_euler((vec3){glm_rad(pitch), glm_rad(yaw), glm_rad(roll)}, rot); 2. Convention mismatch. You may have extrinsic angles, if you do (if you must) then consider to use reverse order e.g if you have **xyz** extrinsic then use **zyx** 3. *cglm* may implemented it wrong, consider to create an issue to report it or pull request to fix it Table of contents (click to go): ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Types: 1. glm_euler_sq Functions: 1. :c:func:`glm_euler_order` #. :c:func:`glm_euler_angles` #. :c:func:`glm_euler` #. :c:func:`glm_euler_xyz` #. :c:func:`glm_euler_zyx` #. :c:func:`glm_euler_zxy` #. :c:func:`glm_euler_xzy` #. :c:func:`glm_euler_yzx` #. :c:func:`glm_euler_yxz` #. :c:func:`glm_euler_by_order` Functions documentation ~~~~~~~~~~~~~~~~~~~~~~~ .. c:function:: glm_euler_sq glm_euler_order(int ord[3]) | packs euler angles order to glm_euler_sq enum. To use :c:func:`glm_euler_by_order` function you need *glm_euler_sq*. You can get it with this function. You can build param like this: | X = 0, Y = 1, Z = 2 if you have ZYX order then you pass this: [2, 1, 0] = ZYX. if you have YXZ order then you pass this: [1, 0, 2] = YXZ As you can see first item specifies which axis will be first then the second one specifies which one will be next an so on. Parameters: | *[in]* **ord** euler angles order [Angle1, Angle2, Angle2] Returns: packed euler order .. c:function:: void glm_euler_angles(mat4 m, vec3 dest) | extract euler angles (in radians) using xyz order Parameters: | *[in]* **m** affine transform | *[out]* **dest** angles vector [x, y, z] .. c:function:: void glm_euler(vec3 angles, mat4 dest) | build rotation matrix from euler angles this is alias of glm_euler_xyz function Parameters: | *[in]* **angles** angles as vector [Xangle, Yangle, Zangle] | *[in]* **dest** rotation matrix .. c:function:: void glm_euler_xyz(vec3 angles, mat4 dest) | build rotation matrix from euler angles Parameters: | *[in]* **angles** angles as vector [Xangle, Yangle, Zangle] | *[in]* **dest** rotation matrix .. c:function:: void glm_euler_zyx(vec3 angles, mat4 dest) | build rotation matrix from euler angles Parameters: | *[in]* **angles** angles as vector [Xangle, Yangle, Zangle] | *[in]* **dest** rotation matrix .. c:function:: void glm_euler_zxy(vec3 angles, mat4 dest) | build rotation matrix from euler angles Parameters: | *[in]* **angles** angles as vector [Xangle, Yangle, Zangle] | *[in]* **dest** rotation matrix .. c:function:: void glm_euler_xzy(vec3 angles, mat4 dest) | build rotation matrix from euler angles Parameters: | *[in]* **angles** angles as vector [Xangle, Yangle, Zangle] | *[in]* **dest** rotation matrix .. c:function:: void glm_euler_yzx(vec3 angles, mat4 dest) build rotation matrix from euler angles Parameters: | *[in]* **angles** angles as vector [Xangle, Yangle, Zangle] | *[in]* **dest** rotation matrix .. c:function:: void glm_euler_yxz(vec3 angles, mat4 dest) | build rotation matrix from euler angles Parameters: | *[in]* **angles** angles as vector [Xangle, Yangle, Zangle] | *[in]* **dest** rotation matrix .. c:function:: void glm_euler_by_order(vec3 angles, glm_euler_sq ord, mat4 dest) | build rotation matrix from euler angles with given euler order. Use :c:func:`glm_euler_order` function to build *ord* parameter Parameters: | *[in]* **angles** angles as vector [Xangle, Yangle, Zangle] | *[in]* **ord** euler order | *[in]* **dest** rotation matrix cglm-0.9.6/docs/source/features.rst000066400000000000000000000023411475344456400172700ustar00rootroot00000000000000Features ================================================================================ * **scalar** and **simd** (sse, avx, neon, wasm...) optimizations * option to use different clipspaces e.g. Left Handed, Zero-to-One... (currently right handed negative-one is default) * array api and struct api, you can use arrays or structs. * general purpose matrix operations (mat4, mat3) * chain matrix multiplication (square only) * general purpose vector operations (cross, dot, rotate, proj, angle...) * affine transformations * matrix decomposition (extract rotation, scaling factor) * optimized affine transform matrices (mul, rigid-body inverse) * camera (lookat) * projections (ortho, perspective) * quaternions * euler angles / yaw-pitch-roll to matrix * extract euler angles * inline or pre-compiled function call * frustum (extract view frustum planes, corners...) * bounding box (AABB in Frustum (culling), crop, merge...) * 2d bounding box (crop, merge...) * bounding sphere * project, unproject * easing functions * curves * curve interpolation helpers (SMC, deCasteljau...) * helpers to convert cglm types to Apple's simd library to pass cglm types to Metal GL without packing them on both sides * ray intersection helpers * and others... cglm-0.9.6/docs/source/frustum.rst000066400000000000000000000114461475344456400171650ustar00rootroot00000000000000.. default-domain:: C frustum ============= Header: cglm/frustum.h cglm provides convenient functions to extract frustum planes, corners... All extracted corners are **vec4** so you must create array of **vec4** not **vec3**. If you want to store them to save space you msut convert them yourself. **vec4** is used to speed up functions need to corners. This is why frustum functions use *vec4* instead of *vec3* Currently related-functions use [-1, 1] clip space configuration to extract corners but you can override it by prodiving **GLM_CUSTOM_CLIPSPACE** macro. If you provide it then you have to all bottom macros as *vec4* Current configuration: .. code-block:: c /* near */ GLM_CSCOORD_LBN {-1.0f, -1.0f, -1.0f, 1.0f} GLM_CSCOORD_LTN {-1.0f, 1.0f, -1.0f, 1.0f} GLM_CSCOORD_RTN { 1.0f, 1.0f, -1.0f, 1.0f} GLM_CSCOORD_RBN { 1.0f, -1.0f, -1.0f, 1.0f} /* far */ GLM_CSCOORD_LBF {-1.0f, -1.0f, 1.0f, 1.0f} GLM_CSCOORD_LTF {-1.0f, 1.0f, 1.0f, 1.0f} GLM_CSCOORD_RTF { 1.0f, 1.0f, 1.0f, 1.0f} GLM_CSCOORD_RBF { 1.0f, -1.0f, 1.0f, 1.0f} Explain of short names: * **LBN**: left bottom near * **LTN**: left top near * **RTN**: right top near * **RBN**: right bottom near * **LBF**: left bottom far * **LTF**: left top far * **RTF**: right top far * **RBF**: right bottom far Table of contents (click to go): ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Macros: .. code-block:: c GLM_LBN 0 /* left bottom near */ GLM_LTN 1 /* left top near */ GLM_RTN 2 /* right top near */ GLM_RBN 3 /* right bottom near */ GLM_LBF 4 /* left bottom far */ GLM_LTF 5 /* left top far */ GLM_RTF 6 /* right top far */ GLM_RBF 7 /* right bottom far */ GLM_LEFT 0 GLM_RIGHT 1 GLM_BOTTOM 2 GLM_TOP 3 GLM_NEAR 4 GLM_FAR 5 Functions: 1. :c:func:`glm_frustum_planes` #. :c:func:`glm_frustum_corners` #. :c:func:`glm_frustum_center` #. :c:func:`glm_frustum_box` #. :c:func:`glm_frustum_corners_at` Functions documentation ~~~~~~~~~~~~~~~~~~~~~~~ .. c:function:: void glm_frustum_planes(mat4 m, vec4 dest[6]) | extracts view frustum planes planes' space: - if m = proj: View Space - if m = viewProj: World Space - if m = MVP: Object Space You probably want to extract planes in world space so use viewProj as m Computing viewProj: .. code-block:: c glm_mat4_mul(proj, view, viewProj); Exracted planes order: [left, right, bottom, top, near, far] Parameters: | *[in]* **m** matrix | *[out]* **dest** exracted view frustum planes .. c:function:: void glm_frustum_corners(mat4 invMat, vec4 dest[8]) | extracts view frustum corners using clip-space coordinates corners' space: - if m = invViewProj: World Space - if m = invMVP: Object Space You probably want to extract corners in world space so use **invViewProj** Computing invViewProj: .. code-block:: c glm_mat4_mul(proj, view, viewProj); ... glm_mat4_inv(viewProj, invViewProj); if you have a near coord at **i** index, you can get it's far coord by i + 4; follow example below to understand that For instance to find center coordinates between a near and its far coord: .. code-block:: c for (j = 0; j < 4; j++) { glm_vec3_center(corners[i], corners[i + 4], centerCorners[i]); } corners[i + 4] is far of corners[i] point. Parameters: | *[in]* **invMat** matrix | *[out]* **dest** exracted view frustum corners .. c:function:: void glm_frustum_center(vec4 corners[8], vec4 dest) | finds center of view frustum Parameters: | *[in]* **corners** view frustum corners | *[out]* **dest** view frustum center .. c:function:: void glm_frustum_box(vec4 corners[8], mat4 m, vec3 box[2]) | finds bounding box of frustum relative to given matrix e.g. view mat Parameters: | *[in]* **corners** view frustum corners | *[in]* **m** matrix to convert existing conners | *[out]* **box** bounding box as array [min, max] .. c:function:: void glm_frustum_corners_at(vec4 corners[8], float splitDist, float farDist, vec4 planeCorners[4]) | finds planes corners which is between near and far planes (parallel) this will be helpful if you want to split a frustum e.g. CSM/PSSM. This will find planes' corners but you will need to one more plane. Actually you have it, it is near, far or created previously with this func ;) Parameters: | *[in]* **corners** frustum corners | *[in]* **splitDist** split distance | *[in]* **farDist** far distance (zFar) | *[out]* **planeCorners** plane corners [LB, LT, RT, RB] cglm-0.9.6/docs/source/getting_started.rst000066400000000000000000000105221475344456400206410ustar00rootroot00000000000000Getting Started ================================ Types: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ **cglm** uses **glm** prefix for all functions e.g. glm_lookat. You can see supported types in common header file: .. code-block:: c :linenos: typedef float vec2[2]; typedef float vec3[3]; typedef int ivec3[3]; typedef CGLM_ALIGN_IF(16) float vec4[4]; typedef vec4 versor; typedef vec3 mat3[3]; #ifdef __AVX__ typedef CGLM_ALIGN_IF(32) vec4 mat4[4]; #else typedef CGLM_ALIGN_IF(16) vec4 mat4[4]; #endif As you can see types don't store extra information in favor of space. You can send these values e.g. matrix to OpenGL directly without casting or calling a function like *value_ptr* Alignment Is Required: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ **vec4** and **mat4** requires 16 (32 for **mat4** if AVX is enabled) byte alignment because **vec4** and **mat4** operations are vectorized by SIMD instructions (SSE/AVX/NEON). **UPDATE:** By starting v0.4.5 cglm provides an option to disable alignment requirement, it is enabled as default | Check :doc:`opt` page for more details Also alignment is disabled for older msvc versions as default. Now alignment is only required in Visual Studio 2017 version 15.6+ if CGLM_ALL_UNALIGNED macro is not defined. Allocations: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *cglm* doesn't alloc any memory on heap. So it doesn't provide any allocator. You must allocate memory yourself. You should alloc memory for out parameters too if you pass pointer of memory location. When allocating memory, don't forget that **vec4** and **mat4** require alignment. .. note:: Unaligned **vec4** and unaligned **mat4** operations will be supported in the future. Check todo list. Because you may want to multiply a CGLM matrix with external matrix. There is no guarantee that non-CGLM matrix is aligned. Unaligned types will have *u* prefix e.g. **umat4** Array vs Struct: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *cglm* uses arrays for vector and matrix types. So you can't access individual elements like vec.x, vec.y, vec.z... You must use subscript to access vector elements e.g. vec[0], vec[1], vec[2]. Also I think it is more meaningful to access matrix elements with subscript e.g **matrix[2][3]** instead of **matrix._23**. Since matrix is array of vectors, vectors are also defined as array. This makes types homogeneous. **Return arrays?** Since C doesn't support return arrays, cglm also doesn't support this feature. Function design: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .. image:: cglm-intro.png :width: 492px  :height: 297px :align: center cglm provides a few way to call a function to do same operation. * Inline - *glm_, glm_u* * Pre-compiled - *glmc_, glmc_u* For instance **glm_mat4_mul** is inline (all *glm_* functions are inline), to make it non-inline (pre-compiled), call it as **glmc_mat4_mul** from library, to use unaligned version use **glm_umat4_mul** (todo). Most functions have **dest** parameter for output. For instance mat4_mul func looks like this: .. code-block:: c CGLM_INLINE void glm_mat4_mul(mat4 m1, mat4 m2, mat4 dest) The dest parameter is out parameter. Result will be stored in **dest**. Also in this case matrix multiplication order is dest = m1 * m2. * Changing parameter order will change the multiplication order. * You can pass all parameter same (this is similar to m1 `*=` m1), you can pass **dest** as m1 or m2 (this is similar to m1 `*=` m2) **v** postfix in function names ------------------------------- You may see **v** postfix in some function names, v stands for vector. For instance consider a function that accepts three parameters x, y, z. This function may be overloaded by **v** postfix to accept vector (vec3) instead of separate parameters. In some places the v means that it will be apply to a vector. **_to** postfix in function names --------------------------------- *_to* version of function will store the result in specified parameter instead of in-out parameter. Some functions don't have _to prefix but they still behave like this e.g. glm_mat4_mul. cglm-0.9.6/docs/source/index.rst000066400000000000000000000017531475344456400165670ustar00rootroot00000000000000.. cglm documentation master file, created by sphinx-quickstart on Tue Jun 6 20:31:05 2017. You can adapt this file completely to your liking, but it should at least contain the root `toctree` directive. cglm Documentation ================================ **cglm** is an optimized 3D math library written in C99 (compatible with C89). It is similar to the original **glm** library, except **cglm** is mainly for **C**. **cglm** stores matrices as column-major order but in the future row-major is considered to be supported as optional. .. toctree:: :maxdepth: 2 :caption: Getting Started: features build getting_started .. toctree:: :maxdepth: 2 :caption: How To: opengl .. toctree:: :maxdepth: 3 :caption: API: api .. toctree:: :maxdepth: 2 :caption: Options: opt .. toctree:: :maxdepth: 2 :caption: Troubleshooting: troubleshooting Indices and Tables: =================== * :ref:`genindex` * :ref:`modindex` * :ref:`search` cglm-0.9.6/docs/source/io.rst000066400000000000000000000100611475344456400160570ustar00rootroot00000000000000.. default-domain:: C io (input / output e.g. print) ================================================================================ Header: cglm/io.h There are some built-in print functions which may save your time, especially for debugging. All functions accept **FILE** parameter which makes very flexible. You can even print it to file on disk. In general you will want to print them to console to see results. You can use **stdout** and **stderr** to write results to console. Some programs may occupy **stdout** but you can still use **stderr**. Using **stderr** is suggested. Example to print mat4 matrix: .. code-block:: c mat4 transform; /* ... */ glm_mat4_print(transform, stderr); .. note:: print functions use **%0.4f** precision if you need more (you probably will in some cases), you can change it temporary. cglm may provide precision parameter in the future. Changes since **v0.7.3**: * Now mis-alignment of columns are fixed: larger numbers are printed via %g and others are printed via %f. Column widths are calculated before print. * Now values are colorful ;) * Some print improvements * New options with default values: .. code-block:: c #define CGLM_PRINT_PRECISION 5 #define CGLM_PRINT_MAX_TO_SHORT 1e5 #define CGLM_PRINT_COLOR "\033[36m" #define CGLM_PRINT_COLOR_RESET "\033[0m" * Inline prints are only enabled in DEBUG mode and if **CGLM_DEFINE_PRINTS** is defined. Check options page. Table of contents (click to go): ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Functions: 1. :c:func:`glm_mat4_print` #. :c:func:`glm_mat3_print` #. :c:func:`glm_vec4_print` #. :c:func:`glm_ivec4_print` #. :c:func:`glm_vec3_print` #. :c:func:`glm_ivec3_print` #. :c:func:`glm_vec2_print` #. :c:func:`glm_ivec2_print` #. :c:func:`glm_versor_print` #. :c:func:`glm_aabb_print` Functions documentation ~~~~~~~~~~~~~~~~~~~~~~~ .. c:function:: void glm_mat4_print(mat4 matrix, FILE * __restrict ostream) | print matrix to given stream Parameters: | *[in]* **matrix** matrix | *[in]* **ostream** FILE to write .. c:function:: void glm_mat3_print(mat3 matrix, FILE * __restrict ostream) | print matrix to given stream Parameters: | *[in]* **matrix** matrix | *[in]* **ostream** FILE to write .. c:function:: void glm_vec4_print(vec4 vec, FILE * __restrict ostream) | print vector to given stream Parameters: | *[in]* **vec** vector | *[in]* **ostream** FILE to write .. c:function:: void glm_ivec4_print(ivec4 vec, FILE * __restrict ostream) | print vector to given stream Parameters: | *[in]* **vec** vector | *[in]* **ostream** FILE to write .. c:function:: void glm_vec3_print(vec3 vec, FILE * __restrict ostream) | print vector to given stream Parameters: | *[in]* **vec** vector | *[in]* **ostream** FILE to write .. c:function:: void glm_ivec3_print(ivec3 vec, FILE * __restrict ostream) | print vector to given stream Parameters: | *[in]* **vec** vector | *[in]* **ostream** FILE to write .. c:function:: void glm_vec2_print(vec2 vec, FILE * __restrict ostream) | print vector to given stream Parameters: | *[in]* **vec** vector | *[in]* **ostream** FILE to write .. c:function:: void glm_ivec2_print(ivec2 vec, FILE * __restrict ostream) | print vector to given stream Parameters: | *[in]* **vec** vector | *[in]* **ostream** FILE to write .. c:function:: void glm_versor_print(versor vec, FILE * __restrict ostream) | print quaternion to given stream Parameters: | *[in]* **vec** quaternion | *[in]* **ostream** FILE to write .. c:function:: void glm_aabb_print(versor vec, const char * __restrict tag, FILE * __restrict ostream) | print aabb to given stream Parameters: | *[in]* **vec** aabb (axis-aligned bounding box) | *[in]* **tag** tag to find it more easily in logs | *[in]* **ostream** FILE to write cglm-0.9.6/docs/source/ivec2.rst000066400000000000000000000144051475344456400164660ustar00rootroot00000000000000.. default-domain:: C ivec2 ===== Header: cglm/ivec2.h Table of contents (click to go): ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Macros: 1. GLM_IVEC2_ONE_INIT #. GLM_IVEC2_ZERO_INIT #. GLM_IVEC2_ONE #. GLM_IVEC2_ZERO Functions: 1. :c:func:`glm_ivec2` #. :c:func:`glm_ivec2_copy` #. :c:func:`glm_ivec2_zero` #. :c:func:`glm_ivec2_one` #. :c:func:`glm_ivec2_dot` #. :c:func:`glm_ivec2_cross` #. :c:func:`glm_ivec2_add` #. :c:func:`glm_ivec2_adds` #. :c:func:`glm_ivec2_sub` #. :c:func:`glm_ivec2_subs` #. :c:func:`glm_ivec2_mul` #. :c:func:`glm_ivec2_scale` #. :c:func:`glm_ivec2_div` #. :c:func:`glm_ivec2_divs` #. :c:func:`glm_ivec2_mod` #. :c:func:`glm_ivec2_distance2` #. :c:func:`glm_ivec2_distance` #. :c:func:`glm_ivec2_maxv` #. :c:func:`glm_ivec2_minv` #. :c:func:`glm_ivec2_clamp` #. :c:func:`glm_ivec2_abs` Functions documentation ~~~~~~~~~~~~~~~~~~~~~~~ .. c:function:: void glm_ivec2(int * v, ivec2 dest) init ivec2 using vec3 or vec4 Parameters: | *[in]* **v** vector | *[out]* **dest** destination .. c:function:: void glm_ivec2_copy(ivec2 a, ivec2 dest) copy all members of [a] to [dest] Parameters: | *[in]* **a** source vector | *[out]* **dest** destination .. c:function:: void glm_ivec2_zero(ivec2 v) set all members of [v] to zero Parameters: | *[out]* **v** vector .. c:function:: void glm_ivec2_one(ivec2 v) set all members of [v] to one Parameters: | *[out]* **v** vector .. c:function:: int glm_ivec2_dot(ivec2 a, ivec2 b) dot product of ivec2 Parameters: | *[in]* **a** vector1 | *[in]* **b** vector2 Returns: dot product .. c:function:: int glm_ivec2_cross(ivec2 a, ivec2 b) cross product of two vector (RH) | ref: http://allenchou.net/2013/07/cross-product-of-2d-vectors/ Parameters: | *[in]* **a** vector 1 | *[in]* **b** vector 2 Returns: Z component of cross product .. c:function:: void glm_ivec2_add(ivec2 a, ivec2 b, ivec2 dest) add vector [a] to vector [b] and store result in [dest] Parameters: | *[in]* **a** first vector | *[in]* **b** second vector | *[out]* **dest** destination .. c:function:: void glm_ivec2_adds(ivec2 v, int s, ivec2 dest) add scalar s to vector [v] and store result in [dest] Parameters: | *[in]* **v** vector | *[in]* **s** scalar | *[out]* **dest** destination .. c:function:: void glm_ivec2_sub(ivec2 a, ivec2 b, ivec2 dest) subtract vector [b] from vector [a] and store result in [dest] Parameters: | *[in]* **a** first vector | *[in]* **b** second vector | *[out]* **dest** destination .. c:function:: void glm_ivec2_subs(ivec2 v, int s, ivec2 dest) subtract scalar s from vector [v] and store result in [dest] Parameters: | *[in]* **v** vector | *[in]* **s** scalar | *[out]* **dest** destination .. c:function:: void glm_ivec2_mul(ivec2 a, ivec2 b, ivec2 dest) multiply vector [a] with vector [b] and store result in [dest] Parameters: | *[in]* **a** first vector | *[in]* **b** second vector | *[out]* **dest** destination .. c:function:: void glm_ivec2_scale(ivec2 v, int s, ivec2 dest) multiply vector [a] with scalar s and store result in [dest] Parameters: | *[in]* **v** vector | *[in]* **s** scalar | *[out]* **dest** destination .. c:function:: void glm_ivec2_div(ivec2 a, ivec2 b, ivec2 dest) div vector with another component-wise division: d = a / b Parameters: | *[in]* **a** vector 1 | *[in]* **b** vector 2 | *[out]* **dest** result = (a[0] / b[0], a[1] / b[1], a[2] / b[2]) .. c:function:: void glm_ivec2_divs(ivec2 v, int s, ivec2 dest) div vector with scalar: d = v / s Parameters: | *[in]* **v** vector | *[in]* **s** scalar | *[out]* **dest** result = (a[0] / s, a[1] / s, a[2] / s) .. c:function:: void glm_ivec2_mod(ivec2 a, ivec2 b, ivec2 dest) mod vector with another component-wise modulo: d = a % b Parameters: | *[in]* **a** vector | *[in]* **b** scalar | *[out]* **dest** result = (a[0] % b[0], a[1] % b[1]) .. c:function:: int glm_ivec2_distance2(ivec2 a, ivec2 b) squared distance between two vectors Parameters: | *[in]* **a** first vector | *[in]* **b** second vector Returns: squared distance (distance * distance) .. c:function:: float glm_ivec2_distance(ivec2 a, ivec2 b) distance between two vectors Parameters: | *[in]* **a** first vector | *[in]* **b** second vector Returns: distance .. c:function:: void glm_ivec2_fill(ivec2 v, int val) fill a vector with specified value Parameters: | *[out]* **v** vector | *[in]* **val** value .. c:function:: bool glm_ivec2_eq(ivec2 v, int val) check if vector is equal to value Parameters: | *[in]* **v** vector | *[in]* **val** value .. c:function:: bool glm_ivec2_eqv(ivec2 v1, ivec2 v2) check if vector is equal to another vector Parameters: | *[in]* **vec** vector 1 | *[in]* **vec** vector 2 .. c:function:: void glm_ivec2_maxv(ivec2 a, ivec2 b, ivec2 dest) set each member of dest to greater of vector a and b Parameters: | *[in]* **a** first vector | *[in]* **b** second vector | *[out]* **dest** destination .. c:function:: void glm_ivec2_minv(ivec2 a, ivec2 b, ivec2 dest) set each member of dest to lesser of vector a and b Parameters: | *[in]* **a** first vector | *[in]* **b** second vector | *[out]* **dest** destination .. c:function:: void glm_ivec2_clamp(ivec2 v, int minVal, int maxVal) clamp each member of [v] between minVal and maxVal (inclusive) Parameters: | *[in, out]* **v** vector | *[in]* **minVal** minimum value | *[in]* **maxVal** maximum value .. c:function:: void glm_ivec2_abs(ivec2 v, ivec2 dest) absolute value of each vector item Parameters: | *[in]* **v** vector | *[out]* **dest** destination vector cglm-0.9.6/docs/source/ivec3.rst000066400000000000000000000152531475344456400164710ustar00rootroot00000000000000.. default-domain:: C ivec3 ===== Header: cglm/ivec3.h Table of contents (click to go): ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Macros: 1. GLM_IVEC3_ONE_INIT #. GLM_IVEC3_ZERO_INIT #. GLM_IVEC3_ONE #. GLM_IVEC3_ZERO Functions: 1. :c:func:`glm_ivec3` #. :c:func:`glm_ivec3_copy` #. :c:func:`glm_ivec3_zero` #. :c:func:`glm_ivec3_one` #. :c:func:`glm_ivec3_dot` #. :c:func:`glm_ivec3_norm2` #. :c:func:`glm_ivec3_norm` #. :c:func:`glm_ivec3_add` #. :c:func:`glm_ivec3_adds` #. :c:func:`glm_ivec3_sub` #. :c:func:`glm_ivec3_subs` #. :c:func:`glm_ivec3_mul` #. :c:func:`glm_ivec3_scale` #. :c:func:`glm_ivec3_div` #. :c:func:`glm_ivec3_divs` #. :c:func:`glm_ivec3_mod` #. :c:func:`glm_ivec3_distance2` #. :c:func:`glm_ivec3_distance` #. :c:func:`glm_ivec3_fill` #. :c:func:`glm_ivec3_eq` #. :c:func:`glm_ivec3_eqv` #. :c:func:`glm_ivec3_maxv` #. :c:func:`glm_ivec3_minv` #. :c:func:`glm_ivec3_clamp` #. :c:func:`glm_ivec2_abs` Functions documentation ~~~~~~~~~~~~~~~~~~~~~~~ .. c:function:: void glm_ivec3(ivec4 v4, ivec3 dest) init ivec3 using ivec4 Parameters: | *[in]* **v** vector | *[out]* **dest** destination .. c:function:: void glm_ivec3_copy(ivec3 a, ivec3 dest) copy all members of [a] to [dest] Parameters: | *[in]* **a** source vector | *[out]* **dest** destination .. c:function:: void glm_ivec3_zero(ivec3 v) set all members of [v] to zero Parameters: | *[out]* **v** vector .. c:function:: void glm_ivec3_one(ivec3 v) set all members of [v] to one Parameters: | *[out]* **v** vector .. c:function:: int glm_ivec3_dot(ivec3 a, ivec3 b) dot product of ivec3 Parameters: | *[in]* **a** vector1 | *[in]* **b** vector2 Returns: dot product .. c:function:: int glm_ivec3_norm2(ivec3 v) norm * norm (magnitude) of vector we can use this func instead of calling norm * norm, because it would call sqrtf function twice but with this func we can avoid func call, maybe this is not good name for this func Parameters: | *[in]* **v** vector Returns: square of norm / magnitude, cast to an integer .. c:function:: int glm_ivec3_norm(ivec3 vec) | euclidean norm (magnitude), also called L2 norm | this will give magnitude of vector in euclidean space Parameters: | *[in]* **vec** vector .. c:function:: void glm_ivec3_add(ivec3 a, ivec3 b, ivec3 dest) add vector [a] to vector [b] and store result in [dest] Parameters: | *[in]* **a** first vector | *[in]* **b** second vector | *[out]* **dest** destination .. c:function:: void glm_ivec3_adds(ivec3 v, int s, ivec3 dest) add scalar s to vector [v] and store result in [dest] Parameters: | *[in]* **v** vector | *[in]* **s** scalar | *[out]* **dest** destination .. c:function:: void glm_ivec3_sub(ivec3 a, ivec3 b, ivec3 dest) subtract vector [b] from vector [a] and store result in [dest] Parameters: | *[in]* **a** first vector | *[in]* **b** second vector | *[out]* **dest** destination .. c:function:: void glm_ivec3_subs(ivec3 v, int s, ivec3 dest) subtract scalar s from vector [v] and store result in [dest] Parameters: | *[in]* **v** vector | *[in]* **s** scalar | *[out]* **dest** destination .. c:function:: void glm_ivec3_mul(ivec3 a, ivec3 b, ivec3 dest) multiply vector [a] with vector [b] and store result in [dest] Parameters: | *[in]* **a** first vector | *[in]* **b** second vector | *[out]* **dest** destination .. c:function:: void glm_ivec3_scale(ivec3 v, int s, ivec3 dest) multiply vector [a] with scalar s and store result in [dest] Parameters: | *[in]* **v** vector | *[in]* **s** scalar | *[out]* **dest** destination .. c:function:: void glm_ivec3_div(ivec3 a, ivec3 b, ivec3 dest) div vector with another component-wise division: d = a / b Parameters: | *[in]* **a** vector 1 | *[in]* **b** vector 2 | *[out]* **dest** result = (a[0] / b[0], a[1] / b[1], a[2] / b[2]) .. c:function:: void glm_ivec3_divs(ivec3 v, int s, ivec3 dest) div vector with scalar: d = v / s Parameters: | *[in]* **v** vector | *[in]* **s** scalar | *[out]* **dest** result = (a[0] / s, a[1] / s, a[2] / s) .. c:function:: void glm_ivec3_mod(ivec3 a, ivec3 b, ivec3 dest) mod vector with another component-wise modulo: d = a % b Parameters: | *[in]* **a** vector | *[in]* **b** scalar | *[out]* **dest** result = (a[0] % b[0], a[1] % b[1], a[2] % b[2]) .. c:function:: int glm_ivec3_distance2(ivec3 a, ivec3 b) squared distance between two vectors Parameters: | *[in]* **a** first vector | *[in]* **b** second vector Returns: squared distance (distance * distance) .. c:function:: float glm_ivec3_distance(ivec3 a, ivec3 b) distance between two vectors Parameters: | *[in]* **a** first vector | *[in]* **b** second vector Returns: distance .. c:function:: void glm_ivec3_fill(ivec3 v, int val) fill a vector with specified value Parameters: | *[out]* **v** vector | *[in]* **val** value .. c:function:: bool glm_ivec3_eq(ivec3 v, int val) check if vector is equal to value Parameters: | *[in]* **v** vector | *[in]* **val** value .. c:function:: bool glm_ivec3_eqv(ivec3 v1, ivec3 v2) check if vector is equal to another vector Parameters: | *[in]* **vec** vector 1 | *[in]* **vec** vector 2 .. c:function:: void glm_ivec3_maxv(ivec3 a, ivec3 b, ivec3 dest) set each member of dest to greater of vector a and b Parameters: | *[in]* **a** first vector | *[in]* **b** second vector | *[out]* **dest** destination .. c:function:: void glm_ivec3_minv(ivec3 a, ivec3 b, ivec3 dest) set each member of dest to lesser of vector a and b Parameters: | *[in]* **a** first vector | *[in]* **b** second vector | *[out]* **dest** destination .. c:function:: void glm_ivec3_clamp(ivec3 v, int minVal, int maxVal) clamp each member of [v] between minVal and maxVal (inclusive) Parameters: | *[in, out]* **v** vector | *[in]* **minVal** minimum value | *[in]* **maxVal** maximum value .. c:function:: void glm_ivec3_abs(ivec3 v, ivec3 dest) absolute value of each vector item Parameters: | *[in]* **v** vector | *[out]* **dest** destination vector cglm-0.9.6/docs/source/ivec4.rst000066400000000000000000000105041475344456400164640ustar00rootroot00000000000000.. default-domain:: C ivec4 ===== Header: cglm/ivec4.h Table of contents (click to go): ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Macros: 1. GLM_IVEC4_ONE_INIT #. GLM_IVEC4_ZERO_INIT #. GLM_IVEC4_ONE #. GLM_IVEC4_ZERO Functions: 1. :c:func:`glm_ivec4` #. :c:func:`glm_ivec4_copy` #. :c:func:`glm_ivec4_zero` #. :c:func:`glm_ivec4_one` #. :c:func:`glm_ivec4_add` #. :c:func:`glm_ivec4_adds` #. :c:func:`glm_ivec4_sub` #. :c:func:`glm_ivec4_subs` #. :c:func:`glm_ivec4_mul` #. :c:func:`glm_ivec4_scale` #. :c:func:`glm_ivec4_distance2` #. :c:func:`glm_ivec4_distance` #. :c:func:`glm_ivec4_maxv` #. :c:func:`glm_ivec4_minv` #. :c:func:`glm_ivec4_clamp` #. :c:func:`glm_ivec4_abs` Functions documentation ~~~~~~~~~~~~~~~~~~~~~~~ .. c:function:: void glm_ivec4(ivec3 v3, int last, ivec4 dest) init ivec4 using ivec3 Parameters: | *[in]* **v** vector | *[out]* **dest** destination .. c:function:: void glm_ivec4_copy(ivec4 a, ivec4 dest) copy all members of [a] to [dest] Parameters: | *[in]* **a** source vector | *[out]* **dest** destination .. c:function:: void glm_ivec4_zero(ivec4 v) set all members of [v] to zero Parameters: | *[out]* **v** vector .. c:function:: void glm_ivec4_one(ivec4 v) set all members of [v] to one Parameters: | *[out]* **v** vector .. c:function:: void glm_ivec4_add(ivec4 a, ivec4 b, ivec4 dest) add vector [a] to vector [b] and store result in [dest] Parameters: | *[in]* **a** first vector | *[in]* **b** second vector | *[out]* **dest** destination .. c:function:: void glm_ivec4_adds(ivec4 v, int s, ivec4 dest) add scalar s to vector [v] and store result in [dest] Parameters: | *[in]* **v** vector | *[in]* **s** scalar | *[out]* **dest** destination .. c:function:: void glm_ivec4_sub(ivec4 a, ivec4 b, ivec4 dest) subtract vector [b] from vector [a] and store result in [dest] Parameters: | *[in]* **a** first vector | *[in]* **b** second vector | *[out]* **dest** destination .. c:function:: void glm_ivec4_subs(ivec4 v, int s, ivec4 dest) subtract scalar s from vector [v] and store result in [dest] Parameters: | *[in]* **v** vector | *[in]* **s** scalar | *[out]* **dest** destination .. c:function:: void glm_ivec4_mul(ivec4 a, ivec4 b, ivec4 dest) multiply vector [a] with vector [b] and store result in [dest] Parameters: | *[in]* **a** first vector | *[in]* **b** second vector | *[out]* **dest** destination .. c:function:: void glm_ivec4_scale(ivec4 v, int s, ivec4 dest) multiply vector [a] with scalar s and store result in [dest] Parameters: | *[in]* **v** vector | *[in]* **s** scalar | *[out]* **dest** destination .. c:function:: int glm_ivec4_distance2(ivec4 a, ivec4 b) squared distance between two vectors Parameters: | *[in]* **a** first vector | *[in]* **b** second vector Returns: squared distance (distance * distance) .. c:function:: float glm_ivec4_distance(ivec4 a, ivec4 b) distance between two vectors Parameters: | *[in]* **a** first vector | *[in]* **b** second vector Returns: distance .. c:function:: void glm_ivec4_maxv(ivec4 a, ivec4 b, ivec4 dest) set each member of dest to greater of vector a and b Parameters: | *[in]* **a** first vector | *[in]* **b** second vector | *[out]* **dest** destination .. c:function:: void glm_ivec4_minv(ivec4 a, ivec4 b, ivec4 dest) set each member of dest to lesser of vector a and b Parameters: | *[in]* **a** first vector | *[in]* **b** second vector | *[out]* **dest** destination .. c:function:: void glm_ivec4_clamp(ivec4 v, int minVal, int maxVal) clamp each member of [v] between minVal and maxVal (inclusive) Parameters: | *[in, out]* **v** vector | *[in]* **minVal** minimum value | *[in]* **maxVal** maximum value .. c:function:: void glm_ivec4_abs(ivec4 v, ivec4 dest) absolute value of each vector item Parameters: | *[in]* **v** vector | *[out]* **dest** destination vector cglm-0.9.6/docs/source/mat2.rst000066400000000000000000000111461475344456400163200ustar00rootroot00000000000000.. default-domain:: C mat2 ==== Header: cglm/mat2.h Table of contents (click to go): ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Macros: 1. GLM_mat2_IDENTITY_INIT #. GLM_mat2_ZERO_INIT #. GLM_mat2_IDENTITY #. GLM_mat2_ZERO Functions: 1. :c:func:`glm_mat2_copy` #. :c:func:`glm_mat2_identity` #. :c:func:`glm_mat2_identity_array` #. :c:func:`glm_mat2_zero` #. :c:func:`glm_mat2_mul` #. :c:func:`glm_mat2_transpose_to` #. :c:func:`glm_mat2_transpose` #. :c:func:`glm_mat2_mulv` #. :c:func:`glm_mat2_scale` #. :c:func:`glm_mat2_det` #. :c:func:`glm_mat2_inv` #. :c:func:`glm_mat2_trace` #. :c:func:`glm_mat2_swap_col` #. :c:func:`glm_mat2_swap_row` #. :c:func:`glm_mat2_rmc` #. :c:func:`glm_mat2_make` Functions documentation ~~~~~~~~~~~~~~~~~~~~~~~ .. c:function:: void glm_mat2_copy(mat2 mat, mat2 dest) copy mat2 to another one (dest). Parameters: | *[in]* **mat** source | *[out]* **dest** destination .. c:function:: void glm_mat2_identity(mat2 mat) copy identity mat2 to mat, or makes mat to identity Parameters: | *[out]* **mat** matrix .. c:function:: void glm_mat2_identity_array(mat2 * __restrict mat, size_t count) make given matrix array's each element identity matrix Parameters: | *[in,out]* **mat** matrix array (must be aligned (16/32) if alignment is not disabled) | *[in]* **count** count of matrices .. c:function:: void glm_mat2_zero(mat2 mat) make given matrix zero Parameters: | *[in,out]* **mat** matrix .. c:function:: void glm_mat2_mul(mat2 m1, mat2 m2, mat2 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 mat2 m = GLM_mat2_IDENTITY_INIT; glm_mat2_mul(m, m, m); Parameters: | *[in]* **m1** left matrix | *[in]* **m2** right matrix | *[out]* **dest** destination matrix .. c:function:: void glm_mat2_transpose_to(mat2 m, mat2 dest) transpose mat4 and store in dest source matrix will not be transposed unless dest is m Parameters: | *[in]* **mat** source | *[out]* **dest** destination .. c:function:: void glm_mat2_transpose(mat2 m) transpose mat2 and store result in same matrix Parameters: | *[in]* **mat** source | *[out]* **dest** destination .. c:function:: void glm_mat2_mulv(mat2 m, vec2 v, vec2 dest) multiply mat2 with vec2 (column vector) and store in dest vector Parameters: | *[in]* **mat** mat2 (left) | *[in]* **v** vec2 (right, column vector) | *[out]* **dest** destination (result, column vector) .. c:function:: void glm_mat2_scale(mat2 m, float s) multiply matrix with scalar Parameters: | *[in, out]* **m** matrix | *[in]* **s** scalar .. c:function:: float glm_mat2_det(mat2 mat) returns mat2 determinant Parameters: | *[in]* **mat** matrix Returns: mat2 determinant .. c:function:: void glm_mat2_inv(mat2 mat, mat2 dest) inverse mat2 and store in dest Parameters: | *[in]* **mat** matrix | *[out]* **dest** destination (inverse matrix) .. c:function:: void glm_mat2_trace(mat2 m) | sum of the elements on the main diagonal from upper left to the lower right Parameters: | *[in]* **m** matrix Returns: trace of matrix .. c:function:: void glm_mat2_swap_col(mat2 mat, int col1, int col2) swap two matrix columns Parameters: | *[in, out]* **mat** matrix | *[in]* **col1** col1 | *[in]* **col2** col2 .. c:function:: void glm_mat2_swap_row(mat2 mat, int row1, int row2) swap two matrix rows Parameters: | *[in, out]* **mat** matrix | *[in]* **row1** row1 | *[in]* **row2** row2 .. c:function:: float glm_mat2_rmc(vec2 r, mat2 m, vec2 c) | **rmc** stands for **Row** * **Matrix** * **Column** | helper for R (row vector) * M (matrix) * C (column vector) | the result is scalar because R * M = Matrix1x2 (row vector), | then Matrix1x2 * Vec2 (column vector) = Matrix1x1 (Scalar) Parameters: | *[in]* **r** row vector or matrix1x2 | *[in]* **m** matrix2x2 | *[in]* **c** column vector or matrix2x1 Returns: scalar value e.g. Matrix1x1 .. c:function:: void glm_mat2_make(const float * __restrict src, mat2 dest) Create mat2 matrix from pointer .. note:: **@src** must contain at least 4 elements. Parameters: | *[in]* **src** pointer to an array of floats | *[out]* **dest** destination matrix2x2 cglm-0.9.6/docs/source/mat2x3.rst000066400000000000000000000065641475344456400166030ustar00rootroot00000000000000.. default-domain:: C mat2x3 ====== Header: cglm/mat2x3.h Table of contents (click to go): ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Macros: 1. GLM_MAT2X3_ZERO_INIT #. GLM_MAT2X3_ZERO Functions: 1. :c:func:`glm_mat2x3_copy` #. :c:func:`glm_mat2x3_zero` #. :c:func:`glm_mat2x3_make` #. :c:func:`glm_mat2x3_mul` #. :c:func:`glm_mat2x3_mulv` #. :c:func:`glm_mat2x3_transpose` #. :c:func:`glm_mat2x3_scale` Represented ~~~~~~~~~~~ .. csv-table:: mat2x3 :header: "", "column 1", "column 2" "row 1", "m00", "m10" "row 2", "m01", "m11" "row 3", "m02", "m12" Functions documentation ~~~~~~~~~~~~~~~~~~~~~~~ .. c:function:: void glm_mat2x3_copy(mat2x3 mat, mat2x3 dest) copy mat2x3 to another one (dest). Parameters: | *[in]* **mat** source | *[out]* **dest** destination .. c:function:: void glm_mat2x3_zero(mat2x3 mat) make given matrix zero Parameters: | *[in,out]* **mat** matrix .. c:function:: void glm_mat2x3_make(const float * __restrict src, mat2x3 dest) Create mat2x3 matrix from pointer .. note:: **@src** must contain at least 6 elements. Parameters: | *[in]* **src** pointer to an array of floats | *[out]* **dest** destination matrix2x3 .. c:function:: void glm_mat2x3_mul(mat2x3 m1, mat3x2 m2, mat3 dest) multiply m1 and m2 to dest .. code-block:: c glm_mat2x3_mul(mat2x3, mat3x2, mat3); Parameters: | *[in]* **m1** left matrix (mat2x3) | *[in]* **m2** right matrix (mat3x2) | *[out]* **dest** destination matrix (mat3) .. csv-table:: mat2x3 :header: "", "column 1", "column 2" "row 1", "a00", "a10" "row 2", "a01", "a11" "row 3", "a02", "a12" .. csv-table:: mat3x2 :header: "", "column 1", "column 2", "column 3" "row 1", "b00", "b10", "b20" "row 2", "b01", "b11", "b21" .. csv-table:: mat3x3 :header: "", "column 1", "column 2", "column 3" "row 1", "a00 * b00 + a10 * b01", "a00 * b10 + a10 * b11", "a00 * b20 + a10 * b21" "row 2", "a01 * b00 + a11 * b01", "a01 * b10 + a11 * b11", "a01 * b20 + a11 * b21" "row 3", "a02 * b00 + a12 * b01", "a02 * b10 + a12 * b11", "a02 * b20 + a12 * b21" .. c:function:: void glm_mat2x3_mulv(mat2x3 m, vec2 v, vec3 dest) multiply mat2x3 with vec2 (column vector) and store in dest column vector Parameters: | *[in]* **m** mat2x3 (left) | *[in]* **v** vec3 (right, column vector) | *[out]* **dest** destination (result, column vector) .. csv-table:: mat2x3 :header: "", "column 1", "column 2" "row 1", "m00", "m10" "row 2", "m01", "m11" "row 3", "m02", "m12" .. csv-table:: column vec2 (1x2) :header: "", "column 1" "row 1", "v0" "row 2", "v1" .. csv-table:: column vec3 (1x3) :header: "", "column 1" "row 1", "m00 * v0 + m10 * v1" "row 2", "m01 * v0 + m11 * v1" "row 3", "m02 * v0 + m12 * v1" .. c:function:: void glm_mat2x3_transpose(mat2x3 m, mat3x2 dest) transpose matrix and store in dest Parameters: | *[in]* **m** matrix | *[out]* **dest** destination .. c:function:: void glm_mat2x3_scale(mat2x3 m, float s) multiply matrix with scalar Parameters: | *[in, out]* **m** matrix | *[in]* **s** scalar cglm-0.9.6/docs/source/mat2x4.rst000066400000000000000000000073251475344456400166000ustar00rootroot00000000000000.. default-domain:: C mat2x4 ====== Header: cglm/mat2x4.h Table of contents (click to go): ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Macros: 1. GLM_MAT2X4_ZERO_INIT #. GLM_MAT2X4_ZERO Functions: 1. :c:func:`glm_mat2x4_copy` #. :c:func:`glm_mat2x4_zero` #. :c:func:`glm_mat2x4_make` #. :c:func:`glm_mat2x4_mul` #. :c:func:`glm_mat2x4_mulv` #. :c:func:`glm_mat2x4_transpose` #. :c:func:`glm_mat2x4_scale` Represented ~~~~~~~~~~~ .. csv-table:: mat2x4 :header: "", "column 1", "column 2" "row 1", "m00", "m10" "row 2", "m01", "m11" "row 3", "m02", "m12" "row 4", "m03", "m13" Functions documentation ~~~~~~~~~~~~~~~~~~~~~~~ .. c:function:: void glm_mat2x4_copy(mat2x4 mat, mat2x4 dest) copy mat2x4 to another one (dest). Parameters: | *[in]* **mat** source | *[out]* **dest** destination .. c:function:: void glm_mat2x4_zero(mat2x4 mat) make given matrix zero Parameters: | *[in,out]* **mat** matrix .. c:function:: void glm_mat2x4_make(const float * __restrict src, mat2x4 dest) Create mat2x4 matrix from pointer .. note:: **@src** must contain at least 8 elements. Parameters: | *[in]* **src** pointer to an array of floats | *[out]* **dest** destination matrix2x4 .. c:function:: void glm_mat2x4_mul(mat2x4 m1, mat4x2 m2, mat4 dest) multiply m1 and m2 to dest .. code-block:: c glm_mat2x4_mul(mat2x4, mat4x2, mat4); Parameters: | *[in]* **m1** left matrix (mat2x4) | *[in]* **m2** right matrix (mat4x2) | *[out]* **dest** destination matrix (mat4) .. csv-table:: mat2x4 :header: "", "column 1", "column 2" "row 1", "a00", "a10" "row 2", "a01", "a11" "row 3", "a02", "a12" "row 4", "a03", "a13" .. csv-table:: mat4x2 :header: "", "column 1", "column 2", "column 3", "column 4" "row 1", "b00", "b10", "b20", "b30" "row 2", "b01", "b11", "b21", "b31" .. csv-table:: mat4x4 :header: "", "column 1", "column 2", "column 3", "column 4" "row 1", "a00 * b00 + a10 * b01", "a00 * b10 + a10 * b11", "a00 * b20 + a10 * b21", "a00 * b30 + a10 * b31" "row 2", "a01 * b00 + a11 * b01", "a01 * b10 + a11 * b11", "a01 * b20 + a11 * b21", "a01 * b30 + a11 * b31" "row 3", "a02 * b00 + a12 * b01", "a02 * b10 + a12 * b11", "a02 * b20 + a12 * b21", "a02 * b30 + a12 * b31" "row 4", "a03 * b00 + a13 * b01", "a03 * b10 + a13 * b11", "a03 * b20 + a13 * b21", "a03 * b30 + a13 * b31" .. c:function:: void glm_mat2x4_mulv(mat2x4 m, vec2 v, vec4 dest) multiply mat2x4 with vec2 (column vector) and store in dest column vector Parameters: | *[in]* **m** mat2x4 (left) | *[in]* **v** vec2 (right, column vector) | *[out]* **dest** destination (result, column vector) .. csv-table:: mat2x4 :header: "", "column 1", "column 2" "row 1", "m00", "m10" "row 2", "m01", "m11" "row 3", "m02", "m12" "row 4", "m03", "m13" .. csv-table:: column vec2 (1x2) :header: "", "column 1" "row 1", "v0" "row 2", "v1" .. csv-table:: column vec4 (1x4) :header: "", "column 1" "row 1", "m00 * v0 + m10 * v1" "row 2", "m01 * v0 + m11 * v1" "row 3", "m02 * v0 + m12 * v1" "row 4", "m03 * v0 + m13 * v1" .. c:function:: void glm_mat2x4_transpose(mat2x4 m, mat4x2 dest) transpose matrix and store in dest Parameters: | *[in]* **m** matrix | *[out]* **dest** destination .. c:function:: void glm_mat2x4_scale(mat2x4 m, float s) multiply matrix with scalar Parameters: | *[in, out]* **m** matrix | *[in]* **s** scalar cglm-0.9.6/docs/source/mat3.rst000066400000000000000000000115561475344456400163260ustar00rootroot00000000000000.. default-domain:: C mat3 ==== Header: cglm/mat3.h Table of contents (click to go): ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Macros: 1. GLM_MAT3_IDENTITY_INIT #. GLM_MAT3_ZERO_INIT #. GLM_MAT3_IDENTITY #. GLM_MAT3_ZERO #. glm_mat3_dup(mat, dest) Functions: 1. :c:func:`glm_mat3_copy` #. :c:func:`glm_mat3_identity` #. :c:func:`glm_mat3_identity_array` #. :c:func:`glm_mat3_zero` #. :c:func:`glm_mat3_mul` #. :c:func:`glm_mat3_transpose_to` #. :c:func:`glm_mat3_transpose` #. :c:func:`glm_mat3_mulv` #. :c:func:`glm_mat3_quat` #. :c:func:`glm_mat3_scale` #. :c:func:`glm_mat3_det` #. :c:func:`glm_mat3_inv` #. :c:func:`glm_mat3_trace` #. :c:func:`glm_mat3_swap_col` #. :c:func:`glm_mat3_swap_row` #. :c:func:`glm_mat3_rmc` #. :c:func:`glm_mat3_make` Functions documentation ~~~~~~~~~~~~~~~~~~~~~~~ .. c:function:: void glm_mat3_copy(mat3 mat, mat3 dest) copy mat3 to another one (dest). Parameters: | *[in]* **mat** source | *[out]* **dest** destination .. c:function:: void glm_mat3_identity(mat3 mat) copy identity mat3 to mat, or makes mat to identity Parameters: | *[out]* **mat** matrix .. c:function:: void glm_mat3_identity_array(mat3 * __restrict mat, size_t count) make given matrix array's each element identity matrix Parameters: | *[in,out]* **mat** matrix array (must be aligned (16/32) if alignment is not disabled) | *[in]* **count** count of matrices .. c:function:: void glm_mat3_zero(mat3 mat) make given matrix zero Parameters: | *[in,out]* **mat** matrix to .. c:function:: void glm_mat3_mul(mat3 m1, mat3 m2, mat3 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 mat3 m = GLM_MAT3_IDENTITY_INIT; glm_mat3_mul(m, m, m); Parameters: | *[in]* **m1** left matrix | *[in]* **m2** right matrix | *[out]* **dest** destination matrix .. c:function:: void glm_mat3_transpose_to(mat3 m, mat3 dest) transpose mat4 and store in dest source matrix will not be transposed unless dest is m Parameters: | *[in]* **mat** source | *[out]* **dest** destination .. c:function:: void glm_mat3_transpose(mat3 m) transpose mat3 and store result in same matrix Parameters: | *[in]* **mat** source | *[out]* **dest** destination .. c:function:: void glm_mat3_mulv(mat3 m, vec3 v, vec3 dest) multiply mat3 with vec3 (column vector) and store in dest vector Parameters: | *[in]* **m** mat3 (left) | *[in]* **v** vec3 (right, column vector) | *[out]* **dest** destination (result, column vector) .. c:function:: void glm_mat3_quat(mat3 m, versor dest) convert mat3 to quaternion Parameters: | *[in]* **m** rotation matrix | *[out]* **dest** destination quaternion .. c:function:: void glm_mat3_scale(mat3 m, float s) multiply matrix with scalar Parameters: | *[in, out]* **m** matrix | *[in]* **s** scalar .. c:function:: float glm_mat3_det(mat3 mat) returns mat3 determinant Parameters: | *[in]* **mat** matrix Returns: mat3 determinant .. c:function:: void glm_mat3_inv(mat3 mat, mat3 dest) inverse mat3 and store in dest Parameters: | *[in]* **mat** matrix | *[out]* **dest** destination (inverse matrix) .. c:function:: void glm_mat3_trace(mat3 m) | sum of the elements on the main diagonal from upper left to the lower right Parameters: | *[in]* **m** matrix Returns: trace of matrix .. c:function:: void glm_mat3_swap_col(mat3 mat, int col1, int col2) swap two matrix columns Parameters: | *[in, out]* **mat** matrix | *[in]* **col1** col1 | *[in]* **col2** col2 .. c:function:: void glm_mat3_swap_row(mat3 mat, int row1, int row2) swap two matrix rows Parameters: | *[in, out]* **mat** matrix | *[in]* **row1** row1 | *[in]* **row2** row2 .. c:function:: float glm_mat3_rmc(vec3 r, mat3 m, vec3 c) | **rmc** stands for **Row** * **Matrix** * **Column** | helper for R (row vector) * M (matrix) * C (column vector) | the result is scalar because R * M = Matrix1x3 (row vector), | then Matrix1x3 * Vec3 (column vector) = Matrix1x1 (Scalar) Parameters: | *[in]* **r** row vector or matrix1x3 | *[in]* **m** matrix3x3 | *[in]* **c** column vector or matrix3x1 Returns: scalar value e.g. Matrix1x1 .. c:function:: void glm_mat3_make(const float * __restrict src, mat3 dest) Create mat3 matrix from pointer .. note:: **@src** must contain at least 9 elements. Parameters: | *[in]* **src** pointer to an array of floats | *[out]* **dest** destination matrix3x3 cglm-0.9.6/docs/source/mat3x2.rst000066400000000000000000000064061475344456400165760ustar00rootroot00000000000000.. default-domain:: C mat3x2 ====== Header: cglm/mat3x2.h Table of contents (click to go): ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Macros: 1. GLM_MAT3X2_ZERO_INIT #. GLM_MAT3X2_ZERO Functions: 1. :c:func:`glm_mat3x2_copy` #. :c:func:`glm_mat3x2_zero` #. :c:func:`glm_mat3x2_make` #. :c:func:`glm_mat3x2_mul` #. :c:func:`glm_mat3x2_mulv` #. :c:func:`glm_mat3x2_transpose` #. :c:func:`glm_mat3x2_scale` Represented ~~~~~~~~~~~ .. csv-table:: mat3x2 :header: "", "column 1", "column 2", "column 3" "row 1", "m00", "m10", "m20" "row 2", "m01", "m11", "m21" Functions documentation ~~~~~~~~~~~~~~~~~~~~~~~ .. c:function:: void glm_mat3x2_copy(mat3x2 mat, mat3x2 dest) copy mat3x2 to another one (dest). Parameters: | *[in]* **mat** source | *[out]* **dest** destination .. c:function:: void glm_mat3x2_zero(mat3x2 mat) make given matrix zero Parameters: | *[in,out]* **mat** matrix .. c:function:: void glm_mat3x2_make(const float * __restrict src, mat3x2 dest) Create mat3x2 matrix from pointer .. note:: **@src** must contain at least 6 elements. Parameters: | *[in]* **src** pointer to an array of floats | *[out]* **dest** destination matrix3x2 .. c:function:: void glm_mat3x2_mul(mat3x2 m1, mat2x3 m2, mat2 dest) multiply m1 and m2 to dest .. code-block:: c glm_mat3x2_mul(mat3x2, mat2x3, mat2); Parameters: | *[in]* **m1** left matrix (mat3x2) | *[in]* **m2** right matrix (mat2x3) | *[out]* **dest** destination matrix (mat2) .. csv-table:: mat3x2 :header: "", "column 1", "column 2", "column 3" "row 1", "a00", "a10", "a20" "row 2", "a01", "a11", "a21" .. csv-table:: mat2x3 :header: "", "column 1", "column 2" "row 1", "b00", "b10" "row 2", "b01", "b11" "row 3", "b02", "b12" .. csv-table:: mat2x2 :header: "", "column 1", "column 2" "row 1", "a00 * b00 + a10 * b01 + a20 * b02", "a00 * b10 + a10 * b11 + a20 * b12" "row 2", "a01 * b00 + a11 * b01 + a21 * b02", "a01 * b10 + a11 * b11 + a21 * b12" .. c:function:: void glm_mat3x2_mulv(mat3x2 m, vec3 v, vec2 dest) multiply mat3x2 with vec3 (column vector) and store in dest vector Parameters: | *[in]* **m** mat3x2 (left) | *[in]* **v** vec3 (right, column vector) | *[out]* **dest** destination (result, column vector) .. csv-table:: mat3x2 :header: "", "column 1", "column 2", "column 3" "row 1", "m00", "m10", "m20" "row 2", "m01", "m11", "m21" .. csv-table:: column vec3 (1x3) :header: "", "column 1" "row 1", "v0" "row 2", "v1" "row 3", "v2" .. csv-table:: column vec2 (1x2) :header: "", "column 1" "row 1", "m00 * v0 + m10 * v1 + m20 * v2" "row 2", "m01 * v0 + m11 * v1 + m21 * v2" .. c:function:: void glm_mat3x2_transpose(mat3x2 m, mat2x3 dest) transpose matrix and store in dest Parameters: | *[in]* **m** matrix | *[out]* **dest** destination .. c:function:: void glm_mat3x2_scale(mat3x2 m, float s) multiply matrix with scalar Parameters: | *[in, out]* **m** matrix | *[in]* **s** scalar cglm-0.9.6/docs/source/mat3x4.rst000066400000000000000000000101661475344456400165760ustar00rootroot00000000000000.. default-domain:: C mat3x4 ====== Header: cglm/mat3x4.h Table of contents (click to go): ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Macros: 1. GLM_MAT3X4_ZERO_INIT #. GLM_MAT3X4_ZERO Functions: 1. :c:func:`glm_mat3x4_copy` #. :c:func:`glm_mat3x4_zero` #. :c:func:`glm_mat3x4_make` #. :c:func:`glm_mat3x4_mul` #. :c:func:`glm_mat3x4_mulv` #. :c:func:`glm_mat3x4_transpose` #. :c:func:`glm_mat3x4_scale` Represented ~~~~~~~~~~~ .. csv-table:: mat3x4 :header: "", "column 1", "column 2", "column 3" "row 1", "m00", "m10", "m20" "row 2", "m01", "m11", "m21" "row 3", "m02", "m12", "m22" "row 4", "m03", "m13", "m23" Functions documentation ~~~~~~~~~~~~~~~~~~~~~~~ .. c:function:: void glm_mat3x4_copy(mat3x4 mat, mat3x4 dest) copy mat3x4 to another one (dest). Parameters: | *[in]* **mat** source | *[out]* **dest** destination .. c:function:: void glm_mat3x4_zero(mat3x4 mat) make given matrix zero Parameters: | *[in,out]* **mat** matrix .. c:function:: void glm_mat3x4_make(const float * __restrict src, mat3x4 dest) Create mat3x4 matrix from pointer .. note::: **@src** must contain at least 12 elements. Parameters: | *[in]* **src** pointer to an array of floats | *[out]* **dest** destination matrix3x4 .. c:function:: void glm_mat3x4_mul(mat3x4 m1, mat4x3 m2, mat4 dest) multiply m1 and m2 to dest .. code-block:: c glm_mat3x4_mul(mat3x4, mat4x3, mat4); Parameters: | *[in]* **m1** left matrix (mat3x4) | *[in]* **m2** right matrix (mat4x3) | *[out]* **dest** destination matrix (mat4) .. csv-table:: mat3x4 :header: "", "column 1", "column 2", "column 3" "row 1", "a00", "a10", "a20" "row 2", "a01", "a11", "a21" "row 3", "a02", "a12", "a22" "row 4", "a03", "a13", "a23" .. csv-table:: mat4x3 :header: "", "column 1", "column 2", "column 3", "column 4" "row 1", "b00", "b10", "b20", "b30" "row 2", "b01", "b11", "b21", "b31" "row 3", "b02", "b12", "b22", "b32" .. csv-table:: mat4x4 :header: "", "column 1", "column 2", "column 3", "column 4" "row 1", "a00 * b00 + a10 * b01 + a20 * b02", "a00 * b10 + a10 * b11 + a20 * b12", "a00 * b20 + a10 * b21 + a20 * b22", "a00 * b30 + a10 * b31 + a20 * b32" "row 2", "a01 * b00 + a11 * b01 + a21 * b02", "a01 * b10 + a11 * b11 + a21 * b12", "a01 * b20 + a11 * b21 + a21 * b22", "a01 * b30 + a11 * b31 + a21 * b32" "row 3", "a02 * b00 + a12 * b01 + a22 * b02", "a02 * b10 + a12 * b11 + a22 * b12", "a02 * b20 + a12 * b21 + a22 * b22", "a02 * b30 + a12 * b31 + a22 * b32" "row 4", "a03 * b00 + a13 * b01 + a23 * b02", "a03 * b10 + a13 * b11 + a23 * b12", "a03 * b20 + a13 * b21 + a23 * b22", "a03 * b30 + a13 * b31 + a23 * b32" .. c:function:: void glm_mat3x4_mulv(mat3x4 m, vec3 v, vec4 dest) multiply mat3x4 with vec3 (column vector) and store in dest vector Parameters: | *[in]* **m** mat3x4 (left) | *[in]* **v** vec3 (right, column vector) | *[out]* **dest** destination (result, column vector) .. csv-table:: mat3x4 :header: "", "column 1", "column 2", "column 3" "row 1", "m00", "m10", "m20" "row 2", "m01", "m11", "m21" "row 3", "m02", "m12", "m22" "row 4", "m03", "m13", "m23" .. csv-table:: column vec3 (1x3) :header: "", "column 1" "row 1", "v0" "row 2", "v1" "row 3", "v2" .. csv-table:: column vec4 (1x4) :header: "", "column 1" "row 1", "m00 * v0 + m10 * v1 + m20 * v2" "row 2", "m01 * v0 + m11 * v1 + m21 * v2" "row 3", "m02 * v0 + m12 * v1 + m22 * v2" "row 4", "m03 * v0 + m13 * v1 + m23 * v2" .. c:function:: void glm_mat3x4_transpose(mat3x4 m, mat4x3 dest) transpose matrix and store in dest Parameters: | *[in]* **m** matrix | *[out]* **dest** destination .. c:function:: void glm_mat3x4_scale(mat3x4 m, float s) multiply matrix with scalar Parameters: | *[in, out]* **m** matrix | *[in]* **s** scalar cglm-0.9.6/docs/source/mat4.rst000066400000000000000000000204701475344456400163220ustar00rootroot00000000000000.. default-domain:: C mat4 ==== Header: cglm/mat4.h Important: :c:func:`glm_mat4_scale` multiplies mat4 with scalar, if you need to apply scale transform use :c:func:`glm_scale` functions. Table of contents (click to go): ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Macros: 1. GLM_MAT4_IDENTITY_INIT #. GLM_MAT4_ZERO_INIT #. GLM_MAT4_IDENTITY #. GLM_MAT4_ZERO #. glm_mat4_udup(mat, dest) #. glm_mat4_dup(mat, dest) Functions: 1. :c:func:`glm_mat4_ucopy` #. :c:func:`glm_mat4_copy` #. :c:func:`glm_mat4_identity` #. :c:func:`glm_mat4_identity_array` #. :c:func:`glm_mat4_zero` #. :c:func:`glm_mat4_pick3` #. :c:func:`glm_mat4_pick3t` #. :c:func:`glm_mat4_ins3` #. :c:func:`glm_mat4_mul` #. :c:func:`glm_mat4_mulN` #. :c:func:`glm_mat4_mulv` #. :c:func:`glm_mat4_mulv3` #. :c:func:`glm_mat4_trace` #. :c:func:`glm_mat4_trace3` #. :c:func:`glm_mat4_quat` #. :c:func:`glm_mat4_transpose_to` #. :c:func:`glm_mat4_transpose` #. :c:func:`glm_mat4_scale_p` #. :c:func:`glm_mat4_scale` #. :c:func:`glm_mat4_det` #. :c:func:`glm_mat4_inv` #. :c:func:`glm_mat4_inv_fast` #. :c:func:`glm_mat4_swap_col` #. :c:func:`glm_mat4_swap_row` #. :c:func:`glm_mat4_rmc` #. :c:func:`glm_mat4_make` Functions documentation ~~~~~~~~~~~~~~~~~~~~~~~ .. c:function:: void glm_mat4_ucopy(mat4 mat, mat4 dest) copy mat4 to another one (dest). u means align is not required for dest Parameters: | *[in]* **mat** source | *[out]* **dest** destination .. c:function:: void glm_mat4_copy(mat4 mat, mat4 dest) copy mat4 to another one (dest). Parameters: | *[in]* **mat** source | *[out]* **dest** destination .. c:function:: void glm_mat4_identity(mat4 mat) copy identity mat4 to mat, or makes mat to identity Parameters: | *[out]* **mat** matrix .. c:function:: void glm_mat4_identity_array(mat4 * __restrict mat, size_t count) make given matrix array's each element identity matrix Parameters: | *[in,out]* **mat** matrix array (must be aligned (16/32) if alignment is not disabled) | *[in]* **count** count of matrices .. c:function:: void glm_mat4_zero(mat4 mat) make given matrix zero Parameters: | *[in,out]* **mat** matrix to .. c:function:: void glm_mat4_pick3(mat4 mat, mat3 dest) copy upper-left of mat4 to mat3 Parameters: | *[in]* **mat** source | *[out]* **dest** destination .. c:function:: void glm_mat4_pick3t(mat4 mat, mat4 dest) copy upper-left of mat4 to mat3 (transposed) the postfix t stands for transpose Parameters: | *[in]* **mat** source | *[out]* **dest** destination .. c:function:: void glm_mat4_ins3(mat3 mat, mat4 dest) copy mat3 to mat4's upper-left. this function does not fill mat4's other elements. To do that use glm_mat4. Parameters: | *[in]* **mat** source | *[out]* **dest** destination .. c:function:: void glm_mat4_mul(mat4 m1, mat4 m2, mat4 dest) multiply m1 and m2 to dest m1, m2 and dest matrices can be same matrix, it is possible to write this: .. code-block:: c mat4 m = GLM_MAT4_IDENTITY_INIT; glm_mat4_mul(m, m, m); Parameters: | *[in]* **m1** left matrix | *[in]* **m2** right matrix | *[out]* **dest** destination matrix .. c:function:: void glm_mat4_mulN(mat4 * __restrict matrices[], int len, mat4 dest) mupliply N mat4 matrices and store result in dest | this function lets you multiply multiple (more than two or more...) | matrices | multiplication will be done in loop, this may reduce instructions | size but if **len** is too small then compiler may unroll whole loop .. code-block:: c mat m1, m2, m3, m4, res; glm_mat4_mulN((mat4 *[]){&m1, &m2, &m3, &m4}, 4, res); Parameters: | *[in]* **matrices** array of mat4 | *[in]* **len** matrices count | *[out]* **dest** destination matrix .. c:function:: void glm_mat4_mulv(mat4 m, vec4 v, vec4 dest) multiply mat4 with vec4 (column vector) and store in dest vector Parameters: | *[in]* **m** mat4 (left) | *[in]* **v** vec4 (right, column vector) | *[out]* **dest** vec4 (result, column vector) .. c:function:: void glm_mat4_mulv3(mat4 m, vec3 v, float last, vec3 dest) | multiply **vec3** with **mat4** and get **vec3** as result | | actually the result is **vec4**, after multiplication, the last component is trimmed, if you need the result's last component then don't use this function and consider to use **glm_mat4_mulv()** Parameters: | *[in]* **m** mat4(affine transform) | *[in]* **v** vec3 | *[in]* **last** 4th item to make it vec4 | *[out]* **dest** result vector (vec3) .. c:function:: void glm_mat4_trace(mat4 m) | sum of the elements on the main diagonal from upper left to the lower right Parameters: | *[in]* **m** matrix Returns: trace of matrix .. c:function:: void glm_mat4_trace3(mat4 m) | trace of matrix (rotation part) | sum of the elements on the main diagonal from upper left to the lower right Parameters: | *[in]* **m** matrix Returns: trace of matrix .. c:function:: void glm_mat4_quat(mat4 m, versor dest) convert mat4's rotation part to quaternion Parameters: | *[in]* **m** affine matrix | *[out]* **dest** destination quaternion .. c:function:: void glm_mat4_transpose_to(mat4 m, mat4 dest) transpose mat4 and store in dest source matrix will not be transposed unless dest is m Parameters: | *[in]* **m** matrix | *[out]* **dest** destination matrix .. c:function:: void glm_mat4_transpose(mat4 m) transpose mat4 and store result in same matrix Parameters: | *[in]* **m** source | *[out]* **dest** destination matrix .. c:function:: void glm_mat4_scale_p(mat4 m, float s) scale (multiply with scalar) matrix without simd optimization Parameters: | *[in, out]* **m** matrix | *[in]* **s** scalar .. c:function:: void glm_mat4_scale(mat4 m, float s) scale (multiply with scalar) matrix THIS IS NOT SCALE TRANSFORM, use glm_scale for that. Parameters: | *[in, out]* **m** matrix | *[in]* **s** scalar .. c:function:: float glm_mat4_det(mat4 mat) mat4 determinant Parameters: | *[in]* **mat** matrix Return: | determinant .. c:function:: void glm_mat4_inv(mat4 mat, mat4 dest) inverse mat4 and store in dest Parameters: | *[in]* **mat** source | *[out]* **dest** destination matrix (inverse matrix) .. c:function:: void glm_mat4_inv_fast(mat4 mat, mat4 dest) inverse mat4 and store in dest | this func uses reciprocal approximation without extra corrections | e.g Newton-Raphson. this should work faster than normal, | to get more precise use glm_mat4_inv version. .. note:: You will lose precision, glm_mat4_inv is more accurate Parameters: | *[in]* **mat** source | *[out]* **dest** destination .. c:function:: void glm_mat4_swap_col(mat4 mat, int col1, int col2) swap two matrix columns Parameters: | *[in, out]* **mat** matrix | *[in]* **col1** col1 | *[in]* **col2** col2 .. c:function:: void glm_mat4_swap_row(mat4 mat, int row1, int row2) swap two matrix rows Parameters: | *[in, out]* **mat** matrix | *[in]* **row1** row1 | *[in]* **row2** row2 .. c:function:: float glm_mat4_rmc(vec4 r, mat4 m, vec4 c) | **rmc** stands for **Row** * **Matrix** * **Column** | helper for R (row vector) * M (matrix) * C (column vector) | the result is scalar because R * M = Matrix1x4 (row vector), | then Matrix1x4 * Vec4 (column vector) = Matrix1x1 (Scalar) Parameters: | *[in]* **r** row vector or matrix1x4 | *[in]* **m** matrix4x4 | *[in]* **c** column vector or matrix4x1 Returns: scalar value e.g. Matrix1x1 .. c:function:: void glm_mat4_make(const float * __restrict src, mat4 dest) Create mat4 matrix from pointer .. note:: **@src** must contain at least 16 elements. Parameters: | *[in]* **src** pointer to an array of floats | *[out]* **dest** destination matrix4x4 cglm-0.9.6/docs/source/mat4x2.rst000066400000000000000000000067751475344456400166100ustar00rootroot00000000000000.. default-domain:: C mat4x2 ====== Header: cglm/mat4x2.h Table of contents (click to go): ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Macros: 1. GLM_MAT4X2_ZERO_INIT #. GLM_MAT4X2_ZERO Functions: 1. :c:func:`glm_mat4x2_copy` #. :c:func:`glm_mat4x2_zero` #. :c:func:`glm_mat4x2_make` #. :c:func:`glm_mat4x2_mul` #. :c:func:`glm_mat4x2_mulv` #. :c:func:`glm_mat4x2_transpose` #. :c:func:`glm_mat4x2_scale` Represented ~~~~~~~~~~~ .. csv-table:: mat4x2 :header: "", "column 1", "column 2", "column 3", "column4" "row 1", "m00", "m10", "m20", "m30" "row 2", "m01", "m11", "m21", "m31" Functions documentation ~~~~~~~~~~~~~~~~~~~~~~~ .. c:function:: void glm_mat4x2_copy(mat4x2 mat, mat4x2 dest) copy mat4x2 to another one (dest). Parameters: | *[in]* **mat** source | *[out]* **dest** destination .. c:function:: void glm_mat4x2_zero(mat4x2 mat) make given matrix zero Parameters: | *[in,out]* **mat** matrix .. c:function:: void glm_mat4x2_make(const float * __restrict src, mat4x2 dest) Create mat4x2 matrix from pointer .. note:: **@src** must contain at least 8 elements. Parameters: | *[in]* **src** pointer to an array of floats | *[out]* **dest** destination matrix4x2 .. c:function:: void glm_mat4x2_mul(mat4x2 m1, mat2x4 m2, mat2 dest) multiply m1 and m2 to dest .. code-block:: c glm_mat4x2_mul(mat4x2, mat2x4, mat2); Parameters: | *[in]* **m1** left matrix (mat4x2) | *[in]* **m2** right matrix (mat2x4) | *[out]* **dest** destination matrix (mat2) .. csv-table:: mat4x2 :header: "", "column 1", "column 2", "column 3", "column 4" "row 1", "a00", "a10", "a20", "a30" "row 2", "a01", "a11", "a21", "a31" .. csv-table:: mat2x4 :header: "", "column 1", "column 2" "row 1", "b00", "b10" "row 2", "b01", "b11" "row 3", "b02", "b12" "row 4", "b03", "b13" .. csv-table:: mat2x2 :header: "", "column 1", "column 2" "row 1", "a00 * b00 + a10 * b01 + a20 * b02 + a30 * b03", "a00 * b10 + a10 * b11 + a20 * b12 + a30 * b13" "row 2", "a01 * b00 + a11 * b01 + a21 * b02 + a31 * b03", "a01 * b10 + a11 * b11 + a21 * b12 + a31 * b13" .. c:function:: void glm_mat4x2_mulv(mat4x2 m, vec4 v, vec2 dest) multiply mat4x2 with vec4 (column vector) and store in dest vector Parameters: | *[in]* **m** mat4x2 (left) | *[in]* **v** vec4 (right, column vector) | *[out]* **dest** destination (result, column vector) .. csv-table:: mat4x2 :header: "", "column 1", "column 2", "column 3" "row 1", "m00", "m10", "m20" "row 2", "m01", "m11", "m21" "row 3", "m02", "m12", "m22" "row 4", "m03", "m13", "m23" .. csv-table:: column vec4 (1x4) :header: "", "column 1" "row 1", "v0" "row 2", "v1" "row 3", "v2" "row 4", "v3" .. csv-table:: column vec2 (1x2) :header: "", "column 1" "row 1", "m00 * v0 + m10 * v1 + m20 * v2 + m30 * v3" "row 2", "m01 * v0 + m11 * v1 + m21 * v2 + m31 * v3" .. c:function:: void glm_mat4x2_transpose(mat4x2 m, mat2x4 dest) transpose matrix and store in dest Parameters: | *[in]* **m** matrix | *[out]* **dest** destination .. c:function:: void glm_mat4x2_scale(mat4x2 m, float s) multiply matrix with scalar Parameters: | *[in, out]* **m** matrix | *[in]* **s** scalar cglm-0.9.6/docs/source/mat4x3.rst000066400000000000000000000077121475344456400166010ustar00rootroot00000000000000.. default-domain:: C mat4x3 ====== Header: cglm/mat4x3.h Table of contents (click to go): ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Macros: 1. GLM_MAT4X3_ZERO_INIT #. GLM_MAT4X3_ZERO Functions: 1. :c:func:`glm_mat4x3_copy` #. :c:func:`glm_mat4x3_zero` #. :c:func:`glm_mat4x3_make` #. :c:func:`glm_mat4x3_mul` #. :c:func:`glm_mat4x3_mulv` #. :c:func:`glm_mat4x3_transpose` #. :c:func:`glm_mat4x3_scale` Represented ~~~~~~~~~~~ .. csv-table:: mat4x3 :header: "", "column 1", "column 2", "column 3", "column4" "row 1", "m00", "m10", "m20", "m30" "row 2", "m01", "m11", "m21", "m31" "row 3", "m02", "m12", "m22", "m32" Functions documentation ~~~~~~~~~~~~~~~~~~~~~~~ .. c:function:: void glm_mat4x3_copy(mat4x3 mat, mat4x3 dest) copy mat4x3 to another one (dest). Parameters: | *[in]* **mat** source | *[out]* **dest** destination .. c:function:: void glm_mat4x3_zero(mat4x3 mat) make given matrix zero Parameters: | *[in,out]* **mat** matrix .. c:function:: void glm_mat4x3_make(const float * __restrict src, mat4x3 dest) Create mat4x3 matrix from pointer .. note:: **@src** must contain at least 12 elements. Parameters: | *[in]* **src** pointer to an array of floats | *[out]* **dest** destination matrix4x3 .. c:function:: void glm_mat4x3_mul(mat4x3 m1, mat3x4 m2, mat3 dest) multiply m1 and m2 to dest .. code-block:: c glm_mat4x3_mul(mat4x3, mat3x4, mat3); Parameters: | *[in]* **m1** left matrix (mat4x3) | *[in]* **m2** right matrix (mat3x4) | *[out]* **dest** destination matrix (mat3) .. csv-table:: mat4x3 :header: "", "column 1", "column 2", "column 3", "column 4" "row 1", "a00", "a10", "a20", "a30" "row 2", "a01", "a11", "a21", "a31" "row 3", "a02", "a12", "a22", "a32" .. csv-table:: mat3x4 :header: "", "column 1", "column 2", "column 3" "row 1", "b00", "b10", "b20" "row 2", "b01", "b11", "b21" "row 3", "b02", "b12", "b22" "row 4", "b03", "b13", "b23" .. csv-table:: mat3x3 :header: "", "column 1", "column 2", "column 3" "row 1", "a00 * b00 + a10 * b01 + a20 * b02 + a30 * b03", "a00 * b10 + a10 * b11 + a20 * b12 + a30 * b13", "a00 * b20 + a10 * b21 + a20 * b22 + a30 * b23" "row 2", "a01 * b00 + a11 * b01 + a21 * b02 + a31 * b03", "a01 * b10 + a11 * b11 + a21 * b12 + a31 * b13", "a01 * b20 + a11 * b21 + a21 * b22 + a31 * b23" "row 3", "a02 * b00 + a12 * b01 + a22 * b02 + a32 * b03", "a02 * b10 + a12 * b11 + a22 * b12 + a32 * b13", "a02 * b20 + a12 * b21 + a22 * b22 + a32 * b23" .. c:function:: void glm_mat4x3_mulv(mat4x3 m, vec4 v, vec3 dest) multiply mat4x3 with vec4 (column vector) and store in dest column vector Parameters: | *[in]* **m** mat4x3 (left) | *[in]* **v** vec4 (right, column vector) | *[out]* **dest** destination (result, column vector) .. csv-table:: mat4x3 :header: "", "column 1", "column 2", "column 3", "column 4" "row 1", "m00", "m10", "m20", "m30" "row 2", "m01", "m11", "m21", "m31" "row 3", "m02", "m12", "m22", "m32" .. csv-table:: column vec4 (1x4) :header: "", "column 1" "row 1", "v0" "row 2", "v1" "row 3", "v2" "row 4", "v3" .. csv-table:: column vec3 (1x3) :header: "", "column 1" "row 1", "m00 * v0 + m10 * v1 + m20 * v2 + m30 * v3" "row 2", "m01 * v0 + m11 * v1 + m21 * v2 + m31 * v3" "row 3", "m02 * v0 + m12 * v1 + m22 * v2 + m32 * v3" .. c:function:: void glm_mat4x3_transpose(mat4x3 m, mat3x4 dest) transpose matrix and store in dest Parameters: | *[in]* **m** matrix | *[out]* **dest** destination .. c:function:: void glm_mat4x3_scale(mat4x3 m, float s) multiply matrix with scalar Parameters: | *[in, out]* **m** matrix | *[in]* **s** scalar cglm-0.9.6/docs/source/noise.rst000066400000000000000000000023761475344456400165770ustar00rootroot00000000000000.. default-domain:: C perlin ================================================================================ Header: cglm/noise.h Classic Perlin noise implementation. Based on the work of Stefan Gustavson and Ashima Arts on "webgl-noise": https://github.com/stegu/webgl-noise Following Stefan Gustavson's paper "Simplex noise demystified": http://www.itn.liu.se/~stegu/simplexnoise/simplexnoise.pdf Implementation based on glm::perlin function: https://github.com/g-truc/glm/blob/master/glm/gtc/noise.inl Table of contents (click to go): ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Functions: 1. :c:func:`glm_perlin_vec4` #. :c:func:`glm_perlin_vec3` #. :c:func:`glm_perlin_vec2` Functions documentation ~~~~~~~~~~~~~~~~~~~~~~~ .. c:function:: float glm_perlin_vec4(vec4 point) | Classic Perlin noise Parameters: | *[in]* **point** 4D point Returns: | noise value .. c:function:: float glm_perlin_vec3(vec3 point) | Classic Perlin noise Parameters: | *[in]* **point** 3D point Returns: | noise value .. c:function:: float glm_perlin_vec2(vec2 point) | Classic Perlin noise Parameters: | *[in]* **point** 2D point Returns: | noise value cglm-0.9.6/docs/source/opengl.rst000066400000000000000000000034771475344456400167510ustar00rootroot00000000000000How to send vector or matrix to OpenGL like API ================================================== *cglm*'s vector and matrix types are arrays. So you can send them directly to a function which accepts pointer. But you may got warnings for matrix because it is two dimensional array. Passing / Uniforming Matrix to OpenGL: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ **glUniformMatrix4fv** accepts float pointer, you can pass matrix to that parameter and it should work but with warnings. "You can pass" doesn't mean that you must pass like that. **Correct options:** Correct doesn't mean correct way to use OpenGL it is just shows correct way to pass cglm type to it. 1. Pass first column --------------------- The goal is that pass address of matrix, first element of matrix is also address of matrix, because it is array of vectors and vector is array of floats. .. code-block:: c mat4 matrix; /* ... */ glUniformMatrix4fv(location, 1, GL_FALSE, matrix[0]); array of matrices: .. code-block:: c mat4 matrix; /* ... */ glUniformMatrix4fv(location, count, GL_FALSE, matrix[0][0]); 2. Cast matrix to pointer -------------------------- .. code-block:: c mat4 matrix; /* ... */ glUniformMatrix4fv(location, count, GL_FALSE, (float *)matrix); in this way, passing array of matrices is same Passing / Uniforming Vectors to OpenGL: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ You don't need to do extra thing when passing cglm vectors to OpengL or other APIs. Because a function like **glUniform4fv** accepts vector as pointer. cglm's vectors are array of floats. So you can pass it directly to those functions: .. code-block:: c vec4 vec; /* ... */ glUniform4fv(location, 1, vec); this show how to pass **vec4** others are same. cglm-0.9.6/docs/source/opt.rst000066400000000000000000000153741475344456400162660ustar00rootroot00000000000000.. default-domain:: C 🛠️ Options =============================================================================== A few options are provided via macros. ❗️ IMPORTANT ❗️ It's a good idea to set up your config macros in build settings like CMake, Xcode, or Visual Studio. This is especially important if you're using features like Modules in Xcode, where adding macros directly before the **cglm** headers might not work. Alignment Option ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ By default, **cglm** requires types to be aligned with specific byte requirements: - vec3: 8 bytes - vec4: 16 bytes - mat4: 16 bytes (32 on AVX) - versor: 16 bytes Starting with **v0.4.5**, **cglm** offers an option to relax these alignment requirements. To use this option, define the **CGLM_ALL_UNALIGNED** macro before including any headers. This definition can be made within Xcode, Visual Studio, other IDEs, or directly in your build system. If using pre-compiled versions of **cglm**, you'll need to compile them with the **CGLM_ALL_UNALIGNED** macro. **❗️NOTE:❗️** If you're using **cglm** across multiple interdependent projects: - Always or never use the **CGLM_ALL_UNALIGNED** macro in all linked projects to avoid configuration conflicts. A **cglm** header from one project could require alignment, while a header from another might not, leading to **cglm** functions accessing invalid memory locations. - **Key Point:** Maintain the same **cglm** configuration across all your projects. For example, if you activate **CGLM_ALL_UNALIGNED** in one project, ensure it's set in the others too. **❗️NOTE:❗️** While **CGLM_ALL_UNALIGNED** allows for flexibility in alignment, it doesn't override C's fundamental alignment rules. For example, an array like *vec4* decays to a pointer (float*) in functions, which must adhere to the alignment requirements of a float pointer (4 bytes). This adherence is crucial because **cglm** directly dereferences these pointers instead of copying data, and failing to meet alignment requirements can lead to unpredictable errors, such as crashes. You can use `CGLM_ALIGN` and `CGLM_ALIGN_MAT` macros for aligning local variables or struct members. However, when dealing with dynamic memory allocation or custom memory locations, you'll need to ensure alignment requirements are met appropriately for those cases Clipspace Option[s] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ By starting **v0.8.3** cglm provides options to switch between clipspace configurations. Clipspace related files are located at `include/cglm/[struct]/clipspace.h` but these are included in related files like `cam.h`. If you don't want to change your existing clipspace configuration and want to use different clipspace function like `glm_lookat_zo` or `glm_lookat_lh_zo`... then you can include individual headers or just define `CGLM_CLIPSPACE_INCLUDE_ALL` which will include all headers for you. 1. **CGLM_CLIPSPACE_INCLUDE_ALL** 2. **CGLM_FORCE_DEPTH_ZERO_TO_ONE** 3. **CGLM_FORCE_LEFT_HANDED** 1. **CGLM_CLIPSPACE_INCLUDE_ALL**: By defining this macro, **cglm** will include all clipspace functions for you by just using `#include cglm/cglm.h` or `#include cglm/struct.h` or `#include cglm/call.h` Otherwise you need to include header you want manually e.g. `#include cglm/clipspace/view_rh_zo.h` 2. **CGLM_FORCE_DEPTH_ZERO_TO_ONE** This is similar to **GLM**'s **GLM_FORCE_DEPTH_ZERO_TO_ONE** option. This will set clip space between 0 to 1 which makes **cglm** Vulkan, Metal friendly. You can use functions like `glm_lookat_lh_zo()` individually. By setting **CGLM_FORCE_DEPTH_ZERO_TO_ONE** functions in cam.h for instance will use `_zo` versions. 3. **CGLM_FORCE_LEFT_HANDED** Force **cglm** to use the left handed coordinate system by default, currently **cglm** uses right handed coordinate system as default, you can change this behavior with this option. **VERY VERY IMPORTANT:** Be careful if you include **cglm** in multiple projects. SSE and SSE2 Shuffle Option ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ **_mm_shuffle_ps** generates **shufps** instruction even if registers are same. You can force it to generate **pshufd** instruction by defining **CGLM_NO_INT_DOMAIN** macro. As default it is not defined. SSE3 and SSE4 Dot Product Options ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ You have to extra options for dot product: **CGLM_SSE4_DOT** and **CGLM_SSE3_DOT**. - If **SSE4** is enabled then you can define **CGLM_SSE4_DOT** to force cglm to use **_mm_dp_ps** instruction. - If **SSE3** is enabled then you can define **CGLM_SSE3_DOT** to force cglm to use **_mm_hadd_ps** instructions. otherwise cglm will use custom cglm's hadd functions which are optimized too. Struct API Options ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ To configure the Struct API namespace, you can define the following macros before including the cglm/struct.h header: - **CGLM_OMIT_NS_FROM_STRUCT_API**: omits CGLM_STRUCT_API_NS (`glms_`) namespace completely if there is sub namespace e.g `mat4_`, `vec4_` ... DEFAULT is not defined - **CGLM_STRUCT_API_NS**: define name space for struct api, DEFAULT is **glms** - **CGLM_STRUCT_API_NAME_SUFFIX**: define name suffix, DEFAULT is **empty** e.g defining it as #define CGLM_STRUCT_API_NAME_SUFFIX s will add s suffix to mat4_mul -> mat4s_mul Print Options ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1. **CGLM_DEFINE_PRINTS** 2. **CGLM_NO_PRINTS_NOOP** (use CGLM_DEFINE_PRINTS) Inline prints are only enabled in **DEBUG** mode or if **CGLM_DEFINE_PRINTS** is defined. **glmc_** versions will always print too. Because **cglm** tried to enable print functions in debug mode and disable them in release/production mode to eliminate printing costs when we do not need them. **cglm** checks **DEBUG** or **_DEBUG** macros to test debug mode, if these are not working for you then you can use **CGLM_DEFINE_PRINTS** to force enable, or create a PR to introduce new macro to test against debugging mode. If DEBUG mode is not enabled then print functions will be emptied to eliminate print function calls. You can disable this feature too by defining **CGLM_DEFINE_PRINTS** macro top of cglm header or in project/build settings... 3. **CGLM_PRINT_PRECISION** 5 precision. 4. **CGLM_PRINT_MAX_TO_SHORT** 1e5 if a number is greater than this value then %g will be used, since this is shorten print you won't be able to see high precision. 5. **CGLM_PRINT_COLOR** "\033[36m" 6. **CGLM_PRINT_COLOR_RESET** "\033[0m" You can disable colorful print output by defining **CGLM_PRINT_COLOR** and **CGLM_PRINT_COLOR_RESET** as empty macro. Because some terminals may not support colors. cglm-0.9.6/docs/source/plane.rst000066400000000000000000000013361475344456400165540ustar00rootroot00000000000000.. default-domain:: C plane ================================================================================ Header: cglm/plane.h Plane extract functions are in frustum header and documented in :doc:`frustum` page. **Definition of plane:** Plane equation: **Ax + By + Cz + D = 0** Plan is stored in **vec4** as **[A, B, C, D]**. (A, B, C) is normal and D is distance Table of contents (click to go): ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Functions: 1. :c:func:`glm_plane_normalize` Functions documentation ~~~~~~~~~~~~~~~~~~~~~~~ .. c:function:: void glm_plane_normalize(vec4 plane) | normalizes a plane Parameters: | *[in, out]* **plane** pnale to normalize cglm-0.9.6/docs/source/project.rst000066400000000000000000000067741475344456400171360ustar00rootroot00000000000000.. default-domain:: C Project / UnProject ================================================================================ Header: cglm/project.h Viewport is required as *vec4* **[X, Y, Width, Height]** but this doesn't mean that you should store it as **vec4**. You can convert your data representation to vec4 before passing it to related functions. Table of contents (click to go): ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Functions: 1. :c:func:`glm_unprojecti` #. :c:func:`glm_unproject` #. :c:func:`glm_project` Functions documentation ~~~~~~~~~~~~~~~~~~~~~~~ .. c:function:: void glm_unprojecti(vec3 pos, mat4 invMat, vec4 vp, vec3 dest) | maps the specified viewport coordinates into specified space [1] the matrix should contain projection matrix. if you don't have ( and don't want to have ) an inverse matrix then use :c:func:`glm_unproject` version. You may use existing inverse of matrix in somewhere else, this is why **glm_unprojecti** exists to save inversion cost [1] space: - if m = invProj: View Space - if m = invViewProj: World Space - if m = invMVP: Object Space You probably want to map the coordinates into object space so use invMVP as m Computing viewProj: .. code-block:: c glm_mat4_mul(proj, view, viewProj); glm_mat4_mul(viewProj, model, MVP); glm_mat4_inv(viewProj, invMVP); Parameters: | *[in]* **pos** point/position in viewport coordinates | *[in]* **invMat** matrix (see brief) | *[in]* **vp** viewport as [x, y, width, height] | *[out]* **dest** unprojected coordinates .. c:function:: void glm_unproject(vec3 pos, mat4 m, vec4 vp, vec3 dest) | maps the specified viewport coordinates into specified space [1] the matrix should contain projection matrix. this is same as :c:func:`glm_unprojecti` except this function get inverse matrix for you. [1] space: - if m = proj: View Space - if m = viewProj: World Space - if m = MVP: Object Space You probably want to map the coordinates into object space so use MVP as m Computing viewProj and MVP: .. code-block:: c glm_mat4_mul(proj, view, viewProj); glm_mat4_mul(viewProj, model, MVP); Parameters: | *[in]* **pos** point/position in viewport coordinates | *[in]* **m** matrix (see brief) | *[in]* **vp** viewport as [x, y, width, height] | *[out]* **dest** unprojected coordinates .. c:function:: void glm_project(vec3 pos, mat4 m, vec4 vp, vec3 dest) | map object coordinates to window coordinates Computing MVP: .. code-block:: c glm_mat4_mul(proj, view, viewProj); glm_mat4_mul(viewProj, model, MVP); Parameters: | *[in]* **pos** object coordinates | *[in]* **m** MVP matrix | *[in]* **vp** viewport as [x, y, width, height] | *[out]* **dest** projected coordinates .. c:function:: float glm_project_z(vec3 pos, mat4 m) | map object's z coordinate to window coordinates this is same as :c:func:`glm_project` except this function projects only Z coordinate which reduces a few calculations and parameters. Computing MVP: .. code-block:: c glm_mat4_mul(proj, view, viewProj); glm_mat4_mul(viewProj, model, MVP); Parameters: | *[in]* **pos** object coordinates | *[in]* **m** MVP matrix Returns: projected z coordinatecglm-0.9.6/docs/source/quat.rst000066400000000000000000000314421475344456400164300ustar00rootroot00000000000000.. default-domain:: C quaternions =========== Header: cglm/quat.h **Important:** *cglm* stores quaternion as **[x, y, z, w]** in memory since **v0.4.0** it was **[w, x, y, z]** before v0.4.0 ( **v0.3.5 and earlier** ). w is real part. What you can do with quaternions with existing functions is (Some of them): - You can rotate transform matrix using quaternion - You can rotate vector using quaternion - You can create view matrix using quaternion - You can create a lookrotation (from source point to dest) Table of contents (click to go): ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Macros: 1. GLM_QUAT_IDENTITY_INIT #. GLM_QUAT_IDENTITY Functions: 1. :c:func:`glm_quat_identity` #. :c:func:`glm_quat_identity_array` #. :c:func:`glm_quat_init` #. :c:func:`glm_quat` #. :c:func:`glm_quatv` #. :c:func:`glm_quat_copy` #. :c:func:`glm_quat_from_vecs` #. :c:func:`glm_quat_norm` #. :c:func:`glm_quat_normalize` #. :c:func:`glm_quat_normalize_to` #. :c:func:`glm_quat_dot` #. :c:func:`glm_quat_conjugate` #. :c:func:`glm_quat_inv` #. :c:func:`glm_quat_add` #. :c:func:`glm_quat_sub` #. :c:func:`glm_quat_real` #. :c:func:`glm_quat_imag` #. :c:func:`glm_quat_imagn` #. :c:func:`glm_quat_imaglen` #. :c:func:`glm_quat_angle` #. :c:func:`glm_quat_axis` #. :c:func:`glm_quat_mul` #. :c:func:`glm_quat_mat4` #. :c:func:`glm_quat_mat4t` #. :c:func:`glm_quat_mat3` #. :c:func:`glm_quat_mat3t` #. :c:func:`glm_quat_lerp` #. :c:func:`glm_quat_nlerp` #. :c:func:`glm_quat_slerp` #. :c:func:`glm_quat_slerp_longest` #. :c:func:`glm_quat_look` #. :c:func:`glm_quat_for` #. :c:func:`glm_quat_forp` #. :c:func:`glm_quat_rotatev` #. :c:func:`glm_quat_rotate` #. :c:func:`glm_quat_rotate_at` #. :c:func:`glm_quat_rotate_atm` #. :c:func:`glm_quat_make` Functions documentation ~~~~~~~~~~~~~~~~~~~~~~~ .. c:function:: void glm_quat_identity(versor q) | makes given quat to identity Parameters: | *[in, out]* **q** quaternion .. c:function:: void glm_quat_identity_array(versor * __restrict q, size_t count) | make given quaternion array's each element identity quaternion Parameters: | *[in, out]* **q** quat array (must be aligned (16) if alignment is not disabled) | *[in]* **count** count of quaternions .. c:function:: void glm_quat_init(versor q, float x, float y, float z, float w) | inits quaternion with given values Parameters: | *[out]* **q** quaternion | *[in]* **x** imag.x | *[in]* **y** imag.y | *[in]* **z** imag.z | *[in]* **w** w (real part) .. c:function:: void glm_quat(versor q, float angle, float x, float y, float z) | creates NEW quaternion with individual axis components | given axis will be normalized Parameters: | *[out]* **q** quaternion | *[in]* **angle** angle (radians) | *[in]* **x** axis.x | *[in]* **y** axis.y | *[in]* **z** axis.z .. c:function:: void glm_quatv(versor q, float angle, vec3 axis) | creates NEW quaternion with axis vector | given axis will be normalized Parameters: | *[out]* **q** quaternion | *[in]* **angle** angle (radians) | *[in]* **axis** axis (will be normalized) .. c:function:: void glm_quat_copy(versor q, versor dest) | copy quaternion to another one Parameters: | *[in]* **q** source quaternion | *[out]* **dest** destination quaternion .. c:function:: void glm_quat_from_vecs(vec3 a, vec3 b, versor dest) | compute unit quaternion needed to rotate a into b References: * `Finding quaternion representing the rotation from one vector to another `_ * `Quaternion from two vectors `_ * `Angle between vectors `_ Parameters: | *[in]* **a** unit vector | *[in]* **b** unit vector | *[in]* **dest** unit quaternion .. c:function:: float glm_quat_norm(versor q) | returns norm (magnitude) of quaternion Parameters: | *[in]* **a** quaternion Returns: norm (magnitude) .. c:function:: void glm_quat_normalize_to(versor q, versor dest) | normalize quaternion and store result in dest, original one will not be normalized Parameters: | *[in]* **q** quaternion to normalize into | *[out]* **dest** destination quaternion .. c:function:: void glm_quat_normalize(versor q) | normalize quaternion Parameters: | *[in, out]* **q** quaternion .. c:function:: float glm_quat_dot(versor p, versor q) dot product of two quaternion Parameters: | *[in]* **p** quaternion 1 | *[in]* **q** quaternion 2 Returns: dot product .. c:function:: void glm_quat_conjugate(versor q, versor dest) conjugate of quaternion Parameters: | *[in]* **q** quaternion | *[in]* **dest** conjugate .. c:function:: void glm_quat_inv(versor q, versor dest) inverse of non-zero quaternion Parameters: | *[in]* **q** quaternion | *[in]* **dest** inverse quaternion .. c:function:: void glm_quat_add(versor p, versor q, versor dest) add (componentwise) two quaternions and store result in dest Parameters: | *[in]* **p** quaternion 1 | *[in]* **q** quaternion 2 | *[in]* **dest** result quaternion .. c:function:: void glm_quat_sub(versor p, versor q, versor dest) subtract (componentwise) two quaternions and store result in dest Parameters: | *[in]* **p** quaternion 1 | *[in]* **q** quaternion 2 | *[in]* **dest** result quaternion .. c:function:: float glm_quat_real(versor q) returns real part of quaternion Parameters: | *[in]* **q** quaternion Returns: real part (quat.w) .. c:function:: void glm_quat_imag(versor q, vec3 dest) returns imaginary part of quaternion Parameters: | *[in]* **q** quaternion | *[out]* **dest** imag .. c:function:: void glm_quat_imagn(versor q, vec3 dest) returns normalized imaginary part of quaternion Parameters: | *[in]* **q** quaternion | *[out]* **dest** imag .. c:function:: float glm_quat_imaglen(versor q) returns length of imaginary part of quaternion Parameters: | *[in]* **q** quaternion Returns: norm of imaginary part .. c:function:: float glm_quat_angle(versor q) returns angle of quaternion Parameters: | *[in]* **q** quaternion Returns: angles of quat (radians) .. c:function:: void glm_quat_axis(versor q, versor dest) axis of quaternion Parameters: | *[in]* **p** quaternion | *[out]* **dest** axis of quaternion .. c:function:: void glm_quat_mul(versor p, versor q, versor dest) | multiplies two quaternion and stores result in dest | this is also called Hamilton Product | According to WikiPedia: | The product of two rotation quaternions [clarification needed] will be equivalent to the rotation q followed by the rotation p Parameters: | *[in]* **p** quaternion 1 (first rotation) | *[in]* **q** quaternion 2 (second rotation) | *[out]* **dest** result quaternion .. c:function:: void glm_quat_mat4(versor q, mat4 dest) | convert quaternion to mat4 Parameters: | *[in]* **q** quaternion | *[out]* **dest** result matrix .. c:function:: void glm_quat_mat4t(versor q, mat4 dest) | convert quaternion to mat4 (transposed). This is transposed version of glm_quat_mat4 Parameters: | *[in]* **q** quaternion | *[out]* **dest** result matrix .. c:function:: void glm_quat_mat3(versor q, mat3 dest) | convert quaternion to mat3 Parameters: | *[in]* **q** quaternion | *[out]* **dest** result matrix .. c:function:: void glm_quat_mat3t(versor q, mat3 dest) | convert quaternion to mat3 (transposed). This is transposed version of glm_quat_mat3 Parameters: | *[in]* **q** quaternion | *[out]* **dest** result matrix .. c:function:: void glm_quat_lerp(versor from, versor to, float t, versor dest) | interpolates between two quaternions | using spherical linear interpolation (LERP) Parameters: | *[in]* **from** from | *[in]* **to** to | *[in]* **t** interpolant (amount) clamped between 0 and 1 | *[out]* **dest** result quaternion .. c:function:: void glm_quat_nlerp(versor q, versor r, float t, versor dest) | interpolates between two quaternions | taking the shortest rotation path using | normalized linear interpolation (NLERP) | This is a cheaper alternative to slerp; most games use nlerp | for animations as it visually makes little difference. References: * `Understanding Slerp, Then Not Using it `_ * `Lerp, Slerp and Nlerp `_ Parameters: | *[in]* **from** from | *[in]* **to** to | *[in]* **t** interpolant (amount) clamped between 0 and 1 | *[out]* **dest** result quaternion .. c:function:: void glm_quat_slerp(versor q, versor r, float t, versor dest) | interpolates between two quaternions | using spherical linear interpolation (SLERP) Parameters: | *[in]* **from** from | *[in]* **to** to | *[in]* **t** interpolant (amount) clamped between 0 and 1 | *[out]* **dest** result quaternion .. c:function:: void glm_quat_slerp_longest(versor q, versor r, float t, versor dest) | interpolates between two quaternions | using spherical linear interpolation (SLERP) and always takes the longest path Parameters: | *[in]* **from** from | *[in]* **to** to | *[in]* **t** interpolant (amount) clamped between 0 and 1 | *[out]* **dest** result quaternion .. c:function:: void glm_quat_look(vec3 eye, versor ori, mat4 dest) | creates view matrix using quaternion as camera orientation Parameters: | *[in]* **eye** eye | *[in]* **ori** orientation in world space as quaternion | *[out]* **dest** result matrix .. c:function:: void glm_quat_for(vec3 dir, vec3 up, versor dest) | creates look rotation quaternion Parameters: | *[in]* **dir** direction to look | *[in]* **up** up vector | *[out]* **dest** result matrix .. c:function:: void glm_quat_forp(vec3 from, vec3 to, vec3 up, versor dest) | creates look rotation quaternion using source and destination positions p suffix stands for position | this is similar to glm_quat_for except this computes direction for glm_quat_for for you. Parameters: | *[in]* **from** source point | *[in]* **to** destination point | *[in]* **up** up vector | *[out]* **dest** result matrix .. c:function:: void glm_quat_rotatev(versor q, vec3 v, vec3 dest) | crotate vector using using quaternion Parameters: | *[in]* **q** quaternion | *[in]* **v** vector to rotate | *[out]* **dest** rotated vector .. c:function:: void glm_quat_rotate(mat4 m, versor q, mat4 dest) | rotate existing transform matrix using quaternion instead of passing identity matrix, consider to use quat_mat4 functions Parameters: | *[in]* **m** existing transform matrix to rotate | *[in]* **q** quaternion | *[out]* **dest** rotated matrix/transform .. c:function:: void glm_quat_rotate_at(mat4 m, versor q, vec3 pivot) | rotate existing transform matrix using quaternion at pivot point Parameters: | *[in, out]* **m** existing transform matrix to rotate | *[in]* **q** quaternion | *[in]* **pivot** pivot .. c:function:: void glm_quat_rotate_atm(mat4 m, versor q, vec3 pivot) | rotate NEW transform matrix using quaternion at pivot point | this creates rotation matrix, it assumes you don't have a matrix | this should work faster than glm_quat_rotate_at because it reduces one glm_translate. Parameters: | *[in, out]* **m** existing transform matrix to rotate | *[in]* **q** quaternion | *[in]* **pivot** pivot .. c:function:: void glm_quat_make(const float * __restrict src, versor dest) Create quaternion from pointer .. note:: **@src** must contain at least 4 elements. cglm store quaternions as [x, y, z, w]. Parameters: | *[in]* **src** pointer to an array of floats | *[out]* **dest** destination quaternion cglm-0.9.6/docs/source/ray.rst000066400000000000000000000044541475344456400162540ustar00rootroot00000000000000.. default-domain:: C ray ==== Header: cglm/ray.h This is for collision-checks used by ray-tracers and the like. Table of contents (click to go): ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Functions: 1. :c:func:`glm_ray_triangle` #. :c:func:`glm_ray_sphere` #. :c:func:`glm_ray_at` Functions documentation ~~~~~~~~~~~~~~~~~~~~~~~ .. c:function:: bool glm_ray_triangle(vec3 origin, vec3 direction, vec3 v0, vec3 v1, vec3 v2, float *d) Möller–Trumbore ray-triangle intersection algorithm Parameters: | *[in]* **origin** origin of ray | *[in]* **direction** direction of ray | *[in]* **v0** first vertex of triangle | *[in]* **v1** second vertex of triangle | *[in]* **v2** third vertex of triangle | *[in, out]* **d** float pointer to save distance to intersection | *[out]* **intersection** whether there is intersection .. c:function:: bool glm_ray_sphere(vec3 origin, vec3 dir, vec4 s, float * __restrict t1, float * __restrict t2) ray sphere intersection returns false if there is no intersection if true: - t1 > 0, t2 > 0: ray intersects the sphere at t1 and t2 both ahead of the origin - t1 < 0, t2 > 0: ray starts inside the sphere, exits at t2 - t1 < 0, t2 < 0: no intersection ahead of the ray ( returns false ) - the caller can check if the intersection points (t1 and t2) fall within a specific range (for example, tmin < t1, t2 < tmax) to determine if the intersections are within a desired segment of the ray Parameters: | *[in]* **origin** ray origin | *[in]* **dir** normalized ray direction | *[in]* **s** sphere [center.x, center.y, center.z, radii] | *[out]* **t1** near point1 (closer to origin) | *[out]* **t2** far point2 (farther from origin) Return: | whether there is intersection .. c:function:: bool glm_ray_at(vec3 orig, vec3 dir, float t, vec3 point) point using t by 𝐏(𝑡)=𝐀+𝑡𝐛 Parameters: | *[in]* **origin** ray origin | *[in]* **dir** ray direction | *[out]* **t** parameter | *[out]* **point** point at t Return: | point at t cglm-0.9.6/docs/source/sphere.rst000066400000000000000000000035721475344456400167470ustar00rootroot00000000000000.. default-domain:: C Sphere ================================================================================ Header: cglm/sphere.h **Definition of sphere:** Sphere Representation in cglm is *vec4*: **[center.x, center.y, center.z, radii]** You can call any vec3 function by passing sphere. Because first three elements defines center of sphere. Table of contents (click to go): ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Functions: 1. :c:func:`glm_sphere_radii` #. :c:func:`glm_sphere_transform` #. :c:func:`glm_sphere_merge` #. :c:func:`glm_sphere_sphere` #. :c:func:`glm_sphere_point` Functions documentation ~~~~~~~~~~~~~~~~~~~~~~~ .. c:function:: float glm_sphere_radii(vec4 s) | helper for getting sphere radius Parameters: | *[in]* **s** sphere Returns: returns radii .. c:function:: void glm_sphere_transform(vec4 s, mat4 m, vec4 dest) | apply transform to sphere, it is just wrapper for glm_mat4_mulv3 Parameters: | *[in]* **s** sphere | *[in]* **m** transform matrix | *[out]* **dest** transformed sphere .. c:function:: void glm_sphere_merge(vec4 s1, vec4 s2, vec4 dest) | merges two spheres and creates a new one two sphere must be in same space, for instance if one in world space then the other must be in world space too, not in local space. Parameters: | *[in]* **s1** sphere 1 | *[in]* **s2** sphere 2 | *[out]* **dest** merged/extended sphere .. c:function:: bool glm_sphere_sphere(vec4 s1, vec4 s2) | check if two sphere intersects Parameters: | *[in]* **s1** sphere | *[in]* **s2** other sphere .. c:function:: bool glm_sphere_point(vec4 s, vec3 point) | check if sphere intersects with point Parameters: | *[in]* **s** sphere | *[in]* **point** point cglm-0.9.6/docs/source/sphinx-static/000077500000000000000000000000001475344456400175165ustar00rootroot00000000000000cglm-0.9.6/docs/source/sphinx-static/theme_overrides.css000066400000000000000000000004541475344456400234170ustar00rootroot00000000000000@media screen { /* content column * * RTD theme's default is 800px as max width for the content, but we have * tables with tons of columns, which need the full width of the view-port. * * Comment from yocto project theme_overrides.css */ .wy-nav-content{ max-width: none; } } cglm-0.9.6/docs/source/troubleshooting.rst000066400000000000000000000101551475344456400207030ustar00rootroot00000000000000.. default-domain:: C Troubleshooting ================================================================================ It is possible that you may sometimes get crashes or wrong results. Follow these topics Memory Allocation: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Recall that **cglm** does not alloc any memory on the heap. cglm functions work like memcpy; they copy data from src, make calculations, then copy the result to dest. You are responsible for allocation of **src** and **dest** parameters. Alignment: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ **vec4** and **mat4** types require 16 byte alignment. These types are marked with the align attribute to let the compiler know about this requirement. Since MSVC (Windows) throws this error: **"formal parameter with requested alignment of 16 won't be aligned"** The alignment attribute has been commented out for MSVC .. code-block:: c #if defined(_MSC_VER) # define CGLM_ALIGN(X) /* __declspec(align(X)) */ #else # define CGLM_ALIGN(X) __attribute((aligned(X))) #endif. So MSVC may not know about alignment requirements when creating variables. The interesting thing is that, if I remember correctly, Visual Studio 2017 doesn't throw the above error. So we may uncomment that line for Visual Studio 2017, you may do it yourself. **This MSVC issue is still in TODOs.** **UPDATE:** Starting with v0.4.5, cglm provides an option to disable the alignment requirement. Also, alignment is disabled for older msvc versions by default. Now alignment is only required in Visual Studio 2017 version 15.6+ if the CGLM_ALL_UNALIGNED macro is not defined. Crashes, Invalid Memory Access: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Most likely, you are trying to write to an invalid memory location. You may have used a wrong function for what you want to do. For example, you may have called a **glm_vec4_** function for a **vec3** data type. It will try to write 32 bytes, but since **vec3** is 24 bytes, it should throw a memory access error or exit the app without saying anything. **UPDATE - IMPORTANT:** | On MSVC or some other compilers, if alignment is enabled (default) then double check alignment requirements if you got a crash. | If you send GLM_VEC4_ONE or similar macros directly to a function, it may crash. | Because the compiler may not apply alignment as defined on **typedef** to that macro while passing it (on stack) to a function. Wrong Results: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Again, you may have used a wrong function. For instance if you use **glm_normalize()** or **glm_vec3_normalize()** for a **vec4**, it will assume that the passed param is a **vec3**, and will normalize it for **vec3**. Since you need a **vec4** to be normalized in your case, you will get wrong results. Accessing a vec4 type with vec3 functions is valid, you will not get any error, exception or crash. You only get wrong results if you don't know what you are doing! So be 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.** BAD_ACCESS : Thread 1: EXC_BAD_ACCESS (code=EXC_I386_GPFLT) or Similar Errors/Crashes ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ This is a similar issue with alignment. For instance if you compiled **cglm** with AVX (**-mavx**, intentionally or not) and if you use **cglm** in an environment that doesn't support AVX (or if AVX is disabled intentionally) e.g. environment that max support SSE2/3/4, then you probably get **BAD ACCESS** or similar... Because if you compile **cglm** with AVX it aligns **mat4** with 32 byte boundary, and your project aligns that as a 16 byte boundary... Check alignment, supported vector extension, or simd in **cglm** and linked projects... Other Issues? ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ **Please let us know by creating an issue on Github.** cglm-0.9.6/docs/source/util.rst000066400000000000000000000100071475344456400164250ustar00rootroot00000000000000.. default-domain:: C utils / helpers ================================================================================ Header: cglm/util.h Table of contents (click to go): ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Functions: 1. :c:func:`glm_sign` #. :c:func:`glm_signf` #. :c:func:`glm_rad` #. :c:func:`glm_deg` #. :c:func:`glm_make_rad` #. :c:func:`glm_make_deg` #. :c:func:`glm_pow2` #. :c:func:`glm_min` #. :c:func:`glm_max` #. :c:func:`glm_clamp` #. :c:func:`glm_lerp` #. :c:func:`glm_swapf` Functions documentation ~~~~~~~~~~~~~~~~~~~~~~~ .. c:function:: int glm_sign(int val) | returns sign of 32 bit integer as +1, -1, 0 | **Important**: It returns 0 for zero input Parameters: | *[in]* **val** an integer Returns: sign of given number .. c:function:: float glm_signf(float val) | returns sign of 32 bit integer as +1.0, -1.0, 0.0 | **Important**: It returns 0.0f for zero input Parameters: | *[in]* **val** a float Returns: sign of given number .. c:function:: float glm_rad(float deg) | convert degree to radians Parameters: | *[in]* **deg** angle in degrees .. c:function:: float glm_deg(float rad) | convert radians to degree Parameters: | *[in]* **rad** angle in radians .. c:function:: void glm_make_rad(float *degm) | convert existing degree to radians. this will override degrees value Parameters: | *[in, out]* **deg** pointer to angle in degrees .. c:function:: void glm_make_deg(float *rad) | convert existing radians to degree. this will override radians value Parameters: | *[in, out]* **rad** pointer to angle in radians .. c:function:: float glm_pow2(float x) | multiplies given parameter with itself = x * x or powf(x, 2) Parameters: | *[in]* **x** value Returns: square of a given number .. c:function:: float glm_min(float a, float b) | returns minimum of given two values Parameters: | *[in]* **a** number 1 | *[in]* **b** number 2 Returns: minimum value .. c:function:: float glm_max(float a, float b) | returns maximum of given two values Parameters: | *[in]* **a** number 1 | *[in]* **b** number 2 Returns: maximum value .. c:function:: void glm_clamp(float val, float minVal, float maxVal) constrain a value to lie between two further values Parameters: | *[in]* **val** input value | *[in]* **minVal** minimum value | *[in]* **maxVal** maximum value Returns: clamped value .. c:function:: float glm_lerp(float from, float to, float t) linear interpolation between two number | formula: from + s * (to - from) Parameters: | *[in]* **from** from value | *[in]* **to** to value | *[in]* **t** interpolant (amount) clamped between 0 and 1 Returns: interpolated value .. c:function:: bool glm_eq(float a, float b) check if two float equal with using EPSILON Parameters: | *[in]* **a** a | *[in]* **b** b Returns: true if a and b are equal .. c:function:: float glm_percent(float from, float to, float current) percentage of current value between start and end value Parameters: | *[in]* **from** from value | *[in]* **to** to value | *[in]* **current** value between from and to values Returns: percentage of current value .. c:function:: float glm_percentc(float from, float to, float current) clamped percentage of current value between start and end value Parameters: | *[in]* **from** from value | *[in]* **to** to value | *[in]* **current** value between from and to values Returns: clamped normalized percent (0-100 in 0-1) .. c:function:: void glm_swapf(float *a, float *b) swap two float values Parameters: | *[in]* **a** float 1 | *[in]* **b** float 2 cglm-0.9.6/docs/source/vec2-ext.rst000066400000000000000000000074521475344456400171170ustar00rootroot00000000000000.. default-domain:: C vec2 extra ========== Header: cglm/vec2-ext.h There are some functions are in called in extra header. These are called extra because they are not used like other functions in vec2.h in the future some of these functions ma be moved to vec2 header. Table of contents (click to go): ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Functions: 1. :c:func:`glm_vec2_fill` #. :c:func:`glm_vec2_eq` #. :c:func:`glm_vec2_eq_eps` #. :c:func:`glm_vec2_eq_all` #. :c:func:`glm_vec2_eqv` #. :c:func:`glm_vec2_eqv_eps` #. :c:func:`glm_vec2_max` #. :c:func:`glm_vec2_min` #. :c:func:`glm_vec2_isnan` #. :c:func:`glm_vec2_isinf` #. :c:func:`glm_vec2_isvalid` #. :c:func:`glm_vec2_sign` #. :c:func:`glm_vec2_abs` #. :c:func:`glm_vec2_fract` #. :c:func:`glm_vec2_floor` #. :c:func:`glm_vec2_sqrt` Functions documentation ~~~~~~~~~~~~~~~~~~~~~~~ .. c:function:: void glm_vec2_fill(vec2 v, float val) fill a vector with specified value Parameters: | *[in,out]* **dest** destination | *[in]* **val** value .. c:function:: bool glm_vec2_eq(vec2 v, float val) check if vector is equal to value (without epsilon) Parameters: | *[in]* **v** vector | *[in]* **val** value .. c:function:: bool glm_vec2_eq_eps(vec2 v, float val) check if vector is equal to value (with epsilon) Parameters: | *[in]* **v** vector | *[in]* **val** value .. c:function:: bool glm_vec2_eq_all(vec2 v) check if vectors members are equal (without epsilon) Parameters: | *[in]* **v** vector .. c:function:: bool glm_vec2_eqv(vec2 v1, vec2 v2) check if vector is equal to another (without epsilon) vector Parameters: | *[in]* **vec** vector 1 | *[in]* **vec** vector 2 .. c:function:: bool glm_vec2_eqv_eps(vec2 v1, vec2 v2) check if vector is equal to another (with epsilon) Parameters: | *[in]* **v1** vector1 | *[in]* **v2** vector2 .. c:function:: float glm_vec2_max(vec2 v) max value of vector Parameters: | *[in]* **v** vector .. c:function:: float glm_vec2_min(vec2 v) min value of vector Parameters: | *[in]* **v** vector .. c:function:: bool glm_vec2_isnan(vec2 v) | check if one of items is NaN (not a number) | you should only use this in DEBUG mode or very critical asserts Parameters: | *[in]* **v** vector .. c:function:: bool glm_vec2_isinf(vec2 v) | check if one of items is INFINITY | you should only use this in DEBUG mode or very critical asserts Parameters: | *[in]* **v** vector .. c:function:: bool glm_vec2_isvalid(vec2 v) | check if all items are valid number | you should only use this in DEBUG mode or very critical asserts Parameters: | *[in]* **v** vector .. c:function:: void glm_vec2_sign(vec2 v, vec2 dest) get sign of 32 bit float as +1, -1, 0 Parameters: | *[in]* **v** vector | *[out]* **dest** sign vector (only keeps signs as -1, 0, -1) .. c:function:: void glm_vec2_abs(vec2 v, vec2 dest) absolute value of each vector item Parameters: | *[in]* **v** vector | *[out]* **dest** destination vector .. c:function:: void glm_vec2_fract(vec2 v, vec2 dest) get fractional part of each vector item Parameters: | *[in]* **v** vector | *[out]* **dest** destination vector .. c:function:: void glm_vec2_floor(vec2 v, vec2 dest) floor value of each vector item Parameters: | *[in]* **v** vector | *[out]* **dest** destination vector .. c:function:: void glm_vec2_sqrt(vec2 v, vec2 dest) square root of each vector item Parameters: | *[in]* **v** vector | *[out]* **dest** destination vector (sqrt(v)) cglm-0.9.6/docs/source/vec2.rst000066400000000000000000000262331475344456400163170ustar00rootroot00000000000000.. default-domain:: C vec2 ==== Header: cglm/vec2.h Table of contents (click to go): ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Macros: 1. GLM_VEC2_ONE_INIT #. GLM_VEC2_ZERO_INIT #. GLM_VEC2_ONE #. GLM_VEC2_ZERO Functions: 1. :c:func:`glm_vec2` #. :c:func:`glm_vec2_copy` #. :c:func:`glm_vec2_zero` #. :c:func:`glm_vec2_one` #. :c:func:`glm_vec2_dot` #. :c:func:`glm_vec2_cross` #. :c:func:`glm_vec2_norm2` #. :c:func:`glm_vec2_norm` #. :c:func:`glm_vec2_add` #. :c:func:`glm_vec2_adds` #. :c:func:`glm_vec2_sub` #. :c:func:`glm_vec2_subs` #. :c:func:`glm_vec2_mul` #. :c:func:`glm_vec2_scale` #. :c:func:`glm_vec2_scale_as` #. :c:func:`glm_vec2_div` #. :c:func:`glm_vec2_divs` #. :c:func:`glm_vec2_addadd` #. :c:func:`glm_vec2_subadd` #. :c:func:`glm_vec2_muladd` #. :c:func:`glm_vec2_muladds` #. :c:func:`glm_vec2_maxadd` #. :c:func:`glm_vec2_minadd` #. :c:func:`glm_vec2_negate` #. :c:func:`glm_vec2_negate_to` #. :c:func:`glm_vec2_normalize` #. :c:func:`glm_vec2_normalize_to` #. :c:func:`glm_vec2_rotate` #. :c:func:`glm_vec2_center` #. :c:func:`glm_vec2_distance2` #. :c:func:`glm_vec2_distance` #. :c:func:`glm_vec2_maxv` #. :c:func:`glm_vec2_minv` #. :c:func:`glm_vec2_clamp` #. :c:func:`glm_vec2_lerp` #. :c:func:`glm_vec2_make` #. :c:func:`glm_vec2_reflect` #. :c:func:`glm_vec2_refract` Functions documentation ~~~~~~~~~~~~~~~~~~~~~~~ .. c:function:: void glm_vec2(float * v, vec2 dest) init vec2 using vec3 or vec4 Parameters: | *[in]* **v** vector | *[out]* **dest** destination .. c:function:: void glm_vec2_copy(vec2 a, vec2 dest) copy all members of [a] to [dest] Parameters: | *[in]* **a** source | *[out]* **dest** destination .. c:function:: void glm_vec2_zero(vec2 v) makes all members 0.0f (zero) Parameters: | *[in, out]* **v** vector .. c:function:: void glm_vec2_one(vec2 v) makes all members 1.0f (one) Parameters: | *[in, out]* **v** vector .. c:function:: float glm_vec2_dot(vec2 a, vec2 b) dot product of vec2 Parameters: | *[in]* **a** vector1 | *[in]* **b** vector2 Returns: dot product .. c:function:: void glm_vec2_cross(vec2 a, vec2 b, vec2 d) cross product of two vector (RH) | ref: http://allenchou.net/2013/07/cross-product-of-2d-vectors/ Parameters: | *[in]* **a** vector 1 | *[in]* **b** vector 2 | *[out]* **dest** destination Returns: Z component of cross product .. c:function:: float glm_vec2_norm2(vec2 v) norm * norm (magnitude) of vector we can use this func instead of calling norm * norm, because it would call sqrtf function twice but with this func we can avoid func call, maybe this is not good name for this func Parameters: | *[in]* **v** vector Returns: square of norm / magnitude .. c:function:: float glm_vec2_norm(vec2 vec) | euclidean norm (magnitude), also called L2 norm | this will give magnitude of vector in euclidean space Parameters: | *[in]* **vec** vector .. c:function:: void glm_vec2_add(vec2 a, vec2 b, vec2 dest) add a vector to b vector store result in dest Parameters: | *[in]* **a** vector1 | *[in]* **b** vector2 | *[out]* **dest** destination vector .. c:function:: void glm_vec2_adds(vec2 a, float s, vec2 dest) add scalar to v vector store result in dest (d = v + vec(s)) Parameters: | *[in]* **v** vector | *[in]* **s** scalar | *[out]* **dest** destination vector .. c:function:: void glm_vec2_sub(vec2 v1, vec2 v2, vec2 dest) subtract b vector from a vector store result in dest (d = v1 - v2) Parameters: | *[in]* **a** vector1 | *[in]* **b** vector2 | *[out]* **dest** destination vector .. c:function:: void glm_vec2_subs(vec2 v, float s, vec2 dest) subtract scalar from v vector store result in dest (d = v - vec(s)) Parameters: | *[in]* **v** vector | *[in]* **s** scalar | *[out]* **dest** destination vector .. c:function:: void glm_vec2_mul(vec2 a, vec2 b, vec2 d) multiply two vector (component-wise multiplication) Parameters: | *[in]* **a** vector | *[in]* **b** scalar | *[out]* **d** result = (a[0] * b[0], a[1] * b[1], a[2] * b[2]) .. c:function:: void glm_vec2_scale(vec2 v, float s, vec2 dest) multiply/scale vec2 vector with scalar: result = v * s Parameters: | *[in]* **v** vector | *[in]* **s** scalar | *[out]* **dest** destination vector .. c:function:: void glm_vec2_scale_as(vec2 v, float s, vec2 dest) make vec2 vector scale as specified: result = unit(v) * s Parameters: | *[in]* **v** vector | *[in]* **s** scalar | *[out]* **dest** destination vector .. c:function:: void glm_vec2_div(vec2 a, vec2 b, vec2 dest) div vector with another component-wise division: d = a / b Parameters: | *[in]* **a** vector 1 | *[in]* **b** vector 2 | *[out]* **dest** result = (a[0] / b[0], a[1] / b[1], a[2] / b[2]) .. c:function:: void glm_vec2_divs(vec2 v, float s, vec2 dest) div vector with scalar: d = v / s Parameters: | *[in]* **v** vector | *[in]* **s** scalar | *[out]* **dest** result = (a[0] / s, a[1] / s, a[2] / s]) .. c:function:: void glm_vec2_addadd(vec2 a, vec2 b, vec2 dest) | add two vectors and add result to sum | it applies += operator so dest must be initialized Parameters: | *[in]* **a** vector 1 | *[in]* **b** vector 2 | *[out]* **dest** dest += (a + b) .. c:function:: void glm_vec2_subadd(vec2 a, vec2 b, vec2 dest) | sub two vectors and add result to sum | it applies += operator so dest must be initialized Parameters: | *[in]* **a** vector 1 | *[in]* **b** vector 2 | *[out]* **dest** dest += (a - b) .. c:function:: void glm_vec2_muladd(vec2 a, vec2 b, vec2 dest) | mul two vectors and add result to sum | it applies += operator so dest must be initialized Parameters: | *[in]* **a** vector 1 | *[in]* **b** vector 2 | *[out]* **dest** dest += (a * b) .. c:function:: void glm_vec2_muladds(vec2 a, float s, vec2 dest) | mul vector with scalar and add result to sum | it applies += operator so dest must be initialized Parameters: | *[in]* **a** vector | *[in]* **s** scalar | *[out]* **dest** dest += (a * b) .. c:function:: void glm_vec2_maxadd(vec2 a, vec2 b, vec2 dest) | add max of two vector to result/dest | it applies += operator so dest must be initialized Parameters: | *[in]* **a** vector 1 | *[in]* **b** vector 2 | *[out]* **dest** dest += (a * b) .. c:function:: void glm_vec2_minadd(vec2 a, vec2 b, vec2 dest) | add min of two vector to result/dest | it applies += operator so dest must be initialized Parameters: | *[in]* **a** vector 1 | *[in]* **b** vector 2 | *[out]* **dest** dest += (a * b) .. c:function:: void glm_vec2_negate(vec2 v) negate vector components Parameters: | *[in, out]* **v** vector .. c:function:: void glm_vec2_negate_to(vec2 v, vec2 dest) negate vector components and store result in dest Parameters: | *[in]* **v** vector | *[out]* **dest** negated vector .. c:function:: void glm_vec2_normalize(vec2 v) normalize vec2 and store result in same vec Parameters: | *[in, out]* **v** vector .. c:function:: void glm_vec2_normalize_to(vec2 vec, vec2 dest) normalize vec2 to dest Parameters: | *[in]* **vec** source | *[out]* **dest** destination .. c:function:: void glm_vec2_rotate(vec2 v, float angle, vec2 dest) rotate vec2 around axis by angle using Rodrigues' rotation formula Parameters: | *[in]* **v** vector | *[in]* **axis** axis vector | *[out]* **dest** destination .. c:function:: void glm_vec2_center(vec2 v1, vec2 v2, vec2 dest) find center point of two vector Parameters: | *[in]* **v1** vector1 | *[in]* **v2** vector2 | *[out]* **dest** center point .. c:function:: float glm_vec2_distance2(vec2 v1, vec2 v2) squared distance between two vectors Parameters: | *[in]* **mat** vector1 | *[in]* **row1** vector2 Returns: | squared distance (distance * distance) .. c:function:: float glm_vec2_distance(vec2 v1, vec2 v2) distance between two vectors Parameters: | *[in]* **mat** vector1 | *[in]* **row1** vector2 Returns: | distance .. c:function:: void glm_vec2_maxv(vec2 v1, vec2 v2, vec2 dest) max values of vectors Parameters: | *[in]* **v1** vector1 | *[in]* **v2** vector2 | *[out]* **dest** destination .. c:function:: void glm_vec2_minv(vec2 v1, vec2 v2, vec2 dest) min values of vectors Parameters: | *[in]* **v1** vector1 | *[in]* **v2** vector2 | *[out]* **dest** destination .. c:function:: void glm_vec2_clamp(vec2 v, float minVal, float maxVal) constrain a value to lie between two further values Parameters: | *[in, out]* **v** vector | *[in]* **minVal** minimum value | *[in]* **maxVal** maximum value .. c:function:: void glm_vec2_lerp(vec2 from, vec2 to, float t, vec2 dest) linear interpolation between two vector | formula: from + s * (to - from) Parameters: | *[in]* **from** from value | *[in]* **to** to value | *[in]* **t** interpolant (amount) clamped between 0 and 1 | *[out]* **dest** destination .. c:function:: void glm_vec2_make(const float * __restrict src, vec2 dest) Create two dimensional vector from pointer .. note:: **@src** must contain at least 2 elements. Parameters: | *[in]* **src** pointer to an array of floats | *[out]* **dest** destination vector .. c:function:: void glm_vec2_reflect(vec2 v, vec2 n, vec2 dest) Reflection vector using an incident ray and a surface normal Parameters: | *[in]* **v** incident vector | *[in]* **n** *❗️ normalized ❗️* normal vector | *[out]* **dest** destination: reflection result .. c:function:: bool glm_vec2_refract(vec2 v, vec2 n, float eta, vec2 dest) Computes refraction vector for an incident vector and a surface normal. Calculates the refraction vector based on Snell's law. If total internal reflection occurs (angle too great given eta), dest is set to zero and returns false. Otherwise, computes refraction vector, stores it in dest, and returns true. Parameters: | *[in]* **v** *❗️ normalized ❗️* incident vector | *[in]* **n** *❗️ normalized ❗️* normal vector | *[in]* **eta** ratio of indices of refraction (incident/transmitted) | *[out]* **dest** refraction vector if refraction occurs; zero vector otherwise Returns: returns true if refraction occurs; false if total internal reflection occurs. cglm-0.9.6/docs/source/vec3-ext.rst000066400000000000000000000103551475344456400171140ustar00rootroot00000000000000.. default-domain:: C vec3 extra ========== Header: cglm/vec3-ext.h There are some functions are in called in extra header. These are called extra because they are not used like other functions in vec3.h in the future some of these functions ma be moved to vec3 header. Table of contents (click to go): ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Functions: 1. :c:func:`glm_vec3_mulv` #. :c:func:`glm_vec3_broadcast` #. :c:func:`glm_vec3_eq` #. :c:func:`glm_vec3_eq_eps` #. :c:func:`glm_vec3_eq_all` #. :c:func:`glm_vec3_eqv` #. :c:func:`glm_vec3_eqv_eps` #. :c:func:`glm_vec3_max` #. :c:func:`glm_vec3_min` #. :c:func:`glm_vec3_isnan` #. :c:func:`glm_vec3_isinf` #. :c:func:`glm_vec3_isvalid` #. :c:func:`glm_vec3_sign` #. :c:func:`glm_vec3_abs` #. :c:func:`glm_vec3_fract` #. :c:func:`glm_vec3_floor` #. :c:func:`glm_vec3_sqrt` Functions documentation ~~~~~~~~~~~~~~~~~~~~~~~ .. c:function:: void glm_vec3_mulv(vec3 a, vec3 b, vec3 d) multiplies individual items Parameters: | *[in]* **a** vec1 | *[in]* **b** vec2 | *[out]* **d** destination (v1[0] * v2[0], v1[1] * v2[1], v1[2] * v2[2]) .. c:function:: void glm_vec3_broadcast(float val, vec3 d) fill a vector with specified value Parameters: | *[in]* **val** value | *[out]* **dest** destination .. c:function:: void glm_vec3_fill(vec3 v, float val) fill a vector with specified value Parameters: | *[out]* **v** vector | *[in]* **val** value .. c:function:: bool glm_vec3_eq(vec3 v, float val) check if vector is equal to value (without epsilon) Parameters: | *[in]* **v** vector | *[in]* **val** value .. c:function:: bool glm_vec3_eq_eps(vec3 v, float val) check if vector is equal to value (with epsilon) Parameters: | *[in]* **v** vector | *[in]* **val** value .. c:function:: bool glm_vec3_eq_all(vec3 v) check if vectors members are equal (without epsilon) Parameters: | *[in]* **v** vector .. c:function:: bool glm_vec3_eqv(vec3 v1, vec3 v2) check if vector is equal to another (without epsilon) vector Parameters: | *[in]* **vec** vector 1 | *[in]* **vec** vector 2 .. c:function:: bool glm_vec3_eqv_eps(vec3 v1, vec3 v2) check if vector is equal to another (with epsilon) Parameters: | *[in]* **v1** vector1 | *[in]* **v2** vector2 .. c:function:: float glm_vec3_max(vec3 v) max value of vector Parameters: | *[in]* **v** vector .. c:function:: float glm_vec3_min(vec3 v) min value of vector Parameters: | *[in]* **v** vector .. c:function:: bool glm_vec3_isnan(vec3 v) | check if one of items is NaN (not a number) | you should only use this in DEBUG mode or very critical asserts Parameters: | *[in]* **v** vector .. c:function:: bool glm_vec3_isinf(vec3 v) | check if one of items is INFINITY | you should only use this in DEBUG mode or very critical asserts Parameters: | *[in]* **v** vector .. c:function:: bool glm_vec3_isvalid(vec3 v) | check if all items are valid number | you should only use this in DEBUG mode or very critical asserts Parameters: | *[in]* **v** vector .. c:function:: void glm_vec3_sign(vec3 v, vec3 dest) get sign of 32 bit float as +1, -1, 0 Parameters: | *[in]* **v** vector | *[out]* **dest** sign vector (only keeps signs as -1, 0, -1) .. c:function:: void glm_vec3_abs(vec3 v, vec3 dest) absolute value of each vector item Parameters: | *[in]* **v** vector | *[out]* **dest** destination vector .. c:function:: void glm_vec3_fract(vec3 v, vec3 dest) fractional part of each vector item Parameters: | *[in]* **v** vector | *[out]* **dest** destination vector .. c:function:: void glm_vec3_floor(vec3 v, vec3 dest) floor of each vector item Parameters: | *[in]* **v** vector | *[out]* **dest** destination vector .. c:function:: void glm_vec3_sqrt(vec3 v, vec3 dest) square root of each vector item Parameters: | *[in]* **v** vector | *[out]* **dest** destination vector (sqrt(v)) cglm-0.9.6/docs/source/vec3.rst000066400000000000000000000352751475344456400163260ustar00rootroot00000000000000.. default-domain:: C vec3 ==== Header: cglm/vec3.h **Important:** *cglm* was used **glm_vec_** namespace for vec3 functions until **v0.5.0**, since **v0.5.0** cglm uses **glm_vec3_** namespace for vec3. Also `glm_vec3_flipsign` has been renamed to `glm_vec3_negate` We mostly use vectors in graphics math, to make writing code faster and easy to read, some *vec3* functions are aliased in global namespace. For instance :c:func:`glm_dot` is alias of :c:func:`glm_vec3_dot`, alias means inline wrapper here. There is no call version of alias functions There are also functions for rotating *vec3* vector. **_m4**, **_m3** prefixes rotate *vec3* with matrix. Table of contents (click to go): ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Macros: 1. glm_vec3_dup(v, dest) #. GLM_VEC3_ONE_INIT #. GLM_VEC3_ZERO_INIT #. GLM_VEC3_ONE #. GLM_VEC3_ZERO #. GLM_YUP #. GLM_ZUP #. GLM_XUP Functions: 1. :c:func:`glm_vec3` #. :c:func:`glm_vec3_copy` #. :c:func:`glm_vec3_zero` #. :c:func:`glm_vec3_one` #. :c:func:`glm_vec3_dot` #. :c:func:`glm_vec3_norm2` #. :c:func:`glm_vec3_norm` #. :c:func:`glm_vec3_add` #. :c:func:`glm_vec3_adds` #. :c:func:`glm_vec3_sub` #. :c:func:`glm_vec3_subs` #. :c:func:`glm_vec3_mul` #. :c:func:`glm_vec3_scale` #. :c:func:`glm_vec3_scale_as` #. :c:func:`glm_vec3_div` #. :c:func:`glm_vec3_divs` #. :c:func:`glm_vec3_addadd` #. :c:func:`glm_vec3_subadd` #. :c:func:`glm_vec3_muladd` #. :c:func:`glm_vec3_muladds` #. :c:func:`glm_vec3_maxadd` #. :c:func:`glm_vec3_minadd` #. :c:func:`glm_vec3_flipsign` #. :c:func:`glm_vec3_flipsign_to` #. :c:func:`glm_vec3_inv` #. :c:func:`glm_vec3_inv_to` #. :c:func:`glm_vec3_negate` #. :c:func:`glm_vec3_negate_to` #. :c:func:`glm_vec3_normalize` #. :c:func:`glm_vec3_normalize_to` #. :c:func:`glm_vec3_cross` #. :c:func:`glm_vec3_crossn` #. :c:func:`glm_vec3_distance2` #. :c:func:`glm_vec3_distance` #. :c:func:`glm_vec3_angle` #. :c:func:`glm_vec3_rotate` #. :c:func:`glm_vec3_rotate_m4` #. :c:func:`glm_vec3_rotate_m3` #. :c:func:`glm_vec3_proj` #. :c:func:`glm_vec3_center` #. :c:func:`glm_vec3_maxv` #. :c:func:`glm_vec3_minv` #. :c:func:`glm_vec3_ortho` #. :c:func:`glm_vec3_clamp` #. :c:func:`glm_vec3_lerp` #. :c:func:`glm_vec3_make` #. :c:func:`glm_vec3_faceforward` #. :c:func:`glm_vec3_reflect` #. :c:func:`glm_vec3_refract` Functions documentation ~~~~~~~~~~~~~~~~~~~~~~~ .. c:function:: void glm_vec3(vec4 v4, vec3 dest) init vec3 using vec4 Parameters: | *[in]* **v4** vector4 | *[out]* **dest** destination .. c:function:: void glm_vec3_copy(vec3 a, vec3 dest) copy all members of [a] to [dest] Parameters: | *[in]* **a** source | *[out]* **dest** destination .. c:function:: void glm_vec3_zero(vec3 v) makes all members 0.0f (zero) Parameters: | *[in, out]* **v** vector .. c:function:: void glm_vec3_one(vec3 v) makes all members 1.0f (one) Parameters: | *[in, out]* **v** vector .. c:function:: float glm_vec3_dot(vec3 a, vec3 b) dot product of vec3 Parameters: | *[in]* **a** vector1 | *[in]* **b** vector2 Returns: dot product .. c:function:: void glm_vec3_cross(vec3 a, vec3 b, vec3 d) cross product of two vector (RH) Parameters: | *[in]* **a** vector 1 | *[in]* **b** vector 2 | *[out]* **dest** destination .. c:function:: void glm_vec3_crossn(vec3 a, vec3 b, vec3 dest) cross product of two vector (RH) and normalize the result Parameters: | *[in]* **a** vector 1 | *[in]* **b** vector 2 | *[out]* **dest** destination .. c:function:: float glm_vec3_norm2(vec3 v) norm * norm (magnitude) of vector we can use this func instead of calling norm * norm, because it would call sqrtf function twice but with this func we can avoid func call, maybe this is not good name for this func Parameters: | *[in]* **v** vector Returns: square of norm / magnitude .. c:function:: float glm_vec3_norm(vec3 vec) | euclidean norm (magnitude), also called L2 norm | this will give magnitude of vector in euclidean space Parameters: | *[in]* **vec** vector .. c:function:: void glm_vec3_add(vec3 a, vec3 b, vec3 dest) add a vector to b vector store result in dest Parameters: | *[in]* **a** vector1 | *[in]* **b** vector2 | *[out]* **dest** destination vector .. c:function:: void glm_vec3_adds(vec3 a, float s, vec3 dest) add scalar to v vector store result in dest (d = v + vec(s)) Parameters: | *[in]* **v** vector | *[in]* **s** scalar | *[out]* **dest** destination vector .. c:function:: void glm_vec3_sub(vec3 v1, vec3 v2, vec3 dest) subtract b vector from a vector store result in dest (d = v1 - v2) Parameters: | *[in]* **a** vector1 | *[in]* **b** vector2 | *[out]* **dest** destination vector .. c:function:: void glm_vec3_subs(vec3 v, float s, vec3 dest) subtract scalar from v vector store result in dest (d = v - vec(s)) Parameters: | *[in]* **v** vector | *[in]* **s** scalar | *[out]* **dest** destination vector .. c:function:: void glm_vec3_mul(vec3 a, vec3 b, vec3 d) multiply two vector (component-wise multiplication) Parameters: | *[in]* **a** vector | *[in]* **b** scalar | *[out]* **d** result = (a[0] * b[0], a[1] * b[1], a[2] * b[2]) .. c:function:: void glm_vec3_scale(vec3 v, float s, vec3 dest) multiply/scale vec3 vector with scalar: result = v * s Parameters: | *[in]* **v** vector | *[in]* **s** scalar | *[out]* **dest** destination vector .. c:function:: void glm_vec3_scale_as(vec3 v, float s, vec3 dest) make vec3 vector scale as specified: result = unit(v) * s Parameters: | *[in]* **v** vector | *[in]* **s** scalar | *[out]* **dest** destination vector .. c:function:: void glm_vec3_div(vec3 a, vec3 b, vec3 dest) div vector with another component-wise division: d = a / b Parameters: | *[in]* **a** vector 1 | *[in]* **b** vector 2 | *[out]* **dest** result = (a[0] / b[0], a[1] / b[1], a[2] / b[2]) .. c:function:: void glm_vec3_divs(vec3 v, float s, vec3 dest) div vector with scalar: d = v / s Parameters: | *[in]* **v** vector | *[in]* **s** scalar | *[out]* **dest** result = (a[0] / s, a[1] / s, a[2] / s]) .. c:function:: void glm_vec3_addadd(vec3 a, vec3 b, vec3 dest) | add two vectors and add result to sum | it applies += operator so dest must be initialized Parameters: | *[in]* **a** vector 1 | *[in]* **b** vector 2 | *[out]* **dest** dest += (a + b) .. c:function:: void glm_vec3_subadd(vec3 a, vec3 b, vec3 dest) | sub two vectors and add result to sum | it applies += operator so dest must be initialized Parameters: | *[in]* **a** vector 1 | *[in]* **b** vector 2 | *[out]* **dest** dest += (a - b) .. c:function:: void glm_vec3_muladd(vec3 a, vec3 b, vec3 dest) | mul two vectors and add result to sum | it applies += operator so dest must be initialized Parameters: | *[in]* **a** vector 1 | *[in]* **b** vector 2 | *[out]* **dest** dest += (a * b) .. c:function:: void glm_vec3_muladds(vec3 a, float s, vec3 dest) | mul vector with scalar and add result to sum | it applies += operator so dest must be initialized Parameters: | *[in]* **a** vector | *[in]* **s** scalar | *[out]* **dest** dest += (a * b) .. c:function:: void glm_vec3_maxadd(vec3 a, vec3 b, vec3 dest) | add max of two vector to result/dest | it applies += operator so dest must be initialized Parameters: | *[in]* **a** vector 1 | *[in]* **b** vector 2 | *[out]* **dest** dest += (a * b) .. c:function:: void glm_vec3_minadd(vec3 a, vec3 b, vec3 dest) | add min of two vector to result/dest | it applies += operator so dest must be initialized Parameters: | *[in]* **a** vector 1 | *[in]* **b** vector 2 | *[out]* **dest** dest += (a * b) .. c:function:: void glm_vec3_flipsign(vec3 v) **DEPRECATED!** use :c:func:`glm_vec3_negate` Parameters: | *[in, out]* **v** vector .. c:function:: void glm_vec3_flipsign_to(vec3 v, vec3 dest) **DEPRECATED!** use :c:func:`glm_vec3_negate_to` Parameters: | *[in]* **v** vector | *[out]* **dest** negated vector .. c:function:: void glm_vec3_inv(vec3 v) **DEPRECATED!** use :c:func:`glm_vec3_negate` Parameters: | *[in, out]* **v** vector .. c:function:: void glm_vec3_inv_to(vec3 v, vec3 dest) **DEPRECATED!** use :c:func:`glm_vec3_negate_to` Parameters: | *[in]* **v** source | *[out]* **dest** destination .. c:function:: void glm_vec3_negate(vec3 v) negate vector components Parameters: | *[in, out]* **v** vector .. c:function:: void glm_vec3_negate_to(vec3 v, vec3 dest) negate vector components and store result in dest Parameters: | *[in]* **v** vector | *[out]* **dest** negated vector .. c:function:: void glm_vec3_normalize(vec3 v) normalize vec3 and store result in same vec Parameters: | *[in, out]* **v** vector .. c:function:: void glm_vec3_normalize_to(vec3 vec, vec3 dest) normalize vec3 to dest Parameters: | *[in]* **vec** source | *[out]* **dest** destination .. c:function:: float glm_vec3_angle(vec3 v1, vec3 v2) angle between two vector Parameters: | *[in]* **v1** vector1 | *[in]* **v2** vector2 Return: | angle as radians .. c:function:: void glm_vec3_rotate(vec3 v, float angle, vec3 axis) rotate vec3 around axis by angle using Rodrigues' rotation formula Parameters: | *[in, out]* **v** vector | *[in]* **axis** axis vector (will be normalized) | *[in]* **angle** angle (radians) .. c:function:: void glm_vec3_rotate_m4(mat4 m, vec3 v, vec3 dest) apply rotation matrix to vector Parameters: | *[in]* **m** affine matrix or rot matrix | *[in]* **v** vector | *[out]* **dest** rotated vector .. c:function:: void glm_vec3_rotate_m3(mat3 m, vec3 v, vec3 dest) apply rotation matrix to vector Parameters: | *[in]* **m** affine matrix or rot matrix | *[in]* **v** vector | *[out]* **dest** rotated vector .. c:function:: void glm_vec3_proj(vec3 a, vec3 b, vec3 dest) project a vector onto b vector Parameters: | *[in]* **a** vector1 | *[in]* **b** vector2 | *[out]* **dest** projected vector .. c:function:: void glm_vec3_center(vec3 v1, vec3 v2, vec3 dest) find center point of two vector Parameters: | *[in]* **v1** vector1 | *[in]* **v2** vector2 | *[out]* **dest** center point .. c:function:: float glm_vec3_distance2(vec3 v1, vec3 v2) squared distance between two vectors Parameters: | *[in]* **v1** vector1 | *[in]* **v2** vector2 Returns: | squared distance (distance * distance) .. c:function:: float glm_vec3_distance(vec3 v1, vec3 v2) distance between two vectors Parameters: | *[in]* **v1** vector1 | *[in]* **v2** vector2 Returns: | distance .. c:function:: void glm_vec3_maxv(vec3 v1, vec3 v2, vec3 dest) max values of vectors Parameters: | *[in]* **v1** vector1 | *[in]* **v2** vector2 | *[out]* **dest** destination .. c:function:: void glm_vec3_minv(vec3 v1, vec3 v2, vec3 dest) min values of vectors Parameters: | *[in]* **v1** vector1 | *[in]* **v2** vector2 | *[out]* **dest** destination .. c:function:: void glm_vec3_ortho(vec3 v, vec3 dest) possible orthogonal/perpendicular vector References: * `On picking an orthogonal vector (and combing coconuts) `_ Parameters: | *[in]* **v** vector | *[out]* **dest** orthogonal/perpendicular vector .. c:function:: void glm_vec3_clamp(vec3 v, float minVal, float maxVal) constrain a value to lie between two further values Parameters: | *[in, out]* **v** vector | *[in]* **minVal** minimum value | *[in]* **maxVal** maximum value .. c:function:: void glm_vec3_lerp(vec3 from, vec3 to, float t, vec3 dest) linear interpolation between two vector | formula: from + s * (to - from) Parameters: | *[in]* **from** from value | *[in]* **to** to value | *[in]* **t** interpolant (amount) clamped between 0 and 1 | *[out]* **dest** destination .. c:function:: void glm_vec3_make(const float * __restrict src, vec3 dest) Create three dimensional vector from pointer .. note::: **@src** must contain at least 3 elements. Parameters: | *[in]* **src** pointer to an array of floats | *[out]* **dest** destination vector .. c:function:: void glm_vec3_faceforward(vec3 n, vec3 v, vec3 nref, vec3 dest) A vector pointing in the same direction as another Parameters: | *[in]* **n** vector to orient | *[in]* **v** incident vector | *[in]* **nref** reference vector | *[out]* **dest** destination: oriented vector, pointing away from the surface. .. c:function:: void glm_vec3_reflect(vec3 v, vec3 n, vec3 dest) Reflection vector using an incident ray and a surface normal Parameters: | *[in]* **v** incident vector | *[in]* **n** *❗️ normalized ❗️* normal vector | *[out]* **dest** destination: reflection result .. c:function:: bool glm_vec3_refract(vec3 v, vec3 n, float eta, vec3 dest) Computes refraction vector for an incident vector and a surface normal. Calculates the refraction vector based on Snell's law. If total internal reflection occurs (angle too great given eta), dest is set to zero and returns false. Otherwise, computes refraction vector, stores it in dest, and returns true. Parameters: | *[in]* **v** *❗️ normalized ❗️* incident vector | *[in]* **n** *❗️ normalized ❗️* normal vector | *[in]* **eta** ratio of indices of refraction (incident/transmitted) | *[out]* **dest** refraction vector if refraction occurs; zero vector otherwise Returns: returns true if refraction occurs; false if total internal reflection occurs. cglm-0.9.6/docs/source/vec4-ext.rst000066400000000000000000000100511475344456400171060ustar00rootroot00000000000000.. default-domain:: C vec4 extra ========== Header: cglm/vec4-ext.h There are some functions are in called in extra header. These are called extra because they are not used like other functions in vec4.h in the future some of these functions ma be moved to vec4 header. Table of contents (click to go): ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Functions: 1. :c:func:`glm_vec4_mulv` #. :c:func:`glm_vec4_broadcast` #. :c:func:`glm_vec4_eq` #. :c:func:`glm_vec4_eq_eps` #. :c:func:`glm_vec4_eq_all` #. :c:func:`glm_vec4_eqv` #. :c:func:`glm_vec4_eqv_eps` #. :c:func:`glm_vec4_max` #. :c:func:`glm_vec4_min` #. :c:func:`glm_vec4_isnan` #. :c:func:`glm_vec4_isinf` #. :c:func:`glm_vec4_isvalid` #. :c:func:`glm_vec4_sign` #. :c:func:`glm_vec4_abs` #. :c:func:`glm_vec4_fract` #. :c:func:`glm_vec4_floor` #. :c:func:`glm_vec4_sqrt` Functions documentation ~~~~~~~~~~~~~~~~~~~~~~~ .. c:function:: void glm_vec4_mulv(vec4 a, vec4 b, vec4 d) multiplies individual items Parameters: | *[in]* **a** vec1 | *[in]* **b** vec2 | *[out]* **d** destination .. c:function:: void glm_vec4_broadcast(float val, vec4 d) fill a vector with specified value Parameters: | *[in]* **val** value | *[out]* **dest** destination .. c:function:: bool glm_vec4_eq(vec4 v, float val) check if vector is equal to value (without epsilon) Parameters: | *[in]* **v** vector | *[in]* **val** value .. c:function:: bool glm_vec4_eq_eps(vec4 v, float val) check if vector is equal to value (with epsilon) Parameters: | *[in]* **v** vector | *[in]* **val** value .. c:function:: bool glm_vec4_eq_all(vec4 v) check if vectors members are equal (without epsilon) Parameters: | *[in]* **v** vector .. c:function:: bool glm_vec4_eqv(vec4 v1, vec4 v2) check if vector is equal to another (without epsilon) vector Parameters: | *[in]* **vec** vector 1 | *[in]* **vec** vector 2 .. c:function:: bool glm_vec4_eqv_eps(vec4 v1, vec4 v2) check if vector is equal to another (with epsilon) Parameters: | *[in]* **v1** vector1 | *[in]* **v2** vector2 .. c:function:: float glm_vec4_max(vec4 v) max value of vector Parameters: | *[in]* **v** vector .. c:function:: float glm_vec4_min(vec4 v) min value of vector Parameters: | *[in]* **v** vector .. c:function:: bool glm_vec4_isnan(vec4 v) | check if one of items is NaN (not a number) | you should only use this in DEBUG mode or very critical asserts Parameters: | *[in]* **v** vector .. c:function:: bool glm_vec4_isinf(vec4 v) | check if one of items is INFINITY | you should only use this in DEBUG mode or very critical asserts Parameters: | *[in]* **v** vector .. c:function:: bool glm_vec4_isvalid(vec4 v) | check if all items are valid number | you should only use this in DEBUG mode or very critical asserts Parameters: | *[in]* **v** vector .. c:function:: void glm_vec4_sign(vec4 v, vec4 dest) get sign of 32 bit float as +1, -1, 0 Parameters: | *[in]* **v** vector | *[out]* **dest** sign vector (only keeps signs as -1, 0, -1) .. c:function:: void glm_vec4_abs(vec4 v, vec4 dest) absolute value of each vector item Parameters: | *[in]* **v** vector | *[out]* **dest** destination vector (abs(v)) .. c:function:: void glm_vec4_fract(vec4 v, vec4 dest) fractional part of each vector item Parameters: | *[in]* **v** vector | *[out]* **dest** destination vector (fract(v)) .. c:function:: void glm_vec4_floor(vec4 v, vec4 dest) floor of each vector item Parameters: | *[in]* **v** vector | *[out]* **dest** destination vector (floor(v)) .. c:function:: void glm_vec4_sqrt(vec4 v, vec4 dest) square root of each vector item Parameters: | *[in]* **v** vector | *[out]* **dest** destination vector (sqrt(v)) cglm-0.9.6/docs/source/vec4.rst000066400000000000000000000300411475344456400163110ustar00rootroot00000000000000.. default-domain:: C vec4 ==== Header: cglm/vec4.h Table of contents (click to go): ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Macros: 1. glm_vec4_dup3(v, dest) #. glm_vec4_dup(v, dest) #. GLM_VEC4_ONE_INIT #. GLM_VEC4_BLACK_INIT #. GLM_VEC4_ZERO_INIT #. GLM_VEC4_ONE #. GLM_VEC4_BLACK #. GLM_VEC4_ZERO Functions: 1. :c:func:`glm_vec4` #. :c:func:`glm_vec4_copy3` #. :c:func:`glm_vec4_copy` #. :c:func:`glm_vec4_ucopy` #. :c:func:`glm_vec4_zero` #. :c:func:`glm_vec4_one` #. :c:func:`glm_vec4_dot` #. :c:func:`glm_vec4_norm2` #. :c:func:`glm_vec4_norm` #. :c:func:`glm_vec4_add` #. :c:func:`glm_vec4_adds` #. :c:func:`glm_vec4_sub` #. :c:func:`glm_vec4_subs` #. :c:func:`glm_vec4_mul` #. :c:func:`glm_vec4_scale` #. :c:func:`glm_vec4_scale_as` #. :c:func:`glm_vec4_div` #. :c:func:`glm_vec4_divs` #. :c:func:`glm_vec4_addadd` #. :c:func:`glm_vec4_subadd` #. :c:func:`glm_vec4_muladd` #. :c:func:`glm_vec4_muladds` #. :c:func:`glm_vec4_maxadd` #. :c:func:`glm_vec4_minadd` #. :c:func:`glm_vec4_flipsign` #. :c:func:`glm_vec4_flipsign_to` #. :c:func:`glm_vec4_inv` #. :c:func:`glm_vec4_inv_to` #. :c:func:`glm_vec4_negate` #. :c:func:`glm_vec4_negate_to` #. :c:func:`glm_vec4_normalize` #. :c:func:`glm_vec4_normalize_to` #. :c:func:`glm_vec4_distance` #. :c:func:`glm_vec4_maxv` #. :c:func:`glm_vec4_minv` #. :c:func:`glm_vec4_clamp` #. :c:func:`glm_vec4_lerp` #. :c:func:`glm_vec4_cubic` #. :c:func:`glm_vec4_make` #. :c:func:`glm_vec4_reflect` #. :c:func:`glm_vec4_refract` Functions documentation ~~~~~~~~~~~~~~~~~~~~~~~ .. c:function:: void glm_vec4(vec3 v3, float last, vec4 dest) init vec4 using vec3, since you are initializing vec4 with vec3 you need to set last item. cglm could set it zero but making it parameter gives more control Parameters: | *[in]* **v3** vector4 | *[in]* **last** last item of vec4 | *[out]* **dest** destination .. c:function:: void glm_vec4_copy3(vec4 a, vec3 dest) copy first 3 members of [a] to [dest] Parameters: | *[in]* **a** source | *[out]* **dest** destination .. c:function:: void glm_vec4_copy(vec4 v, vec4 dest) copy all members of [a] to [dest] Parameters: | *[in]* **v** source | *[in]* **dest** destination .. c:function:: void glm_vec4_ucopy(vec4 v, vec4 dest) copy all members of [a] to [dest] | alignment is not required Parameters: | *[in]* **v** source | *[in]* **dest** destination .. c:function:: void glm_vec4_zero(vec4 v) makes all members zero Parameters: | *[in, out]* **v** vector .. c:function:: void glm_vec4_one(vec4 v) makes all members one Parameters: | *[in, out]* **v** vector .. c:function:: float glm_vec4_dot(vec4 a, vec4 b) dot product of vec4 Parameters: | *[in]* **a** vector1 | *[in]* **b** vector2 Returns: dot product .. c:function:: float glm_vec4_norm2(vec4 v) norm * norm (magnitude) of vector we can use this func instead of calling norm * norm, because it would call sqrtf function twice but with this func we can avoid func call, maybe this is not good name for this func Parameters: | *[in]* **v** vector Returns: square of norm / magnitude .. c:function:: float glm_vec4_norm(vec4 vec) | euclidean norm (magnitude), also called L2 norm | this will give magnitude of vector in euclidean space Parameters: | *[in]* **vec** vector .. c:function:: void glm_vec4_add(vec4 a, vec4 b, vec4 dest) add a vector to b vector store result in dest Parameters: | *[in]* **a** vector1 | *[in]* **b** vector2 | *[out]* **dest** destination vector .. c:function:: void glm_vec4_adds(vec4 v, float s, vec4 dest) add scalar to v vector store result in dest (d = v + vec(s)) Parameters: | *[in]* **v** vector | *[in]* **s** scalar | *[out]* **dest** destination vector .. c:function:: void glm_vec4_sub(vec4 a, vec4 b, vec4 dest) subtract b vector from a vector store result in dest (d = v1 - v2) Parameters: | *[in]* **a** vector1 | *[in]* **b** vector2 | *[out]* **dest** destination vector .. c:function:: void glm_vec4_subs(vec4 v, float s, vec4 dest) subtract scalar from v vector store result in dest (d = v - vec(s)) Parameters: | *[in]* **v** vector | *[in]* **s** scalar | *[out]* **dest** destination vector .. c:function:: void glm_vec4_mul(vec4 a, vec4 b, vec4 d) multiply two vector (component-wise multiplication) Parameters: | *[in]* **a** vector1 | *[in]* **b** vector2 | *[out]* **dest** result = (a[0] * b[0], a[1] * b[1], a[2] * b[2], a[3] * b[3]) .. c:function:: void glm_vec4_scale(vec4 v, float s, vec4 dest) multiply/scale vec4 vector with scalar: result = v * s Parameters: | *[in]* **v** vector | *[in]* **s** scalar | *[out]* **dest** destination vector .. c:function:: void glm_vec4_scale_as(vec4 v, float s, vec4 dest) make vec4 vector scale as specified: result = unit(v) * s Parameters: | *[in]* **v** vector | *[in]* **s** scalar | *[out]* **dest** destination vector .. c:function:: void glm_vec4_div(vec4 a, vec4 b, vec4 dest) div vector with another component-wise division: d = v1 / v2 Parameters: | *[in]* **a** vector1 | *[in]* **b** vector2 | *[out]* **dest** result = (a[0] / b[0], a[1] / b[1], a[2] / b[2], a[3] / b[3]) .. c:function:: void glm_vec4_divs(vec4 v, float s, vec4 dest) div vector with scalar: d = v / s Parameters: | *[in]* **v** vector | *[in]* **s** scalar | *[out]* **dest** result = (a[0] / s, a[1] / s, a[2] / s, a[3] / s) .. c:function:: void glm_vec4_addadd(vec4 a, vec4 b, vec4 dest) | add two vectors and add result to sum | it applies += operator so dest must be initialized Parameters: | *[in]* **a** vector 1 | *[in]* **b** vector 2 | *[out]* **dest** dest += (a + b) .. c:function:: void glm_vec4_subadd(vec4 a, vec4 b, vec4 dest) | sub two vectors and add result to sum | it applies += operator so dest must be initialized Parameters: | *[in]* **a** vector 1 | *[in]* **b** vector 2 | *[out]* **dest** dest += (a - b) .. c:function:: void glm_vec4_muladd(vec4 a, vec4 b, vec4 dest) | mul two vectors and add result to sum | it applies += operator so dest must be initialized Parameters: | *[in]* **a** vector 1 | *[in]* **b** vector 2 | *[out]* **dest** dest += (a * b) .. c:function:: void glm_vec4_muladds(vec4 a, float s, vec4 dest) | mul vector with scalar and add result to sum | it applies += operator so dest must be initialized Parameters: | *[in]* **a** vector | *[in]* **s** scalar | *[out]* **dest** dest += (a * b) .. c:function:: void glm_vec4_maxadd(vec4 a, vec4 b, vec4 dest) | add max of two vector to result/dest | it applies += operator so dest must be initialized Parameters: | *[in]* **a** vector 1 | *[in]* **b** vector 2 | *[out]* **dest** dest += (a * b) .. c:function:: void glm_vec4_minadd(vec4 a, vec4 b, vec4 dest) | add min of two vector to result/dest | it applies += operator so dest must be initialized Parameters: | *[in]* **a** vector 1 | *[in]* **b** vector 2 | *[out]* **dest** dest += (a * b) .. c:function:: void glm_vec4_flipsign(vec4 v) **DEPRECATED!** use :c:func:`glm_vec4_negate` Parameters: | *[in, out]* **v** vector .. c:function:: void glm_vec4_flipsign_to(vec4 v, vec4 dest) **DEPRECATED!** use :c:func:`glm_vec4_negate_to` Parameters: | *[in]* **v** vector | *[out]* **dest** negated vector .. c:function:: void glm_vec4_inv(vec4 v) **DEPRECATED!** use :c:func:`glm_vec4_negate` Parameters: | *[in, out]* **v** vector .. c:function:: void glm_vec4_inv_to(vec4 v, vec4 dest) **DEPRECATED!** use :c:func:`glm_vec4_negate_to` Parameters: | *[in]* **v** source | *[out]* **dest** destination .. c:function:: void glm_vec4_negate(vec4 v) negate vector components Parameters: | *[in, out]* **v** vector .. c:function:: void glm_vec4_negate_to(vec4 v, vec4 dest) negate vector components and store result in dest Parameters: | *[in]* **v** vector | *[out]* **dest** negated vector .. c:function:: void glm_vec4_normalize(vec4 v) normalize vec4 and store result in same vec Parameters: | *[in, out]* **v** vector .. c:function:: void glm_vec4_normalize_to(vec4 vec, vec4 dest) normalize vec4 to dest Parameters: | *[in]* **vec** source | *[out]* **dest** destination .. c:function:: float glm_vec4_distance(vec4 v1, vec4 v2) distance between two vectors Parameters: | *[in]* **mat** vector1 | *[in]* **row1** vector2 Returns: | distance .. c:function:: void glm_vec4_maxv(vec4 v1, vec4 v2, vec4 dest) max values of vectors Parameters: | *[in]* **v1** vector1 | *[in]* **v2** vector2 | *[out]* **dest** destination .. c:function:: void glm_vec4_minv(vec4 v1, vec4 v2, vec4 dest) min values of vectors Parameters: | *[in]* **v1** vector1 | *[in]* **v2** vector2 | *[out]* **dest** destination .. c:function:: void glm_vec4_clamp(vec4 v, float minVal, float maxVal) constrain a value to lie between two further values Parameters: | *[in, out]* **v** vector | *[in]* **minVal** minimum value | *[in]* **maxVal** maximum value .. c:function:: void glm_vec4_lerp(vec4 from, vec4 to, float t, vec4 dest) linear interpolation between two vector | formula: from + s * (to - from) Parameters: | *[in]* **from** from value | *[in]* **to** to value | *[in]* **t** interpolant (amount) clamped between 0 and 1 | *[out]* **dest** destination .. c:function:: void glm_vec4_cubic(float s, vec4 dest) helper to fill vec4 as [S^3, S^2, S, 1] Parameters: | *[in]* **s** parameter | *[out]* **dest** destination .. c:function:: void glm_vec4_make(const float * __restrict src, vec4 dest) Create four dimensional vector from pointer .. note:: **@src** must contain at least 4 elements. Parameters: | *[in]* **src** pointer to an array of floats | *[out]* **dest** destination vector .. c:function:: bool glm_vec4_reflect(vec4 v, vec4 n, vec4 dest) Reflection vector using an incident ray and a surface normal Parameters: | *[in]* **v** incident vector | *[in]* **n** *❗️ normalized ❗️* normal vector | *[out]* **dest** destination: reflection result .. c:function:: bool glm_vec4_refract(vec4 v, vec4 n, float eta, vec4 dest) computes refraction vector for an incident vector and a surface normal. Calculates the refraction vector based on Snell's law. If total internal reflection occurs (angle too great given eta), dest is set to zero and returns false. Otherwise, computes refraction vector, stores it in dest, and returns true. This implementation does not explicitly preserve the 'w' component of the incident vector 'I' in the output 'dest', users requiring the preservation of the 'w' component should manually adjust 'dest' after calling this function. Parameters: | *[in]* **v** *❗️ normalized ❗️* incident vector | *[in]* **n** *❗️ normalized ❗️* normal vector | *[in]* **eta** ratio of indices of refraction (incident/transmitted) | *[out]* **dest** refraction vector if refraction occurs; zero vector otherwise Returns: returns true if refraction occurs; false if total internal reflection occurs. cglm-0.9.6/docs/source/version.rst000066400000000000000000000007551475344456400171460ustar00rootroot00000000000000.. default-domain:: C version ================================================================================ Header: cglm/version.h **cglm** uses semantic versioning (http://semver.org) which is MAJOR.MINOR.PATCH | **CGLM_VERSION_MAJOR** is major number of the version. | **CGLM_VERSION_MINOR** is minor number of the version. | **CGLM_VERSION_PATCH** is patch number of the version. every release increases these numbers. You can check existing version by including `cglm/version.h` cglm-0.9.6/include/000077500000000000000000000000001475344456400141135ustar00rootroot00000000000000cglm-0.9.6/include/cglm/000077500000000000000000000000001475344456400150355ustar00rootroot00000000000000cglm-0.9.6/include/cglm/aabb2d.h000066400000000000000000000142121475344456400163210ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ #ifndef cglm_aabb2d_h #define cglm_aabb2d_h #include "common.h" #include "vec2.h" #include "util.h" /* DEPRECATED! use _diag */ #define glm_aabb2d_size(aabb) glm_aabb2d_diag(aabb) /*! * @brief make [aabb] zero * * @param[in, out] aabb aabb */ CGLM_INLINE void glm_aabb2d_zero(vec2 aabb[2]) { glm_vec2_zero(aabb[0]); glm_vec2_zero(aabb[1]); } /*! * @brief copy all members of [aabb] to [dest] * * @param[in] aabb source * @param[out] dest destination */ CGLM_INLINE void glm_aabb2d_copy(vec2 aabb[2], vec2 dest[2]) { glm_vec2_copy(aabb[0], dest[0]); glm_vec2_copy(aabb[1], dest[1]); } /*! * @brief apply transform to Axis-Aligned Bounding aabb * * @param[in] aabb bounding aabb * @param[in] m transform matrix * @param[out] dest transformed bounding aabb */ CGLM_INLINE void glm_aabb2d_transform(vec2 aabb[2], mat3 m, vec2 dest[2]) { vec2 v[2], xa, xb, ya, yb; glm_vec2_scale(m[0], aabb[0][0], xa); glm_vec2_scale(m[0], aabb[1][0], xb); glm_vec2_scale(m[1], aabb[0][1], ya); glm_vec2_scale(m[1], aabb[1][1], yb); /* translation + min(xa, xb) + min(ya, yb) */ glm_vec2(m[2], v[0]); glm_vec2_minadd(xa, xb, v[0]); glm_vec2_minadd(ya, yb, v[0]); /* translation + max(xa, xb) + max(ya, yb) */ glm_vec2(m[2], v[1]); glm_vec2_maxadd(xa, xb, v[1]); glm_vec2_maxadd(ya, yb, v[1]); glm_vec2_copy(v[0], dest[0]); glm_vec2_copy(v[1], dest[1]); } /*! * @brief merges two AABB bounding aabb and creates new one * * two aabb must be in same space, if one of aabb is in different space then * you should consider to convert it's space by glm_aabb_space * * @param[in] aabb1 bounding aabb 1 * @param[in] aabb2 bounding aabb 2 * @param[out] dest merged bounding aabb */ CGLM_INLINE void glm_aabb2d_merge(vec2 aabb1[2], vec2 aabb2[2], vec2 dest[2]) { dest[0][0] = glm_min(aabb1[0][0], aabb2[0][0]); dest[0][1] = glm_min(aabb1[0][1], aabb2[0][1]); dest[1][0] = glm_max(aabb1[1][0], aabb2[1][0]); dest[1][1] = glm_max(aabb1[1][1], aabb2[1][1]); } /*! * @brief crops a bounding aabb with another one. * * this could be useful for getting a baabb which fits with view frustum and * object bounding aabbes. In this case you crop view frustum aabb with objects * aabb * * @param[in] aabb bounding aabb 1 * @param[in] cropAabb crop aabb * @param[out] dest cropped bounding aabb */ CGLM_INLINE void glm_aabb2d_crop(vec2 aabb[2], vec2 cropAabb[2], vec2 dest[2]) { dest[0][0] = glm_max(aabb[0][0], cropAabb[0][0]); dest[0][1] = glm_max(aabb[0][1], cropAabb[0][1]); dest[1][0] = glm_min(aabb[1][0], cropAabb[1][0]); dest[1][1] = glm_min(aabb[1][1], cropAabb[1][1]); } /*! * @brief crops a bounding aabb with another one. * * this could be useful for getting a baabb which fits with view frustum and * object bounding aabbes. In this case you crop view frustum aabb with objects * aabb * * @param[in] aabb bounding aabb * @param[in] cropAabb crop aabb * @param[in] clampAabb minimum aabb * @param[out] dest cropped bounding aabb */ CGLM_INLINE void glm_aabb2d_crop_until(vec2 aabb[2], vec2 cropAabb[2], vec2 clampAabb[2], vec2 dest[2]) { glm_aabb2d_crop(aabb, cropAabb, dest); glm_aabb2d_merge(clampAabb, dest, dest); } /*! * @brief invalidate AABB min and max values * * @param[in, out] aabb bounding aabb */ CGLM_INLINE void glm_aabb2d_invalidate(vec2 aabb[2]) { glm_vec2_fill(aabb[0], FLT_MAX); glm_vec2_fill(aabb[1], -FLT_MAX); } /*! * @brief check if AABB is valid or not * * @param[in] aabb bounding aabb */ CGLM_INLINE bool glm_aabb2d_isvalid(vec2 aabb[2]) { return glm_vec2_max(aabb[0]) != FLT_MAX && glm_vec2_min(aabb[1]) != -FLT_MAX; } /*! * @brief distance between of min and max * * @param[in] aabb bounding aabb */ CGLM_INLINE float glm_aabb2d_diag(vec2 aabb[2]) { return glm_vec2_distance(aabb[0], aabb[1]); } /*! * @brief size of aabb * * @param[in] aabb bounding aabb * @param[out] dest size */ CGLM_INLINE void glm_aabb2d_sizev(vec2 aabb[2], vec2 dest) { glm_vec2_sub(aabb[1], aabb[0], dest); } /*! * @brief radius of sphere which surrounds AABB * * @param[in] aabb bounding aabb */ CGLM_INLINE float glm_aabb2d_radius(vec2 aabb[2]) { return glm_aabb2d_diag(aabb) * 0.5f; } /*! * @brief computes center point of AABB * * @param[in] aabb bounding aabb * @param[out] dest center of bounding aabb */ CGLM_INLINE void glm_aabb2d_center(vec2 aabb[2], vec2 dest) { glm_vec2_center(aabb[0], aabb[1], dest); } /*! * @brief check if two AABB intersects * * @param[in] aabb bounding aabb * @param[in] other other bounding aabb */ CGLM_INLINE bool glm_aabb2d_aabb(vec2 aabb[2], vec2 other[2]) { return (aabb[0][0] <= other[1][0] && aabb[1][0] >= other[0][0]) && (aabb[0][1] <= other[1][1] && aabb[1][1] >= other[0][1]); } /*! * @brief check if AABB intersects with a circle * * Circle Representation in cglm: [center.x, center.y, radii] * * @param[in] aabb solid bounding aabb * @param[in] c solid circle */ CGLM_INLINE bool glm_aabb2d_circle(vec2 aabb[2], vec3 c) { float dmin; int a, b; a = (c[0] < aabb[0][0]) + (c[0] > aabb[1][0]); b = (c[1] < aabb[0][1]) + (c[1] > aabb[1][1]); dmin = glm_pow2((c[0] - aabb[!(a - 1)][0]) * (a != 0)) + glm_pow2((c[1] - aabb[!(b - 1)][1]) * (b != 0)); return dmin <= glm_pow2(c[2]); } /*! * @brief check if point is inside of AABB * * @param[in] aabb bounding aabb * @param[in] point point */ CGLM_INLINE bool glm_aabb2d_point(vec2 aabb[2], vec2 point) { return (point[0] >= aabb[0][0] && point[0] <= aabb[1][0]) && (point[1] >= aabb[0][1] && point[1] <= aabb[1][1]); } /*! * @brief check if AABB contains other AABB * * @param[in] aabb bounding aabb * @param[in] other other bounding aabb */ CGLM_INLINE bool glm_aabb2d_contains(vec2 aabb[2], vec2 other[2]) { return (aabb[0][0] <= other[0][0] && aabb[1][0] >= other[1][0]) && (aabb[0][1] <= other[0][1] && aabb[1][1] >= other[1][1]); } #endif /* cglm_aabb2d_h */ cglm-0.9.6/include/cglm/affine-mat.h000066400000000000000000000125331475344456400172210ustar00rootroot00000000000000/* * 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_mul(mat4 m1, mat4 m2, mat4 dest); CGLM_INLINE void glm_mul_rot(mat4 m1, mat4 m2, mat4 dest); CGLM_INLINE void glm_inv_tr(mat4 mat); */ #ifndef cglm_affine_mat_h #define cglm_affine_mat_h #include "common.h" #include "mat4.h" #include "mat3.h" #ifdef CGLM_SSE_FP # include "simd/sse2/affine.h" #endif #ifdef CGLM_AVX_FP # include "simd/avx/affine.h" #endif #ifdef CGLM_NEON_FP # include "simd/neon/affine.h" #endif #ifdef CGLM_SIMD_WASM # include "simd/wasm/affine.h" #endif /*! * @brief this is similar to glm_mat4_mul but specialized to affine transform * * Matrix format should be: * R R R X * R R R Y * R R R Z * 0 0 0 W * * this reduces some multiplications. It should be faster than mat4_mul. * if you are not sure about matrix format then DON'T use this! use mat4_mul * * @param[in] m1 affine matrix 1 * @param[in] m2 affine matrix 2 * @param[out] dest result matrix */ CGLM_INLINE void glm_mul(mat4 m1, mat4 m2, mat4 dest) { #if defined(__wasm__) && defined(__wasm_simd128__) glm_mul_wasm(m1, m2, dest); #elif defined(__AVX__) glm_mul_avx(m1, m2, dest); #elif defined( __SSE__ ) || defined( __SSE2__ ) glm_mul_sse2(m1, m2, dest); #elif defined(CGLM_NEON_FP) glm_mul_neon(m1, m2, dest); #else float a00 = m1[0][0], a01 = m1[0][1], a02 = m1[0][2], a03 = m1[0][3], a10 = m1[1][0], a11 = m1[1][1], a12 = m1[1][2], a13 = m1[1][3], a20 = m1[2][0], a21 = m1[2][1], a22 = m1[2][2], a23 = m1[2][3], a30 = m1[3][0], a31 = m1[3][1], a32 = m1[3][2], a33 = m1[3][3], b00 = m2[0][0], b01 = m2[0][1], b02 = m2[0][2], b10 = m2[1][0], b11 = m2[1][1], b12 = m2[1][2], b20 = m2[2][0], b21 = m2[2][1], b22 = m2[2][2], b30 = m2[3][0], b31 = m2[3][1], b32 = m2[3][2], b33 = m2[3][3]; dest[0][0] = a00 * b00 + a10 * b01 + a20 * b02; dest[0][1] = a01 * b00 + a11 * b01 + a21 * b02; dest[0][2] = a02 * b00 + a12 * b01 + a22 * b02; dest[0][3] = a03 * b00 + a13 * b01 + a23 * b02; dest[1][0] = a00 * b10 + a10 * b11 + a20 * b12; dest[1][1] = a01 * b10 + a11 * b11 + a21 * b12; dest[1][2] = a02 * b10 + a12 * b11 + a22 * b12; dest[1][3] = a03 * b10 + a13 * b11 + a23 * b12; dest[2][0] = a00 * b20 + a10 * b21 + a20 * b22; dest[2][1] = a01 * b20 + a11 * b21 + a21 * b22; dest[2][2] = a02 * b20 + a12 * b21 + a22 * b22; dest[2][3] = a03 * b20 + a13 * b21 + a23 * b22; dest[3][0] = a00 * b30 + a10 * b31 + a20 * b32 + a30 * b33; dest[3][1] = a01 * b30 + a11 * b31 + a21 * b32 + a31 * b33; dest[3][2] = a02 * b30 + a12 * b31 + a22 * b32 + a32 * b33; dest[3][3] = a03 * b30 + a13 * b31 + a23 * b32 + a33 * b33; #endif } /*! * @brief this is similar to glm_mat4_mul but specialized to affine transform * * Right Matrix format should be: * R R R 0 * R R R 0 * R R R 0 * 0 0 0 1 * * this reduces some multiplications. It should be faster than mat4_mul. * if you are not sure about matrix format then DON'T use this! use mat4_mul * * @param[in] m1 affine matrix 1 * @param[in] m2 affine matrix 2 * @param[out] dest result matrix */ CGLM_INLINE void glm_mul_rot(mat4 m1, mat4 m2, mat4 dest) { #if defined(__wasm__) && defined(__wasm_simd128__) glm_mul_rot_wasm(m1, m2, dest); #elif defined( __SSE__ ) || defined( __SSE2__ ) glm_mul_rot_sse2(m1, m2, dest); #elif defined(CGLM_NEON_FP) glm_mul_rot_neon(m1, m2, dest); #else float a00 = m1[0][0], a01 = m1[0][1], a02 = m1[0][2], a03 = m1[0][3], a10 = m1[1][0], a11 = m1[1][1], a12 = m1[1][2], a13 = m1[1][3], a20 = m1[2][0], a21 = m1[2][1], a22 = m1[2][2], a23 = m1[2][3], a30 = m1[3][0], a31 = m1[3][1], a32 = m1[3][2], a33 = m1[3][3], b00 = m2[0][0], b01 = m2[0][1], b02 = m2[0][2], b10 = m2[1][0], b11 = m2[1][1], b12 = m2[1][2], b20 = m2[2][0], b21 = m2[2][1], b22 = m2[2][2]; dest[0][0] = a00 * b00 + a10 * b01 + a20 * b02; dest[0][1] = a01 * b00 + a11 * b01 + a21 * b02; dest[0][2] = a02 * b00 + a12 * b01 + a22 * b02; dest[0][3] = a03 * b00 + a13 * b01 + a23 * b02; dest[1][0] = a00 * b10 + a10 * b11 + a20 * b12; dest[1][1] = a01 * b10 + a11 * b11 + a21 * b12; dest[1][2] = a02 * b10 + a12 * b11 + a22 * b12; dest[1][3] = a03 * b10 + a13 * b11 + a23 * b12; dest[2][0] = a00 * b20 + a10 * b21 + a20 * b22; dest[2][1] = a01 * b20 + a11 * b21 + a21 * b22; dest[2][2] = a02 * b20 + a12 * b21 + a22 * b22; dest[2][3] = a03 * b20 + a13 * b21 + a23 * b22; dest[3][0] = a30; dest[3][1] = a31; dest[3][2] = a32; dest[3][3] = a33; #endif } /*! * @brief inverse orthonormal rotation + translation matrix (ridig-body) * * @code * X = | R T | X' = | R' -R'T | * | 0 1 | | 0 1 | * @endcode * * @param[in,out] mat matrix */ CGLM_INLINE void glm_inv_tr(mat4 mat) { #if defined(__wasm__) && defined(__wasm_simd128__) glm_inv_tr_wasm(mat); #elif defined( __SSE__ ) || defined( __SSE2__ ) glm_inv_tr_sse2(mat); #elif defined(CGLM_NEON_FP) glm_inv_tr_neon(mat); #else CGLM_ALIGN_MAT mat3 r; CGLM_ALIGN(8) vec3 t; /* rotate */ glm_mat4_pick3t(mat, r); glm_mat4_ins3(r, mat); /* translate */ glm_mat3_mulv(r, mat[3], t); glm_vec3_negate(t); glm_vec3_copy(t, mat[3]); #endif } #endif /* cglm_affine_mat_h */ cglm-0.9.6/include/cglm/affine-post.h000066400000000000000000000136011475344456400174220ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ #ifndef cglm_affine_post_h #define cglm_affine_post_h /* Functions: CGLM_INLINE void glm_translated_to(mat4 m, vec3 v, mat4 dest); CGLM_INLINE void glm_translated(mat4 m, vec3 v); CGLM_INLINE void glm_translated_x(mat4 m, float to); CGLM_INLINE void glm_translated_y(mat4 m, float to); CGLM_INLINE void glm_translated_z(mat4 m, float to); CGLM_INLINE void glm_rotated_x(mat4 m, float angle, mat4 dest); CGLM_INLINE void glm_rotated_y(mat4 m, float angle, mat4 dest); CGLM_INLINE void glm_rotated_z(mat4 m, float angle, mat4 dest); CGLM_INLINE void glm_rotated(mat4 m, float angle, vec3 axis); CGLM_INLINE void glm_rotated_at(mat4 m, vec3 pivot, float angle, vec3 axis); CGLM_INLINE void glm_spinned(mat4 m, float angle, vec3 axis); */ #include "common.h" #include "util.h" #include "vec3.h" #include "vec4.h" #include "mat4.h" #include "affine-mat.h" /*! * @brief translate existing transform matrix by v vector * and stores result in same matrix * * this is POST transform, applies to existing transform as last transform * * @param[in, out] m affine transform * @param[in] v translate vector [x, y, z] */ CGLM_INLINE void glm_translated(mat4 m, vec3 v) { glm_vec3_add(m[3], v, m[3]); } /*! * @brief translate existing transform matrix by v vector * and store result in dest * * source matrix will remain same * * this is POST transform, applies to existing transform as last transform * * @param[in] m affine transform * @param[in] v translate vector [x, y, z] * @param[out] dest translated matrix */ CGLM_INLINE void glm_translated_to(mat4 m, vec3 v, mat4 dest) { glm_mat4_copy(m, dest); glm_translated(dest, v); } /*! * @brief translate existing transform matrix by x factor * * this is POST transform, applies to existing transform as last transform * * @param[in, out] m affine transform * @param[in] x x factor */ CGLM_INLINE void glm_translated_x(mat4 m, float x) { m[3][0] += x; } /*! * @brief translate existing transform matrix by y factor * * this is POST transform, applies to existing transform as last transform * * @param[in, out] m affine transform * @param[in] y y factor */ CGLM_INLINE void glm_translated_y(mat4 m, float y) { m[3][1] += y; } /*! * @brief translate existing transform matrix by z factor * * this is POST transform, applies to existing transform as last transform * * @param[in, out] m affine transform * @param[in] z z factor */ CGLM_INLINE void glm_translated_z(mat4 m, float z) { m[3][2] += z; } /*! * @brief rotate existing transform matrix around X axis by angle * and store result in dest * * this is POST transform, applies to existing transform as last transform * * @param[in] m affine transform * @param[in] angle angle (radians) * @param[out] dest rotated matrix */ CGLM_INLINE void glm_rotated_x(mat4 m, float angle, mat4 dest) { CGLM_ALIGN_MAT mat4 t = GLM_MAT4_IDENTITY_INIT; float c, s; c = cosf(angle); s = sinf(angle); t[1][1] = c; t[1][2] = s; t[2][1] = -s; t[2][2] = c; glm_mul_rot(t, m, dest); } /*! * @brief rotate existing transform matrix around Y axis by angle * and store result in dest * * this is POST transform, applies to existing transform as last transform * * @param[in] m affine transform * @param[in] angle angle (radians) * @param[out] dest rotated matrix */ CGLM_INLINE void glm_rotated_y(mat4 m, float angle, mat4 dest) { CGLM_ALIGN_MAT mat4 t = GLM_MAT4_IDENTITY_INIT; float c, s; c = cosf(angle); s = sinf(angle); t[0][0] = c; t[0][2] = -s; t[2][0] = s; t[2][2] = c; glm_mul_rot(t, m, dest); } /*! * @brief rotate existing transform matrix around Z axis by angle * and store result in dest * * this is POST transform, applies to existing transform as last transform * * @param[in] m affine transform * @param[in] angle angle (radians) * @param[out] dest rotated matrix */ CGLM_INLINE void glm_rotated_z(mat4 m, float angle, mat4 dest) { CGLM_ALIGN_MAT mat4 t = GLM_MAT4_IDENTITY_INIT; float c, s; c = cosf(angle); s = sinf(angle); t[0][0] = c; t[0][1] = s; t[1][0] = -s; t[1][1] = c; glm_mul_rot(t, m, dest); } /*! * @brief rotate existing transform matrix around given axis by angle * * this is POST transform, applies to existing transform as last transform * * @param[in, out] m affine transform * @param[in] angle angle (radians) * @param[in] axis axis */ CGLM_INLINE void glm_rotated(mat4 m, float angle, vec3 axis) { CGLM_ALIGN_MAT mat4 rot; glm_rotate_make(rot, angle, axis); glm_mul_rot(rot, m, m); } /*! * @brief rotate existing transform * around given axis by angle at given pivot point (rotation center) * * this is POST transform, applies to existing transform as last transform * * @param[in, out] m affine transform * @param[in] pivot rotation center * @param[in] angle angle (radians) * @param[in] axis axis */ CGLM_INLINE void glm_rotated_at(mat4 m, vec3 pivot, float angle, vec3 axis) { CGLM_ALIGN(8) vec3 pivotInv; glm_vec3_negate_to(pivot, pivotInv); glm_translated(m, pivot); glm_rotated(m, angle, axis); glm_translated(m, pivotInv); } /*! * @brief rotate existing transform matrix around given axis by angle around self (doesn't affected by position) * * this is POST transform, applies to existing transform as last transform * * @param[in, out] m affine transform * @param[in] angle angle (radians) * @param[in] axis axis */ CGLM_INLINE void glm_spinned(mat4 m, float angle, vec3 axis) { CGLM_ALIGN_MAT mat4 rot; glm_rotate_atm(rot, m[3], angle, axis); glm_mat4_mul(rot, m, m); } #endif /* cglm_affine_post_h */ cglm-0.9.6/include/cglm/affine-pre.h000066400000000000000000000170301475344456400172230ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ #ifndef cglm_affine_pre_h #define cglm_affine_pre_h /* Functions: CGLM_INLINE void glm_translate_to(mat4 m, vec3 v, mat4 dest); CGLM_INLINE void glm_translate(mat4 m, vec3 v); CGLM_INLINE void glm_translate_x(mat4 m, float to); CGLM_INLINE void glm_translate_y(mat4 m, float to); CGLM_INLINE void glm_translate_z(mat4 m, float to); CGLM_INLINE void glm_rotate_x(mat4 m, float angle, mat4 dest); CGLM_INLINE void glm_rotate_y(mat4 m, float angle, mat4 dest); CGLM_INLINE void glm_rotate_z(mat4 m, float angle, mat4 dest); CGLM_INLINE void glm_rotate(mat4 m, float angle, vec3 axis); CGLM_INLINE void glm_rotate_at(mat4 m, vec3 pivot, float angle, vec3 axis); CGLM_INLINE void glm_rotate_atm(mat4 m, vec3 pivot, float angle, vec3 axis); CGLM_INLINE void glm_spin(mat4 m, float angle, vec3 axis); */ #include "common.h" #include "util.h" #include "vec3.h" #include "vec4.h" #include "mat4.h" #include "affine-mat.h" /*! * @brief translate existing transform matrix by v vector * and stores result in same matrix * * @param[in, out] m affine transform * @param[in] v translate vector [x, y, z] */ CGLM_INLINE void glm_translate(mat4 m, vec3 v) { #if defined(CGLM_SIMD) glmm_128 m0, m1, m2, m3; m0 = glmm_load(m[0]); m1 = glmm_load(m[1]); m2 = glmm_load(m[2]); m3 = glmm_load(m[3]); glmm_store(m[3], glmm_fmadd(m0, glmm_set1(v[0]), glmm_fmadd(m1, glmm_set1(v[1]), glmm_fmadd(m2, glmm_set1(v[2]), m3)))); #else glm_vec4_muladds(m[0], v[0], m[3]); glm_vec4_muladds(m[1], v[1], m[3]); glm_vec4_muladds(m[2], v[2], m[3]); #endif } /*! * @brief translate existing transform matrix by v vector * and store result in dest * * source matrix will remain same * * @param[in] m affine transform * @param[in] v translate vector [x, y, z] * @param[out] dest translated matrix */ CGLM_INLINE void glm_translate_to(mat4 m, vec3 v, mat4 dest) { glm_mat4_copy(m, dest); glm_translate(dest, v); } /*! * @brief translate existing transform matrix by x factor * * @param[in, out] m affine transform * @param[in] x x factor */ CGLM_INLINE void glm_translate_x(mat4 m, float x) { #if defined(CGLM_SIMD) glmm_store(m[3], glmm_fmadd(glmm_load(m[0]), glmm_set1(x), glmm_load(m[3]))); #else vec4 v1; glm_vec4_scale(m[0], x, v1); glm_vec4_add(v1, m[3], m[3]); #endif } /*! * @brief translate existing transform matrix by y factor * * @param[in, out] m affine transform * @param[in] y y factor */ CGLM_INLINE void glm_translate_y(mat4 m, float y) { #if defined(CGLM_SIMD) glmm_store(m[3], glmm_fmadd(glmm_load(m[1]), glmm_set1(y), glmm_load(m[3]))); #else vec4 v1; glm_vec4_scale(m[1], y, v1); glm_vec4_add(v1, m[3], m[3]); #endif } /*! * @brief translate existing transform matrix by z factor * * @param[in, out] m affine transform * @param[in] z z factor */ CGLM_INLINE void glm_translate_z(mat4 m, float z) { #if defined(CGLM_SIMD) glmm_store(m[3], glmm_fmadd(glmm_load(m[2]), glmm_set1(z), glmm_load(m[3]))); #else vec4 v1; glm_vec4_scale(m[2], z, v1); glm_vec4_add(v1, m[3], m[3]); #endif } /*! * @brief rotate existing transform matrix around X axis by angle * and store result in dest * * @param[in] m affine transform * @param[in] angle angle (radians) * @param[out] dest rotated matrix */ CGLM_INLINE void glm_rotate_x(mat4 m, float angle, mat4 dest) { CGLM_ALIGN_MAT mat4 t = GLM_MAT4_IDENTITY_INIT; float c, s; c = cosf(angle); s = sinf(angle); t[1][1] = c; t[1][2] = s; t[2][1] = -s; t[2][2] = c; glm_mul_rot(m, t, dest); } /*! * @brief rotate existing transform matrix around Y axis by angle * and store result in dest * * @param[in] m affine transform * @param[in] angle angle (radians) * @param[out] dest rotated matrix */ CGLM_INLINE void glm_rotate_y(mat4 m, float angle, mat4 dest) { CGLM_ALIGN_MAT mat4 t = GLM_MAT4_IDENTITY_INIT; float c, s; c = cosf(angle); s = sinf(angle); t[0][0] = c; t[0][2] = -s; t[2][0] = s; t[2][2] = c; glm_mul_rot(m, t, dest); } /*! * @brief rotate existing transform matrix around Z axis by angle * and store result in dest * * @param[in] m affine transform * @param[in] angle angle (radians) * @param[out] dest rotated matrix */ CGLM_INLINE void glm_rotate_z(mat4 m, float angle, mat4 dest) { CGLM_ALIGN_MAT mat4 t = GLM_MAT4_IDENTITY_INIT; float c, s; c = cosf(angle); s = sinf(angle); t[0][0] = c; t[0][1] = s; t[1][0] = -s; t[1][1] = c; glm_mul_rot(m, t, dest); } /*! * @brief rotate existing transform matrix * around given axis by angle at ORIGIN (0,0,0) * * **❗️IMPORTANT ❗️** * * If you need to rotate object around itself e.g. center of object or at * some point [of object] then `glm_rotate_at()` would be better choice to do so. * * Even if object's model transform is identity, rotation may not be around * center of object if object does not lay out at ORIGIN perfectly. * * Using `glm_rotate_at()` with center of bounding shape ( AABB, Sphere ... ) * would be an easy option to rotate around object if object is not at origin. * * One another option to rotate around itself at any point is `glm_spin()` * which is perfect if only rotating around model position is desired e.g. not * specific point on model for instance center of geometry or center of mass, * again if geometry is not perfectly centered at origin at identity transform, * rotation may not be around geometry. * * @param[in, out] m affine transform * @param[in] angle angle (radians) * @param[in] axis axis */ CGLM_INLINE void glm_rotate(mat4 m, float angle, vec3 axis) { CGLM_ALIGN_MAT mat4 rot; glm_rotate_make(rot, angle, axis); glm_mul_rot(m, rot, m); } /*! * @brief rotate existing transform * around given axis by angle at given pivot point (rotation center) * * @param[in, out] m affine transform * @param[in] pivot rotation center * @param[in] angle angle (radians) * @param[in] axis axis */ CGLM_INLINE void glm_rotate_at(mat4 m, vec3 pivot, float angle, vec3 axis) { CGLM_ALIGN(8) vec3 pivotInv; glm_vec3_negate_to(pivot, pivotInv); glm_translate(m, pivot); glm_rotate(m, angle, axis); glm_translate(m, pivotInv); } /*! * @brief creates NEW rotation matrix by angle and axis at given point * * this creates rotation matrix, it assumes you don't have a matrix * * this should work faster than glm_rotate_at because it reduces * one glm_translate. * * @param[out] m affine transform * @param[in] pivot rotation center * @param[in] angle angle (radians) * @param[in] axis axis */ CGLM_INLINE void glm_rotate_atm(mat4 m, vec3 pivot, float angle, vec3 axis) { CGLM_ALIGN(8) vec3 pivotInv; glm_vec3_negate_to(pivot, pivotInv); glm_translate_make(m, pivot); glm_rotate(m, angle, axis); glm_translate(m, pivotInv); } /*! * @brief rotate existing transform matrix * around given axis by angle around self (doesn't affected by position) * * @param[in, out] m affine transform * @param[in] angle angle (radians) * @param[in] axis axis */ CGLM_INLINE void glm_spin(mat4 m, float angle, vec3 axis) { CGLM_ALIGN_MAT mat4 rot; glm_rotate_atm(rot, m[3], angle, axis); glm_mat4_mul(m, rot, m); } #endif /* cglm_affine_pre_h */ cglm-0.9.6/include/cglm/affine.h000066400000000000000000000140361475344456400164420ustar00rootroot00000000000000/* * 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_translate_to(mat4 m, vec3 v, mat4 dest); CGLM_INLINE void glm_translate(mat4 m, vec3 v); CGLM_INLINE void glm_translate_x(mat4 m, float to); CGLM_INLINE void glm_translate_y(mat4 m, float to); CGLM_INLINE void glm_translate_z(mat4 m, float to); CGLM_INLINE void glm_translate_make(mat4 m, vec3 v); CGLM_INLINE void glm_scale_to(mat4 m, vec3 v, mat4 dest); CGLM_INLINE void glm_scale_make(mat4 m, vec3 v); CGLM_INLINE void glm_scale(mat4 m, vec3 v); CGLM_INLINE void glm_scale_uni(mat4 m, float s); CGLM_INLINE void glm_rotate_x(mat4 m, float angle, mat4 dest); CGLM_INLINE void glm_rotate_y(mat4 m, float angle, mat4 dest); CGLM_INLINE void glm_rotate_z(mat4 m, float angle, mat4 dest); CGLM_INLINE void glm_rotate_make(mat4 m, float angle, vec3 axis); CGLM_INLINE void glm_rotate(mat4 m, float angle, vec3 axis); CGLM_INLINE void glm_rotate_at(mat4 m, vec3 pivot, float angle, vec3 axis); CGLM_INLINE void glm_rotate_atm(mat4 m, vec3 pivot, float angle, vec3 axis); CGLM_INLINE void glm_spin(mat4 m, float angle, vec3 axis); CGLM_INLINE void glm_decompose_scalev(mat4 m, vec3 s); CGLM_INLINE bool glm_uniscaled(mat4 m); CGLM_INLINE void glm_decompose_rs(mat4 m, mat4 r, vec3 s); CGLM_INLINE void glm_decompose(mat4 m, vec4 t, mat4 r, vec3 s); */ #ifndef cglm_affine_h #define cglm_affine_h #include "common.h" #include "util.h" #include "vec3.h" #include "vec4.h" #include "mat4.h" #include "affine-mat.h" /*! * @brief creates NEW translate transform matrix by v vector * * @param[out] m affine transform * @param[in] v translate vector [x, y, z] */ CGLM_INLINE void glm_translate_make(mat4 m, vec3 v) { glm_mat4_identity(m); glm_vec3_copy(v, m[3]); } /*! * @brief scale existing transform matrix by v vector * and store result in dest * * @param[in] m affine transform * @param[in] v scale vector [x, y, z] * @param[out] dest scaled matrix */ CGLM_INLINE void glm_scale_to(mat4 m, vec3 v, mat4 dest) { glm_vec4_scale(m[0], v[0], dest[0]); glm_vec4_scale(m[1], v[1], dest[1]); glm_vec4_scale(m[2], v[2], dest[2]); glm_vec4_copy(m[3], dest[3]); } /*! * @brief creates NEW scale matrix by v vector * * @param[out] m affine transform * @param[in] v scale vector [x, y, z] */ CGLM_INLINE void glm_scale_make(mat4 m, vec3 v) { glm_mat4_identity(m); m[0][0] = v[0]; m[1][1] = v[1]; m[2][2] = v[2]; } /*! * @brief scales existing transform matrix by v vector * and stores result in same matrix * * @param[in, out] m affine transform * @param[in] v scale vector [x, y, z] */ CGLM_INLINE void glm_scale(mat4 m, vec3 v) { glm_scale_to(m, v, m); } /*! * @brief applies uniform scale to existing transform matrix v = [s, s, s] * and stores result in same matrix * * @param[in, out] m affine transform * @param[in] s scale factor */ CGLM_INLINE void glm_scale_uni(mat4 m, float s) { CGLM_ALIGN(8) vec3 v = { s, s, s }; glm_scale_to(m, v, m); } /*! * @brief creates NEW rotation matrix by angle and axis * * axis will be normalized so you don't need to normalize it * * @param[out] m affine transform * @param[in] angle angle (radians) * @param[in] axis axis */ CGLM_INLINE void glm_rotate_make(mat4 m, float angle, vec3 axis) { CGLM_ALIGN(8) vec3 axisn, v, vs; float c; c = cosf(angle); glm_vec3_normalize_to(axis, axisn); glm_vec3_scale(axisn, 1.0f - c, v); glm_vec3_scale(axisn, sinf(angle), vs); glm_vec3_scale(axisn, v[0], m[0]); glm_vec3_scale(axisn, v[1], m[1]); glm_vec3_scale(axisn, v[2], m[2]); m[0][0] += c; m[1][0] -= vs[2]; m[2][0] += vs[1]; m[0][1] += vs[2]; m[1][1] += c; m[2][1] -= vs[0]; m[0][2] -= vs[1]; m[1][2] += vs[0]; m[2][2] += c; m[0][3] = m[1][3] = m[2][3] = m[3][0] = m[3][1] = m[3][2] = 0.0f; m[3][3] = 1.0f; } /*! * @brief decompose scale vector * * @param[in] m affine transform * @param[out] s scale vector (Sx, Sy, Sz) */ CGLM_INLINE void glm_decompose_scalev(mat4 m, vec3 s) { s[0] = glm_vec3_norm(m[0]); s[1] = glm_vec3_norm(m[1]); s[2] = glm_vec3_norm(m[2]); } /*! * @brief returns true if matrix is uniform scaled. This is helpful for * creating normal matrix. * * @param[in] m m * * @return boolean */ CGLM_INLINE bool glm_uniscaled(mat4 m) { CGLM_ALIGN(8) vec3 s; glm_decompose_scalev(m, s); return glm_vec3_eq_all(s); } /*! * @brief decompose rotation matrix (mat4) and scale vector [Sx, Sy, Sz] * DON'T pass projected matrix here * * @param[in] m affine transform * @param[out] r rotation matrix * @param[out] s scale matrix */ CGLM_INLINE void glm_decompose_rs(mat4 m, mat4 r, vec3 s) { CGLM_ALIGN(16) vec4 t = {0.0f, 0.0f, 0.0f, 1.0f}; CGLM_ALIGN(8) vec3 v; glm_vec4_copy(m[0], r[0]); glm_vec4_copy(m[1], r[1]); glm_vec4_copy(m[2], r[2]); glm_vec4_copy(t, r[3]); s[0] = glm_vec3_norm(m[0]); s[1] = glm_vec3_norm(m[1]); s[2] = glm_vec3_norm(m[2]); glm_vec4_scale(r[0], 1.0f/s[0], r[0]); glm_vec4_scale(r[1], 1.0f/s[1], r[1]); glm_vec4_scale(r[2], 1.0f/s[2], r[2]); /* Note from Apple Open Source (assume that the matrix is orthonormal): check for a coordinate system flip. If the determinant is -1, then negate the matrix and the scaling factors. */ glm_vec3_cross(m[0], m[1], v); if (glm_vec3_dot(v, m[2]) < 0.0f) { glm_vec4_negate(r[0]); glm_vec4_negate(r[1]); glm_vec4_negate(r[2]); glm_vec3_negate(s); } } /*! * @brief decompose affine transform, TODO: extract shear factors. * DON'T pass projected matrix here * * @param[in] m affine transform * @param[out] t translation vector * @param[out] r rotation matrix (mat4) * @param[out] s scaling vector [X, Y, Z] */ CGLM_INLINE void glm_decompose(mat4 m, vec4 t, mat4 r, vec3 s) { glm_vec4_copy(m[3], t); glm_decompose_rs(m, r, s); } #include "affine-pre.h" #include "affine-post.h" #endif /* cglm_affine_h */ cglm-0.9.6/include/cglm/affine2d.h000066400000000000000000000137351475344456400166750ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ /* Functions: CGLM_INLINE void glm_translate2d(mat3 m, vec2 v) CGLM_INLINE void glm_translate2d_to(mat3 m, vec2 v, mat3 dest) CGLM_INLINE void glm_translate2d_x(mat3 m, float x) CGLM_INLINE void glm_translate2d_y(mat3 m, float y) CGLM_INLINE void glm_translate2d_make(mat3 m, vec2 v) CGLM_INLINE void glm_scale2d_to(mat3 m, vec2 v, mat3 dest) CGLM_INLINE void glm_scale2d_make(mat3 m, vec2 v) CGLM_INLINE void glm_scale2d(mat3 m, vec2 v) CGLM_INLINE void glm_scale2d_uni(mat3 m, float s) CGLM_INLINE void glm_rotate2d_make(mat3 m, float angle) CGLM_INLINE void glm_rotate2d(mat3 m, float angle) CGLM_INLINE void glm_rotate2d_to(mat3 m, float angle, mat3 dest) */ #ifndef cglm_affine2d_h #define cglm_affine2d_h #include "common.h" #include "util.h" #include "vec2.h" #include "mat3.h" /*! * @brief translate existing 2d transform matrix by v vector * and stores result in same matrix * * @param[in, out] m affine transform * @param[in] v translate vector [x, y] */ CGLM_INLINE void glm_translate2d(mat3 m, vec2 v) { m[2][0] = m[0][0] * v[0] + m[1][0] * v[1] + m[2][0]; m[2][1] = m[0][1] * v[0] + m[1][1] * v[1] + m[2][1]; m[2][2] = m[0][2] * v[0] + m[1][2] * v[1] + m[2][2]; } /*! * @brief translate existing 2d transform matrix by v vector * and store result in dest * * source matrix will remain same * * @param[in] m affine transform * @param[in] v translate vector [x, y] * @param[out] dest translated matrix */ CGLM_INLINE void glm_translate2d_to(mat3 m, vec2 v, mat3 dest) { glm_mat3_copy(m, dest); glm_translate2d(dest, v); } /*! * @brief translate existing 2d transform matrix by x factor * * @param[in, out] m affine transform * @param[in] x x factor */ CGLM_INLINE void glm_translate2d_x(mat3 m, float x) { m[2][0] = m[0][0] * x + m[2][0]; m[2][1] = m[0][1] * x + m[2][1]; m[2][2] = m[0][2] * x + m[2][2]; } /*! * @brief translate existing 2d transform matrix by y factor * * @param[in, out] m affine transform * @param[in] y y factor */ CGLM_INLINE void glm_translate2d_y(mat3 m, float y) { m[2][0] = m[1][0] * y + m[2][0]; m[2][1] = m[1][1] * y + m[2][1]; m[2][2] = m[1][2] * y + m[2][2]; } /*! * @brief creates NEW translate 2d transform matrix by v vector * * @param[out] m affine transform * @param[in] v translate vector [x, y] */ CGLM_INLINE void glm_translate2d_make(mat3 m, vec2 v) { glm_mat3_identity(m); m[2][0] = v[0]; m[2][1] = v[1]; } /*! * @brief scale existing 2d transform matrix by v vector * and store result in dest * * @param[in] m affine transform * @param[in] v scale vector [x, y] * @param[out] dest scaled matrix */ CGLM_INLINE void glm_scale2d_to(mat3 m, vec2 v, mat3 dest) { dest[0][0] = m[0][0] * v[0]; dest[0][1] = m[0][1] * v[0]; dest[0][2] = m[0][2] * v[0]; dest[1][0] = m[1][0] * v[1]; dest[1][1] = m[1][1] * v[1]; dest[1][2] = m[1][2] * v[1]; dest[2][0] = m[2][0]; dest[2][1] = m[2][1]; dest[2][2] = m[2][2]; } /*! * @brief creates NEW 2d scale matrix by v vector * * @param[out] m affine transform * @param[in] v scale vector [x, y] */ CGLM_INLINE void glm_scale2d_make(mat3 m, vec2 v) { glm_mat3_identity(m); m[0][0] = v[0]; m[1][1] = v[1]; } /*! * @brief scales existing 2d transform matrix by v vector * and stores result in same matrix * * @param[in, out] m affine transform * @param[in] v scale vector [x, y] */ CGLM_INLINE void glm_scale2d(mat3 m, vec2 v) { m[0][0] = m[0][0] * v[0]; m[0][1] = m[0][1] * v[0]; m[0][2] = m[0][2] * v[0]; m[1][0] = m[1][0] * v[1]; m[1][1] = m[1][1] * v[1]; m[1][2] = m[1][2] * v[1]; } /*! * @brief applies uniform scale to existing 2d transform matrix v = [s, s] * and stores result in same matrix * * @param[in, out] m affine transform * @param[in] s scale factor */ CGLM_INLINE void glm_scale2d_uni(mat3 m, float s) { m[0][0] = m[0][0] * s; m[0][1] = m[0][1] * s; m[0][2] = m[0][2] * s; m[1][0] = m[1][0] * s; m[1][1] = m[1][1] * s; m[1][2] = m[1][2] * s; } /*! * @brief creates NEW rotation matrix by angle around Z axis * * @param[out] m affine transform * @param[in] angle angle (radians) */ CGLM_INLINE void glm_rotate2d_make(mat3 m, float angle) { float c, s; s = sinf(angle); c = cosf(angle); m[0][0] = c; m[0][1] = s; m[0][2] = 0; m[1][0] = -s; m[1][1] = c; m[1][2] = 0; m[2][0] = 0.0f; m[2][1] = 0.0f; m[2][2] = 1.0f; } /*! * @brief rotate existing 2d transform matrix around Z axis by angle * and store result in same matrix * * @param[in, out] m affine transform * @param[in] angle angle (radians) */ CGLM_INLINE void glm_rotate2d(mat3 m, float angle) { float m00 = m[0][0], m10 = m[1][0], m01 = m[0][1], m11 = m[1][1], m02 = m[0][2], m12 = m[1][2]; float c, s; s = sinf(angle); c = cosf(angle); m[0][0] = m00 * c + m10 * s; m[0][1] = m01 * c + m11 * s; m[0][2] = m02 * c + m12 * s; m[1][0] = m00 * -s + m10 * c; m[1][1] = m01 * -s + m11 * c; m[1][2] = m02 * -s + m12 * c; } /*! * @brief rotate existing 2d transform matrix around Z axis by angle * and store result in dest * * @param[in] m affine transform * @param[in] angle angle (radians) * @param[out] dest destination */ CGLM_INLINE void glm_rotate2d_to(mat3 m, float angle, mat3 dest) { float m00 = m[0][0], m10 = m[1][0], m01 = m[0][1], m11 = m[1][1], m02 = m[0][2], m12 = m[1][2]; float c, s; s = sinf(angle); c = cosf(angle); dest[0][0] = m00 * c + m10 * s; dest[0][1] = m01 * c + m11 * s; dest[0][2] = m02 * c + m12 * s; dest[1][0] = m00 * -s + m10 * c; dest[1][1] = m01 * -s + m11 * c; dest[1][2] = m02 * -s + m12 * c; dest[2][0] = m[2][0]; dest[2][1] = m[2][1]; dest[2][2] = m[2][2]; } #endif /* cglm_affine2d_h */ cglm-0.9.6/include/cglm/applesimd.h000066400000000000000000000040261475344456400171660ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ #ifndef cglm_applesimd_h #define cglm_applesimd_h #if defined(__APPLE__) \ && defined(SIMD_COMPILER_HAS_REQUIRED_FEATURES) \ && defined(SIMD_BASE) \ && defined(SIMD_TYPES) \ && defined(SIMD_VECTOR_TYPES) #include "common.h" /*! * @brief converts mat4 to Apple's simd type simd_float4x4 * @return simd_float4x4 */ CGLM_INLINE simd_float4x4 glm_mat4_applesimd(mat4 m) { simd_float4x4 t; t.columns[0][0] = m[0][0]; t.columns[0][1] = m[0][1]; t.columns[0][2] = m[0][2]; t.columns[0][3] = m[0][3]; t.columns[1][0] = m[1][0]; t.columns[1][1] = m[1][1]; t.columns[1][2] = m[1][2]; t.columns[1][3] = m[1][3]; t.columns[2][0] = m[2][0]; t.columns[2][1] = m[2][1]; t.columns[2][2] = m[2][2]; t.columns[2][3] = m[2][3]; t.columns[3][0] = m[3][0]; t.columns[3][1] = m[3][1]; t.columns[3][2] = m[3][2]; t.columns[3][3] = m[3][3]; return t; } /*! * @brief converts mat3 to Apple's simd type simd_float3x3 * @return simd_float3x3 */ CGLM_INLINE simd_float3x3 glm_mat3_applesimd(mat3 m) { simd_float3x3 t; t.columns[0][0] = m[0][0]; t.columns[0][1] = m[0][1]; t.columns[0][2] = m[0][2]; t.columns[1][0] = m[1][0]; t.columns[1][1] = m[1][1]; t.columns[1][2] = m[1][2]; t.columns[2][0] = m[2][0]; t.columns[2][1] = m[2][1]; t.columns[2][2] = m[2][2]; return t; } /*! * @brief converts vec4 to Apple's simd type simd_float4 * @return simd_float4 */ CGLM_INLINE simd_float4 glm_vec4_applesimd(vec4 v) { return (simd_float4){v[0], v[1], v[2], v[3]}; } /*! * @brief converts vec3 to Apple's simd type simd_float3 * @return v */ CGLM_INLINE simd_float3 glm_vec3_applesimd(vec3 v) { return (simd_float3){v[0], v[1], v[2]}; } #endif #endif /* cglm_applesimd_h */ cglm-0.9.6/include/cglm/bezier.h000066400000000000000000000074121475344456400164720ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ #ifndef cglm_bezier_h #define cglm_bezier_h #include "common.h" #define GLM_BEZIER_MAT_INIT {{-1.0f, 3.0f, -3.0f, 1.0f}, \ { 3.0f, -6.0f, 3.0f, 0.0f}, \ {-3.0f, 3.0f, 0.0f, 0.0f}, \ { 1.0f, 0.0f, 0.0f, 0.0f}} #define GLM_HERMITE_MAT_INIT {{ 2.0f, -3.0f, 0.0f, 1.0f}, \ {-2.0f, 3.0f, 0.0f, 0.0f}, \ { 1.0f, -2.0f, 1.0f, 0.0f}, \ { 1.0f, -1.0f, 0.0f, 0.0f}} /* for C only */ #define GLM_BEZIER_MAT ((mat4)GLM_BEZIER_MAT_INIT) #define GLM_HERMITE_MAT ((mat4)GLM_HERMITE_MAT_INIT) #define CGLM_DECASTEL_EPS 1e-9f #define CGLM_DECASTEL_MAX 1000 #define CGLM_DECASTEL_SMALL 1e-20f /*! * @brief cubic bezier interpolation * * Formula: * B(s) = P0*(1-s)^3 + 3*C0*s*(1-s)^2 + 3*C1*s^2*(1-s) + P1*s^3 * * similar result using matrix: * B(s) = glm_smc(t, GLM_BEZIER_MAT, (vec4){p0, c0, c1, p1}) * * glm_eq(glm_smc(...), glm_bezier(...)) should return TRUE * * @param[in] s parameter between 0 and 1 * @param[in] p0 begin point * @param[in] c0 control point 1 * @param[in] c1 control point 2 * @param[in] p1 end point * * @return B(s) */ CGLM_INLINE float glm_bezier(float s, float p0, float c0, float c1, float p1) { float x, xx, ss, xs3, a; x = 1.0f - s; xx = x * x; ss = s * s; xs3 = (s - ss) * 3.0f; a = p0 * xx + c0 * xs3; return a + s * (c1 * xs3 + p1 * ss - a); } /*! * @brief cubic hermite interpolation * * Formula: * H(s) = P0*(2*s^3 - 3*s^2 + 1) + T0*(s^3 - 2*s^2 + s) * + P1*(-2*s^3 + 3*s^2) + T1*(s^3 - s^2) * * similar result using matrix: * H(s) = glm_smc(t, GLM_HERMITE_MAT, (vec4){p0, p1, c0, c1}) * * glm_eq(glm_smc(...), glm_hermite(...)) should return TRUE * * @param[in] s parameter between 0 and 1 * @param[in] p0 begin point * @param[in] t0 tangent 1 * @param[in] t1 tangent 2 * @param[in] p1 end point * * @return H(s) */ CGLM_INLINE float glm_hermite(float s, float p0, float t0, float t1, float p1) { float ss, d, a, b, c, e, f; ss = s * s; a = ss + ss; c = a + ss; b = a * s; d = s * ss; f = d - ss; e = b - c; return p0 * (e + 1.0f) + t0 * (f - ss + s) + t1 * f - p1 * e; } /*! * @brief iterative way to solve cubic equation * * @param[in] prm parameter between 0 and 1 * @param[in] p0 begin point * @param[in] c0 control point 1 * @param[in] c1 control point 2 * @param[in] p1 end point * * @return parameter to use in cubic equation */ CGLM_INLINE float glm_decasteljau(float prm, float p0, float c0, float c1, float p1) { float u, v, a, b, c, d, e, f; int i; if (prm - p0 < CGLM_DECASTEL_SMALL) return 0.0f; if (p1 - prm < CGLM_DECASTEL_SMALL) return 1.0f; u = 0.0f; v = 1.0f; for (i = 0; i < CGLM_DECASTEL_MAX; i++) { /* de Casteljau Subdivision */ a = (p0 + c0) * 0.5f; b = (c0 + c1) * 0.5f; c = (c1 + p1) * 0.5f; d = (a + b) * 0.5f; e = (b + c) * 0.5f; f = (d + e) * 0.5f; /* this one is on the curve! */ /* The curve point is close enough to our wanted t */ if (fabsf(f - prm) < CGLM_DECASTEL_EPS) return glm_clamp_zo((u + v) * 0.5f); /* dichotomy */ if (f < prm) { p0 = f; c0 = e; c1 = c; u = (u + v) * 0.5f; } else { c0 = a; c1 = d; p1 = f; v = (u + v) * 0.5f; } } return glm_clamp_zo((u + v) * 0.5f); } #endif /* cglm_bezier_h */ cglm-0.9.6/include/cglm/box.h000066400000000000000000000155601475344456400160050ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ #ifndef cglm_box_h #define cglm_box_h #include "common.h" #include "vec3.h" #include "vec4.h" #include "util.h" /*! * @brief apply transform to Axis-Aligned Bounding Box * * @param[in] box bounding box * @param[in] m transform matrix * @param[out] dest transformed bounding box */ CGLM_INLINE void glm_aabb_transform(vec3 box[2], mat4 m, vec3 dest[2]) { vec3 v[2], xa, xb, ya, yb, za, zb; glm_vec3_scale(m[0], box[0][0], xa); glm_vec3_scale(m[0], box[1][0], xb); glm_vec3_scale(m[1], box[0][1], ya); glm_vec3_scale(m[1], box[1][1], yb); glm_vec3_scale(m[2], box[0][2], za); glm_vec3_scale(m[2], box[1][2], zb); /* translation + min(xa, xb) + min(ya, yb) + min(za, zb) */ glm_vec3(m[3], v[0]); glm_vec3_minadd(xa, xb, v[0]); glm_vec3_minadd(ya, yb, v[0]); glm_vec3_minadd(za, zb, v[0]); /* translation + max(xa, xb) + max(ya, yb) + max(za, zb) */ glm_vec3(m[3], v[1]); glm_vec3_maxadd(xa, xb, v[1]); glm_vec3_maxadd(ya, yb, v[1]); glm_vec3_maxadd(za, zb, v[1]); glm_vec3_copy(v[0], dest[0]); glm_vec3_copy(v[1], dest[1]); } /*! * @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] box1 bounding box 1 * @param[in] box2 bounding box 2 * @param[out] dest merged bounding box */ CGLM_INLINE void glm_aabb_merge(vec3 box1[2], vec3 box2[2], vec3 dest[2]) { dest[0][0] = glm_min(box1[0][0], box2[0][0]); dest[0][1] = glm_min(box1[0][1], box2[0][1]); dest[0][2] = glm_min(box1[0][2], box2[0][2]); dest[1][0] = glm_max(box1[1][0], box2[1][0]); dest[1][1] = glm_max(box1[1][1], box2[1][1]); dest[1][2] = glm_max(box1[1][2], box2[1][2]); } /*! * @brief crops a bounding box with another one. * * this could be useful for getting a bbox which fits with view frustum and * object bounding boxes. In this case you crop view frustum box with objects * box * * @param[in] box bounding box 1 * @param[in] cropBox crop box * @param[out] dest cropped bounding box */ CGLM_INLINE void glm_aabb_crop(vec3 box[2], vec3 cropBox[2], vec3 dest[2]) { dest[0][0] = glm_max(box[0][0], cropBox[0][0]); dest[0][1] = glm_max(box[0][1], cropBox[0][1]); dest[0][2] = glm_max(box[0][2], cropBox[0][2]); dest[1][0] = glm_min(box[1][0], cropBox[1][0]); dest[1][1] = glm_min(box[1][1], cropBox[1][1]); dest[1][2] = glm_min(box[1][2], cropBox[1][2]); } /*! * @brief crops a bounding box with another one. * * this could be useful for getting a bbox which fits with view frustum and * object bounding boxes. In this case you crop view frustum box with objects * box * * @param[in] box bounding box * @param[in] cropBox crop box * @param[in] clampBox minimum box * @param[out] dest cropped bounding box */ CGLM_INLINE void glm_aabb_crop_until(vec3 box[2], vec3 cropBox[2], vec3 clampBox[2], vec3 dest[2]) { glm_aabb_crop(box, cropBox, dest); glm_aabb_merge(clampBox, dest, dest); } /*! * @brief check if AABB intersects with frustum planes * * this could be useful for frustum culling using AABB. * * OPTIMIZATION HINT: * if planes order is similar to LEFT, RIGHT, BOTTOM, TOP, NEAR, FAR * then this method should run even faster because it would only use two * planes if object is not inside the two planes * fortunately cglm extracts planes as this order! just pass what you got! * * @param[in] box bounding box * @param[in] planes frustum planes */ CGLM_INLINE bool glm_aabb_frustum(vec3 box[2], vec4 planes[6]) { float *p, dp; int i; for (i = 0; i < 6; i++) { p = planes[i]; dp = p[0] * box[p[0] > 0.0f][0] + p[1] * box[p[1] > 0.0f][1] + p[2] * box[p[2] > 0.0f][2]; if (dp < -p[3]) return false; } return true; } /*! * @brief invalidate AABB min and max values * * @param[in, out] box bounding box */ CGLM_INLINE void glm_aabb_invalidate(vec3 box[2]) { glm_vec3_broadcast(FLT_MAX, box[0]); glm_vec3_broadcast(-FLT_MAX, box[1]); } /*! * @brief check if AABB is valid or not * * @param[in] box bounding box */ CGLM_INLINE bool glm_aabb_isvalid(vec3 box[2]) { return glm_vec3_max(box[0]) != FLT_MAX && glm_vec3_min(box[1]) != -FLT_MAX; } /*! * @brief distance between of min and max * * @param[in] box bounding box */ CGLM_INLINE float glm_aabb_size(vec3 box[2]) { return glm_vec3_distance(box[0], box[1]); } /*! * @brief radius of sphere which surrounds AABB * * @param[in] box bounding box */ CGLM_INLINE float glm_aabb_radius(vec3 box[2]) { return glm_aabb_size(box) * 0.5f; } /*! * @brief computes center point of AABB * * @param[in] box bounding box * @param[out] dest center of bounding box */ CGLM_INLINE void glm_aabb_center(vec3 box[2], vec3 dest) { glm_vec3_center(box[0], box[1], dest); } /*! * @brief check if two AABB intersects * * @param[in] box bounding box * @param[in] other other bounding box */ CGLM_INLINE bool glm_aabb_aabb(vec3 box[2], vec3 other[2]) { return (box[0][0] <= other[1][0] && box[1][0] >= other[0][0]) && (box[0][1] <= other[1][1] && box[1][1] >= other[0][1]) && (box[0][2] <= other[1][2] && box[1][2] >= other[0][2]); } /*! * @brief check if AABB intersects with sphere * * https://github.com/erich666/GraphicsGems/blob/master/gems/BoxSphere.c * Solid Box - Solid Sphere test. * * Sphere Representation in cglm: [center.x, center.y, center.z, radii] * * @param[in] box solid bounding box * @param[in] s solid sphere */ CGLM_INLINE bool glm_aabb_sphere(vec3 box[2], vec4 s) { float dmin; int a, b, c; a = (s[0] < box[0][0]) + (s[0] > box[1][0]); b = (s[1] < box[0][1]) + (s[1] > box[1][1]); c = (s[2] < box[0][2]) + (s[2] > box[1][2]); dmin = glm_pow2((s[0] - box[!(a - 1)][0]) * (a != 0)) + glm_pow2((s[1] - box[!(b - 1)][1]) * (b != 0)) + glm_pow2((s[2] - box[!(c - 1)][2]) * (c != 0)); return dmin <= glm_pow2(s[3]); } /*! * @brief check if point is inside of AABB * * @param[in] box bounding box * @param[in] point point */ CGLM_INLINE bool glm_aabb_point(vec3 box[2], vec3 point) { return (point[0] >= box[0][0] && point[0] <= box[1][0]) && (point[1] >= box[0][1] && point[1] <= box[1][1]) && (point[2] >= box[0][2] && point[2] <= box[1][2]); } /*! * @brief check if AABB contains other AABB * * @param[in] box bounding box * @param[in] other other bounding box */ CGLM_INLINE bool glm_aabb_contains(vec3 box[2], vec3 other[2]) { return (box[0][0] <= other[0][0] && box[1][0] >= other[1][0]) && (box[0][1] <= other[0][1] && box[1][1] >= other[1][1]) && (box[0][2] <= other[0][2] && box[1][2] >= other[1][2]); } #endif /* cglm_box_h */ cglm-0.9.6/include/cglm/call.h000066400000000000000000000020571475344456400161250ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ #ifndef cglm_call_h #define cglm_call_h #ifdef __cplusplus extern "C" { #endif #include "cglm.h" #include "call/vec2.h" #include "call/vec3.h" #include "call/vec4.h" #include "call/ivec2.h" #include "call/ivec3.h" #include "call/ivec4.h" #include "call/mat2.h" #include "call/mat2x3.h" #include "call/mat2x4.h" #include "call/mat3.h" #include "call/mat3x2.h" #include "call/mat3x4.h" #include "call/mat4.h" #include "call/mat4x2.h" #include "call/mat4x3.h" #include "call/affine.h" #include "call/cam.h" #include "call/quat.h" #include "call/euler.h" #include "call/plane.h" #include "call/noise.h" #include "call/frustum.h" #include "call/aabb2d.h" #include "call/box.h" #include "call/io.h" #include "call/project.h" #include "call/sphere.h" #include "call/ease.h" #include "call/curve.h" #include "call/bezier.h" #include "call/ray.h" #include "call/affine2d.h" #ifdef __cplusplus } #endif #endif /* cglm_call_h */ cglm-0.9.6/include/cglm/call/000077500000000000000000000000001475344456400157505ustar00rootroot00000000000000cglm-0.9.6/include/cglm/call/aabb2d.h000066400000000000000000000027551475344456400172450ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ #ifndef cglmc_aabb2d_h #define cglmc_aabb2d_h #ifdef __cplusplus extern "C" { #endif #include "../cglm.h" /* DEPRECATED! use _diag */ #define glmc_aabb2d_size(aabb) glmc_aabb2d_diag(aabb) CGLM_EXPORT void glmc_aabb2d_zero(vec2 aabb[2]); CGLM_EXPORT void glmc_aabb2d_copy(vec2 aabb[2], vec2 dest[2]); CGLM_EXPORT void glmc_aabb2d_transform(vec2 aabb[2], mat3 m, vec2 dest[2]); CGLM_EXPORT void glmc_aabb2d_merge(vec2 aabb1[2], vec2 aabb2[2], vec2 dest[2]); CGLM_EXPORT void glmc_aabb2d_crop(vec2 aabb[2], vec2 cropAabb[2], vec2 dest[2]); CGLM_EXPORT void glmc_aabb2d_crop_until(vec2 aabb[2], vec2 cropAabb[2], vec2 clampAabb[2], vec2 dest[2]); CGLM_EXPORT void glmc_aabb2d_invalidate(vec2 aabb[2]); CGLM_EXPORT bool glmc_aabb2d_isvalid(vec2 aabb[2]); CGLM_EXPORT float glmc_aabb2d_diag(vec2 aabb[2]); CGLM_EXPORT void glmc_aabb2d_sizev(vec2 aabb[2], vec2 dest); CGLM_EXPORT float glmc_aabb2d_radius(vec2 aabb[2]); CGLM_EXPORT void glmc_aabb2d_center(vec2 aabb[2], vec2 dest); CGLM_EXPORT bool glmc_aabb2d_aabb(vec2 aabb[2], vec2 other[2]); CGLM_EXPORT bool glmc_aabb2d_point(vec2 aabb[2], vec2 point); CGLM_EXPORT bool glmc_aabb2d_contains(vec2 aabb[2], vec2 other[2]); CGLM_EXPORT bool glmc_aabb2d_circle(vec2 aabb[2], vec3 s); #ifdef __cplusplus } #endif #endif /* cglmc_aabb2d_h */ cglm-0.9.6/include/cglm/call/affine.h000066400000000000000000000047011475344456400173530ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ #ifndef cglmc_affine_h #define cglmc_affine_h #ifdef __cplusplus extern "C" { #endif #include "../cglm.h" CGLM_EXPORT void glmc_translate_make(mat4 m, vec3 v); CGLM_EXPORT void glmc_translate_to(mat4 m, vec3 v, mat4 dest); CGLM_EXPORT void glmc_translate(mat4 m, vec3 v); CGLM_EXPORT void glmc_translate_x(mat4 m, float to); CGLM_EXPORT void glmc_translate_y(mat4 m, float to); CGLM_EXPORT void glmc_translate_z(mat4 m, float to); CGLM_EXPORT void glmc_scale_make(mat4 m, vec3 v); CGLM_EXPORT void glmc_scale_to(mat4 m, vec3 v, mat4 dest); CGLM_EXPORT void glmc_scale(mat4 m, vec3 v); CGLM_EXPORT void glmc_scale_uni(mat4 m, float s); CGLM_EXPORT void glmc_rotate_x(mat4 m, float rad, mat4 dest); CGLM_EXPORT void glmc_rotate_y(mat4 m, float rad, mat4 dest); CGLM_EXPORT void glmc_rotate_z(mat4 m, float rad, mat4 dest); CGLM_EXPORT void glmc_rotate_make(mat4 m, float angle, vec3 axis); CGLM_EXPORT void glmc_rotate(mat4 m, float angle, vec3 axis); CGLM_EXPORT void glmc_rotate_at(mat4 m, vec3 pivot, float angle, vec3 axis); CGLM_EXPORT void glmc_rotate_atm(mat4 m, vec3 pivot, float angle, vec3 axis); CGLM_EXPORT void glmc_spin(mat4 m, float angle, vec3 axis); CGLM_EXPORT void glmc_decompose_scalev(mat4 m, vec3 s); CGLM_EXPORT bool glmc_uniscaled(mat4 m); CGLM_EXPORT void glmc_decompose_rs(mat4 m, mat4 r, vec3 s); CGLM_EXPORT void glmc_decompose(mat4 m, vec4 t, mat4 r, vec3 s); /* affine-post */ CGLM_EXPORT void glmc_translated(mat4 m, vec3 v); CGLM_EXPORT void glmc_translated_to(mat4 m, vec3 v, mat4 dest); CGLM_EXPORT void glmc_translated_x(mat4 m, float x); CGLM_EXPORT void glmc_translated_y(mat4 m, float y); CGLM_EXPORT void glmc_translated_z(mat4 m, float z); CGLM_EXPORT void glmc_rotated_x(mat4 m, float angle, mat4 dest); CGLM_EXPORT void glmc_rotated_y(mat4 m, float angle, mat4 dest); CGLM_EXPORT void glmc_rotated_z(mat4 m, float angle, mat4 dest); CGLM_EXPORT void glmc_rotated(mat4 m, float angle, vec3 axis); CGLM_EXPORT void glmc_rotated_at(mat4 m, vec3 pivot, float angle, vec3 axis); CGLM_EXPORT void glmc_spinned(mat4 m, float angle, vec3 axis); /* affine-mat */ CGLM_EXPORT void glmc_mul(mat4 m1, mat4 m2, mat4 dest); CGLM_EXPORT void glmc_mul_rot(mat4 m1, mat4 m2, mat4 dest); CGLM_EXPORT void glmc_inv_tr(mat4 mat); #ifdef __cplusplus } #endif #endif /* cglmc_affine_h */ cglm-0.9.6/include/cglm/call/affine2d.h000066400000000000000000000017551475344456400176070ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ #ifndef cglmc_affine2d_h #define cglmc_affine2d_h #ifdef __cplusplus extern "C" { #endif #include "../cglm.h" CGLM_EXPORT void glmc_translate2d_make(mat3 m, vec2 v); CGLM_EXPORT void glmc_translate2d_to(mat3 m, vec2 v, mat3 dest); CGLM_EXPORT void glmc_translate2d(mat3 m, vec2 v); CGLM_EXPORT void glmc_translate2d_x(mat3 m, float to); CGLM_EXPORT void glmc_translate2d_y(mat3 m, float to); CGLM_EXPORT void glmc_scale2d_to(mat3 m, vec2 v, mat3 dest); CGLM_EXPORT void glmc_scale2d_make(mat3 m, vec2 v); CGLM_EXPORT void glmc_scale2d(mat3 m, vec2 v); CGLM_EXPORT void glmc_scale2d_uni(mat3 m, float s); CGLM_EXPORT void glmc_rotate2d_make(mat3 m, float angle); CGLM_EXPORT void glmc_rotate2d(mat3 m, float angle); CGLM_EXPORT void glmc_rotate2d_to(mat3 m, float angle, mat3 dest); #ifdef __cplusplus } #endif #endif /* cglmc_affine2d_h */ cglm-0.9.6/include/cglm/call/bezier.h000066400000000000000000000010661475344456400174040ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ #ifndef cglmc_bezier_h #define cglmc_bezier_h #ifdef __cplusplus extern "C" { #endif #include "../cglm.h" CGLM_EXPORT float glmc_bezier(float s, float p0, float c0, float c1, float p1); CGLM_EXPORT float glmc_hermite(float s, float p0, float t0, float t1, float p1); CGLM_EXPORT float glmc_decasteljau(float prm, float p0, float c0, float c1, float p1); #ifdef __cplusplus } #endif #endif /* cglmc_bezier_h */ cglm-0.9.6/include/cglm/call/box.h000066400000000000000000000023701475344456400167130ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ #ifndef cglmc_box_h #define cglmc_box_h #ifdef __cplusplus extern "C" { #endif #include "../cglm.h" CGLM_EXPORT void glmc_aabb_transform(vec3 box[2], mat4 m, vec3 dest[2]); CGLM_EXPORT void glmc_aabb_merge(vec3 box1[2], vec3 box2[2], vec3 dest[2]); CGLM_EXPORT void glmc_aabb_crop(vec3 box[2], vec3 cropBox[2], vec3 dest[2]); CGLM_EXPORT void glmc_aabb_crop_until(vec3 box[2], vec3 cropBox[2], vec3 clampBox[2], vec3 dest[2]); CGLM_EXPORT bool glmc_aabb_frustum(vec3 box[2], vec4 planes[6]); CGLM_EXPORT void glmc_aabb_invalidate(vec3 box[2]); CGLM_EXPORT bool glmc_aabb_isvalid(vec3 box[2]); CGLM_EXPORT float glmc_aabb_size(vec3 box[2]); CGLM_EXPORT float glmc_aabb_radius(vec3 box[2]); CGLM_EXPORT void glmc_aabb_center(vec3 box[2], vec3 dest); CGLM_EXPORT bool glmc_aabb_aabb(vec3 box[2], vec3 other[2]); CGLM_EXPORT bool glmc_aabb_point(vec3 box[2], vec3 point); CGLM_EXPORT bool glmc_aabb_contains(vec3 box[2], vec3 other[2]); CGLM_EXPORT bool glmc_aabb_sphere(vec3 box[2], vec4 s); #ifdef __cplusplus } #endif #endif /* cglmc_box_h */ cglm-0.9.6/include/cglm/call/cam.h000066400000000000000000000050501475344456400166610ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ #ifndef cglmc_cam_h #define cglmc_cam_h #ifdef __cplusplus extern "C" { #endif #include "../cglm.h" CGLM_EXPORT void glmc_frustum(float left, float right, float bottom, float top, float nearZ, float farZ, mat4 dest); CGLM_EXPORT void glmc_ortho(float left, float right, float bottom, float top, float nearZ, float farZ, mat4 dest); CGLM_EXPORT void glmc_ortho_aabb(vec3 box[2], mat4 dest); CGLM_EXPORT void glmc_ortho_aabb_p(vec3 box[2], float padding, mat4 dest); CGLM_EXPORT void glmc_ortho_aabb_pz(vec3 box[2], float padding, mat4 dest); CGLM_EXPORT void glmc_ortho_default(float aspect, mat4 dest); CGLM_EXPORT void glmc_ortho_default_s(float aspect, float size, mat4 dest); CGLM_EXPORT void glmc_perspective(float fovy, float aspect, float nearZ, float farZ, mat4 dest); CGLM_EXPORT void glmc_persp_move_far(mat4 proj, float deltaFar); CGLM_EXPORT void glmc_perspective_default(float aspect, mat4 dest); CGLM_EXPORT void glmc_perspective_resize(float aspect, mat4 proj); CGLM_EXPORT void glmc_lookat(vec3 eye, vec3 center, vec3 up, mat4 dest); CGLM_EXPORT void glmc_look(vec3 eye, vec3 dir, vec3 up, mat4 dest); CGLM_EXPORT void glmc_look_anyup(vec3 eye, vec3 dir, mat4 dest); CGLM_EXPORT void glmc_persp_decomp(mat4 proj, float * __restrict nearZ, float * __restrict farZ, float * __restrict top, float * __restrict bottom, float * __restrict left, float * __restrict right); CGLM_EXPORT void glmc_persp_decompv(mat4 proj, float dest[6]); CGLM_EXPORT void glmc_persp_decomp_x(mat4 proj, float * __restrict left, float * __restrict right); CGLM_EXPORT void glmc_persp_decomp_y(mat4 proj, float * __restrict top, float * __restrict bottom); CGLM_EXPORT void glmc_persp_decomp_z(mat4 proj, float * __restrict nearZ, float * __restrict farZ); CGLM_EXPORT void glmc_persp_decomp_far(mat4 proj, float * __restrict farZ); CGLM_EXPORT void glmc_persp_decomp_near(mat4 proj, float * __restrict nearZ); CGLM_EXPORT float glmc_persp_fovy(mat4 proj); CGLM_EXPORT float glmc_persp_aspect(mat4 proj); CGLM_EXPORT void glmc_persp_sizes(mat4 proj, float fovy, vec4 dest); #ifdef __cplusplus } #endif #endif /* cglmc_cam_h */ cglm-0.9.6/include/cglm/call/clipspace/000077500000000000000000000000001475344456400177135ustar00rootroot00000000000000cglm-0.9.6/include/cglm/call/clipspace/ortho_lh_no.h000066400000000000000000000015771475344456400224100ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ #ifndef cglmc_ortho_lh_no_h #define cglmc_ortho_lh_no_h #ifdef __cplusplus extern "C" { #endif #include "../../cglm.h" CGLM_EXPORT void glmc_ortho_lh_no(float left, float right, float bottom, float top, float nearZ, float farZ, mat4 dest); CGLM_EXPORT void glmc_ortho_aabb_lh_no(vec3 box[2], mat4 dest); CGLM_EXPORT void glmc_ortho_aabb_p_lh_no(vec3 box[2], float padding, mat4 dest); CGLM_EXPORT void glmc_ortho_aabb_pz_lh_no(vec3 box[2], float padding, mat4 dest); CGLM_EXPORT void glmc_ortho_default_lh_no(float aspect, mat4 dest); CGLM_EXPORT void glmc_ortho_default_s_lh_no(float aspect, float size, mat4 dest); #ifdef __cplusplus } #endif #endif /* cglmc_ortho_lh_no_h */ cglm-0.9.6/include/cglm/call/clipspace/ortho_lh_zo.h000066400000000000000000000015771475344456400224240ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ #ifndef cglmc_ortho_lh_zo_h #define cglmc_ortho_lh_zo_h #ifdef __cplusplus extern "C" { #endif #include "../../cglm.h" CGLM_EXPORT void glmc_ortho_lh_zo(float left, float right, float bottom, float top, float nearZ, float farZ, mat4 dest); CGLM_EXPORT void glmc_ortho_aabb_lh_zo(vec3 box[2], mat4 dest); CGLM_EXPORT void glmc_ortho_aabb_p_lh_zo(vec3 box[2], float padding, mat4 dest); CGLM_EXPORT void glmc_ortho_aabb_pz_lh_zo(vec3 box[2], float padding, mat4 dest); CGLM_EXPORT void glmc_ortho_default_lh_zo(float aspect, mat4 dest); CGLM_EXPORT void glmc_ortho_default_s_lh_zo(float aspect, float size, mat4 dest); #ifdef __cplusplus } #endif #endif /* cglmc_ortho_lh_zo_h */ cglm-0.9.6/include/cglm/call/clipspace/ortho_rh_no.h000066400000000000000000000015771475344456400224160ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ #ifndef cglmc_ortho_rh_no_h #define cglmc_ortho_rh_no_h #ifdef __cplusplus extern "C" { #endif #include "../../cglm.h" CGLM_EXPORT void glmc_ortho_rh_no(float left, float right, float bottom, float top, float nearZ, float farZ, mat4 dest); CGLM_EXPORT void glmc_ortho_aabb_rh_no(vec3 box[2], mat4 dest); CGLM_EXPORT void glmc_ortho_aabb_p_rh_no(vec3 box[2], float padding, mat4 dest); CGLM_EXPORT void glmc_ortho_aabb_pz_rh_no(vec3 box[2], float padding, mat4 dest); CGLM_EXPORT void glmc_ortho_default_rh_no(float aspect, mat4 dest); CGLM_EXPORT void glmc_ortho_default_s_rh_no(float aspect, float size, mat4 dest); #ifdef __cplusplus } #endif #endif /* cglmc_ortho_rh_no_h */ cglm-0.9.6/include/cglm/call/clipspace/ortho_rh_zo.h000066400000000000000000000015771475344456400224320ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ #ifndef cglmc_ortho_rh_zo_h #define cglmc_ortho_rh_zo_h #ifdef __cplusplus extern "C" { #endif #include "../../cglm.h" CGLM_EXPORT void glmc_ortho_rh_zo(float left, float right, float bottom, float top, float nearZ, float farZ, mat4 dest); CGLM_EXPORT void glmc_ortho_aabb_rh_zo(vec3 box[2], mat4 dest); CGLM_EXPORT void glmc_ortho_aabb_p_rh_zo(vec3 box[2], float padding, mat4 dest); CGLM_EXPORT void glmc_ortho_aabb_pz_rh_zo(vec3 box[2], float padding, mat4 dest); CGLM_EXPORT void glmc_ortho_default_rh_zo(float aspect, mat4 dest); CGLM_EXPORT void glmc_ortho_default_s_rh_zo(float aspect, float size, mat4 dest); #ifdef __cplusplus } #endif #endif /* cglmc_ortho_rh_zo_h */ cglm-0.9.6/include/cglm/call/clipspace/persp_lh_no.h000066400000000000000000000036661475344456400224070ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ #ifndef cglmc_persp_lh_no_h #define cglmc_persp_lh_no_h #ifdef __cplusplus extern "C" { #endif #include "../../cglm.h" CGLM_EXPORT void glmc_frustum_lh_no(float left, float right, float bottom, float top, float nearZ, float farZ, mat4 dest); CGLM_EXPORT void glmc_perspective_lh_no(float fovy, float aspect, float nearVal, float farVal, mat4 dest); CGLM_EXPORT void glmc_persp_move_far_lh_no(mat4 proj, float deltaFar); CGLM_EXPORT void glmc_persp_decomp_lh_no(mat4 proj, float * __restrict nearZ, float * __restrict farZ, float * __restrict top, float * __restrict bottom, float * __restrict left, float * __restrict right); CGLM_EXPORT void glmc_persp_decompv_lh_no(mat4 proj, float dest[6]); CGLM_EXPORT void glmc_persp_decomp_x_lh_no(mat4 proj, float * __restrict left, float * __restrict right); CGLM_EXPORT void glmc_persp_decomp_y_lh_no(mat4 proj, float * __restrict top, float * __restrict bottom); CGLM_EXPORT void glmc_persp_decomp_z_lh_no(mat4 proj, float * __restrict nearZ, float * __restrict farZ); CGLM_EXPORT void glmc_persp_decomp_far_lh_no(mat4 proj, float * __restrict farZ); CGLM_EXPORT void glmc_persp_decomp_near_lh_no(mat4 proj, float * __restrict nearZ); CGLM_EXPORT void glmc_persp_sizes_lh_no(mat4 proj, float fovy, vec4 dest); CGLM_EXPORT float glmc_persp_fovy_lh_no(mat4 proj); CGLM_EXPORT float glmc_persp_aspect_lh_no(mat4 proj); #ifdef __cplusplus } #endif #endif /* cglmc_persp_lh_no_h */ cglm-0.9.6/include/cglm/call/clipspace/persp_lh_zo.h000066400000000000000000000036661475344456400224230ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ #ifndef cglmc_persp_lh_zo_h #define cglmc_persp_lh_zo_h #ifdef __cplusplus extern "C" { #endif #include "../../cglm.h" CGLM_EXPORT void glmc_frustum_lh_zo(float left, float right, float bottom, float top, float nearZ, float farZ, mat4 dest); CGLM_EXPORT void glmc_perspective_lh_zo(float fovy, float aspect, float nearVal, float farVal, mat4 dest); CGLM_EXPORT void glmc_persp_move_far_lh_zo(mat4 proj, float deltaFar); CGLM_EXPORT void glmc_persp_decomp_lh_zo(mat4 proj, float * __restrict nearZ, float * __restrict farZ, float * __restrict top, float * __restrict bottom, float * __restrict left, float * __restrict right); CGLM_EXPORT void glmc_persp_decompv_lh_zo(mat4 proj, float dest[6]); CGLM_EXPORT void glmc_persp_decomp_x_lh_zo(mat4 proj, float * __restrict left, float * __restrict right); CGLM_EXPORT void glmc_persp_decomp_y_lh_zo(mat4 proj, float * __restrict top, float * __restrict bottom); CGLM_EXPORT void glmc_persp_decomp_z_lh_zo(mat4 proj, float * __restrict nearZ, float * __restrict farZ); CGLM_EXPORT void glmc_persp_decomp_far_lh_zo(mat4 proj, float * __restrict farZ); CGLM_EXPORT void glmc_persp_decomp_near_lh_zo(mat4 proj, float * __restrict nearZ); CGLM_EXPORT void glmc_persp_sizes_lh_zo(mat4 proj, float fovy, vec4 dest); CGLM_EXPORT float glmc_persp_fovy_lh_zo(mat4 proj); CGLM_EXPORT float glmc_persp_aspect_lh_zo(mat4 proj); #ifdef __cplusplus } #endif #endif /* cglmc_persp_lh_zo_h */ cglm-0.9.6/include/cglm/call/clipspace/persp_rh_no.h000066400000000000000000000036661475344456400224150ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ #ifndef cglmc_persp_rh_no_h #define cglmc_persp_rh_no_h #ifdef __cplusplus extern "C" { #endif #include "../../cglm.h" CGLM_EXPORT void glmc_frustum_rh_no(float left, float right, float bottom, float top, float nearZ, float farZ, mat4 dest); CGLM_EXPORT void glmc_perspective_rh_no(float fovy, float aspect, float nearVal, float farVal, mat4 dest); CGLM_EXPORT void glmc_persp_move_far_rh_no(mat4 proj, float deltaFar); CGLM_EXPORT void glmc_persp_decomp_rh_no(mat4 proj, float * __restrict nearZ, float * __restrict farZ, float * __restrict top, float * __restrict bottom, float * __restrict left, float * __restrict right); CGLM_EXPORT void glmc_persp_decompv_rh_no(mat4 proj, float dest[6]); CGLM_EXPORT void glmc_persp_decomp_x_rh_no(mat4 proj, float * __restrict left, float * __restrict right); CGLM_EXPORT void glmc_persp_decomp_y_rh_no(mat4 proj, float * __restrict top, float * __restrict bottom); CGLM_EXPORT void glmc_persp_decomp_z_rh_no(mat4 proj, float * __restrict nearZ, float * __restrict farZ); CGLM_EXPORT void glmc_persp_decomp_far_rh_no(mat4 proj, float * __restrict farZ); CGLM_EXPORT void glmc_persp_decomp_near_rh_no(mat4 proj, float * __restrict nearZ); CGLM_EXPORT void glmc_persp_sizes_rh_no(mat4 proj, float fovy, vec4 dest); CGLM_EXPORT float glmc_persp_fovy_rh_no(mat4 proj); CGLM_EXPORT float glmc_persp_aspect_rh_no(mat4 proj); #ifdef __cplusplus } #endif #endif /* cglmc_persp_rh_no_h */ cglm-0.9.6/include/cglm/call/clipspace/persp_rh_zo.h000066400000000000000000000036661475344456400224310ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ #ifndef cglmc_persp_rh_zo_h #define cglmc_persp_rh_zo_h #ifdef __cplusplus extern "C" { #endif #include "../../cglm.h" CGLM_EXPORT void glmc_frustum_rh_zo(float left, float right, float bottom, float top, float nearZ, float farZ, mat4 dest); CGLM_EXPORT void glmc_perspective_rh_zo(float fovy, float aspect, float nearVal, float farVal, mat4 dest); CGLM_EXPORT void glmc_persp_move_far_rh_zo(mat4 proj, float deltaFar); CGLM_EXPORT void glmc_persp_decomp_rh_zo(mat4 proj, float * __restrict nearZ, float * __restrict farZ, float * __restrict top, float * __restrict bottom, float * __restrict left, float * __restrict right); CGLM_EXPORT void glmc_persp_decompv_rh_zo(mat4 proj, float dest[6]); CGLM_EXPORT void glmc_persp_decomp_x_rh_zo(mat4 proj, float * __restrict left, float * __restrict right); CGLM_EXPORT void glmc_persp_decomp_y_rh_zo(mat4 proj, float * __restrict top, float * __restrict bottom); CGLM_EXPORT void glmc_persp_decomp_z_rh_zo(mat4 proj, float * __restrict nearZ, float * __restrict farZ); CGLM_EXPORT void glmc_persp_decomp_far_rh_zo(mat4 proj, float * __restrict farZ); CGLM_EXPORT void glmc_persp_decomp_near_rh_zo(mat4 proj, float * __restrict nearZ); CGLM_EXPORT void glmc_persp_sizes_rh_zo(mat4 proj, float fovy, vec4 dest); CGLM_EXPORT float glmc_persp_fovy_rh_zo(mat4 proj); CGLM_EXPORT float glmc_persp_aspect_rh_zo(mat4 proj); #ifdef __cplusplus } #endif #endif /* cglmc_persp_rh_zo_h */ cglm-0.9.6/include/cglm/call/clipspace/project_no.h000066400000000000000000000010341475344456400222240ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ #ifndef cglmc_project_no_h #define cglmc_project_no_h #ifdef __cplusplus extern "C" { #endif #include "../../cglm.h" CGLM_EXPORT void glmc_unprojecti_no(vec3 pos, mat4 invMat, vec4 vp, vec3 dest); CGLM_EXPORT void glmc_project_no(vec3 pos, mat4 m, vec4 vp, vec3 dest); CGLM_EXPORT float glmc_project_z_no(vec3 pos, mat4 m); #ifdef __cplusplus } #endif #endif /* cglmc_project_no_h */ cglm-0.9.6/include/cglm/call/clipspace/project_zo.h000066400000000000000000000010341475344456400222400ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ #ifndef cglmc_project_zo_h #define cglmc_project_zo_h #ifdef __cplusplus extern "C" { #endif #include "../../cglm.h" CGLM_EXPORT void glmc_unprojecti_zo(vec3 pos, mat4 invMat, vec4 vp, vec3 dest); CGLM_EXPORT void glmc_project_zo(vec3 pos, mat4 m, vec4 vp, vec3 dest); CGLM_EXPORT float glmc_project_z_zo(vec3 pos, mat4 m); #ifdef __cplusplus } #endif #endif /* cglmc_project_zo_h */ cglm-0.9.6/include/cglm/call/clipspace/view_lh_no.h000066400000000000000000000010551475344456400222160ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ #ifndef cglmc_view_lh_no_h #define cglmc_view_lh_no_h #ifdef __cplusplus extern "C" { #endif #include "../../cglm.h" CGLM_EXPORT void glmc_lookat_lh_no(vec3 eye, vec3 center, vec3 up, mat4 dest); CGLM_EXPORT void glmc_look_lh_no(vec3 eye, vec3 dir, vec3 up, mat4 dest); CGLM_EXPORT void glmc_look_anyup_lh_no(vec3 eye, vec3 dir, mat4 dest); #ifdef __cplusplus } #endif #endif /* cglmc_view_lh_no_h */ cglm-0.9.6/include/cglm/call/clipspace/view_lh_zo.h000066400000000000000000000010551475344456400222320ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ #ifndef cglmc_view_lh_zo_h #define cglmc_view_lh_zo_h #ifdef __cplusplus extern "C" { #endif #include "../../cglm.h" CGLM_EXPORT void glmc_lookat_lh_zo(vec3 eye, vec3 center, vec3 up, mat4 dest); CGLM_EXPORT void glmc_look_lh_zo(vec3 eye, vec3 dir, vec3 up, mat4 dest); CGLM_EXPORT void glmc_look_anyup_lh_zo(vec3 eye, vec3 dir, mat4 dest); #ifdef __cplusplus } #endif #endif /* cglmc_view_lh_zo_h */ cglm-0.9.6/include/cglm/call/clipspace/view_rh_no.h000066400000000000000000000010551475344456400222240ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ #ifndef cglmc_view_rh_no_h #define cglmc_view_rh_no_h #ifdef __cplusplus extern "C" { #endif #include "../../cglm.h" CGLM_EXPORT void glmc_lookat_rh_no(vec3 eye, vec3 center, vec3 up, mat4 dest); CGLM_EXPORT void glmc_look_rh_no(vec3 eye, vec3 dir, vec3 up, mat4 dest); CGLM_EXPORT void glmc_look_anyup_rh_no(vec3 eye, vec3 dir, mat4 dest); #ifdef __cplusplus } #endif #endif /* cglmc_view_rh_no_h */ cglm-0.9.6/include/cglm/call/clipspace/view_rh_zo.h000066400000000000000000000010551475344456400222400ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ #ifndef cglmc_view_rh_zo_h #define cglmc_view_rh_zo_h #ifdef __cplusplus extern "C" { #endif #include "../../cglm.h" CGLM_EXPORT void glmc_lookat_rh_zo(vec3 eye, vec3 center, vec3 up, mat4 dest); CGLM_EXPORT void glmc_look_rh_zo(vec3 eye, vec3 dir, vec3 up, mat4 dest); CGLM_EXPORT void glmc_look_anyup_rh_zo(vec3 eye, vec3 dir, mat4 dest); #ifdef __cplusplus } #endif #endif /* cglmc_view_rh_zo_h */ cglm-0.9.6/include/cglm/call/curve.h000066400000000000000000000005561475344456400172530ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ #ifndef cglmc_curve_h #define cglmc_curve_h #ifdef __cplusplus extern "C" { #endif #include "../cglm.h" CGLM_EXPORT float glmc_smc(float s, mat4 m, vec4 c); #ifdef __cplusplus } #endif #endif /* cglmc_curve_h */ cglm-0.9.6/include/cglm/call/ease.h000066400000000000000000000034341475344456400170420ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ #ifndef cglmc_ease_h #define cglmc_ease_h #ifdef __cplusplus extern "C" { #endif #include "../cglm.h" CGLM_EXPORT float glmc_ease_linear(float t); CGLM_EXPORT float glmc_ease_sine_in(float t); CGLM_EXPORT float glmc_ease_sine_out(float t); CGLM_EXPORT float glmc_ease_sine_inout(float t); CGLM_EXPORT float glmc_ease_quad_in(float t); CGLM_EXPORT float glmc_ease_quad_out(float t); CGLM_EXPORT float glmc_ease_quad_inout(float t); CGLM_EXPORT float glmc_ease_cubic_in(float t); CGLM_EXPORT float glmc_ease_cubic_out(float t); CGLM_EXPORT float glmc_ease_cubic_inout(float t); CGLM_EXPORT float glmc_ease_quart_in(float t); CGLM_EXPORT float glmc_ease_quart_out(float t); CGLM_EXPORT float glmc_ease_quart_inout(float t); CGLM_EXPORT float glmc_ease_quint_in(float t); CGLM_EXPORT float glmc_ease_quint_out(float t); CGLM_EXPORT float glmc_ease_quint_inout(float t); CGLM_EXPORT float glmc_ease_exp_in(float t); CGLM_EXPORT float glmc_ease_exp_out(float t); CGLM_EXPORT float glmc_ease_exp_inout(float t); CGLM_EXPORT float glmc_ease_circ_in(float t); CGLM_EXPORT float glmc_ease_circ_out(float t); CGLM_EXPORT float glmc_ease_circ_inout(float t); CGLM_EXPORT float glmc_ease_back_in(float t); CGLM_EXPORT float glmc_ease_back_out(float t); CGLM_EXPORT float glmc_ease_back_inout(float t); CGLM_EXPORT float glmc_ease_elast_in(float t); CGLM_EXPORT float glmc_ease_elast_out(float t); CGLM_EXPORT float glmc_ease_elast_inout(float t); CGLM_EXPORT float glmc_ease_bounce_out(float t); CGLM_EXPORT float glmc_ease_bounce_in(float t); CGLM_EXPORT float glmc_ease_bounce_inout(float t); #ifdef __cplusplus } #endif #endif /* cglmc_ease_h */ cglm-0.9.6/include/cglm/call/euler.h000066400000000000000000000023361475344456400172410ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ #ifndef cglmc_euler_h #define cglmc_euler_h #ifdef __cplusplus extern "C" { #endif #include "../cglm.h" CGLM_EXPORT void glmc_euler_angles(mat4 m, vec3 dest); CGLM_EXPORT void glmc_euler(vec3 angles, mat4 dest); CGLM_EXPORT void glmc_euler_xyz(vec3 angles, mat4 dest); CGLM_EXPORT void glmc_euler_zyx(vec3 angles, mat4 dest); CGLM_EXPORT void glmc_euler_zxy(vec3 angles, mat4 dest); CGLM_EXPORT void glmc_euler_xzy(vec3 angles, mat4 dest); CGLM_EXPORT void glmc_euler_yzx(vec3 angles, mat4 dest); CGLM_EXPORT void glmc_euler_yxz(vec3 angles, mat4 dest); CGLM_EXPORT void 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 } #endif #endif /* cglmc_euler_h */ cglm-0.9.6/include/cglm/call/frustum.h000066400000000000000000000014061475344456400176270ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ #ifndef cglmc_frustum_h #define cglmc_frustum_h #ifdef __cplusplus extern "C" { #endif #include "../cglm.h" CGLM_EXPORT void glmc_frustum_planes(mat4 m, vec4 dest[6]); CGLM_EXPORT void glmc_frustum_corners(mat4 invMat, vec4 dest[8]); CGLM_EXPORT void glmc_frustum_center(vec4 corners[8], vec4 dest); CGLM_EXPORT void glmc_frustum_box(vec4 corners[8], mat4 m, vec3 box[2]); CGLM_EXPORT void glmc_frustum_corners_at(vec4 corners[8], float splitDist, float farDist, vec4 planeCorners[4]); #ifdef __cplusplus } #endif #endif /* cglmc_frustum_h */ cglm-0.9.6/include/cglm/call/io.h000066400000000000000000000013661475344456400165360ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ #ifndef cglmc_io_h #define cglmc_io_h #ifdef __cplusplus extern "C" { #endif #include "../cglm.h" CGLM_EXPORT void glmc_mat4_print(mat4 matrix, FILE * __restrict ostream); CGLM_EXPORT void glmc_mat3_print(mat3 matrix, FILE * __restrict ostream); CGLM_EXPORT void glmc_vec4_print(vec4 vec, FILE * __restrict ostream); CGLM_EXPORT void glmc_vec3_print(vec3 vec, FILE * __restrict ostream); CGLM_EXPORT void glmc_versor_print(versor vec, FILE * __restrict ostream); #ifdef __cplusplus } #endif #endif /* cglmc_io_h */ cglm-0.9.6/include/cglm/call/ivec2.h000066400000000000000000000054011475344456400171310ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ #ifndef cglmc_ivec2_h #define cglmc_ivec2_h #ifdef __cplusplus extern "C" { #endif #include "../cglm.h" CGLM_EXPORT void glmc_ivec2(int * __restrict v, ivec2 dest); CGLM_EXPORT void glmc_ivec2_copy(ivec2 a, ivec2 dest); CGLM_EXPORT void glmc_ivec2_zero(ivec2 v); CGLM_EXPORT void glmc_ivec2_one(ivec2 v); CGLM_EXPORT int glmc_ivec2_dot(ivec2 a, ivec2 b); CGLM_EXPORT int glmc_ivec2_cross(ivec2 a, ivec2 b); CGLM_EXPORT void glmc_ivec2_add(ivec2 a, ivec2 b, ivec2 dest); CGLM_EXPORT void glmc_ivec2_adds(ivec2 v, int s, ivec2 dest); CGLM_EXPORT void glmc_ivec2_sub(ivec2 a, ivec2 b, ivec2 dest); CGLM_EXPORT void glmc_ivec2_subs(ivec2 v, int s, ivec2 dest); CGLM_EXPORT void glmc_ivec2_mul(ivec2 a, ivec2 b, ivec2 dest); CGLM_EXPORT void glmc_ivec2_scale(ivec2 v, int s, ivec2 dest); CGLM_EXPORT void glmc_ivec2_div(ivec2 a, ivec2 b, ivec2 dest); CGLM_EXPORT void glmc_ivec2_divs(ivec2 v, int s, ivec2 dest); CGLM_EXPORT void glmc_ivec2_mod(ivec2 a, ivec2 b, 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 int glmc_ivec2_distance2(ivec2 a, ivec2 b); CGLM_EXPORT float 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 void glmc_ivec2_maxv(ivec2 a, ivec2 b, ivec2 dest); CGLM_EXPORT void glmc_ivec2_minv(ivec2 a, ivec2 b, ivec2 dest); CGLM_EXPORT void glmc_ivec2_clamp(ivec2 v, int minVal, int maxVal); CGLM_EXPORT void glmc_ivec2_abs(ivec2 v, ivec2 dest); #ifdef __cplusplus } #endif #endif /* cglmc_ivec2_h */ cglm-0.9.6/include/cglm/call/ivec3.h000066400000000000000000000054341475344456400171400ustar00rootroot00000000000000/* * Copyright (c);, Recep Aslantas. * * MIT License (MIT);, http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ #ifndef cglmc_ivec3_h #define cglmc_ivec3_h #ifdef __cplusplus extern "C" { #endif #include "../cglm.h" CGLM_EXPORT void glmc_ivec3(ivec4 v4, ivec3 dest); CGLM_EXPORT void glmc_ivec3_copy(ivec3 a, ivec3 dest); CGLM_EXPORT void glmc_ivec3_zero(ivec3 v); CGLM_EXPORT void glmc_ivec3_one(ivec3 v); CGLM_EXPORT int glmc_ivec3_dot(ivec3 a, ivec3 b); CGLM_EXPORT int glmc_ivec3_norm2(ivec3 v); CGLM_EXPORT int glmc_ivec3_norm(ivec3 v); CGLM_EXPORT void glmc_ivec3_add(ivec3 a, ivec3 b, ivec3 dest); CGLM_EXPORT void glmc_ivec3_adds(ivec3 v, int s, ivec3 dest); CGLM_EXPORT void glmc_ivec3_sub(ivec3 a, ivec3 b, ivec3 dest); CGLM_EXPORT void glmc_ivec3_subs(ivec3 v, int s, ivec3 dest); CGLM_EXPORT void glmc_ivec3_mul(ivec3 a, ivec3 b, ivec3 dest); CGLM_EXPORT void glmc_ivec3_scale(ivec3 v, int s, ivec3 dest); CGLM_EXPORT void glmc_ivec3_div(ivec3 a, ivec3 b, ivec3 dest); CGLM_EXPORT void glmc_ivec3_divs(ivec3 v, int s, ivec3 dest); CGLM_EXPORT void glmc_ivec3_mod(ivec3 a, ivec3 b, 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 int glmc_ivec3_distance2(ivec3 a, ivec3 b); CGLM_EXPORT float 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 void glmc_ivec3_maxv(ivec3 a, ivec3 b, ivec3 dest); CGLM_EXPORT void glmc_ivec3_minv(ivec3 a, ivec3 b, ivec3 dest); CGLM_EXPORT void glmc_ivec3_clamp(ivec3 v, int minVal, int maxVal); CGLM_EXPORT void glmc_ivec3_abs(ivec3 v, ivec3 dest); #ifdef __cplusplus } #endif #endif /* cglmc_ivec3_h */ cglm-0.9.6/include/cglm/call/ivec4.h000066400000000000000000000044771475344456400171470ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ #ifndef cglmc_ivec4_h #define cglmc_ivec4_h #ifdef __cplusplus extern "C" { #endif #include "../cglm.h" CGLM_EXPORT void glmc_ivec4(ivec3 v3, int last, ivec4 dest); CGLM_EXPORT void glmc_ivec4_copy(ivec4 a, ivec4 dest); CGLM_EXPORT void glmc_ivec4_zero(ivec4 v); CGLM_EXPORT void glmc_ivec4_one(ivec4 v); CGLM_EXPORT void glmc_ivec4_add(ivec4 a, ivec4 b, ivec4 dest); CGLM_EXPORT void glmc_ivec4_adds(ivec4 v, int s, ivec4 dest); CGLM_EXPORT void glmc_ivec4_sub(ivec4 a, ivec4 b, ivec4 dest); CGLM_EXPORT void glmc_ivec4_subs(ivec4 v, int s, ivec4 dest); CGLM_EXPORT void glmc_ivec4_mul(ivec4 a, ivec4 b, ivec4 dest); CGLM_EXPORT void 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 int glmc_ivec4_distance2(ivec4 a, ivec4 b); CGLM_EXPORT float glmc_ivec4_distance(ivec4 a, ivec4 b); CGLM_EXPORT void glmc_ivec4_maxv(ivec4 a, ivec4 b, ivec4 dest); CGLM_EXPORT void glmc_ivec4_minv(ivec4 a, ivec4 b, ivec4 dest); CGLM_EXPORT void glmc_ivec4_clamp(ivec4 v, int minVal, int maxVal); CGLM_EXPORT void glmc_ivec4_abs(ivec4 v, ivec4 dest); #ifdef __cplusplus } #endif #endif /* cglmc_ivec4_h */ cglm-0.9.6/include/cglm/call/mat2.h000066400000000000000000000023171475344456400167670ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ #ifndef cglmc_mat2_h #define cglmc_mat2_h #ifdef __cplusplus extern "C" { #endif #include "../cglm.h" CGLM_EXPORT void glmc_mat2_copy(mat2 mat, mat2 dest); CGLM_EXPORT void glmc_mat2_identity(mat2 mat); CGLM_EXPORT void glmc_mat2_identity_array(mat2 * __restrict mat, size_t count); CGLM_EXPORT void glmc_mat2_zero(mat2 mat); CGLM_EXPORT void glmc_mat2_mul(mat2 m1, mat2 m2, mat2 dest); CGLM_EXPORT void glmc_mat2_transpose_to(mat2 m, mat2 dest); CGLM_EXPORT void glmc_mat2_transpose(mat2 m); CGLM_EXPORT void glmc_mat2_mulv(mat2 m, vec2 v, vec2 dest); CGLM_EXPORT float glmc_mat2_trace(mat2 m); CGLM_EXPORT void glmc_mat2_scale(mat2 m, float s); CGLM_EXPORT float glmc_mat2_det(mat2 mat); CGLM_EXPORT void glmc_mat2_inv(mat2 mat, mat2 dest); CGLM_EXPORT void glmc_mat2_swap_col(mat2 mat, int col1, int col2); CGLM_EXPORT void glmc_mat2_swap_row(mat2 mat, int row1, int row2); CGLM_EXPORT float glmc_mat2_rmc(vec2 r, mat2 m, vec2 c); CGLM_EXPORT void glmc_mat2_make(const float * __restrict src, mat2 dest); #ifdef __cplusplus } #endif #endif /* cglmc_mat2_h */ cglm-0.9.6/include/cglm/call/mat2x3.h000066400000000000000000000013641475344456400172430ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ #ifndef cglmc_mat2x3_h #define cglmc_mat2x3_h #ifdef __cplusplus extern "C" { #endif #include "../cglm.h" CGLM_EXPORT void glmc_mat2x3_copy(mat2x3 mat, mat2x3 dest); CGLM_EXPORT void glmc_mat2x3_zero(mat2x3 mat); CGLM_EXPORT void glmc_mat2x3_make(const float * __restrict src, mat2x3 dest); CGLM_EXPORT void glmc_mat2x3_mul(mat2x3 m1, mat3x2 m2, mat3 dest); CGLM_EXPORT void glmc_mat2x3_mulv(mat2x3 m, vec2 v, vec3 dest); CGLM_EXPORT void glmc_mat2x3_transpose(mat2x3 m, mat3x2 dest); CGLM_EXPORT void glmc_mat2x3_scale(mat2x3 m, float s); #ifdef __cplusplus } #endif #endif /* cglmc_mat2x3_h */ cglm-0.9.6/include/cglm/call/mat2x4.h000066400000000000000000000013641475344456400172440ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ #ifndef cglmc_mat2x4_h #define cglmc_mat2x4_h #ifdef __cplusplus extern "C" { #endif #include "../cglm.h" CGLM_EXPORT void glmc_mat2x4_copy(mat2x4 mat, mat2x4 dest); CGLM_EXPORT void glmc_mat2x4_zero(mat2x4 mat); CGLM_EXPORT void glmc_mat2x4_make(const float * __restrict src, mat2x4 dest); CGLM_EXPORT void glmc_mat2x4_mul(mat2x4 m1, mat4x2 m2, mat4 dest); CGLM_EXPORT void glmc_mat2x4_mulv(mat2x4 m, vec2 v, vec4 dest); CGLM_EXPORT void glmc_mat2x4_transpose(mat2x4 m, mat4x2 dest); CGLM_EXPORT void glmc_mat2x4_scale(mat2x4 m, float s); #ifdef __cplusplus } #endif #endif /* cglmc_mat2x4_h */ cglm-0.9.6/include/cglm/call/mat3.h000066400000000000000000000025601475344456400167700ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ #ifndef cglmc_mat3_h #define cglmc_mat3_h #ifdef __cplusplus extern "C" { #endif #include "../cglm.h" /* DEPRECATED! use _copy, _ucopy versions */ #define glmc_mat3_dup(mat, dest) glmc_mat3_copy(mat, dest) CGLM_EXPORT void glmc_mat3_copy(mat3 mat, mat3 dest); CGLM_EXPORT void glmc_mat3_identity(mat3 mat); CGLM_EXPORT void glmc_mat3_zero(mat3 mat); CGLM_EXPORT void glmc_mat3_identity_array(mat3 * __restrict mat, size_t count); CGLM_EXPORT void glmc_mat3_mul(mat3 m1, mat3 m2, mat3 dest); CGLM_EXPORT void glmc_mat3_transpose_to(mat3 m, mat3 dest); CGLM_EXPORT void glmc_mat3_transpose(mat3 m); CGLM_EXPORT void glmc_mat3_mulv(mat3 m, vec3 v, vec3 dest); CGLM_EXPORT float glmc_mat3_trace(mat3 m); CGLM_EXPORT void glmc_mat3_quat(mat3 m, versor dest); CGLM_EXPORT void glmc_mat3_scale(mat3 m, float s); CGLM_EXPORT float glmc_mat3_det(mat3 mat); CGLM_EXPORT void glmc_mat3_inv(mat3 mat, mat3 dest); CGLM_EXPORT void glmc_mat3_swap_col(mat3 mat, int col1, int col2); CGLM_EXPORT void glmc_mat3_swap_row(mat3 mat, int row1, int row2); CGLM_EXPORT float glmc_mat3_rmc(vec3 r, mat3 m, vec3 c); CGLM_EXPORT void glmc_mat3_make(const float * __restrict src, mat3 dest); #ifdef __cplusplus } #endif #endif /* cglmc_mat3_h */ cglm-0.9.6/include/cglm/call/mat3x2.h000066400000000000000000000013641475344456400172430ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ #ifndef cglmc_mat3x2_h #define cglmc_mat3x2_h #ifdef __cplusplus extern "C" { #endif #include "../cglm.h" CGLM_EXPORT void glmc_mat3x2_copy(mat3x2 mat, mat3x2 dest); CGLM_EXPORT void glmc_mat3x2_zero(mat3x2 mat); CGLM_EXPORT void glmc_mat3x2_make(const float * __restrict src, mat3x2 dest); CGLM_EXPORT void glmc_mat3x2_mul(mat3x2 m1, mat2x3 m2, mat2 dest); CGLM_EXPORT void glmc_mat3x2_mulv(mat3x2 m, vec3 v, vec2 dest); CGLM_EXPORT void glmc_mat3x2_transpose(mat3x2 m, mat2x3 dest); CGLM_EXPORT void glmc_mat3x2_scale(mat3x2 m, float s); #ifdef __cplusplus } #endif #endif /* cglmc_mat3x2_h */ cglm-0.9.6/include/cglm/call/mat3x4.h000066400000000000000000000013641475344456400172450ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ #ifndef cglmc_mat3x4_h #define cglmc_mat3x4_h #ifdef __cplusplus extern "C" { #endif #include "../cglm.h" CGLM_EXPORT void glmc_mat3x4_copy(mat3x4 mat, mat3x4 dest); CGLM_EXPORT void glmc_mat3x4_zero(mat3x4 mat); CGLM_EXPORT void glmc_mat3x4_make(const float * __restrict src, mat3x4 dest); CGLM_EXPORT void glmc_mat3x4_mul(mat3x4 m1, mat4x3 m2, mat4 dest); CGLM_EXPORT void glmc_mat3x4_mulv(mat3x4 m, vec3 v, vec4 dest); CGLM_EXPORT void glmc_mat3x4_transpose(mat3x4 m, mat4x3 dest); CGLM_EXPORT void glmc_mat3x4_scale(mat3x4 m, float s); #ifdef __cplusplus } #endif #endif /* cglmc_mat3x4_h */ cglm-0.9.6/include/cglm/call/mat4.h000066400000000000000000000040111475344456400167620ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ #ifndef cglmc_mat_h #define cglmc_mat_h #ifdef __cplusplus extern "C" { #endif #include "../cglm.h" /* DEPRECATED! use _copy, _ucopy versions */ #define glmc_mat4_udup(mat, dest) glmc_mat4_ucopy(mat, dest) #define glmc_mat4_dup(mat, dest) glmc_mat4_copy(mat, dest) CGLM_EXPORT void glmc_mat4_ucopy(mat4 mat, mat4 dest); CGLM_EXPORT void glmc_mat4_copy(mat4 mat, mat4 dest); CGLM_EXPORT void glmc_mat4_identity(mat4 mat); CGLM_EXPORT void glmc_mat4_identity_array(mat4 * __restrict mat, size_t count); CGLM_EXPORT void glmc_mat4_zero(mat4 mat); CGLM_EXPORT void glmc_mat4_pick3(mat4 mat, mat3 dest); CGLM_EXPORT void glmc_mat4_pick3t(mat4 mat, mat3 dest); CGLM_EXPORT void glmc_mat4_ins3(mat3 mat, mat4 dest); CGLM_EXPORT void glmc_mat4_mul(mat4 m1, mat4 m2, mat4 dest); CGLM_EXPORT void glmc_mat4_mulN(mat4 * __restrict matrices[], uint32_t len, mat4 dest); CGLM_EXPORT void glmc_mat4_mulv(mat4 m, vec4 v, vec4 dest); CGLM_EXPORT void glmc_mat4_mulv3(mat4 m, vec3 v, float last, vec3 dest); CGLM_EXPORT float glmc_mat4_trace(mat4 m); CGLM_EXPORT float glmc_mat4_trace3(mat4 m); CGLM_EXPORT void glmc_mat4_quat(mat4 m, versor dest); CGLM_EXPORT void glmc_mat4_transpose_to(mat4 m, mat4 dest); CGLM_EXPORT void glmc_mat4_transpose(mat4 m); CGLM_EXPORT void glmc_mat4_scale_p(mat4 m, float s); CGLM_EXPORT void glmc_mat4_scale(mat4 m, float s); CGLM_EXPORT float glmc_mat4_det(mat4 mat); CGLM_EXPORT void glmc_mat4_inv(mat4 mat, mat4 dest); CGLM_EXPORT void glmc_mat4_inv_precise(mat4 mat, mat4 dest); CGLM_EXPORT void glmc_mat4_inv_fast(mat4 mat, mat4 dest); CGLM_EXPORT void glmc_mat4_swap_col(mat4 mat, int col1, int col2); CGLM_EXPORT void glmc_mat4_swap_row(mat4 mat, int row1, int row2); CGLM_EXPORT float glmc_mat4_rmc(vec4 r, mat4 m, vec4 c); CGLM_EXPORT void glmc_mat4_make(const float * __restrict src, mat4 dest); #ifdef __cplusplus } #endif #endif /* cglmc_mat_h */ cglm-0.9.6/include/cglm/call/mat4x2.h000066400000000000000000000013641475344456400172440ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ #ifndef cglmc_mat4x2_h #define cglmc_mat4x2_h #ifdef __cplusplus extern "C" { #endif #include "../cglm.h" CGLM_EXPORT void glmc_mat4x2_copy(mat4x2 mat, mat4x2 dest); CGLM_EXPORT void glmc_mat4x2_zero(mat4x2 mat); CGLM_EXPORT void glmc_mat4x2_make(const float * __restrict src, mat4x2 dest); CGLM_EXPORT void glmc_mat4x2_mul(mat4x2 m1, mat2x4 m2, mat2 dest); CGLM_EXPORT void glmc_mat4x2_mulv(mat4x2 m, vec4 v, vec2 dest); CGLM_EXPORT void glmc_mat4x2_transpose(mat4x2 m, mat2x4 dest); CGLM_EXPORT void glmc_mat4x2_scale(mat4x2 m, float s); #ifdef __cplusplus } #endif #endif /* cglmc_mat4x2_h */ cglm-0.9.6/include/cglm/call/mat4x3.h000066400000000000000000000013641475344456400172450ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ #ifndef cglmc_mat4x3_h #define cglmc_mat4x3_h #ifdef __cplusplus extern "C" { #endif #include "../cglm.h" CGLM_EXPORT void glmc_mat4x3_copy(mat4x3 mat, mat4x3 dest); CGLM_EXPORT void glmc_mat4x3_zero(mat4x3 mat); CGLM_EXPORT void glmc_mat4x3_make(const float * __restrict src, mat4x3 dest); CGLM_EXPORT void glmc_mat4x3_mul(mat4x3 m1, mat3x4 m2, mat3 dest); CGLM_EXPORT void glmc_mat4x3_mulv(mat4x3 m, vec4 v, vec3 dest); CGLM_EXPORT void glmc_mat4x3_transpose(mat4x3 m, mat3x4 dest); CGLM_EXPORT void glmc_mat4x3_scale(mat4x3 m, float s); #ifdef __cplusplus } #endif #endif /* cglmc_mat4x3_h */ cglm-0.9.6/include/cglm/call/noise.h000066400000000000000000000007131475344456400172370ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ #ifndef cglmc_noise_h #define cglmc_noise_h #ifdef __cplusplus extern "C" { #endif #include "../cglm.h" CGLM_EXPORT float glmc_perlin_vec4(vec4 point); CGLM_EXPORT float glmc_perlin_vec3(vec3 point); CGLM_EXPORT float glmc_perlin_vec2(vec2 point); #ifdef __cplusplus } #endif #endif /* cglmc_noise_h */ cglm-0.9.6/include/cglm/call/plane.h000066400000000000000000000005541475344456400172240ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ #ifndef cglmc_plane_h #define cglmc_plane_h #ifdef __cplusplus extern "C" { #endif #include "../cglm.h" CGLM_EXPORT void glmc_plane_normalize(vec4 plane); #ifdef __cplusplus } #endif #endif /* cglmc_plane_h */ cglm-0.9.6/include/cglm/call/project.h000066400000000000000000000012361475344456400175710ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ #ifndef cglmc_project_h #define cglmc_project_h #ifdef __cplusplus extern "C" { #endif #include "../cglm.h" CGLM_EXPORT void glmc_unprojecti(vec3 pos, mat4 invMat, vec4 vp, vec3 dest); CGLM_EXPORT void glmc_unproject(vec3 pos, mat4 m, vec4 vp, vec3 dest); CGLM_EXPORT void glmc_project(vec3 pos, mat4 m, vec4 vp, vec3 dest); CGLM_EXPORT float glmc_project_z(vec3 pos, mat4 m); CGLM_EXPORT void glmc_pickmatrix(vec2 center, vec2 size, vec4 vp, mat4 dest); #ifdef __cplusplus } #endif #endif /* cglmc_project_h */ cglm-0.9.6/include/cglm/call/quat.h000066400000000000000000000053651475344456400171040ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ #ifndef cglmc_quat_h #define cglmc_quat_h #ifdef __cplusplus extern "C" { #endif #include "../cglm.h" CGLM_EXPORT void glmc_quat_identity(versor q); CGLM_EXPORT void glmc_quat_identity_array(versor * __restrict q, size_t count); CGLM_EXPORT void glmc_quat_init(versor q, float x, float y, float z, float w); CGLM_EXPORT void glmc_quat(versor q, float angle, float x, float y, float z); CGLM_EXPORT void glmc_quatv(versor q, float angle, vec3 axis); CGLM_EXPORT void glmc_quat_copy(versor q, versor dest); CGLM_EXPORT void glmc_quat_from_vecs(vec3 a, vec3 b, versor dest); CGLM_EXPORT float glmc_quat_norm(versor q); CGLM_EXPORT void glmc_quat_normalize_to(versor q, versor dest); CGLM_EXPORT void glmc_quat_normalize(versor q); CGLM_EXPORT float glmc_quat_dot(versor p, versor q); CGLM_EXPORT void glmc_quat_conjugate(versor q, versor dest); CGLM_EXPORT void glmc_quat_inv(versor q, versor dest); CGLM_EXPORT void glmc_quat_add(versor p, versor q, versor dest); CGLM_EXPORT void glmc_quat_sub(versor p, versor q, versor dest); CGLM_EXPORT float glmc_quat_real(versor q); CGLM_EXPORT void glmc_quat_imag(versor q, vec3 dest); CGLM_EXPORT void glmc_quat_imagn(versor q, vec3 dest); CGLM_EXPORT float glmc_quat_imaglen(versor q); CGLM_EXPORT float glmc_quat_angle(versor q); CGLM_EXPORT void glmc_quat_axis(versor q, vec3 dest); CGLM_EXPORT void glmc_quat_mul(versor p, versor q, versor dest); CGLM_EXPORT void glmc_quat_mat4(versor q, mat4 dest); CGLM_EXPORT void glmc_quat_mat4t(versor q, mat4 dest); CGLM_EXPORT void glmc_quat_mat3(versor q, mat3 dest); CGLM_EXPORT void glmc_quat_mat3t(versor q, mat3 dest); CGLM_EXPORT void glmc_quat_lerp(versor from, versor to, float t, versor dest); CGLM_EXPORT void glmc_quat_lerpc(versor from, versor to, float t, versor dest); CGLM_EXPORT void glmc_quat_nlerp(versor q, versor r, float t, versor dest); CGLM_EXPORT void glmc_quat_slerp(versor q, versor r, float t, versor dest); CGLM_EXPORT void glmc_quat_slerp_longest(versor q, versor r, float t, versor dest); CGLM_EXPORT void glmc_quat_look(vec3 eye, versor ori, mat4 dest); CGLM_EXPORT void glmc_quat_for(vec3 dir, vec3 up, versor dest); CGLM_EXPORT void glmc_quat_forp(vec3 from, vec3 to, vec3 up, versor dest); CGLM_EXPORT void glmc_quat_rotatev(versor from, vec3 to, vec3 dest); CGLM_EXPORT void glmc_quat_rotate(mat4 m, versor q, mat4 dest); CGLM_EXPORT void glmc_quat_rotate_at(mat4 model, versor q, vec3 pivot); CGLM_EXPORT void glmc_quat_rotate_atm(mat4 m, versor q, vec3 pivot); CGLM_EXPORT void glmc_quat_make(const float * __restrict src, versor dest); #ifdef __cplusplus } #endif #endif /* cglmc_quat_h */ cglm-0.9.6/include/cglm/call/ray.h000066400000000000000000000013651475344456400167210ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ #ifndef cglmc_ray_h #define cglmc_ray_h #ifdef __cplusplus extern "C" { #endif #include "../cglm.h" CGLM_EXPORT bool glmc_ray_triangle(vec3 origin, vec3 direction, vec3 v0, vec3 v1, vec3 v2, float *d); CGLM_EXPORT bool glmc_ray_sphere(vec3 origin, vec3 dir, vec4 s, float * __restrict t1, float * __restrict t2); CGLM_EXPORT void glmc_ray_at(vec3 orig, vec3 dir, float t, vec3 point); #ifdef __cplusplus } #endif #endif /* cglmc_ray_h */ cglm-0.9.6/include/cglm/call/sphere.h000066400000000000000000000011401475344456400174030ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ #ifndef cglmc_sphere_h #define cglmc_sphere_h #ifdef __cplusplus extern "C" { #endif #include "../cglm.h" CGLM_EXPORT float glmc_sphere_radii(vec4 s); CGLM_EXPORT void glmc_sphere_transform(vec4 s, mat4 m, vec4 dest); CGLM_EXPORT void glmc_sphere_merge(vec4 s1, vec4 s2, vec4 dest); CGLM_EXPORT bool glmc_sphere_sphere(vec4 s1, vec4 s2); CGLM_EXPORT bool glmc_sphere_point(vec4 s, vec3 point); #ifdef __cplusplus } #endif #endif /* cglmc_sphere_h */ cglm-0.9.6/include/cglm/call/vec2.h000066400000000000000000000073071475344456400167670ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ #ifndef cglmc_vec2_h #define cglmc_vec2_h #ifdef __cplusplus extern "C" { #endif #include "../cglm.h" CGLM_EXPORT void glmc_vec2(float * __restrict v, vec2 dest); CGLM_EXPORT void glmc_vec2_fill(vec2 v, float val); CGLM_EXPORT bool glmc_vec2_eq(vec2 v, float val); CGLM_EXPORT bool glmc_vec2_eqv(vec2 a, vec2 b); CGLM_EXPORT void glmc_vec2_copy(vec2 a, vec2 dest); CGLM_EXPORT void glmc_vec2_zero(vec2 v); CGLM_EXPORT void glmc_vec2_one(vec2 v); CGLM_EXPORT float glmc_vec2_dot(vec2 a, vec2 b); CGLM_EXPORT float glmc_vec2_cross(vec2 a, vec2 b); CGLM_EXPORT float glmc_vec2_norm2(vec2 v); CGLM_EXPORT float glmc_vec2_norm(vec2 v); CGLM_EXPORT void glmc_vec2_add(vec2 a, vec2 b, vec2 dest); CGLM_EXPORT void glmc_vec2_adds(vec2 v, float s, vec2 dest); CGLM_EXPORT void glmc_vec2_sub(vec2 a, vec2 b, vec2 dest); CGLM_EXPORT void glmc_vec2_subs(vec2 v, float s, vec2 dest); CGLM_EXPORT void glmc_vec2_mul(vec2 a, vec2 b, vec2 dest); CGLM_EXPORT void glmc_vec2_scale(vec2 v, float s, vec2 dest); CGLM_EXPORT void glmc_vec2_scale_as(vec2 v, float s, vec2 dest); CGLM_EXPORT void glmc_vec2_div(vec2 a, vec2 b, vec2 dest); CGLM_EXPORT void glmc_vec2_divs(vec2 v, float s, vec2 dest); CGLM_EXPORT void glmc_vec2_addadd(vec2 a, vec2 b, vec2 dest); CGLM_EXPORT void glmc_vec2_subadd(vec2 a, vec2 b, vec2 dest); CGLM_EXPORT void glmc_vec2_muladd(vec2 a, vec2 b, vec2 dest); CGLM_EXPORT void glmc_vec2_muladds(vec2 a, float s, vec2 dest); CGLM_EXPORT void glmc_vec2_maxadd(vec2 a, vec2 b, vec2 dest); CGLM_EXPORT void 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 void glmc_vec2_negate_to(vec2 v, vec2 dest); CGLM_EXPORT void glmc_vec2_negate(vec2 v); CGLM_EXPORT void glmc_vec2_normalize(vec2 v); CGLM_EXPORT void glmc_vec2_normalize_to(vec2 v, vec2 dest); CGLM_EXPORT void glmc_vec2_rotate(vec2 v, float angle, vec2 dest); CGLM_EXPORT void glmc_vec2_center(vec2 a, vec2 b, vec2 dest); CGLM_EXPORT float glmc_vec2_distance2(vec2 a, vec2 b); CGLM_EXPORT float glmc_vec2_distance(vec2 a, vec2 b); CGLM_EXPORT void glmc_vec2_maxv(vec2 a, vec2 b, vec2 dest); CGLM_EXPORT void glmc_vec2_minv(vec2 a, vec2 b, vec2 dest); CGLM_EXPORT void glmc_vec2_clamp(vec2 v, float minval, float maxval); CGLM_EXPORT void glmc_vec2_abs(vec2 v, vec2 dest); CGLM_EXPORT void glmc_vec2_fract(vec2 v, vec2 dest); CGLM_EXPORT void glmc_vec2_floor(vec2 v, vec2 dest); CGLM_EXPORT void glmc_vec2_mods(vec2 v, float s, vec2 dest); CGLM_EXPORT void glmc_vec2_swizzle(vec2 v, int mask, vec2 dest); CGLM_EXPORT void glmc_vec2_lerp(vec2 from, vec2 to, float t, vec2 dest); CGLM_EXPORT void glmc_vec2_step(vec2 edge, vec2 x, vec2 dest); CGLM_EXPORT void glmc_vec2_steps(float edge, vec2 x, vec2 dest); CGLM_EXPORT void glmc_vec2_stepr(vec2 edge, float x, vec2 dest); CGLM_EXPORT void glmc_vec2_complex_mul(vec2 a, vec2 b, vec2 dest); CGLM_EXPORT void glmc_vec2_complex_div(vec2 a, vec2 b, vec2 dest); CGLM_EXPORT void glmc_vec2_complex_conjugate(vec2 a, vec2 dest); CGLM_EXPORT void glmc_vec2_make(const float * __restrict src, vec2 dest); CGLM_EXPORT void glmc_vec2_reflect(vec2 v, vec2 n, vec2 dest); CGLM_EXPORT bool glmc_vec2_refract(vec2 v, vec2 n, float eta, vec2 dest); #ifdef __cplusplus } #endif #endif /* cglmc_vec2_h */ cglm-0.9.6/include/cglm/call/vec3.h000066400000000000000000000133061475344456400167640ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ #ifndef cglmc_vec3_h #define cglmc_vec3_h #ifdef __cplusplus extern "C" { #endif #include "../cglm.h" /* DEPRECATED! use _copy, _ucopy versions */ #define glmc_vec_dup(v, dest) glmc_vec3_copy(v, dest) #define glmc_vec3_flipsign(v) glmc_vec3_negate(v) #define glmc_vec3_flipsign_to(v, dest) glmc_vec3_negate_to(v, dest) #define glmc_vec3_inv(v) glmc_vec3_negate(v) #define glmc_vec3_inv_to(v, dest) glmc_vec3_negate_to(v, dest) #define glmc_vec3_step_uni(edge, x, dest) glmc_vec3_steps(edge, x, dest); CGLM_EXPORT void glmc_vec3(vec4 v4, vec3 dest); CGLM_EXPORT void glmc_vec3_copy(vec3 a, vec3 dest); CGLM_EXPORT void glmc_vec3_zero(vec3 v); CGLM_EXPORT void glmc_vec3_one(vec3 v); CGLM_EXPORT float glmc_vec3_dot(vec3 a, vec3 b); CGLM_EXPORT void glmc_vec3_cross(vec3 a, vec3 b, vec3 dest); CGLM_EXPORT void glmc_vec3_crossn(vec3 a, vec3 b, vec3 dest); CGLM_EXPORT float glmc_vec3_norm(vec3 v); CGLM_EXPORT float glmc_vec3_norm2(vec3 v); CGLM_EXPORT float glmc_vec3_norm_one(vec3 v); CGLM_EXPORT float glmc_vec3_norm_inf(vec3 v); CGLM_EXPORT void glmc_vec3_normalize_to(vec3 v, vec3 dest); CGLM_EXPORT void glmc_vec3_normalize(vec3 v); CGLM_EXPORT void glmc_vec3_add(vec3 a, vec3 b, vec3 dest); CGLM_EXPORT void glmc_vec3_adds(vec3 v, float s, vec3 dest); CGLM_EXPORT void glmc_vec3_sub(vec3 a, vec3 b, vec3 dest); CGLM_EXPORT void glmc_vec3_subs(vec3 v, float s, vec3 dest); CGLM_EXPORT void glmc_vec3_mul(vec3 a, vec3 b, vec3 d); CGLM_EXPORT void glmc_vec3_scale(vec3 v, float s, vec3 dest); CGLM_EXPORT void glmc_vec3_scale_as(vec3 v, float s, vec3 dest); CGLM_EXPORT void glmc_vec3_div(vec3 a, vec3 b, vec3 dest); CGLM_EXPORT void glmc_vec3_divs(vec3 a, float s, vec3 dest); CGLM_EXPORT void glmc_vec3_addadd(vec3 a, vec3 b, vec3 dest); CGLM_EXPORT void glmc_vec3_subadd(vec3 a, vec3 b, vec3 dest); CGLM_EXPORT void glmc_vec3_muladd(vec3 a, vec3 b, vec3 dest); CGLM_EXPORT void glmc_vec3_muladds(vec3 a, float s, vec3 dest); CGLM_EXPORT void glmc_vec3_maxadd(vec3 a, vec3 b, vec3 dest); CGLM_EXPORT void 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 void glmc_vec3_negate(vec3 v); CGLM_EXPORT void glmc_vec3_negate_to(vec3 v, vec3 dest); CGLM_EXPORT float glmc_vec3_angle(vec3 a, vec3 b); CGLM_EXPORT void glmc_vec3_rotate(vec3 v, float angle, vec3 axis); CGLM_EXPORT void glmc_vec3_rotate_m4(mat4 m, vec3 v, vec3 dest); CGLM_EXPORT void glmc_vec3_rotate_m3(mat3 m, vec3 v, vec3 dest); CGLM_EXPORT void glmc_vec3_proj(vec3 a, vec3 b, vec3 dest); CGLM_EXPORT void glmc_vec3_center(vec3 a, vec3 b, vec3 dest); CGLM_EXPORT float glmc_vec3_distance2(vec3 a, vec3 b); CGLM_EXPORT float glmc_vec3_distance(vec3 a, vec3 b); CGLM_EXPORT void glmc_vec3_maxv(vec3 a, vec3 b, vec3 dest); CGLM_EXPORT void glmc_vec3_minv(vec3 a, vec3 b, vec3 dest); CGLM_EXPORT void glmc_vec3_clamp(vec3 v, float minVal, float maxVal); CGLM_EXPORT void glmc_vec3_ortho(vec3 v, vec3 dest); CGLM_EXPORT void glmc_vec3_lerp(vec3 from, vec3 to, float t, vec3 dest); CGLM_EXPORT void glmc_vec3_lerpc(vec3 from, vec3 to, float t, vec3 dest); CGLM_INLINE void glmc_vec3_mix(vec3 from, vec3 to, float t, vec3 dest) { glmc_vec3_lerp(from, to, t, dest); } CGLM_INLINE void glmc_vec3_mixc(vec3 from, vec3 to, float t, vec3 dest) { glmc_vec3_lerpc(from, to, t, dest); } CGLM_EXPORT void glmc_vec3_step(vec3 edge, vec3 x, vec3 dest); CGLM_EXPORT void glmc_vec3_smoothstep_uni(float edge0, float edge1, vec3 x, vec3 dest); CGLM_EXPORT void glmc_vec3_smoothstep(vec3 edge0, vec3 edge1, vec3 x, vec3 dest); CGLM_EXPORT void glmc_vec3_smoothinterp(vec3 from, vec3 to, float t, vec3 dest); CGLM_EXPORT void glmc_vec3_smoothinterpc(vec3 from, vec3 to, float t, vec3 dest); CGLM_EXPORT void glmc_vec3_swizzle(vec3 v, int mask, vec3 dest); /* ext */ CGLM_EXPORT void glmc_vec3_mulv(vec3 a, vec3 b, vec3 d); CGLM_EXPORT void glmc_vec3_broadcast(float val, vec3 d); CGLM_EXPORT void glmc_vec3_fill(vec3 v, float val); CGLM_EXPORT bool glmc_vec3_eq(vec3 v, float val); CGLM_EXPORT bool glmc_vec3_eq_eps(vec3 v, float val); CGLM_EXPORT bool glmc_vec3_eq_all(vec3 v); CGLM_EXPORT bool glmc_vec3_eqv(vec3 a, vec3 b); CGLM_EXPORT bool glmc_vec3_eqv_eps(vec3 a, vec3 b); CGLM_EXPORT float glmc_vec3_max(vec3 v); CGLM_EXPORT float glmc_vec3_min(vec3 v); CGLM_EXPORT bool glmc_vec3_isnan(vec3 v); CGLM_EXPORT bool glmc_vec3_isinf(vec3 v); CGLM_EXPORT bool glmc_vec3_isvalid(vec3 v); CGLM_EXPORT void glmc_vec3_sign(vec3 v, vec3 dest); CGLM_EXPORT void glmc_vec3_abs(vec3 v, vec3 dest); CGLM_EXPORT void glmc_vec3_fract(vec3 v, vec3 dest); CGLM_EXPORT void glmc_vec3_floor(vec3 v, vec3 dest); CGLM_EXPORT void glmc_vec3_mods(vec3 v, float s, vec3 dest); CGLM_EXPORT void glmc_vec3_steps(float edge, vec3 x, vec3 dest); CGLM_EXPORT void glmc_vec3_stepr(vec3 edge, float x, vec3 dest); CGLM_EXPORT float glmc_vec3_hadd(vec3 v); CGLM_EXPORT void glmc_vec3_sqrt(vec3 v, vec3 dest); CGLM_EXPORT void glmc_vec3_make(const float * __restrict src, vec3 dest); CGLM_EXPORT void glmc_vec3_faceforward(vec3 n, vec3 v, vec3 nref, vec3 dest); CGLM_EXPORT void glmc_vec3_reflect(vec3 v, vec3 n, vec3 dest); CGLM_EXPORT bool glmc_vec3_refract(vec3 v, vec3 n, float eta, vec3 dest); #ifdef __cplusplus } #endif #endif /* cglmc_vec3_h */ cglm-0.9.6/include/cglm/call/vec4.h000066400000000000000000000125001475344456400167600ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ #ifndef cglmc_vec4_h #define cglmc_vec4_h #ifdef __cplusplus extern "C" { #endif #include "../cglm.h" /* DEPRECATED! use _copy, _ucopy versions */ #define glmc_vec4_dup3(v, dest) glmc_vec4_copy3(v, dest) #define glmc_vec4_dup(v, dest) glmc_vec4_copy(v, dest) #define glmc_vec4_flipsign(v) glmc_vec4_negate(v) #define glmc_vec4_flipsign_to(v, dest) glmc_vec4_negate_to(v, dest) #define glmc_vec4_inv(v) glmc_vec4_negate(v) #define glmc_vec4_inv_to(v, dest) glmc_vec4_negate_to(v, dest) #define glmc_vec4_step_uni(edge, x, dest) glmc_vec4_steps(edge, x, dest) CGLM_EXPORT void glmc_vec4(vec3 v3, float last, vec4 dest); CGLM_EXPORT void glmc_vec4_zero(vec4 v); CGLM_EXPORT void glmc_vec4_one(vec4 v); CGLM_EXPORT void glmc_vec4_copy3(vec4 v, vec3 dest); CGLM_EXPORT void glmc_vec4_copy(vec4 v, vec4 dest); CGLM_EXPORT void glmc_vec4_ucopy(vec4 v, vec4 dest); CGLM_EXPORT float glmc_vec4_dot(vec4 a, vec4 b); CGLM_EXPORT float glmc_vec4_norm(vec4 v); CGLM_EXPORT float glmc_vec4_norm2(vec4 v); CGLM_EXPORT float glmc_vec4_norm_one(vec4 v); CGLM_EXPORT float glmc_vec4_norm_inf(vec4 v); CGLM_EXPORT void glmc_vec4_normalize_to(vec4 v, vec4 dest); CGLM_EXPORT void glmc_vec4_normalize(vec4 v); CGLM_EXPORT void glmc_vec4_add(vec4 a, vec4 b, vec4 dest); CGLM_EXPORT void glmc_vec4_adds(vec4 v, float s, vec4 dest); CGLM_EXPORT void glmc_vec4_sub(vec4 a, vec4 b, vec4 dest); CGLM_EXPORT void glmc_vec4_subs(vec4 v, float s, vec4 dest); CGLM_EXPORT void glmc_vec4_mul(vec4 a, vec4 b, vec4 d); CGLM_EXPORT void glmc_vec4_scale(vec4 v, float s, vec4 dest); CGLM_EXPORT void glmc_vec4_scale_as(vec4 v, float s, vec4 dest); CGLM_EXPORT void glmc_vec4_div(vec4 a, vec4 b, vec4 dest); CGLM_EXPORT void glmc_vec4_divs(vec4 v, float s, vec4 dest); CGLM_EXPORT void glmc_vec4_addadd(vec4 a, vec4 b, vec4 dest); CGLM_EXPORT void glmc_vec4_subadd(vec4 a, vec4 b, vec4 dest); CGLM_EXPORT void glmc_vec4_muladd(vec4 a, vec4 b, vec4 dest); CGLM_EXPORT void glmc_vec4_muladds(vec4 a, float s, vec4 dest); CGLM_EXPORT void glmc_vec4_maxadd(vec4 a, vec4 b, vec4 dest); CGLM_EXPORT void 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 void glmc_vec4_negate(vec4 v); CGLM_EXPORT void glmc_vec4_negate_to(vec4 v, vec4 dest); CGLM_EXPORT float glmc_vec4_distance(vec4 a, vec4 b); CGLM_EXPORT float glmc_vec4_distance2(vec4 a, vec4 b); CGLM_EXPORT void glmc_vec4_maxv(vec4 a, vec4 b, vec4 dest); CGLM_EXPORT void glmc_vec4_minv(vec4 a, vec4 b, vec4 dest); CGLM_EXPORT void glmc_vec4_clamp(vec4 v, float minVal, float maxVal); CGLM_EXPORT void glmc_vec4_lerp(vec4 from, vec4 to, float t, vec4 dest); CGLM_EXPORT void glmc_vec4_lerpc(vec4 from, vec4 to, float t, vec4 dest); CGLM_INLINE void glmc_vec4_mix(vec4 from, vec4 to, float t, vec4 dest) { glmc_vec4_lerp(from, to, t, dest); } CGLM_INLINE void glmc_vec4_mixc(vec4 from, vec4 to, float t, vec4 dest) { glmc_vec4_lerpc(from, to, t, dest); } CGLM_EXPORT void glmc_vec4_step(vec4 edge, vec4 x, vec4 dest); CGLM_EXPORT void glmc_vec4_smoothstep_uni(float edge0, float edge1, vec4 x, vec4 dest); CGLM_EXPORT void glmc_vec4_smoothstep(vec4 edge0, vec4 edge1, vec4 x, vec4 dest); CGLM_EXPORT void glmc_vec4_smoothinterp(vec4 from, vec4 to, float t, vec4 dest); CGLM_EXPORT void glmc_vec4_smoothinterpc(vec4 from, vec4 to, float t, vec4 dest); CGLM_EXPORT void glmc_vec4_cubic(float s, vec4 dest); CGLM_EXPORT void glmc_vec4_swizzle(vec4 v, int mask, vec4 dest); /* ext */ CGLM_EXPORT void glmc_vec4_mulv(vec4 a, vec4 b, vec4 d); CGLM_EXPORT void glmc_vec4_broadcast(float val, vec4 d); CGLM_EXPORT void glmc_vec4_fill(vec4 v, float val); CGLM_EXPORT bool glmc_vec4_eq(vec4 v, float val); CGLM_EXPORT bool glmc_vec4_eq_eps(vec4 v, float val); CGLM_EXPORT bool glmc_vec4_eq_all(vec4 v); CGLM_EXPORT bool glmc_vec4_eqv(vec4 a, vec4 b); CGLM_EXPORT bool glmc_vec4_eqv_eps(vec4 a, vec4 b); CGLM_EXPORT float glmc_vec4_max(vec4 v); CGLM_EXPORT float glmc_vec4_min(vec4 v); CGLM_EXPORT bool glmc_vec4_isnan(vec4 v); CGLM_EXPORT bool glmc_vec4_isinf(vec4 v); CGLM_EXPORT bool glmc_vec4_isvalid(vec4 v); CGLM_EXPORT void glmc_vec4_sign(vec4 v, vec4 dest); CGLM_EXPORT void glmc_vec4_abs(vec4 v, vec4 dest); CGLM_EXPORT void glmc_vec4_fract(vec4 v, vec4 dest); CGLM_EXPORT void glmc_vec4_floor(vec4 v, vec4 dest); CGLM_EXPORT void glmc_vec4_mods(vec4 v, float s, vec4 dest); CGLM_EXPORT void glmc_vec4_steps(float edge, vec4 x, vec4 dest); CGLM_EXPORT void glmc_vec4_stepr(vec4 edge, float x, vec4 dest); CGLM_EXPORT float glmc_vec4_hadd(vec4 v); CGLM_EXPORT void glmc_vec4_sqrt(vec4 v, vec4 dest); CGLM_EXPORT void glmc_vec4_make(const float * __restrict src, vec4 dest); CGLM_EXPORT void glmc_vec4_reflect(vec4 v, vec4 n, vec4 dest); CGLM_EXPORT bool glmc_vec4_refract(vec4 v, vec4 n, float eta, vec4 dest); #ifdef __cplusplus } #endif #endif /* cglmc_vec4_h */ cglm-0.9.6/include/cglm/cam.h000066400000000000000000000465621475344456400157630ustar00rootroot00000000000000/* * 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_frustum(float left, float right, float bottom, float top, float nearZ, float farZ, mat4 dest) CGLM_INLINE void glm_ortho(float left, float right, float bottom, float top, float nearZ, float farZ, mat4 dest) CGLM_INLINE void glm_ortho_aabb(vec3 box[2], mat4 dest) CGLM_INLINE void glm_ortho_aabb_p(vec3 box[2], float padding, mat4 dest) CGLM_INLINE void glm_ortho_aabb_pz(vec3 box[2], float padding, mat4 dest) CGLM_INLINE void glm_ortho_default(float aspect, mat4 dest) CGLM_INLINE void glm_ortho_default_s(float aspect, float size, mat4 dest) CGLM_INLINE void glm_perspective(float fovy, float aspect, float nearZ, float farZ, mat4 dest) CGLM_INLINE void glm_perspective_default(float aspect, mat4 dest) CGLM_INLINE void glm_perspective_resize(float aspect, mat4 proj) CGLM_INLINE void glm_lookat(vec3 eye, vec3 center, vec3 up, mat4 dest) CGLM_INLINE void glm_look(vec3 eye, vec3 dir, vec3 up, mat4 dest) CGLM_INLINE void glm_look_anyup(vec3 eye, vec3 dir, mat4 dest) CGLM_INLINE void glm_persp_decomp(mat4 proj, float *nearZ, float *farZ, float *top, float *bottom, float *left, float *right) CGLM_INLINE void glm_persp_decompv(mat4 proj, float dest[6]) CGLM_INLINE void glm_persp_decomp_x(mat4 proj, float *left, float *right) CGLM_INLINE void glm_persp_decomp_y(mat4 proj, float *top, float *bottom) CGLM_INLINE void glm_persp_decomp_z(mat4 proj, float *nearv, float *farv) CGLM_INLINE void glm_persp_decomp_far(mat4 proj, float *farZ) CGLM_INLINE void glm_persp_decomp_near(mat4 proj, float *nearZ) CGLM_INLINE float glm_persp_fovy(mat4 proj) CGLM_INLINE float glm_persp_aspect(mat4 proj) CGLM_INLINE void glm_persp_sizes(mat4 proj, float fovy, vec4 dest) */ #ifndef cglm_cam_h #define cglm_cam_h #include "common.h" #include "plane.h" #include "clipspace/persp.h" #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 /*! * @brief set up perspective peprojection matrix * * @param[in] left viewport.left * @param[in] right viewport.right * @param[in] bottom viewport.bottom * @param[in] top viewport.top * @param[in] nearZ near clipping plane * @param[in] farZ far clipping plane * @param[out] dest result matrix */ CGLM_INLINE void glm_frustum(float left, float right, float bottom, float top, float nearZ, float farZ, mat4 dest) { #if CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_LH_ZO glm_frustum_lh_zo(left, right, bottom, top, nearZ, farZ, dest); #elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_LH_NO glm_frustum_lh_no(left, right, bottom, top, nearZ, farZ, dest); #elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_RH_ZO glm_frustum_rh_zo(left, right, bottom, top, nearZ, farZ, dest); #elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_RH_NO glm_frustum_rh_no(left, right, bottom, top, nearZ, farZ, dest); #endif } /*! * @brief set up orthographic projection matrix * * @param[in] left viewport.left * @param[in] right viewport.right * @param[in] bottom viewport.bottom * @param[in] top viewport.top * @param[in] nearZ near clipping plane * @param[in] farZ far clipping plane * @param[out] dest result matrix */ CGLM_INLINE void glm_ortho(float left, float right, float bottom, float top, float nearZ, float farZ, mat4 dest) { #if CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_LH_ZO glm_ortho_lh_zo(left, right, bottom, top, nearZ, farZ, dest); #elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_LH_NO glm_ortho_lh_no(left, right, bottom, top, nearZ, farZ, dest); #elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_RH_ZO glm_ortho_rh_zo(left, right, bottom, top, nearZ, farZ, dest); #elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_RH_NO glm_ortho_rh_no(left, right, bottom, top, nearZ, farZ, dest); #endif } /*! * @brief set up orthographic projection matrix using bounding box * * bounding box (AABB) must be in view space * * @param[in] box AABB * @param[out] dest result matrix */ CGLM_INLINE void glm_ortho_aabb(vec3 box[2], mat4 dest) { #if CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_LH_ZO glm_ortho_aabb_lh_zo(box, dest); #elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_LH_NO glm_ortho_aabb_lh_no(box, dest); #elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_RH_ZO glm_ortho_aabb_rh_zo(box, dest); #elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_RH_NO glm_ortho_aabb_rh_no(box, dest); #endif } /*! * @brief set up orthographic projection matrix using bounding box * * bounding box (AABB) must be in view space * * @param[in] box AABB * @param[in] padding padding * @param[out] dest result matrix */ CGLM_INLINE void glm_ortho_aabb_p(vec3 box[2], float padding, mat4 dest) { #if CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_LH_ZO glm_ortho_aabb_p_lh_zo(box, padding, dest); #elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_LH_NO glm_ortho_aabb_p_lh_no(box, padding, dest); #elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_RH_ZO glm_ortho_aabb_p_rh_zo(box, padding, dest); #elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_RH_NO glm_ortho_aabb_p_rh_no(box, padding, dest); #endif } /*! * @brief set up orthographic projection matrix using bounding box * * bounding box (AABB) must be in view space * * @param[in] box AABB * @param[in] padding padding for near and far * @param[out] dest result matrix */ CGLM_INLINE void glm_ortho_aabb_pz(vec3 box[2], float padding, mat4 dest) { #if CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_LH_ZO glm_ortho_aabb_pz_lh_zo(box, padding, dest); #elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_LH_NO glm_ortho_aabb_pz_lh_no(box, padding, dest); #elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_RH_ZO glm_ortho_aabb_pz_rh_zo(box, padding, dest); #elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_RH_NO glm_ortho_aabb_pz_rh_no(box, padding, dest); #endif } /*! * @brief set up unit orthographic projection matrix * * @param[in] aspect aspect ration ( width / height ) * @param[out] dest result matrix */ CGLM_INLINE void glm_ortho_default(float aspect, mat4 dest) { #if CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_LH_ZO glm_ortho_default_lh_zo(aspect, dest); #elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_LH_NO glm_ortho_default_lh_no(aspect, dest); #elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_RH_ZO glm_ortho_default_rh_zo(aspect, dest); #elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_RH_NO glm_ortho_default_rh_no(aspect, dest); #endif } /*! * @brief set up orthographic projection matrix with given CUBE size * * @param[in] aspect aspect ratio ( width / height ) * @param[in] size cube size * @param[out] dest result matrix */ CGLM_INLINE void glm_ortho_default_s(float aspect, float size, mat4 dest) { #if CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_LH_ZO glm_ortho_default_s_lh_zo(aspect, size, dest); #elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_LH_NO glm_ortho_default_s_lh_no(aspect, size, dest); #elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_RH_ZO glm_ortho_default_s_rh_zo(aspect, size, dest); #elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_RH_NO glm_ortho_default_s_rh_no(aspect, size, dest); #endif } /*! * @brief set up perspective projection matrix * * @param[in] fovy field of view angle * @param[in] aspect aspect ratio ( width / height ) * @param[in] nearZ near clipping plane * @param[in] farZ far clipping planes * @param[out] dest result matrix */ CGLM_INLINE void glm_perspective(float fovy, float aspect, float nearZ, float farZ, mat4 dest) { #if CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_LH_ZO glm_perspective_lh_zo(fovy, aspect, nearZ, farZ, dest); #elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_LH_NO glm_perspective_lh_no(fovy, aspect, nearZ, farZ, dest); #elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_RH_ZO glm_perspective_rh_zo(fovy, aspect, nearZ, farZ, dest); #elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_RH_NO glm_perspective_rh_no(fovy, aspect, nearZ, farZ, dest); #endif } /*! * @brief extend perspective projection matrix's far distance * * this function does not guarantee far >= near, be aware of that! * * @param[in, out] proj projection matrix to extend * @param[in] deltaFar distance from existing far (negative to shink) */ CGLM_INLINE void glm_persp_move_far(mat4 proj, float deltaFar) { #if CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_LH_ZO glm_persp_move_far_lh_zo(proj, deltaFar); #elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_LH_NO glm_persp_move_far_lh_no(proj, deltaFar); #elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_RH_ZO glm_persp_move_far_rh_zo(proj, deltaFar); #elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_RH_NO glm_persp_move_far_rh_no(proj, deltaFar); #endif } /*! * @brief set up perspective projection matrix with default near/far * and angle values * * @param[in] aspect aspect ratio ( width / height ) * @param[out] dest result matrix */ CGLM_INLINE void glm_perspective_default(float aspect, mat4 dest) { #if CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_LH_ZO glm_perspective_default_lh_zo(aspect, dest); #elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_LH_NO glm_perspective_default_lh_no(aspect, dest); #elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_RH_ZO glm_perspective_default_rh_zo(aspect, dest); #elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_RH_NO glm_perspective_default_rh_no(aspect, dest); #endif } /*! * @brief resize perspective matrix by aspect ratio ( width / height ) * this makes very easy to resize proj matrix when window /viewport * reized * * @param[in] aspect aspect ratio ( width / height ) * @param[in, out] proj perspective projection matrix */ CGLM_INLINE void glm_perspective_resize(float aspect, mat4 proj) { if (proj[0][0] == 0.0f) return; proj[0][0] = proj[1][1] / aspect; } /*! * @brief set up view matrix * * NOTE: The UP vector must not be parallel to the line of sight from * the eye point to the reference point * * @param[in] eye eye vector * @param[in] center center vector * @param[in] up up vector * @param[out] dest result matrix */ CGLM_INLINE void glm_lookat(vec3 eye, vec3 center, vec3 up, mat4 dest) { #if CGLM_CONFIG_CLIP_CONTROL & CGLM_CLIP_CONTROL_LH_BIT glm_lookat_lh(eye, center, up, dest); #elif CGLM_CONFIG_CLIP_CONTROL & CGLM_CLIP_CONTROL_RH_BIT glm_lookat_rh(eye, center, up, dest); #endif } /*! * @brief set up view matrix * * convenient wrapper for lookat: if you only have direction not target self * then this might be useful. Because you need to get target from direction. * * NOTE: The UP vector must not be parallel to the line of sight from * the eye point to the reference point * * @param[in] eye eye vector * @param[in] dir direction vector * @param[in] up up vector * @param[out] dest result matrix */ CGLM_INLINE void glm_look(vec3 eye, vec3 dir, vec3 up, mat4 dest) { #if CGLM_CONFIG_CLIP_CONTROL & CGLM_CLIP_CONTROL_LH_BIT glm_look_lh(eye, dir, up, dest); #elif CGLM_CONFIG_CLIP_CONTROL & CGLM_CLIP_CONTROL_RH_BIT glm_look_rh(eye, dir, up, dest); #endif } /*! * @brief set up view matrix * * convenient wrapper for look: if you only have direction and if you don't * care what UP vector is then this might be useful to create view matrix * * @param[in] eye eye vector * @param[in] dir direction vector * @param[out] dest result matrix */ CGLM_INLINE void glm_look_anyup(vec3 eye, vec3 dir, mat4 dest) { #if CGLM_CONFIG_CLIP_CONTROL & CGLM_CLIP_CONTROL_LH_BIT glm_look_anyup_lh(eye, dir, dest); #elif CGLM_CONFIG_CLIP_CONTROL & CGLM_CLIP_CONTROL_RH_BIT glm_look_anyup_rh(eye, dir, dest); #endif } /*! * @brief decomposes frustum values of perspective projection. * * @param[in] proj perspective projection matrix * @param[out] nearZ near * @param[out] farZ far * @param[out] top top * @param[out] bottom bottom * @param[out] left left * @param[out] right right */ CGLM_INLINE void glm_persp_decomp(mat4 proj, float * __restrict nearZ, float * __restrict farZ, float * __restrict top, float * __restrict bottom, float * __restrict left, float * __restrict right) { #if CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_LH_ZO glm_persp_decomp_lh_zo(proj, nearZ, farZ, top, bottom, left, right); #elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_LH_NO glm_persp_decomp_lh_no(proj, nearZ, farZ, top, bottom, left, right); #elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_RH_ZO glm_persp_decomp_rh_zo(proj, nearZ, farZ, top, bottom, left, right); #elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_RH_NO glm_persp_decomp_rh_no(proj, nearZ, farZ, top, bottom, left, right); #endif } /*! * @brief decomposes frustum values of perspective projection. * this makes easy to get all values at once * * @param[in] proj perspective projection matrix * @param[out] dest array */ CGLM_INLINE void glm_persp_decompv(mat4 proj, float dest[6]) { #if CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_LH_ZO glm_persp_decompv_lh_zo(proj, dest); #elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_LH_NO glm_persp_decompv_lh_no(proj, dest); #elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_RH_ZO glm_persp_decompv_rh_zo(proj, dest); #elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_RH_NO glm_persp_decompv_rh_no(proj, dest); #endif } /*! * @brief decomposes left and right values of perspective projection. * x stands for x axis (left / right axis) * * @param[in] proj perspective projection matrix * @param[out] left left * @param[out] right right */ CGLM_INLINE void glm_persp_decomp_x(mat4 proj, float * __restrict left, float * __restrict right) { #if CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_LH_ZO glm_persp_decomp_x_lh_zo(proj, left, right); #elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_LH_NO glm_persp_decomp_x_lh_no(proj, left, right); #elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_RH_ZO glm_persp_decomp_x_rh_zo(proj, left, right); #elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_RH_NO glm_persp_decomp_x_rh_no(proj, left, right); #endif } /*! * @brief decomposes top and bottom values of perspective projection. * y stands for y axis (top / bottom axis) * * @param[in] proj perspective projection matrix * @param[out] top top * @param[out] bottom bottom */ CGLM_INLINE void glm_persp_decomp_y(mat4 proj, float * __restrict top, float * __restrict bottom) { #if CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_LH_ZO glm_persp_decomp_y_lh_zo(proj, top, bottom); #elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_LH_NO glm_persp_decomp_y_lh_no(proj, top, bottom); #elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_RH_ZO glm_persp_decomp_y_rh_zo(proj, top, bottom); #elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_RH_NO glm_persp_decomp_y_rh_no(proj, top, bottom); #endif } /*! * @brief decomposes near and far values of perspective projection. * z stands for z axis (near / far axis) * * @param[in] proj perspective projection matrix * @param[out] nearZ near * @param[out] farZ far */ CGLM_INLINE void glm_persp_decomp_z(mat4 proj, float * __restrict nearZ, float * __restrict farZ) { #if CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_LH_ZO glm_persp_decomp_z_lh_zo(proj, nearZ, farZ); #elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_LH_NO glm_persp_decomp_z_lh_no(proj, nearZ, farZ); #elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_RH_ZO glm_persp_decomp_z_rh_zo(proj, nearZ, farZ); #elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_RH_NO glm_persp_decomp_z_rh_no(proj, nearZ, farZ); #endif } /*! * @brief decomposes far value of perspective projection. * * @param[in] proj perspective projection matrix * @param[out] farZ far */ CGLM_INLINE void glm_persp_decomp_far(mat4 proj, float * __restrict farZ) { #if CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_LH_ZO glm_persp_decomp_far_lh_zo(proj, farZ); #elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_LH_NO glm_persp_decomp_far_lh_no(proj, farZ); #elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_RH_ZO glm_persp_decomp_far_rh_zo(proj, farZ); #elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_RH_NO glm_persp_decomp_far_rh_no(proj, farZ); #endif } /*! * @brief decomposes near value of perspective projection. * * @param[in] proj perspective projection matrix * @param[out] nearZ near */ CGLM_INLINE void glm_persp_decomp_near(mat4 proj, float * __restrict nearZ) { #if CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_LH_ZO glm_persp_decomp_near_lh_zo(proj, nearZ); #elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_LH_NO glm_persp_decomp_near_lh_no(proj, nearZ); #elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_RH_ZO glm_persp_decomp_near_rh_zo(proj, nearZ); #elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_RH_NO glm_persp_decomp_near_rh_no(proj, nearZ); #endif } /*! * @brief returns sizes of near and far planes of perspective projection * * @param[in] proj perspective projection matrix * @param[in] fovy fovy (see brief) * @param[out] dest sizes order: [Wnear, Hnear, Wfar, Hfar] */ CGLM_INLINE void glm_persp_sizes(mat4 proj, float fovy, vec4 dest) { #if CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_LH_ZO glm_persp_sizes_lh_zo(proj, fovy, dest); #elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_LH_NO glm_persp_sizes_lh_no(proj, fovy, dest); #elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_RH_ZO glm_persp_sizes_rh_zo(proj, fovy, dest); #elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_RH_NO glm_persp_sizes_rh_no(proj, fovy, dest); #endif } #endif /* cglm_cam_h */ cglm-0.9.6/include/cglm/cglm.h000066400000000000000000000015441475344456400161340ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ #ifndef cglm_h #define cglm_h #include "common.h" #include "vec2.h" #include "vec3.h" #include "vec4.h" #include "ivec2.h" #include "ivec3.h" #include "ivec4.h" #include "mat4.h" #include "mat4x2.h" #include "mat4x3.h" #include "mat3.h" #include "mat3x2.h" #include "mat3x4.h" #include "mat2.h" #include "mat2x3.h" #include "mat2x4.h" #include "affine.h" #include "cam.h" #include "frustum.h" #include "quat.h" #include "euler.h" #include "plane.h" #include "noise.h" #include "aabb2d.h" #include "box.h" #include "color.h" #include "util.h" #include "io.h" #include "project.h" #include "sphere.h" #include "ease.h" #include "curve.h" #include "bezier.h" #include "ray.h" #include "affine2d.h" #endif /* cglm_h */ cglm-0.9.6/include/cglm/clipspace/000077500000000000000000000000001475344456400170005ustar00rootroot00000000000000cglm-0.9.6/include/cglm/clipspace/ortho_lh_no.h000066400000000000000000000122211475344456400214610ustar00rootroot00000000000000/* * 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_ortho_lh_no(float left, float right, float bottom, float top, float nearZ, float farZ, mat4 dest) CGLM_INLINE void glm_ortho_aabb_lh_no(vec3 box[2], mat4 dest) CGLM_INLINE void glm_ortho_aabb_p_lh_no(vec3 box[2], float padding, mat4 dest) CGLM_INLINE void glm_ortho_aabb_pz_lh_no(vec3 box[2], float padding, mat4 dest) CGLM_INLINE void glm_ortho_default_lh_no(float aspect, mat4 dest) CGLM_INLINE void glm_ortho_default_s_lh_no(float aspect, float size, mat4 dest) */ #ifndef cglm_ortho_lh_no_h #define cglm_ortho_lh_no_h #include "../common.h" #include "../plane.h" #include "../mat4.h" /*! * @brief set up orthographic projection matrix * with a left-hand coordinate system and a * clip-space of [-1, 1]. * * @param[in] left viewport.left * @param[in] right viewport.right * @param[in] bottom viewport.bottom * @param[in] top viewport.top * @param[in] nearZ near clipping plane * @param[in] farZ far clipping plane * @param[out] dest result matrix */ CGLM_INLINE void glm_ortho_lh_no(float left, float right, float bottom, float top, float nearZ, float farZ, mat4 dest) { float rl, tb, fn; glm_mat4_zero(dest); rl = 1.0f / (right - left); tb = 1.0f / (top - bottom); fn =-1.0f / (farZ - nearZ); dest[0][0] = 2.0f * rl; dest[1][1] = 2.0f * tb; dest[2][2] =-2.0f * fn; dest[3][0] =-(right + left) * rl; dest[3][1] =-(top + bottom) * tb; dest[3][2] = (farZ + nearZ) * fn; dest[3][3] = 1.0f; } /*! * @brief set up orthographic projection matrix using bounding box * with a left-hand coordinate system and a * clip-space of [-1, 1]. * * bounding box (AABB) must be in view space * * @param[in] box AABB * @param[out] dest result matrix */ CGLM_INLINE void glm_ortho_aabb_lh_no(vec3 box[2], mat4 dest) { glm_ortho_lh_no(box[0][0], box[1][0], box[0][1], box[1][1], -box[1][2], -box[0][2], dest); } /*! * @brief set up orthographic projection matrix using bounding box * with a left-hand coordinate system and a * clip-space of [-1, 1]. * * bounding box (AABB) must be in view space * * @param[in] box AABB * @param[in] padding padding * @param[out] dest result matrix */ CGLM_INLINE void glm_ortho_aabb_p_lh_no(vec3 box[2], float padding, mat4 dest) { glm_ortho_lh_no(box[0][0] - padding, box[1][0] + padding, box[0][1] - padding, box[1][1] + padding, -(box[1][2] + padding), -(box[0][2] - padding), dest); } /*! * @brief set up orthographic projection matrix using bounding box * with a left-hand coordinate system and a * clip-space of [-1, 1]. * * bounding box (AABB) must be in view space * * @param[in] box AABB * @param[in] padding padding for near and far * @param[out] dest result matrix */ CGLM_INLINE void glm_ortho_aabb_pz_lh_no(vec3 box[2], float padding, mat4 dest) { glm_ortho_lh_no(box[0][0], box[1][0], box[0][1], box[1][1], -(box[1][2] + padding), -(box[0][2] - padding), dest); } /*! * @brief set up unit orthographic projection matrix * with a left-hand coordinate system and a * clip-space of [-1, 1]. * * @param[in] aspect aspect ration ( width / height ) * @param[out] dest result matrix */ CGLM_INLINE void glm_ortho_default_lh_no(float aspect, mat4 dest) { if (aspect >= 1.0f) { glm_ortho_lh_no(-aspect, aspect, -1.0f, 1.0f, -100.0f, 100.0f, dest); return; } aspect = 1.0f / aspect; glm_ortho_lh_no(-1.0f, 1.0f, -aspect, aspect, -100.0f, 100.0f, dest); } /*! * @brief set up orthographic projection matrix with given CUBE size * with a left-hand coordinate system and a * clip-space of [-1, 1]. * * @param[in] aspect aspect ratio ( width / height ) * @param[in] size cube size * @param[out] dest result matrix */ CGLM_INLINE void glm_ortho_default_s_lh_no(float aspect, float size, mat4 dest) { if (aspect >= 1.0f) { glm_ortho_lh_no(-size * aspect, size * aspect, -size, size, -size - 100.0f, size + 100.0f, dest); return; } glm_ortho_lh_no(-size, size, -size / aspect, size / aspect, -size - 100.0f, size + 100.0f, dest); } #endif /*cglm_ortho_lh_no_h*/ cglm-0.9.6/include/cglm/clipspace/ortho_lh_zo.h000066400000000000000000000120771475344456400215060ustar00rootroot00000000000000/* * 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_ortho_lh_zo(float left, float right, float bottom, float top, float nearZ, float farZ, mat4 dest) CGLM_INLINE void glm_ortho_aabb_lh_zo(vec3 box[2], mat4 dest) CGLM_INLINE void glm_ortho_aabb_p_lh_zo(vec3 box[2], float padding, mat4 dest) CGLM_INLINE void glm_ortho_aabb_pz_lh_zo(vec3 box[2], float padding, mat4 dest) CGLM_INLINE void glm_ortho_default_lh_zo(float aspect, mat4 dest) CGLM_INLINE void glm_ortho_default_s_lh_zo(float aspect, float size, mat4 dest) */ #ifndef cglm_ortho_lh_zo_h #define cglm_ortho_lh_zo_h #include "../common.h" #include "../plane.h" #include "../mat4.h" /*! * @brief set up orthographic projection matrix with a left-hand coordinate * system and a clip-space of [0, 1]. * * @param[in] left viewport.left * @param[in] right viewport.right * @param[in] bottom viewport.bottom * @param[in] top viewport.top * @param[in] nearZ near clipping plane * @param[in] farZ far clipping plane * @param[out] dest result matrix */ CGLM_INLINE void glm_ortho_lh_zo(float left, float right, float bottom, float top, float nearZ, float farZ, mat4 dest) { float rl, tb, fn; glm_mat4_zero(dest); rl = 1.0f / (right - left); tb = 1.0f / (top - bottom); fn =-1.0f / (farZ - nearZ); dest[0][0] = 2.0f * rl; dest[1][1] = 2.0f * tb; dest[2][2] =-fn; dest[3][0] =-(right + left) * rl; dest[3][1] =-(top + bottom) * tb; dest[3][2] = nearZ * fn; dest[3][3] = 1.0f; } /*! * @brief set up orthographic projection matrix using bounding box * with a left-hand coordinate system and a clip-space of [0, 1]. * * bounding box (AABB) must be in view space * * @param[in] box AABB * @param[out] dest result matrix */ CGLM_INLINE void glm_ortho_aabb_lh_zo(vec3 box[2], mat4 dest) { glm_ortho_lh_zo(box[0][0], box[1][0], box[0][1], box[1][1], -box[1][2], -box[0][2], dest); } /*! * @brief set up orthographic projection matrix using bounding box * with a left-hand coordinate system and a clip-space of [0, 1]. * * bounding box (AABB) must be in view space * * @param[in] box AABB * @param[in] padding padding * @param[out] dest result matrix */ CGLM_INLINE void glm_ortho_aabb_p_lh_zo(vec3 box[2], float padding, mat4 dest) { glm_ortho_lh_zo(box[0][0] - padding, box[1][0] + padding, box[0][1] - padding, box[1][1] + padding, -(box[1][2] + padding), -(box[0][2] - padding), dest); } /*! * @brief set up orthographic projection matrix using bounding box * with a left-hand coordinate system and a clip-space of [0, 1]. * * bounding box (AABB) must be in view space * * @param[in] box AABB * @param[in] padding padding for near and far * @param[out] dest result matrix */ CGLM_INLINE void glm_ortho_aabb_pz_lh_zo(vec3 box[2], float padding, mat4 dest) { glm_ortho_lh_zo(box[0][0], box[1][0], box[0][1], box[1][1], -(box[1][2] + padding), -(box[0][2] - padding), dest); } /*! * @brief set up unit orthographic projection matrix * with a left-hand coordinate system and a clip-space of [0, 1]. * * @param[in] aspect aspect ration ( width / height ) * @param[out] dest result matrix */ CGLM_INLINE void glm_ortho_default_lh_zo(float aspect, mat4 dest) { if (aspect >= 1.0f) { glm_ortho_lh_zo(-aspect, aspect, -1.0f, 1.0f, -100.0f, 100.0f, dest); return; } aspect = 1.0f / aspect; glm_ortho_lh_zo(-1.0f, 1.0f, -aspect, aspect, -100.0f, 100.0f, dest); } /*! * @brief set up orthographic projection matrix with given CUBE size * with a left-hand coordinate system and a clip-space of [0, 1]. * * @param[in] aspect aspect ratio ( width / height ) * @param[in] size cube size * @param[out] dest result matrix */ CGLM_INLINE void glm_ortho_default_s_lh_zo(float aspect, float size, mat4 dest) { if (aspect >= 1.0f) { glm_ortho_lh_zo(-size * aspect, size * aspect, -size, size, -size - 100.0f, size + 100.0f, dest); return; } glm_ortho_lh_zo(-size, size, -size / aspect, size / aspect, -size - 100.0f, size + 100.0f, dest); } #endif /*cglm_ortho_lh_zo_h*/ cglm-0.9.6/include/cglm/clipspace/ortho_rh_no.h000066400000000000000000000122271475344456400214750ustar00rootroot00000000000000/* * 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_ortho_rh_no(float left, float right, float bottom, float top, float nearZ, float farZ, mat4 dest) CGLM_INLINE void glm_ortho_aabb_rh_no(vec3 box[2], mat4 dest) CGLM_INLINE void glm_ortho_aabb_p_rh_no(vec3 box[2], float padding, mat4 dest) CGLM_INLINE void glm_ortho_aabb_pz_rh_no(vec3 box[2], float padding, mat4 dest) CGLM_INLINE void glm_ortho_default_rh_no(float aspect, mat4 dest) CGLM_INLINE void glm_ortho_default_s_rh_no(float aspect, float size, mat4 dest) */ #ifndef cglm_ortho_rh_no_h #define cglm_ortho_rh_no_h #include "../common.h" #include "../plane.h" #include "../mat4.h" /*! * @brief set up orthographic projection matrix * with a right-hand coordinate system and a * clip-space of [-1, 1]. * * @param[in] left viewport.left * @param[in] right viewport.right * @param[in] bottom viewport.bottom * @param[in] top viewport.top * @param[in] nearZ near clipping plane * @param[in] farZ far clipping plane * @param[out] dest result matrix */ CGLM_INLINE void glm_ortho_rh_no(float left, float right, float bottom, float top, float nearZ, float farZ, mat4 dest) { float rl, tb, fn; glm_mat4_zero(dest); rl = 1.0f / (right - left); tb = 1.0f / (top - bottom); fn =-1.0f / (farZ - nearZ); dest[0][0] = 2.0f * rl; dest[1][1] = 2.0f * tb; dest[2][2] = 2.0f * fn; dest[3][0] =-(right + left) * rl; dest[3][1] =-(top + bottom) * tb; dest[3][2] = (farZ + nearZ) * fn; dest[3][3] = 1.0f; } /*! * @brief set up orthographic projection matrix using bounding box * with a right-hand coordinate system and a * clip-space of [-1, 1]. * * bounding box (AABB) must be in view space * * @param[in] box AABB * @param[out] dest result matrix */ CGLM_INLINE void glm_ortho_aabb_rh_no(vec3 box[2], mat4 dest) { glm_ortho_rh_no(box[0][0], box[1][0], box[0][1], box[1][1], -box[1][2], -box[0][2], dest); } /*! * @brief set up orthographic projection matrix using bounding box * with a right-hand coordinate system and a * clip-space of [-1, 1]. * * bounding box (AABB) must be in view space * * @param[in] box AABB * @param[in] padding padding * @param[out] dest result matrix */ CGLM_INLINE void glm_ortho_aabb_p_rh_no(vec3 box[2], float padding, mat4 dest) { glm_ortho_rh_no(box[0][0] - padding, box[1][0] + padding, box[0][1] - padding, box[1][1] + padding, -(box[1][2] + padding), -(box[0][2] - padding), dest); } /*! * @brief set up orthographic projection matrix using bounding box * with a right-hand coordinate system and a * clip-space of [-1, 1]. * * bounding box (AABB) must be in view space * * @param[in] box AABB * @param[in] padding padding for near and far * @param[out] dest result matrix */ CGLM_INLINE void glm_ortho_aabb_pz_rh_no(vec3 box[2], float padding, mat4 dest) { glm_ortho_rh_no(box[0][0], box[1][0], box[0][1], box[1][1], -(box[1][2] + padding), -(box[0][2] - padding), dest); } /*! * @brief set up unit orthographic projection matrix * with a right-hand coordinate system and a * clip-space of [-1, 1]. * * @param[in] aspect aspect ration ( width / height ) * @param[out] dest result matrix */ CGLM_INLINE void glm_ortho_default_rh_no(float aspect, mat4 dest) { if (aspect >= 1.0f) { glm_ortho_rh_no(-aspect, aspect, -1.0f, 1.0f, -100.0f, 100.0f, dest); return; } aspect = 1.0f / aspect; glm_ortho_rh_no(-1.0f, 1.0f, -aspect, aspect, -100.0f, 100.0f, dest); } /*! * @brief set up orthographic projection matrix with given CUBE size * with a right-hand coordinate system and a * clip-space of [-1, 1]. * * @param[in] aspect aspect ratio ( width / height ) * @param[in] size cube size * @param[out] dest result matrix */ CGLM_INLINE void glm_ortho_default_s_rh_no(float aspect, float size, mat4 dest) { if (aspect >= 1.0f) { glm_ortho_rh_no(-size * aspect, size * aspect, -size, size, -size - 100.0f, size + 100.0f, dest); return; } glm_ortho_rh_no(-size, size, -size / aspect, size / aspect, -size - 100.0f, size + 100.0f, dest); } #endif /*cglm_ortho_rh_no_h*/ cglm-0.9.6/include/cglm/clipspace/ortho_rh_zo.h000066400000000000000000000123211475344456400215040ustar00rootroot00000000000000/* * 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_ortho_rh_zo(float left, float right, float bottom, float top, float nearZ, float farZ, mat4 dest) CGLM_INLINE void glm_ortho_aabb_rh_zo(vec3 box[2], mat4 dest) CGLM_INLINE void glm_ortho_aabb_p_rh_zo(vec3 box[2], float padding, mat4 dest) CGLM_INLINE void glm_ortho_aabb_pz_rh_zo(vec3 box[2], float padding, mat4 dest) CGLM_INLINE void glm_ortho_default_rh_zo(float aspect, mat4 dest) CGLM_INLINE void glm_ortho_default_s_rh_zo(float aspect, float size, mat4 dest) */ #ifndef cglm_ortho_rh_zo_h #define cglm_ortho_rh_zo_h #include "../common.h" #include "../plane.h" #include "../mat4.h" /*! * @brief set up orthographic projection matrix with a right-hand coordinate * system and a clip-space of [0, 1]. * * @param[in] left viewport.left * @param[in] right viewport.right * @param[in] bottom viewport.bottom * @param[in] top viewport.top * @param[in] nearZ near clipping plane * @param[in] farZ far clipping plane * @param[out] dest result matrix */ CGLM_INLINE void glm_ortho_rh_zo(float left, float right, float bottom, float top, float nearZ, float farZ, mat4 dest) { float rl, tb, fn; glm_mat4_zero(dest); rl = 1.0f / (right - left); tb = 1.0f / (top - bottom); fn =-1.0f / (farZ - nearZ); dest[0][0] = 2.0f * rl; dest[1][1] = 2.0f * tb; dest[2][2] = fn; dest[3][0] =-(right + left) * rl; dest[3][1] =-(top + bottom) * tb; dest[3][2] = nearZ * fn; dest[3][3] = 1.0f; } /*! * @brief set up orthographic projection matrix using bounding box * with a right-hand coordinate system and a clip-space with depth * values from zero to one. * * bounding box (AABB) must be in view space * * @param[in] box AABB * @param[out] dest result matrix */ CGLM_INLINE void glm_ortho_aabb_rh_zo(vec3 box[2], mat4 dest) { glm_ortho_rh_zo(box[0][0], box[1][0], box[0][1], box[1][1], -box[1][2], -box[0][2], dest); } /*! * @brief set up orthographic projection matrix using bounding box * with a right-hand coordinate system and a clip-space with depth * values from zero to one. * * bounding box (AABB) must be in view space * * @param[in] box AABB * @param[in] padding padding * @param[out] dest result matrix */ CGLM_INLINE void glm_ortho_aabb_p_rh_zo(vec3 box[2], float padding, mat4 dest) { glm_ortho_rh_zo(box[0][0] - padding, box[1][0] + padding, box[0][1] - padding, box[1][1] + padding, -(box[1][2] + padding), -(box[0][2] - padding), dest); } /*! * @brief set up orthographic projection matrix using bounding box * with a right-hand coordinate system and a clip-space with depth * values from zero to one. * * bounding box (AABB) must be in view space * * @param[in] box AABB * @param[in] padding padding for near and far * @param[out] dest result matrix */ CGLM_INLINE void glm_ortho_aabb_pz_rh_zo(vec3 box[2], float padding, mat4 dest) { glm_ortho_rh_zo(box[0][0], box[1][0], box[0][1], box[1][1], -(box[1][2] + padding), -(box[0][2] - padding), dest); } /*! * @brief set up unit orthographic projection matrix with a right-hand * coordinate system and a clip-space of [0, 1]. * * @param[in] aspect aspect ration ( width / height ) * @param[out] dest result matrix */ CGLM_INLINE void glm_ortho_default_rh_zo(float aspect, mat4 dest) { if (aspect >= 1.0f) { glm_ortho_rh_zo(-aspect, aspect, -1.0f, 1.0f, -100.0f, 100.0f, dest); return; } aspect = 1.0f / aspect; glm_ortho_rh_zo(-1.0f, 1.0f, -aspect, aspect, -100.0f, 100.0f, dest); } /*! * @brief set up orthographic projection matrix with given CUBE size * with a right-hand coordinate system and a clip-space with depth * values from zero to one. * * @param[in] aspect aspect ratio ( width / height ) * @param[in] size cube size * @param[out] dest result matrix */ CGLM_INLINE void glm_ortho_default_s_rh_zo(float aspect, float size, mat4 dest) { if (aspect >= 1.0f) { glm_ortho_rh_zo(-size * aspect, size * aspect, -size, size, -size - 100.0f, size + 100.0f, dest); return; } glm_ortho_rh_zo(-size, size, -size / aspect, size / aspect, -size - 100.0f, size + 100.0f, dest); } #endif /*cglm_ortho_rh_zo_h*/ cglm-0.9.6/include/cglm/clipspace/persp.h000066400000000000000000000020701475344456400203010ustar00rootroot00000000000000/* * 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_persp_decomp_far(mat4 proj, float *farZ) CGLM_INLINE float glm_persp_fovy(mat4 proj) CGLM_INLINE float glm_persp_aspect(mat4 proj) CGLM_INLINE void glm_persp_sizes(mat4 proj, float fovy, vec4 dest) */ #ifndef cglm_persp_h #define cglm_persp_h #include "../common.h" #include "../plane.h" #include "../mat4.h" /*! * @brief returns field of view angle along the Y-axis (in radians) * * if you need to degrees, use glm_deg to convert it or use this: * fovy_deg = glm_deg(glm_persp_fovy(projMatrix)) * * @param[in] proj perspective projection matrix */ CGLM_INLINE float glm_persp_fovy(mat4 proj) { return 2.0f * atanf(1.0f / proj[1][1]); } /*! * @brief returns aspect ratio of perspective projection * * @param[in] proj perspective projection matrix */ CGLM_INLINE float glm_persp_aspect(mat4 proj) { return proj[1][1] / proj[0][0]; } #endif /* cglm_persp_h */ cglm-0.9.6/include/cglm/clipspace/persp_lh_no.h000066400000000000000000000264131475344456400214670ustar00rootroot00000000000000/* * 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_frustum_lh_no(float left, float right, float bottom, float top, float nearZ, float farZ, mat4 dest) CGLM_INLINE void glm_perspective_lh_no(float fovy, float aspect, float nearZ, float farZ, mat4 dest) CGLM_INLINE void glm_perspective_default_lh_no(float aspect, mat4 dest) CGLM_INLINE void glm_perspective_resize_lh_no(float aspect, mat4 proj) CGLM_INLINE void glm_persp_move_far_lh_no(mat4 proj, float deltaFar) CGLM_INLINE void glm_persp_decomp_lh_no(mat4 proj, float * __restrict nearZ, float * __restrict farZ, float * __restrict top, float * __restrict bottom, float * __restrict left, float * __restrict right) CGLM_INLINE void glm_persp_decompv_lh_no(mat4 proj, float dest[6]) CGLM_INLINE void glm_persp_decomp_x_lh_no(mat4 proj, float * __restrict left, float * __restrict right) CGLM_INLINE void glm_persp_decomp_y_lh_no(mat4 proj, float * __restrict top, float * __restrict bottom) CGLM_INLINE void glm_persp_decomp_z_lh_no(mat4 proj, float * __restrict nearZ, float * __restrict farZ) CGLM_INLINE void glm_persp_decomp_far_lh_no(mat4 proj, float * __restrict farZ) CGLM_INLINE void glm_persp_decomp_near_lh_no(mat4 proj, float * __restrict nearZ) CGLM_INLINE void glm_persp_sizes_lh_no(mat4 proj, float fovy, vec4 dest) */ #ifndef cglm_persp_lh_no_h #define cglm_persp_lh_no_h #include "../common.h" #include "persp.h" /*! * @brief set up perspective peprojection matrix * with a left-hand coordinate system and a * clip-space of [-1, 1]. * * @param[in] left viewport.left * @param[in] right viewport.right * @param[in] bottom viewport.bottom * @param[in] top viewport.top * @param[in] nearZ near clipping plane * @param[in] farZ far clipping plane * @param[out] dest result matrix */ CGLM_INLINE void glm_frustum_lh_no(float left, float right, float bottom, float top, float nearZ, float farZ, mat4 dest) { float rl, tb, fn, nv; glm_mat4_zero(dest); rl = 1.0f / (right - left); tb = 1.0f / (top - bottom); fn =-1.0f / (farZ - nearZ); nv = 2.0f * nearZ; dest[0][0] = nv * rl; dest[1][1] = nv * tb; dest[2][0] = (right + left) * rl; dest[2][1] = (top + bottom) * tb; dest[2][2] =-(farZ + nearZ) * fn; dest[2][3] = 1.0f; dest[3][2] = farZ * nv * fn; } /*! * @brief set up perspective projection matrix * with a left-hand coordinate system and a * clip-space of [-1, 1]. * * @param[in] fovy field of view angle * @param[in] aspect aspect ratio ( width / height ) * @param[in] nearZ near clipping plane * @param[in] farZ far clipping planes * @param[out] dest result matrix */ CGLM_INLINE void glm_perspective_lh_no(float fovy, float aspect, float nearZ, float farZ, mat4 dest) { float f, fn; glm_mat4_zero(dest); f = 1.0f / tanf(fovy * 0.5f); fn = 1.0f / (nearZ - farZ); dest[0][0] = f / aspect; dest[1][1] = f; dest[2][2] =-(nearZ + farZ) * fn; dest[2][3] = 1.0f; dest[3][2] = 2.0f * nearZ * farZ * fn; } /*! * @brief set up perspective projection matrix with default near/far * and angle values with a left-hand coordinate system and a * clip-space of [-1, 1]. * * @param[in] aspect aspect ratio ( width / height ) * @param[out] dest result matrix */ CGLM_INLINE void glm_perspective_default_lh_no(float aspect, mat4 dest) { glm_perspective_lh_no(GLM_PI_4f, aspect, 0.01f, 100.0f, dest); } /*! * @brief resize perspective matrix by aspect ratio ( width / height ) * this makes very easy to resize proj matrix when window /viewport * resized with a left-hand coordinate system and a * clip-space of [-1, 1]. * * @param[in] aspect aspect ratio ( width / height ) * @param[in, out] proj perspective projection matrix */ CGLM_INLINE void glm_perspective_resize_lh_no(float aspect, mat4 proj) { if (proj[0][0] == 0.0f) return; proj[0][0] = proj[1][1] / aspect; } /*! * @brief extend perspective projection matrix's far distance * with a left-hand coordinate system and a * clip-space of [-1, 1]. * * this function does not guarantee far >= near, be aware of that! * * @param[in, out] proj projection matrix to extend * @param[in] deltaFar distance from existing far (negative to shink) */ CGLM_INLINE void glm_persp_move_far_lh_no(mat4 proj, float deltaFar) { float fn, farZ, nearZ, p22, p32; p22 = -proj[2][2]; p32 = proj[3][2]; nearZ = p32 / (p22 - 1.0f); farZ = p32 / (p22 + 1.0f) + deltaFar; fn = 1.0f / (nearZ - farZ); proj[2][2] = -(farZ + nearZ) * fn; proj[3][2] = 2.0f * nearZ * farZ * fn; } /*! * @brief decomposes frustum values of perspective projection * with a left-hand coordinate system and a * clip-space of [-1, 1]. * * @param[in] proj perspective projection matrix * @param[out] nearZ near * @param[out] farZ far * @param[out] top top * @param[out] bottom bottom * @param[out] left left * @param[out] right right */ CGLM_INLINE void glm_persp_decomp_lh_no(mat4 proj, float * __restrict nearZ, float * __restrict farZ, float * __restrict top, float * __restrict bottom, float * __restrict left, float * __restrict right) { float m00, m11, m20, m21, m22, m32, n, f; float n_m11, n_m00; m00 = proj[0][0]; m11 = proj[1][1]; m20 = proj[2][0]; m21 = proj[2][1]; m22 =-proj[2][2]; m32 = proj[3][2]; n = m32 / (m22 - 1.0f); f = m32 / (m22 + 1.0f); n_m11 = n / m11; n_m00 = n / m00; *nearZ = n; *farZ = f; *bottom = n_m11 * (m21 - 1.0f); *top = n_m11 * (m21 + 1.0f); *left = n_m00 * (m20 - 1.0f); *right = n_m00 * (m20 + 1.0f); } /*! * @brief decomposes frustum values of perspective projection * with a left-hand coordinate system and a * clip-space of [-1, 1]. * this makes easy to get all values at once * * @param[in] proj perspective projection matrix * @param[out] dest array */ CGLM_INLINE void glm_persp_decompv_lh_no(mat4 proj, float dest[6]) { glm_persp_decomp_lh_no(proj, &dest[0], &dest[1], &dest[2], &dest[3], &dest[4], &dest[5]); } /*! * @brief decomposes left and right values of perspective projection * with a left-hand coordinate system and a * clip-space of [-1, 1]. * x stands for x axis (left / right axis) * * @param[in] proj perspective projection matrix * @param[out] left left * @param[out] right right */ CGLM_INLINE void glm_persp_decomp_x_lh_no(mat4 proj, float * __restrict left, float * __restrict right) { float nearZ, m20, m00, m22; m00 = proj[0][0]; m20 = proj[2][0]; m22 =-proj[2][2]; nearZ = proj[3][2] / (m22 - 1.0f); *left = nearZ * (m20 - 1.0f) / m00; *right = nearZ * (m20 + 1.0f) / m00; } /*! * @brief decomposes top and bottom values of perspective projection * with a left-hand coordinate system and a * clip-space of [-1, 1]. * y stands for y axis (top / bottom axis) * * @param[in] proj perspective projection matrix * @param[out] top top * @param[out] bottom bottom */ CGLM_INLINE void glm_persp_decomp_y_lh_no(mat4 proj, float * __restrict top, float * __restrict bottom) { float nearZ, m21, m11, m22; m21 = proj[2][1]; m11 = proj[1][1]; m22 =-proj[2][2]; nearZ = proj[3][2] / (m22 - 1.0f); *bottom = nearZ * (m21 - 1.0f) / m11; *top = nearZ * (m21 + 1.0f) / m11; } /*! * @brief decomposes near and far values of perspective projection * with a left-hand coordinate system and a * clip-space of [-1, 1]. * z stands for z axis (near / far axis) * * @param[in] proj perspective projection matrix * @param[out] nearZ near * @param[out] farZ far */ CGLM_INLINE void glm_persp_decomp_z_lh_no(mat4 proj, float * __restrict nearZ, float * __restrict farZ) { float m32, m22; m32 = proj[3][2]; m22 =-proj[2][2]; *nearZ = m32 / (m22 - 1.0f); *farZ = m32 / (m22 + 1.0f); } /*! * @brief decomposes far value of perspective projection * with a left-hand coordinate system and a * clip-space of [-1, 1]. * * @param[in] proj perspective projection matrix * @param[out] farZ far */ CGLM_INLINE void glm_persp_decomp_far_lh_no(mat4 proj, float * __restrict farZ) { *farZ = proj[3][2] / (-proj[2][2] + 1.0f); } /*! * @brief decomposes near value of perspective projection * with a left-hand coordinate system and a * clip-space of [-1, 1]. * * @param[in] proj perspective projection matrix * @param[out] nearZ near */ CGLM_INLINE void glm_persp_decomp_near_lh_no(mat4 proj, float * __restrict nearZ) { *nearZ = proj[3][2] / (-proj[2][2] - 1.0f); } /*! * @brief returns sizes of near and far planes of perspective projection * with a left-hand coordinate system and a * clip-space of [-1, 1]. * * @param[in] proj perspective projection matrix * @param[in] fovy fovy (see brief) * @param[out] dest sizes order: [Wnear, Hnear, Wfar, Hfar] */ CGLM_INLINE void glm_persp_sizes_lh_no(mat4 proj, float fovy, vec4 dest) { float t, a, nearZ, farZ; t = 2.0f * tanf(fovy * 0.5f); a = glm_persp_aspect(proj); glm_persp_decomp_z_lh_no(proj, &nearZ, &farZ); dest[1] = t * nearZ; dest[3] = t * farZ; dest[0] = a * dest[1]; dest[2] = a * dest[3]; } /*! * @brief returns field of view angle along the Y-axis (in radians) * with a left-hand coordinate system and a clip-space of [-1, 1]. * * if you need to degrees, use glm_deg to convert it or use this: * fovy_deg = glm_deg(glm_persp_fovy(projMatrix)) * * @param[in] proj perspective projection matrix */ CGLM_INLINE float glm_persp_fovy_lh_no(mat4 proj) { return glm_persp_fovy(proj); } /*! * @brief returns aspect ratio of perspective projection * with a left-hand coordinate system and a clip-space of [-1, 1]. * * @param[in] proj perspective projection matrix */ CGLM_INLINE float glm_persp_aspect_lh_no(mat4 proj) { return glm_persp_aspect(proj); } #endif /*cglm_cam_lh_no_h*/ cglm-0.9.6/include/cglm/clipspace/persp_lh_zo.h000066400000000000000000000261131475344456400215000ustar00rootroot00000000000000/* * 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_frustum_lh_zo(float left, float right, float bottom, float top, float nearZ, float farZ, mat4 dest) CGLM_INLINE void glm_perspective_lh_zo(float fovy, float aspect, float nearZ, float farZ, mat4 dest) CGLM_INLINE void glm_perspective_default_lh_zo(float aspect, mat4 dest) CGLM_INLINE void glm_perspective_resize_lh_zo(float aspect, mat4 proj) CGLM_INLINE void glm_persp_move_far_lh_zo(mat4 proj, float deltaFar) CGLM_INLINE void glm_persp_decomp_lh_zo(mat4 proj, float * __restrict nearZ, float * __restrict farZ, float * __restrict top, float * __restrict bottom, float * __restrict left, float * __restrict right) CGLM_INLINE void glm_persp_decompv_lh_zo(mat4 proj, float dest[6]) CGLM_INLINE void glm_persp_decomp_x_lh_zo(mat4 proj, float * __restrict left, float * __restrict right) CGLM_INLINE void glm_persp_decomp_y_lh_zo(mat4 proj, float * __restrict top, float * __restrict bottom) CGLM_INLINE void glm_persp_decomp_z_lh_zo(mat4 proj, float * __restrict nearZ, float * __restrict farZ) CGLM_INLINE void glm_persp_decomp_far_lh_zo(mat4 proj, float * __restrict farZ) CGLM_INLINE void glm_persp_decomp_near_lh_zo(mat4 proj, float * __restrict nearZ) CGLM_INLINE void glm_persp_sizes_lh_zo(mat4 proj, float fovy, vec4 dest) */ #ifndef cglm_persp_lh_zo_h #define cglm_persp_lh_zo_h #include "../common.h" #include "persp.h" /*! * @brief set up perspective peprojection matrix with a left-hand coordinate * system and a clip-space of [0, 1]. * * @param[in] left viewport.left * @param[in] right viewport.right * @param[in] bottom viewport.bottom * @param[in] top viewport.top * @param[in] nearZ near clipping plane * @param[in] farZ far clipping plane * @param[out] dest result matrix */ CGLM_INLINE void glm_frustum_lh_zo(float left, float right, float bottom, float top, float nearZ, float farZ, mat4 dest) { float rl, tb, fn, nv; glm_mat4_zero(dest); rl = 1.0f / (right - left); tb = 1.0f / (top - bottom); fn =-1.0f / (farZ - nearZ); nv = 2.0f * nearZ; dest[0][0] = nv * rl; dest[1][1] = nv * tb; dest[2][0] = (right + left) * rl; dest[2][1] = (top + bottom) * tb; dest[2][2] =-farZ * fn; dest[2][3] = 1.0f; dest[3][2] = farZ * nearZ * fn; } /*! * @brief set up perspective projection matrix with a left-hand coordinate * system and a clip-space of [0, 1]. * * @param[in] fovy field of view angle * @param[in] aspect aspect ratio ( width / height ) * @param[in] nearZ near clipping plane * @param[in] farZ far clipping planes * @param[out] dest result matrix */ CGLM_INLINE void glm_perspective_lh_zo(float fovy, float aspect, float nearZ, float farZ, mat4 dest) { float f, fn; glm_mat4_zero(dest); f = 1.0f / tanf(fovy * 0.5f); fn = 1.0f / (nearZ - farZ); dest[0][0] = f / aspect; dest[1][1] = f; dest[2][2] =-farZ * fn; dest[2][3] = 1.0f; dest[3][2] = nearZ * farZ * fn; } /*! * @brief extend perspective projection matrix's far distance with a * left-hand coordinate system and a clip-space with depth values * from zero to one. * * this function does not guarantee far >= near, be aware of that! * * @param[in, out] proj projection matrix to extend * @param[in] deltaFar distance from existing far (negative to shink) */ CGLM_INLINE void glm_persp_move_far_lh_zo(mat4 proj, float deltaFar) { float fn, farZ, nearZ, p22, p32; p22 = -proj[2][2]; p32 = proj[3][2]; nearZ = p32 / p22; farZ = p32 / (p22 + 1.0f) + deltaFar; fn = 1.0f / (nearZ - farZ); proj[2][2] = -farZ * fn; proj[3][2] = nearZ * farZ * fn; } /*! * @brief set up perspective projection matrix with default near/far * and angle values with a left-hand coordinate system and a * clip-space of [0, 1]. * * @param[in] aspect aspect ratio ( width / height ) * @param[out] dest result matrix */ CGLM_INLINE void glm_perspective_default_lh_zo(float aspect, mat4 dest) { glm_perspective_lh_zo(GLM_PI_4f, aspect, 0.01f, 100.0f, dest); } /*! * @brief resize perspective matrix by aspect ratio ( width / height ) * this makes very easy to resize proj matrix when window /viewport * reized * * @param[in] aspect aspect ratio ( width / height ) * @param[in, out] proj perspective projection matrix */ CGLM_INLINE void glm_perspective_resize_lh_zo(float aspect, mat4 proj) { if (proj[0][0] == 0.0f) return; proj[0][0] = proj[1][1] / aspect; } /*! * @brief decomposes frustum values of perspective projection * with angle values with a left-hand coordinate system and a * clip-space of [0, 1]. * * @param[in] proj perspective projection matrix * @param[out] nearZ near * @param[out] farZ far * @param[out] top top * @param[out] bottom bottom * @param[out] left left * @param[out] right right */ CGLM_INLINE void glm_persp_decomp_lh_zo(mat4 proj, float * __restrict nearZ, float * __restrict farZ, float * __restrict top, float * __restrict bottom, float * __restrict left, float * __restrict right) { float m00, m11, m20, m21, m22, m32, n, f; float n_m11, n_m00; m00 = proj[0][0]; m11 = proj[1][1]; m20 = proj[2][0]; m21 = proj[2][1]; m22 =-proj[2][2]; m32 = proj[3][2]; n = m32 / m22; f = m32 / (m22 + 1.0f); n_m11 = n / m11; n_m00 = n / m00; *nearZ = n; *farZ = f; *bottom = n_m11 * (m21 - 1.0f); *top = n_m11 * (m21 + 1.0f); *left = n_m00 * (m20 - 1.0f); *right = n_m00 * (m20 + 1.0f); } /*! * @brief decomposes frustum values of perspective projection * with angle values with a left-hand coordinate system and a * clip-space of [0, 1]. * this makes easy to get all values at once * * @param[in] proj perspective projection matrix * @param[out] dest array */ CGLM_INLINE void glm_persp_decompv_lh_zo(mat4 proj, float dest[6]) { glm_persp_decomp_lh_zo(proj, &dest[0], &dest[1], &dest[2], &dest[3], &dest[4], &dest[5]); } /*! * @brief decomposes left and right values of perspective projection (ZO). * x stands for x axis (left / right axis) * * @param[in] proj perspective projection matrix * @param[out] left left * @param[out] right right */ CGLM_INLINE void glm_persp_decomp_x_lh_zo(mat4 proj, float * __restrict left, float * __restrict right) { float nearZ, m20, m00; m00 = proj[0][0]; m20 = proj[2][0]; nearZ = proj[3][2] / (proj[3][3]); *left = nearZ * (m20 - 1.0f) / m00; *right = nearZ * (m20 + 1.0f) / m00; } /*! * @brief decomposes top and bottom values of perspective projection * with angle values with a left-hand coordinate system and a * clip-space of [0, 1]. * y stands for y axis (top / bottom axis) * * @param[in] proj perspective projection matrix * @param[out] top top * @param[out] bottom bottom */ CGLM_INLINE void glm_persp_decomp_y_lh_zo(mat4 proj, float * __restrict top, float * __restrict bottom) { float nearZ, m21, m11; m21 = proj[2][1]; m11 = proj[1][1]; nearZ = proj[3][2] / (proj[3][3]); *bottom = nearZ * (m21 - 1) / m11; *top = nearZ * (m21 + 1) / m11; } /*! * @brief decomposes near and far values of perspective projection * with angle values with a left-hand coordinate system and a * clip-space of [0, 1]. * z stands for z axis (near / far axis) * * @param[in] proj perspective projection matrix * @param[out] nearZ near * @param[out] farZ far */ CGLM_INLINE void glm_persp_decomp_z_lh_zo(mat4 proj, float * __restrict nearZ, float * __restrict farZ) { float m32, m22; m32 = proj[3][2]; m22 = -proj[2][2]; *nearZ = m32 / m22; *farZ = m32 / (m22 + 1.0f); } /*! * @brief decomposes far value of perspective projection * with angle values with a left-hand coordinate system and a * clip-space of [0, 1]. * * @param[in] proj perspective projection matrix * @param[out] farZ far */ CGLM_INLINE void glm_persp_decomp_far_lh_zo(mat4 proj, float * __restrict farZ) { *farZ = proj[3][2] / (-proj[2][2] + 1.0f); } /*! * @brief decomposes near value of perspective projection * with angle values with a left-hand coordinate system and a * clip-space of [0, 1]. * * @param[in] proj perspective projection matrix * @param[out] nearZ near */ CGLM_INLINE void glm_persp_decomp_near_lh_zo(mat4 proj, float * __restrict nearZ) { *nearZ = proj[3][2] / -proj[2][2]; } /*! * @brief returns sizes of near and far planes of perspective projection * with a left-hand coordinate system and a * clip-space of [0, 1]. * * @param[in] proj perspective projection matrix * @param[in] fovy fovy (see brief) * @param[out] dest sizes order: [Wnear, Hnear, Wfar, Hfar] */ CGLM_INLINE void glm_persp_sizes_lh_zo(mat4 proj, float fovy, vec4 dest) { float t, a, nearZ, farZ; t = 2.0f * tanf(fovy * 0.5f); a = glm_persp_aspect(proj); glm_persp_decomp_z_lh_zo(proj, &nearZ, &farZ); dest[1] = t * nearZ; dest[3] = t * farZ; dest[0] = a * dest[1]; dest[2] = a * dest[3]; } /*! * @brief returns field of view angle along the Y-axis (in radians) * with a left-hand coordinate system and a clip-space of [0, 1]. * * if you need to degrees, use glm_deg to convert it or use this: * fovy_deg = glm_deg(glm_persp_fovy(projMatrix)) * * @param[in] proj perspective projection matrix */ CGLM_INLINE float glm_persp_fovy_lh_zo(mat4 proj) { return glm_persp_fovy(proj); } /*! * @brief returns aspect ratio of perspective projection * with a left-hand coordinate system and a clip-space of [0, 1]. * * @param[in] proj perspective projection matrix */ CGLM_INLINE float glm_persp_aspect_lh_zo(mat4 proj) { return glm_persp_aspect(proj); } #endif /*cglm_persp_lh_zo_h*/ cglm-0.9.6/include/cglm/clipspace/persp_rh_no.h000066400000000000000000000264171475344456400215010ustar00rootroot00000000000000/* * 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_frustum_rh_no(float left, float right, float bottom, float top, float nearZ, float farZ, mat4 dest) CGLM_INLINE void glm_perspective_rh_no(float fovy, float aspect, float nearZ, float farZ, mat4 dest) CGLM_INLINE void glm_perspective_default_rh_no(float aspect, mat4 dest) CGLM_INLINE void glm_perspective_resize_rh_no(float aspect, mat4 proj) CGLM_INLINE void glm_persp_move_far_rh_no(mat4 proj, float deltaFar) CGLM_INLINE void glm_persp_decomp_rh_no(mat4 proj, float * __restrict nearZ, float * __restrict farZ, float * __restrict top, float * __restrict bottom, float * __restrict left, float * __restrict right) CGLM_INLINE void glm_persp_decompv_rh_no(mat4 proj, float dest[6]) CGLM_INLINE void glm_persp_decomp_x_rh_no(mat4 proj, float * __restrict left, float * __restrict right) CGLM_INLINE void glm_persp_decomp_y_rh_no(mat4 proj, float * __restrict top, float * __restrict bottom) CGLM_INLINE void glm_persp_decomp_z_rh_no(mat4 proj, float * __restrict nearZ, float * __restrict farZ) CGLM_INLINE void glm_persp_decomp_far_rh_no(mat4 proj, float * __restrict farZ) CGLM_INLINE void glm_persp_decomp_near_rh_no(mat4 proj, float * __restrict nearZ) CGLM_INLINE void glm_persp_sizes_rh_no(mat4 proj, float fovy, vec4 dest) */ #ifndef cglm_persp_rh_no_h #define cglm_persp_rh_no_h #include "../common.h" #include "persp.h" /*! * @brief set up perspective peprojection matrix * with a right-hand coordinate system and a * clip-space of [-1, 1]. * * @param[in] left viewport.left * @param[in] right viewport.right * @param[in] bottom viewport.bottom * @param[in] top viewport.top * @param[in] nearZ near clipping plane * @param[in] farZ far clipping plane * @param[out] dest result matrix */ CGLM_INLINE void glm_frustum_rh_no(float left, float right, float bottom, float top, float nearZ, float farZ, mat4 dest) { float rl, tb, fn, nv; glm_mat4_zero(dest); rl = 1.0f / (right - left); tb = 1.0f / (top - bottom); fn =-1.0f / (farZ - nearZ); nv = 2.0f * nearZ; dest[0][0] = nv * rl; dest[1][1] = nv * tb; dest[2][0] = (right + left) * rl; dest[2][1] = (top + bottom) * tb; dest[2][2] = (farZ + nearZ) * fn; dest[2][3] =-1.0f; dest[3][2] = farZ * nv * fn; } /*! * @brief set up perspective projection matrix * with a right-hand coordinate system and a * clip-space of [-1, 1]. * * @param[in] fovy field of view angle * @param[in] aspect aspect ratio ( width / height ) * @param[in] nearZ near clipping plane * @param[in] farZ far clipping planes * @param[out] dest result matrix */ CGLM_INLINE void glm_perspective_rh_no(float fovy, float aspect, float nearZ, float farZ, mat4 dest) { float f, fn; glm_mat4_zero(dest); f = 1.0f / tanf(fovy * 0.5f); fn = 1.0f / (nearZ - farZ); dest[0][0] = f / aspect; dest[1][1] = f; dest[2][2] = (nearZ + farZ) * fn; dest[2][3] =-1.0f; dest[3][2] = 2.0f * nearZ * farZ * fn; } /*! * @brief set up perspective projection matrix with default near/far * and angle values with a right-hand coordinate system and a * clip-space of [-1, 1]. * * @param[in] aspect aspect ratio ( width / height ) * @param[out] dest result matrix */ CGLM_INLINE void glm_perspective_default_rh_no(float aspect, mat4 dest) { glm_perspective_rh_no(GLM_PI_4f, aspect, 0.01f, 100.0f, dest); } /*! * @brief resize perspective matrix by aspect ratio ( width / height ) * this makes very easy to resize proj matrix when window /viewport * resized with a right-hand coordinate system and a * clip-space of [-1, 1]. * * @param[in] aspect aspect ratio ( width / height ) * @param[in, out] proj perspective projection matrix */ CGLM_INLINE void glm_perspective_resize_rh_no(float aspect, mat4 proj) { if (proj[0][0] == 0.0f) return; proj[0][0] = proj[1][1] / aspect; } /*! * @brief extend perspective projection matrix's far distance * with a right-hand coordinate system and a * clip-space of [-1, 1]. * * this function does not guarantee far >= near, be aware of that! * * @param[in, out] proj projection matrix to extend * @param[in] deltaFar distance from existing far (negative to shink) */ CGLM_INLINE void glm_persp_move_far_rh_no(mat4 proj, float deltaFar) { float fn, farZ, nearZ, p22, p32; p22 = proj[2][2]; p32 = proj[3][2]; nearZ = p32 / (p22 - 1.0f); farZ = p32 / (p22 + 1.0f) + deltaFar; fn = 1.0f / (nearZ - farZ); proj[2][2] = (farZ + nearZ) * fn; proj[3][2] = 2.0f * nearZ * farZ * fn; } /*! * @brief decomposes frustum values of perspective projection * with a right-hand coordinate system and a * clip-space of [-1, 1]. * * @param[in] proj perspective projection matrix * @param[out] nearZ near * @param[out] farZ far * @param[out] top top * @param[out] bottom bottom * @param[out] left left * @param[out] right right */ CGLM_INLINE void glm_persp_decomp_rh_no(mat4 proj, float * __restrict nearZ, float * __restrict farZ, float * __restrict top, float * __restrict bottom, float * __restrict left, float * __restrict right) { float m00, m11, m20, m21, m22, m32, n, f; float n_m11, n_m00; m00 = proj[0][0]; m11 = proj[1][1]; m20 = proj[2][0]; m21 = proj[2][1]; m22 = proj[2][2]; m32 = proj[3][2]; n = m32 / (m22 - 1.0f); f = m32 / (m22 + 1.0f); n_m11 = n / m11; n_m00 = n / m00; *nearZ = n; *farZ = f; *bottom = n_m11 * (m21 - 1.0f); *top = n_m11 * (m21 + 1.0f); *left = n_m00 * (m20 - 1.0f); *right = n_m00 * (m20 + 1.0f); } /*! * @brief decomposes frustum values of perspective projection * with a right-hand coordinate system and a * clip-space of [-1, 1]. * this makes easy to get all values at once * * @param[in] proj perspective projection matrix * @param[out] dest array */ CGLM_INLINE void glm_persp_decompv_rh_no(mat4 proj, float dest[6]) { glm_persp_decomp_rh_no(proj, &dest[0], &dest[1], &dest[2], &dest[3], &dest[4], &dest[5]); } /*! * @brief decomposes left and right values of perspective projection * with a right-hand coordinate system and a * clip-space of [-1, 1]. * x stands for x axis (left / right axis) * * @param[in] proj perspective projection matrix * @param[out] left left * @param[out] right right */ CGLM_INLINE void glm_persp_decomp_x_rh_no(mat4 proj, float * __restrict left, float * __restrict right) { float nearZ, m20, m00, m22; m00 = proj[0][0]; m20 = proj[2][0]; m22 = proj[2][2]; nearZ = proj[3][2] / (m22 - 1.0f); *left = nearZ * (m20 - 1.0f) / m00; *right = nearZ * (m20 + 1.0f) / m00; } /*! * @brief decomposes top and bottom values of perspective projection * with a right-hand coordinate system and a * clip-space of [-1, 1]. * y stands for y axis (top / bottom axis) * * @param[in] proj perspective projection matrix * @param[out] top top * @param[out] bottom bottom */ CGLM_INLINE void glm_persp_decomp_y_rh_no(mat4 proj, float * __restrict top, float * __restrict bottom) { float nearZ, m21, m11, m22; m21 = proj[2][1]; m11 = proj[1][1]; m22 = proj[2][2]; nearZ = proj[3][2] / (m22 - 1.0f); *bottom = nearZ * (m21 - 1.0f) / m11; *top = nearZ * (m21 + 1.0f) / m11; } /*! * @brief decomposes near and far values of perspective projection * with a right-hand coordinate system and a * clip-space of [-1, 1]. * z stands for z axis (near / far axis) * * @param[in] proj perspective projection matrix * @param[out] nearZ near * @param[out] farZ far */ CGLM_INLINE void glm_persp_decomp_z_rh_no(mat4 proj, float * __restrict nearZ, float * __restrict farZ) { float m32, m22; m32 = proj[3][2]; m22 = proj[2][2]; *nearZ = m32 / (m22 - 1.0f); *farZ = m32 / (m22 + 1.0f); } /*! * @brief decomposes far value of perspective projection * with a right-hand coordinate system and a * clip-space of [-1, 1]. * * @param[in] proj perspective projection matrix * @param[out] farZ far */ CGLM_INLINE void glm_persp_decomp_far_rh_no(mat4 proj, float * __restrict farZ) { *farZ = proj[3][2] / (proj[2][2] + 1.0f); } /*! * @brief decomposes near value of perspective projection * with a right-hand coordinate system and a * clip-space of [-1, 1]. * * @param[in] proj perspective projection matrix * @param[out] nearZ near */ CGLM_INLINE void glm_persp_decomp_near_rh_no(mat4 proj, float * __restrict nearZ) { *nearZ = proj[3][2] / (proj[2][2] - 1.0f); } /*! * @brief returns sizes of near and far planes of perspective projection * with a right-hand coordinate system and a * clip-space of [-1, 1]. * * @param[in] proj perspective projection matrix * @param[in] fovy fovy (see brief) * @param[out] dest sizes order: [Wnear, Hnear, Wfar, Hfar] */ CGLM_INLINE void glm_persp_sizes_rh_no(mat4 proj, float fovy, vec4 dest) { float t, a, nearZ, farZ; t = 2.0f * tanf(fovy * 0.5f); a = glm_persp_aspect(proj); glm_persp_decomp_z_rh_no(proj, &nearZ, &farZ); dest[1] = t * nearZ; dest[3] = t * farZ; dest[0] = a * dest[1]; dest[2] = a * dest[3]; } /*! * @brief returns field of view angle along the Y-axis (in radians) * with a right-hand coordinate system and a clip-space of [-1, 1]. * * if you need to degrees, use glm_deg to convert it or use this: * fovy_deg = glm_deg(glm_persp_fovy(projMatrix)) * * @param[in] proj perspective projection matrix */ CGLM_INLINE float glm_persp_fovy_rh_no(mat4 proj) { return glm_persp_fovy(proj); } /*! * @brief returns aspect ratio of perspective projection * with a right-hand coordinate system and a clip-space of [-1, 1]. * * @param[in] proj perspective projection matrix */ CGLM_INLINE float glm_persp_aspect_rh_no(mat4 proj) { return glm_persp_aspect(proj); } #endif /*cglm_cam_rh_no_h*/ cglm-0.9.6/include/cglm/clipspace/persp_rh_zo.h000066400000000000000000000262351475344456400215130ustar00rootroot00000000000000/* * 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_frustum_rh_zo(float left, float right, float bottom, float top, float nearZ, float farZ, mat4 dest) CGLM_INLINE void glm_perspective_rh_zo(float fovy, float aspect, float nearZ, float farZ, mat4 dest) CGLM_INLINE void glm_perspective_default_rh_zo(float aspect, mat4 dest) CGLM_INLINE void glm_perspective_resize_rh_zo(float aspect, mat4 proj) CGLM_INLINE void glm_persp_move_far_rh_zo(mat4 proj, float deltaFar) CGLM_INLINE void glm_persp_decomp_rh_zo(mat4 proj, float * __restrict nearZ, float * __restrict farZ, float * __restrict top, float * __restrict bottom, float * __restrict left, float * __restrict right) CGLM_INLINE void glm_persp_decompv_rh_zo(mat4 proj, float dest[6]) CGLM_INLINE void glm_persp_decomp_x_rh_zo(mat4 proj, float * __restrict left, float * __restrict right) CGLM_INLINE void glm_persp_decomp_y_rh_zo(mat4 proj, float * __restrict top, float * __restrict bottom) CGLM_INLINE void glm_persp_decomp_z_rh_zo(mat4 proj, float * __restrict nearZ, float * __restrict farZ) CGLM_INLINE void glm_persp_decomp_far_rh_zo(mat4 proj, float * __restrict farZ) CGLM_INLINE void glm_persp_decomp_near_rh_zo(mat4 proj, float * __restrict nearZ) CGLM_INLINE void glm_persp_sizes_rh_zo(mat4 proj, float fovy, vec4 dest) */ #ifndef cglm_persp_rh_zo_h #define cglm_persp_rh_zo_h #include "../common.h" #include "persp.h" /*! * @brief set up perspective peprojection matrix with a right-hand coordinate * system and a clip-space of [0, 1]. * * @param[in] left viewport.left * @param[in] right viewport.right * @param[in] bottom viewport.bottom * @param[in] top viewport.top * @param[in] nearZ near clipping plane * @param[in] farZ far clipping plane * @param[out] dest result matrix */ CGLM_INLINE void glm_frustum_rh_zo(float left, float right, float bottom, float top, float nearZ, float farZ, mat4 dest) { float rl, tb, fn, nv; glm_mat4_zero(dest); rl = 1.0f / (right - left); tb = 1.0f / (top - bottom); fn =-1.0f / (farZ - nearZ); nv = 2.0f * nearZ; dest[0][0] = nv * rl; dest[1][1] = nv * tb; dest[2][0] = (right + left) * rl; dest[2][1] = (top + bottom) * tb; dest[2][2] = farZ * fn; dest[2][3] =-1.0f; dest[3][2] = farZ * nearZ * fn; } /*! * @brief set up perspective projection matrix with a right-hand coordinate * system and a clip-space of [0, 1]. * * @param[in] fovy field of view angle * @param[in] aspect aspect ratio ( width / height ) * @param[in] nearZ near clipping plane * @param[in] farZ far clipping planes * @param[out] dest result matrix */ CGLM_INLINE void glm_perspective_rh_zo(float fovy, float aspect, float nearZ, float farZ, mat4 dest) { float f, fn; glm_mat4_zero(dest); f = 1.0f / tanf(fovy * 0.5f); fn = 1.0f / (nearZ - farZ); dest[0][0] = f / aspect; dest[1][1] = f; dest[2][2] = farZ * fn; dest[2][3] =-1.0f; dest[3][2] = nearZ * farZ * fn; } /*! * @brief set up perspective projection matrix with default near/far * and angle values with a right-hand coordinate system and a * clip-space of [0, 1]. * * @param[in] aspect aspect ratio ( width / height ) * @param[out] dest result matrix */ CGLM_INLINE void glm_perspective_default_rh_zo(float aspect, mat4 dest) { glm_perspective_rh_zo(GLM_PI_4f, aspect, 0.01f, 100.0f, dest); } /*! * @brief resize perspective matrix by aspect ratio ( width / height ) * this makes very easy to resize proj matrix when window /viewport * resized with a right-hand coordinate system and a clip-space of * [0, 1]. * * @param[in] aspect aspect ratio ( width / height ) * @param[in, out] proj perspective projection matrix */ CGLM_INLINE void glm_perspective_resize_rh_zo(float aspect, mat4 proj) { if (proj[0][0] == 0.0f) return; proj[0][0] = proj[1][1] / aspect; } /*! * @brief extend perspective projection matrix's far distance with a * right-hand coordinate system and a clip-space of [0, 1]. * * this function does not guarantee far >= near, be aware of that! * * @param[in, out] proj projection matrix to extend * @param[in] deltaFar distance from existing far (negative to shink) */ CGLM_INLINE void glm_persp_move_far_rh_zo(mat4 proj, float deltaFar) { float fn, farZ, nearZ, p22, p32; p22 = proj[2][2]; p32 = proj[3][2]; nearZ = p32 / p22; farZ = p32 / (p22 + 1.0f) + deltaFar; fn = 1.0f / (nearZ - farZ); proj[2][2] = farZ * fn; proj[3][2] = nearZ * farZ * fn; } /*! * @brief decomposes frustum values of perspective projection * with angle values with a right-hand coordinate system and a * clip-space of [0, 1]. * * @param[in] proj perspective projection matrix * @param[out] nearZ near * @param[out] farZ far * @param[out] top top * @param[out] bottom bottom * @param[out] left left * @param[out] right right */ CGLM_INLINE void glm_persp_decomp_rh_zo(mat4 proj, float * __restrict nearZ, float * __restrict farZ, float * __restrict top, float * __restrict bottom, float * __restrict left, float * __restrict right) { float m00, m11, m20, m21, m22, m32, n, f; float n_m11, n_m00; m00 = proj[0][0]; m11 = proj[1][1]; m20 = proj[2][0]; m21 = proj[2][1]; m22 = proj[2][2]; m32 = proj[3][2]; n = m32 / m22; f = m32 / (m22 + 1.0f); n_m11 = n / m11; n_m00 = n / m00; *nearZ = n; *farZ = f; *bottom = n_m11 * (m21 - 1.0f); *top = n_m11 * (m21 + 1.0f); *left = n_m00 * (m20 - 1.0f); *right = n_m00 * (m20 + 1.0f); } /*! * @brief decomposes frustum values of perspective projection * with angle values with a right-hand coordinate system and a * clip-space of [0, 1]. * this makes easy to get all values at once * * @param[in] proj perspective projection matrix * @param[out] dest array */ CGLM_INLINE void glm_persp_decompv_rh_zo(mat4 proj, float dest[6]) { glm_persp_decomp_rh_zo(proj, &dest[0], &dest[1], &dest[2], &dest[3], &dest[4], &dest[5]); } /*! * @brief decomposes left and right values of perspective projection (ZO). * x stands for x axis (left / right axis) * * @param[in] proj perspective projection matrix * @param[out] left left * @param[out] right right */ CGLM_INLINE void glm_persp_decomp_x_rh_zo(mat4 proj, float * __restrict left, float * __restrict right) { float nearZ, m20, m00, m22; m00 = proj[0][0]; m20 = proj[2][0]; m22 = proj[2][2]; nearZ = proj[3][2] / m22; *left = nearZ * (m20 - 1.0f) / m00; *right = nearZ * (m20 + 1.0f) / m00; } /*! * @brief decomposes top and bottom values of perspective projection * with angle values with a right-hand coordinate system and a * clip-space of [0, 1]. * y stands for y axis (top / bottom axis) * * @param[in] proj perspective projection matrix * @param[out] top top * @param[out] bottom bottom */ CGLM_INLINE void glm_persp_decomp_y_rh_zo(mat4 proj, float * __restrict top, float * __restrict bottom) { float nearZ, m21, m11, m22; m21 = proj[2][1]; m11 = proj[1][1]; m22 = proj[2][2]; nearZ = proj[3][2] / m22; *bottom = nearZ * (m21 - 1) / m11; *top = nearZ * (m21 + 1) / m11; } /*! * @brief decomposes near and far values of perspective projection * with angle values with a right-hand coordinate system and a * clip-space of [0, 1]. * z stands for z axis (near / far axis) * * @param[in] proj perspective projection matrix * @param[out] nearZ near * @param[out] farZ far */ CGLM_INLINE void glm_persp_decomp_z_rh_zo(mat4 proj, float * __restrict nearZ, float * __restrict farZ) { float m32, m22; m32 = proj[3][2]; m22 = proj[2][2]; *nearZ = m32 / m22; *farZ = m32 / (m22 + 1.0f); } /*! * @brief decomposes far value of perspective projection * with angle values with a right-hand coordinate system and a * clip-space of [0, 1]. * * @param[in] proj perspective projection matrix * @param[out] farZ far */ CGLM_INLINE void glm_persp_decomp_far_rh_zo(mat4 proj, float * __restrict farZ) { *farZ = proj[3][2] / (proj[2][2] + 1.0f); } /*! * @brief decomposes near value of perspective projection * with angle values with a right-hand coordinate system and a * clip-space of [0, 1]. * * @param[in] proj perspective projection matrix * @param[out] nearZ near */ CGLM_INLINE void glm_persp_decomp_near_rh_zo(mat4 proj, float * __restrict nearZ) { *nearZ = proj[3][2] / proj[2][2]; } /*! * @brief returns sizes of near and far planes of perspective projection * with a right-hand coordinate system and a * clip-space of [0, 1]. * * @param[in] proj perspective projection matrix * @param[in] fovy fovy (see brief) * @param[out] dest sizes order: [Wnear, Hnear, Wfar, Hfar] */ CGLM_INLINE void glm_persp_sizes_rh_zo(mat4 proj, float fovy, vec4 dest) { float t, a, nearZ, farZ; t = 2.0f * tanf(fovy * 0.5f); a = glm_persp_aspect(proj); glm_persp_decomp_z_rh_zo(proj, &nearZ, &farZ); dest[1] = t * nearZ; dest[3] = t * farZ; dest[0] = a * dest[1]; dest[2] = a * dest[3]; } /*! * @brief returns field of view angle along the Y-axis (in radians) * with a right-hand coordinate system and a clip-space of [0, 1]. * * if you need to degrees, use glm_deg to convert it or use this: * fovy_deg = glm_deg(glm_persp_fovy(projMatrix)) * * @param[in] proj perspective projection matrix */ CGLM_INLINE float glm_persp_fovy_rh_zo(mat4 proj) { return glm_persp_fovy(proj); } /*! * @brief returns aspect ratio of perspective projection * with a right-hand coordinate system and a clip-space of [0, 1]. * * @param[in] proj perspective projection matrix */ CGLM_INLINE float glm_persp_aspect_rh_zo(mat4 proj) { return glm_persp_aspect(proj); } #endif /*cglm_persp_rh_zo_h*/ cglm-0.9.6/include/cglm/clipspace/project_no.h000066400000000000000000000055011475344456400213140ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ #ifndef cglm_project_no_h #define cglm_project_no_h #include "../common.h" #include "../vec3.h" #include "../vec4.h" #include "../mat4.h" /*! * @brief maps the specified viewport coordinates into specified space [1] * the matrix should contain projection matrix. * * if you don't have ( and don't want to have ) an inverse matrix then use * glm_unproject version. You may use existing inverse of matrix in somewhere * else, this is why glm_unprojecti exists to save save inversion cost * * [1] space: * 1- if m = invProj: View Space * 2- if m = invViewProj: World Space * 3- if m = invMVP: Object Space * * You probably want to map the coordinates into object space * so use invMVP as m * * Computing viewProj: * glm_mat4_mul(proj, view, viewProj); * glm_mat4_mul(viewProj, model, MVP); * glm_mat4_inv(viewProj, invMVP); * * @param[in] pos point/position in viewport coordinates * @param[in] invMat matrix (see brief) * @param[in] vp viewport as [x, y, width, height] * @param[out] dest unprojected coordinates */ CGLM_INLINE void glm_unprojecti_no(vec3 pos, mat4 invMat, vec4 vp, vec3 dest) { vec4 v; v[0] = 2.0f * (pos[0] - vp[0]) / vp[2] - 1.0f; v[1] = 2.0f * (pos[1] - vp[1]) / vp[3] - 1.0f; v[2] = 2.0f * pos[2] - 1.0f; v[3] = 1.0f; glm_mat4_mulv(invMat, v, v); glm_vec4_scale(v, 1.0f / v[3], v); glm_vec3(v, dest); } /*! * @brief map object coordinates to window coordinates * * Computing MVP: * glm_mat4_mul(proj, view, viewProj); * glm_mat4_mul(viewProj, model, MVP); * * @param[in] pos object coordinates * @param[in] m MVP matrix * @param[in] vp viewport as [x, y, width, height] * @param[out] dest projected coordinates */ CGLM_INLINE void glm_project_no(vec3 pos, mat4 m, vec4 vp, vec3 dest) { CGLM_ALIGN(16) vec4 pos4; glm_vec4(pos, 1.0f, pos4); glm_mat4_mulv(m, pos4, pos4); glm_vec4_scale(pos4, 1.0f / pos4[3], pos4); /* pos = pos / pos.w */ glm_vec4_scale(pos4, 0.5f, pos4); glm_vec4_adds(pos4, 0.5f, pos4); dest[0] = pos4[0] * vp[2] + vp[0]; dest[1] = pos4[1] * vp[3] + vp[1]; dest[2] = pos4[2]; } /*! * @brief map object's z coordinate to window coordinates * * Computing MVP: * glm_mat4_mul(proj, view, viewProj); * glm_mat4_mul(viewProj, model, MVP); * * @param[in] v object coordinates * @param[in] m MVP matrix * * @returns projected z coordinate */ CGLM_INLINE float glm_project_z_no(vec3 v, mat4 m) { float z, w; z = m[0][2] * v[0] + m[1][2] * v[1] + m[2][2] * v[2] + m[3][2]; w = m[0][3] * v[0] + m[1][3] * v[1] + m[2][3] * v[2] + m[3][3]; return 0.5f * (z / w) + 0.5f; } #endif /* cglm_project_no_h */ cglm-0.9.6/include/cglm/clipspace/project_zo.h000066400000000000000000000054251475344456400213350ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ #ifndef cglm_project_zo_h #define cglm_project_zo_h #include "../common.h" #include "../vec3.h" #include "../vec4.h" #include "../mat4.h" /*! * @brief maps the specified viewport coordinates into specified space [1] * the matrix should contain projection matrix. * * if you don't have ( and don't want to have ) an inverse matrix then use * glm_unproject version. You may use existing inverse of matrix in somewhere * else, this is why glm_unprojecti exists to save save inversion cost * * [1] space: * 1- if m = invProj: View Space * 2- if m = invViewProj: World Space * 3- if m = invMVP: Object Space * * You probably want to map the coordinates into object space * so use invMVP as m * * Computing viewProj: * glm_mat4_mul(proj, view, viewProj); * glm_mat4_mul(viewProj, model, MVP); * glm_mat4_inv(viewProj, invMVP); * * @param[in] pos point/position in viewport coordinates * @param[in] invMat matrix (see brief) * @param[in] vp viewport as [x, y, width, height] * @param[out] dest unprojected coordinates */ CGLM_INLINE void glm_unprojecti_zo(vec3 pos, mat4 invMat, vec4 vp, vec3 dest) { vec4 v; v[0] = 2.0f * (pos[0] - vp[0]) / vp[2] - 1.0f; v[1] = 2.0f * (pos[1] - vp[1]) / vp[3] - 1.0f; v[2] = pos[2]; v[3] = 1.0f; glm_mat4_mulv(invMat, v, v); glm_vec4_scale(v, 1.0f / v[3], v); glm_vec3(v, dest); } /*! * @brief map object coordinates to window coordinates * * Computing MVP: * glm_mat4_mul(proj, view, viewProj); * glm_mat4_mul(viewProj, model, MVP); * * @param[in] pos object coordinates * @param[in] m MVP matrix * @param[in] vp viewport as [x, y, width, height] * @param[out] dest projected coordinates */ CGLM_INLINE void glm_project_zo(vec3 pos, mat4 m, vec4 vp, vec3 dest) { CGLM_ALIGN(16) vec4 pos4; glm_vec4(pos, 1.0f, pos4); glm_mat4_mulv(m, pos4, pos4); glm_vec4_scale(pos4, 1.0f / pos4[3], pos4); /* pos = pos / pos.w */ dest[2] = pos4[2]; glm_vec4_scale(pos4, 0.5f, pos4); glm_vec4_adds(pos4, 0.5f, pos4); dest[0] = pos4[0] * vp[2] + vp[0]; dest[1] = pos4[1] * vp[3] + vp[1]; } /*! * @brief map object's z coordinate to window coordinates * * Computing MVP: * glm_mat4_mul(proj, view, viewProj); * glm_mat4_mul(viewProj, model, MVP); * * @param[in] v object coordinates * @param[in] m MVP matrix * * @returns projected z coordinate */ CGLM_INLINE float glm_project_z_zo(vec3 v, mat4 m) { float z, w; z = m[0][2] * v[0] + m[1][2] * v[1] + m[2][2] * v[2] + m[3][2]; w = m[0][3] * v[0] + m[1][3] * v[1] + m[2][3] * v[2] + m[3][3]; return z / w; } #endif /* cglm_project_zo_h */ cglm-0.9.6/include/cglm/clipspace/view_lh.h000066400000000000000000000050041475344456400206050ustar00rootroot00000000000000/* * 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_lookat_lh(vec3 eye, vec3 center, vec3 up, mat4 dest) CGLM_INLINE void glm_look_lh(vec3 eye, vec3 dir, vec3 up, mat4 dest) CGLM_INLINE void glm_look_anyup_lh(vec3 eye, vec3 dir, mat4 dest) */ #ifndef cglm_view_lh_h #define cglm_view_lh_h #include "../common.h" #include "../plane.h" /*! * @brief set up view matrix (LH) * * NOTE: The UP vector must not be parallel to the line of sight from * the eye point to the reference point * * @param[in] eye eye vector * @param[in] center center vector * @param[in] up up vector * @param[out] dest result matrix */ CGLM_INLINE void glm_lookat_lh(vec3 eye, vec3 center, vec3 up, mat4 dest) { CGLM_ALIGN(8) vec3 f, u, s; glm_vec3_sub(center, eye, f); glm_vec3_normalize(f); glm_vec3_crossn(up, f, s); glm_vec3_cross(f, s, u); dest[0][0] = s[0]; dest[0][1] = u[0]; dest[0][2] = f[0]; dest[1][0] = s[1]; dest[1][1] = u[1]; dest[1][2] = f[1]; dest[2][0] = s[2]; dest[2][1] = u[2]; dest[2][2] = f[2]; dest[3][0] =-glm_vec3_dot(s, eye); dest[3][1] =-glm_vec3_dot(u, eye); dest[3][2] =-glm_vec3_dot(f, eye); dest[0][3] = dest[1][3] = dest[2][3] = 0.0f; dest[3][3] = 1.0f; } /*! * @brief set up view matrix with left handed coordinate system * * convenient wrapper for lookat: if you only have direction not target self * then this might be useful. Because you need to get target from direction. * * NOTE: The UP vector must not be parallel to the line of sight from * the eye point to the reference point * * @param[in] eye eye vector * @param[in] dir direction vector * @param[in] up up vector * @param[out] dest result matrix */ CGLM_INLINE void glm_look_lh(vec3 eye, vec3 dir, vec3 up, mat4 dest) { CGLM_ALIGN(8) vec3 target; glm_vec3_add(eye, dir, target); glm_lookat_lh(eye, target, up, dest); } /*! * @brief set up view matrix with left handed coordinate system * * convenient wrapper for look: if you only have direction and if you don't * care what UP vector is then this might be useful to create view matrix * * @param[in] eye eye vector * @param[in] dir direction vector * @param[out] dest result matrix */ CGLM_INLINE void glm_look_anyup_lh(vec3 eye, vec3 dir, mat4 dest) { CGLM_ALIGN(8) vec3 up; glm_vec3_ortho(dir, up); glm_look_lh(eye, dir, up, dest); } #endif /*cglm_view_lh_h*/ cglm-0.9.6/include/cglm/clipspace/view_lh_no.h000066400000000000000000000037571475344456400213160ustar00rootroot00000000000000/* * 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_lookat_lh_no(vec3 eye, vec3 center, vec3 up, mat4 dest) CGLM_INLINE void glm_look_lh_no(vec3 eye, vec3 dir, vec3 up, mat4 dest) CGLM_INLINE void glm_look_anyup_lh_no(vec3 eye, vec3 dir, mat4 dest) */ #ifndef cglm_view_lh_no_h #define cglm_view_lh_no_h #include "../common.h" #include "view_lh.h" /*! * @brief set up view matrix with left handed coordinate system. * * NOTE: The UP vector must not be parallel to the line of sight from * the eye point to the reference point * * @param[in] eye eye vector * @param[in] center center vector * @param[in] up up vector * @param[out] dest result matrix */ CGLM_INLINE void glm_lookat_lh_no(vec3 eye, vec3 center, vec3 up, mat4 dest) { glm_lookat_lh(eye, center, up, dest); } /*! * @brief set up view matrix with left handed coordinate system. * * convenient wrapper for lookat: if you only have direction not target self * then this might be useful. Because you need to get target from direction. * * NOTE: The UP vector must not be parallel to the line of sight from * the eye point to the reference point * * @param[in] eye eye vector * @param[in] dir direction vector * @param[in] up up vector * @param[out] dest result matrix */ CGLM_INLINE void glm_look_lh_no(vec3 eye, vec3 dir, vec3 up, mat4 dest) { glm_look_lh(eye, dir, up, dest); } /*! * @brief set up view matrix with left handed coordinate system. * * convenient wrapper for look: if you only have direction and if you don't * care what UP vector is then this might be useful to create view matrix * * @param[in] eye eye vector * @param[in] dir direction vector * @param[out] dest result matrix */ CGLM_INLINE void glm_look_anyup_lh_no(vec3 eye, vec3 dir, mat4 dest) { glm_look_anyup_lh(eye, dir, dest); } #endif /*cglm_view_lh_no_h*/ cglm-0.9.6/include/cglm/clipspace/view_lh_zo.h000066400000000000000000000037571475344456400213320ustar00rootroot00000000000000/* * 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_lookat_lh_zo(vec3 eye, vec3 center, vec3 up, mat4 dest) CGLM_INLINE void glm_look_lh_zo(vec3 eye, vec3 dir, vec3 up, mat4 dest) CGLM_INLINE void glm_look_anyup_lh_zo(vec3 eye, vec3 dir, mat4 dest) */ #ifndef cglm_view_lh_zo_h #define cglm_view_lh_zo_h #include "../common.h" #include "view_lh.h" /*! * @brief set up view matrix with left handed coordinate system. * * NOTE: The UP vector must not be parallel to the line of sight from * the eye point to the reference point * * @param[in] eye eye vector * @param[in] center center vector * @param[in] up up vector * @param[out] dest result matrix */ CGLM_INLINE void glm_lookat_lh_zo(vec3 eye, vec3 center, vec3 up, mat4 dest) { glm_lookat_lh(eye, center, up, dest); } /*! * @brief set up view matrix with left handed coordinate system. * * convenient wrapper for lookat: if you only have direction not target self * then this might be useful. Because you need to get target from direction. * * NOTE: The UP vector must not be parallel to the line of sight from * the eye point to the reference point * * @param[in] eye eye vector * @param[in] dir direction vector * @param[in] up up vector * @param[out] dest result matrix */ CGLM_INLINE void glm_look_lh_zo(vec3 eye, vec3 dir, vec3 up, mat4 dest) { glm_look_lh(eye, dir, up, dest); } /*! * @brief set up view matrix with left handed coordinate system. * * convenient wrapper for look: if you only have direction and if you don't * care what UP vector is then this might be useful to create view matrix * * @param[in] eye eye vector * @param[in] dir direction vector * @param[out] dest result matrix */ CGLM_INLINE void glm_look_anyup_lh_zo(vec3 eye, vec3 dir, mat4 dest) { glm_look_anyup_lh(eye, dir, dest); } #endif /*cglm_view_lh_zo_h*/ cglm-0.9.6/include/cglm/clipspace/view_rh.h000066400000000000000000000050501475344456400206140ustar00rootroot00000000000000/* * 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_lookat_rh(vec3 eye, vec3 center, vec3 up, mat4 dest) CGLM_INLINE void glm_look_rh(vec3 eye, vec3 dir, vec3 up, mat4 dest) CGLM_INLINE void glm_look_anyup_rh(vec3 eye, vec3 dir, mat4 dest) */ #ifndef cglm_view_rh_h #define cglm_view_rh_h #include "../common.h" #include "../plane.h" /*! * @brief set up view matrix with right handed coordinate system. * * NOTE: The UP vector must not be parallel to the line of sight from * the eye point to the reference point * * @param[in] eye eye vector * @param[in] center center vector * @param[in] up up vector * @param[out] dest result matrix */ CGLM_INLINE void glm_lookat_rh(vec3 eye, vec3 center, vec3 up, mat4 dest) { CGLM_ALIGN(8) vec3 f, u, s; glm_vec3_sub(center, eye, f); glm_vec3_normalize(f); glm_vec3_crossn(f, up, s); glm_vec3_cross(s, f, u); dest[0][0] = s[0]; dest[0][1] = u[0]; dest[0][2] =-f[0]; dest[1][0] = s[1]; dest[1][1] = u[1]; dest[1][2] =-f[1]; dest[2][0] = s[2]; dest[2][1] = u[2]; dest[2][2] =-f[2]; dest[3][0] =-glm_vec3_dot(s, eye); dest[3][1] =-glm_vec3_dot(u, eye); dest[3][2] = glm_vec3_dot(f, eye); dest[0][3] = dest[1][3] = dest[2][3] = 0.0f; dest[3][3] = 1.0f; } /*! * @brief set up view matrix with right handed coordinate system. * * convenient wrapper for lookat: if you only have direction not target self * then this might be useful. Because you need to get target from direction. * * NOTE: The UP vector must not be parallel to the line of sight from * the eye point to the reference point * * @param[in] eye eye vector * @param[in] dir direction vector * @param[in] up up vector * @param[out] dest result matrix */ CGLM_INLINE void glm_look_rh(vec3 eye, vec3 dir, vec3 up, mat4 dest) { CGLM_ALIGN(8) vec3 target; glm_vec3_add(eye, dir, target); glm_lookat_rh(eye, target, up, dest); } /*! * @brief set up view matrix with right handed coordinate system. * * convenient wrapper for look: if you only have direction and if you don't * care what UP vector is then this might be useful to create view matrix * * @param[in] eye eye vector * @param[in] dir direction vector * @param[out] dest result matrix */ CGLM_INLINE void glm_look_anyup_rh(vec3 eye, vec3 dir, mat4 dest) { CGLM_ALIGN(8) vec3 up; glm_vec3_ortho(dir, up); glm_look_rh(eye, dir, up, dest); } #endif /*cglm_view_rh_h*/ cglm-0.9.6/include/cglm/clipspace/view_rh_no.h000066400000000000000000000037621475344456400213200ustar00rootroot00000000000000/* * 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_lookat_rh_no(vec3 eye, vec3 center, vec3 up, mat4 dest) CGLM_INLINE void glm_look_rh_no(vec3 eye, vec3 dir, vec3 up, mat4 dest) CGLM_INLINE void glm_look_anyup_rh_no(vec3 eye, vec3 dir, mat4 dest) */ #ifndef cglm_view_rh_no_h #define cglm_view_rh_no_h #include "../common.h" #include "view_rh.h" /*! * @brief set up view matrix with right handed coordinate system. * * NOTE: The UP vector must not be parallel to the line of sight from * the eye point to the reference point * * @param[in] eye eye vector * @param[in] center center vector * @param[in] up up vector * @param[out] dest result matrix */ CGLM_INLINE void glm_lookat_rh_no(vec3 eye, vec3 center, vec3 up, mat4 dest) { glm_lookat_rh(eye, center, up, dest); } /*! * @brief set up view matrix with right handed coordinate system. * * convenient wrapper for lookat: if you only have direction not target self * then this might be useful. Because you need to get target from direction. * * NOTE: The UP vector must not be parallel to the line of sight from * the eye point to the reference point * * @param[in] eye eye vector * @param[in] dir direction vector * @param[in] up up vector * @param[out] dest result matrix */ CGLM_INLINE void glm_look_rh_no(vec3 eye, vec3 dir, vec3 up, mat4 dest) { glm_look_rh(eye, dir, up, dest); } /*! * @brief set up view matrix with right handed coordinate system. * * convenient wrapper for look: if you only have direction and if you don't * care what UP vector is then this might be useful to create view matrix * * @param[in] eye eye vector * @param[in] dir direction vector * @param[out] dest result matrix */ CGLM_INLINE void glm_look_anyup_rh_no(vec3 eye, vec3 dir, mat4 dest) { glm_look_anyup_rh(eye, dir, dest); } #endif /*cglm_view_rh_no_h*/ cglm-0.9.6/include/cglm/clipspace/view_rh_zo.h000066400000000000000000000037621475344456400213340ustar00rootroot00000000000000/* * 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_lookat_rh_zo(vec3 eye, vec3 center, vec3 up, mat4 dest) CGLM_INLINE void glm_look_rh_zo(vec3 eye, vec3 dir, vec3 up, mat4 dest) CGLM_INLINE void glm_look_anyup_rh_zo(vec3 eye, vec3 dir, mat4 dest) */ #ifndef cglm_view_rh_zo_h #define cglm_view_rh_zo_h #include "../common.h" #include "view_rh.h" /*! * @brief set up view matrix with right handed coordinate system. * * NOTE: The UP vector must not be parallel to the line of sight from * the eye point to the reference point * * @param[in] eye eye vector * @param[in] center center vector * @param[in] up up vector * @param[out] dest result matrix */ CGLM_INLINE void glm_lookat_rh_zo(vec3 eye, vec3 center, vec3 up, mat4 dest) { glm_lookat_rh(eye, center, up, dest); } /*! * @brief set up view matrix with right handed coordinate system. * * convenient wrapper for lookat: if you only have direction not target self * then this might be useful. Because you need to get target from direction. * * NOTE: The UP vector must not be parallel to the line of sight from * the eye point to the reference point * * @param[in] eye eye vector * @param[in] dir direction vector * @param[in] up up vector * @param[out] dest result matrix */ CGLM_INLINE void glm_look_rh_zo(vec3 eye, vec3 dir, vec3 up, mat4 dest) { glm_look_rh(eye, dir, up, dest); } /*! * @brief set up view matrix with right handed coordinate system. * * convenient wrapper for look: if you only have direction and if you don't * care what UP vector is then this might be useful to create view matrix * * @param[in] eye eye vector * @param[in] dir direction vector * @param[out] dest result matrix */ CGLM_INLINE void glm_look_anyup_rh_zo(vec3 eye, vec3 dir, mat4 dest) { glm_look_anyup_rh(eye, dir, dest); } #endif /*cglm_view_rh_zo_h*/ cglm-0.9.6/include/cglm/color.h000066400000000000000000000007271475344456400163320ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ #ifndef cglm_color_h #define cglm_color_h #include "common.h" #include "vec3.h" /*! * @brief averages the color channels into one value * * @param[in] rgb RGB color */ CGLM_INLINE float glm_luminance(vec3 rgb) { vec3 l = {0.212671f, 0.715160f, 0.072169f}; return glm_dot(rgb, l); } #endif /* cglm_color_h */ cglm-0.9.6/include/cglm/common.h000066400000000000000000000100201475344456400164670ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ #ifndef cglm_common_h #define cglm_common_h #ifndef _USE_MATH_DEFINES # define _USE_MATH_DEFINES /* for windows */ #endif #ifndef _CRT_SECURE_NO_WARNINGS # define _CRT_SECURE_NO_WARNINGS /* for windows */ #endif #include #include #include #include #include #include #if defined(_MSC_VER) # ifdef CGLM_STATIC # define CGLM_EXPORT # elif defined(CGLM_EXPORTS) # define CGLM_EXPORT __declspec(dllexport) # else # define CGLM_EXPORT __declspec(dllimport) # endif # define CGLM_INLINE __forceinline #else # define CGLM_EXPORT __attribute__((visibility("default"))) # define CGLM_INLINE static inline __attribute((always_inline)) #endif #if defined(__GNUC__) || defined(__clang__) # define CGLM_UNLIKELY(expr) __builtin_expect(!!(expr), 0) # define CGLM_LIKELY(expr) __builtin_expect(!!(expr), 1) #else # define CGLM_UNLIKELY(expr) (expr) # define CGLM_LIKELY(expr) (expr) #endif #if defined(_M_FP_FAST) || defined(__FAST_MATH__) # define CGLM_FAST_MATH #endif #define GLM_SHUFFLE4(z, y, x, w) (((z) << 6) | ((y) << 4) | ((x) << 2) | (w)) #define GLM_SHUFFLE3(z, y, x) (((z) << 4) | ((y) << 2) | (x)) #define GLM_SHUFFLE2(y, x) (((y) << 2) | (x)) #include "types.h" #include "simd/intrin.h" #ifndef CGLM_USE_DEFAULT_EPSILON # ifndef GLM_FLT_EPSILON # define GLM_FLT_EPSILON 1e-5f # endif #else # define GLM_FLT_EPSILON FLT_EPSILON #endif /* * Clip control: define CGLM_FORCE_DEPTH_ZERO_TO_ONE before including * CGLM to use a clip space between 0 to 1. * Coordinate system: define CGLM_FORCE_LEFT_HANDED before including * CGLM to use the left handed coordinate system by default. */ #define CGLM_CLIP_CONTROL_ZO_BIT (1 << 0) /* ZERO_TO_ONE */ #define CGLM_CLIP_CONTROL_NO_BIT (1 << 1) /* NEGATIVE_ONE_TO_ONE */ #define CGLM_CLIP_CONTROL_LH_BIT (1 << 2) /* LEFT_HANDED, For DirectX, Metal, Vulkan */ #define CGLM_CLIP_CONTROL_RH_BIT (1 << 3) /* RIGHT_HANDED, For OpenGL, default in GLM */ #define CGLM_CLIP_CONTROL_LH_ZO (CGLM_CLIP_CONTROL_LH_BIT | CGLM_CLIP_CONTROL_ZO_BIT) #define CGLM_CLIP_CONTROL_LH_NO (CGLM_CLIP_CONTROL_LH_BIT | CGLM_CLIP_CONTROL_NO_BIT) #define CGLM_CLIP_CONTROL_RH_ZO (CGLM_CLIP_CONTROL_RH_BIT | CGLM_CLIP_CONTROL_ZO_BIT) #define CGLM_CLIP_CONTROL_RH_NO (CGLM_CLIP_CONTROL_RH_BIT | CGLM_CLIP_CONTROL_NO_BIT) #ifdef CGLM_FORCE_DEPTH_ZERO_TO_ONE # ifdef CGLM_FORCE_LEFT_HANDED # define CGLM_CONFIG_CLIP_CONTROL CGLM_CLIP_CONTROL_LH_ZO # else # define CGLM_CONFIG_CLIP_CONTROL CGLM_CLIP_CONTROL_RH_ZO # endif #else # ifdef CGLM_FORCE_LEFT_HANDED # define CGLM_CONFIG_CLIP_CONTROL CGLM_CLIP_CONTROL_LH_NO # else # define CGLM_CONFIG_CLIP_CONTROL CGLM_CLIP_CONTROL_RH_NO # endif #endif /* struct API configurator */ /* TODO: move struct/common.h? */ /* WARN: dont use concant helpers outside cglm headers, because they may be changed */ #define CGLM_MACRO_CONCAT_HELPER(A, B, C, D, E, ...) A ## B ## C ## D ## E ## __VA_ARGS__ #define CGLM_MACRO_CONCAT(A, B, C, D, E, ...) CGLM_MACRO_CONCAT_HELPER(A, B, C, D, E,__VA_ARGS__) #ifndef CGLM_OMIT_NS_FROM_STRUCT_API # ifndef CGLM_STRUCT_API_NS # define CGLM_STRUCT_API_NS glms # endif # ifndef CGLM_STRUCT_API_NS_SEPERATOR # define CGLM_STRUCT_API_NS_SEPERATOR _ # endif #else # define CGLM_STRUCT_API_NS # define CGLM_STRUCT_API_NS_SEPERATOR #endif #ifndef CGLM_STRUCT_API_NAME_SUFFIX # define CGLM_STRUCT_API_NAME_SUFFIX #endif #define CGLM_STRUCTAPI(A, ...) CGLM_MACRO_CONCAT(CGLM_STRUCT_API_NS, \ CGLM_STRUCT_API_NS_SEPERATOR, \ A, \ CGLM_STRUCT_API_NAME_SUFFIX, \ _, \ __VA_ARGS__) #endif /* cglm_common_h */ cglm-0.9.6/include/cglm/curve.h000066400000000000000000000016221475344456400163330ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ #ifndef cglm_curve_h #define cglm_curve_h #include "common.h" #include "vec4.h" #include "mat4.h" /*! * @brief helper function to calculate S*M*C multiplication for curves * * This function does not encourage you to use SMC, * instead it is a helper if you use SMC. * * if you want to specify S as vector then use more generic glm_mat4_rmc() func. * * Example usage: * B(s) = glm_smc(s, GLM_BEZIER_MAT, (vec4){p0, c0, c1, p1}) * * @param[in] s parameter between 0 and 1 (this will be [s3, s2, s, 1]) * @param[in] m basis matrix * @param[in] c position/control vector * * @return B(s) */ CGLM_INLINE float glm_smc(float s, mat4 m, vec4 c) { vec4 vs; glm_vec4_cubic(s, vs); return glm_mat4_rmc(vs, m, c); } #endif /* cglm_curve_h */ cglm-0.9.6/include/cglm/ease.h000066400000000000000000000112401475344456400161210ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ #ifndef cglm_ease_h #define cglm_ease_h #include "common.h" CGLM_INLINE float glm_ease_linear(float t) { return t; } CGLM_INLINE float glm_ease_sine_in(float t) { return sinf((t - 1.0f) * GLM_PI_2f) + 1.0f; } CGLM_INLINE float glm_ease_sine_out(float t) { return sinf(t * GLM_PI_2f); } CGLM_INLINE float glm_ease_sine_inout(float t) { return 0.5f * (1.0f - cosf(t * GLM_PIf)); } CGLM_INLINE float glm_ease_quad_in(float t) { return t * t; } CGLM_INLINE float glm_ease_quad_out(float t) { return -(t * (t - 2.0f)); } CGLM_INLINE float glm_ease_quad_inout(float t) { float tt; tt = t * t; if (t < 0.5f) return 2.0f * tt; return (-2.0f * tt) + (4.0f * t) - 1.0f; } CGLM_INLINE float glm_ease_cubic_in(float t) { return t * t * t; } CGLM_INLINE float glm_ease_cubic_out(float t) { float f; f = t - 1.0f; return f * f * f + 1.0f; } CGLM_INLINE float glm_ease_cubic_inout(float t) { float f; if (t < 0.5f) return 4.0f * t * t * t; f = 2.0f * t - 2.0f; return 0.5f * f * f * f + 1.0f; } CGLM_INLINE float glm_ease_quart_in(float t) { float f; f = t * t; return f * f; } CGLM_INLINE float glm_ease_quart_out(float t) { float f; f = t - 1.0f; return f * f * f * (1.0f - t) + 1.0f; } CGLM_INLINE float glm_ease_quart_inout(float t) { float f, g; if (t < 0.5f) { f = t * t; return 8.0f * f * f; } f = t - 1.0f; g = f * f; return -8.0f * g * g + 1.0f; } CGLM_INLINE float glm_ease_quint_in(float t) { float f; f = t * t; return f * f * t; } CGLM_INLINE float glm_ease_quint_out(float t) { float f, g; f = t - 1.0f; g = f * f; return g * g * f + 1.0f; } CGLM_INLINE float glm_ease_quint_inout(float t) { float f, g; if (t < 0.5f) { f = t * t; return 16.0f * f * f * t; } f = 2.0f * t - 2.0f; g = f * f; return 0.5f * g * g * f + 1.0f; } CGLM_INLINE float glm_ease_exp_in(float t) { if (t == 0.0f) return t; return powf(2.0f, 10.0f * (t - 1.0f)); } CGLM_INLINE float glm_ease_exp_out(float t) { if (t == 1.0f) return t; return 1.0f - powf(2.0f, -10.0f * t); } CGLM_INLINE float glm_ease_exp_inout(float t) { if (t == 0.0f || t == 1.0f) return t; if (t < 0.5f) return 0.5f * powf(2.0f, (20.0f * t) - 10.0f); return -0.5f * powf(2.0f, (-20.0f * t) + 10.0f) + 1.0f; } CGLM_INLINE float glm_ease_circ_in(float t) { return 1.0f - sqrtf(1.0f - (t * t)); } CGLM_INLINE float glm_ease_circ_out(float t) { return sqrtf((2.0f - t) * t); } CGLM_INLINE float glm_ease_circ_inout(float t) { if (t < 0.5f) return 0.5f * (1.0f - sqrtf(1.0f - 4.0f * (t * t))); return 0.5f * (sqrtf(-((2.0f * t) - 3.0f) * ((2.0f * t) - 1.0f)) + 1.0f); } CGLM_INLINE float glm_ease_back_in(float t) { float o, z; o = 1.70158f; z = ((o + 1.0f) * t) - o; return t * t * z; } CGLM_INLINE float glm_ease_back_out(float t) { float o, z, n; o = 1.70158f; n = t - 1.0f; z = (o + 1.0f) * n + o; return n * n * z + 1.0f; } CGLM_INLINE float glm_ease_back_inout(float t) { float o, z, n, m, s, x; o = 1.70158f; s = o * 1.525f; x = 0.5f; n = t / 0.5f; if (n < 1.0f) { z = (s + 1) * n - s; m = n * n * z; return x * m; } n -= 2.0f; z = (s + 1.0f) * n + s; m = (n * n * z) + 2; return x * m; } CGLM_INLINE float glm_ease_elast_in(float t) { return sinf(13.0f * GLM_PI_2f * t) * powf(2.0f, 10.0f * (t - 1.0f)); } CGLM_INLINE float glm_ease_elast_out(float t) { return sinf(-13.0f * GLM_PI_2f * (t + 1.0f)) * powf(2.0f, -10.0f * t) + 1.0f; } CGLM_INLINE float glm_ease_elast_inout(float t) { float a; a = 2.0f * t; if (t < 0.5f) return 0.5f * sinf(13.0f * GLM_PI_2f * a) * powf(2.0f, 10.0f * (a - 1.0f)); return 0.5f * (sinf(-13.0f * GLM_PI_2f * a) * powf(2.0f, -10.0f * (a - 1.0f)) + 2.0f); } CGLM_INLINE float glm_ease_bounce_out(float t) { float tt; tt = t * t; if (t < (4.0f / 11.0f)) return (121.0f * tt) / 16.0f; if (t < 8.0f / 11.0f) return ((363.0f / 40.0f) * tt) - ((99.0f / 10.0f) * t) + (17.0f / 5.0f); if (t < (9.0f / 10.0f)) return (4356.0f / 361.0f) * tt - (35442.0f / 1805.0f) * t + (16061.0f / 1805.0f); return ((54.0f / 5.0f) * tt) - ((513.0f / 25.0f) * t) + (268.0f / 25.0f); } CGLM_INLINE float glm_ease_bounce_in(float t) { return 1.0f - glm_ease_bounce_out(1.0f - t); } CGLM_INLINE float glm_ease_bounce_inout(float t) { if (t < 0.5f) return 0.5f * (1.0f - glm_ease_bounce_out(t * 2.0f)); return 0.5f * glm_ease_bounce_out(t * 2.0f - 1.0f) + 0.5f; } #endif /* cglm_ease_h */ cglm-0.9.6/include/cglm/euler.h000066400000000000000000000361131475344456400163260ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ /* NOTE: angles must be passed as [X-Angle, Y-Angle, Z-angle] order For instance you don't pass angles as [Z-Angle, X-Angle, Y-angle] to glm_euler_zxy function, All RELATED functions accept angles same order which is [X, Y, Z]. */ /* Types: enum glm_euler_seq Functions: CGLM_INLINE glm_euler_seq glm_euler_order(int newOrder[3]); CGLM_INLINE void glm_euler_angles(mat4 m, vec3 dest); CGLM_INLINE void glm_euler(vec3 angles, mat4 dest); CGLM_INLINE void glm_euler_xyz(vec3 angles, mat4 dest); CGLM_INLINE void glm_euler_zyx(vec3 angles, mat4 dest); CGLM_INLINE void glm_euler_zxy(vec3 angles, mat4 dest); CGLM_INLINE void glm_euler_xzy(vec3 angles, mat4 dest); CGLM_INLINE void glm_euler_yzx(vec3 angles, mat4 dest); CGLM_INLINE void glm_euler_yxz(vec3 angles, mat4 dest); CGLM_INLINE void glm_euler_by_order(vec3 angles, glm_euler_seq ord, 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 #define cglm_euler_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]... * vector then you can convert it to this enum by doing this: * @code * glm_euler_seq order; * order = orderVec[0] | orderVec[1] << 2 | orderVec[2] << 4; * @endcode * you may need to explicit cast if required */ typedef enum glm_euler_seq { GLM_EULER_XYZ = 0 << 0 | 1 << 2 | 2 << 4, GLM_EULER_XZY = 0 << 0 | 2 << 2 | 1 << 4, GLM_EULER_YZX = 1 << 0 | 2 << 2 | 0 << 4, GLM_EULER_YXZ = 1 << 0 | 0 << 2 | 2 << 4, GLM_EULER_ZXY = 2 << 0 | 0 << 2 | 1 << 4, GLM_EULER_ZYX = 2 << 0 | 1 << 2 | 0 << 4 } glm_euler_seq; CGLM_INLINE glm_euler_seq glm_euler_order(int ord[3]) { return (glm_euler_seq)(ord[0] << 0 | ord[1] << 2 | ord[2] << 4); } /*! * @brief extract euler angles (in radians) using xyz order * * @param[in] m affine transform * @param[out] dest angles vector [x, y, z] */ CGLM_INLINE void glm_euler_angles(mat4 m, vec3 dest) { float m00, m01, m10, m11, m20, m21, m22; float thetaX, thetaY, thetaZ; m00 = m[0][0]; m10 = m[1][0]; m20 = m[2][0]; m01 = m[0][1]; m11 = m[1][1]; m21 = m[2][1]; m22 = m[2][2]; if (m20 < 1.0f) { if (m20 > -1.0f) { thetaY = asinf(m20); thetaX = atan2f(-m21, m22); thetaZ = atan2f(-m10, m00); } else { /* m20 == -1 */ /* Not a unique solution */ thetaY = -GLM_PI_2f; thetaX = -atan2f(m01, m11); thetaZ = 0.0f; } } else { /* m20 == +1 */ thetaY = GLM_PI_2f; thetaX = atan2f(m01, m11); thetaZ = 0.0f; } dest[0] = thetaX; dest[1] = thetaY; dest[2] = thetaZ; } /*! * @brief build rotation matrix from euler angles * * @param[in] angles angles as vector [Xangle, Yangle, Zangle] * @param[out] dest rotation matrix */ CGLM_INLINE void glm_euler_xyz(vec3 angles, mat4 dest) { float cx, cy, cz, sx, sy, sz, czsx, cxcz, sysz; sx = sinf(angles[0]); cx = cosf(angles[0]); sy = sinf(angles[1]); cy = cosf(angles[1]); sz = sinf(angles[2]); cz = cosf(angles[2]); czsx = cz * sx; cxcz = cx * cz; sysz = sy * sz; dest[0][0] = cy * cz; dest[0][1] = czsx * sy + cx * sz; dest[0][2] = -cxcz * sy + sx * sz; dest[1][0] = -cy * sz; dest[1][1] = cxcz - sx * sysz; dest[1][2] = czsx + cx * sysz; dest[2][0] = sy; dest[2][1] = -cy * sx; dest[2][2] = cx * cy; dest[0][3] = 0.0f; dest[1][3] = 0.0f; dest[2][3] = 0.0f; dest[3][0] = 0.0f; dest[3][1] = 0.0f; dest[3][2] = 0.0f; dest[3][3] = 1.0f; } /*! * @brief build rotation matrix from euler angles * * @param[in] angles angles as vector [Xangle, Yangle, Zangle] * @param[out] dest rotation matrix */ CGLM_INLINE void glm_euler(vec3 angles, mat4 dest) { glm_euler_xyz(angles, dest); } /*! * @brief build rotation matrix from euler angles * * @param[in] angles angles as vector [Xangle, Yangle, Zangle] * @param[out] dest rotation matrix */ CGLM_INLINE void glm_euler_xzy(vec3 angles, mat4 dest) { float cx, cy, cz, sx, sy, sz, sxsy, cysx, cxsy, cxcy; sx = sinf(angles[0]); cx = cosf(angles[0]); sy = sinf(angles[1]); cy = cosf(angles[1]); sz = sinf(angles[2]); cz = cosf(angles[2]); sxsy = sx * sy; cysx = cy * sx; cxsy = cx * sy; cxcy = cx * cy; dest[0][0] = cy * cz; dest[0][1] = sxsy + cxcy * sz; dest[0][2] = -cxsy + cysx * sz; dest[1][0] = -sz; dest[1][1] = cx * cz; dest[1][2] = cz * sx; dest[2][0] = cz * sy; dest[2][1] = -cysx + cxsy * sz; dest[2][2] = cxcy + sxsy * sz; dest[0][3] = 0.0f; dest[1][3] = 0.0f; dest[2][3] = 0.0f; dest[3][0] = 0.0f; dest[3][1] = 0.0f; dest[3][2] = 0.0f; dest[3][3] = 1.0f; } /*! * @brief build rotation matrix from euler angles * * @param[in] angles angles as vector [Xangle, Yangle, Zangle] * @param[out] dest rotation matrix */ CGLM_INLINE void glm_euler_yxz(vec3 angles, mat4 dest) { float cx, cy, cz, sx, sy, sz, cycz, sysz, czsy, cysz; sx = sinf(angles[0]); cx = cosf(angles[0]); sy = sinf(angles[1]); cy = cosf(angles[1]); sz = sinf(angles[2]); cz = cosf(angles[2]); cycz = cy * cz; sysz = sy * sz; czsy = cz * sy; cysz = cy * sz; dest[0][0] = cycz + sx * sysz; dest[0][1] = cx * sz; dest[0][2] = -czsy + cysz * sx; dest[1][0] = -cysz + czsy * sx; dest[1][1] = cx * cz; dest[1][2] = cycz * sx + sysz; dest[2][0] = cx * sy; dest[2][1] = -sx; dest[2][2] = cx * cy; dest[0][3] = 0.0f; dest[1][3] = 0.0f; dest[2][3] = 0.0f; dest[3][0] = 0.0f; dest[3][1] = 0.0f; dest[3][2] = 0.0f; dest[3][3] = 1.0f; } /*! * @brief build rotation matrix from euler angles * * @param[in] angles angles as vector [Xangle, Yangle, Zangle] * @param[out] dest rotation matrix */ CGLM_INLINE void glm_euler_yzx(vec3 angles, mat4 dest) { float cx, cy, cz, sx, sy, sz, sxsy, cxcy, cysx, cxsy; sx = sinf(angles[0]); cx = cosf(angles[0]); sy = sinf(angles[1]); cy = cosf(angles[1]); sz = sinf(angles[2]); cz = cosf(angles[2]); sxsy = sx * sy; cxcy = cx * cy; cysx = cy * sx; cxsy = cx * sy; dest[0][0] = cy * cz; dest[0][1] = sz; dest[0][2] = -cz * sy; dest[1][0] = sxsy - cxcy * sz; dest[1][1] = cx * cz; dest[1][2] = cysx + cxsy * sz; dest[2][0] = cxsy + cysx * sz; dest[2][1] = -cz * sx; dest[2][2] = cxcy - sxsy * sz; dest[0][3] = 0.0f; dest[1][3] = 0.0f; dest[2][3] = 0.0f; dest[3][0] = 0.0f; dest[3][1] = 0.0f; dest[3][2] = 0.0f; dest[3][3] = 1.0f; } /*! * @brief build rotation matrix from euler angles * * @param[in] angles angles as vector [Xangle, Yangle, Zangle] * @param[out] dest rotation matrix */ CGLM_INLINE void glm_euler_zxy(vec3 angles, mat4 dest) { float cx, cy, cz, sx, sy, sz, cycz, sxsy, cysz; sx = sinf(angles[0]); cx = cosf(angles[0]); sy = sinf(angles[1]); cy = cosf(angles[1]); sz = sinf(angles[2]); cz = cosf(angles[2]); cycz = cy * cz; sxsy = sx * sy; cysz = cy * sz; dest[0][0] = cycz - sxsy * sz; dest[0][1] = cz * sxsy + cysz; dest[0][2] = -cx * sy; dest[1][0] = -cx * sz; dest[1][1] = cx * cz; dest[1][2] = sx; dest[2][0] = cz * sy + cysz * sx; dest[2][1] = -cycz * sx + sy * sz; dest[2][2] = cx * cy; dest[0][3] = 0.0f; dest[1][3] = 0.0f; dest[2][3] = 0.0f; dest[3][0] = 0.0f; dest[3][1] = 0.0f; dest[3][2] = 0.0f; dest[3][3] = 1.0f; } /*! * @brief build rotation matrix from euler angles * * @param[in] angles angles as vector [Xangle, Yangle, Zangle] * @param[out] dest rotation matrix */ CGLM_INLINE void glm_euler_zyx(vec3 angles, mat4 dest) { float cx, cy, cz, sx, sy, sz, czsx, cxcz, sysz; sx = sinf(angles[0]); cx = cosf(angles[0]); sy = sinf(angles[1]); cy = cosf(angles[1]); sz = sinf(angles[2]); cz = cosf(angles[2]); czsx = cz * sx; cxcz = cx * cz; sysz = sy * sz; dest[0][0] = cy * cz; dest[0][1] = cy * sz; dest[0][2] = -sy; dest[1][0] = czsx * sy - cx * sz; dest[1][1] = cxcz + sx * sysz; dest[1][2] = cy * sx; dest[2][0] = cxcz * sy + sx * sz; dest[2][1] = -czsx + cx * sysz; dest[2][2] = cx * cy; dest[0][3] = 0.0f; dest[1][3] = 0.0f; dest[2][3] = 0.0f; dest[3][0] = 0.0f; dest[3][1] = 0.0f; dest[3][2] = 0.0f; dest[3][3] = 1.0f; } /*! * @brief build rotation matrix from euler angles * * @param[in] angles angles as vector [Xangle, Yangle, Zangle] * @param[in] ord euler order * @param[out] dest rotation matrix */ CGLM_INLINE void glm_euler_by_order(vec3 angles, glm_euler_seq ord, mat4 dest) { float cx, cy, cz, sx, sy, sz; float cycz, cysz, cysx, cxcy, czsy, cxcz, czsx, cxsz, sysz; sx = sinf(angles[0]); cx = cosf(angles[0]); sy = sinf(angles[1]); cy = cosf(angles[1]); sz = sinf(angles[2]); cz = cosf(angles[2]); cycz = cy * cz; cysz = cy * sz; cysx = cy * sx; cxcy = cx * cy; czsy = cz * sy; cxcz = cx * cz; czsx = cz * sx; cxsz = cx * sz; sysz = sy * sz; switch (ord) { case GLM_EULER_XZY: dest[0][0] = cycz; dest[0][1] = sx * sy + cx * cysz; dest[0][2] = -cx * sy + cysx * sz; dest[1][0] = -sz; dest[1][1] = cxcz; dest[1][2] = czsx; dest[2][0] = czsy; dest[2][1] = -cysx + cx * sysz; dest[2][2] = cxcy + sx * sysz; break; case GLM_EULER_XYZ: dest[0][0] = cycz; dest[0][1] = czsx * sy + cxsz; dest[0][2] = -cx * czsy + sx * sz; dest[1][0] = -cysz; dest[1][1] = cxcz - sx * sysz; dest[1][2] = czsx + cx * sysz; dest[2][0] = sy; dest[2][1] = -cysx; dest[2][2] = cxcy; break; case GLM_EULER_YXZ: dest[0][0] = cycz + sx * sysz; dest[0][1] = cxsz; dest[0][2] = -czsy + cysx * sz; dest[1][0] = czsx * sy - cysz; dest[1][1] = cxcz; dest[1][2] = cycz * sx + sysz; dest[2][0] = cx * sy; dest[2][1] = -sx; dest[2][2] = cxcy; break; case GLM_EULER_YZX: dest[0][0] = cycz; dest[0][1] = sz; dest[0][2] = -czsy; dest[1][0] = sx * sy - cx * cysz; dest[1][1] = cxcz; dest[1][2] = cysx + cx * sysz; dest[2][0] = cx * sy + cysx * sz; dest[2][1] = -czsx; dest[2][2] = cxcy - sx * sysz; break; case GLM_EULER_ZXY: dest[0][0] = cycz - sx * sysz; dest[0][1] = czsx * sy + cysz; dest[0][2] = -cx * sy; dest[1][0] = -cxsz; dest[1][1] = cxcz; dest[1][2] = sx; dest[2][0] = czsy + cysx * sz; dest[2][1] = -cycz * sx + sysz; dest[2][2] = cxcy; break; case GLM_EULER_ZYX: dest[0][0] = cycz; dest[0][1] = cysz; dest[0][2] = -sy; dest[1][0] = czsx * sy - cxsz; dest[1][1] = cxcz + sx * sysz; dest[1][2] = cysx; dest[2][0] = cx * czsy + sx * sz; dest[2][1] = -czsx + cx * sysz; dest[2][2] = cxcy; break; } dest[0][3] = 0.0f; dest[1][3] = 0.0f; dest[2][3] = 0.0f; dest[3][0] = 0.0f; dest[3][1] = 0.0f; dest[3][2] = 0.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 */ cglm-0.9.6/include/cglm/frustum.h000066400000000000000000000161471475344456400167240ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ #ifndef cglm_frustum_h #define cglm_frustum_h #include "common.h" #include "plane.h" #include "vec3.h" #include "vec4.h" #include "mat4.h" #define GLM_LBN 0 /* left bottom near */ #define GLM_LTN 1 /* left top near */ #define GLM_RTN 2 /* right top near */ #define GLM_RBN 3 /* right bottom near */ #define GLM_LBF 4 /* left bottom far */ #define GLM_LTF 5 /* left top far */ #define GLM_RTF 6 /* right top far */ #define GLM_RBF 7 /* right bottom far */ #define GLM_LEFT 0 #define GLM_RIGHT 1 #define GLM_BOTTOM 2 #define GLM_TOP 3 #define GLM_NEAR 4 #define GLM_FAR 5 /* you can override clip space coords but you have to provide all with same name e.g.: define GLM_CSCOORD_LBN {0.0f, 0.0f, 1.0f, 1.0f} */ #ifndef GLM_CUSTOM_CLIPSPACE /* near */ #define GLM_CSCOORD_LBN {-1.0f, -1.0f, -1.0f, 1.0f} #define GLM_CSCOORD_LTN {-1.0f, 1.0f, -1.0f, 1.0f} #define GLM_CSCOORD_RTN { 1.0f, 1.0f, -1.0f, 1.0f} #define GLM_CSCOORD_RBN { 1.0f, -1.0f, -1.0f, 1.0f} /* far */ #define GLM_CSCOORD_LBF {-1.0f, -1.0f, 1.0f, 1.0f} #define GLM_CSCOORD_LTF {-1.0f, 1.0f, 1.0f, 1.0f} #define GLM_CSCOORD_RTF { 1.0f, 1.0f, 1.0f, 1.0f} #define GLM_CSCOORD_RBF { 1.0f, -1.0f, 1.0f, 1.0f} #endif /*! * @brief extracts view frustum planes * * planes' space: * 1- if m = proj: View Space * 2- if m = viewProj: World Space * 3- if m = MVP: Object Space * * You probably want to extract planes in world space so use viewProj as m * Computing viewProj: * glm_mat4_mul(proj, view, viewProj); * * Exracted planes order: [left, right, bottom, top, near, far] * * @param[in] m matrix (see brief) * @param[out] dest extracted view frustum planes (see brief) */ CGLM_INLINE void glm_frustum_planes(mat4 m, vec4 dest[6]) { mat4 t; glm_mat4_transpose_to(m, t); glm_vec4_add(t[3], t[0], dest[0]); /* left */ glm_vec4_sub(t[3], t[0], dest[1]); /* right */ glm_vec4_add(t[3], t[1], dest[2]); /* bottom */ glm_vec4_sub(t[3], t[1], dest[3]); /* top */ glm_vec4_add(t[3], t[2], dest[4]); /* near */ glm_vec4_sub(t[3], t[2], dest[5]); /* far */ glm_plane_normalize(dest[0]); glm_plane_normalize(dest[1]); glm_plane_normalize(dest[2]); glm_plane_normalize(dest[3]); glm_plane_normalize(dest[4]); glm_plane_normalize(dest[5]); } /*! * @brief extracts view frustum corners using clip-space coordinates * * corners' space: * 1- if m = invViewProj: World Space * 2- if m = invMVP: Object Space * * You probably want to extract corners in world space so use invViewProj * Computing invViewProj: * glm_mat4_mul(proj, view, viewProj); * ... * glm_mat4_inv(viewProj, invViewProj); * * if you have a near coord at i index, you can get it's far coord by i + 4 * * Find center coordinates: * for (j = 0; j < 4; j++) { * glm_vec3_center(corners[i], corners[i + 4], centerCorners[i]); * } * * @param[in] invMat matrix (see brief) * @param[out] dest exracted view frustum corners (see brief) */ CGLM_INLINE void glm_frustum_corners(mat4 invMat, vec4 dest[8]) { vec4 c[8]; /* indexOf(nearCoord) = indexOf(farCoord) + 4 */ vec4 csCoords[8] = { GLM_CSCOORD_LBN, GLM_CSCOORD_LTN, GLM_CSCOORD_RTN, GLM_CSCOORD_RBN, GLM_CSCOORD_LBF, GLM_CSCOORD_LTF, GLM_CSCOORD_RTF, GLM_CSCOORD_RBF }; glm_mat4_mulv(invMat, csCoords[0], c[0]); glm_mat4_mulv(invMat, csCoords[1], c[1]); glm_mat4_mulv(invMat, csCoords[2], c[2]); glm_mat4_mulv(invMat, csCoords[3], c[3]); glm_mat4_mulv(invMat, csCoords[4], c[4]); glm_mat4_mulv(invMat, csCoords[5], c[5]); glm_mat4_mulv(invMat, csCoords[6], c[6]); glm_mat4_mulv(invMat, csCoords[7], c[7]); glm_vec4_scale(c[0], 1.0f / c[0][3], dest[0]); glm_vec4_scale(c[1], 1.0f / c[1][3], dest[1]); glm_vec4_scale(c[2], 1.0f / c[2][3], dest[2]); glm_vec4_scale(c[3], 1.0f / c[3][3], dest[3]); glm_vec4_scale(c[4], 1.0f / c[4][3], dest[4]); glm_vec4_scale(c[5], 1.0f / c[5][3], dest[5]); glm_vec4_scale(c[6], 1.0f / c[6][3], dest[6]); glm_vec4_scale(c[7], 1.0f / c[7][3], dest[7]); } /*! * @brief finds center of view frustum * * @param[in] corners view frustum corners * @param[out] dest view frustum center */ CGLM_INLINE void glm_frustum_center(vec4 corners[8], vec4 dest) { vec4 center; glm_vec4_copy(corners[0], center); glm_vec4_add(corners[1], center, center); glm_vec4_add(corners[2], center, center); glm_vec4_add(corners[3], center, center); glm_vec4_add(corners[4], center, center); glm_vec4_add(corners[5], center, center); glm_vec4_add(corners[6], center, center); glm_vec4_add(corners[7], center, center); glm_vec4_scale(center, 0.125f, dest); } /*! * @brief finds bounding box of frustum relative to given matrix e.g. view mat * * @param[in] corners view frustum corners * @param[in] m matrix to convert existing conners * @param[out] box bounding box as array [min, max] */ CGLM_INLINE void glm_frustum_box(vec4 corners[8], mat4 m, vec3 box[2]) { vec4 v; vec3 min, max; int i; glm_vec3_broadcast(FLT_MAX, min); glm_vec3_broadcast(-FLT_MAX, max); for (i = 0; i < 8; i++) { glm_mat4_mulv(m, corners[i], v); min[0] = glm_min(min[0], v[0]); min[1] = glm_min(min[1], v[1]); min[2] = glm_min(min[2], v[2]); max[0] = glm_max(max[0], v[0]); max[1] = glm_max(max[1], v[1]); max[2] = glm_max(max[2], v[2]); } glm_vec3_copy(min, box[0]); glm_vec3_copy(max, box[1]); } /*! * @brief finds planes corners which is between near and far planes (parallel) * * this will be helpful if you want to split a frustum e.g. CSM/PSSM. This will * find planes' corners but you will need to one more plane. * Actually you have it, it is near, far or created previously with this func ;) * * @param[in] corners view frustum corners * @param[in] splitDist split distance * @param[in] farDist far distance (zFar) * @param[out] planeCorners plane corners [LB, LT, RT, RB] */ CGLM_INLINE void glm_frustum_corners_at(vec4 corners[8], float splitDist, float farDist, vec4 planeCorners[4]) { vec4 corner; float dist, sc; /* because distance and scale is same for all */ dist = glm_vec3_distance(corners[GLM_RTF], corners[GLM_RTN]); sc = dist * (splitDist / farDist); /* left bottom */ glm_vec4_sub(corners[GLM_LBF], corners[GLM_LBN], corner); glm_vec4_scale_as(corner, sc, corner); glm_vec4_add(corners[GLM_LBN], corner, planeCorners[0]); /* left top */ glm_vec4_sub(corners[GLM_LTF], corners[GLM_LTN], corner); glm_vec4_scale_as(corner, sc, corner); glm_vec4_add(corners[GLM_LTN], corner, planeCorners[1]); /* right top */ glm_vec4_sub(corners[GLM_RTF], corners[GLM_RTN], corner); glm_vec4_scale_as(corner, sc, corner); glm_vec4_add(corners[GLM_RTN], corner, planeCorners[2]); /* right bottom */ glm_vec4_sub(corners[GLM_RBF], corners[GLM_RBN], corner); glm_vec4_scale_as(corner, sc, corner); glm_vec4_add(corners[GLM_RBN], corner, planeCorners[3]); } #endif /* cglm_frustum_h */ cglm-0.9.6/include/cglm/handed/000077500000000000000000000000001475344456400162605ustar00rootroot00000000000000cglm-0.9.6/include/cglm/handed/euler_to_quat_lh.h000066400000000000000000000114631475344456400217710ustar00rootroot00000000000000/* * 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*/ cglm-0.9.6/include/cglm/handed/euler_to_quat_rh.h000066400000000000000000000114521475344456400217750ustar00rootroot00000000000000/* * 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*/ cglm-0.9.6/include/cglm/io.h000066400000000000000000000240061475344456400156170ustar00rootroot00000000000000/* * 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_mat4_print(mat4 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_ivec4_print(ivec4 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_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_arch_print(FILE *ostream); */ /* cglm tried to enable print functions in debug mode and disable them in release/production mode to eliminate printing costs. if you need to force enable then define CGLM_DEFINE_PRINTS macro not DEBUG one Print functions are enabled if: - DEBUG or _DEBUG macro is defined (mostly defined automatically in debugging) - CGLM_DEFINE_PRINTS macro is defined including release/production which makes enabled printing always - glmc_ calls for io are always prints */ /* DEPRECATED: CGLM_NO_PRINTS_NOOP (use CGLM_DEFINE_PRINTS) */ #ifndef cglm_io_h #define cglm_io_h #if !defined(NDEBUG) \ || defined(CGLM_DEFINE_PRINTS) || defined(CGLM_LIB_SRC) \ || defined(CGLM_NO_PRINTS_NOOP) #include "common.h" #include "util.h" #include #include #ifndef CGLM_PRINT_PRECISION # define CGLM_PRINT_PRECISION 5 #endif #ifndef CGLM_PRINT_MAX_TO_SHORT # define CGLM_PRINT_MAX_TO_SHORT 1e5f #endif #ifndef GLM_TESTS_NO_COLORFUL_OUTPUT # ifndef CGLM_PRINT_COLOR # define CGLM_PRINT_COLOR "\033[36m" # endif # ifndef CGLM_PRINT_COLOR_RESET # define CGLM_PRINT_COLOR_RESET "\033[0m" # endif #else # ifndef CGLM_PRINT_COLOR # define CGLM_PRINT_COLOR # endif # ifndef CGLM_PRINT_COLOR_RESET # define CGLM_PRINT_COLOR_RESET # endif #endif /*! * @brief prints current SIMD path in general * * @param[in] ostream stream to print e.g. stdout, stderr, FILE ... */ CGLM_INLINE void glm_arch_print(FILE* __restrict ostream) { fprintf(ostream, CGLM_PRINT_COLOR "arch: " #if defined(CGLM_SIMD_WASM) "wasm SIMD128" #elif defined(CGLM_SIMD_x86) "x86 SSE* " # ifdef __AVX__ " AVX" # endif #elif defined(CGLM_SIMD_ARM) "arm" # ifndef __ARM_NEON_FP " NEON_FP" # endif # ifdef CGLM_ARM64 " ARM64" # endif #else "uncommon" #endif CGLM_PRINT_COLOR_RESET); } /*! * @brief prints current SIMD path in general * * @param[in] ostream stream to print e.g. stdout, stderr, FILE ... */ CGLM_INLINE void glm_arch_print_name(FILE* __restrict ostream) { fprintf(ostream, CGLM_PRINT_COLOR "\ncglm "); glm_arch_print(ostream); fprintf(ostream, "\n\n" CGLM_PRINT_COLOR_RESET); } CGLM_INLINE void glm_mat4_print(mat4 matrix, FILE * __restrict ostream) { char buff[16]; int i, j, cw[4], cwi; #define m 4 #define n 4 fprintf(ostream, "Matrix (float%dx%d): " CGLM_PRINT_COLOR "\n" , m, n); cw[0] = cw[1] = cw[2] = cw[3] = 0; for (i = 0; i < m; i++) { for (j = 0; j < n; j++) { if (matrix[i][j] < CGLM_PRINT_MAX_TO_SHORT) cwi = snprintf(buff, sizeof(buff), "% .*f", CGLM_PRINT_PRECISION, (double)matrix[i][j]); else cwi = snprintf(buff, sizeof(buff), "% g", (double)matrix[i][j]); cw[i] = GLM_MAX(cw[i], cwi); } } for (i = 0; i < m; i++) { fprintf(ostream, " |"); for (j = 0; j < n; j++) if (matrix[i][j] < CGLM_PRINT_MAX_TO_SHORT) fprintf(ostream, " % *.*f", cw[j], CGLM_PRINT_PRECISION, (double)matrix[j][i]); else fprintf(ostream, " % *g", cw[j], (double)matrix[j][i]); fprintf(ostream, " |\n"); } fprintf(ostream, CGLM_PRINT_COLOR_RESET "\n"); #undef m #undef n } CGLM_INLINE void glm_mat3_print(mat3 matrix, FILE * __restrict ostream) { char buff[16]; int i, j, cw[4], cwi; #define m 3 #define n 3 fprintf(ostream, "Matrix (float%dx%d): " CGLM_PRINT_COLOR "\n", m, n); cw[0] = cw[1] = cw[2] = 0; for (i = 0; i < m; i++) { for (j = 0; j < n; j++) { if (matrix[i][j] < CGLM_PRINT_MAX_TO_SHORT) cwi = snprintf(buff, sizeof(buff), "% .*f", CGLM_PRINT_PRECISION, (double)matrix[i][j]); else cwi = snprintf(buff, sizeof(buff), "% g", (double)matrix[i][j]); cw[i] = GLM_MAX(cw[i], cwi); } } for (i = 0; i < m; i++) { fprintf(ostream, " |"); for (j = 0; j < n; j++) if (matrix[i][j] < CGLM_PRINT_MAX_TO_SHORT) fprintf(ostream, " % *.*f", cw[j], CGLM_PRINT_PRECISION, (double)matrix[j][i]); else fprintf(ostream, " % *g", cw[j], (double)matrix[j][i]); fprintf(ostream, " |\n"); } fprintf(ostream, CGLM_PRINT_COLOR_RESET "\n"); #undef m #undef n } CGLM_INLINE void glm_mat2_print(mat2 matrix, FILE * __restrict ostream) { char buff[16]; int i, j, cw[4], cwi; #define m 2 #define n 2 fprintf(ostream, "Matrix (float%dx%d): " CGLM_PRINT_COLOR "\n", m, n); cw[0] = cw[1] = 0; for (i = 0; i < m; i++) { for (j = 0; j < n; j++) { if (matrix[i][j] < CGLM_PRINT_MAX_TO_SHORT) cwi = snprintf(buff, sizeof(buff), "% .*f", CGLM_PRINT_PRECISION, (double)matrix[i][j]); else cwi = snprintf(buff, sizeof(buff), "% g", (double)matrix[i][j]); cw[i] = GLM_MAX(cw[i], cwi); } } for (i = 0; i < m; i++) { fprintf(ostream, " |"); for (j = 0; j < n; j++) if (matrix[i][j] < CGLM_PRINT_MAX_TO_SHORT) fprintf(ostream, " % *.*f", cw[j], CGLM_PRINT_PRECISION, (double)matrix[j][i]); else fprintf(ostream, " % *g", cw[j], (double)matrix[j][i]); fprintf(ostream, " |\n"); } fprintf(ostream, CGLM_PRINT_COLOR_RESET "\n"); #undef m #undef n } CGLM_INLINE void glm_vec4_print(vec4 vec, FILE * __restrict ostream) { int i; #define m 4 fprintf(ostream, "Vector (float%d): " CGLM_PRINT_COLOR "\n (", m); for (i = 0; i < m; i++) { if (vec[i] < CGLM_PRINT_MAX_TO_SHORT) fprintf(ostream, " % .*f", CGLM_PRINT_PRECISION, (double)vec[i]); else fprintf(ostream, " % g", (double)vec[i]); } fprintf(ostream, " )" CGLM_PRINT_COLOR_RESET "\n\n"); #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 void glm_vec3_print(vec3 vec, FILE * __restrict ostream) { int i; #define m 3 fprintf(ostream, "Vector (float%d): " CGLM_PRINT_COLOR "\n (", m); for (i = 0; i < m; i++) { if (vec[i] < CGLM_PRINT_MAX_TO_SHORT) fprintf(ostream, " % .*f", CGLM_PRINT_PRECISION, (double)vec[i]); else fprintf(ostream, " % g", (double)vec[i]); } fprintf(ostream, " )" CGLM_PRINT_COLOR_RESET "\n\n"); #undef m } CGLM_INLINE void glm_ivec3_print(ivec3 vec, FILE * __restrict ostream) { int i; #define m 3 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 void glm_vec2_print(vec2 vec, FILE * __restrict ostream) { int i; #define m 2 fprintf(ostream, "Vector (float%d): " CGLM_PRINT_COLOR "\n (", m); for (i = 0; i < m; i++) { if (vec[i] < CGLM_PRINT_MAX_TO_SHORT) fprintf(ostream, " % .*f", CGLM_PRINT_PRECISION, (double)vec[i]); else fprintf(ostream, " % g", (double)vec[i]); } fprintf(ostream, " )" CGLM_PRINT_COLOR_RESET "\n\n"); #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 void glm_versor_print(versor vec, FILE * __restrict ostream) { int i; #define m 4 fprintf(ostream, "Quaternion (float%d): " CGLM_PRINT_COLOR "\n (", m); for (i = 0; i < m; i++) { if (vec[i] < CGLM_PRINT_MAX_TO_SHORT) fprintf(ostream, " % .*f", CGLM_PRINT_PRECISION, (double)vec[i]); else fprintf(ostream, " % g", (double)vec[i]); } fprintf(ostream, " )" CGLM_PRINT_COLOR_RESET "\n\n"); #undef m } CGLM_INLINE void glm_aabb_print(vec3 bbox[2], const char * __restrict tag, FILE * __restrict ostream) { int i, j; #define m 3 fprintf(ostream, "AABB (%s): " CGLM_PRINT_COLOR "\n", tag ? tag: "float"); for (i = 0; i < 2; i++) { fprintf(ostream, " ("); for (j = 0; j < m; j++) { if (bbox[i][j] < CGLM_PRINT_MAX_TO_SHORT) fprintf(ostream, " % .*f", CGLM_PRINT_PRECISION, (double)bbox[i][j]); else fprintf(ostream, " % g", (double)bbox[i][j]); } fprintf(ostream, " )\n"); } fprintf(ostream, CGLM_PRINT_COLOR_RESET "\n"); #undef m } #else #include "common.h" #include #include /* NOOP: Remove print from DEBUG */ #define glm_mat4_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_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_ivec3_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_aabb_print(v, t, s) (void)v; (void)t; (void)s; #define glm_arch_print(s) (void)s; #define glm_arch_print_name(s) (void)s; #endif #endif /* cglm_io_h */ cglm-0.9.6/include/cglm/ivec2.h000066400000000000000000000351651475344456400162300ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ /* Macros: GLM_IVEC2_ONE_INIT GLM_IVEC2_ZERO_INIT GLM_IVEC2_ONE GLM_IVEC2_ZERO Functions: CGLM_INLINE void glm_ivec2(int * __restrict v, ivec2 dest) CGLM_INLINE void glm_ivec2_copy(ivec2 a, ivec2 dest) CGLM_INLINE void glm_ivec2_zero(ivec2 v) CGLM_INLINE void glm_ivec2_one(ivec2 v) CGLM_INLINE int glm_ivec2_dot(ivec2 a, ivec2 b) CGLM_INLINE int glm_ivec2_cross(ivec2 a, ivec2 b) CGLM_INLINE void glm_ivec2_add(ivec2 a, ivec2 b, ivec2 dest) CGLM_INLINE void glm_ivec2_adds(ivec2 v, int s, ivec2 dest) CGLM_INLINE void glm_ivec2_sub(ivec2 a, ivec2 b, 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_scale(ivec2 v, int s, ivec2 dest) CGLM_INLINE void glm_ivec2_div(ivec2 a, ivec2 b, ivec2 dest) CGLM_INLINE void glm_ivec2_divs(ivec2 v, int s, ivec2 dest) CGLM_INLINE void glm_ivec2_mod(ivec2 a, ivec2 b, 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 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_minv(ivec2 a, ivec2 b, ivec2 dest) CGLM_INLINE void glm_ivec2_clamp(ivec2 v, int minVal, int maxVal) CGLM_INLINE void glm_ivec2_abs(ivec2 v, ivec2 dest) */ #ifndef cglm_ivec2_h #define cglm_ivec2_h #include "common.h" #include "util.h" #define GLM_IVEC2_ONE_INIT {1, 1} #define GLM_IVEC2_ZERO_INIT {0, 0} #define GLM_IVEC2_ONE ((ivec2)GLM_IVEC2_ONE_INIT) #define GLM_IVEC2_ZERO ((ivec2)GLM_IVEC2_ZERO_INIT) /*! * @brief init ivec2 using vec3 or vec4 * * @param[in] v vector * @param[out] dest destination */ CGLM_INLINE void glm_ivec2(int * __restrict v, ivec2 dest) { dest[0] = v[0]; dest[1] = v[1]; } /*! * @brief copy all members of [a] to [dest] * * @param[in] a source vector * @param[out] dest destination */ CGLM_INLINE void glm_ivec2_copy(ivec2 a, ivec2 dest) { dest[0] = a[0]; dest[1] = a[1]; } /*! * @brief set all members of [v] to zero * * @param[out] v vector */ CGLM_INLINE void glm_ivec2_zero(ivec2 v) { v[0] = v[1] = 0; } /*! * @brief set all members of [v] to one * * @param[out] v vector */ CGLM_INLINE void glm_ivec2_one(ivec2 v) { v[0] = v[1] = 1; } /*! * @brief ivec2 dot product * * @param[in] a vector1 * @param[in] b vector2 * * @return dot product */ CGLM_INLINE int glm_ivec2_dot(ivec2 a, ivec2 b) { return a[0] * b[0] + a[1] * b[1]; } /*! * @brief ivec2 cross product * * REF: http://allenchou.net/2013/07/cross-product-of-2d-vectors/ * * @param[in] a vector1 * @param[in] b vector2 * * @return Z component of cross product */ CGLM_INLINE int glm_ivec2_cross(ivec2 a, ivec2 b) { return a[0] * b[1] - a[1] * b[0]; } /*! * @brief add vector [a] to vector [b] and store result in [dest] * * @param[in] a first vector * @param[in] b second vector * @param[out] dest destination */ CGLM_INLINE void glm_ivec2_add(ivec2 a, ivec2 b, ivec2 dest) { dest[0] = a[0] + b[0]; dest[1] = a[1] + b[1]; } /*! * @brief add scalar s to vector [v] and store result in [dest] * * @param[in] v vector * @param[in] s scalar * @param[out] dest destination */ CGLM_INLINE void glm_ivec2_adds(ivec2 v, int s, ivec2 dest) { dest[0] = v[0] + s; dest[1] = v[1] + s; } /*! * @brief subtract vector [b] from vector [a] and store result in [dest] * * @param[in] a first vector * @param[in] b second vector * @param[out] dest destination */ CGLM_INLINE void glm_ivec2_sub(ivec2 a, ivec2 b, ivec2 dest) { dest[0] = a[0] - b[0]; dest[1] = a[1] - b[1]; } /*! * @brief subtract scalar s from vector [v] and store result in [dest] * * @param[in] v vector * @param[in] s scalar * @param[out] dest destination */ CGLM_INLINE void glm_ivec2_subs(ivec2 v, int s, ivec2 dest) { dest[0] = v[0] - s; dest[1] = v[1] - s; } /*! * @brief multiply vector [a] with vector [b] and store result in [dest] * * @param[in] a first vector * @param[in] b second vector * @param[out] dest destination */ CGLM_INLINE void glm_ivec2_mul(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 store result in [dest] * * @param[in] v vector * @param[in] s scalar * @param[out] dest destination */ CGLM_INLINE void glm_ivec2_scale(ivec2 v, int s, ivec2 dest) { dest[0] = v[0] * s; dest[1] = v[1] * s; } /*! * @brief div vector with another component-wise division: d = a / b * * @param[in] a vector 1 * @param[in] b vector 2 * @param[out] dest result = (a[0]/b[0], a[1]/b[1]) */ CGLM_INLINE void glm_ivec2_div(ivec2 a, ivec2 b, ivec2 dest) { dest[0] = a[0] / b[0]; dest[1] = a[1] / b[1]; } /*! * @brief div vector with scalar: d = v / s * * @param[in] v vector * @param[in] s scalar * @param[out] dest result = (a[0]/s, a[1]/s) */ CGLM_INLINE void glm_ivec2_divs(ivec2 v, int s, ivec2 dest) { dest[0] = v[0] / s; dest[1] = v[1] / s; } /*! * @brief mod vector with another component-wise modulo: d = a % b * * @param[in] a vector 1 * @param[in] b vector 2 * @param[out] dest result = (a[0]%b[0], a[1]%b[1]) */ CGLM_INLINE void glm_ivec2_mod(ivec2 a, ivec2 b, ivec2 dest) { dest[0] = a[0] % b[0]; dest[1] = a[1] % b[1]; } /*! * @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 * * @param[in] a first vector * @param[in] b second vector * @return returns squared distance (distance * distance) */ CGLM_INLINE int glm_ivec2_distance2(ivec2 a, ivec2 b) { int xd, yd; xd = a[0] - b[0]; yd = a[1] - b[1]; return xd * xd + yd * yd; } /*! * @brief distance between two vectors * * @param[in] a first vector * @param[in] b second vector * @return returns distance */ CGLM_INLINE float glm_ivec2_distance(ivec2 a, ivec2 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 * * @param[in] a first vector * @param[in] b second vector * @param[out] dest destination */ CGLM_INLINE void glm_ivec2_maxv(ivec2 a, ivec2 b, ivec2 dest) { dest[0] = a[0] > b[0] ? a[0] : b[0]; dest[1] = a[1] > b[1] ? a[1] : b[1]; } /*! * @brief set each member of dest to lesser of vector a and b * * @param[in] a first vector * @param[in] b second vector * @param[out] dest destination */ CGLM_INLINE void glm_ivec2_minv(ivec2 a, ivec2 b, ivec2 dest) { dest[0] = a[0] < b[0] ? a[0] : b[0]; dest[1] = a[1] < b[1] ? a[1] : b[1]; } /*! * @brief clamp each member of [v] between minVal and maxVal (inclusive) * * @param[in, out] v vector * @param[in] minVal minimum value * @param[in] maxVal maximum value */ CGLM_INLINE void glm_ivec2_clamp(ivec2 v, int minVal, int maxVal) { if (v[0] < minVal) v[0] = minVal; else if(v[0] > maxVal) v[0] = maxVal; if (v[1] < minVal) v[1] = minVal; else if(v[1] > maxVal) v[1] = maxVal; } /*! * @brief absolute value of v * * @param[in] v vector * @param[out] dest destination */ CGLM_INLINE void glm_ivec2_abs(ivec2 v, ivec2 dest) { dest[0] = abs(v[0]); dest[1] = abs(v[1]); } #endif /* cglm_ivec2_h */ cglm-0.9.6/include/cglm/ivec3.h000066400000000000000000000400361475344456400162220ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ /* Macros: GLM_IVEC3_ONE_INIT GLM_IVEC3_ZERO_INIT GLM_IVEC3_ONE GLM_IVEC3_ZERO Functions: CGLM_INLINE void glm_ivec3(ivec4 v4, ivec3 dest) CGLM_INLINE void glm_ivec3_copy(ivec3 a, ivec3 dest) CGLM_INLINE void glm_ivec3_zero(ivec3 v) CGLM_INLINE void glm_ivec3_one(ivec3 v) CGLM_INLINE int glm_ivec3_dot(ivec3 a, ivec3 b) CGLM_INLINE int glm_ivec3_norm2(ivec3 v) CGLM_INLINE int glm_ivec3_norm(ivec3 v) CGLM_INLINE void glm_ivec3_add(ivec3 a, ivec3 b, ivec3 dest) CGLM_INLINE void glm_ivec3_adds(ivec3 v, int s, ivec3 dest) CGLM_INLINE void glm_ivec3_sub(ivec3 a, ivec3 b, 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_scale(ivec3 v, int s, ivec3 dest) CGLM_INLINE void glm_ivec3_div(ivec3 a, ivec3 b, ivec3 dest) CGLM_INLINE void glm_ivec3_divs(ivec3 v, int s, ivec3 dest) CGLM_INLINE void glm_ivec3_mod(ivec3 a, ivec3 b, 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 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_minv(ivec3 a, ivec3 b, ivec3 dest) CGLM_INLINE void glm_ivec3_clamp(ivec3 v, int minVal, int maxVal) CGLM_INLINE void glm_ivec3_abs(ivec3 v, ivec3 dest) */ #ifndef cglm_ivec3_h #define cglm_ivec3_h #include "common.h" #include "util.h" #define GLM_IVEC3_ONE_INIT {1, 1, 1} #define GLM_IVEC3_ZERO_INIT {0, 0, 0} #define GLM_IVEC3_ONE ((ivec3)GLM_IVEC3_ONE_INIT) #define GLM_IVEC3_ZERO ((ivec3)GLM_IVEC3_ZERO_INIT) /*! * @brief init ivec3 using ivec4 * * @param[in] v4 vector4 * @param[out] dest destination */ CGLM_INLINE void glm_ivec3(ivec4 v4, ivec3 dest) { dest[0] = v4[0]; dest[1] = v4[1]; dest[2] = v4[2]; } /*! * @brief copy all members of [a] to [dest] * * @param[in] a source vector * @param[out] dest destination */ CGLM_INLINE void glm_ivec3_copy(ivec3 a, ivec3 dest) { dest[0] = a[0]; dest[1] = a[1]; dest[2] = a[2]; } /*! * @brief set all members of [v] to zero * * @param[out] v vector */ CGLM_INLINE void glm_ivec3_zero(ivec3 v) { v[0] = v[1] = v[2] = 0; } /*! * @brief set all members of [v] to one * * @param[out] v vector */ CGLM_INLINE void glm_ivec3_one(ivec3 v) { v[0] = v[1] = v[2] = 1; } /*! * @brief ivec3 dot product * * @param[in] a vector1 * @param[in] b vector2 * * @return dot product */ CGLM_INLINE int glm_ivec3_dot(ivec3 a, ivec3 b) { return a[0] * b[0] + a[1] * b[1] + a[2] * b[2]; } /*! * @brief norm * norm (magnitude) of vec * * we can use this func instead of calling norm * norm, because it would call * sqrtf function twice but with this func we can avoid func call, maybe this is * not good name for this func * * @param[in] v vector * * @return norm * norm */ CGLM_INLINE int glm_ivec3_norm2(ivec3 v) { return glm_ivec3_dot(v, v); } /*! * @brief euclidean norm (magnitude), also called L2 norm * this will give magnitude of vector in euclidean space * * @param[in] v vector * * @return norm */ CGLM_INLINE int glm_ivec3_norm(ivec3 v) { return (int)sqrtf((float)glm_ivec3_norm2(v)); } /*! * @brief add vector [a] to vector [b] and store result in [dest] * * @param[in] a first vector * @param[in] b second vector * @param[out] dest destination */ CGLM_INLINE void glm_ivec3_add(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 [v] and store result in [dest] * * @param[in] v vector * @param[in] s scalar * @param[out] dest destination */ CGLM_INLINE void glm_ivec3_adds(ivec3 v, int s, ivec3 dest) { dest[0] = v[0] + s; dest[1] = v[1] + s; dest[2] = v[2] + s; } /*! * @brief subtract vector [b] from vector [a] and store result in [dest] * * @param[in] a first vector * @param[in] b second vector * @param[out] dest destination */ CGLM_INLINE void glm_ivec3_sub(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 [v] and store result in [dest] * * @param[in] v vector * @param[in] s scalar * @param[out] dest destination */ CGLM_INLINE void glm_ivec3_subs(ivec3 v, int s, ivec3 dest) { dest[0] = v[0] - s; dest[1] = v[1] - s; dest[2] = v[2] - s; } /*! * @brief multiply vector [a] with vector [b] and store result in [dest] * * @param[in] a first vector * @param[in] b second vector * @param[out] dest destination */ CGLM_INLINE void glm_ivec3_mul(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 store result in [dest] * * @param[in] v vector * @param[in] s scalar * @param[out] dest destination */ CGLM_INLINE void glm_ivec3_scale(ivec3 v, int s, ivec3 dest) { dest[0] = v[0] * s; dest[1] = v[1] * s; dest[2] = v[2] * s; } /*! * @brief div vector with another component-wise division: d = a / b * * @param[in] a vector 1 * @param[in] b vector 2 * @param[out] dest result = (a[0]/b[0], a[1]/b[1], a[2]/b[2]) */ CGLM_INLINE void glm_ivec3_div(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 div vector with scalar: d = v / s * * @param[in] v vector * @param[in] s scalar * @param[out] dest result = (a[0]/s, a[1]/s, a[2]/s) */ CGLM_INLINE void glm_ivec3_divs(ivec3 v, int s, ivec3 dest) { dest[0] = v[0] / s; dest[1] = v[1] / s; dest[2] = v[2] / s; } /*! * @brief Element-wise modulo operation on ivec3 vectors: dest = a % b * * Performs element-wise modulo on each component of vectors `a` and `b`. * * @param[in] a vector 1 * @param[in] b vector 2 * @param[out] dest result = (a[0]%b[0], a[1]%b[1], a[2]%b[2]) */ CGLM_INLINE void glm_ivec3_mod(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 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 * * @param[in] a first vector * @param[in] b second vector * @return returns squared distance (distance * distance) */ CGLM_INLINE int glm_ivec3_distance2(ivec3 a, ivec3 b) { int xd, yd, zd; xd = a[0] - b[0]; yd = a[1] - b[1]; zd = a[2] - b[2]; return xd * xd + yd * yd + zd * zd; } /*! * @brief distance between two vectors * * @param[in] a first vector * @param[in] b second vector * @return returns distance */ CGLM_INLINE float glm_ivec3_distance(ivec3 a, ivec3 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 * * @param[in] a first vector * @param[in] b second vector * @param[out] dest destination */ CGLM_INLINE void glm_ivec3_maxv(ivec3 a, ivec3 b, ivec3 dest) { dest[0] = a[0] > b[0] ? a[0] : b[0]; dest[1] = a[1] > b[1] ? a[1] : b[1]; dest[2] = a[2] > b[2] ? a[2] : b[2]; } /*! * @brief set each member of dest to lesser of vector a and b * * @param[in] a first vector * @param[in] b second vector * @param[out] dest destination */ CGLM_INLINE void glm_ivec3_minv(ivec3 a, ivec3 b, ivec3 dest) { dest[0] = a[0] < b[0] ? a[0] : b[0]; dest[1] = a[1] < b[1] ? a[1] : b[1]; dest[2] = a[2] < b[2] ? a[2] : b[2]; } /*! * @brief clamp each member of [v] between minVal and maxVal (inclusive) * * @param[in, out] v vector * @param[in] minVal minimum value * @param[in] maxVal maximum value */ CGLM_INLINE void glm_ivec3_clamp(ivec3 v, int minVal, int maxVal) { if (v[0] < minVal) v[0] = minVal; else if(v[0] > maxVal) v[0] = maxVal; if (v[1] < minVal) v[1] = minVal; else if(v[1] > maxVal) v[1] = maxVal; if (v[2] < minVal) v[2] = minVal; else if(v[2] > maxVal) v[2] = maxVal; } /*! * @brief absolute value of v * * @param[in] v vector * @param[out] dest destination */ CGLM_INLINE void glm_ivec3_abs(ivec3 v, ivec3 dest) { dest[0] = abs(v[0]); dest[1] = abs(v[1]); dest[2] = abs(v[2]); } #endif /* cglm_ivec3_h */ cglm-0.9.6/include/cglm/ivec4.h000066400000000000000000000337301475344456400162260ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ /* Macros: GLM_IVEC4_ONE_INIT GLM_IVEC4_ZERO_INIT GLM_IVEC4_ONE GLM_IVEC4_ZERO Functions: CGLM_INLINE void glm_ivec4(ivec3 v3, int last, ivec4 dest) CGLM_INLINE void glm_ivec4_copy(ivec4 a, ivec4 dest) CGLM_INLINE void glm_ivec4_zero(ivec4 v) CGLM_INLINE void glm_ivec4_one(ivec4 v) CGLM_INLINE void glm_ivec4_add(ivec4 a, ivec4 b, ivec4 dest) CGLM_INLINE void glm_ivec4_adds(ivec4 v, int s, ivec4 dest) CGLM_INLINE void glm_ivec4_sub(ivec4 a, ivec4 b, 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_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 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_minv(ivec4 a, ivec4 b, ivec4 dest) CGLM_INLINE void glm_ivec4_clamp(ivec4 v, int minVal, int maxVal) CGLM_INLINE void glm_ivec4_abs(ivec4 v, ivec4 dest) */ #ifndef cglm_ivec4_h #define cglm_ivec4_h #include "common.h" #include "util.h" #define GLM_IVEC4_ONE_INIT {1, 1, 1, 1} #define GLM_IVEC4_ZERO_INIT {0, 0, 0, 0} #define GLM_IVEC4_ONE ((ivec4)GLM_IVEC4_ONE_INIT) #define GLM_IVEC4_ZERO ((ivec4)GLM_IVEC4_ZERO_INIT) /*! * @brief init ivec4 using ivec3 * * @param[in] v3 vector3 * @param[in] last last item * @param[out] dest destination */ CGLM_INLINE void glm_ivec4(ivec3 v3, int last, ivec4 dest) { dest[0] = v3[0]; dest[1] = v3[1]; dest[2] = v3[2]; dest[3] = last; } /*! * @brief copy all members of [a] to [dest] * * @param[in] a source vector * @param[out] dest destination */ CGLM_INLINE void glm_ivec4_copy(ivec4 a, ivec4 dest) { dest[0] = a[0]; dest[1] = a[1]; dest[2] = a[2]; dest[3] = a[3]; } /*! * @brief set all members of [v] to zero * * @param[out] v vector */ CGLM_INLINE void glm_ivec4_zero(ivec4 v) { v[0] = v[1] = v[2] = v[3] = 0; } /*! * @brief set all members of [v] to one * * @param[out] v vector */ CGLM_INLINE void glm_ivec4_one(ivec4 v) { v[0] = v[1] = v[2] = v[3] = 1; } /*! * @brief add vector [a] to vector [b] and store result in [dest] * * @param[in] a first vector * @param[in] b second vector * @param[out] dest destination */ CGLM_INLINE void glm_ivec4_add(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 [v] and store result in [dest] * * @param[in] v vector * @param[in] s scalar * @param[out] dest destination */ CGLM_INLINE void glm_ivec4_adds(ivec4 v, int s, ivec4 dest) { dest[0] = v[0] + s; dest[1] = v[1] + s; dest[2] = v[2] + s; dest[3] = v[3] + s; } /*! * @brief subtract vector [b] from vector [a] and store result in [dest] * * @param[in] a first vector * @param[in] b second vector * @param[out] dest destination */ CGLM_INLINE void glm_ivec4_sub(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 [v] and store result in [dest] * * @param[in] v vector * @param[in] s scalar * @param[out] dest destination */ CGLM_INLINE void glm_ivec4_subs(ivec4 v, int s, ivec4 dest) { dest[0] = v[0] - s; dest[1] = v[1] - s; dest[2] = v[2] - s; dest[3] = v[3] - s; } /*! * @brief multiply vector [a] with vector [b] and store result in [dest] * * @param[in] a first vector * @param[in] b second vector * @param[out] dest destination */ CGLM_INLINE void glm_ivec4_mul(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 store result in [dest] * * @param[in] v vector * @param[in] s scalar * @param[out] dest destination */ CGLM_INLINE void glm_ivec4_scale(ivec4 v, int s, ivec4 dest) { dest[0] = v[0] * s; dest[1] = v[1] * s; dest[2] = v[2] * 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 * * @param[in] a first vector * @param[in] b second vector * @return returns squared distance (distance * distance) */ CGLM_INLINE int glm_ivec4_distance2(ivec4 a, ivec4 b) { int xd, yd, zd, wd; xd = a[0] - b[0]; yd = a[1] - b[1]; zd = a[2] - b[2]; wd = a[3] - b[3]; return xd * xd + yd * yd + zd * zd + wd * wd; } /*! * @brief distance between two vectors * * @param[in] a first vector * @param[in] b second vector * @return returns distance */ CGLM_INLINE float glm_ivec4_distance(ivec4 a, ivec4 b) { return sqrtf((float)glm_ivec4_distance2(a, b)); } /*! * @brief set each member of dest to greater of vector a and b * * @param[in] a first vector * @param[in] b second vector * @param[out] dest destination */ CGLM_INLINE void glm_ivec4_maxv(ivec4 a, ivec4 b, ivec4 dest) { dest[0] = a[0] > b[0] ? a[0] : b[0]; dest[1] = a[1] > b[1] ? a[1] : b[1]; dest[2] = a[2] > b[2] ? a[2] : b[2]; dest[3] = a[3] > b[3] ? a[3] : b[3]; } /*! * @brief set each member of dest to lesser of vector a and b * * @param[in] a first vector * @param[in] b second vector * @param[out] dest destination */ CGLM_INLINE void glm_ivec4_minv(ivec4 a, ivec4 b, ivec4 dest) { dest[0] = a[0] < b[0] ? a[0] : b[0]; dest[1] = a[1] < b[1] ? a[1] : b[1]; dest[2] = a[2] < b[2] ? a[2] : b[2]; dest[3] = a[3] < b[3] ? a[3] : b[3]; } /*! * @brief clamp each member of [v] between minVal and maxVal (inclusive) * * @param[in, out] v vector * @param[in] minVal minimum value * @param[in] maxVal maximum value */ CGLM_INLINE void glm_ivec4_clamp(ivec4 v, int minVal, int maxVal) { if (v[0] < minVal) v[0] = minVal; else if(v[0] > maxVal) v[0] = maxVal; if (v[1] < minVal) v[1] = minVal; else if(v[1] > maxVal) v[1] = maxVal; if (v[2] < minVal) v[2] = minVal; else if(v[2] > maxVal) v[2] = maxVal; if (v[3] < minVal) v[3] = minVal; else if(v[3] > maxVal) v[3] = maxVal; } /*! * @brief absolute value of v * * @param[in] v vector * @param[out] dest destination */ CGLM_INLINE void glm_ivec4_abs(ivec4 v, ivec4 dest) { dest[0] = abs(v[0]); dest[1] = abs(v[1]); dest[2] = abs(v[2]); dest[3] = abs(v[3]); } #endif /* cglm_ivec4_h */ cglm-0.9.6/include/cglm/mat2.h000066400000000000000000000177371475344456400160700ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ /* Macros: GLM_MAT2_IDENTITY_INIT GLM_MAT2_ZERO_INIT GLM_MAT2_IDENTITY GLM_MAT2_ZERO Functions: CGLM_INLINE void glm_mat2_copy(mat2 mat, mat2 dest) CGLM_INLINE void glm_mat2_identity(mat2 mat) CGLM_INLINE void glm_mat2_identity_array(mat2 * restrict mat, size_t count) CGLM_INLINE void glm_mat2_zero(mat2 mat) CGLM_INLINE void glm_mat2_mul(mat2 m1, mat2 m2, mat2 dest) CGLM_INLINE void glm_mat2_transpose_to(mat2 m, mat2 dest) CGLM_INLINE void glm_mat2_transpose(mat2 m) CGLM_INLINE void glm_mat2_mulv(mat2 m, vec2 v, vec2 dest) CGLM_INLINE float glm_mat2_trace(mat2 m) CGLM_INLINE void glm_mat2_scale(mat2 m, float s) CGLM_INLINE float glm_mat2_det(mat2 mat) CGLM_INLINE void glm_mat2_inv(mat2 mat, mat2 dest) CGLM_INLINE void glm_mat2_swap_col(mat2 mat, int col1, int col2) CGLM_INLINE void glm_mat2_swap_row(mat2 mat, int row1, int row2) CGLM_INLINE float glm_mat2_rmc(vec2 r, mat2 m, vec2 c) CGLM_INLINE void glm_mat2_make(float * restrict src, mat2 dest) */ #ifndef cglm_mat2_h #define cglm_mat2_h #include "common.h" #include "vec2.h" #ifdef CGLM_SSE_FP # include "simd/sse2/mat2.h" #endif #ifdef CGLM_NEON_FP # include "simd/neon/mat2.h" #endif #ifdef CGLM_SIMD_WASM # include "simd/wasm/mat2.h" #endif #define GLM_MAT2_IDENTITY_INIT {{1.0f, 0.0f}, {0.0f, 1.0f}} #define GLM_MAT2_ZERO_INIT {{0.0f, 0.0f}, {0.0f, 0.0f}} /* for C only */ #define GLM_MAT2_IDENTITY ((mat2)GLM_MAT2_IDENTITY_INIT) #define GLM_MAT2_ZERO ((mat2)GLM_MAT2_ZERO_INIT) /*! * @brief copy all members of [mat] to [dest] * * @param[in] mat source * @param[out] dest destination */ CGLM_INLINE void glm_mat2_copy(mat2 mat, mat2 dest) { glm_vec4_ucopy(mat[0], dest[0]); } /*! * @brief make given matrix identity. It is identical with below, * but it is more easy to do that with this func especially for members * e.g. glm_mat2_identity(aStruct->aMatrix); * * @code * glm_mat2_copy(GLM_MAT2_IDENTITY, mat); // C only * * // or * mat2 mat = GLM_MAT2_IDENTITY_INIT; * @endcode * * @param[in, out] mat destination */ CGLM_INLINE void glm_mat2_identity(mat2 mat) { CGLM_ALIGN_MAT mat2 t = GLM_MAT2_IDENTITY_INIT; glm_mat2_copy(t, mat); } /*! * @brief make given matrix array's each element identity matrix * * @param[in, out] mat matrix array (must be aligned (16) * if alignment is not disabled) * * @param[in] count count of matrices */ CGLM_INLINE void glm_mat2_identity_array(mat2 * __restrict mat, size_t count) { CGLM_ALIGN_MAT mat2 t = GLM_MAT2_IDENTITY_INIT; size_t i; for (i = 0; i < count; i++) { glm_mat2_copy(t, mat[i]); } } /*! * @brief make given matrix zero. * * @param[in, out] mat matrix */ CGLM_INLINE void glm_mat2_zero(mat2 mat) { CGLM_ALIGN_MAT mat2 t = GLM_MAT2_ZERO_INIT; glm_mat2_copy(t, mat); } /*! * @brief multiply m1 and m2 to dest * * m1, m2 and dest matrices can be same matrix, it is possible to write this: * * @code * mat2 m = GLM_MAT2_IDENTITY_INIT; * glm_mat2_mul(m, m, m); * @endcode * * @param[in] m1 left matrix * @param[in] m2 right matrix * @param[out] dest destination matrix */ CGLM_INLINE void glm_mat2_mul(mat2 m1, mat2 m2, mat2 dest) { #if defined(__wasm__) && defined(__wasm_simd128__) glm_mat2_mul_wasm(m1, m2, dest); #elif defined( __SSE__ ) || defined( __SSE2__ ) glm_mat2_mul_sse2(m1, m2, dest); #elif defined(CGLM_NEON_FP) glm_mat2_mul_neon(m1, m2, dest); #else float a00 = m1[0][0], a01 = m1[0][1], a10 = m1[1][0], a11 = m1[1][1], b00 = m2[0][0], b01 = m2[0][1], b10 = m2[1][0], b11 = m2[1][1]; dest[0][0] = a00 * b00 + a10 * b01; dest[0][1] = a01 * b00 + a11 * b01; dest[1][0] = a00 * b10 + a10 * b11; dest[1][1] = a01 * b10 + a11 * b11; #endif } /*! * @brief transpose mat2 and store in dest * * source matrix will not be transposed unless dest is m * * @param[in] m matrix * @param[out] dest result */ CGLM_INLINE void glm_mat2_transpose_to(mat2 m, mat2 dest) { #if defined(__wasm__) && defined(__wasm_simd128__) glm_mat2_transp_wasm(m, dest); #elif defined( __SSE__ ) || defined( __SSE2__ ) glm_mat2_transp_sse2(m, dest); #else dest[0][0] = m[0][0]; dest[0][1] = m[1][0]; dest[1][0] = m[0][1]; dest[1][1] = m[1][1]; #endif } /*! * @brief transpose mat2 and store result in same matrix * * @param[in, out] m source and dest */ CGLM_INLINE void glm_mat2_transpose(mat2 m) { float tmp; tmp = m[0][1]; m[0][1] = m[1][0]; m[1][0] = tmp; } /*! * @brief multiply mat2 with vec2 (column vector) and store in dest vector * * @param[in] m mat2 (left) * @param[in] v vec2 (right, column vector) * @param[out] dest vec2 (result, column vector) */ CGLM_INLINE void glm_mat2_mulv(mat2 m, vec2 v, vec2 dest) { dest[0] = m[0][0] * v[0] + m[1][0] * v[1]; dest[1] = m[0][1] * v[0] + m[1][1] * v[1]; } /*! * @brief trace of matrix * * sum of the elements on the main diagonal from upper left to the lower right * * @param[in] m matrix */ CGLM_INLINE float glm_mat2_trace(mat2 m) { return m[0][0] + m[1][1]; } /*! * @brief scale (multiply with scalar) matrix * * multiply matrix with scalar * * @param[in, out] m matrix * @param[in] s scalar */ CGLM_INLINE void glm_mat2_scale(mat2 m, float s) { #if defined(__wasm__) && defined(__wasm_simd128__) glmm_store(m[0], wasm_f32x4_mul(wasm_v128_load(m[0]), wasm_f32x4_splat(s))); #elif defined( __SSE__ ) || defined( __SSE2__ ) glmm_store(m[0], _mm_mul_ps(_mm_loadu_ps(m[0]), glmm_set1(s))); #elif defined(CGLM_NEON_FP) vst1q_f32(m[0], vmulq_f32(vld1q_f32(m[0]), vdupq_n_f32(s))); #else m[0][0] = m[0][0] * s; m[0][1] = m[0][1] * s; m[1][0] = m[1][0] * s; m[1][1] = m[1][1] * s; #endif } /*! * @brief mat2 determinant * * @param[in] mat matrix * * @return determinant */ CGLM_INLINE float glm_mat2_det(mat2 mat) { return mat[0][0] * mat[1][1] - mat[1][0] * mat[0][1]; } /*! * @brief inverse mat2 and store in dest * * @param[in] mat matrix * @param[out] dest inverse matrix */ CGLM_INLINE void glm_mat2_inv(mat2 mat, mat2 dest) { float det; float a = mat[0][0], b = mat[0][1], c = mat[1][0], d = mat[1][1]; det = 1.0f / (a * d - b * c); dest[0][0] = d * det; dest[0][1] = -b * det; dest[1][0] = -c * det; dest[1][1] = a * det; } /*! * @brief swap two matrix columns * * @param[in,out] mat matrix * @param[in] col1 col1 * @param[in] col2 col2 */ CGLM_INLINE void glm_mat2_swap_col(mat2 mat, int col1, int col2) { float a, b; a = mat[col1][0]; b = mat[col1][1]; mat[col1][0] = mat[col2][0]; mat[col1][1] = mat[col2][1]; mat[col2][0] = a; mat[col2][1] = b; } /*! * @brief swap two matrix rows * * @param[in,out] mat matrix * @param[in] row1 row1 * @param[in] row2 row2 */ CGLM_INLINE void glm_mat2_swap_row(mat2 mat, int row1, int row2) { float a, b; a = mat[0][row1]; b = mat[1][row1]; mat[0][row1] = mat[0][row2]; mat[1][row1] = mat[1][row2]; mat[0][row2] = a; mat[1][row2] = b; } /*! * @brief helper for R (row vector) * M (matrix) * C (column vector) * * rmc stands for Row * Matrix * Column * * the result is scalar because R * M = Matrix1x2 (row vector), * then Matrix1x2 * Vec2 (column vector) = Matrix1x1 (Scalar) * * @param[in] r row vector or matrix1x2 * @param[in] m matrix2x2 * @param[in] c column vector or matrix2x1 * * @return scalar value e.g. Matrix1x1 */ CGLM_INLINE float glm_mat2_rmc(vec2 r, mat2 m, vec2 c) { vec2 tmp; glm_mat2_mulv(m, c, tmp); return glm_vec2_dot(r, tmp); } /*! * @brief Create mat2 matrix from pointer * * @param[in] src pointer to an array of floats * @param[out] dest matrix */ CGLM_INLINE void glm_mat2_make(const float * __restrict src, mat2 dest) { dest[0][0] = src[0]; dest[0][1] = src[1]; dest[1][0] = src[2]; dest[1][1] = src[3]; } #endif /* cglm_mat2_h */ cglm-0.9.6/include/cglm/mat2x3.h000066400000000000000000000071601475344456400163300ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ /* Macros: GLM_MAT2X3_ZERO_INIT GLM_MAT2X3_ZERO Functions: CGLM_INLINE void glm_mat2x3_copy(mat2x3 mat, mat2x3 dest); CGLM_INLINE void glm_mat2x3_zero(mat2x3 mat); CGLM_INLINE void glm_mat2x3_make(const float * __restrict src, mat2x3 dest); CGLM_INLINE void glm_mat2x3_mul(mat2x3 m1, mat3x2 m2, mat3 dest); CGLM_INLINE void glm_mat2x3_mulv(mat2x3 m, vec2 v, vec3 dest); CGLM_INLINE void glm_mat2x3_transpose(mat2x3 m, mat3x2 dest); CGLM_INLINE void glm_mat2x3_scale(mat2x3 m, float s); */ #ifndef cglm_mat2x3_h #define cglm_mat2x3_h #include "common.h" #define GLM_MAT2X3_ZERO_INIT {{0.0f, 0.0f, 0.0f}, {0.0f, 0.0f, 0.0f}} /* for C only */ #define GLM_MAT2X3_ZERO GLM_MAT2X3_ZERO_INIT /*! * @brief copy all members of [mat] to [dest] * * @param[in] mat source * @param[out] dest destination */ CGLM_INLINE void glm_mat2x3_copy(mat2x3 mat, mat2x3 dest) { dest[0][0] = mat[0][0]; dest[0][1] = mat[0][1]; dest[0][2] = mat[0][2]; dest[1][0] = mat[1][0]; dest[1][1] = mat[1][1]; dest[1][2] = mat[1][2]; } /*! * @brief make given matrix zero. * * @param[in, out] mat matrix */ CGLM_INLINE void glm_mat2x3_zero(mat2x3 mat) { CGLM_ALIGN_MAT mat2x3 t = GLM_MAT2X3_ZERO_INIT; glm_mat2x3_copy(t, mat); } /*! * @brief Create mat2x3 matrix from pointer * * @param[in] src pointer to an array of floats * @param[out] dest matrix */ CGLM_INLINE void glm_mat2x3_make(const float * __restrict src, mat2x3 dest) { dest[0][0] = src[0]; dest[0][1] = src[1]; dest[0][2] = src[2]; dest[1][0] = src[3]; dest[1][1] = src[4]; dest[1][2] = src[5]; } /*! * @brief multiply m1 and m2 to dest * * @code * glm_mat2x3_mul(mat2x3, mat3x2, mat3); * @endcode * * @param[in] m1 left matrix (mat2x3) * @param[in] m2 right matrix (mat3x2) * @param[out] dest destination matrix (mat2) */ CGLM_INLINE void glm_mat2x3_mul(mat2x3 m1, mat3x2 m2, mat3 dest) { float a00 = m1[0][0], a01 = m1[0][1], a02 = m1[0][2], a10 = m1[1][0], a11 = m1[1][1], a12 = m1[1][2], b00 = m2[0][0], b01 = m2[0][1], b10 = m2[1][0], b11 = m2[1][1], b20 = m2[2][0], b21 = m2[2][1]; dest[0][0] = a00 * b00 + a10 * b01; dest[0][1] = a01 * b00 + a11 * b01; dest[0][2] = a02 * b00 + a12 * b01; dest[1][0] = a00 * b10 + a10 * b11; dest[1][1] = a01 * b10 + a11 * b11; dest[1][2] = a02 * b10 + a12 * b11; dest[2][0] = a00 * b20 + a10 * b21; dest[2][1] = a01 * b20 + a11 * b21; dest[2][2] = a02 * b20 + a12 * b21; } /*! * @brief multiply matrix with column vector and store in dest vector * * @param[in] m matrix (left) * @param[in] v vector (right, column vector) * @param[out] dest result vector */ CGLM_INLINE void glm_mat2x3_mulv(mat2x3 m, vec2 v, vec3 dest) { float v0 = v[0], v1 = v[1]; dest[0] = m[0][0] * v0 + m[1][0] * v1; dest[1] = m[0][1] * v0 + m[1][1] * v1; dest[2] = m[0][2] * v0 + m[1][2] * v1; } /*! * @brief transpose matrix and store in dest * * @param[in] m matrix * @param[out] dest result */ CGLM_INLINE void glm_mat2x3_transpose(mat2x3 m, mat3x2 dest) { dest[0][0] = m[0][0]; dest[0][1] = m[1][0]; dest[1][0] = m[0][1]; dest[1][1] = m[1][1]; dest[2][0] = m[0][2]; dest[2][1] = m[1][2]; } /*! * @brief scale (multiply with scalar) matrix * * multiply matrix with scalar * * @param[in, out] m matrix * @param[in] s scalar */ CGLM_INLINE void glm_mat2x3_scale(mat2x3 m, float s) { m[0][0] *= s; m[0][1] *= s; m[0][2] *= s; m[1][0] *= s; m[1][1] *= s; m[1][2] *= s; } #endif cglm-0.9.6/include/cglm/mat2x4.h000066400000000000000000000100641475344456400163260ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ /* Macros: GLM_MAT2X4_ZERO_INIT GLM_MAT2X4_ZERO Functions: CGLM_INLINE void glm_mat2x4_copy(mat2x4 mat, mat2x4 dest); CGLM_INLINE void glm_mat2x4_zero(mat2x4 mat); CGLM_INLINE void glm_mat2x4_make(const float * __restrict src, mat2x4 dest); CGLM_INLINE void glm_mat2x4_mul(mat2x4 m1, mat4x2 m2, mat4 dest); CGLM_INLINE void glm_mat2x4_mulv(mat2x4 m, vec2 v, vec4 dest); CGLM_INLINE void glm_mat2x4_transpose(mat2x4 m, mat4x2 dest); CGLM_INLINE void glm_mat2x4_scale(mat2x4 m, float s); */ #ifndef cglm_mat2x4_h #define cglm_mat2x4_h #include "common.h" #include "vec4.h" #define GLM_MAT2X4_ZERO_INIT {{0.0f, 0.0f, 0.0f, 0.0f}, {0.0f, 0.0f, 0.0f, 0.0f}} /* for C only */ #define GLM_MAT2X4_ZERO GLM_MAT2X4_ZERO_INIT /*! * @brief copy all members of [mat] to [dest] * * @param[in] mat source * @param[out] dest destination */ CGLM_INLINE void glm_mat2x4_copy(mat2x4 mat, mat2x4 dest) { glm_vec4_ucopy(mat[0], dest[0]); glm_vec4_ucopy(mat[1], dest[1]); } /*! * @brief make given matrix zero. * * @param[in, out] mat matrix */ CGLM_INLINE void glm_mat2x4_zero(mat2x4 mat) { CGLM_ALIGN_MAT mat2x4 t = GLM_MAT2X4_ZERO_INIT; glm_mat2x4_copy(t, mat); } /*! * @brief Create mat2x4 matrix from pointer * * @param[in] src pointer to an array of floats * @param[out] dest matrix */ CGLM_INLINE void glm_mat2x4_make(const float * __restrict src, mat2x4 dest) { dest[0][0] = src[0]; dest[0][1] = src[1]; dest[0][2] = src[2]; dest[0][3] = src[3]; dest[1][0] = src[4]; dest[1][1] = src[5]; dest[1][2] = src[6]; dest[1][3] = src[7]; } /*! * @brief multiply m1 and m2 to dest * * @code * glm_mat2x4_mul(mat2x4, mat4x2, mat4); * @endcode * * @param[in] m1 left matrix (mat2x4) * @param[in] m2 right matrix (mat4x2) * @param[out] dest destination matrix (mat4) */ CGLM_INLINE void glm_mat2x4_mul(mat2x4 m1, mat4x2 m2, mat4 dest) { float a00 = m1[0][0], a01 = m1[0][1], a02 = m1[0][2], a03 = m1[0][3], a10 = m1[1][0], a11 = m1[1][1], a12 = m1[1][2], a13 = m1[1][3], b00 = m2[0][0], b01 = m2[0][1], b10 = m2[1][0], b11 = m2[1][1], b20 = m2[2][0], b21 = m2[2][1], b30 = m2[3][0], b31 = m2[3][1]; dest[0][0] = a00 * b00 + a10 * b01; dest[0][1] = a01 * b00 + a11 * b01; dest[0][2] = a02 * b00 + a12 * b01; dest[0][3] = a03 * b00 + a13 * b01; dest[1][0] = a00 * b10 + a10 * b11; dest[1][1] = a01 * b10 + a11 * b11; dest[1][2] = a02 * b10 + a12 * b11; dest[1][3] = a03 * b10 + a13 * b11; dest[2][0] = a00 * b20 + a10 * b21; dest[2][1] = a01 * b20 + a11 * b21; dest[2][2] = a02 * b20 + a12 * b21; dest[2][3] = a03 * b20 + a13 * b21; dest[3][0] = a00 * b30 + a10 * b31; dest[3][1] = a01 * b30 + a11 * b31; dest[3][2] = a02 * b30 + a12 * b31; dest[3][3] = a03 * b30 + a13 * b31; } /*! * @brief multiply matrix with column vector and store in dest column vector * * @param[in] m matrix (left) * @param[in] v vector (right, column vector) * @param[out] dest result vector */ CGLM_INLINE void glm_mat2x4_mulv(mat2x4 m, vec2 v, vec4 dest) { float v0 = v[0], v1 = v[1]; dest[0] = m[0][0] * v0 + m[1][0] * v1; dest[1] = m[0][1] * v0 + m[1][1] * v1; dest[2] = m[0][2] * v0 + m[1][2] * v1; dest[3] = m[0][3] * v0 + m[1][3] * v1; } /*! * @brief transpose matrix and store in dest * * @param[in] m matrix * @param[out] dest result */ CGLM_INLINE void glm_mat2x4_transpose(mat2x4 m, mat4x2 dest) { dest[0][0] = m[0][0]; dest[0][1] = m[1][0]; dest[1][0] = m[0][1]; dest[1][1] = m[1][1]; dest[2][0] = m[0][2]; dest[2][1] = m[1][2]; dest[3][0] = m[0][3]; dest[3][1] = m[1][3]; } /*! * @brief scale (multiply with scalar) matrix * * multiply matrix with scalar * * @param[in, out] m matrix * @param[in] s scalar */ CGLM_INLINE void glm_mat2x4_scale(mat2x4 m, float s) { m[0][0] *= s; m[0][1] *= s; m[0][2] *= s; m[0][3] *= s; m[1][0] *= s; m[1][1] *= s; m[1][2] *= s; m[1][3] *= s; } #endif cglm-0.9.6/include/cglm/mat3.h000066400000000000000000000260311475344456400160540ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ /* Macros: GLM_MAT3_IDENTITY_INIT GLM_MAT3_ZERO_INIT GLM_MAT3_IDENTITY GLM_MAT3_ZERO glm_mat3_dup(mat, dest) Functions: CGLM_INLINE void glm_mat3_copy(mat3 mat, mat3 dest); CGLM_INLINE void glm_mat3_identity(mat3 mat); CGLM_INLINE void glm_mat3_identity_array(mat3 * restrict mat, size_t count); CGLM_INLINE void glm_mat3_zero(mat3 mat); CGLM_INLINE void glm_mat3_mul(mat3 m1, mat3 m2, mat3 dest); CGLM_INLINE void glm_mat3_transpose_to(mat3 m, mat3 dest); CGLM_INLINE void glm_mat3_transpose(mat3 m); CGLM_INLINE void glm_mat3_mulv(mat3 m, vec3 v, vec3 dest); CGLM_INLINE float glm_mat3_trace(mat3 m); CGLM_INLINE void glm_mat3_quat(mat3 m, versor dest); CGLM_INLINE void glm_mat3_scale(mat3 m, float s); CGLM_INLINE float glm_mat3_det(mat3 mat); CGLM_INLINE void glm_mat3_inv(mat3 mat, mat3 dest); CGLM_INLINE void glm_mat3_swap_col(mat3 mat, int col1, int col2); CGLM_INLINE void glm_mat3_swap_row(mat3 mat, int row1, int row2); CGLM_INLINE float glm_mat3_rmc(vec3 r, mat3 m, vec3 c); CGLM_INLINE void glm_mat3_make(float * restrict src, mat3 dest); */ #ifndef cglm_mat3_h #define cglm_mat3_h #include "common.h" #include "vec3.h" #ifdef CGLM_SSE_FP # include "simd/sse2/mat3.h" #endif #ifdef CGLM_SIMD_WASM # include "simd/wasm/mat3.h" #endif #define GLM_MAT3_IDENTITY_INIT {{1.0f, 0.0f, 0.0f}, \ {0.0f, 1.0f, 0.0f}, \ {0.0f, 0.0f, 1.0f}} #define GLM_MAT3_ZERO_INIT {{0.0f, 0.0f, 0.0f}, \ {0.0f, 0.0f, 0.0f}, \ {0.0f, 0.0f, 0.0f}} /* for C only */ #define GLM_MAT3_IDENTITY ((mat3)GLM_MAT3_IDENTITY_INIT) #define GLM_MAT3_ZERO ((mat3)GLM_MAT3_ZERO_INIT) /* DEPRECATED! use _copy, _ucopy versions */ #define glm_mat3_dup(mat, dest) glm_mat3_copy(mat, dest) /*! * @brief copy all members of [mat] to [dest] * * @param[in] mat source * @param[out] dest destination */ CGLM_INLINE void glm_mat3_copy(mat3 mat, mat3 dest) { dest[0][0] = mat[0][0]; dest[0][1] = mat[0][1]; dest[0][2] = mat[0][2]; dest[1][0] = mat[1][0]; dest[1][1] = mat[1][1]; dest[1][2] = mat[1][2]; dest[2][0] = mat[2][0]; dest[2][1] = mat[2][1]; dest[2][2] = mat[2][2]; } /*! * @brief make given matrix identity. It is identical with below, * but it is more easy to do that with this func especially for members * e.g. glm_mat3_identity(aStruct->aMatrix); * * @code * glm_mat3_copy(GLM_MAT3_IDENTITY, mat); // C only * * // or * mat3 mat = GLM_MAT3_IDENTITY_INIT; * @endcode * * @param[in, out] mat destination */ CGLM_INLINE void glm_mat3_identity(mat3 mat) { CGLM_ALIGN_MAT mat3 t = GLM_MAT3_IDENTITY_INIT; glm_mat3_copy(t, mat); } /*! * @brief make given matrix array's each element identity matrix * * @param[in, out] mat matrix array (must be aligned (16/32) * if alignment is not disabled) * * @param[in] count count of matrices */ CGLM_INLINE void glm_mat3_identity_array(mat3 * __restrict mat, size_t count) { CGLM_ALIGN_MAT mat3 t = GLM_MAT3_IDENTITY_INIT; size_t i; for (i = 0; i < count; i++) { glm_mat3_copy(t, mat[i]); } } /*! * @brief make given matrix zero. * * @param[in, out] mat matrix */ CGLM_INLINE void glm_mat3_zero(mat3 mat) { CGLM_ALIGN_MAT mat3 t = GLM_MAT3_ZERO_INIT; glm_mat3_copy(t, mat); } /*! * @brief multiply m1 and m2 to dest * * m1, m2 and dest matrices can be same matrix, it is possible to write this: * * @code * mat3 m = GLM_MAT3_IDENTITY_INIT; * glm_mat3_mul(m, m, m); * @endcode * * @param[in] m1 left matrix * @param[in] m2 right matrix * @param[out] dest destination matrix */ CGLM_INLINE void glm_mat3_mul(mat3 m1, mat3 m2, mat3 dest) { #if defined(__wasm__) && defined(__wasm_simd128__) glm_mat3_mul_wasm(m1, m2, dest); #elif defined( __SSE__ ) || defined( __SSE2__ ) glm_mat3_mul_sse2(m1, m2, dest); #else float a00 = m1[0][0], a01 = m1[0][1], a02 = m1[0][2], a10 = m1[1][0], a11 = m1[1][1], a12 = m1[1][2], a20 = m1[2][0], a21 = m1[2][1], a22 = m1[2][2], b00 = m2[0][0], b01 = m2[0][1], b02 = m2[0][2], b10 = m2[1][0], b11 = m2[1][1], b12 = m2[1][2], b20 = m2[2][0], b21 = m2[2][1], b22 = m2[2][2]; dest[0][0] = a00 * b00 + a10 * b01 + a20 * b02; dest[0][1] = a01 * b00 + a11 * b01 + a21 * b02; dest[0][2] = a02 * b00 + a12 * b01 + a22 * b02; dest[1][0] = a00 * b10 + a10 * b11 + a20 * b12; dest[1][1] = a01 * b10 + a11 * b11 + a21 * b12; dest[1][2] = a02 * b10 + a12 * b11 + a22 * b12; dest[2][0] = a00 * b20 + a10 * b21 + a20 * b22; dest[2][1] = a01 * b20 + a11 * b21 + a21 * b22; dest[2][2] = a02 * b20 + a12 * b21 + a22 * b22; #endif } /*! * @brief transpose mat3 and store in dest * * source matrix will not be transposed unless dest is m * * @param[in] m matrix * @param[out] dest result */ CGLM_INLINE void glm_mat3_transpose_to(mat3 m, mat3 dest) { dest[0][0] = m[0][0]; dest[0][1] = m[1][0]; dest[0][2] = m[2][0]; dest[1][0] = m[0][1]; dest[1][1] = m[1][1]; dest[1][2] = m[2][1]; dest[2][0] = m[0][2]; dest[2][1] = m[1][2]; dest[2][2] = m[2][2]; } /*! * @brief transpose mat3 and store result in same matrix * * @param[in, out] m source and dest */ CGLM_INLINE void glm_mat3_transpose(mat3 m) { CGLM_ALIGN_MAT mat3 tmp; tmp[0][1] = m[1][0]; tmp[0][2] = m[2][0]; tmp[1][0] = m[0][1]; tmp[1][2] = m[2][1]; tmp[2][0] = m[0][2]; tmp[2][1] = m[1][2]; m[0][1] = tmp[0][1]; m[0][2] = tmp[0][2]; m[1][0] = tmp[1][0]; m[1][2] = tmp[1][2]; m[2][0] = tmp[2][0]; m[2][1] = tmp[2][1]; } /*! * @brief multiply mat3 with vec3 (column vector) and store in dest vector * * @param[in] m mat3 (left) * @param[in] v vec3 (right, column vector) * @param[out] dest vec3 (result, column vector) */ CGLM_INLINE void glm_mat3_mulv(mat3 m, vec3 v, vec3 dest) { vec3 res; res[0] = m[0][0] * v[0] + m[1][0] * v[1] + m[2][0] * v[2]; res[1] = m[0][1] * v[0] + m[1][1] * v[1] + m[2][1] * v[2]; res[2] = m[0][2] * v[0] + m[1][2] * v[1] + m[2][2] * v[2]; glm_vec3_copy(res, dest); } /*! * @brief trace of matrix * * sum of the elements on the main diagonal from upper left to the lower right * * @param[in] m matrix */ CGLM_INLINE float glm_mat3_trace(mat3 m) { return m[0][0] + m[1][1] + m[2][2]; } /*! * @brief convert mat3 to quaternion * * @param[in] m rotation matrix * @param[out] dest destination quaternion */ CGLM_INLINE void glm_mat3_quat(mat3 m, versor dest) { float trace, r, rinv; /* it seems using like m12 instead of m[1][2] causes extra instructions */ trace = m[0][0] + m[1][1] + m[2][2]; if (trace >= 0.0f) { r = sqrtf(1.0f + trace); rinv = 0.5f / r; dest[0] = rinv * (m[1][2] - m[2][1]); dest[1] = rinv * (m[2][0] - m[0][2]); dest[2] = rinv * (m[0][1] - m[1][0]); dest[3] = r * 0.5f; } else if (m[0][0] >= m[1][1] && m[0][0] >= m[2][2]) { r = sqrtf(1.0f - m[1][1] - m[2][2] + m[0][0]); rinv = 0.5f / r; dest[0] = r * 0.5f; dest[1] = rinv * (m[0][1] + m[1][0]); dest[2] = rinv * (m[0][2] + m[2][0]); dest[3] = rinv * (m[1][2] - m[2][1]); } else if (m[1][1] >= m[2][2]) { r = sqrtf(1.0f - m[0][0] - m[2][2] + m[1][1]); rinv = 0.5f / r; dest[0] = rinv * (m[0][1] + m[1][0]); dest[1] = r * 0.5f; dest[2] = rinv * (m[1][2] + m[2][1]); dest[3] = rinv * (m[2][0] - m[0][2]); } else { r = sqrtf(1.0f - m[0][0] - m[1][1] + m[2][2]); rinv = 0.5f / r; dest[0] = rinv * (m[0][2] + m[2][0]); dest[1] = rinv * (m[1][2] + m[2][1]); dest[2] = r * 0.5f; dest[3] = rinv * (m[0][1] - m[1][0]); } } /*! * @brief scale (multiply with scalar) matrix * * multiply matrix with scalar * * @param[in, out] m matrix * @param[in] s scalar */ CGLM_INLINE void glm_mat3_scale(mat3 m, float s) { m[0][0] *= s; m[0][1] *= s; m[0][2] *= s; m[1][0] *= s; m[1][1] *= s; m[1][2] *= s; m[2][0] *= s; m[2][1] *= s; m[2][2] *= s; } /*! * @brief mat3 determinant * * @param[in] mat matrix * * @return determinant */ CGLM_INLINE float glm_mat3_det(mat3 mat) { float a = mat[0][0], b = mat[0][1], c = mat[0][2], d = mat[1][0], e = mat[1][1], f = mat[1][2], g = mat[2][0], h = mat[2][1], i = mat[2][2]; return a * (e * i - h * f) - d * (b * i - h * c) + g * (b * f - e * c); } /*! * @brief inverse mat3 and store in dest * * @param[in] mat matrix * @param[out] dest inverse matrix */ CGLM_INLINE void glm_mat3_inv(mat3 mat, mat3 dest) { float a = mat[0][0], b = mat[0][1], c = mat[0][2], d = mat[1][0], e = mat[1][1], f = mat[1][2], g = mat[2][0], h = mat[2][1], i = mat[2][2], c1 = e * i - f * h, c2 = d * i - g * f, c3 = d * h - g * e, idt = 1.0f / (a * c1 - b * c2 + c * c3), ndt = -idt; dest[0][0] = idt * c1; dest[0][1] = ndt * (b * i - h * c); dest[0][2] = idt * (b * f - e * c); dest[1][0] = ndt * c2; dest[1][1] = idt * (a * i - g * c); dest[1][2] = ndt * (a * f - d * c); dest[2][0] = idt * c3; dest[2][1] = ndt * (a * h - g * b); dest[2][2] = idt * (a * e - d * b); } /*! * @brief swap two matrix columns * * @param[in,out] mat matrix * @param[in] col1 col1 * @param[in] col2 col2 */ CGLM_INLINE void glm_mat3_swap_col(mat3 mat, int col1, int col2) { vec3 tmp; glm_vec3_copy(mat[col1], tmp); glm_vec3_copy(mat[col2], mat[col1]); glm_vec3_copy(tmp, mat[col2]); } /*! * @brief swap two matrix rows * * @param[in,out] mat matrix * @param[in] row1 row1 * @param[in] row2 row2 */ CGLM_INLINE void glm_mat3_swap_row(mat3 mat, int row1, int row2) { vec3 tmp; tmp[0] = mat[0][row1]; tmp[1] = mat[1][row1]; tmp[2] = mat[2][row1]; mat[0][row1] = mat[0][row2]; mat[1][row1] = mat[1][row2]; mat[2][row1] = mat[2][row2]; mat[0][row2] = tmp[0]; mat[1][row2] = tmp[1]; mat[2][row2] = tmp[2]; } /*! * @brief helper for R (row vector) * M (matrix) * C (column vector) * * rmc stands for Row * Matrix * Column * * the result is scalar because R * M = Matrix1x3 (row vector), * then Matrix1x3 * Vec3 (column vector) = Matrix1x1 (Scalar) * * @param[in] r row vector or matrix1x3 * @param[in] m matrix3x3 * @param[in] c column vector or matrix3x1 * * @return scalar value e.g. Matrix1x1 */ CGLM_INLINE float glm_mat3_rmc(vec3 r, mat3 m, vec3 c) { vec3 tmp; glm_mat3_mulv(m, c, tmp); return glm_vec3_dot(r, tmp); } /*! * @brief Create mat3 matrix from pointer * * @param[in] src pointer to an array of floats * @param[out] dest matrix */ CGLM_INLINE void glm_mat3_make(const float * __restrict src, mat3 dest) { dest[0][0] = src[0]; dest[0][1] = src[1]; dest[0][2] = src[2]; dest[1][0] = src[3]; dest[1][1] = src[4]; dest[1][2] = src[5]; dest[2][0] = src[6]; dest[2][1] = src[7]; dest[2][2] = src[8]; } #endif /* cglm_mat3_h */ cglm-0.9.6/include/cglm/mat3x2.h000066400000000000000000000067521475344456400163360ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ /* Macros: GLM_MAT3X2_ZERO_INIT GLM_MAT3X2_ZERO Functions: CGLM_INLINE void glm_mat3x2_copy(mat3x2 mat, mat3x2 dest); CGLM_INLINE void glm_mat3x2_zero(mat3x2 mat); CGLM_INLINE void glm_mat3x2_make(const float * __restrict src, mat3x2 dest); CGLM_INLINE void glm_mat3x2_mul(mat3x2 m1, mat2x3 m2, mat2 dest); CGLM_INLINE void glm_mat3x2_mulv(mat3x2 m, vec3 v, vec2 dest); CGLM_INLINE void glm_mat3x2_transpose(mat3x2 m, mat2x3 dest); CGLM_INLINE void glm_mat3x2_scale(mat3x2 m, float s); */ #ifndef cglm_mat3x2_h #define cglm_mat3x2_h #include "common.h" #define GLM_MAT3X2_ZERO_INIT {{0.0f, 0.0f}, {0.0f, 0.0f}, {0.0f, 0.0f}} /* for C only */ #define GLM_MAT3X2_ZERO GLM_MAT3X2_ZERO_INIT /*! * @brief copy all members of [mat] to [dest] * * @param[in] mat source * @param[out] dest destination */ CGLM_INLINE void glm_mat3x2_copy(mat3x2 mat, mat3x2 dest) { dest[0][0] = mat[0][0]; dest[0][1] = mat[0][1]; dest[1][0] = mat[1][0]; dest[1][1] = mat[1][1]; dest[2][0] = mat[2][0]; dest[2][1] = mat[2][1]; } /*! * @brief make given matrix zero. * * @param[in, out] mat matrix */ CGLM_INLINE void glm_mat3x2_zero(mat3x2 mat) { CGLM_ALIGN_MAT mat3x2 t = GLM_MAT3X2_ZERO_INIT; glm_mat3x2_copy(t, mat); } /*! * @brief Create mat3x2 matrix from pointer * * @param[in] src pointer to an array of floats * @param[out] dest matrix */ CGLM_INLINE void glm_mat3x2_make(const float * __restrict src, mat3x2 dest) { dest[0][0] = src[0]; dest[0][1] = src[1]; dest[1][0] = src[2]; dest[1][1] = src[3]; dest[2][0] = src[4]; dest[2][1] = src[5]; } /*! * @brief multiply m1 and m2 to dest * * @code * glm_mat3x2_mul(mat3x2, mat2x3, mat2); * @endcode * * @param[in] m1 left matrix (mat3x2) * @param[in] m2 right matrix (mat2x3) * @param[out] dest destination matrix (mat2) */ CGLM_INLINE void glm_mat3x2_mul(mat3x2 m1, mat2x3 m2, mat2 dest) { float a00 = m1[0][0], a01 = m1[0][1], a10 = m1[1][0], a11 = m1[1][1], a20 = m1[2][0], a21 = m1[2][1], b00 = m2[0][0], b01 = m2[0][1], b02 = m2[0][2], b10 = m2[1][0], b11 = m2[1][1], b12 = m2[1][2]; dest[0][0] = a00 * b00 + a10 * b01 + a20 * b02; dest[0][1] = a01 * b00 + a11 * b01 + a21 * b02; dest[1][0] = a00 * b10 + a10 * b11 + a20 * b12; dest[1][1] = a01 * b10 + a11 * b11 + a21 * b12; } /*! * @brief multiply matrix with column vector and store in dest column vector * * @param[in] m matrix (left) * @param[in] v vector (right, column vector) * @param[out] dest result vector */ CGLM_INLINE void glm_mat3x2_mulv(mat3x2 m, vec3 v, vec2 dest) { float v0 = v[0], v1 = v[1], v2 = v[2]; dest[0] = m[0][0] * v0 + m[1][0] * v1 + m[2][0] * v2; dest[1] = m[0][1] * v0 + m[1][1] * v1 + m[2][1] * v2; } /*! * @brief transpose matrix and store in dest * * @param[in] m matrix * @param[out] dest result */ CGLM_INLINE void glm_mat3x2_transpose(mat3x2 m, mat2x3 dest) { dest[0][0] = m[0][0]; dest[0][1] = m[1][0]; dest[0][2] = m[2][0]; dest[1][0] = m[0][1]; dest[1][1] = m[1][1]; dest[1][2] = m[2][1]; } /*! * @brief scale (multiply with scalar) matrix * * multiply matrix with scalar * * @param[in, out] m matrix * @param[in] s scalar */ CGLM_INLINE void glm_mat3x2_scale(mat3x2 m, float s) { m[0][0] *= s; m[0][1] *= s; m[1][0] *= s; m[1][1] *= s; m[2][0] *= s; m[2][1] *= s; } #endif cglm-0.9.6/include/cglm/mat3x4.h000066400000000000000000000114351475344456400163320ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ /* Macros: GLM_MAT3X4_ZERO_INIT GLM_MAT3X4_ZERO Functions: CGLM_INLINE void glm_mat3x4_copy(mat3x4 mat, mat3x4 dest); CGLM_INLINE void glm_mat3x4_zero(mat3x4 mat); CGLM_INLINE void glm_mat3x4_make(const float * __restrict src, mat3x4 dest); CGLM_INLINE void glm_mat3x4_mul(mat3x4 m1, mat4x3 m2, mat4 dest); CGLM_INLINE void glm_mat3x4_mulv(mat3x4 m, vec3 v, vec4 dest); CGLM_INLINE void glm_mat3x4_transpose(mat3x4 m, mat4x3 dest); CGLM_INLINE void glm_mat3x4_scale(mat3x4 m, float s); */ #ifndef cglm_mat3x4_h #define cglm_mat3x4_h #include "common.h" #define GLM_MAT3X4_ZERO_INIT {{0.0f, 0.0f, 0.0f, 0.0f}, \ {0.0f, 0.0f, 0.0f, 0.0f}, \ {0.0f, 0.0f, 0.0f, 0.0f}} /* for C only */ #define GLM_MAT3X4_ZERO GLM_MAT3X4_ZERO_INIT /*! * @brief copy all members of [mat] to [dest] * * @param[in] mat source * @param[out] dest destination */ CGLM_INLINE void glm_mat3x4_copy(mat3x4 mat, mat3x4 dest) { glm_vec4_ucopy(mat[0], dest[0]); glm_vec4_ucopy(mat[1], dest[1]); glm_vec4_ucopy(mat[2], dest[2]); } /*! * @brief make given matrix zero. * * @param[in, out] mat matrix */ CGLM_INLINE void glm_mat3x4_zero(mat3x4 mat) { CGLM_ALIGN_MAT mat3x4 t = GLM_MAT3X4_ZERO_INIT; glm_mat3x4_copy(t, mat); } /*! * @brief Create mat3x4 matrix from pointer * * @param[in] src pointer to an array of floats * @param[out] dest matrix */ CGLM_INLINE void glm_mat3x4_make(const float * __restrict src, mat3x4 dest) { dest[0][0] = src[0]; dest[0][1] = src[1]; dest[0][2] = src[2]; dest[0][3] = src[3]; dest[1][0] = src[4]; dest[1][1] = src[5]; dest[1][2] = src[6]; dest[1][3] = src[7]; dest[2][0] = src[8]; dest[2][1] = src[9]; dest[2][2] = src[10]; dest[2][3] = src[11]; } /*! * @brief multiply m1 and m2 to dest * * @code * glm_mat3x4_mul(mat3x4, mat4x3, mat4); * @endcode * * @param[in] m1 left matrix (mat3x4) * @param[in] m2 right matrix (mat4x3) * @param[out] dest destination matrix (mat4) */ CGLM_INLINE void glm_mat3x4_mul(mat3x4 m1, mat4x3 m2, mat4 dest) { float a00 = m1[0][0], a01 = m1[0][1], a02 = m1[0][2], a03 = m1[0][3], a10 = m1[1][0], a11 = m1[1][1], a12 = m1[1][2], a13 = m1[1][3], a20 = m1[2][0], a21 = m1[2][1], a22 = m1[2][2], a23 = m1[2][3], b00 = m2[0][0], b01 = m2[0][1], b02 = m2[0][2], b10 = m2[1][0], b11 = m2[1][1], b12 = m2[1][2], b20 = m2[2][0], b21 = m2[2][1], b22 = m2[2][2], b30 = m2[3][0], b31 = m2[3][1], b32 = m2[3][2]; dest[0][0] = a00 * b00 + a10 * b01 + a20 * b02; dest[0][1] = a01 * b00 + a11 * b01 + a21 * b02; dest[0][2] = a02 * b00 + a12 * b01 + a22 * b02; dest[0][3] = a03 * b00 + a13 * b01 + a23 * b02; dest[1][0] = a00 * b10 + a10 * b11 + a20 * b12; dest[1][1] = a01 * b10 + a11 * b11 + a21 * b12; dest[1][2] = a02 * b10 + a12 * b11 + a22 * b12; dest[1][3] = a03 * b10 + a13 * b11 + a23 * b12; dest[2][0] = a00 * b20 + a10 * b21 + a20 * b22; dest[2][1] = a01 * b20 + a11 * b21 + a21 * b22; dest[2][2] = a02 * b20 + a12 * b21 + a22 * b22; dest[2][3] = a03 * b20 + a13 * b21 + a23 * b22; dest[3][0] = a00 * b30 + a10 * b31 + a20 * b32; dest[3][1] = a01 * b30 + a11 * b31 + a21 * b32; dest[3][2] = a02 * b30 + a12 * b31 + a22 * b32; dest[3][3] = a03 * b30 + a13 * b31 + a23 * b32; } /*! * @brief multiply matrix with column vector and store in dest column vector * * @param[in] m matrix (left) * @param[in] v vector (right, column vector) * @param[out] dest result vector */ CGLM_INLINE void glm_mat3x4_mulv(mat3x4 m, vec3 v, vec4 dest) { float v0 = v[0], v1 = v[1], v2 = v[2]; dest[0] = m[0][0] * v0 + m[1][0] * v1 + m[2][0] * v2; dest[1] = m[0][1] * v0 + m[1][1] * v1 + m[2][1] * v2; dest[2] = m[0][2] * v0 + m[1][2] * v1 + m[2][2] * v2; dest[3] = m[0][3] * v0 + m[1][3] * v1 + m[2][3] * v2; } /*! * @brief transpose matrix and store in dest * * @param[in] m matrix * @param[out] dest result */ CGLM_INLINE void glm_mat3x4_transpose(mat3x4 m, mat4x3 dest) { dest[0][0] = m[0][0]; dest[0][1] = m[1][0]; dest[0][2] = m[2][0]; dest[1][0] = m[0][1]; dest[1][1] = m[1][1]; dest[1][2] = m[2][1]; dest[2][0] = m[0][2]; dest[2][1] = m[1][2]; dest[2][2] = m[2][2]; dest[3][0] = m[0][3]; dest[3][1] = m[1][3]; dest[3][2] = m[2][3]; } /*! * @brief scale (multiply with scalar) matrix * * multiply matrix with scalar * * @param[in, out] m matrix * @param[in] s scalar */ CGLM_INLINE void glm_mat3x4_scale(mat3x4 m, float s) { m[0][0] *= s; m[0][1] *= s; m[0][2] *= s; m[0][3] *= s; m[1][0] *= s; m[1][1] *= s; m[1][2] *= s; m[1][3] *= s; m[2][0] *= s; m[2][1] *= s; m[2][2] *= s; m[2][3] *= s; } #endif cglm-0.9.6/include/cglm/mat4.h000066400000000000000000000537051475344456400160650ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ /*! * Most of functions in this header are optimized manually with SIMD * if available. You dont need to call/incude SIMD headers manually */ /* Macros: GLM_MAT4_IDENTITY_INIT GLM_MAT4_ZERO_INIT GLM_MAT4_IDENTITY GLM_MAT4_ZERO Functions: CGLM_INLINE void glm_mat4_ucopy(mat4 mat, mat4 dest); CGLM_INLINE void glm_mat4_copy(mat4 mat, mat4 dest); CGLM_INLINE void glm_mat4_identity(mat4 mat); CGLM_INLINE void glm_mat4_identity_array(mat4 * restrict mat, size_t count); CGLM_INLINE void glm_mat4_zero(mat4 mat); CGLM_INLINE void glm_mat4_pick3(mat4 mat, mat3 dest); CGLM_INLINE void glm_mat4_pick3t(mat4 mat, mat3 dest); CGLM_INLINE void glm_mat4_ins3(mat3 mat, mat4 dest); CGLM_INLINE void glm_mat4_mul(mat4 m1, mat4 m2, mat4 dest); CGLM_INLINE void glm_mat4_mulN(mat4 *matrices[], int len, mat4 dest); CGLM_INLINE void glm_mat4_mulv(mat4 m, vec4 v, vec4 dest); CGLM_INLINE void glm_mat4_mulv3(mat4 m, vec3 v, float last, vec3 dest); CGLM_INLINE float glm_mat4_trace(mat4 m); CGLM_INLINE float glm_mat4_trace3(mat4 m); CGLM_INLINE void glm_mat4_quat(mat4 m, versor dest) ; CGLM_INLINE void glm_mat4_transpose_to(mat4 m, mat4 dest); CGLM_INLINE void glm_mat4_transpose(mat4 m); CGLM_INLINE void glm_mat4_scale_p(mat4 m, float s); CGLM_INLINE void glm_mat4_scale(mat4 m, float s); CGLM_INLINE float glm_mat4_det(mat4 mat); CGLM_INLINE void glm_mat4_inv(mat4 mat, mat4 dest); CGLM_INLINE void glm_mat4_inv_fast(mat4 mat, mat4 dest); CGLM_INLINE void glm_mat4_swap_col(mat4 mat, int col1, int col2); CGLM_INLINE void glm_mat4_swap_row(mat4 mat, int row1, int row2); CGLM_INLINE float glm_mat4_rmc(vec4 r, mat4 m, vec4 c); CGLM_INLINE void glm_mat4_make(float * restrict src, mat4 dest); */ #ifndef cglm_mat_h #define cglm_mat_h #include "common.h" #include "vec4.h" #include "vec3.h" #ifdef CGLM_SSE_FP # include "simd/sse2/mat4.h" #endif #ifdef CGLM_AVX_FP # include "simd/avx/mat4.h" #endif #ifdef CGLM_NEON_FP # include "simd/neon/mat4.h" #endif #ifdef CGLM_SIMD_WASM # include "simd/wasm/mat4.h" #endif #ifndef NDEBUG # include #endif #define GLM_MAT4_IDENTITY_INIT {{1.0f, 0.0f, 0.0f, 0.0f}, \ {0.0f, 1.0f, 0.0f, 0.0f}, \ {0.0f, 0.0f, 1.0f, 0.0f}, \ {0.0f, 0.0f, 0.0f, 1.0f}} #define GLM_MAT4_ZERO_INIT {{0.0f, 0.0f, 0.0f, 0.0f}, \ {0.0f, 0.0f, 0.0f, 0.0f}, \ {0.0f, 0.0f, 0.0f, 0.0f}, \ {0.0f, 0.0f, 0.0f, 0.0f}} /* for C only */ #define GLM_MAT4_IDENTITY ((mat4)GLM_MAT4_IDENTITY_INIT) #define GLM_MAT4_ZERO ((mat4)GLM_MAT4_ZERO_INIT) /* DEPRECATED! use _copy, _ucopy versions */ #define glm_mat4_udup(mat, dest) glm_mat4_ucopy(mat, dest) #define glm_mat4_dup(mat, dest) glm_mat4_copy(mat, dest) /* DEPRECATED! default is precise now. */ #define glm_mat4_inv_precise(mat, dest) glm_mat4_inv(mat, dest) /*! * @brief copy all members of [mat] to [dest] * * matrix may not be aligned, u stands for unaligned, this may be useful when * copying a matrix from external source e.g. asset importer... * * @param[in] mat source * @param[out] dest destination */ CGLM_INLINE void glm_mat4_ucopy(mat4 mat, mat4 dest) { dest[0][0] = mat[0][0]; dest[1][0] = mat[1][0]; dest[0][1] = mat[0][1]; dest[1][1] = mat[1][1]; dest[0][2] = mat[0][2]; dest[1][2] = mat[1][2]; dest[0][3] = mat[0][3]; dest[1][3] = mat[1][3]; dest[2][0] = mat[2][0]; dest[3][0] = mat[3][0]; dest[2][1] = mat[2][1]; dest[3][1] = mat[3][1]; dest[2][2] = mat[2][2]; dest[3][2] = mat[3][2]; dest[2][3] = mat[2][3]; dest[3][3] = mat[3][3]; } /*! * @brief copy all members of [mat] to [dest] * * @param[in] mat source * @param[out] dest destination */ CGLM_INLINE void glm_mat4_copy(mat4 mat, mat4 dest) { #if defined(__wasm__) && defined(__wasm_simd128__) glmm_store(dest[0], glmm_load(mat[0])); glmm_store(dest[1], glmm_load(mat[1])); glmm_store(dest[2], glmm_load(mat[2])); glmm_store(dest[3], glmm_load(mat[3])); #elif defined(__AVX__) glmm_store256(dest[0], glmm_load256(mat[0])); glmm_store256(dest[2], glmm_load256(mat[2])); #elif defined( __SSE__ ) || defined( __SSE2__ ) glmm_store(dest[0], glmm_load(mat[0])); glmm_store(dest[1], glmm_load(mat[1])); glmm_store(dest[2], glmm_load(mat[2])); glmm_store(dest[3], glmm_load(mat[3])); #elif defined(CGLM_NEON_FP) vst1q_f32(dest[0], vld1q_f32(mat[0])); vst1q_f32(dest[1], vld1q_f32(mat[1])); vst1q_f32(dest[2], vld1q_f32(mat[2])); vst1q_f32(dest[3], vld1q_f32(mat[3])); #else glm_mat4_ucopy(mat, dest); #endif } /*! * @brief make given matrix identity. It is identical with below, * but it is more easy to do that with this func especially for members * e.g. glm_mat4_identity(aStruct->aMatrix); * * @code * glm_mat4_copy(GLM_MAT4_IDENTITY, mat); // C only * * // or * mat4 mat = GLM_MAT4_IDENTITY_INIT; * @endcode * * @param[in, out] mat destination */ CGLM_INLINE void glm_mat4_identity(mat4 mat) { CGLM_ALIGN_MAT mat4 t = GLM_MAT4_IDENTITY_INIT; glm_mat4_copy(t, mat); } /*! * @brief make given matrix array's each element identity matrix * * @param[in, out] mat matrix array (must be aligned (16/32) * if alignment is not disabled) * * @param[in] count count of matrices */ CGLM_INLINE void glm_mat4_identity_array(mat4 * __restrict mat, size_t count) { CGLM_ALIGN_MAT mat4 t = GLM_MAT4_IDENTITY_INIT; size_t i; for (i = 0; i < count; i++) { glm_mat4_copy(t, mat[i]); } } /*! * @brief make given matrix zero. * * @param[in, out] mat matrix */ CGLM_INLINE void glm_mat4_zero(mat4 mat) { #if defined(__wasm__) && defined(__wasm_simd128__) glmm_128 x0; x0 = wasm_f32x4_const_splat(0.f); glmm_store(mat[0], x0); glmm_store(mat[1], x0); glmm_store(mat[2], x0); glmm_store(mat[3], x0); #elif defined(__AVX__) __m256 y0; y0 = _mm256_setzero_ps(); glmm_store256(mat[0], y0); glmm_store256(mat[2], y0); #elif defined( __SSE__ ) || defined( __SSE2__ ) glmm_128 x0; x0 = _mm_setzero_ps(); glmm_store(mat[0], x0); glmm_store(mat[1], x0); glmm_store(mat[2], x0); glmm_store(mat[3], x0); #elif defined(CGLM_NEON_FP) glmm_128 x0; x0 = vdupq_n_f32(0.0f); vst1q_f32(mat[0], x0); vst1q_f32(mat[1], x0); vst1q_f32(mat[2], x0); vst1q_f32(mat[3], x0); #else CGLM_ALIGN_MAT mat4 t = GLM_MAT4_ZERO_INIT; glm_mat4_copy(t, mat); #endif } /*! * @brief copy upper-left of mat4 to mat3 * * @param[in] mat source * @param[out] dest destination */ CGLM_INLINE void glm_mat4_pick3(mat4 mat, mat3 dest) { dest[0][0] = mat[0][0]; dest[0][1] = mat[0][1]; dest[0][2] = mat[0][2]; dest[1][0] = mat[1][0]; dest[1][1] = mat[1][1]; dest[1][2] = mat[1][2]; dest[2][0] = mat[2][0]; dest[2][1] = mat[2][1]; dest[2][2] = mat[2][2]; } /*! * @brief copy upper-left of mat4 to mat3 (transposed) * * the postfix t stands for transpose * * @param[in] mat source * @param[out] dest destination */ CGLM_INLINE void glm_mat4_pick3t(mat4 mat, mat3 dest) { dest[0][0] = mat[0][0]; dest[0][1] = mat[1][0]; dest[0][2] = mat[2][0]; dest[1][0] = mat[0][1]; dest[1][1] = mat[1][1]; dest[1][2] = mat[2][1]; dest[2][0] = mat[0][2]; dest[2][1] = mat[1][2]; dest[2][2] = mat[2][2]; } /*! * @brief copy mat3 to mat4's upper-left * * @param[in] mat source * @param[out] dest destination */ CGLM_INLINE void glm_mat4_ins3(mat3 mat, mat4 dest) { dest[0][0] = mat[0][0]; dest[0][1] = mat[0][1]; dest[0][2] = mat[0][2]; dest[1][0] = mat[1][0]; dest[1][1] = mat[1][1]; dest[1][2] = mat[1][2]; dest[2][0] = mat[2][0]; dest[2][1] = mat[2][1]; dest[2][2] = mat[2][2]; } /*! * @brief multiply m1 and m2 to dest * * m1, m2 and dest matrices can be same matrix, it is possible to write this: * * @code * mat4 m = GLM_MAT4_IDENTITY_INIT; * glm_mat4_mul(m, m, m); * @endcode * * @param[in] m1 left matrix * @param[in] m2 right matrix * @param[out] dest destination matrix */ CGLM_INLINE void glm_mat4_mul(mat4 m1, mat4 m2, mat4 dest) { #if defined(__wasm__) && defined(__wasm_simd128__) glm_mat4_mul_wasm(m1, m2, dest); #elif defined(__AVX__) glm_mat4_mul_avx(m1, m2, dest); #elif defined( __SSE__ ) || defined( __SSE2__ ) glm_mat4_mul_sse2(m1, m2, dest); #elif defined(CGLM_NEON_FP) glm_mat4_mul_neon(m1, m2, dest); #else float a00 = m1[0][0], a01 = m1[0][1], a02 = m1[0][2], a03 = m1[0][3], a10 = m1[1][0], a11 = m1[1][1], a12 = m1[1][2], a13 = m1[1][3], a20 = m1[2][0], a21 = m1[2][1], a22 = m1[2][2], a23 = m1[2][3], a30 = m1[3][0], a31 = m1[3][1], a32 = m1[3][2], a33 = m1[3][3], b00 = m2[0][0], b01 = m2[0][1], b02 = m2[0][2], b03 = m2[0][3], b10 = m2[1][0], b11 = m2[1][1], b12 = m2[1][2], b13 = m2[1][3], b20 = m2[2][0], b21 = m2[2][1], b22 = m2[2][2], b23 = m2[2][3], b30 = m2[3][0], b31 = m2[3][1], b32 = m2[3][2], b33 = m2[3][3]; dest[0][0] = a00 * b00 + a10 * b01 + a20 * b02 + a30 * b03; dest[0][1] = a01 * b00 + a11 * b01 + a21 * b02 + a31 * b03; dest[0][2] = a02 * b00 + a12 * b01 + a22 * b02 + a32 * b03; dest[0][3] = a03 * b00 + a13 * b01 + a23 * b02 + a33 * b03; dest[1][0] = a00 * b10 + a10 * b11 + a20 * b12 + a30 * b13; dest[1][1] = a01 * b10 + a11 * b11 + a21 * b12 + a31 * b13; dest[1][2] = a02 * b10 + a12 * b11 + a22 * b12 + a32 * b13; dest[1][3] = a03 * b10 + a13 * b11 + a23 * b12 + a33 * b13; dest[2][0] = a00 * b20 + a10 * b21 + a20 * b22 + a30 * b23; dest[2][1] = a01 * b20 + a11 * b21 + a21 * b22 + a31 * b23; dest[2][2] = a02 * b20 + a12 * b21 + a22 * b22 + a32 * b23; dest[2][3] = a03 * b20 + a13 * b21 + a23 * b22 + a33 * b23; dest[3][0] = a00 * b30 + a10 * b31 + a20 * b32 + a30 * b33; dest[3][1] = a01 * b30 + a11 * b31 + a21 * b32 + a31 * b33; dest[3][2] = a02 * b30 + a12 * b31 + a22 * b32 + a32 * b33; dest[3][3] = a03 * b30 + a13 * b31 + a23 * b32 + a33 * b33; #endif } /*! * @brief mupliply N mat4 matrices and store result in dest * * this function lets you multiply multiple (more than two or more...) matrices *

multiplication will be done in loop, this may reduce instructions * size but if len is too small then compiler may unroll whole loop, * usage: * @code * mat m1, m2, m3, m4, res; * * glm_mat4_mulN((mat4 *[]){&m1, &m2, &m3, &m4}, 4, res); * @endcode * * @warning matrices parameter is pointer array not mat4 array! * * @param[in] matrices mat4 * array * @param[in] len matrices count * @param[out] dest result */ CGLM_INLINE void glm_mat4_mulN(mat4 * __restrict matrices[], uint32_t len, mat4 dest) { uint32_t i; #ifndef NDEBUG assert(len > 1 && "there must be least 2 matrices to go!"); #endif glm_mat4_mul(*matrices[0], *matrices[1], dest); for (i = 2; i < len; i++) glm_mat4_mul(dest, *matrices[i], dest); } /*! * @brief multiply mat4 with vec4 (column vector) and store in dest vector * * @param[in] m mat4 (left) * @param[in] v vec4 (right, column vector) * @param[out] dest vec4 (result, column vector) */ CGLM_INLINE void glm_mat4_mulv(mat4 m, vec4 v, vec4 dest) { #if defined(__wasm__) && defined(__wasm_simd128__) glm_mat4_mulv_wasm(m, v, dest); #elif defined( __SSE__ ) || defined( __SSE2__ ) glm_mat4_mulv_sse2(m, v, dest); #elif defined(CGLM_NEON_FP) glm_mat4_mulv_neon(m, v, dest); #else vec4 res; res[0] = m[0][0] * v[0] + m[1][0] * v[1] + m[2][0] * v[2] + m[3][0] * v[3]; res[1] = m[0][1] * v[0] + m[1][1] * v[1] + m[2][1] * v[2] + m[3][1] * v[3]; res[2] = m[0][2] * v[0] + m[1][2] * v[1] + m[2][2] * v[2] + m[3][2] * v[3]; res[3] = m[0][3] * v[0] + m[1][3] * v[1] + m[2][3] * v[2] + m[3][3] * v[3]; glm_vec4_copy(res, dest); #endif } /*! * @brief trace of matrix * * sum of the elements on the main diagonal from upper left to the lower right * * @param[in] m matrix */ CGLM_INLINE float glm_mat4_trace(mat4 m) { return m[0][0] + m[1][1] + m[2][2] + m[3][3]; } /*! * @brief trace of matrix (rotation part) * * sum of the elements on the main diagonal from upper left to the lower right * * @param[in] m matrix */ CGLM_INLINE float glm_mat4_trace3(mat4 m) { return m[0][0] + m[1][1] + m[2][2]; } /*! * @brief convert mat4's rotation part to quaternion * * @param[in] m affine matrix * @param[out] dest destination quaternion */ CGLM_INLINE void glm_mat4_quat(mat4 m, versor dest) { float trace, r, rinv; /* it seems using like m12 instead of m[1][2] causes extra instructions */ trace = m[0][0] + m[1][1] + m[2][2]; if (trace >= 0.0f) { r = sqrtf(1.0f + trace); rinv = 0.5f / r; dest[0] = rinv * (m[1][2] - m[2][1]); dest[1] = rinv * (m[2][0] - m[0][2]); dest[2] = rinv * (m[0][1] - m[1][0]); dest[3] = r * 0.5f; } else if (m[0][0] >= m[1][1] && m[0][0] >= m[2][2]) { r = sqrtf(1.0f - m[1][1] - m[2][2] + m[0][0]); rinv = 0.5f / r; dest[0] = r * 0.5f; dest[1] = rinv * (m[0][1] + m[1][0]); dest[2] = rinv * (m[0][2] + m[2][0]); dest[3] = rinv * (m[1][2] - m[2][1]); } else if (m[1][1] >= m[2][2]) { r = sqrtf(1.0f - m[0][0] - m[2][2] + m[1][1]); rinv = 0.5f / r; dest[0] = rinv * (m[0][1] + m[1][0]); dest[1] = r * 0.5f; dest[2] = rinv * (m[1][2] + m[2][1]); dest[3] = rinv * (m[2][0] - m[0][2]); } else { r = sqrtf(1.0f - m[0][0] - m[1][1] + m[2][2]); rinv = 0.5f / r; dest[0] = rinv * (m[0][2] + m[2][0]); dest[1] = rinv * (m[1][2] + m[2][1]); dest[2] = r * 0.5f; dest[3] = rinv * (m[0][1] - m[1][0]); } } /*! * @brief multiply vector with mat4 * * actually the result is vec4, after multiplication the last component * is trimmed. if you need it don't use this func. * * @param[in] m mat4(affine transform) * @param[in] v vec3 * @param[in] last 4th item to make it vec4 * @param[out] dest result vector (vec3) */ CGLM_INLINE void glm_mat4_mulv3(mat4 m, vec3 v, float last, vec3 dest) { vec4 res; glm_vec4(v, last, res); glm_mat4_mulv(m, res, res); glm_vec3(res, dest); } /*! * @brief transpose mat4 and store in dest * * source matrix will not be transposed unless dest is m * * @param[in] m matrix * @param[out] dest result */ CGLM_INLINE void glm_mat4_transpose_to(mat4 m, mat4 dest) { #if defined(__wasm__) && defined(__wasm_simd128__) glm_mat4_transp_wasm(m, dest); #elif defined(__AVX__) glm_mat4_transp_avx(m, dest); #elif defined( __SSE__ ) || defined( __SSE2__ ) glm_mat4_transp_sse2(m, dest); #elif defined(CGLM_NEON_FP) glm_mat4_transp_neon(m, dest); #else dest[0][0] = m[0][0]; dest[1][0] = m[0][1]; dest[0][1] = m[1][0]; dest[1][1] = m[1][1]; dest[0][2] = m[2][0]; dest[1][2] = m[2][1]; dest[0][3] = m[3][0]; dest[1][3] = m[3][1]; dest[2][0] = m[0][2]; dest[3][0] = m[0][3]; dest[2][1] = m[1][2]; dest[3][1] = m[1][3]; dest[2][2] = m[2][2]; dest[3][2] = m[2][3]; dest[2][3] = m[3][2]; dest[3][3] = m[3][3]; #endif } /*! * @brief transpose mat4 and store result in same matrix * * @param[in, out] m source and dest */ CGLM_INLINE void glm_mat4_transpose(mat4 m) { #if defined(__wasm__) && defined(__wasm_simd128__) glm_mat4_transp_wasm(m, m); #elif defined(__AVX__) glm_mat4_transp_avx(m, m); #elif defined( __SSE__ ) || defined( __SSE2__ ) glm_mat4_transp_sse2(m, m); #elif defined(CGLM_NEON_FP) glm_mat4_transp_neon(m, m); #else mat4 d; glm_mat4_transpose_to(m, d); glm_mat4_ucopy(d, m); #endif } /*! * @brief scale (multiply with scalar) matrix without simd optimization * * multiply matrix with scalar * * @param[in, out] m matrix * @param[in] s scalar */ CGLM_INLINE void glm_mat4_scale_p(mat4 m, float s) { m[0][0] *= s; m[0][1] *= s; m[0][2] *= s; m[0][3] *= s; m[1][0] *= s; m[1][1] *= s; m[1][2] *= s; m[1][3] *= s; m[2][0] *= s; m[2][1] *= s; m[2][2] *= s; m[2][3] *= s; m[3][0] *= s; m[3][1] *= s; m[3][2] *= s; m[3][3] *= s; } /*! * @brief scale (multiply with scalar) matrix * * multiply matrix with scalar * * @param[in, out] m matrix * @param[in] s scalar */ CGLM_INLINE void glm_mat4_scale(mat4 m, float s) { #if defined(__wasm__) && defined(__wasm_simd128__) glm_mat4_scale_wasm(m, s); #elif defined(__AVX__) glm_mat4_scale_avx(m, s); #elif defined( __SSE__ ) || defined( __SSE2__ ) glm_mat4_scale_sse2(m, s); #elif defined(CGLM_NEON_FP) glm_mat4_scale_neon(m, s); #else glm_mat4_scale_p(m, s); #endif } /*! * @brief mat4 determinant * * @param[in] mat matrix * * @return determinant */ CGLM_INLINE float glm_mat4_det(mat4 mat) { #if defined(__wasm__) && defined(__wasm_simd128__) return glm_mat4_det_wasm(mat); #elif defined( __SSE__ ) || defined( __SSE2__ ) return glm_mat4_det_sse2(mat); #elif defined(CGLM_NEON_FP) return glm_mat4_det_neon(mat); #else /* [square] det(A) = det(At) */ float t[6]; float a = mat[0][0], b = mat[0][1], c = mat[0][2], d = mat[0][3], e = mat[1][0], f = mat[1][1], g = mat[1][2], h = mat[1][3], i = mat[2][0], j = mat[2][1], k = mat[2][2], l = mat[2][3], m = mat[3][0], n = mat[3][1], o = mat[3][2], p = mat[3][3]; t[0] = k * p - o * l; t[1] = j * p - n * l; t[2] = j * o - n * k; t[3] = i * p - m * l; t[4] = i * o - m * k; t[5] = i * n - m * j; return a * (f * t[0] - g * t[1] + h * t[2]) - b * (e * t[0] - g * t[3] + h * t[4]) + c * (e * t[1] - f * t[3] + h * t[5]) - d * (e * t[2] - f * t[4] + g * t[5]); #endif } /*! * @brief inverse mat4 and store in dest * * @param[in] mat matrix * @param[out] dest inverse matrix */ CGLM_INLINE void glm_mat4_inv(mat4 mat, mat4 dest) { #if defined(__wasm__) && defined(__wasm_simd128__) glm_mat4_inv_wasm(mat, dest); #elif defined( __SSE__ ) || defined( __SSE2__ ) glm_mat4_inv_sse2(mat, dest); #elif defined(CGLM_NEON_FP) glm_mat4_inv_neon(mat, dest); #else float a = mat[0][0], b = mat[0][1], c = mat[0][2], d = mat[0][3], e = mat[1][0], f = mat[1][1], g = mat[1][2], h = mat[1][3], i = mat[2][0], j = mat[2][1], k = mat[2][2], l = mat[2][3], m = mat[3][0], n = mat[3][1], o = mat[3][2], p = mat[3][3], c1 = k * p - l * o, c2 = c * h - d * g, c3 = i * p - l * m, c4 = a * h - d * e, c5 = j * p - l * n, c6 = b * h - d * f, c7 = i * n - j * m, c8 = a * f - b * e, c9 = j * o - k * n, c10 = b * g - c * f, c11 = i * o - k * m, c12 = a * g - c * e, idt = 1.0f/(c8*c1+c4*c9+c10*c3+c2*c7-c12*c5-c6*c11), ndt = -idt; dest[0][0] = (f * c1 - g * c5 + h * c9) * idt; dest[0][1] = (b * c1 - c * c5 + d * c9) * ndt; dest[0][2] = (n * c2 - o * c6 + p * c10) * idt; dest[0][3] = (j * c2 - k * c6 + l * c10) * ndt; dest[1][0] = (e * c1 - g * c3 + h * c11) * ndt; dest[1][1] = (a * c1 - c * c3 + d * c11) * idt; dest[1][2] = (m * c2 - o * c4 + p * c12) * ndt; dest[1][3] = (i * c2 - k * c4 + l * c12) * idt; dest[2][0] = (e * c5 - f * c3 + h * c7) * idt; dest[2][1] = (a * c5 - b * c3 + d * c7) * ndt; dest[2][2] = (m * c6 - n * c4 + p * c8) * idt; dest[2][3] = (i * c6 - j * c4 + l * c8) * ndt; dest[3][0] = (e * c9 - f * c11 + g * c7) * ndt; dest[3][1] = (a * c9 - b * c11 + c * c7) * idt; dest[3][2] = (m * c10 - n * c12 + o * c8) * ndt; dest[3][3] = (i * c10 - j * c12 + k * c8) * idt; #endif } /*! * @brief inverse mat4 and store in dest * * this func uses reciprocal approximation without extra corrections * e.g Newton-Raphson. this should work faster than normal, * to get more precise use glm_mat4_inv version. * * NOTE: You will lose precision, glm_mat4_inv is more accurate * * @param[in] mat matrix * @param[out] dest inverse matrix */ CGLM_INLINE void glm_mat4_inv_fast(mat4 mat, mat4 dest) { #if defined(__wasm__) && defined(__wasm_simd128__) glm_mat4_inv_fast_wasm(mat, dest); #elif defined( __SSE__ ) || defined( __SSE2__ ) glm_mat4_inv_fast_sse2(mat, dest); #else glm_mat4_inv(mat, dest); #endif } /*! * @brief swap two matrix columns * * @param[in,out] mat matrix * @param[in] col1 col1 * @param[in] col2 col2 */ CGLM_INLINE void glm_mat4_swap_col(mat4 mat, int col1, int col2) { CGLM_ALIGN(16) vec4 tmp; glm_vec4_copy(mat[col1], tmp); glm_vec4_copy(mat[col2], mat[col1]); glm_vec4_copy(tmp, mat[col2]); } /*! * @brief swap two matrix rows * * @param[in,out] mat matrix * @param[in] row1 row1 * @param[in] row2 row2 */ CGLM_INLINE void glm_mat4_swap_row(mat4 mat, int row1, int row2) { CGLM_ALIGN(16) vec4 tmp; tmp[0] = mat[0][row1]; tmp[1] = mat[1][row1]; tmp[2] = mat[2][row1]; tmp[3] = mat[3][row1]; mat[0][row1] = mat[0][row2]; mat[1][row1] = mat[1][row2]; mat[2][row1] = mat[2][row2]; mat[3][row1] = mat[3][row2]; mat[0][row2] = tmp[0]; mat[1][row2] = tmp[1]; mat[2][row2] = tmp[2]; mat[3][row2] = tmp[3]; } /*! * @brief helper for R (row vector) * M (matrix) * C (column vector) * * rmc stands for Row * Matrix * Column * * the result is scalar because R * M = Matrix1x4 (row vector), * then Matrix1x4 * Vec4 (column vector) = Matrix1x1 (Scalar) * * @param[in] r row vector or matrix1x4 * @param[in] m matrix4x4 * @param[in] c column vector or matrix4x1 * * @return scalar value e.g. B(s) */ CGLM_INLINE float glm_mat4_rmc(vec4 r, mat4 m, vec4 c) { vec4 tmp; glm_mat4_mulv(m, c, tmp); return glm_vec4_dot(r, tmp); } /*! * @brief Create mat4 matrix from pointer * * @param[in] src pointer to an array of floats * @param[out] dest matrix */ CGLM_INLINE void glm_mat4_make(const float * __restrict src, mat4 dest) { dest[0][0] = src[0]; dest[1][0] = src[4]; dest[0][1] = src[1]; dest[1][1] = src[5]; dest[0][2] = src[2]; dest[1][2] = src[6]; dest[0][3] = src[3]; dest[1][3] = src[7]; dest[2][0] = src[8]; dest[3][0] = src[12]; dest[2][1] = src[9]; dest[3][1] = src[13]; dest[2][2] = src[10]; dest[3][2] = src[14]; dest[2][3] = src[11]; dest[3][3] = src[15]; } #endif /* cglm_mat_h */ cglm-0.9.6/include/cglm/mat4x2.h000066400000000000000000000075171475344456400163370ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ /* Macros: GLM_MAT4X2_ZERO_INIT GLM_MAT4X2_ZERO Functions: CGLM_INLINE void glm_mat4x2_copy(mat4x2 mat, mat4x2 dest); CGLM_INLINE void glm_mat4x2_zero(mat4x2 mat); CGLM_INLINE void glm_mat4x2_make(const float * __restrict src, mat4x2 dest); CGLM_INLINE void glm_mat4x2_mul(mat4x2 m1, mat2x4 m2, mat2 dest); CGLM_INLINE void glm_mat4x2_mulv(mat4x2 m, vec4 v, vec2 dest); CGLM_INLINE void glm_mat4x2_transpose(mat4x2 m, mat2x4 dest); CGLM_INLINE void glm_mat4x2_scale(mat4x2 m, float s); */ #ifndef cglm_mat4x2_h #define cglm_mat4x2_h #include "common.h" #define GLM_MAT4X2_ZERO_INIT {{0.0f, 0.0f}, {0.0f, 0.0f}, {0.0f, 0.0f}, {0.0f, 0.0f}} /* for C only */ #define GLM_MAT4X2_ZERO GLM_MAT4X2_ZERO_INIT /*! * @brief copy all members of [mat] to [dest] * * @param[in] mat source * @param[out] dest destination */ CGLM_INLINE void glm_mat4x2_copy(mat4x2 mat, mat4x2 dest) { dest[0][0] = mat[0][0]; dest[0][1] = mat[0][1]; dest[1][0] = mat[1][0]; dest[1][1] = mat[1][1]; dest[2][0] = mat[2][0]; dest[2][1] = mat[2][1]; dest[3][0] = mat[3][0]; dest[3][1] = mat[3][1]; } /*! * @brief make given matrix zero. * * @param[in, out] mat matrix */ CGLM_INLINE void glm_mat4x2_zero(mat4x2 mat) { CGLM_ALIGN_MAT mat4x2 t = GLM_MAT4X2_ZERO_INIT; glm_mat4x2_copy(t, mat); } /*! * @brief Create mat4x2 matrix from pointer * * @param[in] src pointer to an array of floats * @param[out] dest matrix */ CGLM_INLINE void glm_mat4x2_make(const float * __restrict src, mat4x2 dest) { dest[0][0] = src[0]; dest[0][1] = src[1]; dest[1][0] = src[2]; dest[1][1] = src[3]; dest[2][0] = src[4]; dest[2][1] = src[5]; dest[3][0] = src[6]; dest[3][1] = src[7]; } /*! * @brief multiply m1 and m2 to dest * * @code * glm_mat4x2_mul(mat4x2, mat2x4, mat2); * @endcode * * @param[in] m1 left matrix (mat4x2) * @param[in] m2 right matrix (mat2x4) * @param[out] dest destination matrix (mat2) */ CGLM_INLINE void glm_mat4x2_mul(mat4x2 m1, mat2x4 m2, mat2 dest) { float a00 = m1[0][0], a01 = m1[0][1], a10 = m1[1][0], a11 = m1[1][1], a20 = m1[2][0], a21 = m1[2][1], a30 = m1[3][0], a31 = m1[3][1], b00 = m2[0][0], b01 = m2[0][1], b02 = m2[0][2], b03 = m2[0][3], b10 = m2[1][0], b11 = m2[1][1], b12 = m2[1][2], b13 = m2[1][3]; dest[0][0] = a00 * b00 + a10 * b01 + a20 * b02 + a30 * b03; dest[0][1] = a01 * b00 + a11 * b01 + a21 * b02 + a31 * b03; dest[1][0] = a00 * b10 + a10 * b11 + a20 * b12 + a30 * b13; dest[1][1] = a01 * b10 + a11 * b11 + a21 * b12 + a31 * b13; } /*! * @brief multiply matrix with column vector and store in dest column vector * * @param[in] m matrix (left) * @param[in] v vector (right, column vector) * @param[out] dest result vector */ CGLM_INLINE void glm_mat4x2_mulv(mat4x2 m, vec4 v, vec2 dest) { float v0 = v[0], v1 = v[1], v2 = v[2], v3 = v[3]; dest[0] = m[0][0] * v0 + m[1][0] * v1 + m[2][0] * v2 + m[3][0] * v3; dest[1] = m[0][1] * v0 + m[1][1] * v1 + m[2][1] * v2 + m[3][1] * v3; } /*! * @brief transpose matrix and store in dest * * @param[in] m matrix * @param[out] dest result */ CGLM_INLINE void glm_mat4x2_transpose(mat4x2 m, mat2x4 dest) { dest[0][0] = m[0][0]; dest[0][1] = m[1][0]; dest[0][2] = m[2][0]; dest[0][3] = m[3][0]; dest[1][0] = m[0][1]; dest[1][1] = m[1][1]; dest[1][2] = m[2][1]; dest[1][3] = m[3][1]; } /*! * @brief scale (multiply with scalar) matrix * * multiply matrix with scalar * * @param[in, out] m matrix * @param[in] s scalar */ CGLM_INLINE void glm_mat4x2_scale(mat4x2 m, float s) { m[0][0] *= s; m[0][1] *= s; m[1][0] *= s; m[1][1] *= s; m[2][0] *= s; m[2][1] *= s; m[3][0] *= s; m[3][1] *= s; } #endif cglm-0.9.6/include/cglm/mat4x3.h000066400000000000000000000113621475344456400163310ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ /* Macros: GLM_MAT4X3_ZERO_INIT GLM_MAT4X3_ZERO Functions: CGLM_INLINE void glm_mat4x3_copy(mat4x3 mat, mat4x3 dest); CGLM_INLINE void glm_mat4x3_zero(mat4x3 mat); CGLM_INLINE void glm_mat4x3_make(const float * __restrict src, mat4x3 dest); CGLM_INLINE void glm_mat4x3_mul(mat4x3 m1, mat3x4 m2, mat3 dest); CGLM_INLINE void glm_mat4x3_mulv(mat4x3 m, vec4 v, vec3 dest); CGLM_INLINE void glm_mat4x3_transpose(mat4x3 m, mat3x4 dest); CGLM_INLINE void glm_mat4x3_scale(mat4x3 m, float s); */ #ifndef cglm_mat4x3_h #define cglm_mat4x3_h #include "common.h" #define GLM_MAT4X3_ZERO_INIT {{0.0f, 0.0f, 0.0f}, {0.0f, 0.0f, 0.0f}, \ {0.0f, 0.0f, 0.0f}, {0.0f, 0.0f, 0.0f}} /* for C only */ #define GLM_MAT4X3_ZERO GLM_MAT4X3_ZERO_INIT /*! * @brief copy all members of [mat] to [dest] * * @param[in] mat source * @param[out] dest destination */ CGLM_INLINE void glm_mat4x3_copy(mat4x3 mat, mat4x3 dest) { dest[0][0] = mat[0][0]; dest[0][1] = mat[0][1]; dest[0][2] = mat[0][2]; dest[1][0] = mat[1][0]; dest[1][1] = mat[1][1]; dest[1][2] = mat[1][2]; dest[2][0] = mat[2][0]; dest[2][1] = mat[2][1]; dest[2][2] = mat[2][2]; dest[3][0] = mat[3][0]; dest[3][1] = mat[3][1]; dest[3][2] = mat[3][2]; } /*! * @brief make given matrix zero. * * @param[in, out] mat matrix */ CGLM_INLINE void glm_mat4x3_zero(mat4x3 mat) { CGLM_ALIGN_MAT mat4x3 t = GLM_MAT4X3_ZERO_INIT; glm_mat4x3_copy(t, mat); } /*! * @brief Create mat4x3 matrix from pointer * * @param[in] src pointer to an array of floats * @param[out] dest matrix */ CGLM_INLINE void glm_mat4x3_make(const float * __restrict src, mat4x3 dest) { dest[0][0] = src[0]; dest[0][1] = src[1]; dest[0][2] = src[2]; dest[1][0] = src[3]; dest[1][1] = src[4]; dest[1][2] = src[5]; dest[2][0] = src[6]; dest[2][1] = src[7]; dest[2][2] = src[8]; dest[3][0] = src[9]; dest[3][1] = src[10]; dest[3][2] = src[11]; } /*! * @brief multiply m1 and m2 to dest * * @code * glm_mat4x3_mul(mat4x3, mat3x4, mat3); * @endcode * * @param[in] m1 left matrix (mat4x3) * @param[in] m2 right matrix (mat3x4) * @param[out] dest destination matrix (mat3) */ CGLM_INLINE void glm_mat4x3_mul(mat4x3 m1, mat3x4 m2, mat3 dest) { float a00 = m1[0][0], a01 = m1[0][1], a02 = m1[0][2], a10 = m1[1][0], a11 = m1[1][1], a12 = m1[1][2], a20 = m1[2][0], a21 = m1[2][1], a22 = m1[2][2], a30 = m1[3][0], a31 = m1[3][1], a32 = m1[3][2], b00 = m2[0][0], b01 = m2[0][1], b02 = m2[0][2], b03 = m2[0][3], b10 = m2[1][0], b11 = m2[1][1], b12 = m2[1][2], b13 = m2[1][3], b20 = m2[2][0], b21 = m2[2][1], b22 = m2[2][2], b23 = m2[2][3]; dest[0][0] = a00 * b00 + a10 * b01 + a20 * b02 + a30 * b03; dest[0][1] = a01 * b00 + a11 * b01 + a21 * b02 + a31 * b03; dest[0][2] = a02 * b00 + a12 * b01 + a22 * b02 + a32 * b03; dest[1][0] = a00 * b10 + a10 * b11 + a20 * b12 + a30 * b13; dest[1][1] = a01 * b10 + a11 * b11 + a21 * b12 + a31 * b13; dest[1][2] = a02 * b10 + a12 * b11 + a22 * b12 + a32 * b13; dest[2][0] = a00 * b20 + a10 * b21 + a20 * b22 + a30 * b23; dest[2][1] = a01 * b20 + a11 * b21 + a21 * b22 + a31 * b23; dest[2][2] = a02 * b20 + a12 * b21 + a22 * b22 + a32 * b23; } /*! * @brief multiply matrix with column vector and store in dest column vector * * @param[in] m matrix (left) * @param[in] v vector (right, column vector) * @param[out] dest result vector */ CGLM_INLINE void glm_mat4x3_mulv(mat4x3 m, vec4 v, vec3 dest) { float v0 = v[0], v1 = v[1], v2 = v[2], v3 = v[3]; dest[0] = m[0][0] * v0 + m[1][0] * v1 + m[2][0] * v2 + m[3][0] * v3; dest[1] = m[0][1] * v0 + m[1][1] * v1 + m[2][1] * v2 + m[3][1] * v3; dest[2] = m[0][2] * v0 + m[1][2] * v1 + m[2][2] * v2 + m[3][2] * v3; } /*! * @brief transpose matrix and store in dest * * @param[in] m matrix * @param[out] dest result */ CGLM_INLINE void glm_mat4x3_transpose(mat4x3 m, mat3x4 dest) { dest[0][0] = m[0][0]; dest[0][1] = m[1][0]; dest[0][2] = m[2][0]; dest[0][3] = m[3][0]; dest[1][0] = m[0][1]; dest[1][1] = m[1][1]; dest[1][2] = m[2][1]; dest[1][3] = m[3][1]; dest[2][0] = m[0][2]; dest[2][1] = m[1][2]; dest[2][2] = m[2][2]; dest[2][3] = m[3][2]; } /*! * @brief scale (multiply with scalar) matrix * * multiply matrix with scalar * * @param[in, out] m matrix * @param[in] s scalar */ CGLM_INLINE void glm_mat4x3_scale(mat4x3 m, float s) { m[0][0] *= s; m[0][1] *= s; m[0][2] *= s; m[1][0] *= s; m[1][1] *= s; m[1][2] *= s; m[2][0] *= s; m[2][1] *= s; m[2][2] *= s; m[3][0] *= s; m[3][1] *= s; m[3][2] *= s; } #endif cglm-0.9.6/include/cglm/noise.h000066400000000000000000000742531475344456400163360ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file * * Based on the work of Stefan Gustavson and Ashima Arts on "webgl-noise": * https://github.com/stegu/webgl-noise * Following Stefan Gustavson's paper "Simplex noise demystified": * http://www.itn.liu.se/~stegu/simplexnoise/simplexnoise.pdf * * Implementation based on glm::perlin function: * https://github.com/g-truc/glm/blob/master/glm/gtc/noise.inl */ #ifndef cglm_noise_h #define cglm_noise_h #include "vec4.h" #include "vec4-ext.h" #include "vec3.h" #include "vec3-ext.h" #include "vec2.h" #include "vec2-ext.h" #define glm__noiseDetail_mod289(x) (x - floorf(x * (1.0f / 289.0f)) * 289.0f) /* glm__noiseDetail_permute(vec4 x, vec4 dest) */ #define glm__noiseDetail_permute(x, dest) { \ dest[0] = glm__noiseDetail_mod289((x[0] * 34.0f + 1.0f) * x[0]); \ dest[1] = glm__noiseDetail_mod289((x[1] * 34.0f + 1.0f) * x[1]); \ dest[2] = glm__noiseDetail_mod289((x[2] * 34.0f + 1.0f) * x[2]); \ dest[3] = glm__noiseDetail_mod289((x[3] * 34.0f + 1.0f) * x[3]); \ } /* glm__noiseDetail_fade_vec4(vec4 t, vec4 dest) */ #define glm__noiseDetail_fade_vec4(t, dest) { \ /* dest = (t * t * t) * (t * (t * 6.0f - 15.0f) + 10.0f) */ \ vec4 temp; \ glm_vec4_mul(t, t, temp); \ glm_vec4_mul(temp, t, temp); \ /* dest = (t * (t * 6.0f - 15.0f) + 10.0f) */ \ glm_vec4_scale(t, 6.0f, dest); \ glm_vec4_subs(dest, 15.0f, dest); \ glm_vec4_mul(t, dest, dest); \ glm_vec4_adds(dest, 10.0f, dest); \ /* dest = temp * dest */ \ glm_vec4_mul(temp, dest, dest); \ } /* glm__noiseDetail_fade_vec3(vec3 t, vec3 dest) */ #define glm__noiseDetail_fade_vec3(t, dest) { \ /* dest = (t * t * t) * (t * (t * 6.0f - 15.0f) + 10.0f) */ \ /* temp = t * t * t */ \ vec3 temp; \ glm_vec3_mul(t, t, temp); \ glm_vec3_mul(temp, t, temp); \ /* dest = (t * (t * 6.0f - 15.0f) + 10.0f) */ \ glm_vec3_scale(t, 6.0f, dest); \ glm_vec3_subs(dest, 15.0f, dest); \ glm_vec3_mul(t, dest, dest); \ glm_vec3_adds(dest, 10.0f, dest); \ /* dest = temp * dest */ \ glm_vec3_mul(temp, dest, dest); \ } /* glm__noiseDetail_fade_vec2(vec2 t, vec2 dest) */ #define glm__noiseDetail_fade_vec2(t, dest) { \ /* dest = (t * t * t) * (t * (t * 6.0f - 15.0f) + 10.0f) */ \ /* temp = t * t * t */ \ vec2 temp; \ glm_vec2_mul(t, t, temp); \ glm_vec2_mul(temp, t, temp); \ /* dest = (t * (t * 6.0f - 15.0f) + 10.0f) */ \ glm_vec2_scale(t, 6.0f, dest); \ glm_vec2_subs(dest, 15.0f, dest); \ glm_vec2_mul(t, dest, dest); \ glm_vec2_adds(dest, 10.0f, dest); \ /* dest = temp * dest */ \ glm_vec2_mul(temp, dest, dest); \ } /* glm__noiseDetail_taylorInvSqrt(vec4 x, vec4 dest) */ #define glm__noiseDetail_taylorInvSqrt(x, dest) { \ /* dest = 1.79284291400159f - 0.85373472095314f * x */ \ vec4 temp; \ glm_vec4_scale(x, 0.85373472095314f, temp); /* temp = 0.853...f * x */ \ glm_vec4_fill(dest, 1.79284291400159f); /* dest = 1.792...f */ \ glm_vec4_sub(dest, temp, dest); /* dest = 1.79284291400159f - temp */ \ } /* norm = taylorInvSqrt(vec4( * dot(g00__, g00__), * dot(g01__, g01__), * dot(g10__, g10__), * dot(g11__, g11__) * )); */ /* glm__noiseDetail_gradNorm_vec4(vec4 g00__, vec4 g01__, vec4 g10__, vec4 g11__) */ #define glm__noiseDetail_gradNorm_vec4(g00__, g01__, g10__, g11__) { \ vec4 norm; \ norm[0] = glm_vec4_dot(g00__, g00__); /* norm.x = dot(g00__, g00__) */ \ norm[1] = glm_vec4_dot(g01__, g01__); /* norm.y = dot(g01__, g01__) */ \ norm[2] = glm_vec4_dot(g10__, g10__); /* norm.z = dot(g10__, g10__) */ \ norm[3] = glm_vec4_dot(g11__, g11__); /* norm.w = dot(g11__, g11__) */ \ glm__noiseDetail_taylorInvSqrt(norm, norm); /* norm = taylorInvSqrt(norm) */ \ \ glm_vec4_scale(g00__, norm[0], g00__); /* g00__ *= norm.x */ \ glm_vec4_scale(g01__, norm[1], g01__); /* g01__ *= norm.y */ \ glm_vec4_scale(g10__, norm[2], g10__); /* g10__ *= norm.z */ \ glm_vec4_scale(g11__, norm[3], g11__); /* g11__ *= norm.w */ \ } /* glm__noiseDetail_gradNorm_vec3(vec3 g00_, vec3 g01_, vec3 g10_, vec3 g11_) */ #define glm__noiseDetail_gradNorm_vec3(g00_, g01_, g10_, g11_) { \ vec4 norm; \ norm[0] = glm_vec3_dot(g00_, g00_); /* norm.x = dot(g00_, g00_) */ \ norm[1] = glm_vec3_dot(g01_, g01_); /* norm.y = dot(g01_, g01_) */ \ norm[2] = glm_vec3_dot(g10_, g10_); /* norm.z = dot(g10_, g10_) */ \ norm[3] = glm_vec3_dot(g11_, g11_); /* norm.w = dot(g11_, g11_) */ \ glm__noiseDetail_taylorInvSqrt(norm, norm); /* norm = taylorInvSqrt(norm) */ \ \ glm_vec3_scale(g00_, norm[0], g00_); /* g00_ *= norm.x */ \ glm_vec3_scale(g01_, norm[1], g01_); /* g01_ *= norm.y */ \ glm_vec3_scale(g10_, norm[2], g10_); /* g10_ *= norm.z */ \ glm_vec3_scale(g11_, norm[3], g11_); /* g11_ *= norm.w */ \ } /* glm__noiseDetail_gradNorm_vec2(vec2 g00, vec2 g01, vec2 g10, vec2 g11) */ #define glm__noiseDetail_gradNorm_vec2(g00, g01, g10, g11) { \ vec4 norm; \ norm[0] = glm_vec2_dot(g00, g00); /* norm.x = dot(g00, g00) */ \ norm[1] = glm_vec2_dot(g01, g01); /* norm.y = dot(g01, g01) */ \ norm[2] = glm_vec2_dot(g10, g10); /* norm.z = dot(g10, g10) */ \ norm[3] = glm_vec2_dot(g11, g11); /* norm.w = dot(g11, g11) */ \ glm__noiseDetail_taylorInvSqrt(norm, norm); /* norm = taylorInvSqrt(norm) */ \ \ glm_vec2_scale(g00, norm[0], g00); /* g00 *= norm.x */ \ glm_vec2_scale(g01, norm[1], g01); /* g01 *= norm.y */ \ glm_vec2_scale(g10, norm[2], g10); /* g10 *= norm.z */ \ glm_vec2_scale(g11, norm[3], g11); /* g11 *= norm.w */ \ } /* glm__noiseDetail_i2gxyzw(vec4 ixy, vec4 gx, vec4 gy, vec4 gz, vec4 gw) */ #define glm__noiseDetail_i2gxyzw(ixy, gx, gy, gz, gw) { \ /* gx = ixy / 7.0 */ \ glm_vec4_divs(ixy, 7.0f, gx); /* gx = ixy / 7.0 */ \ \ /* gy = fract(gx) / 7.0 */ \ glm_vec4_floor(gx, gy); /* gy = floor(gx) */ \ glm_vec4_divs(gy, 7.0f, gy); /* gy /= 7.0 */ \ \ /* gz = floor(gy) / 6.0 */ \ glm_vec4_floor(gy, gz); /* gz = floor(gy) */ \ glm_vec4_divs(gz, 6.0f, gz); /* gz /= 6.0 */ \ \ /* gx = fract(gx) - 0.5f */ \ glm_vec4_fract(gx, gx); /* gx = fract(gx) */ \ glm_vec4_subs(gx, 0.5f, gx); /* gx -= 0.5f */ \ \ /* gy = fract(gy) - 0.5f */ \ glm_vec4_fract(gy, gy); /* gy = fract(gy) */ \ glm_vec4_subs(gy, 0.5f, gy); /* gy -= 0.5f */ \ \ /* gz = fract(gz) - 0.5f */ \ glm_vec4_fract(gz, gz); /* gz = fract(gz) */ \ glm_vec4_subs(gz, 0.5f, gz); /* gz -= 0.5f */ \ \ /* abs(gx), abs(gy), abs(gz) */ \ vec4 gxa, gya, gza; \ glm_vec4_abs(gx, gxa); /* gxa = abs(gx) */ \ glm_vec4_abs(gy, gya); /* gya = abs(gy) */ \ glm_vec4_abs(gz, gza); /* gza = abs(gz) */ \ \ /* gw = 0.75 - abs(gx) - abs(gy) - abs(gz) */ \ glm_vec4_fill(gw, 0.75f); /* gw = 0.75 */ \ glm_vec4_sub(gw, gxa, gw); /* gw -= gxa */ \ glm_vec4_sub(gw, gza, gw); /* gw -= gza */ \ glm_vec4_sub(gw, gya, gw); /* gw -= gya */ \ \ /* sw = step(gw, 0.0); */ \ vec4 sw; \ glm_vec4_stepr(gw, 0.0f, sw); /* sw = step(gw, 0.0) */ \ \ /* gx -= sw * (step(vec4(0), gx) - T(0.5)); */ \ vec4 temp = {0.0f}; /* temp = 0.0 */ \ glm_vec4_step(temp, gx, temp); /* temp = step(temp, gx) */ \ glm_vec4_subs(temp, 0.5f, temp); /* temp -= 0.5 */ \ glm_vec4_mul(sw, temp, temp); /* temp *= sw */ \ glm_vec4_sub(gx, temp, gx); /* gx -= temp */ \ \ /* gy -= sw * (step(vec4(0), gy) - T(0.5)); */ \ glm_vec4_zero(temp); /* reset temp */ \ glm_vec4_step(temp, gy, temp); /* temp = step(temp, gy) */ \ glm_vec4_subs(temp, 0.5f, temp); /* temp -= 0.5 */ \ glm_vec4_mul(sw, temp, temp); /* temp *= sw */ \ glm_vec4_sub(gy, temp, gy); /* gy -= temp */ \ } /* NOTE: This function is not *quite* analogous to glm__noiseDetail_i2gxyzw * to try to match the output of glm::perlin. I think it might be a bug in * in the original implementation, but for now I'm keeping it consistent. -MK * * Follow up: The original implementation (glm v 1.0.1) does: * * vec<4, T, Q> gx0 = ixy0 * T(1.0 / 7.0); * * as opposed to: * * vec<4, T, Q> gx0 = ixy0 / T(7); * * This ends up mapping to different simd instructions, at least on AMD. * The delta is tiny but it gets amplified by the rest of the noise function. * Hence we too need to do `glm_vec4_scale` as opposed to `glm_vec4_divs`, to * match it. -MK */ /* glm__noiseDetail_i2gxyz(vec4 i, vec4 gx, vec4 gy, vec4 gz) */ #define glm__noiseDetail_i2gxyz(ixy, gx, gy, gz) { \ /* gx = ixy / 7.0 */ \ glm_vec4_scale(ixy, 1.0f / 7.0f, gx); /* gx = ixy * (1/7.0) */\ \ /* gy = fract(floor(gx0) / 7.0)) - 0.5; */ \ glm_vec4_floor(gx, gy); /* gy = floor(gx) */ \ glm_vec4_scale(gy, 1.0f / 7.0f, gy); /* gy *= 1 / 7.0 */ \ glm_vec4_fract(gy, gy); /* gy = fract(gy) */ \ glm_vec4_subs(gy, 0.5f, gy); /* gy -= 0.5f */ \ \ /* gx = fract(gx); */ \ glm_vec4_fract(gx, gx); /* gx = fract(gx) */ \ \ /* abs(gx), abs(gy) */ \ vec4 gxa, gya; \ glm_vec4_abs(gx, gxa); /* gxa = abs(gx) */ \ glm_vec4_abs(gy, gya); /* gya = abs(gy) */ \ \ /* gz = vec4(0.5) - abs(gx0) - abs(gy0); */ \ glm_vec4_fill(gz, 0.5f); /* gz = 0.5 */ \ glm_vec4_sub(gz, gxa, gz); /* gz -= gxa */ \ glm_vec4_sub(gz, gya, gz); /* gz -= gya */ \ \ /* sz = step(gw, 0.0); */ \ vec4 sz; \ glm_vec4_stepr(gz, 0.0f, sz); /* sz = step(gz, 0.0) */ \ \ /* gx0 -= sz0 * (step(0.0, gx0) - T(0.5)); */ \ vec4 temp = {0.0f}; /* temp = 0.0 */ \ glm_vec4_step(temp, gx, temp); /* temp = step(temp, gx) */ \ glm_vec4_subs(temp, 0.5f, temp); /* temp -= 0.5 */ \ glm_vec4_mul(sz, temp, temp); /* temp *= sz */ \ glm_vec4_sub(gx, temp, gx); /* gx -= temp */ \ \ /* gy0 -= sz0 * (step(0.0, gy0) - T(0.5)); */ \ glm_vec4_zero(temp); /* reset temp */ \ glm_vec4_step(temp, gy, temp); /* temp = step(temp, gy) */ \ glm_vec4_subs(temp, 0.5f, temp); /* temp -= 0.5 */ \ glm_vec4_mul(sz, temp, temp); /* temp *= sz */ \ glm_vec4_sub(gy, temp, gy); /* gy -= temp */ \ } /* glm__noiseDetail_i2gxy(vec4 i, vec4 gx, vec4 gy) */ #define glm__noiseDetail_i2gxy(i, gx, gy) { \ /* gx = 2.0 * fract(i / 41.0) - 1.0; */ \ glm_vec4_divs(i, 41.0f, gx); /* gx = i / 41.0 */ \ glm_vec4_fract(gx, gx); /* gx = fract(gx) */ \ glm_vec4_scale(gx, 2.0f, gx); /* gx *= 2.0 */ \ glm_vec4_subs(gx, 1.0f, gx); /* gx -= 1.0 */ \ \ /* gy = abs(gx) - 0.5; */ \ glm_vec4_abs(gx, gy); /* gy = abs(gx) */ \ glm_vec4_subs(gy, 0.5f, gy); /* gy -= 0.5 */ \ \ /* tx = floor(gx + 0.5); */ \ vec4 tx; \ glm_vec4_adds(gx, 0.5f, tx); /* tx = gx + 0.5 */ \ glm_vec4_floor(tx, tx); /* tx = floor(tx) */ \ \ /* gx = gx - tx; */ \ glm_vec4_sub(gx, tx, gx); /* gx -= tx */ \ } /* ============================================================================ * Classic perlin noise * ============================================================================ */ /*! * @brief Classic perlin noise * * @param[in] point 4D vector * @returns perlin noise value */ CGLM_INLINE float glm_perlin_vec4(vec4 point) { /* Integer part of p for indexing */ vec4 Pi0; glm_vec4_floor(point, Pi0); /* Pi0 = floor(point); */ /* Integer part + 1 */ vec4 Pi1; glm_vec4_adds(Pi0, 1.0f, Pi1); /* Pi1 = Pi0 + 1.0f; */ glm_vec4_mods(Pi0, 289.0f, Pi0); /* Pi0 = mod(Pi0, 289.0f); */ glm_vec4_mods(Pi1, 289.0f, Pi1); /* Pi1 = mod(Pi1, 289.0f); */ /* Fractional part of p for interpolation */ vec4 Pf0; glm_vec4_fract(point, Pf0); /* Fractional part - 1.0 */ vec4 Pf1; glm_vec4_subs(Pf0, 1.0f, Pf1); vec4 ix = {Pi0[0], Pi1[0], Pi0[0], Pi1[0]}; vec4 iy = {Pi0[1], Pi0[1], Pi1[1], Pi1[1]}; vec4 iz0 = {Pi0[2], Pi0[2], Pi0[2], Pi0[2]}; /* iz0 = vec4(Pi0.z); */ vec4 iz1 = {Pi1[2], Pi1[2], Pi1[2], Pi1[2]}; /* iz1 = vec4(Pi1.z); */ vec4 iw0 = {Pi0[3], Pi0[3], Pi0[3], Pi0[3]}; /* iw0 = vec4(Pi0.w); */ vec4 iw1 = {Pi1[3], Pi1[3], Pi1[3], Pi1[3]}; /* iw1 = vec4(Pi1.w); */ /* ------------ */ /* ixy = permute(permute(ix) + iy) */ vec4 ixy; glm__noiseDetail_permute(ix, ixy); /* ixy = permute(ix) */ glm_vec4_add(ixy, iy, ixy); /* ixy += iy; */ glm__noiseDetail_permute(ixy, ixy); /* ixy = permute(ixy) */ /* ixy0 = permute(ixy + iz0) */ vec4 ixy0; glm_vec4_add(ixy, iz0, ixy0); /* ixy0 = ixy + iz0 */ glm__noiseDetail_permute(ixy0, ixy0); /* ixy0 = permute(ixy0) */ /* ixy1 = permute(ixy + iz1) */ vec4 ixy1; glm_vec4_add(ixy, iz1, ixy1); /* ixy1 = ixy, iz1 */ glm__noiseDetail_permute(ixy1, ixy1); /* ixy1 = permute(ixy1) */ /* ixy00 = permute(ixy0 + iw0) */ vec4 ixy00; glm_vec4_add(ixy0, iw0, ixy00); /* ixy00 = ixy0 + iw0 */ glm__noiseDetail_permute(ixy00, ixy00); /* ixy00 = permute(ixy00) */ /* ixy01 = permute(ixy0 + iw1) */ vec4 ixy01; glm_vec4_add(ixy0, iw1, ixy01); /* ixy01 = ixy0 + iw1 */ glm__noiseDetail_permute(ixy01, ixy01); /* ixy01 = permute(ixy01) */ /* ixy10 = permute(ixy1 + iw0) */ vec4 ixy10; glm_vec4_add(ixy1, iw0, ixy10); /* ixy10 = ixy1 + iw0 */ glm__noiseDetail_permute(ixy10, ixy10); /* ixy10 = permute(ixy10) */ /* ixy11 = permute(ixy1 + iw1) */ vec4 ixy11; glm_vec4_add(ixy1, iw1, ixy11); /* ixy11 = ixy1 + iw1 */ glm__noiseDetail_permute(ixy11, ixy11); /* ixy11 = permute(ixy11) */ /* ------------ */ vec4 gx00, gy00, gz00, gw00; glm__noiseDetail_i2gxyzw(ixy00, gx00, gy00, gz00, gw00); vec4 gx01, gy01, gz01, gw01; glm__noiseDetail_i2gxyzw(ixy01, gx01, gy01, gz01, gw01); vec4 gx10, gy10, gz10, gw10; glm__noiseDetail_i2gxyzw(ixy10, gx10, gy10, gz10, gw10); vec4 gx11, gy11, gz11, gw11; glm__noiseDetail_i2gxyzw(ixy11, gx11, gy11, gz11, gw11); /* ------------ */ vec4 g0000 = {gx00[0], gy00[0], gz00[0], gw00[0]}; /* g0000 = vec4(gx00.x, gy00.x, gz00.x, gw00.x); */ vec4 g0100 = {gx00[2], gy00[2], gz00[2], gw00[2]}; /* g0100 = vec4(gx00.z, gy00.z, gz00.z, gw00.z); */ vec4 g1000 = {gx00[1], gy00[1], gz00[1], gw00[1]}; /* g1000 = vec4(gx00.y, gy00.y, gz00.y, gw00.y); */ vec4 g1100 = {gx00[3], gy00[3], gz00[3], gw00[3]}; /* g1100 = vec4(gx00.w, gy00.w, gz00.w, gw00.w); */ vec4 g0001 = {gx01[0], gy01[0], gz01[0], gw01[0]}; /* g0001 = vec4(gx01.x, gy01.x, gz01.x, gw01.x); */ vec4 g0101 = {gx01[2], gy01[2], gz01[2], gw01[2]}; /* g0101 = vec4(gx01.z, gy01.z, gz01.z, gw01.z); */ vec4 g1001 = {gx01[1], gy01[1], gz01[1], gw01[1]}; /* g1001 = vec4(gx01.y, gy01.y, gz01.y, gw01.y); */ vec4 g1101 = {gx01[3], gy01[3], gz01[3], gw01[3]}; /* g1101 = vec4(gx01.w, gy01.w, gz01.w, gw01.w); */ vec4 g0010 = {gx10[0], gy10[0], gz10[0], gw10[0]}; /* g0010 = vec4(gx10.x, gy10.x, gz10.x, gw10.x); */ vec4 g0110 = {gx10[2], gy10[2], gz10[2], gw10[2]}; /* g0110 = vec4(gx10.z, gy10.z, gz10.z, gw10.z); */ vec4 g1010 = {gx10[1], gy10[1], gz10[1], gw10[1]}; /* g1010 = vec4(gx10.y, gy10.y, gz10.y, gw10.y); */ vec4 g1110 = {gx10[3], gy10[3], gz10[3], gw10[3]}; /* g1110 = vec4(gx10.w, gy10.w, gz10.w, gw10.w); */ vec4 g0011 = {gx11[0], gy11[0], gz11[0], gw11[0]}; /* g0011 = vec4(gx11.x, gy11.x, gz11.x, gw11.x); */ vec4 g0111 = {gx11[2], gy11[2], gz11[2], gw11[2]}; /* g0111 = vec4(gx11.z, gy11.z, gz11.z, gw11.z); */ vec4 g1011 = {gx11[1], gy11[1], gz11[1], gw11[1]}; /* g1011 = vec4(gx11.y, gy11.y, gz11.y, gw11.y); */ vec4 g1111 = {gx11[3], gy11[3], gz11[3], gw11[3]}; /* g1111 = vec4(gx11.w, gy11.w, gz11.w, gw11.w); */ glm__noiseDetail_gradNorm_vec4(g0000, g0100, g1000, g1100); glm__noiseDetail_gradNorm_vec4(g0001, g0101, g1001, g1101); glm__noiseDetail_gradNorm_vec4(g0010, g0110, g1010, g1110); glm__noiseDetail_gradNorm_vec4(g0011, g0111, g1011, g1111); /* ------------ */ float n0000 = glm_vec4_dot(g0000, Pf0); /* n0000 = dot(g0000, Pf0) */ /* n1000 = dot(g1000, vec4(Pf1.x, Pf0.y, Pf0.z, Pf0.w)) */ vec4 n1000d = {Pf1[0], Pf0[1], Pf0[2], Pf0[3]}; float n1000 = glm_vec4_dot(g1000, n1000d); /* n0100 = dot(g0100, vec4(Pf0.x, Pf1.y, Pf0.z, Pf0.w)) */ vec4 n0100d = {Pf0[0], Pf1[1], Pf0[2], Pf0[3]}; float n0100 = glm_vec4_dot(g0100, n0100d); /* n1100 = dot(g1100, vec4(Pf1.x, Pf1.y, Pf0.z, Pf0.w)) */ vec4 n1100d = {Pf1[0], Pf1[1], Pf0[2], Pf0[3]}; float n1100 = glm_vec4_dot(g1100, n1100d); /* n0010 = dot(g0010, vec4(Pf0.x, Pf0.y, Pf1.z, Pf0.w)) */ vec4 n0010d = {Pf0[0], Pf0[1], Pf1[2], Pf0[3]}; float n0010 = glm_vec4_dot(g0010, n0010d); /* n1010 = dot(g1010, vec4(Pf1.x, Pf0.y, Pf1.z, Pf0.w)) */ vec4 n1010d = {Pf1[0], Pf0[1], Pf1[2], Pf0[3]}; float n1010 = glm_vec4_dot(g1010, n1010d); /* n0110 = dot(g0110, vec4(Pf0.x, Pf1.y, Pf1.z, Pf0.w)) */ vec4 n0110d = {Pf0[0], Pf1[1], Pf1[2], Pf0[3]}; float n0110 = glm_vec4_dot(g0110, n0110d); /* n1110 = dot(g1110, vec4(Pf1.x, Pf1.y, Pf1.z, Pf0.w)) */ vec4 n1110d = {Pf1[0], Pf1[1], Pf1[2], Pf0[3]}; float n1110 = glm_vec4_dot(g1110, n1110d); /* n0001 = dot(g0001, vec4(Pf0.x, Pf0.y, Pf0.z, Pf1.w)) */ vec4 n0001d = {Pf0[0], Pf0[1], Pf0[2], Pf1[3]}; float n0001 = glm_vec4_dot(g0001, n0001d); /* n1001 = dot(g1001, vec4(Pf1.x, Pf0.y, Pf0.z, Pf1.w)) */ vec4 n1001d = {Pf1[0], Pf0[1], Pf0[2], Pf1[3]}; float n1001 = glm_vec4_dot(g1001, n1001d); /* n0101 = dot(g0101, vec4(Pf0.x, Pf1.y, Pf0.z, Pf1.w)) */ vec4 n0101d = {Pf0[0], Pf1[1], Pf0[2], Pf1[3]}; float n0101 = glm_vec4_dot(g0101, n0101d); /* n1101 = dot(g1101, vec4(Pf1.x, Pf1.y, Pf0.z, Pf1.w)) */ vec4 n1101d = {Pf1[0], Pf1[1], Pf0[2], Pf1[3]}; float n1101 = glm_vec4_dot(g1101, n1101d); /* n0011 = dot(g0011, vec4(Pf0.x, Pf0.y, Pf1.z, Pf1.w)) */ vec4 n0011d = {Pf0[0], Pf0[1], Pf1[2], Pf1[3]}; float n0011 = glm_vec4_dot(g0011, n0011d); /* n1011 = dot(g1011, vec4(Pf1.x, Pf0.y, Pf1.z, Pf1.w)) */ vec4 n1011d = {Pf1[0], Pf0[1], Pf1[2], Pf1[3]}; float n1011 = glm_vec4_dot(g1011, n1011d); /* n0111 = dot(g0111, vec4(Pf0.x, Pf1.y, Pf1.z, Pf1.w)) */ vec4 n0111d = {Pf0[0], Pf1[1], Pf1[2], Pf1[3]}; float n0111 = glm_vec4_dot(g0111, n0111d); float n1111 = glm_vec4_dot(g1111, Pf1); /* n1111 = dot(g1111, Pf1) */ /* ------------ */ vec4 fade_xyzw; glm__noiseDetail_fade_vec4(Pf0, fade_xyzw); /* fade_xyzw = fade(Pf0) */ /* n_0w = lerp(vec4(n0000, n1000, n0100, n1100), vec4(n0001, n1001, n0101, n1101), fade_xyzw.w) */ vec4 n_0w1 = {n0000, n1000, n0100, n1100}; vec4 n_0w2 = {n0001, n1001, n0101, n1101}; vec4 n_0w; glm_vec4_lerp(n_0w1, n_0w2, fade_xyzw[3], n_0w); /* n_1w = lerp(vec4(n0010, n1010, n0110, n1110), vec4(n0011, n1011, n0111, n1111), fade_xyzw.w) */ vec4 n_1w1 = {n0010, n1010, n0110, n1110}; vec4 n_1w2 = {n0011, n1011, n0111, n1111}; vec4 n_1w; glm_vec4_lerp(n_1w1, n_1w2, fade_xyzw[3], n_1w); /* n_zw = lerp(n_0w, n_1w, fade_xyzw.z) */ vec4 n_zw; glm_vec4_lerp(n_0w, n_1w, fade_xyzw[2], n_zw); /* n_yzw = lerp(vec2(n_zw.x, n_zw.y), vec2(n_zw.z, n_zw.w), fade_xyzw.y) */ vec2 n_yzw; vec2 n_yzw1 = {n_zw[0], n_zw[1]}; vec2 n_yzw2 = {n_zw[2], n_zw[3]}; glm_vec2_lerp(n_yzw1, n_yzw2, fade_xyzw[1], n_yzw); /* n_xyzw = lerp(n_yzw.x, n_yzw.y, fade_xyzw.x) */ float n_xyzw = glm_lerp(n_yzw[0], n_yzw[1], fade_xyzw[0]); return n_xyzw * 2.2f; } /*! * @brief Classic perlin noise * * @param[in] point 3D vector * @returns perlin noise value */ CGLM_INLINE float glm_perlin_vec3(vec3 point) { /* Integer part of p for indexing */ vec3 Pi0; glm_vec3_floor(point, Pi0); /* Pi0 = floor(point); */ /* Integer part + 1 */ vec3 Pi1; glm_vec3_adds(Pi0, 1.0f, Pi1); /* Pi1 = Pi0 + 1.0f; */ glm_vec3_mods(Pi0, 289.0f, Pi0); /* Pi0 = mod(Pi0, 289.0f); */ glm_vec3_mods(Pi1, 289.0f, Pi1); /* Pi1 = mod(Pi1, 289.0f); */ /* Fractional part of p for interpolation */ vec3 Pf0; glm_vec3_fract(point, Pf0); /* Fractional part - 1.0 */ vec3 Pf1; glm_vec3_subs(Pf0, 1.0f, Pf1); vec4 ix = {Pi0[0], Pi1[0], Pi0[0], Pi1[0]}; vec4 iy = {Pi0[1], Pi0[1], Pi1[1], Pi1[1]}; vec4 iz0 = {Pi0[2], Pi0[2], Pi0[2], Pi0[2]}; /* iz0 = vec4(Pi0.z); */ vec4 iz1 = {Pi1[2], Pi1[2], Pi1[2], Pi1[2]}; /* iz1 = vec4(Pi1.z); */ /* ------------ */ /* ixy = permute(permute(ix) + iy) */ vec4 ixy; glm__noiseDetail_permute(ix, ixy); /* ixy = permute(ix) */ glm_vec4_add(ixy, iy, ixy); /* ixy += iy; */ glm__noiseDetail_permute(ixy, ixy); /* ixy = permute(ixy) */ /* ixy0 = permute(ixy + iz0) */ vec4 ixy0; glm_vec4_add(ixy, iz0, ixy0); /* ixy0 = ixy + iz0 */ glm__noiseDetail_permute(ixy0, ixy0); /* ixy0 = permute(ixy0) */ /* ixy1 = permute(ixy + iz1) */ vec4 ixy1; glm_vec4_add(ixy, iz1, ixy1); /* ixy1 = ixy, iz1 */ glm__noiseDetail_permute(ixy1, ixy1); /* ixy1 = permute(ixy1) */ /* ------------ */ vec4 gx0, gy0, gz0; glm__noiseDetail_i2gxyz(ixy0, gx0, gy0, gz0); vec4 gx1, gy1, gz1; glm__noiseDetail_i2gxyz(ixy1, gx1, gy1, gz1); /* ------------ */ vec3 g000 = {gx0[0], gy0[0], gz0[0]}; /* g000 = vec3(gx0.x, gy0.x, gz0.x); */ vec3 g100 = {gx0[1], gy0[1], gz0[1]}; /* g100 = vec3(gx0.y, gy0.y, gz0.y); */ vec3 g010 = {gx0[2], gy0[2], gz0[2]}; /* g010 = vec3(gx0.z, gy0.z, gz0.z); */ vec3 g110 = {gx0[3], gy0[3], gz0[3]}; /* g110 = vec3(gx0.w, gy0.w, gz0.w); */ vec3 g001 = {gx1[0], gy1[0], gz1[0]}; /* g001 = vec3(gx1.x, gy1.x, gz1.x); */ vec3 g101 = {gx1[1], gy1[1], gz1[1]}; /* g101 = vec3(gx1.y, gy1.y, gz1.y); */ vec3 g011 = {gx1[2], gy1[2], gz1[2]}; /* g011 = vec3(gx1.z, gy1.z, gz1.z); */ vec3 g111 = {gx1[3], gy1[3], gz1[3]}; /* g111 = vec3(gx1.w, gy1.w, gz1.w); */ glm__noiseDetail_gradNorm_vec3(g000, g010, g100, g110); glm__noiseDetail_gradNorm_vec3(g001, g011, g101, g111); /* ------------ */ float n000 = glm_vec3_dot(g000, Pf0); /* n000 = dot(g000, Pf0) */ /* n100 = dot(g100, vec3(Pf1.x, Pf0.y, Pf0.z)) */ vec3 n100d = {Pf1[0], Pf0[1], Pf0[2]}; float n100 = glm_vec3_dot(g100, n100d); /* n010 = dot(g010, vec3(Pf0.x, Pf1.y, Pf0.z)) */ vec3 n010d = {Pf0[0], Pf1[1], Pf0[2]}; float n010 = glm_vec3_dot(g010, n010d); /* n110 = dot(g110, vec3(Pf1.x, Pf1.y, Pf0.z)) */ vec3 n110d = {Pf1[0], Pf1[1], Pf0[2]}; float n110 = glm_vec3_dot(g110, n110d); /* n001 = dot(g001, vec3(Pf0.x, Pf0.y, Pf1.z)) */ vec3 n001d = {Pf0[0], Pf0[1], Pf1[2]}; float n001 = glm_vec3_dot(g001, n001d); /* n101 = dot(g101, vec3(Pf1.x, Pf0.y, Pf1.z)) */ vec3 n101d = {Pf1[0], Pf0[1], Pf1[2]}; float n101 = glm_vec3_dot(g101, n101d); /* n011 = dot(g011, vec3(Pf0.x, Pf1.y, Pf1.z)) */ vec3 n011d = {Pf0[0], Pf1[1], Pf1[2]}; float n011 = glm_vec3_dot(g011, n011d); float n111 = glm_vec3_dot(g111, Pf1); /* n111 = dot(g111, Pf1) */ /* ------------ */ vec3 fade_xyz; glm__noiseDetail_fade_vec3(Pf0, fade_xyz); /* fade_xyz = fade(Pf0) */ /* n_z = lerp(vec4(n000, n100, n010, n110), vec4(n001, n101, n011, n111), fade_xyz.z); */ vec4 n_z; vec4 n_z1 = {n000, n100, n010, n110}; vec4 n_z2 = {n001, n101, n011, n111}; glm_vec4_lerp(n_z1, n_z2, fade_xyz[2], n_z); /* vec2 n_yz = lerp(vec2(n_z.x, n_z.y), vec2(n_z.z, n_z.w), fade_xyz.y); */ vec2 n_yz; vec2 n_yz1 = {n_z[0], n_z[1]}; vec2 n_yz2 = {n_z[2], n_z[3]}; glm_vec2_lerp(n_yz1, n_yz2, fade_xyz[1], n_yz); /* n_xyz = lerp(n_yz.x, n_yz.y, fade_xyz.x); */ float n_xyz = glm_lerp(n_yz[0], n_yz[1], fade_xyz[0]); return n_xyz * 2.2f; } /*! * @brief Classic perlin noise * * @param[in] point 2D vector * @returns perlin noise value */ CGLM_INLINE float glm_perlin_vec2(vec2 point) { /* Integer part of p for indexing */ /* Pi = floor(vec4(point.x, point.y, point.x, point.y)) + vec4(0.0, 0.0, 1.0, 1.0); */ vec4 Pi = {point[0], point[1], point[0], point[1]}; /* Pi = vec4(point.x, point.y, point.x, point.y) */ glm_vec4_floor(Pi, Pi); /* Pi = floor(Pi) */ Pi[2] += 1.0f; /* Pi.z += 1.0 */ Pi[3] += 1.0f; /* Pi.w += 1.0 */ /* Fractional part of p for interpolation */ /* vec<4, T, Q> Pf = glm::fract(vec<4, T, Q>(Position.x, Position.y, Position.x, Position.y)) - vec<4, T, Q>(0.0, 0.0, 1.0, 1.0); */ vec4 Pf = {point[0], point[1], point[0], point[1]}; /* Pf = vec4(point.x, point.y, point.x, point.y) */ glm_vec4_fract(Pf, Pf); /* Pf = fract(Pf) */ Pf[2] -= 1.0f; /* Pf.z -= 1.0 */ Pf[3] -= 1.0f; /* Pf.w -= 1.0 */ /* Mod to avoid truncation effects in permutation */ glm_vec4_mods(Pi, 289.0f, Pi); /* Pi = mod(Pi, 289.0f); */ vec4 ix = {Pi[0], Pi[2], Pi[0], Pi[2]}; /* ix = vec4(Pi.x, Pi.z, Pi.x, Pi.z) */ vec4 iy = {Pi[1], Pi[1], Pi[3], Pi[3]}; /* iy = vec4(Pi.y, Pi.y, Pi.w, Pi.w) */ vec4 fx = {Pf[0], Pf[2], Pf[0], Pf[2]}; /* fx = vec4(Pf.x, Pf.z, Pf.x, Pf.z) */ vec4 fy = {Pf[1], Pf[1], Pf[3], Pf[3]}; /* fy = vec4(Pf.y, Pf.y, Pf.w, Pf.w) */ /* ------------ */ /* i = permute(permute(ix) + iy); */ vec4 i; glm__noiseDetail_permute(ix, i); /* i = permute(ix) */ glm_vec4_add(i, iy, i); /* i += iy; */ glm__noiseDetail_permute(i, i); /* i = permute(i) */ /* ------------ */ vec4 gx, gy; glm__noiseDetail_i2gxy(i, gx, gy); /* ------------ */ vec2 g00 = {gx[0], gy[0]}; /* g00 = vec2(gx.x, gy.x) */ vec2 g10 = {gx[1], gy[1]}; /* g10 = vec2(gx.y, gy.y) */ vec2 g01 = {gx[2], gy[2]}; /* g01 = vec2(gx.z, gy.z) */ vec2 g11 = {gx[3], gy[3]}; /* g11 = vec2(gx.w, gy.w) */ glm__noiseDetail_gradNorm_vec2(g00, g01, g10, g11); /* ------------ */ /* n00 = dot(g00, vec2(fx.x, fy.x)) */ vec2 n00d = {fx[0], fy[0]}; /* n00d = vec2(fx.x, fy.x) */ float n00 = glm_vec2_dot(g00, n00d); /* n00 = dot(g00, n00d) */ /* n10 = dot(g10, vec2(fx.y, fy.y)) */ vec2 n10d = {fx[1], fy[1]}; /* n10d = vec2(fx.y, fy.y) */ float n10 = glm_vec2_dot(g10, n10d); /* n10 = dot(g10, n10d) */ /* n01 = dot(g01, vec2(fx.z, fy.z)) */ vec2 n01d = {fx[2], fy[2]}; /* n01d = vec2(fx.z, fy.z) */ float n01 = glm_vec2_dot(g01, n01d); /* n01 = dot(g01, n01d) */ /* n11 = dot(g11, vec2(fx.w, fy.w)) */ vec2 n11d = {fx[3], fy[3]}; /* n11d = vec2(fx.w, fy.w) */ float n11 = glm_vec2_dot(g11, n11d); /* n11 = dot(g11, n11d) */ /* ------------ */ /* fade_xyz = fade(vec2(Pf.x, Pf.y)) */ vec2 fade_xy; vec2 temp2 = {Pf[0], Pf[1]}; /* temp = vec2(Pf.x, Pf.y) */ glm__noiseDetail_fade_vec2(temp2, fade_xy); /* fade_xy = fade(temp) */ /* n_x = lerp(vec2(n00, n01), vec2(n10, n11), fade_xy.x); */ vec2 n_x; vec2 n_x1 = {n00, n01}; /* n_x1 = vec2(n00, n01) */ vec2 n_x2 = {n10, n11}; /* n_x2 = vec2(n10, n11) */ glm_vec2_lerp(n_x1, n_x2, fade_xy[0], n_x); /* n_x = lerp(n_x1, n_x2, fade_xy.x) */ /* T n_xy = mix(n_x.x, n_x.y, fade_xy.y); */ /* n_xy = lerp(n_x.x, n_x.y, fade_xy.y); */ float n_xy = glm_lerp(n_x[0], n_x[1], fade_xy[1]); return n_xy * 2.3f; } /* Undefine all helper macros */ #undef glm__noiseDetail_mod289 #undef glm__noiseDetail_permute #undef glm__noiseDetail_fade_vec4 #undef glm__noiseDetail_fade_vec3 #undef glm__noiseDetail_fade_vec2 #undef glm__noiseDetail_taylorInvSqrt #undef glm__noiseDetail_gradNorm_vec4 #undef glm__noiseDetail_gradNorm_vec3 #undef glm__noiseDetail_gradNorm_vec2 #undef glm__noiseDetail_i2gxyzw #undef glm__noiseDetail_i2gxyz #undef glm__noiseDetail_i2gxy #endif /* cglm_noise_h */ cglm-0.9.6/include/cglm/plane.h000066400000000000000000000014221475344456400163040ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ #ifndef cglm_plane_h #define cglm_plane_h #include "common.h" #include "vec3.h" #include "vec4.h" /* Plane equation: Ax + By + Cz + D = 0; It stored in vec4 as [A, B, C, D]. (A, B, C) is normal and D is distance */ /* Functions: CGLM_INLINE void glm_plane_normalize(vec4 plane); */ /*! * @brief normalizes a plane * * @param[in, out] plane plane to normalize */ CGLM_INLINE void glm_plane_normalize(vec4 plane) { float norm; if (CGLM_UNLIKELY((norm = glm_vec3_norm(plane)) < FLT_EPSILON)) { glm_vec4_zero(plane); return; } glm_vec4_scale(plane, 1.0f / norm, plane); } #endif /* cglm_plane_h */ cglm-0.9.6/include/cglm/project.h000066400000000000000000000111761475344456400166620ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ #ifndef cglm_project_h #define cglm_project_h #include "common.h" #include "vec3.h" #include "vec4.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] * the matrix should contain projection matrix. * * if you don't have ( and don't want to have ) an inverse matrix then use * glm_unproject version. You may use existing inverse of matrix in somewhere * else, this is why glm_unprojecti exists to save save inversion cost * * [1] space: * 1- if m = invProj: View Space * 2- if m = invViewProj: World Space * 3- if m = invMVP: Object Space * * You probably want to map the coordinates into object space * so use invMVP as m * * Computing viewProj: * glm_mat4_mul(proj, view, viewProj); * glm_mat4_mul(viewProj, model, MVP); * glm_mat4_inv(viewProj, invMVP); * * @param[in] pos point/position in viewport coordinates * @param[in] invMat matrix (see brief) * @param[in] vp viewport as [x, y, width, height] * @param[out] dest unprojected coordinates */ CGLM_INLINE void glm_unprojecti(vec3 pos, mat4 invMat, vec4 vp, vec3 dest) { #if CGLM_CONFIG_CLIP_CONTROL & CGLM_CLIP_CONTROL_ZO_BIT glm_unprojecti_zo(pos, invMat, vp, dest); #elif CGLM_CONFIG_CLIP_CONTROL & CGLM_CLIP_CONTROL_NO_BIT glm_unprojecti_no(pos, invMat, vp, dest); #endif } /*! * @brief maps the specified viewport coordinates into specified space [1] * the matrix should contain projection matrix. * * this is same as glm_unprojecti except this function get inverse matrix for * you. * * [1] space: * 1- if m = proj: View Space * 2- if m = viewProj: World Space * 3- if m = MVP: Object Space * * You probably want to map the coordinates into object space * so use MVP as m * * Computing viewProj and MVP: * glm_mat4_mul(proj, view, viewProj); * glm_mat4_mul(viewProj, model, MVP); * * @param[in] pos point/position in viewport coordinates * @param[in] m matrix (see brief) * @param[in] vp viewport as [x, y, width, height] * @param[out] dest unprojected coordinates */ CGLM_INLINE void glm_unproject(vec3 pos, mat4 m, vec4 vp, vec3 dest) { mat4 inv; glm_mat4_inv(m, inv); glm_unprojecti(pos, inv, vp, dest); } /*! * @brief map object coordinates to window coordinates * * Computing MVP: * glm_mat4_mul(proj, view, viewProj); * glm_mat4_mul(viewProj, model, MVP); * * @param[in] pos object coordinates * @param[in] m MVP matrix * @param[in] vp viewport as [x, y, width, height] * @param[out] dest projected coordinates */ CGLM_INLINE void glm_project(vec3 pos, mat4 m, vec4 vp, vec3 dest) { #if CGLM_CONFIG_CLIP_CONTROL & CGLM_CLIP_CONTROL_ZO_BIT glm_project_zo(pos, m, vp, dest); #elif CGLM_CONFIG_CLIP_CONTROL & CGLM_CLIP_CONTROL_NO_BIT glm_project_no(pos, m, vp, dest); #endif } /*! * @brief map object's z coordinate to window coordinates * * Computing MVP: * glm_mat4_mul(proj, view, viewProj); * glm_mat4_mul(viewProj, model, MVP); * * @param[in] v object coordinates * @param[in] m MVP matrix * * @returns projected z coordinate */ CGLM_INLINE float glm_project_z(vec3 v, mat4 m) { #if CGLM_CONFIG_CLIP_CONTROL & CGLM_CLIP_CONTROL_ZO_BIT return glm_project_z_zo(v, m); #elif CGLM_CONFIG_CLIP_CONTROL & CGLM_CLIP_CONTROL_NO_BIT return glm_project_z_no(v, m); #endif } /*! * @brief define a picking region * * @param[in] center center [x, y] of a picking region in window coordinates * @param[in] size size [width, height] of the picking region in window coordinates * @param[in] vp viewport as [x, y, width, height] * @param[out] dest projected coordinates */ CGLM_INLINE void glm_pickmatrix(vec2 center, vec2 size, vec4 vp, mat4 dest) { mat4 res; vec3 v; if (size[0] <= 0.0f || size[1] <= 0.0f) return; /* Translate and scale the picked region to the entire window */ v[0] = (vp[2] - 2.0f * (center[0] - vp[0])) / size[0]; v[1] = (vp[3] - 2.0f * (center[1] - vp[1])) / size[1]; v[2] = 0.0f; glm_translate_make(res, v); v[0] = vp[2] / size[0]; v[1] = vp[3] / size[1]; v[2] = 1.0f; glm_scale(res, v); glm_mat4_copy(res, dest); } #endif /* cglm_project_h */ cglm-0.9.6/include/cglm/quat.h000066400000000000000000000526701475344456400161720ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ /* Macros: GLM_QUAT_IDENTITY_INIT GLM_QUAT_IDENTITY Functions: CGLM_INLINE void glm_quat_identity(versor q); CGLM_INLINE void glm_quat_init(versor q, float x, float y, float z, float w); CGLM_INLINE void glm_quat(versor q, float angle, float x, float y, float z); CGLM_INLINE void glm_quatv(versor q, float angle, vec3 axis); CGLM_INLINE void glm_quat_copy(versor q, versor dest); CGLM_INLINE void glm_quat_from_vecs(vec3 a, vec3 b, versor dest); CGLM_INLINE float glm_quat_norm(versor q); CGLM_INLINE void glm_quat_normalize(versor q); CGLM_INLINE void glm_quat_normalize_to(versor q, versor dest); CGLM_INLINE float glm_quat_dot(versor p, versor q); CGLM_INLINE void glm_quat_conjugate(versor q, versor dest); CGLM_INLINE void glm_quat_inv(versor q, versor dest); CGLM_INLINE void glm_quat_add(versor p, versor q, versor dest); CGLM_INLINE void glm_quat_sub(versor p, versor q, versor dest); CGLM_INLINE float glm_quat_real(versor q); CGLM_INLINE void glm_quat_imag(versor q, vec3 dest); CGLM_INLINE void glm_quat_imagn(versor q, vec3 dest); CGLM_INLINE float glm_quat_imaglen(versor q); CGLM_INLINE float glm_quat_angle(versor q); CGLM_INLINE void glm_quat_axis(versor q, vec3 dest); CGLM_INLINE void glm_quat_mul(versor p, versor q, versor dest); CGLM_INLINE void glm_quat_mat4(versor q, mat4 dest); CGLM_INLINE void glm_quat_mat4t(versor q, mat4 dest); CGLM_INLINE void glm_quat_mat3(versor q, mat3 dest); CGLM_INLINE void glm_quat_mat3t(versor q, mat3 dest); CGLM_INLINE void glm_quat_lerp(versor from, versor to, float t, versor dest); CGLM_INLINE void glm_quat_lerpc(versor from, versor to, float t, versor dest); CGLM_INLINE void glm_quat_slerp(versor q, versor r, float t, versor dest); CGLM_INLINE void glm_quat_slerp_longest(versor q, versor r, float t, versor dest); CGLM_INLINE void glm_quat_nlerp(versor q, versor r, float t, versor dest); CGLM_INLINE void glm_quat_look(vec3 eye, versor ori, mat4 dest); CGLM_INLINE void glm_quat_for(vec3 dir, vec3 fwd, vec3 up, versor dest); CGLM_INLINE void glm_quat_forp(vec3 from, vec3 to, vec3 fwd, vec3 up, versor dest); CGLM_INLINE void glm_quat_rotatev(versor q, vec3 v, vec3 dest); CGLM_INLINE void glm_quat_rotate(mat4 m, versor q, mat4 dest); CGLM_INLINE void glm_quat_make(float * restrict src, versor dest); */ #ifndef cglm_quat_h #define cglm_quat_h #include "common.h" #include "vec3.h" #include "vec4.h" #include "mat4.h" #include "mat3.h" #include "affine-mat.h" #include "affine.h" #ifdef CGLM_SSE_FP # include "simd/sse2/quat.h" #endif #ifdef CGLM_NEON_FP # include "simd/neon/quat.h" #endif #ifdef CGLM_SIMD_WASM # include "simd/wasm/quat.h" #endif CGLM_INLINE void glm_quat_normalize(versor q); /* * IMPORTANT: * ---------------------------------------------------------------------------- * cglm stores quat as [x, y, z, w] since v0.3.6 * * it was [w, x, y, z] before v0.3.6 it has been changed to [x, y, z, w] * with v0.3.6 version. * ---------------------------------------------------------------------------- */ #define GLM_QUAT_IDENTITY_INIT {0.0f, 0.0f, 0.0f, 1.0f} #define GLM_QUAT_IDENTITY ((versor)GLM_QUAT_IDENTITY_INIT) /*! * @brief makes given quat to identity * * @param[in, out] q quaternion */ CGLM_INLINE void glm_quat_identity(versor q) { CGLM_ALIGN(16) versor v = GLM_QUAT_IDENTITY_INIT; glm_vec4_copy(v, q); } /*! * @brief make given quaternion array's each element identity quaternion * * @param[in, out] q quat array (must be aligned (16) * if alignment is not disabled) * * @param[in] count count of quaternions */ CGLM_INLINE void glm_quat_identity_array(versor * __restrict q, size_t count) { CGLM_ALIGN(16) versor v = GLM_QUAT_IDENTITY_INIT; size_t i; for (i = 0; i < count; i++) { glm_vec4_copy(v, q[i]); } } /*! * @brief inits quaternion with raw values * * @param[out] q quaternion * @param[in] x x * @param[in] y y * @param[in] z z * @param[in] w w (real part) */ CGLM_INLINE void glm_quat_init(versor q, float x, float y, float z, float w) { q[0] = x; q[1] = y; q[2] = z; q[3] = w; } /*! * @brief creates NEW quaternion with axis vector * * @param[out] q quaternion * @param[in] angle angle (radians) * @param[in] axis axis */ CGLM_INLINE void glm_quatv(versor q, float angle, vec3 axis) { CGLM_ALIGN(8) vec3 k; float a, c, s; a = angle * 0.5f; c = cosf(a); s = sinf(a); glm_normalize_to(axis, k); q[0] = s * k[0]; q[1] = s * k[1]; q[2] = s * k[2]; q[3] = c; } /*! * @brief creates NEW quaternion with individual axis components * * @param[out] q quaternion * @param[in] angle angle (radians) * @param[in] x axis.x * @param[in] y axis.y * @param[in] z axis.z */ CGLM_INLINE void glm_quat(versor q, float angle, float x, float y, float z) { CGLM_ALIGN(8) vec3 axis = {x, y, z}; glm_quatv(q, angle, axis); } /*! * @brief copy quaternion to another one * * @param[in] q quaternion * @param[out] dest destination */ CGLM_INLINE void glm_quat_copy(versor q, versor dest) { glm_vec4_copy(q, dest); } /*! * @brief compute quaternion rotating vector A to vector B * * @param[in] a vec3 (must have unit length) * @param[in] b vec3 (must have unit length) * @param[out] dest quaternion (of unit length) */ CGLM_INLINE void glm_quat_from_vecs(vec3 a, vec3 b, versor dest) { CGLM_ALIGN(8) vec3 axis; float cos_theta; float cos_half_theta; cos_theta = glm_vec3_dot(a, b); if (cos_theta >= 1.f - GLM_FLT_EPSILON) { /* a ∥ b */ glm_quat_identity(dest); return; } if (cos_theta < -1.f + GLM_FLT_EPSILON) { /* angle(a, b) = π */ glm_vec3_ortho(a, axis); cos_half_theta = 0.f; /* cos π/2 */ } else { glm_vec3_cross(a, b, axis); cos_half_theta = 1.0f + cos_theta; /* cos 0 + cos θ */ } glm_quat_init(dest, axis[0], axis[1], axis[2], cos_half_theta); glm_quat_normalize(dest); } /*! * @brief returns norm (magnitude) of quaternion * * @param[in] q quaternion */ CGLM_INLINE float glm_quat_norm(versor q) { return glm_vec4_norm(q); } /*! * @brief normalize quaternion and store result in dest * * @param[in] q quaternion to normalze * @param[out] dest destination quaternion */ CGLM_INLINE void glm_quat_normalize_to(versor q, versor dest) { #if defined(__wasm__) && defined(__wasm_simd128__) glmm_128 xdot, x0; float dot; x0 = glmm_load(q); xdot = glmm_vdot(x0, x0); /* dot = _mm_cvtss_f32(xdot); */ dot = wasm_f32x4_extract_lane(xdot, 0); if (dot <= 0.0f) { glm_quat_identity(dest); return; } glmm_store(dest, wasm_f32x4_div(x0, wasm_f32x4_sqrt(xdot))); #elif defined( __SSE__ ) || defined( __SSE2__ ) __m128 xdot, x0; float dot; x0 = glmm_load(q); xdot = glmm_vdot(x0, x0); dot = _mm_cvtss_f32(xdot); if (dot <= 0.0f) { glm_quat_identity(dest); return; } glmm_store(dest, _mm_div_ps(x0, _mm_sqrt_ps(xdot))); #else float dot; dot = glm_vec4_norm2(q); if (dot <= 0.0f) { glm_quat_identity(dest); return; } glm_vec4_scale(q, 1.0f / sqrtf(dot), dest); #endif } /*! * @brief normalize quaternion * * @param[in, out] q quaternion */ CGLM_INLINE void glm_quat_normalize(versor q) { glm_quat_normalize_to(q, q); } /*! * @brief dot product of two quaternion * * @param[in] p quaternion 1 * @param[in] q quaternion 2 */ CGLM_INLINE float glm_quat_dot(versor p, versor q) { return glm_vec4_dot(p, q); } /*! * @brief conjugate of quaternion * * @param[in] q quaternion * @param[out] dest conjugate */ CGLM_INLINE void glm_quat_conjugate(versor q, versor dest) { glm_vec4_negate_to(q, dest); dest[3] = -dest[3]; } /*! * @brief inverse of non-zero quaternion * * @param[in] q quaternion * @param[out] dest inverse quaternion */ CGLM_INLINE void glm_quat_inv(versor q, versor dest) { CGLM_ALIGN(16) versor conj; glm_quat_conjugate(q, conj); glm_vec4_scale(conj, 1.0f / glm_vec4_norm2(q), dest); } /*! * @brief add (componentwise) two quaternions and store result in dest * * @param[in] p quaternion 1 * @param[in] q quaternion 2 * @param[out] dest result quaternion */ CGLM_INLINE void glm_quat_add(versor p, versor q, versor dest) { glm_vec4_add(p, q, dest); } /*! * @brief subtract (componentwise) two quaternions and store result in dest * * @param[in] p quaternion 1 * @param[in] q quaternion 2 * @param[out] dest result quaternion */ CGLM_INLINE void glm_quat_sub(versor p, versor q, versor dest) { glm_vec4_sub(p, q, dest); } /*! * @brief returns real part of quaternion * * @param[in] q quaternion */ CGLM_INLINE float glm_quat_real(versor q) { return q[3]; } /*! * @brief returns imaginary part of quaternion * * @param[in] q quaternion * @param[out] dest imag */ CGLM_INLINE void glm_quat_imag(versor q, vec3 dest) { dest[0] = q[0]; dest[1] = q[1]; dest[2] = q[2]; } /*! * @brief returns normalized imaginary part of quaternion * * @param[in] q quaternion */ CGLM_INLINE void glm_quat_imagn(versor q, vec3 dest) { glm_normalize_to(q, dest); } /*! * @brief returns length of imaginary part of quaternion * * @param[in] q quaternion */ CGLM_INLINE float glm_quat_imaglen(versor q) { return glm_vec3_norm(q); } /*! * @brief returns angle of quaternion * * @param[in] q quaternion */ CGLM_INLINE float glm_quat_angle(versor q) { /* sin(theta / 2) = length(x*x + y*y + z*z) cos(theta / 2) = w theta = 2 * atan(sin(theta / 2) / cos(theta / 2)) */ return 2.0f * atan2f(glm_quat_imaglen(q), glm_quat_real(q)); } /*! * @brief axis of quaternion * * @param[in] q quaternion * @param[out] dest axis of quaternion */ CGLM_INLINE void glm_quat_axis(versor q, vec3 dest) { glm_quat_imagn(q, dest); } /*! * @brief multiplies two quaternion and stores result in dest * this is also called Hamilton Product * * According to WikiPedia: * The product of two rotation quaternions [clarification needed] will be * equivalent to the rotation q followed by the rotation p * * @param[in] p quaternion 1 * @param[in] q quaternion 2 * @param[out] dest result quaternion */ CGLM_INLINE void glm_quat_mul(versor p, versor q, versor dest) { /* + (a1 b2 + b1 a2 + c1 d2 − d1 c2)i + (a1 c2 − b1 d2 + c1 a2 + d1 b2)j + (a1 d2 + b1 c2 − c1 b2 + d1 a2)k a1 a2 − b1 b2 − c1 c2 − d1 d2 */ #if defined(__wasm__) && defined(__wasm_simd128__) glm_quat_mul_wasm(p, q, dest); #elif defined( __SSE__ ) || defined( __SSE2__ ) glm_quat_mul_sse2(p, q, dest); #elif defined(CGLM_NEON_FP) glm_quat_mul_neon(p, q, dest); #else dest[0] = p[3] * q[0] + p[0] * q[3] + p[1] * q[2] - p[2] * q[1]; dest[1] = p[3] * q[1] - p[0] * q[2] + p[1] * q[3] + p[2] * q[0]; dest[2] = p[3] * q[2] + p[0] * q[1] - p[1] * q[0] + p[2] * q[3]; dest[3] = p[3] * q[3] - p[0] * q[0] - p[1] * q[1] - p[2] * q[2]; #endif } /*! * @brief convert quaternion to mat4 * * @param[in] q quaternion * @param[out] dest result matrix */ CGLM_INLINE void glm_quat_mat4(versor q, mat4 dest) { float w, x, y, z, xx, yy, zz, xy, yz, xz, wx, wy, wz, norm, s; norm = glm_quat_norm(q); s = norm > 0.0f ? 2.0f / norm : 0.0f; x = q[0]; y = q[1]; z = q[2]; w = q[3]; xx = s * x * x; xy = s * x * y; wx = s * w * x; yy = s * y * y; yz = s * y * z; wy = s * w * y; zz = s * z * z; xz = s * x * z; wz = s * w * z; dest[0][0] = 1.0f - yy - zz; dest[1][1] = 1.0f - xx - zz; dest[2][2] = 1.0f - xx - yy; dest[0][1] = xy + wz; dest[1][2] = yz + wx; dest[2][0] = xz + wy; dest[1][0] = xy - wz; dest[2][1] = yz - wx; dest[0][2] = xz - wy; dest[0][3] = 0.0f; dest[1][3] = 0.0f; dest[2][3] = 0.0f; dest[3][0] = 0.0f; dest[3][1] = 0.0f; dest[3][2] = 0.0f; dest[3][3] = 1.0f; } /*! * @brief convert quaternion to mat4 (transposed) * * @param[in] q quaternion * @param[out] dest result matrix as transposed */ CGLM_INLINE void glm_quat_mat4t(versor q, mat4 dest) { float w, x, y, z, xx, yy, zz, xy, yz, xz, wx, wy, wz, norm, s; norm = glm_quat_norm(q); s = norm > 0.0f ? 2.0f / norm : 0.0f; x = q[0]; y = q[1]; z = q[2]; w = q[3]; xx = s * x * x; xy = s * x * y; wx = s * w * x; yy = s * y * y; yz = s * y * z; wy = s * w * y; zz = s * z * z; xz = s * x * z; wz = s * w * z; dest[0][0] = 1.0f - yy - zz; dest[1][1] = 1.0f - xx - zz; dest[2][2] = 1.0f - xx - yy; dest[1][0] = xy + wz; dest[2][1] = yz + wx; dest[0][2] = xz + wy; dest[0][1] = xy - wz; dest[1][2] = yz - wx; dest[2][0] = xz - wy; dest[0][3] = 0.0f; dest[1][3] = 0.0f; dest[2][3] = 0.0f; dest[3][0] = 0.0f; dest[3][1] = 0.0f; dest[3][2] = 0.0f; dest[3][3] = 1.0f; } /*! * @brief convert quaternion to mat3 * * @param[in] q quaternion * @param[out] dest result matrix */ CGLM_INLINE void glm_quat_mat3(versor q, mat3 dest) { float w, x, y, z, xx, yy, zz, xy, yz, xz, wx, wy, wz, norm, s; norm = glm_quat_norm(q); s = norm > 0.0f ? 2.0f / norm : 0.0f; x = q[0]; y = q[1]; z = q[2]; w = q[3]; xx = s * x * x; xy = s * x * y; wx = s * w * x; yy = s * y * y; yz = s * y * z; wy = s * w * y; zz = s * z * z; xz = s * x * z; wz = s * w * z; dest[0][0] = 1.0f - yy - zz; dest[1][1] = 1.0f - xx - zz; dest[2][2] = 1.0f - xx - yy; dest[0][1] = xy + wz; dest[1][2] = yz + wx; dest[2][0] = xz + wy; dest[1][0] = xy - wz; dest[2][1] = yz - wx; dest[0][2] = xz - wy; } /*! * @brief convert quaternion to mat3 (transposed) * * @param[in] q quaternion * @param[out] dest result matrix */ CGLM_INLINE void glm_quat_mat3t(versor q, mat3 dest) { float w, x, y, z, xx, yy, zz, xy, yz, xz, wx, wy, wz, norm, s; norm = glm_quat_norm(q); s = norm > 0.0f ? 2.0f / norm : 0.0f; x = q[0]; y = q[1]; z = q[2]; w = q[3]; xx = s * x * x; xy = s * x * y; wx = s * w * x; yy = s * y * y; yz = s * y * z; wy = s * w * y; zz = s * z * z; xz = s * x * z; wz = s * w * z; dest[0][0] = 1.0f - yy - zz; dest[1][1] = 1.0f - xx - zz; dest[2][2] = 1.0f - xx - yy; dest[1][0] = xy + wz; dest[2][1] = yz + wx; dest[0][2] = xz + wy; dest[0][1] = xy - wz; dest[1][2] = yz - wx; dest[2][0] = xz - wy; } /*! * @brief interpolates between two quaternions * using linear interpolation (LERP) * * @param[in] from from * @param[in] to to * @param[in] t interpolant (amount) * @param[out] dest result quaternion */ CGLM_INLINE void glm_quat_lerp(versor from, versor to, float t, versor dest) { glm_vec4_lerp(from, to, t, dest); } /*! * @brief interpolates between two quaternions * using linear interpolation (LERP) * * @param[in] from from * @param[in] to to * @param[in] t interpolant (amount) clamped between 0 and 1 * @param[out] dest result quaternion */ CGLM_INLINE void glm_quat_lerpc(versor from, versor to, float t, versor dest) { glm_vec4_lerpc(from, to, t, dest); } /*! * @brief interpolates between two quaternions * taking the shortest rotation path using * normalized linear interpolation (NLERP) * * @param[in] from from * @param[in] to to * @param[in] t interpolant (amount) * @param[out] dest result quaternion */ CGLM_INLINE void glm_quat_nlerp(versor from, versor to, float t, versor dest) { versor target; float dot; dot = glm_vec4_dot(from, to); glm_vec4_scale(to, (dot >= 0) ? 1.0f : -1.0f, target); glm_quat_lerp(from, target, t, dest); glm_quat_normalize(dest); } /*! * @brief interpolates between two quaternions * using spherical linear interpolation (SLERP) * * @param[in] from from * @param[in] to to * @param[in] t amount * @param[out] dest result quaternion */ CGLM_INLINE void glm_quat_slerp(versor from, versor to, float t, versor dest) { CGLM_ALIGN(16) vec4 q1, q2; float cosTheta, sinTheta, angle; cosTheta = glm_quat_dot(from, to); glm_quat_copy(from, q1); if (fabsf(cosTheta) >= 1.0f) { glm_quat_copy(q1, dest); return; } if (cosTheta < 0.0f) { glm_vec4_negate(q1); cosTheta = -cosTheta; } sinTheta = sqrtf(1.0f - cosTheta * cosTheta); /* LERP to avoid zero division */ if (fabsf(sinTheta) < 0.001f) { glm_quat_lerp(from, to, t, dest); return; } /* SLERP */ angle = acosf(cosTheta); glm_vec4_scale(q1, sinf((1.0f - t) * angle), q1); glm_vec4_scale(to, sinf(t * angle), q2); glm_vec4_add(q1, q2, q1); glm_vec4_scale(q1, 1.0f / sinTheta, dest); } /*! * @brief interpolates between two quaternions * using spherical linear interpolation (SLERP) and always takes the long path * * @param[in] from from * @param[in] to to * @param[in] t amount * @param[out] dest result quaternion */ CGLM_INLINE void glm_quat_slerp_longest(versor from, versor to, float t, versor dest) { CGLM_ALIGN(16) vec4 q1, q2; float cosTheta, sinTheta, angle; cosTheta = glm_quat_dot(from, to); glm_quat_copy(from, q1); if (fabsf(cosTheta) >= 1.0f) { glm_quat_copy(q1, dest); return; } /* longest path */ if (!(cosTheta < 0.0f)) { glm_vec4_negate(q1); cosTheta = -cosTheta; } sinTheta = sqrtf(1.0f - cosTheta * cosTheta); /* LERP to avoid zero division */ if (fabsf(sinTheta) < 0.001f) { glm_quat_lerp(from, to, t, dest); return; } /* SLERP */ angle = acosf(cosTheta); glm_vec4_scale(q1, sinf((1.0f - t) * angle), q1); glm_vec4_scale(to, sinf(t * angle), q2); glm_vec4_add(q1, q2, q1); glm_vec4_scale(q1, 1.0f / sinTheta, dest); } /*! * @brief creates view matrix using quaternion as camera orientation * * @param[in] eye eye * @param[in] ori orientation in world space as quaternion * @param[out] dest view matrix */ CGLM_INLINE void glm_quat_look(vec3 eye, versor ori, mat4 dest) { /* orientation */ glm_quat_mat4t(ori, dest); /* translate */ glm_mat4_mulv3(dest, eye, 1.0f, dest[3]); glm_vec3_negate(dest[3]); } /*! * @brief creates look rotation quaternion * * @param[in] dir direction to look * @param[in] up up vector * @param[out] dest destination quaternion */ CGLM_INLINE void glm_quat_for(vec3 dir, vec3 up, versor dest) { CGLM_ALIGN_MAT mat3 m; glm_vec3_normalize_to(dir, m[2]); /* No need to negate in LH, but we use RH here */ glm_vec3_negate(m[2]); glm_vec3_crossn(up, m[2], m[0]); glm_vec3_cross(m[2], m[0], m[1]); glm_mat3_quat(m, dest); } /*! * @brief creates look rotation quaternion using source and * destination positions p suffix stands for position * * @param[in] from source point * @param[in] to destination point * @param[in] up up vector * @param[out] dest destination quaternion */ CGLM_INLINE void glm_quat_forp(vec3 from, vec3 to, vec3 up, versor dest) { CGLM_ALIGN(8) vec3 dir; glm_vec3_sub(to, from, dir); glm_quat_for(dir, up, dest); } /*! * @brief rotate vector using using quaternion * * @param[in] q quaternion * @param[in] v vector to rotate * @param[out] dest rotated vector */ CGLM_INLINE void glm_quat_rotatev(versor q, vec3 v, vec3 dest) { CGLM_ALIGN(16) versor p; CGLM_ALIGN(8) vec3 u, v1, v2; float s; glm_quat_normalize_to(q, p); glm_quat_imag(p, u); s = glm_quat_real(p); glm_vec3_scale(u, 2.0f * glm_vec3_dot(u, v), v1); glm_vec3_scale(v, s * s - glm_vec3_dot(u, u), v2); glm_vec3_add(v1, v2, v1); glm_vec3_cross(u, v, v2); glm_vec3_scale(v2, 2.0f * s, v2); glm_vec3_add(v1, v2, dest); } /*! * @brief rotate existing transform matrix using quaternion * * @param[in] m existing transform matrix * @param[in] q quaternion * @param[out] dest rotated matrix/transform */ CGLM_INLINE void glm_quat_rotate(mat4 m, versor q, mat4 dest) { CGLM_ALIGN_MAT mat4 rot; glm_quat_mat4(q, rot); glm_mul_rot(m, rot, dest); } /*! * @brief rotate existing transform matrix using quaternion at pivot point * * @param[in, out] m existing transform matrix * @param[in] q quaternion * @param[out] pivot pivot */ CGLM_INLINE void glm_quat_rotate_at(mat4 m, versor q, vec3 pivot) { CGLM_ALIGN(8) vec3 pivotInv; glm_vec3_negate_to(pivot, pivotInv); glm_translate(m, pivot); glm_quat_rotate(m, q, m); glm_translate(m, pivotInv); } /*! * @brief rotate NEW transform matrix using quaternion at pivot point * * this creates rotation matrix, it assumes you don't have a matrix * * this should work faster than glm_quat_rotate_at because it reduces * one glm_translate. * * @param[out] m existing transform matrix * @param[in] q quaternion * @param[in] pivot pivot */ CGLM_INLINE void glm_quat_rotate_atm(mat4 m, versor q, vec3 pivot) { CGLM_ALIGN(8) vec3 pivotInv; glm_vec3_negate_to(pivot, pivotInv); glm_translate_make(m, pivot); glm_quat_rotate(m, q, m); glm_translate(m, pivotInv); } /*! * @brief Create quaternion from pointer * * @param[in] src pointer to an array of floats * @param[out] dest quaternion */ CGLM_INLINE void glm_quat_make(const float * __restrict src, versor dest) { dest[0] = src[0]; dest[1] = src[1]; dest[2] = src[2]; dest[3] = src[3]; } #endif /* cglm_quat_h */ cglm-0.9.6/include/cglm/ray.h000066400000000000000000000107301475344456400160020ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ /* Functions: CGLM_INLINE bool glm_ray_triangle(vec3 origin, vec3 direction, vec3 v0, vec3 v1, vec3 v2, float *d); CGLM_INLINE bool glm_ray_sphere(vec3 origin, vec3 dir, vec4 s, float * __restrict t1, float * __restrict t2) CGLM_INLINE void glm_ray_at(vec3 orig, vec3 dir, float t, vec3 point); */ #ifndef cglm_ray_h #define cglm_ray_h #include "vec3.h" /*! * @brief Möller–Trumbore ray-triangle intersection algorithm * * @param[in] origin origin of ray * @param[in] direction direction of ray * @param[in] v0 first vertex of triangle * @param[in] v1 second vertex of triangle * @param[in] v2 third vertex of triangle * @param[in, out] d distance to intersection * @return whether there is intersection */ CGLM_INLINE bool glm_ray_triangle(vec3 origin, vec3 direction, vec3 v0, vec3 v1, vec3 v2, float *d) { vec3 edge1, edge2, p, t, q; float det, inv_det, u, v, dist; const float epsilon = 0.000001f; glm_vec3_sub(v1, v0, edge1); glm_vec3_sub(v2, v0, edge2); glm_vec3_cross(direction, edge2, p); det = glm_vec3_dot(edge1, p); if (det > -epsilon && det < epsilon) return false; inv_det = 1.0f / det; glm_vec3_sub(origin, v0, t); u = inv_det * glm_vec3_dot(t, p); if (u < 0.0f || u > 1.0f) return false; glm_vec3_cross(t, edge1, q); v = inv_det * glm_vec3_dot(direction, q); if (v < 0.0f || u + v > 1.0f) return false; dist = inv_det * glm_vec3_dot(edge2, q); if (d) *d = dist; return dist > epsilon; } /*! * @brief ray sphere intersection * * returns false if there is no intersection if true: * * - t1 > 0, t2 > 0: ray intersects the sphere at t1 and t2 both ahead of the origin * - t1 < 0, t2 > 0: ray starts inside the sphere, exits at t2 * - t1 < 0, t2 < 0: no intersection ahead of the ray ( returns false ) * - the caller can check if the intersection points (t1 and t2) fall within a * specific range (for example, tmin < t1, t2 < tmax) to determine if the * intersections are within a desired segment of the ray * * @param[in] origin ray origin * @param[out] dir normalized ray direction * @param[in] s sphere [center.x, center.y, center.z, radii] * @param[in] t1 near point1 (closer to origin) * @param[in] t2 far point2 (farther from origin) * * @returns whether there is intersection */ CGLM_INLINE bool glm_ray_sphere(vec3 origin, vec3 dir, vec4 s, float * __restrict t1, float * __restrict t2) { vec3 dp; float r2, ddp, dpp, dscr, q, tmp, _t1, _t2; glm_vec3_sub(s, origin, dp); ddp = glm_vec3_dot(dir, dp); dpp = glm_vec3_norm2(dp); /* compute the remedy term for numerical stability */ glm_vec3_mulsubs(dir, ddp, dp); /* dp: remedy term */ r2 = s[3] * s[3]; dscr = r2 - glm_vec3_norm2(dp); if (dscr < 0.0f) { /* no intersection */ return false; } dscr = sqrtf(dscr); q = (ddp >= 0.0f) ? (ddp + dscr) : (ddp - dscr); /* include Press, William H., Saul A. Teukolsky, William T. Vetterling, and Brian P. Flannery, "Numerical Recipes in C," Cambridge University Press, 1992. */ _t1 = q; _t2 = (dpp - r2) / q; /* adjust t1 and t2 to ensure t1 is the closer intersection */ if (_t1 > _t2) { tmp = _t1; _t1 = _t2; _t2 = tmp; } *t1 = _t1; *t2 = _t2; /* check if the closest intersection (t1) is behind the ray's origin */ if (_t1 < 0.0f && _t2 < 0.0f) { /* both intersections are behind the ray, no visible intersection */ return false; } return true; } /*! * @brief point using t by 𝐏(𝑡)=𝐀+𝑡𝐛 * * @param[in] orig origin of ray * @param[in] dir direction of ray * @param[in] t parameter * @param[out] point point at t */ CGLM_INLINE void glm_ray_at(vec3 orig, vec3 dir, float t, vec3 point) { vec3 dst; glm_vec3_scale(dir, t, dst); glm_vec3_add(orig, dst, point); } #endif cglm-0.9.6/include/cglm/simd/000077500000000000000000000000001475344456400157715ustar00rootroot00000000000000cglm-0.9.6/include/cglm/simd/arm.h000066400000000000000000000121541475344456400167240ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ #ifndef cglm_simd_arm_h #define cglm_simd_arm_h #include "intrin.h" #ifdef CGLM_SIMD_ARM #if defined(_M_ARM64) || defined(_M_HYBRID_X86_ARM64) || defined(_M_ARM64EC) || defined(__aarch64__) # define CGLM_ARM64 1 #else # define CGLM_ARM64 0 #endif #define glmm_load(p) vld1q_f32(p) #define glmm_store(p, a) vst1q_f32(p, a) #define glmm_set1(x) vdupq_n_f32(x) #define glmm_128 float32x4_t #define glmm_splat_x(x) vdupq_lane_f32(vget_low_f32(x), 0) #define glmm_splat_y(x) vdupq_lane_f32(vget_low_f32(x), 1) #define glmm_splat_z(x) vdupq_lane_f32(vget_high_f32(x), 0) #define glmm_splat_w(x) vdupq_lane_f32(vget_high_f32(x), 1) #define glmm_xor(a, b) \ vreinterpretq_f32_s32(veorq_s32(vreinterpretq_s32_f32(a), \ vreinterpretq_s32_f32(b))) #define glmm_swplane(v) vextq_f32(v, v, 2) #define glmm_low(x) vget_low_f32(x) #define glmm_high(x) vget_high_f32(x) #define glmm_combine_ll(x, y) vcombine_f32(vget_low_f32(x), vget_low_f32(y)) #define glmm_combine_hl(x, y) vcombine_f32(vget_high_f32(x), vget_low_f32(y)) #define glmm_combine_lh(x, y) vcombine_f32(vget_low_f32(x), vget_high_f32(y)) #define glmm_combine_hh(x, y) vcombine_f32(vget_high_f32(x), vget_high_f32(y)) #if defined(_WIN32) && defined(_MSC_VER) /* # define glmm_float32x4_init(x, y, z, w) { .n128_f32 = { x, y, z, w } } */ CGLM_INLINE float32x4_t glmm_float32x4_init(float x, float y, float z, float w) { CGLM_ALIGN(16) float v[4] = {x, y, z, w}; return vld1q_f32(v); } #else # define glmm_float32x4_init(x, y, z, w) { x, y, z, w } #endif #define glmm_float32x4_SIGNMASK_PNPN glmm_float32x4_init( 0.f, -0.f, 0.f, -0.f) #define glmm_float32x4_SIGNMASK_NPNP glmm_float32x4_init(-0.f, 0.f, -0.f, 0.f) #define glmm_float32x4_SIGNMASK_NPPN glmm_float32x4_init(-0.f, 0.f, 0.f, -0.f) static inline float32x4_t glmm_abs(float32x4_t v) { return vabsq_f32(v); } static inline float32x4_t glmm_min(float32x4_t a, float32x4_t b) { return vminq_f32(a, b); } static inline float32x4_t glmm_max(float32x4_t a, float32x4_t b) { return vmaxq_f32(a, b); } static inline float32x4_t glmm_vhadd(float32x4_t v) { #if CGLM_ARM64 float32x4_t p; p = vpaddq_f32(v, v); /* [a+b, c+d, a+b, c+d] */ return vpaddq_f32(p, p); /* [t, t, t, t] */; #else return vaddq_f32(vaddq_f32(glmm_splat_x(v), glmm_splat_y(v)), vaddq_f32(glmm_splat_z(v), glmm_splat_w(v))); #endif /* TODO: measure speed of this compare to above */ /* return vdupq_n_f32(vaddvq_f32(v)); */ /* return vaddq_f32(vaddq_f32(glmm_splat_x(v), glmm_splat_y(v)), vaddq_f32(glmm_splat_z(v), glmm_splat_w(v))); */ /* this seems slower: v = vaddq_f32(v, vrev64q_f32(v)); return vaddq_f32(v, vcombine_f32(vget_high_f32(v), vget_low_f32(v))); */ } static inline float glmm_hadd(float32x4_t v) { #if CGLM_ARM64 return vaddvq_f32(v); #else v = vaddq_f32(v, vrev64q_f32(v)); v = vaddq_f32(v, vcombine_f32(vget_high_f32(v), vget_low_f32(v))); return vgetq_lane_f32(v, 0); #endif } static inline float glmm_hmin(float32x4_t v) { float32x2_t t; t = vpmin_f32(vget_low_f32(v), vget_high_f32(v)); t = vpmin_f32(t, t); return vget_lane_f32(t, 0); } static inline float glmm_hmax(float32x4_t v) { float32x2_t t; t = vpmax_f32(vget_low_f32(v), vget_high_f32(v)); t = vpmax_f32(t, t); return vget_lane_f32(t, 0); } static inline float glmm_dot(float32x4_t a, float32x4_t b) { return glmm_hadd(vmulq_f32(a, b)); } static inline float32x4_t glmm_vdot(float32x4_t a, float32x4_t b) { return glmm_vhadd(vmulq_f32(a, b)); } static inline float glmm_norm(float32x4_t a) { return sqrtf(glmm_dot(a, a)); } static inline float glmm_norm2(float32x4_t a) { return glmm_dot(a, a); } static inline float glmm_norm_one(float32x4_t a) { return glmm_hadd(glmm_abs(a)); } static inline float glmm_norm_inf(float32x4_t a) { return glmm_hmax(glmm_abs(a)); } static inline float32x4_t glmm_div(float32x4_t a, float32x4_t b) { #if CGLM_ARM64 return vdivq_f32(a, b); #else /* 2 iterations of Newton-Raphson refinement of reciprocal */ float32x4_t r0, r1; r0 = vrecpeq_f32(b); r1 = vrecpsq_f32(r0, b); r0 = vmulq_f32(r1, r0); r1 = vrecpsq_f32(r0, b); r0 = vmulq_f32(r1, r0); return vmulq_f32(a, r0); #endif } static inline float32x4_t glmm_fmadd(float32x4_t a, float32x4_t b, float32x4_t c) { #if CGLM_ARM64 return vfmaq_f32(c, a, b); /* why vfmaq_f32 is slower than vmlaq_f32 ??? */ #else return vmlaq_f32(c, a, b); #endif } static inline float32x4_t glmm_fnmadd(float32x4_t a, float32x4_t b, float32x4_t c) { #if CGLM_ARM64 return vfmsq_f32(c, a, b); #else return vmlsq_f32(c, a, b); #endif } static inline float32x4_t glmm_fmsub(float32x4_t a, float32x4_t b, float32x4_t c) { return glmm_fmadd(a, b, vnegq_f32(c)); } static inline float32x4_t glmm_fnmsub(float32x4_t a, float32x4_t b, float32x4_t c) { return vsubq_f32(vdupq_n_f32(0.0f), glmm_fmadd(a, b, c)); } #endif #endif /* cglm_simd_arm_h */ cglm-0.9.6/include/cglm/simd/avx/000077500000000000000000000000001475344456400165675ustar00rootroot00000000000000cglm-0.9.6/include/cglm/simd/avx/affine.h000066400000000000000000000043011475344456400201660ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ #ifndef cglm_affine_mat_avx_h #define cglm_affine_mat_avx_h #ifdef __AVX__ #include "../../common.h" #include "../intrin.h" #include CGLM_INLINE void glm_mul_avx(mat4 m1, mat4 m2, mat4 dest) { /* D = R * L (Column-Major) */ __m256 y0, y1, y2, y3, y4, y5, y6, y7, y8, y9; y0 = glmm_load256(m2[0]); /* h g f e d c b a */ y1 = glmm_load256(m2[2]); /* p o n m l k j i */ y2 = glmm_load256(m1[0]); /* h g f e d c b a */ y3 = glmm_load256(m1[2]); /* p o n m l k j i */ /* 0x03: 0b00000011 */ y4 = _mm256_permute2f128_ps(y2, y2, 0x03); /* d c b a h g f e */ y5 = _mm256_permute2f128_ps(y3, y3, 0x03); /* l k j i p o n m */ /* f f f f a a a a */ /* h h h h c c c c */ /* e e e e b b b b */ /* g g g g d d d d */ y6 = _mm256_permutevar_ps(y0, _mm256_set_epi32(1, 1, 1, 1, 0, 0, 0, 0)); y7 = _mm256_permutevar_ps(y0, _mm256_set_epi32(3, 3, 3, 3, 2, 2, 2, 2)); y8 = _mm256_permutevar_ps(y0, _mm256_set_epi32(0, 0, 0, 0, 1, 1, 1, 1)); y9 = _mm256_permutevar_ps(y0, _mm256_set_epi32(2, 2, 2, 2, 3, 3, 3, 3)); glmm_store256(dest[0], _mm256_add_ps(_mm256_add_ps(_mm256_mul_ps(y2, y6), _mm256_mul_ps(y3, y7)), _mm256_add_ps(_mm256_mul_ps(y4, y8), _mm256_mul_ps(y5, y9)))); /* n n n n i i i i */ /* p p p p k k k k */ /* m m m m j j j j */ /* o o o o l l l l */ y6 = _mm256_permutevar_ps(y1, _mm256_set_epi32(1, 1, 1, 1, 0, 0, 0, 0)); y7 = _mm256_permutevar_ps(y1, _mm256_set_epi32(3, 3, 3, 3, 2, 2, 2, 2)); y8 = _mm256_permutevar_ps(y1, _mm256_set_epi32(0, 0, 0, 0, 1, 1, 1, 1)); y9 = _mm256_permutevar_ps(y1, _mm256_set_epi32(2, 2, 2, 2, 3, 3, 3, 3)); glmm_store256(dest[2], _mm256_add_ps(_mm256_add_ps(_mm256_mul_ps(y2, y6), _mm256_mul_ps(y3, y7)), _mm256_add_ps(_mm256_mul_ps(y4, y8), _mm256_mul_ps(y5, y9)))); } #endif #endif /* cglm_affine_mat_avx_h */ cglm-0.9.6/include/cglm/simd/avx/mat4.h000066400000000000000000000061461475344456400176140ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ #ifndef cglm_mat_simd_avx_h #define cglm_mat_simd_avx_h #ifdef __AVX__ #include "../../common.h" #include "../intrin.h" CGLM_INLINE void glm_mat4_scale_avx(mat4 m, float s) { __m256 y0, y1, y2, y3, y4; y0 = glmm_load256(m[0]); /* h g f e d c b a */ y1 = glmm_load256(m[2]); /* p o n m l k j i */ y2 = _mm256_broadcast_ss(&s); y3 = _mm256_mul_ps(y0, y2); y4 = _mm256_mul_ps(y1, y2); glmm_store256(m[0], y3); glmm_store256(m[2], y4); } /* TODO: this must be tested and compared to SSE version, may be slower!!! */ CGLM_INLINE void glm_mat4_transp_avx(mat4 m, mat4 dest) { __m256 y0, y1, y2, y3; y0 = glmm_load256(m[0]); /* h g f e d c b a */ y1 = glmm_load256(m[2]); /* p o n m l k j i */ y2 = _mm256_unpacklo_ps(y0, y1); /* n f m e j b i a */ y3 = _mm256_unpackhi_ps(y0, y1); /* p h o g l d k c */ y0 = _mm256_permute2f128_ps(y2, y3, 0x20); /* l d k c j b i a */ y1 = _mm256_permute2f128_ps(y2, y3, 0x31); /* p h o g n f m e */ y2 = _mm256_unpacklo_ps(y0, y1); /* o k g c m i e a */ y3 = _mm256_unpackhi_ps(y0, y1); /* p l h d n j f b */ y0 = _mm256_permute2f128_ps(y2, y3, 0x20); /* n j f b m i e a */ y1 = _mm256_permute2f128_ps(y2, y3, 0x31); /* p l h d o k g c */ glmm_store256(dest[0], y0); glmm_store256(dest[2], y1); } CGLM_INLINE void glm_mat4_mul_avx(mat4 m1, mat4 m2, mat4 dest) { /* D = R * L (Column-Major) */ __m256 y0, y1, y2, y3, y4, y5, y6, y7, y8, y9, y10, y11, y12, y13; __m256i yi0, yi1, yi2, yi3; y0 = glmm_load256(m2[0]); /* h g f e d c b a */ y1 = glmm_load256(m2[2]); /* p o n m l k j i */ y2 = glmm_load256(m1[0]); /* h g f e d c b a */ y3 = glmm_load256(m1[2]); /* p o n m l k j i */ /* 0x03: 0b00000011 */ y4 = _mm256_permute2f128_ps(y2, y2, 0x03); /* d c b a h g f e */ y5 = _mm256_permute2f128_ps(y3, y3, 0x03); /* l k j i p o n m */ yi0 = _mm256_set_epi32(1, 1, 1, 1, 0, 0, 0, 0); yi1 = _mm256_set_epi32(3, 3, 3, 3, 2, 2, 2, 2); yi2 = _mm256_set_epi32(0, 0, 0, 0, 1, 1, 1, 1); yi3 = _mm256_set_epi32(2, 2, 2, 2, 3, 3, 3, 3); /* f f f f a a a a */ /* h h h h c c c c */ /* e e e e b b b b */ /* g g g g d d d d */ y6 = _mm256_permutevar_ps(y0, yi0); y7 = _mm256_permutevar_ps(y0, yi1); y8 = _mm256_permutevar_ps(y0, yi2); y9 = _mm256_permutevar_ps(y0, yi3); /* n n n n i i i i */ /* p p p p k k k k */ /* m m m m j j j j */ /* o o o o l l l l */ y10 = _mm256_permutevar_ps(y1, yi0); y11 = _mm256_permutevar_ps(y1, yi1); y12 = _mm256_permutevar_ps(y1, yi2); y13 = _mm256_permutevar_ps(y1, yi3); y0 = _mm256_mul_ps(y2, y6); y1 = _mm256_mul_ps(y2, y10); y0 = glmm256_fmadd(y3, y7, y0); y1 = glmm256_fmadd(y3, y11, y1); y0 = glmm256_fmadd(y4, y8, y0); y1 = glmm256_fmadd(y4, y12, y1); y0 = glmm256_fmadd(y5, y9, y0); y1 = glmm256_fmadd(y5, y13, y1); glmm_store256(dest[0], y0); glmm_store256(dest[2], y1); } #endif #endif /* cglm_mat_simd_avx_h */ cglm-0.9.6/include/cglm/simd/intrin.h000066400000000000000000000062011475344456400174440ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ #ifndef cglm_intrin_h #define cglm_intrin_h #if defined(_MSC_VER) && !defined(_M_ARM64EC) # if (defined(_M_AMD64) || defined(_M_X64)) || _M_IX86_FP == 2 # ifndef __SSE__ # define __SSE__ # endif # ifndef __SSE2__ # define __SSE2__ # endif # elif _M_IX86_FP == 1 # ifndef __SSE__ # define __SSE__ # endif # endif /* do not use alignment for older visual studio versions */ /* also ARM32 also causes similar error, disable it for now on ARM32 too */ # if _MSC_VER < 1913 || _M_ARM /* Visual Studio 2017 version 15.6 */ # define CGLM_ALL_UNALIGNED # endif #endif #ifdef __AVX__ # include # define CGLM_AVX_FP 1 # ifndef __SSE2__ # define __SSE2__ # endif # ifndef __SSE3__ # define __SSE3__ # endif # ifndef __SSE4__ # define __SSE4__ # endif # ifndef __SSE4_1__ # define __SSE4_1__ # endif # ifndef __SSE4_2__ # define __SSE4_2__ # endif # ifndef CGLM_SIMD_x86 # define CGLM_SIMD_x86 # endif #endif #if defined(__SSE__) # include # define CGLM_SSE_FP 1 # ifndef CGLM_SIMD_x86 # define CGLM_SIMD_x86 # endif #endif #if defined(__SSE2__) # include # define CGLM_SSE2_FP 1 # ifndef CGLM_SIMD_x86 # define CGLM_SIMD_x86 # endif #endif #if defined(__SSE3__) # include # ifndef CGLM_SIMD_x86 # define CGLM_SIMD_x86 # endif #endif #if defined(__SSE4_1__) # include # ifndef CGLM_SIMD_x86 # define CGLM_SIMD_x86 # endif #endif #if defined(__SSE4_2__) # include # ifndef CGLM_SIMD_x86 # define CGLM_SIMD_x86 # endif #endif /* ARM Neon */ #if defined(_WIN32) && defined(_MSC_VER) /* TODO: non-ARM stuff already inported, will this be better option */ /* # include */ # if defined(_M_ARM64) || defined(_M_HYBRID_X86_ARM64) || defined(_M_ARM64EC) # include # include # ifndef CGLM_NEON_FP # define CGLM_NEON_FP 1 # endif # ifndef CGLM_SIMD_ARM # define CGLM_SIMD_ARM # endif # elif defined(_M_ARM) # include # include # ifndef CGLM_NEON_FP # define CGLM_NEON_FP 1 # endif # ifndef CGLM_SIMD_ARM # define CGLM_SIMD_ARM # endif # endif #else /* non-windows */ # if defined(__ARM_NEON) || defined(__ARM_NEON__) # include # if defined(__ARM_NEON_FP) || defined(__ARM_FP) # define CGLM_NEON_FP 1 # endif # ifndef CGLM_SIMD_ARM # define CGLM_SIMD_ARM # endif # endif #endif /* WebAssembly */ #if defined(__wasm__) && defined(__wasm_simd128__) # ifndef CGLM_SIMD_WASM # define CGLM_SIMD_WASM # endif #endif #if defined(CGLM_SIMD_x86) || defined(CGLM_SIMD_ARM) || defined(CGLM_SIMD_WASM) # ifndef CGLM_SIMD # define CGLM_SIMD # endif #endif #if defined(CGLM_SIMD_x86) && !defined(CGLM_SIMD_WASM) # include "x86.h" #endif #if defined(CGLM_SIMD_ARM) # include "arm.h" #endif #if defined(CGLM_SIMD_WASM) # include "wasm.h" #endif #endif /* cglm_intrin_h */ cglm-0.9.6/include/cglm/simd/neon/000077500000000000000000000000001475344456400167305ustar00rootroot00000000000000cglm-0.9.6/include/cglm/simd/neon/affine.h000066400000000000000000000054731475344456400203420ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ #ifndef cglm_affine_neon_h #define cglm_affine_neon_h #if defined(CGLM_NEON_FP) #include "../../common.h" #include "../intrin.h" CGLM_INLINE void glm_mul_neon(mat4 m1, mat4 m2, mat4 dest) { /* D = R * L (Column-Major) */ glmm_128 l, r0, r1, r2, r3, v0, v1, v2, v3; l = glmm_load(m1[0]); r0 = glmm_load(m2[0]); r1 = glmm_load(m2[1]); r2 = glmm_load(m2[2]); r3 = glmm_load(m2[3]); v0 = vmulq_f32(glmm_splat_x(r0), l); v1 = vmulq_f32(glmm_splat_x(r1), l); v2 = vmulq_f32(glmm_splat_x(r2), l); v3 = vmulq_f32(glmm_splat_x(r3), l); l = glmm_load(m1[1]); v0 = glmm_fmadd(glmm_splat_y(r0), l, v0); v1 = glmm_fmadd(glmm_splat_y(r1), l, v1); v2 = glmm_fmadd(glmm_splat_y(r2), l, v2); v3 = glmm_fmadd(glmm_splat_y(r3), l, v3); l = glmm_load(m1[2]); v0 = glmm_fmadd(glmm_splat_z(r0), l, v0); v1 = glmm_fmadd(glmm_splat_z(r1), l, v1); v2 = glmm_fmadd(glmm_splat_z(r2), l, v2); v3 = glmm_fmadd(glmm_splat_z(r3), l, v3); v3 = glmm_fmadd(glmm_splat_w(r3), glmm_load(m1[3]), v3); glmm_store(dest[0], v0); glmm_store(dest[1], v1); glmm_store(dest[2], v2); glmm_store(dest[3], v3); } CGLM_INLINE void glm_mul_rot_neon(mat4 m1, mat4 m2, mat4 dest) { /* D = R * L (Column-Major) */ glmm_128 l, r0, r1, r2, v0, v1, v2; l = glmm_load(m1[0]); r0 = glmm_load(m2[0]); r1 = glmm_load(m2[1]); r2 = glmm_load(m2[2]); v0 = vmulq_f32(glmm_splat_x(r0), l); v1 = vmulq_f32(glmm_splat_x(r1), l); v2 = vmulq_f32(glmm_splat_x(r2), l); l = glmm_load(m1[1]); v0 = glmm_fmadd(glmm_splat_y(r0), l, v0); v1 = glmm_fmadd(glmm_splat_y(r1), l, v1); v2 = glmm_fmadd(glmm_splat_y(r2), l, v2); l = glmm_load(m1[2]); v0 = glmm_fmadd(glmm_splat_z(r0), l, v0); v1 = glmm_fmadd(glmm_splat_z(r1), l, v1); v2 = glmm_fmadd(glmm_splat_z(r2), l, v2); glmm_store(dest[0], v0); glmm_store(dest[1], v1); glmm_store(dest[2], v2); glmm_store(dest[3], glmm_load(m1[3])); } CGLM_INLINE void glm_inv_tr_neon(mat4 mat) { float32x4x4_t vmat; glmm_128 r0, r1, r2, x0; vmat = vld4q_f32(mat[0]); r0 = vmat.val[0]; r1 = vmat.val[1]; r2 = vmat.val[2]; x0 = glmm_fmadd(r0, glmm_splat_w(r0), glmm_fmadd(r1, glmm_splat_w(r1), vmulq_f32(r2, glmm_splat_w(r2)))); x0 = vnegq_f32(x0); glmm_store(mat[0], r0); glmm_store(mat[1], r1); glmm_store(mat[2], r2); glmm_store(mat[3], x0); mat[0][3] = 0.0f; mat[1][3] = 0.0f; mat[2][3] = 0.0f; mat[3][3] = 1.0f; /* TODO: ? zo = vget_high_f32(r3); vst1_lane_f32(&mat[0][3], zo, 0); vst1_lane_f32(&mat[1][3], zo, 0); vst1_lane_f32(&mat[2][3], zo, 0); vst1_lane_f32(&mat[3][3], zo, 1); */ } #endif #endif /* cglm_affine_neon_h */ cglm-0.9.6/include/cglm/simd/neon/mat2.h000066400000000000000000000016251475344456400177500ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ #ifndef cglm_mat2_neon_h #define cglm_mat2_neon_h #if defined(CGLM_NEON_FP) #include "../../common.h" #include "../intrin.h" CGLM_INLINE void glm_mat2_mul_neon(mat2 m1, mat2 m2, mat2 dest) { float32x4x2_t a1; glmm_128 x0, x1, x2; float32x2_t dc, ba; x1 = glmm_load(m1[0]); /* d c b a */ x2 = glmm_load(m2[0]); /* h g f e */ dc = vget_high_f32(x1); ba = vget_low_f32(x1); /* g g e e, h h f f */ a1 = vtrnq_f32(x2, x2); /* dest[0][0] = a * e + c * f; dest[0][1] = b * e + d * f; dest[1][0] = a * g + c * h; dest[1][1] = b * g + d * h; */ x0 = glmm_fmadd(vcombine_f32(ba, ba), a1.val[0], vmulq_f32(vcombine_f32(dc, dc), a1.val[1])); glmm_store(dest[0], x0); } #endif #endif /* cglm_mat2_neon_h */ cglm-0.9.6/include/cglm/simd/neon/mat4.h000066400000000000000000000333271475344456400177560ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ #ifndef cglm_mat4_neon_h #define cglm_mat4_neon_h #if defined(CGLM_NEON_FP) #include "../../common.h" #include "../intrin.h" CGLM_INLINE void glm_mat4_scale_neon(mat4 m, float s) { float32x4_t v0; v0 = vdupq_n_f32(s); vst1q_f32(m[0], vmulq_f32(vld1q_f32(m[0]), v0)); vst1q_f32(m[1], vmulq_f32(vld1q_f32(m[1]), v0)); vst1q_f32(m[2], vmulq_f32(vld1q_f32(m[2]), v0)); vst1q_f32(m[3], vmulq_f32(vld1q_f32(m[3]), v0)); } CGLM_INLINE void glm_mat4_transp_neon(mat4 m, mat4 dest) { float32x4x4_t vmat; vmat = vld4q_f32(m[0]); vst1q_f32(dest[0], vmat.val[0]); vst1q_f32(dest[1], vmat.val[1]); vst1q_f32(dest[2], vmat.val[2]); vst1q_f32(dest[3], vmat.val[3]); } CGLM_INLINE void glm_mat4_mul_neon(mat4 m1, mat4 m2, mat4 dest) { /* D = R * L (Column-Major) */ glmm_128 l, r0, r1, r2, r3, v0, v1, v2, v3; l = glmm_load(m1[0]); r0 = glmm_load(m2[0]); r1 = glmm_load(m2[1]); r2 = glmm_load(m2[2]); r3 = glmm_load(m2[3]); v0 = vmulq_f32(glmm_splat_x(r0), l); v1 = vmulq_f32(glmm_splat_x(r1), l); v2 = vmulq_f32(glmm_splat_x(r2), l); v3 = vmulq_f32(glmm_splat_x(r3), l); l = glmm_load(m1[1]); v0 = glmm_fmadd(glmm_splat_y(r0), l, v0); v1 = glmm_fmadd(glmm_splat_y(r1), l, v1); v2 = glmm_fmadd(glmm_splat_y(r2), l, v2); v3 = glmm_fmadd(glmm_splat_y(r3), l, v3); l = glmm_load(m1[2]); v0 = glmm_fmadd(glmm_splat_z(r0), l, v0); v1 = glmm_fmadd(glmm_splat_z(r1), l, v1); v2 = glmm_fmadd(glmm_splat_z(r2), l, v2); v3 = glmm_fmadd(glmm_splat_z(r3), l, v3); l = glmm_load(m1[3]); v0 = glmm_fmadd(glmm_splat_w(r0), l, v0); v1 = glmm_fmadd(glmm_splat_w(r1), l, v1); v2 = glmm_fmadd(glmm_splat_w(r2), l, v2); v3 = glmm_fmadd(glmm_splat_w(r3), l, v3); glmm_store(dest[0], v0); glmm_store(dest[1], v1); glmm_store(dest[2], v2); glmm_store(dest[3], v3); } CGLM_INLINE void glm_mat4_mulv_neon(mat4 m, vec4 v, vec4 dest) { float32x4_t l0, l1, l2, l3; float32x2_t vlo, vhi; l0 = vld1q_f32(m[0]); l1 = vld1q_f32(m[1]); l2 = vld1q_f32(m[2]); l3 = vld1q_f32(m[3]); vlo = vld1_f32(&v[0]); vhi = vld1_f32(&v[2]); l0 = vmulq_lane_f32(l0, vlo, 0); l0 = vmlaq_lane_f32(l0, l1, vlo, 1); l0 = vmlaq_lane_f32(l0, l2, vhi, 0); l0 = vmlaq_lane_f32(l0, l3, vhi, 1); vst1q_f32(dest, l0); } CGLM_INLINE float glm_mat4_det_neon(mat4 mat) { float32x4_t r0, r1, r2, r3, x0, x1, x2; float32x2_t ij, op, mn, kl, nn, mm, jj, ii, gh, ef, t12, t34; float32x4x2_t a1; float32x4_t x3 = glmm_float32x4_SIGNMASK_PNPN; /* 127 <- 0, [square] det(A) = det(At) */ r0 = glmm_load(mat[0]); /* d c b a */ r1 = vrev64q_f32(glmm_load(mat[1])); /* g h e f */ r2 = vrev64q_f32(glmm_load(mat[2])); /* l k i j */ r3 = vrev64q_f32(glmm_load(mat[3])); /* o p m n */ gh = vget_high_f32(r1); ef = vget_low_f32(r1); kl = vget_high_f32(r2); ij = vget_low_f32(r2); op = vget_high_f32(r3); mn = vget_low_f32(r3); mm = vdup_lane_f32(mn, 1); nn = vdup_lane_f32(mn, 0); ii = vdup_lane_f32(ij, 1); jj = vdup_lane_f32(ij, 0); /* t[1] = j * p - n * l; t[2] = j * o - n * k; t[3] = i * p - m * l; t[4] = i * o - m * k; */ x0 = glmm_fnmadd(vcombine_f32(kl, kl), vcombine_f32(nn, mm), vmulq_f32(vcombine_f32(op, op), vcombine_f32(jj, ii))); t12 = vget_low_f32(x0); t34 = vget_high_f32(x0); /* 1 3 1 3 2 4 2 4 */ a1 = vuzpq_f32(x0, x0); /* t[0] = k * p - o * l; t[0] = k * p - o * l; t[5] = i * n - m * j; t[5] = i * n - m * j; */ x1 = glmm_fnmadd(vcombine_f32(vdup_lane_f32(kl, 0), jj), vcombine_f32(vdup_lane_f32(op, 1), mm), vmulq_f32(vcombine_f32(vdup_lane_f32(op, 0), nn), vcombine_f32(vdup_lane_f32(kl, 1), ii))); /* a * (f * t[0] - g * t[1] + h * t[2]) - b * (e * t[0] - g * t[3] + h * t[4]) + c * (e * t[1] - f * t[3] + h * t[5]) - d * (e * t[2] - f * t[4] + g * t[5]) */ x2 = glmm_fnmadd(vcombine_f32(vdup_lane_f32(gh, 1), vdup_lane_f32(ef, 0)), vcombine_f32(vget_low_f32(a1.val[0]), t34), vmulq_f32(vcombine_f32(ef, vdup_lane_f32(ef, 1)), vcombine_f32(vget_low_f32(x1), t12))); x2 = glmm_fmadd(vcombine_f32(vdup_lane_f32(gh, 0), gh), vcombine_f32(vget_low_f32(a1.val[1]), vget_high_f32(x1)), x2); x2 = glmm_xor(x2, x3); return glmm_hadd(vmulq_f32(x2, r0)); } /* old one */ #if 0 CGLM_INLINE void glm_mat4_inv_neon(mat4 mat, mat4 dest) { float32x4_t r0, r1, r2, r3, v0, v1, v2, v3, t0, t1, t2, t3, t4, t5, x0, x1, x2, x3, x4, x5, x6, x7, x8; float32x4x2_t a1; float32x2_t lp, ko, hg, jn, im, fe, ae, bf, cg, dh; float32x4_t x9 = glmm_float32x4_SIGNMASK_NPNP; x8 = vrev64q_f32(x9); /* 127 <- 0 */ r0 = glmm_load(mat[0]); /* d c b a */ r1 = glmm_load(mat[1]); /* h g f e */ r2 = glmm_load(mat[2]); /* l k j i */ r3 = glmm_load(mat[3]); /* p o n m */ /* l p k o, j n i m */ a1 = vzipq_f32(r3, r2); jn = vget_high_f32(a1.val[0]); im = vget_low_f32(a1.val[0]); lp = vget_high_f32(a1.val[1]); ko = vget_low_f32(a1.val[1]); hg = vget_high_f32(r1); x1 = vcombine_f32(vdup_lane_f32(lp, 0), lp); /* l p p p */ x2 = vcombine_f32(vdup_lane_f32(ko, 0), ko); /* k o o o */ x0 = vcombine_f32(vdup_lane_f32(lp, 1), vdup_lane_f32(hg, 1)); /* h h l l */ x3 = vcombine_f32(vdup_lane_f32(ko, 1), vdup_lane_f32(hg, 0)); /* g g k k */ /* t1[0] = k * p - o * l; t1[0] = k * p - o * l; t2[0] = g * p - o * h; t3[0] = g * l - k * h; */ t0 = glmm_fnmadd(x2, x0, vmulq_f32(x3, x1)); fe = vget_low_f32(r1); x4 = vcombine_f32(vdup_lane_f32(jn, 0), jn); /* j n n n */ x5 = vcombine_f32(vdup_lane_f32(jn, 1), vdup_lane_f32(fe, 1)); /* f f j j */ /* t1[1] = j * p - n * l; t1[1] = j * p - n * l; t2[1] = f * p - n * h; t3[1] = f * l - j * h; */ t1 = glmm_fnmadd(x4, x0, vmulq_f32(x5, x1)); /* t1[2] = j * o - n * k t1[2] = j * o - n * k; t2[2] = f * o - n * g; t3[2] = f * k - j * g; */ t2 = glmm_fnmadd(x4, x3, vmulq_f32(x5, x2)); x6 = vcombine_f32(vdup_lane_f32(im, 1), vdup_lane_f32(fe, 0)); /* e e i i */ x7 = vcombine_f32(vdup_lane_f32(im, 0), im); /* i m m m */ /* t1[3] = i * p - m * l; t1[3] = i * p - m * l; t2[3] = e * p - m * h; t3[3] = e * l - i * h; */ t3 = glmm_fnmadd(x7, x0, vmulq_f32(x6, x1)); /* t1[4] = i * o - m * k; t1[4] = i * o - m * k; t2[4] = e * o - m * g; t3[4] = e * k - i * g; */ t4 = glmm_fnmadd(x7, x3, vmulq_f32(x6, x2)); /* t1[5] = i * n - m * j; t1[5] = i * n - m * j; t2[5] = e * n - m * f; t3[5] = e * j - i * f; */ t5 = glmm_fnmadd(x7, x5, vmulq_f32(x6, x4)); /* h d f b, g c e a */ a1 = vtrnq_f32(r0, r1); x4 = vrev64q_f32(a1.val[0]); /* c g a e */ x5 = vrev64q_f32(a1.val[1]); /* d h b f */ ae = vget_low_f32(x4); cg = vget_high_f32(x4); bf = vget_low_f32(x5); dh = vget_high_f32(x5); x0 = vcombine_f32(ae, vdup_lane_f32(ae, 1)); /* a a a e */ x1 = vcombine_f32(bf, vdup_lane_f32(bf, 1)); /* b b b f */ x2 = vcombine_f32(cg, vdup_lane_f32(cg, 1)); /* c c c g */ x3 = vcombine_f32(dh, vdup_lane_f32(dh, 1)); /* d d d h */ /* dest[0][0] = f * t1[0] - g * t1[1] + h * t1[2]; dest[0][1] =-(b * t1[0] - c * t1[1] + d * t1[2]); dest[0][2] = b * t2[0] - c * t2[1] + d * t2[2]; dest[0][3] =-(b * t3[0] - c * t3[1] + d * t3[2]); */ v0 = glmm_xor(glmm_fmadd(x3, t2, glmm_fnmadd(x2, t1, vmulq_f32(x1, t0))), x8); /* dest[2][0] = e * t1[1] - f * t1[3] + h * t1[5]; dest[2][1] =-(a * t1[1] - b * t1[3] + d * t1[5]); dest[2][2] = a * t2[1] - b * t2[3] + d * t2[5]; dest[2][3] =-(a * t3[1] - b * t3[3] + d * t3[5]);*/ v2 = glmm_xor(glmm_fmadd(x3, t5, glmm_fnmadd(x1, t3, vmulq_f32(x0, t1))), x8); /* dest[1][0] =-(e * t1[0] - g * t1[3] + h * t1[4]); dest[1][1] = a * t1[0] - c * t1[3] + d * t1[4]; dest[1][2] =-(a * t2[0] - c * t2[3] + d * t2[4]); dest[1][3] = a * t3[0] - c * t3[3] + d * t3[4]; */ v1 = glmm_xor(glmm_fmadd(x3, t4, glmm_fnmadd(x2, t3, vmulq_f32(x0, t0))), x9); /* dest[3][0] =-(e * t1[2] - f * t1[4] + g * t1[5]); dest[3][1] = a * t1[2] - b * t1[4] + c * t1[5]; dest[3][2] =-(a * t2[2] - b * t2[4] + c * t2[5]); dest[3][3] = a * t3[2] - b * t3[4] + c * t3[5]; */ v3 = glmm_xor(glmm_fmadd(x2, t5, glmm_fnmadd(x1, t4, vmulq_f32(x0, t2))), x9); /* determinant */ x0 = vcombine_f32(vget_low_f32(vzipq_f32(v0, v1).val[0]), vget_low_f32(vzipq_f32(v2, v3).val[0])); /* x0 = glmm_div(glmm_set1_rval(1.0f), glmm_vhadd(vmulq_f32(x0, r0))); glmm_store(dest[0], vmulq_f32(v0, x0)); glmm_store(dest[1], vmulq_f32(v1, x0)); glmm_store(dest[2], vmulq_f32(v2, x0)); glmm_store(dest[3], vmulq_f32(v3, x0)); */ x0 = glmm_vhadd(vmulq_f32(x0, r0)); glmm_store(dest[0], glmm_div(v0, x0)); glmm_store(dest[1], glmm_div(v1, x0)); glmm_store(dest[2], glmm_div(v2, x0)); glmm_store(dest[3], glmm_div(v3, x0)); } #endif CGLM_INLINE void glm_mat4_inv_neon(mat4 mat, mat4 dest) { float32x4_t r0, r1, r2, r3, v0, v1, v2, v3, v4, v5, t0, t1, t2; float32x4x2_t a0, a1, a2, a3, a4; float32x4_t s1 = glmm_float32x4_SIGNMASK_PNPN, s2; #if !CGLM_ARM64 float32x2_t l0, l1; #endif s2 = vrev64q_f32(s1); /* 127 <- 0 */ r0 = glmm_load(mat[0]); /* d c b a */ r1 = glmm_load(mat[1]); /* h g f e */ r2 = glmm_load(mat[2]); /* l k j i */ r3 = glmm_load(mat[3]); /* p o n m */ a1 = vzipq_f32(r0, r2); /* l d k c, j b i a */ a2 = vzipq_f32(r1, r3); /* p h o g, n f m e */ a3 = vzipq_f32(a2.val[0], a1.val[0]); /* j n b f, i m a e */ a4 = vzipq_f32(a2.val[1], a1.val[1]); /* l p d h, k o c g */ v0 = vextq_f32(a1.val[0], a1.val[1], 2); /* k c j b */ v1 = vextq_f32(a2.val[0], a2.val[1], 2); /* o g n f */ v2 = vextq_f32(a1.val[1], a2.val[0], 2); /* m e l d */ v3 = vextq_f32(a2.val[1], a1.val[0], 2); /* i a p h */ v4 = vextq_f32(v1, v2, 2); /* l d o g */ v5 = vextq_f32(v0, v3, 2); /* p h k c */ /* c2 = c * h - g * d c12 = a * g - c * e c8 = a * f - b * e c1 = k * p - o * l c11 = i * o - k * m c7 = i * n - j * m c4 = h * a - d * e c6 = b * h - d * f c10 = b * g - c * f c3 = p * i - l * m c5 = j * p - l * n c9 = j * o - k * n */ t0 = vmulq_f32(v5, v3); t1 = vmulq_f32(a1.val[0], a2.val[1]); t2 = vmulq_f32(a1.val[0], v1); t0 = glmm_fnmadd(v4, v2, t0); t1 = glmm_fnmadd(a1.val[1], a2.val[0], t1); t2 = glmm_fnmadd(v0, a2.val[0], t2); t0 = vrev64q_f32(t0); t1 = vrev64q_f32(t1); t2 = vrev64q_f32(t2); /* det */ v0 = vrev64q_f32(t2); v1 = vextq_f32(t1, t1, 2); v0 = vmulq_f32(t0, v0); v1 = vrev64q_f32(v1); v1 = vmulq_f32(v1, t1); /* c3 * c10 + c4 * c9 + c1 * c8 + c2 * c7 */ #if CGLM_ARM64 v0 = vpaddq_f32(v0, v0); v0 = vpaddq_f32(v0, v0); #else l0 = vget_low_f32(v0); l1 = vget_high_f32(v0); l0 = vpadd_f32(l0, l0); /* [a+b, a+b] */ l1 = vpadd_f32(l1, l1); /* [c+d, c+d] */ l0 = vadd_f32(l0, l1); /* [sum, sum] */ v0 = vcombine_f32(l0, l0); #endif /* c5 * c12 + c6 * c11 */ #if CGLM_ARM64 v1 = vpaddq_f32(v1, v1); #else l0 = vget_low_f32(v1); l1 = vget_high_f32(v1); l0 = vpadd_f32(l0, l0); /* [a+b, a+b] */ l1 = vpadd_f32(l1, l1); /* [c+d, c+d] */ v1 = vcombine_f32(l0, l1); #endif v0 = vsubq_f32(v0, v1); /* det */ /* inv div */ v1 = vdupq_n_f32(1.0f); v0 = glmm_div(v1, v0); /* inv div */ /* multiply t0,t1,t2 by idt to reduce 1mul below: 2eor+4mul vs 3mul+4eor */ t0 = vmulq_f32(t0, v0); t1 = vmulq_f32(t1, v0); t2 = vmulq_f32(t2, v0); a0 = vzipq_f32(t0, t0); /* c4 c4 c3 c3, c2 c2 c1 c1 */ a1 = vzipq_f32(t1, t1); /* c6 c6 c5 c5, c12 c12 c11 c11 */ a2 = vzipq_f32(t2, t2); /* c10 c10 c9 c9, c8 c8 c7 c7 */ /* result */ /* dest[0][0] = (f * c1 - g * c5 + h * c9) * idt; dest[0][1] = (b * c1 - c * c5 + d * c9) * ndt; dest[0][2] = (n * c2 - o * c6 + p * c10) * idt; dest[0][3] = (j * c2 - k * c6 + l * c10) * ndt; dest[1][0] = (e * c1 - g * c3 + h * c11) * ndt; dest[1][1] = (a * c1 - c * c3 + d * c11) * idt; dest[1][2] = (m * c2 - o * c4 + p * c12) * ndt; dest[1][3] = (i * c2 - k * c4 + l * c12) * idt; dest[2][0] = (e * c5 - f * c3 + h * c7) * idt; dest[2][1] = (a * c5 - b * c3 + d * c7) * ndt; dest[2][2] = (m * c6 - n * c4 + p * c8) * idt; dest[2][3] = (i * c6 - j * c4 + l * c8) * ndt; dest[3][0] = (e * c9 - f * c11 + g * c7) * ndt; dest[3][1] = (a * c9 - b * c11 + c * c7) * idt; dest[3][2] = (m * c10 - n * c12 + o * c8) * ndt; dest[3][3] = (i * c10 - j * c12 + k * c8) * idt; */ r0 = vmulq_f32(a3.val[1], a0.val[0]); r1 = vmulq_f32(a3.val[0], a0.val[0]); r2 = vmulq_f32(a3.val[0], a1.val[1]); r3 = vmulq_f32(a3.val[0], a2.val[1]); r0 = glmm_fnmadd(a4.val[0], a1.val[1], r0); r1 = glmm_fnmadd(a4.val[0], a0.val[1], r1); r2 = glmm_fnmadd(a3.val[1], a0.val[1], r2); r3 = glmm_fnmadd(a3.val[1], a1.val[0], r3); r0 = glmm_fmadd(a4.val[1], a2.val[1], r0); r1 = glmm_fmadd(a4.val[1], a1.val[0], r1); r2 = glmm_fmadd(a4.val[1], a2.val[0], r2); r3 = glmm_fmadd(a4.val[0], a2.val[0], r3); /* 4xor may be fastart then 4mul, see above */ r0 = glmm_xor(r0, s1); r1 = glmm_xor(r1, s2); r2 = glmm_xor(r2, s1); r3 = glmm_xor(r3, s2); glmm_store(dest[0], r0); glmm_store(dest[1], r1); glmm_store(dest[2], r2); glmm_store(dest[3], r3); } #endif #endif /* cglm_mat4_neon_h */ cglm-0.9.6/include/cglm/simd/neon/quat.h000066400000000000000000000024451475344456400200600ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ #ifndef cglm_quat_neon_h #define cglm_quat_neon_h #if defined(CGLM_NEON_FP) #include "../../common.h" #include "../intrin.h" CGLM_INLINE void glm_quat_mul_neon(versor p, versor q, versor dest) { /* + (a1 b2 + b1 a2 + c1 d2 − d1 c2)i + (a1 c2 − b1 d2 + c1 a2 + d1 b2)j + (a1 d2 + b1 c2 − c1 b2 + d1 a2)k a1 a2 − b1 b2 − c1 c2 − d1 d2 */ glmm_128 xp, xq, xqr, r, x, y, z, s2, s3; glmm_128 s1 = glmm_float32x4_SIGNMASK_NPPN; float32x2_t qh, ql; xp = glmm_load(p); /* 3 2 1 0 */ xq = glmm_load(q); r = vmulq_f32(glmm_splat_w(xp), xq); x = glmm_splat_x(xp); y = glmm_splat_y(xp); z = glmm_splat_z(xp); ql = vget_high_f32(s1); s3 = vcombine_f32(ql, ql); s2 = vzipq_f32(s3, s3).val[0]; xqr = vrev64q_f32(xq); qh = vget_high_f32(xqr); ql = vget_low_f32(xqr); r = glmm_fmadd(glmm_xor(x, s3), vcombine_f32(qh, ql), r); r = glmm_fmadd(glmm_xor(y, s2), vcombine_f32(vget_high_f32(xq), vget_low_f32(xq)), r); r = glmm_fmadd(glmm_xor(z, s1), vcombine_f32(ql, qh), r); glmm_store(dest, r); } #endif #endif /* cglm_quat_neon_h */ cglm-0.9.6/include/cglm/simd/sse2/000077500000000000000000000000001475344456400166455ustar00rootroot00000000000000cglm-0.9.6/include/cglm/simd/sse2/affine.h000066400000000000000000000054071475344456400202540ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ #ifndef cglm_affine_mat_sse2_h #define cglm_affine_mat_sse2_h #if defined( __SSE__ ) || defined( __SSE2__ ) #include "../../common.h" #include "../intrin.h" CGLM_INLINE void glm_mul_sse2(mat4 m1, mat4 m2, mat4 dest) { /* D = R * L (Column-Major) */ glmm_128 l, r0, r1, r2, r3, v0, v1, v2, v3; l = glmm_load(m1[0]); r0 = glmm_load(m2[0]); r1 = glmm_load(m2[1]); r2 = glmm_load(m2[2]); r3 = glmm_load(m2[3]); v0 = _mm_mul_ps(glmm_splat_x(r0), l); v1 = _mm_mul_ps(glmm_splat_x(r1), l); v2 = _mm_mul_ps(glmm_splat_x(r2), l); v3 = _mm_mul_ps(glmm_splat_x(r3), l); l = glmm_load(m1[1]); v0 = glmm_fmadd(glmm_splat_y(r0), l, v0); v1 = glmm_fmadd(glmm_splat_y(r1), l, v1); v2 = glmm_fmadd(glmm_splat_y(r2), l, v2); v3 = glmm_fmadd(glmm_splat_y(r3), l, v3); l = glmm_load(m1[2]); v0 = glmm_fmadd(glmm_splat_z(r0), l, v0); v1 = glmm_fmadd(glmm_splat_z(r1), l, v1); v2 = glmm_fmadd(glmm_splat_z(r2), l, v2); v3 = glmm_fmadd(glmm_splat_z(r3), l, v3); l = glmm_load(m1[3]); v3 = glmm_fmadd(glmm_splat_w(r3), l, v3); glmm_store(dest[0], v0); glmm_store(dest[1], v1); glmm_store(dest[2], v2); glmm_store(dest[3], v3); } CGLM_INLINE void glm_mul_rot_sse2(mat4 m1, mat4 m2, mat4 dest) { /* D = R * L (Column-Major) */ glmm_128 l, r0, r1, r2, v0, v1, v2; l = glmm_load(m1[0]); r0 = glmm_load(m2[0]); r1 = glmm_load(m2[1]); r2 = glmm_load(m2[2]); v0 = _mm_mul_ps(glmm_splat_x(r0), l); v1 = _mm_mul_ps(glmm_splat_x(r1), l); v2 = _mm_mul_ps(glmm_splat_x(r2), l); l = glmm_load(m1[1]); v0 = glmm_fmadd(glmm_splat_y(r0), l, v0); v1 = glmm_fmadd(glmm_splat_y(r1), l, v1); v2 = glmm_fmadd(glmm_splat_y(r2), l, v2); l = glmm_load(m1[2]); v0 = glmm_fmadd(glmm_splat_z(r0), l, v0); v1 = glmm_fmadd(glmm_splat_z(r1), l, v1); v2 = glmm_fmadd(glmm_splat_z(r2), l, v2); glmm_store(dest[0], v0); glmm_store(dest[1], v1); glmm_store(dest[2], v2); glmm_store(dest[3], glmm_load(m1[3])); } CGLM_INLINE void glm_inv_tr_sse2(mat4 mat) { __m128 r0, r1, r2, r3, x0, x1, x2, x3, x4, x5; r0 = glmm_load(mat[0]); r1 = glmm_load(mat[1]); r2 = glmm_load(mat[2]); r3 = glmm_load(mat[3]); x1 = _mm_set_ps(1.0f, 0.0f, 0.0f, 0.0f); _MM_TRANSPOSE4_PS(r0, r1, r2, x1); x2 = glmm_shuff1(r3, 0, 0, 0, 0); x3 = glmm_shuff1(r3, 1, 1, 1, 1); x4 = glmm_shuff1(r3, 2, 2, 2, 2); x5 = glmm_float32x4_SIGNMASK_NEG; x0 = glmm_fmadd(r0, x2, glmm_fmadd(r1, x3, _mm_mul_ps(r2, x4))); x0 = _mm_xor_ps(x0, x5); x0 = _mm_add_ps(x0, x1); glmm_store(mat[0], r0); glmm_store(mat[1], r1); glmm_store(mat[2], r2); glmm_store(mat[3], x0); } #endif #endif /* cglm_affine_mat_sse2_h */ cglm-0.9.6/include/cglm/simd/sse2/mat2.h000066400000000000000000000017641475344456400176710ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ #ifndef cglm_mat2_sse_h #define cglm_mat2_sse_h #if defined( __SSE__ ) || defined( __SSE2__ ) #include "../../common.h" #include "../intrin.h" CGLM_INLINE void glm_mat2_mul_sse2(mat2 m1, mat2 m2, mat2 dest) { __m128 x0, x1, x2, x3, x4; x1 = glmm_load(m1[0]); /* d c b a */ x2 = glmm_load(m2[0]); /* h g f e */ x3 = glmm_shuff1(x2, 2, 2, 0, 0); x4 = glmm_shuff1(x2, 3, 3, 1, 1); x0 = _mm_movelh_ps(x1, x1); x2 = _mm_movehl_ps(x1, x1); /* dest[0][0] = a * e + c * f; dest[0][1] = b * e + d * f; dest[1][0] = a * g + c * h; dest[1][1] = b * g + d * h; */ x0 = glmm_fmadd(x0, x3, _mm_mul_ps(x2, x4)); glmm_store(dest[0], x0); } CGLM_INLINE void glm_mat2_transp_sse2(mat2 m, mat2 dest) { /* d c b a */ /* d b c a */ glmm_store(dest[0], glmm_shuff1(glmm_load(m[0]), 3, 1, 2, 0)); } #endif #endif /* cglm_mat2_sse_h */ cglm-0.9.6/include/cglm/simd/sse2/mat3.h000066400000000000000000000055321475344456400176670ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ #ifndef cglm_mat3_sse_h #define cglm_mat3_sse_h #if defined( __SSE__ ) || defined( __SSE2__ ) #include "../../common.h" #include "../intrin.h" CGLM_INLINE void glm_mat3_mul_sse2(mat3 m1, mat3 m2, mat3 dest) { __m128 l0, l1, l2, r0, r1, r2, x0, x1, x2, x3, x4, x5, x6, x7, x8, x9; l0 = _mm_loadu_ps(m1[0]); l1 = _mm_loadu_ps(&m1[1][1]); r0 = _mm_loadu_ps(m2[0]); r1 = _mm_loadu_ps(&m2[1][1]); x8 = glmm_shuff1(l0, 0, 2, 1, 0); /* a00 a02 a01 a00 */ x1 = glmm_shuff1(r0, 3, 0, 0, 0); /* b10 b00 b00 b00 */ x2 = _mm_shuffle_ps(l0, l1, _MM_SHUFFLE(1, 0, 3, 3)); /* a12 a11 a10 a10 */ x3 = _mm_shuffle_ps(r0, r1, _MM_SHUFFLE(2, 0, 3, 1)); /* b20 b11 b10 b01 */ x0 = _mm_mul_ps(x8, x1); x6 = glmm_shuff1(l0, 1, 0, 2, 1); /* a01 a00 a02 a01 */ x7 = glmm_shuff1(x3, 3, 3, 1, 1); /* b20 b20 b10 b10 */ l2 = _mm_load_ss(&m1[2][2]); r2 = _mm_load_ss(&m2[2][2]); x1 = _mm_mul_ps(x6, x7); l2 = glmm_shuff1(l2, 0, 0, 1, 0); /* a22 a22 0.f a22 */ r2 = glmm_shuff1(r2, 0, 0, 1, 0); /* b22 b22 0.f b22 */ x4 = glmm_shuff1(x2, 0, 3, 2, 0); /* a10 a12 a11 a10 */ x5 = glmm_shuff1(x2, 2, 0, 3, 2); /* a11 a10 a12 a11 */ x6 = glmm_shuff1(x3, 2, 0, 0, 0); /* b11 b01 b01 b01 */ x2 = glmm_shuff1(r1, 3, 3, 0, 0); /* b21 b21 b11 b11 */ x8 = _mm_unpackhi_ps(x8, x4); /* a10 a00 a12 a02 */ x9 = _mm_unpackhi_ps(x7, x2); /* b21 b20 b21 b20 */ x0 = glmm_fmadd(x4, x6, x0); x1 = glmm_fmadd(x5, x2, x1); x2 = _mm_movehl_ps(l2, l1); /* a22 a22 a21 a20 */ x3 = glmm_shuff1(x2, 0, 2, 1, 0); /* a20 a22 a21 a20 */ x2 = glmm_shuff1(x2, 1, 0, 2, 1); /* a21 a20 a22 a21 */ x4 = _mm_shuffle_ps(r0, r1, _MM_SHUFFLE(1, 1, 2, 2)); /* b12 b12 b02 b02 */ x5 = glmm_shuff1(x4, 3, 0, 0, 0); /* b12 b02 b02 b02 */ x4 = _mm_movehl_ps(r2, x4); /* b22 b22 b12 b12 */ x0 = glmm_fmadd(x3, x5, x0); x1 = glmm_fmadd(x2, x4, x1); /* Dot Product : dest[2][2] = a02 * b20 + a12 * b21 + a22 * b22 + 0 * 00 */ x2 = _mm_movelh_ps(x8, l2); /* 0.f a22 a12 a02 */ x3 = _mm_movelh_ps(x9, r2); /* 0.f b22 b21 b20 */ x2 = glmm_vdots(x2, x3); _mm_storeu_ps(&dest[0][0], x0); _mm_storeu_ps(&dest[1][1], x1); _mm_store_ss (&dest[2][2], x2); } #endif #endif /* cglm_mat3_sse_h */ cglm-0.9.6/include/cglm/simd/sse2/mat4.h000066400000000000000000000421461475344456400176720ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ #ifndef cglm_mat_sse_h #define cglm_mat_sse_h #if defined( __SSE__ ) || defined( __SSE2__ ) #include "../../common.h" #include "../intrin.h" #define glm_mat4_inv_precise_sse2(mat, dest) glm_mat4_inv_sse2(mat, dest) CGLM_INLINE void glm_mat4_scale_sse2(mat4 m, float s) { __m128 x0; x0 = glmm_set1(s); glmm_store(m[0], _mm_mul_ps(glmm_load(m[0]), x0)); glmm_store(m[1], _mm_mul_ps(glmm_load(m[1]), x0)); glmm_store(m[2], _mm_mul_ps(glmm_load(m[2]), x0)); glmm_store(m[3], _mm_mul_ps(glmm_load(m[3]), x0)); } CGLM_INLINE void glm_mat4_transp_sse2(mat4 m, mat4 dest) { __m128 r0, r1, r2, r3; r0 = glmm_load(m[0]); r1 = glmm_load(m[1]); r2 = glmm_load(m[2]); r3 = glmm_load(m[3]); _MM_TRANSPOSE4_PS(r0, r1, r2, r3); glmm_store(dest[0], r0); glmm_store(dest[1], r1); glmm_store(dest[2], r2); glmm_store(dest[3], r3); } CGLM_INLINE void glm_mat4_mul_sse2(mat4 m1, mat4 m2, mat4 dest) { /* D = R * L (Column-Major) */ glmm_128 l, r0, r1, r2, r3, v0, v1, v2, v3; l = glmm_load(m1[0]); r0 = glmm_load(m2[0]); r1 = glmm_load(m2[1]); r2 = glmm_load(m2[2]); r3 = glmm_load(m2[3]); v0 = _mm_mul_ps(glmm_splat_x(r0), l); v1 = _mm_mul_ps(glmm_splat_x(r1), l); v2 = _mm_mul_ps(glmm_splat_x(r2), l); v3 = _mm_mul_ps(glmm_splat_x(r3), l); l = glmm_load(m1[1]); v0 = glmm_fmadd(glmm_splat_y(r0), l, v0); v1 = glmm_fmadd(glmm_splat_y(r1), l, v1); v2 = glmm_fmadd(glmm_splat_y(r2), l, v2); v3 = glmm_fmadd(glmm_splat_y(r3), l, v3); l = glmm_load(m1[2]); v0 = glmm_fmadd(glmm_splat_z(r0), l, v0); v1 = glmm_fmadd(glmm_splat_z(r1), l, v1); v2 = glmm_fmadd(glmm_splat_z(r2), l, v2); v3 = glmm_fmadd(glmm_splat_z(r3), l, v3); l = glmm_load(m1[3]); v0 = glmm_fmadd(glmm_splat_w(r0), l, v0); v1 = glmm_fmadd(glmm_splat_w(r1), l, v1); v2 = glmm_fmadd(glmm_splat_w(r2), l, v2); v3 = glmm_fmadd(glmm_splat_w(r3), l, v3); glmm_store(dest[0], v0); glmm_store(dest[1], v1); glmm_store(dest[2], v2); glmm_store(dest[3], v3); } CGLM_INLINE void glm_mat4_mulv_sse2(mat4 m, vec4 v, vec4 dest) { __m128 x0, x1, m0, m1, m2, m3, v0, v1, v2, v3; m0 = glmm_load(m[0]); m1 = glmm_load(m[1]); m2 = glmm_load(m[2]); m3 = glmm_load(m[3]); x0 = glmm_load(v); v0 = glmm_splat_x(x0); v1 = glmm_splat_y(x0); v2 = glmm_splat_z(x0); v3 = glmm_splat_w(x0); x1 = _mm_mul_ps(m3, v3); x1 = glmm_fmadd(m2, v2, x1); x1 = glmm_fmadd(m1, v1, x1); x1 = glmm_fmadd(m0, v0, x1); glmm_store(dest, x1); } CGLM_INLINE float glm_mat4_det_sse2(mat4 mat) { __m128 r0, r1, r2, r3, x0, x1, x2; /* 127 <- 0, [square] det(A) = det(At) */ r0 = glmm_load(mat[0]); /* d c b a */ r1 = glmm_load(mat[1]); /* h g f e */ r2 = glmm_load(mat[2]); /* l k j i */ r3 = glmm_load(mat[3]); /* p o n m */ /* t[1] = j * p - n * l; t[2] = j * o - n * k; t[3] = i * p - m * l; t[4] = i * o - m * k; */ x0 = glmm_fnmadd(glmm_shuff1(r3, 0, 0, 1, 1), glmm_shuff1(r2, 2, 3, 2, 3), _mm_mul_ps(glmm_shuff1(r2, 0, 0, 1, 1), glmm_shuff1(r3, 2, 3, 2, 3))); /* t[0] = k * p - o * l; t[0] = k * p - o * l; t[5] = i * n - m * j; t[5] = i * n - m * j; */ x1 = glmm_fnmadd(glmm_shuff1(r3, 0, 0, 2, 2), glmm_shuff1(r2, 1, 1, 3, 3), _mm_mul_ps(glmm_shuff1(r2, 0, 0, 2, 2), glmm_shuff1(r3, 1, 1, 3, 3))); /* a * (f * t[0] - g * t[1] + h * t[2]) - b * (e * t[0] - g * t[3] + h * t[4]) + c * (e * t[1] - f * t[3] + h * t[5]) - d * (e * t[2] - f * t[4] + g * t[5]) */ x2 = glmm_fnmadd(glmm_shuff1(r1, 1, 1, 2, 2), glmm_shuff1(x0, 3, 2, 2, 0), _mm_mul_ps(glmm_shuff1(r1, 0, 0, 0, 1), _mm_shuffle_ps(x1, x0, _MM_SHUFFLE(1, 0, 0, 0)))); x2 = glmm_fmadd(glmm_shuff1(r1, 2, 3, 3, 3), _mm_shuffle_ps(x0, x1, _MM_SHUFFLE(2, 2, 3, 1)), x2); x2 = _mm_xor_ps(x2, glmm_float32x4_SIGNMASK_NPNP); return glmm_hadd(_mm_mul_ps(x2, r0)); } CGLM_INLINE void glm_mat4_inv_fast_sse2(mat4 mat, mat4 dest) { __m128 r0, r1, r2, r3, v0, v1, v2, v3, t0, t1, t2, t3, t4, t5, x0, x1, x2, x3, x4, x5, x6, x7, x8, x9; /* x8 = _mm_set_ps(-0.f, 0.f, -0.f, 0.f); */ x8 = glmm_float32x4_SIGNMASK_NPNP; x9 = glmm_shuff1(x8, 2, 1, 2, 1); /* 127 <- 0 */ r0 = glmm_load(mat[0]); /* d c b a */ r1 = glmm_load(mat[1]); /* h g f e */ r2 = glmm_load(mat[2]); /* l k j i */ r3 = glmm_load(mat[3]); /* p o n m */ x0 = _mm_movehl_ps(r3, r2); /* p o l k */ x3 = _mm_movelh_ps(r2, r3); /* n m j i */ x1 = glmm_shuff1(x0, 1, 3, 3 ,3); /* l p p p */ x2 = glmm_shuff1(x0, 0, 2, 2, 2); /* k o o o */ x4 = glmm_shuff1(x3, 1, 3, 3, 3); /* j n n n */ x7 = glmm_shuff1(x3, 0, 2, 2, 2); /* i m m m */ x6 = _mm_shuffle_ps(r2, r1, _MM_SHUFFLE(0, 0, 0, 0)); /* e e i i */ x5 = _mm_shuffle_ps(r2, r1, _MM_SHUFFLE(1, 1, 1, 1)); /* f f j j */ x3 = _mm_shuffle_ps(r2, r1, _MM_SHUFFLE(2, 2, 2, 2)); /* g g k k */ x0 = _mm_shuffle_ps(r2, r1, _MM_SHUFFLE(3, 3, 3, 3)); /* h h l l */ t0 = _mm_mul_ps(x3, x1); t1 = _mm_mul_ps(x5, x1); t2 = _mm_mul_ps(x5, x2); t3 = _mm_mul_ps(x6, x1); t4 = _mm_mul_ps(x6, x2); t5 = _mm_mul_ps(x6, x4); /* t1[0] = k * p - o * l; t1[0] = k * p - o * l; t2[0] = g * p - o * h; t3[0] = g * l - k * h; */ t0 = glmm_fnmadd(x2, x0, t0); /* t1[1] = j * p - n * l; t1[1] = j * p - n * l; t2[1] = f * p - n * h; t3[1] = f * l - j * h; */ t1 = glmm_fnmadd(x4, x0, t1); /* t1[2] = j * o - n * k t1[2] = j * o - n * k; t2[2] = f * o - n * g; t3[2] = f * k - j * g; */ t2 = glmm_fnmadd(x4, x3, t2); /* t1[3] = i * p - m * l; t1[3] = i * p - m * l; t2[3] = e * p - m * h; t3[3] = e * l - i * h; */ t3 = glmm_fnmadd(x7, x0, t3); /* t1[4] = i * o - m * k; t1[4] = i * o - m * k; t2[4] = e * o - m * g; t3[4] = e * k - i * g; */ t4 = glmm_fnmadd(x7, x3, t4); /* t1[5] = i * n - m * j; t1[5] = i * n - m * j; t2[5] = e * n - m * f; t3[5] = e * j - i * f; */ t5 = glmm_fnmadd(x7, x5, t5); x4 = _mm_movelh_ps(r0, r1); /* f e b a */ x5 = _mm_movehl_ps(r1, r0); /* h g d c */ x0 = glmm_shuff1(x4, 0, 0, 0, 2); /* a a a e */ x1 = glmm_shuff1(x4, 1, 1, 1, 3); /* b b b f */ x2 = glmm_shuff1(x5, 0, 0, 0, 2); /* c c c g */ x3 = glmm_shuff1(x5, 1, 1, 1, 3); /* d d d h */ v2 = _mm_mul_ps(x0, t1); v1 = _mm_mul_ps(x0, t0); v3 = _mm_mul_ps(x0, t2); v0 = _mm_mul_ps(x1, t0); v2 = glmm_fnmadd(x1, t3, v2); v3 = glmm_fnmadd(x1, t4, v3); v0 = glmm_fnmadd(x2, t1, v0); v1 = glmm_fnmadd(x2, t3, v1); v3 = glmm_fmadd(x2, t5, v3); v0 = glmm_fmadd(x3, t2, v0); v2 = glmm_fmadd(x3, t5, v2); v1 = glmm_fmadd(x3, t4, v1); /* dest[0][0] = f * t1[0] - g * t1[1] + h * t1[2]; dest[0][1] =-(b * t1[0] - c * t1[1] + d * t1[2]); dest[0][2] = b * t2[0] - c * t2[1] + d * t2[2]; dest[0][3] =-(b * t3[0] - c * t3[1] + d * t3[2]); */ v0 = _mm_xor_ps(v0, x8); /* dest[2][0] = e * t1[1] - f * t1[3] + h * t1[5]; dest[2][1] =-(a * t1[1] - b * t1[3] + d * t1[5]); dest[2][2] = a * t2[1] - b * t2[3] + d * t2[5]; dest[2][3] =-(a * t3[1] - b * t3[3] + d * t3[5]);*/ v2 = _mm_xor_ps(v2, x8); /* dest[1][0] =-(e * t1[0] - g * t1[3] + h * t1[4]); dest[1][1] = a * t1[0] - c * t1[3] + d * t1[4]; dest[1][2] =-(a * t2[0] - c * t2[3] + d * t2[4]); dest[1][3] = a * t3[0] - c * t3[3] + d * t3[4]; */ v1 = _mm_xor_ps(v1, x9); /* dest[3][0] =-(e * t1[2] - f * t1[4] + g * t1[5]); dest[3][1] = a * t1[2] - b * t1[4] + c * t1[5]; dest[3][2] =-(a * t2[2] - b * t2[4] + c * t2[5]); dest[3][3] = a * t3[2] - b * t3[4] + c * t3[5]; */ v3 = _mm_xor_ps(v3, x9); /* determinant */ x0 = _mm_shuffle_ps(v0, v1, _MM_SHUFFLE(0, 0, 0, 0)); x1 = _mm_shuffle_ps(v2, v3, _MM_SHUFFLE(0, 0, 0, 0)); x0 = _mm_shuffle_ps(x0, x1, _MM_SHUFFLE(2, 0, 2, 0)); x0 = _mm_rcp_ps(glmm_vhadd(_mm_mul_ps(x0, r0))); glmm_store(dest[0], _mm_mul_ps(v0, x0)); glmm_store(dest[1], _mm_mul_ps(v1, x0)); glmm_store(dest[2], _mm_mul_ps(v2, x0)); glmm_store(dest[3], _mm_mul_ps(v3, x0)); } /* old one */ #if 0 CGLM_INLINE void glm_mat4_inv_sse2(mat4 mat, mat4 dest) { __m128 r0, r1, r2, r3, v0, v1, v2, v3, t0, t1, t2, t3, t4, t5, x0, x1, x2, x3, x4, x5, x6, x7, x8, x9; /* x8 = _mm_set_ps(-0.f, 0.f, -0.f, 0.f); */ x8 = glmm_float32x4_SIGNMASK_NPNP; x9 = glmm_shuff1(x8, 2, 1, 2, 1); /* 127 <- 0 */ r0 = glmm_load(mat[0]); /* d c b a */ r1 = glmm_load(mat[1]); /* h g f e */ r2 = glmm_load(mat[2]); /* l k j i */ r3 = glmm_load(mat[3]); /* p o n m */ x0 = _mm_movehl_ps(r3, r2); /* p o l k */ x3 = _mm_movelh_ps(r2, r3); /* n m j i */ x1 = glmm_shuff1(x0, 1, 3, 3 ,3); /* l p p p */ x2 = glmm_shuff1(x0, 0, 2, 2, 2); /* k o o o */ x4 = glmm_shuff1(x3, 1, 3, 3, 3); /* j n n n */ x7 = glmm_shuff1(x3, 0, 2, 2, 2); /* i m m m */ x6 = _mm_shuffle_ps(r2, r1, _MM_SHUFFLE(0, 0, 0, 0)); /* e e i i */ x5 = _mm_shuffle_ps(r2, r1, _MM_SHUFFLE(1, 1, 1, 1)); /* f f j j */ x3 = _mm_shuffle_ps(r2, r1, _MM_SHUFFLE(2, 2, 2, 2)); /* g g k k */ x0 = _mm_shuffle_ps(r2, r1, _MM_SHUFFLE(3, 3, 3, 3)); /* h h l l */ t0 = _mm_mul_ps(x3, x1); t1 = _mm_mul_ps(x5, x1); t2 = _mm_mul_ps(x5, x2); t3 = _mm_mul_ps(x6, x1); t4 = _mm_mul_ps(x6, x2); t5 = _mm_mul_ps(x6, x4); /* t1[0] = k * p - o * l; t1[0] = k * p - o * l; t2[0] = g * p - o * h; t3[0] = g * l - k * h; */ t0 = glmm_fnmadd(x2, x0, t0); /* t1[1] = j * p - n * l; t1[1] = j * p - n * l; t2[1] = f * p - n * h; t3[1] = f * l - j * h; */ t1 = glmm_fnmadd(x4, x0, t1); /* t1[2] = j * o - n * k t1[2] = j * o - n * k; t2[2] = f * o - n * g; t3[2] = f * k - j * g; */ t2 = glmm_fnmadd(x4, x3, t2); /* t1[3] = i * p - m * l; t1[3] = i * p - m * l; t2[3] = e * p - m * h; t3[3] = e * l - i * h; */ t3 = glmm_fnmadd(x7, x0, t3); /* t1[4] = i * o - m * k; t1[4] = i * o - m * k; t2[4] = e * o - m * g; t3[4] = e * k - i * g; */ t4 = glmm_fnmadd(x7, x3, t4); /* t1[5] = i * n - m * j; t1[5] = i * n - m * j; t2[5] = e * n - m * f; t3[5] = e * j - i * f; */ t5 = glmm_fnmadd(x7, x5, t5); x4 = _mm_movelh_ps(r0, r1); /* f e b a */ x5 = _mm_movehl_ps(r1, r0); /* h g d c */ x0 = glmm_shuff1(x4, 0, 0, 0, 2); /* a a a e */ x1 = glmm_shuff1(x4, 1, 1, 1, 3); /* b b b f */ x2 = glmm_shuff1(x5, 0, 0, 0, 2); /* c c c g */ x3 = glmm_shuff1(x5, 1, 1, 1, 3); /* d d d h */ v2 = _mm_mul_ps(x0, t1); v1 = _mm_mul_ps(x0, t0); v3 = _mm_mul_ps(x0, t2); v0 = _mm_mul_ps(x1, t0); v2 = glmm_fnmadd(x1, t3, v2); v3 = glmm_fnmadd(x1, t4, v3); v0 = glmm_fnmadd(x2, t1, v0); v1 = glmm_fnmadd(x2, t3, v1); v3 = glmm_fmadd(x2, t5, v3); v0 = glmm_fmadd(x3, t2, v0); v2 = glmm_fmadd(x3, t5, v2); v1 = glmm_fmadd(x3, t4, v1); /* dest[0][0] = f * t1[0] - g * t1[1] + h * t1[2]; dest[0][1] =-(b * t1[0] - c * t1[1] + d * t1[2]); dest[0][2] = b * t2[0] - c * t2[1] + d * t2[2]; dest[0][3] =-(b * t3[0] - c * t3[1] + d * t3[2]); */ v0 = _mm_xor_ps(v0, x8); /* dest[2][0] = e * t1[1] - f * t1[3] + h * t1[5]; dest[2][1] =-(a * t1[1] - b * t1[3] + d * t1[5]); dest[2][2] = a * t2[1] - b * t2[3] + d * t2[5]; dest[2][3] =-(a * t3[1] - b * t3[3] + d * t3[5]);*/ v2 = _mm_xor_ps(v2, x8); /* dest[1][0] =-(e * t1[0] - g * t1[3] + h * t1[4]); dest[1][1] = a * t1[0] - c * t1[3] + d * t1[4]; dest[1][2] =-(a * t2[0] - c * t2[3] + d * t2[4]); dest[1][3] = a * t3[0] - c * t3[3] + d * t3[4]; */ v1 = _mm_xor_ps(v1, x9); /* dest[3][0] =-(e * t1[2] - f * t1[4] + g * t1[5]); dest[3][1] = a * t1[2] - b * t1[4] + c * t1[5]; dest[3][2] =-(a * t2[2] - b * t2[4] + c * t2[5]); dest[3][3] = a * t3[2] - b * t3[4] + c * t3[5]; */ v3 = _mm_xor_ps(v3, x9); /* determinant */ x0 = _mm_shuffle_ps(v0, v1, _MM_SHUFFLE(0, 0, 0, 0)); x1 = _mm_shuffle_ps(v2, v3, _MM_SHUFFLE(0, 0, 0, 0)); x0 = _mm_shuffle_ps(x0, x1, _MM_SHUFFLE(2, 0, 2, 0)); x0 = _mm_div_ps(glmm_set1(1.0f), glmm_vhadd(_mm_mul_ps(x0, r0))); glmm_store(dest[0], _mm_mul_ps(v0, x0)); glmm_store(dest[1], _mm_mul_ps(v1, x0)); glmm_store(dest[2], _mm_mul_ps(v2, x0)); glmm_store(dest[3], _mm_mul_ps(v3, x0)); } #endif CGLM_INLINE void glm_mat4_inv_sse2(mat4 mat, mat4 dest) { __m128 r0, r1, r2, r3, s1, s2, v0, v1, v2, v3, v4, v5, t0, t1, t2, x0, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13; /* s1 = _mm_set_ps(-0.f, 0.f, -0.f, 0.f); */ s1 = glmm_float32x4_SIGNMASK_NPNP; s2 = glmm_shuff1(s1, 2, 1, 2, 1); /* 127 <- 0 */ r1 = glmm_load(mat[1]); /* h g f e */ r0 = glmm_load(mat[0]); /* d c b a */ r3 = glmm_load(mat[3]); /* p o n m */ r2 = glmm_load(mat[2]); /* l k j i */ x4 = _mm_unpackhi_ps(r0, r2); /* l d k c */ x5 = _mm_unpacklo_ps(r0, r2); /* j b i a */ x6 = _mm_unpackhi_ps(r1, r3); /* p h o g */ x7 = _mm_unpacklo_ps(r1, r3); /* n f m e */ x0 = _mm_unpackhi_ps(x7, x5); /* j n b f */ x1 = _mm_unpacklo_ps(x7, x5); /* i m a e */ x2 = _mm_unpackhi_ps(x6, x4); /* l p d h */ x3 = _mm_unpacklo_ps(x6, x4); /* k o c g */ /* c2 = c * h - d * g c12 = a * g - c * e c8 = a * f - b * e c1 = k * p - l * o c11 = i * o - k * m c7 = i * n - j * m c4 = a * h - d * e c6 = b * h - d * f c10 = b * g - c * f c3 = i * p - l * m c5 = j * p - l * n c9 = j * o - k * n */ x8 = _mm_shuffle_ps(x0, x3, _MM_SHUFFLE(3, 1, 3, 1)); /* k c j b */ x9 = _mm_shuffle_ps(x0, x3, _MM_SHUFFLE(2, 0, 2, 0)); /* o g n f */ x10 = glmm_shuff1(x2, 2, 0, 2, 0); /* p h p h */ x11 = glmm_shuff1(x2, 3, 1, 3, 1); /* l d l d */ #if 0 /* TODO measure both */ x12 = _mm_shuffle_ps(x4, x5, _MM_SHUFFLE(1, 0, 1, 0)); /* i a k c */ x13 = _mm_shuffle_ps(x6, x7, _MM_SHUFFLE(1, 0, 1, 0)); /* m e o g */ #else x12 = _mm_movelh_ps(x4, x5); /* i a k c */ x13 = _mm_movelh_ps(x6, x7); /* m e o g */ #endif t0 = _mm_mul_ps(x12, x10); t1 = _mm_mul_ps(x5, x6); t2 = _mm_mul_ps(x5, x9); t0 = glmm_fnmadd(x11, x13, t0); t1 = glmm_fnmadd(x4, x7, t1); t2 = glmm_fnmadd(x8, x7, t2); /* det */ /* v0: c3 * c10 + c4 * c9 + c1 * c8 + c2 * c7 */ /* v1: c5 * c12 + c6 * c11 */ v5 = glmm_set1_rval(1.0f); v0 = glmm_shuff1(t2, 2, 3, 0, 1); v1 = glmm_shuff1(t1, 0, 1, 2, 3); v0 = _mm_mul_ps(t0, v0); v1 = _mm_mul_ps(t1, v1); v2 = glmm_shuff1(v1, 1, 0, 0, 1); v3 = glmm_shuff1(v0, 0, 1, 2, 3); v1 = _mm_add_ps(v1, v2); v0 = _mm_add_ps(v0, v3); v2 = glmm_shuff1(v0, 1, 0, 0, 1); v0 = _mm_add_ps(v0, v2); v0 = _mm_sub_ps(v0, v1); /* det */ v0 = _mm_div_ps(v5, v0); /* idt */ /* multiply t0,t1,t2 by idt to reduce 1mul below: 2eor+4mul vs 3mul+4eor */ t0 = _mm_mul_ps(t0, v0); t1 = _mm_mul_ps(t1, v0); t2 = _mm_mul_ps(t2, v0); v0 = glmm_shuff1(t0, 0, 0, 1, 1); /* c2 c2 c1 c1 */ v1 = glmm_shuff1(t0, 2, 2, 3, 3); /* c4 c4 c3 c3 */ v2 = glmm_shuff1(t1, 0, 0, 1, 1); /* c12 c12 c11 c11 */ v3 = glmm_shuff1(t1, 2, 2, 3, 3); /* c6 c6 c5 c5 */ v4 = glmm_shuff1(t2, 0, 0, 1, 1); /* c8 c8 c7 c7 */ v5 = glmm_shuff1(t2, 2, 2, 3, 3); /* c10 c10 c9 c9 */ /* result */ /* dest[0][0] = (f * c1 - g * c5 + h * c9) * idt; dest[0][1] = (b * c1 - c * c5 + d * c9) * ndt; dest[0][2] = (n * c2 - o * c6 + p * c10) * idt; dest[0][3] = (j * c2 - k * c6 + l * c10) * ndt; dest[1][0] = (e * c1 - g * c3 + h * c11) * ndt; dest[1][1] = (a * c1 - c * c3 + d * c11) * idt; dest[1][2] = (m * c2 - o * c4 + p * c12) * ndt; dest[1][3] = (i * c2 - k * c4 + l * c12) * idt; dest[2][0] = (e * c5 - f * c3 + h * c7) * idt; dest[2][1] = (a * c5 - b * c3 + d * c7) * ndt; dest[2][2] = (m * c6 - n * c4 + p * c8) * idt; dest[2][3] = (i * c6 - j * c4 + l * c8) * ndt; dest[3][0] = (e * c9 - f * c11 + g * c7) * ndt; dest[3][1] = (a * c9 - b * c11 + c * c7) * idt; dest[3][2] = (m * c10 - n * c12 + o * c8) * ndt; dest[3][3] = (i * c10 - j * c12 + k * c8) * idt; */ r0 = _mm_mul_ps(x0, v0); r1 = _mm_mul_ps(x1, v0); r2 = _mm_mul_ps(x1, v3); r3 = _mm_mul_ps(x1, v5); r0 = glmm_fnmadd(x3, v3, r0); r1 = glmm_fnmadd(x3, v1, r1); r2 = glmm_fnmadd(x0, v1, r2); r3 = glmm_fnmadd(x0, v2, r3); r0 = glmm_fmadd(x2, v5, r0); r1 = glmm_fmadd(x2, v2, r1); r2 = glmm_fmadd(x2, v4, r2); r3 = glmm_fmadd(x3, v4, r3); /* 4xor may be fastart then 4mul, see above */ r0 = _mm_xor_ps(r0, s1); r1 = _mm_xor_ps(r1, s2); r2 = _mm_xor_ps(r2, s1); r3 = _mm_xor_ps(r3, s2); glmm_store(dest[0], r0); glmm_store(dest[1], r1); glmm_store(dest[2], r2); glmm_store(dest[3], r3); } #endif #endif /* cglm_mat_sse_h */ cglm-0.9.6/include/cglm/simd/sse2/quat.h000066400000000000000000000023311475344456400177670ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ #ifndef cglm_quat_simd_h #define cglm_quat_simd_h #if defined( __SSE__ ) || defined( __SSE2__ ) #include "../../common.h" #include "../intrin.h" CGLM_INLINE void glm_quat_mul_sse2(versor p, versor q, versor dest) { /* + (a1 b2 + b1 a2 + c1 d2 − d1 c2)i + (a1 c2 − b1 d2 + c1 a2 + d1 b2)j + (a1 d2 + b1 c2 − c1 b2 + d1 a2)k a1 a2 − b1 b2 − c1 c2 − d1 d2 */ __m128 xp, xq, x1, x2, x3, r, x, y, z; xp = glmm_load(p); /* 3 2 1 0 */ xq = glmm_load(q); x1 = glmm_float32x4_SIGNMASK_NPNP; /* TODO: _mm_set1_ss() + shuff ? */ r = _mm_mul_ps(glmm_splat_w(xp), xq); x2 = _mm_unpackhi_ps(x1, x1); x3 = glmm_shuff1(x1, 3, 2, 0, 1); x = glmm_splat_x(xp); y = glmm_splat_y(xp); z = glmm_splat_z(xp); x = _mm_xor_ps(x, x1); y = _mm_xor_ps(y, x2); z = _mm_xor_ps(z, x3); x1 = glmm_shuff1(xq, 0, 1, 2, 3); x2 = glmm_shuff1(xq, 1, 0, 3, 2); x3 = glmm_shuff1(xq, 2, 3, 0, 1); r = glmm_fmadd(x, x1, r); r = glmm_fmadd(y, x2, r); r = glmm_fmadd(z, x3, r); glmm_store(dest, r); } #endif #endif /* cglm_quat_simd_h */ cglm-0.9.6/include/cglm/simd/wasm.h000066400000000000000000000115461475344456400171200ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ #ifndef cglm_simd_wasm_h #define cglm_simd_wasm_h #include "intrin.h" #ifdef CGLM_SIMD_WASM #include #define glmm_load(p) wasm_v128_load(p) #define glmm_store(p, a) wasm_v128_store(p, (a)) #define glmm_set1(x) wasm_f32x4_splat(x) #define glmm_set1_rval(x) wasm_f32x4_splat(x) #define glmm_128 v128_t #define glmm_shuff1(xmm, z, y, x, w) wasm_i32x4_shuffle(xmm, xmm, w, x, y, z) #define glmm_splat(x, lane) glmm_shuff1(x, lane, lane, lane, lane) #define glmm_splat_x(x) glmm_splat(x, 0) #define glmm_splat_y(x) glmm_splat(x, 1) #define glmm_splat_z(x) glmm_splat(x, 2) #define glmm_splat_w(x) glmm_splat(x, 3) #define GLMM_NEGZEROf 0x80000000 /* 0x80000000 ---> -0.0f */ /* _mm_set_ps(X, Y, Z, W); */ #define GLMM__SIGNMASKf(X, Y, Z, W) wasm_i32x4_const(X, Y, Z, W) #define glmm_float32x4_SIGNMASK_PNPN GLMM__SIGNMASKf(0, GLMM_NEGZEROf, 0, GLMM_NEGZEROf) #define glmm_float32x4_SIGNMASK_NPNP GLMM__SIGNMASKf(GLMM_NEGZEROf, 0, GLMM_NEGZEROf, 0) #define glmm_float32x4_SIGNMASK_NPPN GLMM__SIGNMASKf(GLMM_NEGZEROf, 0, 0, GLMM_NEGZEROf) #define glmm_float32x4_SIGNMASK_NEG wasm_i32x4_const_splat(GLMM_NEGZEROf) static inline glmm_128 glmm_abs(glmm_128 x) { return wasm_f32x4_abs(x); } static inline glmm_128 glmm_min(glmm_128 a, glmm_128 b) { return wasm_f32x4_pmin(b, a); } static inline glmm_128 glmm_max(glmm_128 a, glmm_128 b) { return wasm_f32x4_pmax(b, a); } static inline glmm_128 glmm_vhadd(glmm_128 v) { glmm_128 x0; x0 = wasm_f32x4_add(v, glmm_shuff1(v, 0, 1, 2, 3)); x0 = wasm_f32x4_add(x0, glmm_shuff1(x0, 1, 0, 0, 1)); return x0; } static inline glmm_128 glmm_vhadds(glmm_128 v) { glmm_128 shuf, sums; shuf = glmm_shuff1(v, 2, 3, 0, 1); sums = wasm_f32x4_add(v, shuf); /* shuf = _mm_movehl_ps(shuf, sums); */ shuf = wasm_i32x4_shuffle(shuf, sums, 6, 7, 2, 3); sums = wasm_i32x4_shuffle(sums, wasm_f32x4_add(sums, shuf), 4, 1, 2, 3); return sums; } static inline float glmm_hadd(glmm_128 v) { return wasm_f32x4_extract_lane(glmm_vhadds(v), 0); } static inline glmm_128 glmm_vhmin(glmm_128 v) { glmm_128 x0, x1, x2; x0 = glmm_shuff1(v, 2, 3, 2, 3); /* [2, 3, 2, 3] */ x1 = wasm_f32x4_pmin(x0, v); /* [0|2, 1|3, 2|2, 3|3] */ x2 = glmm_splat(x1, 1); /* [1|3, 1|3, 1|3, 1|3] */ return wasm_f32x4_pmin(x1, x2); } static inline float glmm_hmin(glmm_128 v) { return wasm_f32x4_extract_lane(glmm_vhmin(v), 0); } static inline glmm_128 glmm_vhmax(glmm_128 v) { glmm_128 x0, x1, x2; x0 = glmm_shuff1(v, 2, 3, 2, 3); /* [2, 3, 2, 3] */ x1 = wasm_f32x4_pmax(x0, v); /* [0|2, 1|3, 2|2, 3|3] */ x2 = glmm_splat(x1, 1); /* [1|3, 1|3, 1|3, 1|3] */ /* _mm_max_ss */ return wasm_i32x4_shuffle(x1, wasm_f32x4_pmax(x1, x2), 4, 1, 2, 3); } static inline float glmm_hmax(glmm_128 v) { return wasm_f32x4_extract_lane(glmm_vhmax(v), 0); } static inline glmm_128 glmm_vdots(glmm_128 a, glmm_128 b) { return glmm_vhadds(wasm_f32x4_mul(a, b)); } static inline glmm_128 glmm_vdot(glmm_128 a, glmm_128 b) { glmm_128 x0; x0 = wasm_f32x4_mul(a, b); x0 = wasm_f32x4_add(x0, glmm_shuff1(x0, 1, 0, 3, 2)); return wasm_f32x4_add(x0, glmm_shuff1(x0, 0, 1, 0, 1)); } static inline float glmm_dot(glmm_128 a, glmm_128 b) { return wasm_f32x4_extract_lane(glmm_vdots(a, b), 0); } static inline float glmm_norm(glmm_128 a) { glmm_128 x0; x0 = glmm_vhadds(wasm_f32x4_mul(a, a)); return wasm_f32x4_extract_lane( wasm_i32x4_shuffle(x0, wasm_f32x4_sqrt(x0),4, 1, 2, 3), 0); } static inline float glmm_norm2(glmm_128 a) { return wasm_f32x4_extract_lane(glmm_vhadds(wasm_f32x4_mul(a, a)), 0); } static inline float glmm_norm_one(glmm_128 a) { return wasm_f32x4_extract_lane(glmm_vhadds(glmm_abs(a)), 0); } static inline float glmm_norm_inf(glmm_128 a) { return wasm_f32x4_extract_lane(glmm_vhmax(glmm_abs(a)), 0); } static inline glmm_128 glmm_load3(float v[3]) { glmm_128 xy = wasm_v128_load64_zero(v); return wasm_f32x4_replace_lane(xy, 2, v[2]); } static inline void glmm_store3(float v[3], glmm_128 vx) { wasm_v128_store64_lane(v, vx, 0); wasm_v128_store32_lane(&v[2], vx, 2); } static inline glmm_128 glmm_div(glmm_128 a, glmm_128 b) { return wasm_f32x4_div(a, b); } static inline glmm_128 glmm_fmadd(glmm_128 a, glmm_128 b, glmm_128 c) { return wasm_f32x4_add(c, wasm_f32x4_mul(a, b)); } static inline glmm_128 glmm_fnmadd(glmm_128 a, glmm_128 b, glmm_128 c) { return wasm_f32x4_sub(c, wasm_f32x4_mul(a, b)); } static inline glmm_128 glmm_fmsub(glmm_128 a, glmm_128 b, glmm_128 c) { return wasm_f32x4_sub(wasm_f32x4_mul(a, b), c); } static inline glmm_128 glmm_fnmsub(glmm_128 a, glmm_128 b, glmm_128 c) { return wasm_f32x4_neg(wasm_f32x4_add(wasm_f32x4_mul(a, b), c)); } #endif #endif /* cglm_simd_wasm_h */ cglm-0.9.6/include/cglm/simd/wasm/000077500000000000000000000000001475344456400167405ustar00rootroot00000000000000cglm-0.9.6/include/cglm/simd/wasm/affine.h000066400000000000000000000064641475344456400203530ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ #ifndef cglm_affine_mat_wasm_h #define cglm_affine_mat_wasm_h #if defined(__wasm__) && defined(__wasm_simd128__) #include "../../common.h" #include "../intrin.h" CGLM_INLINE void glm_mul_wasm(mat4 m1, mat4 m2, mat4 dest) { /* D = R * L (Column-Major) */ glmm_128 l, r0, r1, r2, r3, v0, v1, v2, v3; l = glmm_load(m1[0]); r0 = glmm_load(m2[0]); r1 = glmm_load(m2[1]); r2 = glmm_load(m2[2]); r3 = glmm_load(m2[3]); v0 = wasm_f32x4_mul(glmm_splat_x(r0), l); v1 = wasm_f32x4_mul(glmm_splat_x(r1), l); v2 = wasm_f32x4_mul(glmm_splat_x(r2), l); v3 = wasm_f32x4_mul(glmm_splat_x(r3), l); l = glmm_load(m1[1]); v0 = glmm_fmadd(glmm_splat_y(r0), l, v0); v1 = glmm_fmadd(glmm_splat_y(r1), l, v1); v2 = glmm_fmadd(glmm_splat_y(r2), l, v2); v3 = glmm_fmadd(glmm_splat_y(r3), l, v3); l = glmm_load(m1[2]); v0 = glmm_fmadd(glmm_splat_z(r0), l, v0); v1 = glmm_fmadd(glmm_splat_z(r1), l, v1); v2 = glmm_fmadd(glmm_splat_z(r2), l, v2); v3 = glmm_fmadd(glmm_splat_z(r3), l, v3); l = glmm_load(m1[3]); v3 = glmm_fmadd(glmm_splat_w(r3), l, v3); glmm_store(dest[0], v0); glmm_store(dest[1], v1); glmm_store(dest[2], v2); glmm_store(dest[3], v3); } CGLM_INLINE void glm_mul_rot_wasm(mat4 m1, mat4 m2, mat4 dest) { /* D = R * L (Column-Major) */ glmm_128 l, r0, r1, r2, v0, v1, v2; l = glmm_load(m1[0]); r0 = glmm_load(m2[0]); r1 = glmm_load(m2[1]); r2 = glmm_load(m2[2]); v0 = wasm_f32x4_mul(glmm_splat_x(r0), l); v1 = wasm_f32x4_mul(glmm_splat_x(r1), l); v2 = wasm_f32x4_mul(glmm_splat_x(r2), l); l = glmm_load(m1[1]); v0 = glmm_fmadd(glmm_splat_y(r0), l, v0); v1 = glmm_fmadd(glmm_splat_y(r1), l, v1); v2 = glmm_fmadd(glmm_splat_y(r2), l, v2); l = glmm_load(m1[2]); v0 = glmm_fmadd(glmm_splat_z(r0), l, v0); v1 = glmm_fmadd(glmm_splat_z(r1), l, v1); v2 = glmm_fmadd(glmm_splat_z(r2), l, v2); glmm_store(dest[0], v0); glmm_store(dest[1], v1); glmm_store(dest[2], v2); glmm_store(dest[3], glmm_load(m1[3])); } CGLM_INLINE void glm_inv_tr_wasm(mat4 mat) { glmm_128 r0, r1, r2, r3, x0, x1, x2, x3, x4, x5; r0 = glmm_load(mat[0]); r1 = glmm_load(mat[1]); r2 = glmm_load(mat[2]); r3 = glmm_load(mat[3]); x1 = wasm_f32x4_const(0.0f, 0.0f, 0.0f, 1.0f); /* _MM_TRANSPOSE4_PS(r0, r1, r2, x1); */ x2 = wasm_i32x4_shuffle(r0, r1, 0, 4, 1, 5); x3 = wasm_i32x4_shuffle(r0, r1, 2, 6, 3, 7); x4 = wasm_i32x4_shuffle(r2, x1, 0, 4, 1, 5); x5 = wasm_i32x4_shuffle(r2, x1, 2, 6, 3, 7); /* r0 = _mm_movelh_ps(x2, x4); */ r0 = wasm_i32x4_shuffle(x2, x4, 0, 1, 4, 5); /* r1 = _mm_movehl_ps(x4, x2); */ r1 = wasm_i32x4_shuffle(x4, x2, 6, 7, 2, 3); /* r2 = _mm_movelh_ps(x3, x5); */ r2 = wasm_i32x4_shuffle(x3, x5, 0, 1, 4, 5); /* x1 = _mm_movehl_ps(x5, x3); */ x1 = wasm_i32x4_shuffle(x5, x3, 6, 7, 2, 3); x2 = glmm_shuff1(r3, 0, 0, 0, 0); x3 = glmm_shuff1(r3, 1, 1, 1, 1); x4 = glmm_shuff1(r3, 2, 2, 2, 2); x0 = glmm_fmadd(r0, x2, glmm_fmadd(r1, x3, wasm_f32x4_mul(r2, x4))); x0 = wasm_f32x4_neg(x0); x0 = wasm_f32x4_add(x0, x1); glmm_store(mat[0], r0); glmm_store(mat[1], r1); glmm_store(mat[2], r2); glmm_store(mat[3], x0); } #endif #endif /* cglm_affine_mat_wasm_h */ cglm-0.9.6/include/cglm/simd/wasm/mat2.h000066400000000000000000000021541475344456400177560ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ #ifndef cglm_mat2_wasm_h #define cglm_mat2_wasm_h #if defined(__wasm__) && defined(__wasm_simd128__) #include "../../common.h" #include "../intrin.h" CGLM_INLINE void glm_mat2_mul_wasm(mat2 m1, mat2 m2, mat2 dest) { glmm_128 x0, x1, x2, x3, x4; x1 = glmm_load(m1[0]); /* d c b a */ x2 = glmm_load(m2[0]); /* h g f e */ x3 = glmm_shuff1(x2, 2, 2, 0, 0); x4 = glmm_shuff1(x2, 3, 3, 1, 1); /* x0 = _mm_movelh_ps(x1, x1); */ x0 = wasm_i32x4_shuffle(x1, x1, 0, 1, 4, 5); /* x2 = _mm_movehl_ps(x1, x1); */ x2 = wasm_i32x4_shuffle(x1, x1, 6, 7, 2, 3); /* dest[0][0] = a * e + c * f; dest[0][1] = b * e + d * f; dest[1][0] = a * g + c * h; dest[1][1] = b * g + d * h; */ x0 = glmm_fmadd(x0, x3, wasm_f32x4_mul(x2, x4)); glmm_store(dest[0], x0); } CGLM_INLINE void glm_mat2_transp_wasm(mat2 m, mat2 dest) { /* d c b a */ /* d b c a */ glmm_store(dest[0], glmm_shuff1(glmm_load(m[0]), 3, 1, 2, 0)); } #endif #endif /* cglm_mat2_wasm_h */ cglm-0.9.6/include/cglm/simd/wasm/mat3.h000066400000000000000000000063561475344456400177670ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ #ifndef cglm_mat3_wasm_h #define cglm_mat3_wasm_h #if defined(__wasm__) && defined(__wasm_simd128__) #include "../../common.h" #include "../intrin.h" CGLM_INLINE void glm_mat3_mul_wasm(mat3 m1, mat3 m2, mat3 dest) { glmm_128 l0, l1, l2, r0, r1, r2, x0, x1, x2, x3, x4, x5, x6, x7, x8, x9; l0 = wasm_v128_load(m1[0]); l1 = wasm_v128_load(&m1[1][1]); r0 = wasm_v128_load(m2[0]); r1 = wasm_v128_load(&m2[1][1]); x8 = glmm_shuff1(l0, 0, 2, 1, 0); /* a00 a02 a01 a00 */ x1 = glmm_shuff1(r0, 3, 0, 0, 0); /* b10 b00 b00 b00 */ x2 = wasm_i32x4_shuffle(l0, l1, 3, 3, 4, 5); /* a12 a11 a10 a10 */ x3 = wasm_i32x4_shuffle(r0, r1, 1, 3, 4, 6); /* b20 b11 b10 b01 */ x0 = wasm_f32x4_mul(x8, x1); x6 = glmm_shuff1(l0, 1, 0, 2, 1); /* a01 a00 a02 a01 */ x7 = glmm_shuff1(x3, 3, 3, 1, 1); /* b20 b20 b10 b10 */ l2 = wasm_v128_load32_zero(&m1[2][2]); r2 = wasm_v128_load32_zero(&m2[2][2]); x1 = wasm_f32x4_mul(x6, x7); l2 = glmm_shuff1(l2, 0, 0, 1, 0); /* a22 a22 0.f a22 */ r2 = glmm_shuff1(r2, 0, 0, 1, 0); /* b22 b22 0.f b22 */ x4 = glmm_shuff1(x2, 0, 3, 2, 0); /* a10 a12 a11 a10 */ x5 = glmm_shuff1(x2, 2, 0, 3, 2); /* a11 a10 a12 a11 */ x6 = glmm_shuff1(x3, 2, 0, 0, 0); /* b11 b01 b01 b01 */ x2 = glmm_shuff1(r1, 3, 3, 0, 0); /* b21 b21 b11 b11 */ /* x8 = _mm_unpackhi_ps(x8, x4); */ /* x9 = _mm_unpackhi_ps(x7, x2); */ x8 = wasm_i32x4_shuffle(x8, x4, 2, 6, 3, 7); /* a10 a00 a12 a02 */ x9 = wasm_i32x4_shuffle(x7, x2, 2, 6, 3, 7); /* b21 b20 b21 b20 */ x0 = glmm_fmadd(x4, x6, x0); x1 = glmm_fmadd(x5, x2, x1); /* x2 = _mm_movehl_ps(l2, l1); */ x2 = wasm_i32x4_shuffle(l2, l1, 6, 7, 2, 3); /* a22 a22 a21 a20 */ x3 = glmm_shuff1(x2, 0, 2, 1, 0); /* a20 a22 a21 a20 */ x2 = glmm_shuff1(x2, 1, 0, 2, 1); /* a21 a20 a22 a21 */ x4 = wasm_i32x4_shuffle(r0, r1, 2, 2, 5, 5); /* b12 b12 b02 b02 */ x5 = glmm_shuff1(x4, 3, 0, 0, 0); /* b12 b02 b02 b02 */ /* x4 = _mm_movehl_ps(r2, x4); */ x4 = wasm_i32x4_shuffle(r2, x4, 6, 7, 2, 3); /* b22 b22 b12 b12 */ x0 = glmm_fmadd(x3, x5, x0); x1 = glmm_fmadd(x2, x4, x1); /* Dot Product : dest[2][2] = a02 * b20 + a12 * b21 + a22 * b22 + 0 * 00 */ /* x2 = _mm_movelh_ps(x8, l2); */ /* x3 = _mm_movelh_ps(x9, r2); */ x2 = wasm_i32x4_shuffle(x8, l2, 0, 1, 4, 5); /* 0.f a22 a12 a02 */ x3 = wasm_i32x4_shuffle(x9, r2, 0, 1, 4, 5); /* 0.f b22 b21 b20 */ x2 = glmm_vdots(x2, x3); /* _mm_storeu_ps(&dest[0][0], x0); */ wasm_v128_store(&dest[0][0], x0); /* _mm_storeu_ps(&dest[1][1], x1); */ wasm_v128_store(&dest[1][1], x1); /* _mm_store_ss (&dest[2][2], x2); */ wasm_v128_store32_lane(&dest[2][2], x2, 0); } #endif #endif /* cglm_mat3_wasm_h */ cglm-0.9.6/include/cglm/simd/wasm/mat4.h000066400000000000000000000341121475344456400177570ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ #ifndef cglm_mat_wasm_h #define cglm_mat_wasm_h #if defined(__wasm__) && defined(__wasm_simd128__) #include "../../common.h" #include "../intrin.h" #define glm_mat4_inv_precise_wasm(mat, dest) glm_mat4_inv_wasm(mat, dest) CGLM_INLINE void glm_mat4_scale_wasm(mat4 m, float s) { glmm_128 x0; x0 = wasm_f32x4_splat(s); glmm_store(m[0], wasm_f32x4_mul(glmm_load(m[0]), x0)); glmm_store(m[1], wasm_f32x4_mul(glmm_load(m[1]), x0)); glmm_store(m[2], wasm_f32x4_mul(glmm_load(m[2]), x0)); glmm_store(m[3], wasm_f32x4_mul(glmm_load(m[3]), x0)); } CGLM_INLINE void glm_mat4_transp_wasm(mat4 m, mat4 dest) { glmm_128 r0, r1, r2, r3, tmp0, tmp1, tmp2, tmp3; r0 = glmm_load(m[0]); r1 = glmm_load(m[1]); r2 = glmm_load(m[2]); r3 = glmm_load(m[3]); /* _MM_TRANSPOSE4_PS(r0, r1, r2, r3); */ tmp0 = wasm_i32x4_shuffle(r0, r1, 0, 4, 1, 5); tmp1 = wasm_i32x4_shuffle(r0, r1, 2, 6, 3, 7); tmp2 = wasm_i32x4_shuffle(r2, r3, 0, 4, 1, 5); tmp3 = wasm_i32x4_shuffle(r2, r3, 2, 6, 3, 7); /* r0 = _mm_movelh_ps(tmp0, tmp2); */ r0 = wasm_i32x4_shuffle(tmp0, tmp2, 0, 1, 4, 5); /* r1 = _mm_movehl_ps(tmp2, tmp0); */ r1 = wasm_i32x4_shuffle(tmp2, tmp0, 6, 7, 2, 3); /* r2 = _mm_movelh_ps(tmp1, tmp3); */ r2 = wasm_i32x4_shuffle(tmp1, tmp3, 0, 1, 4, 5); /* r3 = _mm_movehl_ps(tmp3, tmp1); */ r3 = wasm_i32x4_shuffle(tmp3, tmp1, 6, 7, 2, 3); glmm_store(dest[0], r0); glmm_store(dest[1], r1); glmm_store(dest[2], r2); glmm_store(dest[3], r3); } CGLM_INLINE void glm_mat4_mul_wasm(mat4 m1, mat4 m2, mat4 dest) { /* D = R * L (Column-Major) */ glmm_128 l, r0, r1, r2, r3, v0, v1, v2, v3; l = glmm_load(m1[0]); r0 = glmm_load(m2[0]); r1 = glmm_load(m2[1]); r2 = glmm_load(m2[2]); r3 = glmm_load(m2[3]); v0 = wasm_f32x4_mul(glmm_splat_x(r0), l); v1 = wasm_f32x4_mul(glmm_splat_x(r1), l); v2 = wasm_f32x4_mul(glmm_splat_x(r2), l); v3 = wasm_f32x4_mul(glmm_splat_x(r3), l); l = glmm_load(m1[1]); v0 = glmm_fmadd(glmm_splat_y(r0), l, v0); v1 = glmm_fmadd(glmm_splat_y(r1), l, v1); v2 = glmm_fmadd(glmm_splat_y(r2), l, v2); v3 = glmm_fmadd(glmm_splat_y(r3), l, v3); l = glmm_load(m1[2]); v0 = glmm_fmadd(glmm_splat_z(r0), l, v0); v1 = glmm_fmadd(glmm_splat_z(r1), l, v1); v2 = glmm_fmadd(glmm_splat_z(r2), l, v2); v3 = glmm_fmadd(glmm_splat_z(r3), l, v3); l = glmm_load(m1[3]); v0 = glmm_fmadd(glmm_splat_w(r0), l, v0); v1 = glmm_fmadd(glmm_splat_w(r1), l, v1); v2 = glmm_fmadd(glmm_splat_w(r2), l, v2); v3 = glmm_fmadd(glmm_splat_w(r3), l, v3); glmm_store(dest[0], v0); glmm_store(dest[1], v1); glmm_store(dest[2], v2); glmm_store(dest[3], v3); } CGLM_INLINE void glm_mat4_mulv_wasm(mat4 m, vec4 v, vec4 dest) { glmm_128 x0, x1, m0, m1, m2, m3, v0, v1, v2, v3; m0 = glmm_load(m[0]); m1 = glmm_load(m[1]); m2 = glmm_load(m[2]); m3 = glmm_load(m[3]); x0 = glmm_load(v); v0 = glmm_splat_x(x0); v1 = glmm_splat_y(x0); v2 = glmm_splat_z(x0); v3 = glmm_splat_w(x0); x1 = wasm_f32x4_mul(m3, v3); x1 = glmm_fmadd(m2, v2, x1); x1 = glmm_fmadd(m1, v1, x1); x1 = glmm_fmadd(m0, v0, x1); glmm_store(dest, x1); } CGLM_INLINE float glm_mat4_det_wasm(mat4 mat) { glmm_128 r0, r1, r2, r3, x0, x1, x2; /* 127 <- 0, [square] det(A) = det(At) */ r0 = glmm_load(mat[0]); /* d c b a */ r1 = glmm_load(mat[1]); /* h g f e */ r2 = glmm_load(mat[2]); /* l k j i */ r3 = glmm_load(mat[3]); /* p o n m */ /* t[1] = j * p - n * l; t[2] = j * o - n * k; t[3] = i * p - m * l; t[4] = i * o - m * k; */ x0 = glmm_fnmadd(glmm_shuff1(r3, 0, 0, 1, 1), glmm_shuff1(r2, 2, 3, 2, 3), wasm_f32x4_mul(glmm_shuff1(r2, 0, 0, 1, 1), glmm_shuff1(r3, 2, 3, 2, 3))); /* t[0] = k * p - o * l; t[0] = k * p - o * l; t[5] = i * n - m * j; t[5] = i * n - m * j; */ x1 = glmm_fnmadd(glmm_shuff1(r3, 0, 0, 2, 2), glmm_shuff1(r2, 1, 1, 3, 3), wasm_f32x4_mul(glmm_shuff1(r2, 0, 0, 2, 2), glmm_shuff1(r3, 1, 1, 3, 3))); /* a * (f * t[0] - g * t[1] + h * t[2]) - b * (e * t[0] - g * t[3] + h * t[4]) + c * (e * t[1] - f * t[3] + h * t[5]) - d * (e * t[2] - f * t[4] + g * t[5]) */ x2 = glmm_fnmadd(glmm_shuff1(r1, 1, 1, 2, 2), glmm_shuff1(x0, 3, 2, 2, 0), wasm_f32x4_mul(glmm_shuff1(r1, 0, 0, 0, 1), wasm_i32x4_shuffle(x1, x0, 0, 0, 4, 5))); x2 = glmm_fmadd(glmm_shuff1(r1, 2, 3, 3, 3), wasm_i32x4_shuffle(x0, x1, 1, 3, 6, 6), x2); /* x2 = wasm_v128_xor(x2, wasm_f32x4_const(0.f, -0.f, 0.f, -0.f)); */ x2 = wasm_v128_xor(x2, glmm_float32x4_SIGNMASK_PNPN); return glmm_hadd(wasm_f32x4_mul(x2, r0)); } CGLM_INLINE void glm_mat4_inv_fast_wasm(mat4 mat, mat4 dest) { glmm_128 r0, r1, r2, r3, v0, v1, v2, v3, t0, t1, t2, t3, t4, t5, x0, x1, x2, x3, x4, x5, x6, x7, x8, x9; /* x8 = wasm_f32x4_const(0.f, -0.f, 0.f, -0.f); */ x8 = glmm_float32x4_SIGNMASK_PNPN; x9 = glmm_shuff1(x8, 2, 1, 2, 1); /* 127 <- 0 */ r0 = glmm_load(mat[0]); /* d c b a */ r1 = glmm_load(mat[1]); /* h g f e */ r2 = glmm_load(mat[2]); /* l k j i */ r3 = glmm_load(mat[3]); /* p o n m */ /* x0 = _mm_movehl_ps(r3, r2); */ x0 = wasm_i32x4_shuffle(r3, r2, 6, 7, 2, 3); /* p o l k */ /* x3 = _mm_movelh_ps(r2, r3); */ x3 = wasm_i32x4_shuffle(r2, r3, 0, 1, 4, 5); /* n m j i */ x1 = glmm_shuff1(x0, 1, 3, 3 ,3); /* l p p p */ x2 = glmm_shuff1(x0, 0, 2, 2, 2); /* k o o o */ x4 = glmm_shuff1(x3, 1, 3, 3, 3); /* j n n n */ x7 = glmm_shuff1(x3, 0, 2, 2, 2); /* i m m m */ x6 = wasm_i32x4_shuffle(r2, r1, 0, 0, 4, 4); /* e e i i */ x5 = wasm_i32x4_shuffle(r2, r1, 1, 1, 5, 5); /* f f j j */ x3 = wasm_i32x4_shuffle(r2, r1, 2, 2, 6, 6); /* g g k k */ x0 = wasm_i32x4_shuffle(r2, r1, 3, 3, 7, 7); /* h h l l */ t0 = wasm_f32x4_mul(x3, x1); t1 = wasm_f32x4_mul(x5, x1); t2 = wasm_f32x4_mul(x5, x2); t3 = wasm_f32x4_mul(x6, x1); t4 = wasm_f32x4_mul(x6, x2); t5 = wasm_f32x4_mul(x6, x4); /* t1[0] = k * p - o * l; t1[0] = k * p - o * l; t2[0] = g * p - o * h; t3[0] = g * l - k * h; */ t0 = glmm_fnmadd(x2, x0, t0); /* t1[1] = j * p - n * l; t1[1] = j * p - n * l; t2[1] = f * p - n * h; t3[1] = f * l - j * h; */ t1 = glmm_fnmadd(x4, x0, t1); /* t1[2] = j * o - n * k t1[2] = j * o - n * k; t2[2] = f * o - n * g; t3[2] = f * k - j * g; */ t2 = glmm_fnmadd(x4, x3, t2); /* t1[3] = i * p - m * l; t1[3] = i * p - m * l; t2[3] = e * p - m * h; t3[3] = e * l - i * h; */ t3 = glmm_fnmadd(x7, x0, t3); /* t1[4] = i * o - m * k; t1[4] = i * o - m * k; t2[4] = e * o - m * g; t3[4] = e * k - i * g; */ t4 = glmm_fnmadd(x7, x3, t4); /* t1[5] = i * n - m * j; t1[5] = i * n - m * j; t2[5] = e * n - m * f; t3[5] = e * j - i * f; */ t5 = glmm_fnmadd(x7, x5, t5); /* x4 = _mm_movelh_ps(r0, r1); */ x4 = wasm_i32x4_shuffle(r0, r1, 0, 1, 4, 5); /* f e b a */ /* x5 = _mm_movehl_ps(r1, r0); */ x5 = wasm_i32x4_shuffle(r1, r0, 6, 7, 2, 3); /* h g d c */ x0 = glmm_shuff1(x4, 0, 0, 0, 2); /* a a a e */ x1 = glmm_shuff1(x4, 1, 1, 1, 3); /* b b b f */ x2 = glmm_shuff1(x5, 0, 0, 0, 2); /* c c c g */ x3 = glmm_shuff1(x5, 1, 1, 1, 3); /* d d d h */ v2 = wasm_f32x4_mul(x0, t1); v1 = wasm_f32x4_mul(x0, t0); v3 = wasm_f32x4_mul(x0, t2); v0 = wasm_f32x4_mul(x1, t0); v2 = glmm_fnmadd(x1, t3, v2); v3 = glmm_fnmadd(x1, t4, v3); v0 = glmm_fnmadd(x2, t1, v0); v1 = glmm_fnmadd(x2, t3, v1); v3 = glmm_fmadd(x2, t5, v3); v0 = glmm_fmadd(x3, t2, v0); v2 = glmm_fmadd(x3, t5, v2); v1 = glmm_fmadd(x3, t4, v1); /* dest[0][0] = f * t1[0] - g * t1[1] + h * t1[2]; dest[0][1] =-(b * t1[0] - c * t1[1] + d * t1[2]); dest[0][2] = b * t2[0] - c * t2[1] + d * t2[2]; dest[0][3] =-(b * t3[0] - c * t3[1] + d * t3[2]); */ v0 = wasm_v128_xor(v0, x8); /* dest[2][0] = e * t1[1] - f * t1[3] + h * t1[5]; dest[2][1] =-(a * t1[1] - b * t1[3] + d * t1[5]); dest[2][2] = a * t2[1] - b * t2[3] + d * t2[5]; dest[2][3] =-(a * t3[1] - b * t3[3] + d * t3[5]);*/ v2 = wasm_v128_xor(v2, x8); /* dest[1][0] =-(e * t1[0] - g * t1[3] + h * t1[4]); dest[1][1] = a * t1[0] - c * t1[3] + d * t1[4]; dest[1][2] =-(a * t2[0] - c * t2[3] + d * t2[4]); dest[1][3] = a * t3[0] - c * t3[3] + d * t3[4]; */ v1 = wasm_v128_xor(v1, x9); /* dest[3][0] =-(e * t1[2] - f * t1[4] + g * t1[5]); dest[3][1] = a * t1[2] - b * t1[4] + c * t1[5]; dest[3][2] =-(a * t2[2] - b * t2[4] + c * t2[5]); dest[3][3] = a * t3[2] - b * t3[4] + c * t3[5]; */ v3 = wasm_v128_xor(v3, x9); /* determinant */ x0 = wasm_i32x4_shuffle(v0, v1, 0, 0, 4, 4); x1 = wasm_i32x4_shuffle(v2, v3, 0, 0, 4, 4); x0 = wasm_i32x4_shuffle(x0, x1, 0, 2, 4, 6); /* x0 = _mm_rcp_ps(glmm_vhadd(wasm_f32x4_mul(x0, r0))); */ x0 = wasm_f32x4_div(wasm_f32x4_const_splat(1.0f), glmm_vhadd(wasm_f32x4_mul(x0, r0))); glmm_store(dest[0], wasm_f32x4_mul(v0, x0)); glmm_store(dest[1], wasm_f32x4_mul(v1, x0)); glmm_store(dest[2], wasm_f32x4_mul(v2, x0)); glmm_store(dest[3], wasm_f32x4_mul(v3, x0)); } CGLM_INLINE void glm_mat4_inv_wasm(mat4 mat, mat4 dest) { glmm_128 r0, r1, r2, r3, v0, v1, v2, v3, t0, t1, t2, t3, t4, t5, x0, x1, x2, x3, x4, x5, x6, x7, x8, x9; /* x8 = wasm_f32x4_const(0.f, -0.f, 0.f, -0.f); */ x8 = glmm_float32x4_SIGNMASK_PNPN; x9 = glmm_shuff1(x8, 2, 1, 2, 1); /* 127 <- 0 */ r0 = glmm_load(mat[0]); /* d c b a */ r1 = glmm_load(mat[1]); /* h g f e */ r2 = glmm_load(mat[2]); /* l k j i */ r3 = glmm_load(mat[3]); /* p o n m */ /* x0 = _mm_movehl_ps(r3, r2); */ x0 = wasm_i32x4_shuffle(r3, r2, 6, 7, 2, 3); /* p o l k */ /* x3 = _mm_movelh_ps(r2, r3); */ x3 = wasm_i32x4_shuffle(r2, r3, 0, 1, 4, 5); /* n m j i */ x1 = glmm_shuff1(x0, 1, 3, 3 ,3); /* l p p p */ x2 = glmm_shuff1(x0, 0, 2, 2, 2); /* k o o o */ x4 = glmm_shuff1(x3, 1, 3, 3, 3); /* j n n n */ x7 = glmm_shuff1(x3, 0, 2, 2, 2); /* i m m m */ x6 = wasm_i32x4_shuffle(r2, r1, 0, 0, 4, 4); /* e e i i */ x5 = wasm_i32x4_shuffle(r2, r1, 1, 1, 5, 5); /* f f j j */ x3 = wasm_i32x4_shuffle(r2, r1, 2, 2, 6, 6); /* g g k k */ x0 = wasm_i32x4_shuffle(r2, r1, 3, 3, 7, 7); /* h h l l */ t0 = wasm_f32x4_mul(x3, x1); t1 = wasm_f32x4_mul(x5, x1); t2 = wasm_f32x4_mul(x5, x2); t3 = wasm_f32x4_mul(x6, x1); t4 = wasm_f32x4_mul(x6, x2); t5 = wasm_f32x4_mul(x6, x4); /* t1[0] = k * p - o * l; t1[0] = k * p - o * l; t2[0] = g * p - o * h; t3[0] = g * l - k * h; */ t0 = glmm_fnmadd(x2, x0, t0); /* t1[1] = j * p - n * l; t1[1] = j * p - n * l; t2[1] = f * p - n * h; t3[1] = f * l - j * h; */ t1 = glmm_fnmadd(x4, x0, t1); /* t1[2] = j * o - n * k t1[2] = j * o - n * k; t2[2] = f * o - n * g; t3[2] = f * k - j * g; */ t2 = glmm_fnmadd(x4, x3, t2); /* t1[3] = i * p - m * l; t1[3] = i * p - m * l; t2[3] = e * p - m * h; t3[3] = e * l - i * h; */ t3 = glmm_fnmadd(x7, x0, t3); /* t1[4] = i * o - m * k; t1[4] = i * o - m * k; t2[4] = e * o - m * g; t3[4] = e * k - i * g; */ t4 = glmm_fnmadd(x7, x3, t4); /* t1[5] = i * n - m * j; t1[5] = i * n - m * j; t2[5] = e * n - m * f; t3[5] = e * j - i * f; */ t5 = glmm_fnmadd(x7, x5, t5); /* x4 = _mm_movelh_ps(r0, r1); */ x4 = wasm_i32x4_shuffle(r0, r1, 0, 1, 4, 5); /* f e b a */ /* x5 = _mm_movehl_ps(r1, r0); */ x5 = wasm_i32x4_shuffle(r1, r0, 6, 7, 2, 3); /* h g d c */ x0 = glmm_shuff1(x4, 0, 0, 0, 2); /* a a a e */ x1 = glmm_shuff1(x4, 1, 1, 1, 3); /* b b b f */ x2 = glmm_shuff1(x5, 0, 0, 0, 2); /* c c c g */ x3 = glmm_shuff1(x5, 1, 1, 1, 3); /* d d d h */ v2 = wasm_f32x4_mul(x0, t1); v1 = wasm_f32x4_mul(x0, t0); v3 = wasm_f32x4_mul(x0, t2); v0 = wasm_f32x4_mul(x1, t0); v2 = glmm_fnmadd(x1, t3, v2); v3 = glmm_fnmadd(x1, t4, v3); v0 = glmm_fnmadd(x2, t1, v0); v1 = glmm_fnmadd(x2, t3, v1); v3 = glmm_fmadd(x2, t5, v3); v0 = glmm_fmadd(x3, t2, v0); v2 = glmm_fmadd(x3, t5, v2); v1 = glmm_fmadd(x3, t4, v1); /* dest[0][0] = f * t1[0] - g * t1[1] + h * t1[2]; dest[0][1] =-(b * t1[0] - c * t1[1] + d * t1[2]); dest[0][2] = b * t2[0] - c * t2[1] + d * t2[2]; dest[0][3] =-(b * t3[0] - c * t3[1] + d * t3[2]); */ v0 = wasm_v128_xor(v0, x8); /* dest[2][0] = e * t1[1] - f * t1[3] + h * t1[5]; dest[2][1] =-(a * t1[1] - b * t1[3] + d * t1[5]); dest[2][2] = a * t2[1] - b * t2[3] + d * t2[5]; dest[2][3] =-(a * t3[1] - b * t3[3] + d * t3[5]);*/ v2 = wasm_v128_xor(v2, x8); /* dest[1][0] =-(e * t1[0] - g * t1[3] + h * t1[4]); dest[1][1] = a * t1[0] - c * t1[3] + d * t1[4]; dest[1][2] =-(a * t2[0] - c * t2[3] + d * t2[4]); dest[1][3] = a * t3[0] - c * t3[3] + d * t3[4]; */ v1 = wasm_v128_xor(v1, x9); /* dest[3][0] =-(e * t1[2] - f * t1[4] + g * t1[5]); dest[3][1] = a * t1[2] - b * t1[4] + c * t1[5]; dest[3][2] =-(a * t2[2] - b * t2[4] + c * t2[5]); dest[3][3] = a * t3[2] - b * t3[4] + c * t3[5]; */ v3 = wasm_v128_xor(v3, x9); /* determinant */ x0 = wasm_i32x4_shuffle(v0, v1, 0, 0, 4, 4); x1 = wasm_i32x4_shuffle(v2, v3, 0, 0, 4, 4); x0 = wasm_i32x4_shuffle(x0, x1, 0, 2, 4, 6); x0 = wasm_f32x4_div(wasm_f32x4_splat(1.0f), glmm_vhadd(wasm_f32x4_mul(x0, r0))); glmm_store(dest[0], wasm_f32x4_mul(v0, x0)); glmm_store(dest[1], wasm_f32x4_mul(v1, x0)); glmm_store(dest[2], wasm_f32x4_mul(v2, x0)); glmm_store(dest[3], wasm_f32x4_mul(v3, x0)); } #endif #endif /* cglm_mat_wasm_h */ cglm-0.9.6/include/cglm/simd/wasm/quat.h000066400000000000000000000025261475344456400200700ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ #ifndef cglm_quat_wasm_h #define cglm_quat_wasm_h #if defined(__wasm__) && defined(__wasm_simd128__) #include "../../common.h" #include "../intrin.h" CGLM_INLINE void glm_quat_mul_wasm(versor p, versor q, versor dest) { /* + (a1 b2 + b1 a2 + c1 d2 − d1 c2)i + (a1 c2 − b1 d2 + c1 a2 + d1 b2)j + (a1 d2 + b1 c2 − c1 b2 + d1 a2)k a1 a2 − b1 b2 − c1 c2 − d1 d2 */ glmm_128 xp, xq, x1, x2, x3, r, x, y, z; xp = glmm_load(p); /* 3 2 1 0 */ xq = glmm_load(q); /* x1 = wasm_f32x4_const(0.f, -0.f, 0.f, -0.f); */ x1 = glmm_float32x4_SIGNMASK_PNPN; /* TODO: _mm_set1_ss() + shuff ? */ r = wasm_f32x4_mul(glmm_splat_w(xp), xq); /* x2 = _mm_unpackhi_ps(x1, x1); */ x2 = wasm_i32x4_shuffle(x1, x1, 2, 6, 3, 7); x3 = glmm_shuff1(x1, 3, 2, 0, 1); x = glmm_splat_x(xp); y = glmm_splat_y(xp); z = glmm_splat_z(xp); x = wasm_v128_xor(x, x1); y = wasm_v128_xor(y, x2); z = wasm_v128_xor(z, x3); x1 = glmm_shuff1(xq, 0, 1, 2, 3); x2 = glmm_shuff1(xq, 1, 0, 3, 2); x3 = glmm_shuff1(xq, 2, 3, 0, 1); r = glmm_fmadd(x, x1, r); r = glmm_fmadd(y, x2, r); r = glmm_fmadd(z, x3, r); glmm_store(dest, r); } #endif #endif /* cglm_quat_wasm_h */ cglm-0.9.6/include/cglm/simd/x86.h000066400000000000000000000214001475344456400165640ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ #ifndef cglm_simd_x86_h #define cglm_simd_x86_h #include "intrin.h" #ifdef CGLM_SIMD_x86 #ifdef CGLM_ALL_UNALIGNED # define glmm_load(p) _mm_loadu_ps(p) # define glmm_store(p, a) _mm_storeu_ps(p, a) #else # define glmm_load(p) _mm_load_ps(p) # define glmm_store(p, a) _mm_store_ps(p, a) #endif #define glmm_128 __m128 #ifdef __AVX__ # define glmm_shuff1(xmm, z, y, x, w) \ _mm_permute_ps((xmm), _MM_SHUFFLE(z, y, x, w)) #else # if !defined(CGLM_NO_INT_DOMAIN) && defined(__SSE2__) # define glmm_shuff1(xmm, z, y, x, w) \ _mm_castsi128_ps(_mm_shuffle_epi32(_mm_castps_si128(xmm), \ _MM_SHUFFLE(z, y, x, w))) # else # define glmm_shuff1(xmm, z, y, x, w) \ _mm_shuffle_ps(xmm, xmm, _MM_SHUFFLE(z, y, x, w)) # endif #endif #define glmm_splat(x, lane) glmm_shuff1(x, lane, lane, lane, lane) #ifdef __AVX__ # define glmm_set1(x) _mm_broadcast_ss(&x) # define glmm_set1_ptr(x) _mm_broadcast_ss(x) # define glmm_set1_rval(x) _mm_set1_ps(x) # ifdef __AVX2__ # define glmm_splat_x(x) _mm_broadcastss_ps(x) # else # define glmm_splat_x(x) _mm_permute_ps(x, _MM_SHUFFLE(0, 0, 0, 0)) # endif # define glmm_splat_y(x) _mm_permute_ps(x, _MM_SHUFFLE(1, 1, 1, 1)) # define glmm_splat_z(x) _mm_permute_ps(x, _MM_SHUFFLE(2, 2, 2, 2)) # define glmm_splat_w(x) _mm_permute_ps(x, _MM_SHUFFLE(3, 3, 3, 3)) #else # define glmm_set1(x) _mm_set1_ps(x) # define glmm_set1_ptr(x) _mm_set1_ps(*x) # define glmm_set1_rval(x) _mm_set1_ps(x) # define glmm_splat_x(x) glmm_splat(x, 0) # define glmm_splat_y(x) glmm_splat(x, 1) # define glmm_splat_z(x) glmm_splat(x, 2) # define glmm_splat_w(x) glmm_splat(x, 3) #endif #ifdef __AVX__ # ifdef CGLM_ALL_UNALIGNED # define glmm_load256(p) _mm256_loadu_ps(p) # define glmm_store256(p, a) _mm256_storeu_ps(p, a) # else # define glmm_load256(p) _mm256_load_ps(p) # define glmm_store256(p, a) _mm256_store_ps(p, a) # endif #endif /* Note that `0x80000000` corresponds to `INT_MIN` for a 32-bit int. */ #if defined(__SSE2__) # define GLMM_NEGZEROf ((int)0x80000000) /* 0x80000000 ---> -0.0f */ # define GLMM_POSZEROf ((int)0x00000000) /* 0x00000000 ---> +0.0f */ #else # ifdef CGLM_FAST_MATH union { int i; float f; } static GLMM_NEGZEROf_TU = { .i = (int)0x80000000 }; # define GLMM_NEGZEROf GLMM_NEGZEROf_TU.f # define GLMM_POSZEROf 0.0f # else # define GLMM_NEGZEROf -0.0f # define GLMM_POSZEROf 0.0f # endif #endif #if defined(__SSE2__) # define GLMM__SIGNMASKf(X, Y, Z, W) \ _mm_castsi128_ps(_mm_set_epi32(X, Y, Z, W)) /* _mm_set_ps(X, Y, Z, W); */ #else # define GLMM__SIGNMASKf(X, Y, Z, W) _mm_set_ps(X, Y, Z, W) #endif #define glmm_float32x4_SIGNMASK_PNPN GLMM__SIGNMASKf(GLMM_POSZEROf, GLMM_NEGZEROf, GLMM_POSZEROf, GLMM_NEGZEROf) #define glmm_float32x4_SIGNMASK_NPNP GLMM__SIGNMASKf(GLMM_NEGZEROf, GLMM_POSZEROf, GLMM_NEGZEROf, GLMM_POSZEROf) #define glmm_float32x4_SIGNMASK_NPPN GLMM__SIGNMASKf(GLMM_NEGZEROf, GLMM_POSZEROf, GLMM_POSZEROf, GLMM_NEGZEROf) /* fasth math prevents -0.0f to work */ #if defined(__SSE2__) # define glmm_float32x4_SIGNMASK_NEG _mm_castsi128_ps(_mm_set1_epi32(GLMM_NEGZEROf)) /* _mm_set1_ps(-0.0f) */ #else # define glmm_float32x4_SIGNMASK_NEG glmm_set1(GLMM_NEGZEROf) #endif #define glmm_float32x8_SIGNMASK_NEG _mm256_castsi256_ps(_mm256_set1_epi32(GLMM_NEGZEROf)) static inline __m128 glmm_abs(__m128 x) { return _mm_andnot_ps(glmm_float32x4_SIGNMASK_NEG, x); } static inline __m128 glmm_min(__m128 a, __m128 b) { return _mm_min_ps(a, b); } static inline __m128 glmm_max(__m128 a, __m128 b) { return _mm_max_ps(a, b); } static inline __m128 glmm_vhadd(__m128 v) { __m128 x0; x0 = _mm_add_ps(v, glmm_shuff1(v, 0, 1, 2, 3)); x0 = _mm_add_ps(x0, glmm_shuff1(x0, 1, 0, 0, 1)); return x0; } static inline __m128 glmm_vhadds(__m128 v) { #if defined(__SSE3__) __m128 shuf, sums; shuf = _mm_movehdup_ps(v); sums = _mm_add_ps(v, shuf); shuf = _mm_movehl_ps(shuf, sums); sums = _mm_add_ss(sums, shuf); return sums; #else __m128 shuf, sums; shuf = glmm_shuff1(v, 2, 3, 0, 1); sums = _mm_add_ps(v, shuf); shuf = _mm_movehl_ps(shuf, sums); sums = _mm_add_ss(sums, shuf); return sums; #endif } static inline float glmm_hadd(__m128 v) { return _mm_cvtss_f32(glmm_vhadds(v)); } static inline __m128 glmm_vhmin(__m128 v) { __m128 x0, x1, x2; x0 = _mm_movehl_ps(v, v); /* [2, 3, 2, 3] */ x1 = _mm_min_ps(x0, v); /* [0|2, 1|3, 2|2, 3|3] */ x2 = glmm_splat(x1, 1); /* [1|3, 1|3, 1|3, 1|3] */ return _mm_min_ss(x1, x2); } static inline float glmm_hmin(__m128 v) { return _mm_cvtss_f32(glmm_vhmin(v)); } static inline __m128 glmm_vhmax(__m128 v) { __m128 x0, x1, x2; x0 = _mm_movehl_ps(v, v); /* [2, 3, 2, 3] */ x1 = _mm_max_ps(x0, v); /* [0|2, 1|3, 2|2, 3|3] */ x2 = glmm_splat(x1, 1); /* [1|3, 1|3, 1|3, 1|3] */ return _mm_max_ss(x1, x2); } static inline float glmm_hmax(__m128 v) { return _mm_cvtss_f32(glmm_vhmax(v)); } static inline __m128 glmm_vdots(__m128 a, __m128 b) { #if (defined(__SSE4_1__) || defined(__SSE4_2__)) && defined(CGLM_SSE4_DOT) return _mm_dp_ps(a, b, 0xFF); #elif defined(__SSE3__) && defined(CGLM_SSE3_DOT) __m128 x0, x1; x0 = _mm_mul_ps(a, b); x1 = _mm_hadd_ps(x0, x0); return _mm_hadd_ps(x1, x1); #else return glmm_vhadds(_mm_mul_ps(a, b)); #endif } static inline __m128 glmm_vdot(__m128 a, __m128 b) { #if (defined(__SSE4_1__) || defined(__SSE4_2__)) && defined(CGLM_SSE4_DOT) return _mm_dp_ps(a, b, 0xFF); #elif defined(__SSE3__) && defined(CGLM_SSE3_DOT) __m128 x0, x1; x0 = _mm_mul_ps(a, b); x1 = _mm_hadd_ps(x0, x0); return _mm_hadd_ps(x1, x1); #else __m128 x0; x0 = _mm_mul_ps(a, b); x0 = _mm_add_ps(x0, glmm_shuff1(x0, 1, 0, 3, 2)); return _mm_add_ps(x0, glmm_shuff1(x0, 0, 1, 0, 1)); #endif } static inline float glmm_dot(__m128 a, __m128 b) { return _mm_cvtss_f32(glmm_vdots(a, b)); } static inline float glmm_norm(__m128 a) { return _mm_cvtss_f32(_mm_sqrt_ss(glmm_vhadds(_mm_mul_ps(a, a)))); } static inline float glmm_norm2(__m128 a) { return _mm_cvtss_f32(glmm_vhadds(_mm_mul_ps(a, a))); } static inline float glmm_norm_one(__m128 a) { return _mm_cvtss_f32(glmm_vhadds(glmm_abs(a))); } static inline float glmm_norm_inf(__m128 a) { return _mm_cvtss_f32(glmm_vhmax(glmm_abs(a))); } #if defined(__SSE2__) static inline __m128 glmm_load3(float v[3]) { __m128i xy; __m128 z; xy = _mm_loadl_epi64(CGLM_CASTPTR_ASSUME_ALIGNED(v, const __m128i)); z = _mm_load_ss(&v[2]); return _mm_movelh_ps(_mm_castsi128_ps(xy), z); } static inline void glmm_store3(float v[3], __m128 vx) { _mm_storel_pi(CGLM_CASTPTR_ASSUME_ALIGNED(v, __m64), vx); _mm_store_ss(&v[2], glmm_shuff1(vx, 2, 2, 2, 2)); } #endif static inline __m128 glmm_div(__m128 a, __m128 b) { return _mm_div_ps(a, b); } /* enable FMA macro for MSVC? */ #if defined(_MSC_VER) && !defined(__FMA__) && defined(__AVX2__) # define __FMA__ 1 #endif static inline __m128 glmm_fmadd(__m128 a, __m128 b, __m128 c) { #ifdef __FMA__ return _mm_fmadd_ps(a, b, c); #else return _mm_add_ps(c, _mm_mul_ps(a, b)); #endif } static inline __m128 glmm_fnmadd(__m128 a, __m128 b, __m128 c) { #ifdef __FMA__ return _mm_fnmadd_ps(a, b, c); #else return _mm_sub_ps(c, _mm_mul_ps(a, b)); #endif } static inline __m128 glmm_fmsub(__m128 a, __m128 b, __m128 c) { #ifdef __FMA__ return _mm_fmsub_ps(a, b, c); #else return _mm_sub_ps(_mm_mul_ps(a, b), c); #endif } static inline __m128 glmm_fnmsub(__m128 a, __m128 b, __m128 c) { #ifdef __FMA__ return _mm_fnmsub_ps(a, b, c); #else return _mm_xor_ps(_mm_add_ps(_mm_mul_ps(a, b), c), glmm_float32x4_SIGNMASK_NEG); #endif } #if defined(__AVX__) static inline __m256 glmm256_fmadd(__m256 a, __m256 b, __m256 c) { #ifdef __FMA__ return _mm256_fmadd_ps(a, b, c); #else return _mm256_add_ps(c, _mm256_mul_ps(a, b)); #endif } static inline __m256 glmm256_fnmadd(__m256 a, __m256 b, __m256 c) { #ifdef __FMA__ return _mm256_fnmadd_ps(a, b, c); #else return _mm256_sub_ps(c, _mm256_mul_ps(a, b)); #endif } static inline __m256 glmm256_fmsub(__m256 a, __m256 b, __m256 c) { #ifdef __FMA__ return _mm256_fmsub_ps(a, b, c); #else return _mm256_sub_ps(_mm256_mul_ps(a, b), c); #endif } static inline __m256 glmm256_fnmsub(__m256 a, __m256 b, __m256 c) { #ifdef __FMA__ return _mm256_fmsub_ps(a, b, c); #else return _mm256_xor_ps(_mm256_sub_ps(_mm256_mul_ps(a, b), c), glmm_float32x8_SIGNMASK_NEG); #endif } #endif #endif #endif /* cglm_simd_x86_h */ cglm-0.9.6/include/cglm/sphere.h000066400000000000000000000037061475344456400165020ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ #ifndef cglm_sphere_h #define cglm_sphere_h #include "common.h" #include "mat4.h" /* Sphere Representation in cglm: [center.x, center.y, center.z, radii] You could use this representation or you can convert it to vec4 before call any function */ /*! * @brief helper for getting sphere radius * * @param[in] s sphere * * @return returns radii */ CGLM_INLINE float glm_sphere_radii(vec4 s) { return s[3]; } /*! * @brief apply transform to sphere, it is just wrapper for glm_mat4_mulv3 * * @param[in] s sphere * @param[in] m transform matrix * @param[out] dest transformed sphere */ CGLM_INLINE void glm_sphere_transform(vec4 s, mat4 m, vec4 dest) { glm_mat4_mulv3(m, s, 1.0f, dest); dest[3] = s[3]; } /*! * @brief merges two spheres and creates a new one * * two sphere must be in same space, for instance if one in world space then * the other must be in world space too, not in local space. * * @param[in] s1 sphere 1 * @param[in] s2 sphere 2 * @param[out] dest merged/extended sphere */ CGLM_INLINE void glm_sphere_merge(vec4 s1, vec4 s2, vec4 dest) { float dist, radii; dist = glm_vec3_distance(s1, s2); radii = dist + s1[3] + s2[3]; radii = glm_max(radii, s1[3]); radii = glm_max(radii, s2[3]); glm_vec3_center(s1, s2, dest); dest[3] = radii; } /*! * @brief check if two sphere intersects * * @param[in] s1 sphere * @param[in] s2 other sphere */ CGLM_INLINE bool glm_sphere_sphere(vec4 s1, vec4 s2) { return glm_vec3_distance2(s1, s2) <= glm_pow2(s1[3] + s2[3]); } /*! * @brief check if sphere intersects with point * * @param[in] s sphere * @param[in] point point */ CGLM_INLINE bool glm_sphere_point(vec4 s, vec3 point) { float rr; rr = s[3] * s[3]; return glm_vec3_distance2(point, s) <= rr; } #endif /* cglm_sphere_h */ cglm-0.9.6/include/cglm/struct.h000066400000000000000000000021351475344456400165330ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ #ifndef cglm_structs_h #define cglm_structs_h #ifdef __cplusplus extern "C" { #endif #include "cglm.h" #include "types-struct.h" #include "struct/vec2.h" #include "struct/vec3.h" #include "struct/vec4.h" #include "struct/ivec2.h" #include "struct/ivec3.h" #include "struct/ivec4.h" #include "struct/mat2.h" #include "struct/mat2x3.h" #include "struct/mat2x4.h" #include "struct/mat3.h" #include "struct/mat3x2.h" #include "struct/mat3x4.h" #include "struct/mat4.h" #include "struct/mat4x2.h" #include "struct/mat4x3.h" #include "struct/affine.h" #include "struct/frustum.h" #include "struct/plane.h" #include "struct/noise.h" #include "struct/box.h" #include "struct/color.h" #include "struct/io.h" #include "struct/cam.h" #include "struct/quat.h" #include "struct/euler.h" #include "struct/project.h" #include "struct/sphere.h" #include "struct/curve.h" #include "struct/affine2d.h" #include "struct/ray.h" #ifdef __cplusplus } #endif #endif /* cglm_structs_h */ cglm-0.9.6/include/cglm/struct/000077500000000000000000000000001475344456400163615ustar00rootroot00000000000000cglm-0.9.6/include/cglm/struct/aabb2d.h000066400000000000000000000131111475344456400176420ustar00rootroot00000000000000/* * 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(aabb2d, 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 getting a bbox which fits with view frustum and * object bounding boxes. In this case you crop view frustum box with objects * box * * @param[in] 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 getting a bbox which fits with view frustum and * object bounding boxes. In this case you crop view frustum box with objects * box * * @param[in] aabb bounding box * @param[in] cropAabb crop box * @param[in] clampAabb minimum 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_(diag)(vec2s aabb[2]) { vec2 rawAabb[2]; glms_vec2_(unpack)(rawAabb, aabb, 2); return glm_aabb2d_diag(rawAabb); } /*! * @brief size of aabb * * @param[in] aabb bounding aabb * @param[out] dest size */ CGLM_INLINE vec2s glms_aabb2d_(sizev)(vec2s aabb[2]) { vec2s size; vec2 rawAabb[2]; glms_vec2_(unpack)(rawAabb, aabb, 2); glm_aabb2d_sizev(rawAabb, size.raw); return size; } /*! * @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 */ cglm-0.9.6/include/cglm/struct/affine-mat.h000066400000000000000000000036731475344456400205520ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ /* Functions: CGLM_INLINE mat4s glms_mul(mat4 m1, mat4 m2); CGLM_INLINE mat4s glms_mul_rot(mat4 m1, mat4 m2); CGLM_INLINE mat4s glms_inv_tr(); */ #ifndef cglms_affine_mat_h #define cglms_affine_mat_h #include "../common.h" #include "../types-struct.h" #include "../affine-mat.h" #include "vec3.h" #include "vec4.h" #include "mat4.h" /*! * @brief this is similar to glms_mat4_mul but specialized to affine transform * * Matrix format should be: * R R R X * R R R Y * R R R Z * 0 0 0 W * * this reduces some multiplications. It should be faster than mat4_mul. * if you are not sure about matrix format then DON'T use this! use mat4_mul * * @param[in] m1 affine matrix 1 * @param[in] m2 affine matrix 2 * @returns destination matrix */ CGLM_INLINE mat4s glms_mul(mat4s m1, mat4s m2){ mat4s r; glm_mul(m1.raw, m2.raw, r.raw); return r; } /*! * @brief this is similar to glm_mat4_mul but specialized to affine transform * * Right Matrix format should be: * R R R 0 * R R R 0 * R R R 0 * 0 0 0 1 * * this reduces some multiplications. It should be faster than mat4_mul. * if you are not sure about matrix format then DON'T use this! use mat4_mul * * @param[in] m1 affine matrix 1 * @param[in] m2 affine matrix 2 * @returns destination matrix */ CGLM_INLINE mat4s glms_mul_rot(mat4s m1, mat4s m2){ mat4s r; glm_mul_rot(m1.raw, m2.raw, r.raw); return r; } /*! * @brief inverse orthonormal rotation + translation matrix (ridig-body) * * @code * X = | R T | X' = | R' -R'T | * | 0 1 | | 0 1 | * @endcode * * @param[in] m matrix * @returns destination matrix */ CGLM_INLINE mat4s glms_inv_tr(mat4s m){ glm_inv_tr(m.raw); return m; } #endif /* cglms_affine_mat_h */ cglm-0.9.6/include/cglm/struct/affine-post.h000066400000000000000000000107041475344456400207470ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ /* Functions: CGLM_INLINE mat4s glms_translated(mat4s m, vec3s v); CGLM_INLINE mat4s glms_translated_x(mat4s m, float x); CGLM_INLINE mat4s glms_translated_y(mat4s m, float y); CGLM_INLINE mat4s glms_translated_z(mat4s m, float z); CGLM_INLINE mat4s glms_rotated_x(mat4s m, float angle); CGLM_INLINE mat4s glms_rotated_y(mat4s m, float angle); CGLM_INLINE mat4s glms_rotated_z(mat4s m, float angle); CGLM_INLINE mat4s glms_rotated(mat4s m, float angle, vec3s axis); CGLM_INLINE mat4s glms_rotated_at(mat4s m, vec3s pivot, float angle, vec3s axis); CGLM_INLINE mat4s glms_spinned(mat4s m, float angle, vec3s axis); */ #ifndef cglms_affines_post_h #define cglms_affines_post_h #include "../common.h" #include "../types-struct.h" #include "../affine.h" #include "vec3.h" #include "vec4.h" #include "mat4.h" /*! * @brief translate existing transform matrix by v vector * and stores result in same matrix * * @param[in] m affine transform * @param[in] v translate vector [x, y, z] * @returns affine transform */ CGLM_INLINE mat4s glms_translated(mat4s m, vec3s v) { glm_translated(m.raw, v.raw); return m; } /*! * @brief translate existing transform matrix by x factor * * @param[in] m affine transform * @param[in] x x factor * @returns affine transform */ CGLM_INLINE mat4s glms_translated_x(mat4s m, float x) { glm_translated_x(m.raw, x); return m; } /*! * @brief translate existing transform matrix by y factor * * @param[in] m affine transform * @param[in] y y factor * @returns affine transform */ CGLM_INLINE mat4s glms_translated_y(mat4s m, float y) { glm_translated_y(m.raw, y); return m; } /*! * @brief translate existing transform matrix by z factor * * @param[in] m affine transform * @param[in] z z factor * @returns affine transform */ CGLM_INLINE mat4s glms_translated_z(mat4s m, float z) { glm_translated_z(m.raw, z); return m; } /*! * @brief rotate existing transform matrix around X axis by angle * and store result in dest * * @param[in] m affine transform * @param[in] angle angle (radians) * @returns rotated matrix */ CGLM_INLINE mat4s glms_rotated_x(mat4s m, float angle) { mat4s r; glm_rotated_x(m.raw, angle, r.raw); return r; } /*! * @brief rotate existing transform matrix around Y axis by angle * and store result in dest * * @param[in] m affine transform * @param[in] angle angle (radians) * @returns rotated matrix */ CGLM_INLINE mat4s glms_rotated_y(mat4s m, float angle) { mat4s r; glm_rotated_y(m.raw, angle, r.raw); return r; } /*! * @brief rotate existing transform matrix around Z axis by angle * and store result in dest * * @param[in] m affine transform * @param[in] angle angle (radians) * @returns rotated matrix */ CGLM_INLINE mat4s glms_rotated_z(mat4s m, float angle) { mat4s r; glm_rotated_z(m.raw, angle, r.raw); return r; } /*! * @brief rotate existing transform matrix around given axis by angle * * @param[in] m affine transform * @param[in] angle angle (radians) * @param[in] axis axis * @returns affine transform */ CGLM_INLINE mat4s glms_rotated(mat4s m, float angle, vec3s axis) { glm_rotated(m.raw, angle, axis.raw); return m; } /*! * @brief rotate existing transform * around given axis by angle at given pivot point (rotation center) * * @param[in] m affine transform * @param[in] pivot rotation center * @param[in] angle angle (radians) * @param[in] axis axis * @returns affine transform */ CGLM_INLINE mat4s glms_rotated_at(mat4s m, vec3s pivot, float angle, vec3s axis) { glm_rotated_at(m.raw, pivot.raw, angle, axis.raw); return m; } /*! * @brief rotate existing transform matrix around given axis by angle around self (doesn't affected by position) * * @param[in] m affine transform * @param[in] angle angle (radians) * @param[in] axis axis * @returns affine transform */ CGLM_INLINE mat4s glms_spinned(mat4s m, float angle, vec3s axis) { glm_spinned(m.raw, angle, axis.raw); return m; } #endif /* cglms_affines_post_h */ cglm-0.9.6/include/cglm/struct/affine-pre.h000066400000000000000000000106351475344456400205530ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ /* Functions: CGLM_INLINE mat4s glms_translate(mat4s m, vec3s v); CGLM_INLINE mat4s glms_translate_x(mat4s m, float x); CGLM_INLINE mat4s glms_translate_y(mat4s m, float y); CGLM_INLINE mat4s glms_translate_z(mat4s m, float z); CGLM_INLINE mat4s glms_rotate_x(mat4s m, float angle); CGLM_INLINE mat4s glms_rotate_y(mat4s m, float angle); CGLM_INLINE mat4s glms_rotate_z(mat4s m, float angle); 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_spin(mat4s m, float angle, vec3s axis); */ #ifndef cglms_affines_pre_h #define cglms_affines_pre_h #include "../common.h" #include "../types-struct.h" #include "../affine.h" #include "vec3.h" #include "vec4.h" #include "mat4.h" /*! * @brief translate existing transform matrix by v vector * and stores result in same matrix * * @param[in] m affine transform * @param[in] v translate vector [x, y, z] * @returns affine transform */ CGLM_INLINE mat4s glms_translate(mat4s m, vec3s v) { glm_translate(m.raw, v.raw); return m; } /*! * @brief translate existing transform matrix by x factor * * @param[in] m affine transform * @param[in] x x factor * @returns affine transform */ CGLM_INLINE mat4s glms_translate_x(mat4s m, float x) { glm_translate_x(m.raw, x); return m; } /*! * @brief translate existing transform matrix by y factor * * @param[in] m affine transform * @param[in] y y factor * @returns affine transform */ CGLM_INLINE mat4s glms_translate_y(mat4s m, float y) { glm_translate_y(m.raw, y); return m; } /*! * @brief translate existing transform matrix by z factor * * @param[in] m affine transform * @param[in] z z factor * @returns affine transform */ CGLM_INLINE mat4s glms_translate_z(mat4s m, float z) { glm_translate_z(m.raw, z); return m; } /*! * @brief rotate existing transform matrix around X axis by angle * and store result in dest * * @param[in] m affine transform * @param[in] angle angle (radians) * @returns rotated matrix */ CGLM_INLINE mat4s glms_rotate_x(mat4s m, float angle) { mat4s r; glm_rotate_x(m.raw, angle, r.raw); return r; } /*! * @brief rotate existing transform matrix around Y axis by angle * and store result in dest * * @param[in] m affine transform * @param[in] angle angle (radians) * @returns rotated matrix */ CGLM_INLINE mat4s glms_rotate_y(mat4s m, float angle) { mat4s r; glm_rotate_y(m.raw, angle, r.raw); return r; } /*! * @brief rotate existing transform matrix around Z axis by angle * and store result in dest * * @param[in] m affine transform * @param[in] angle angle (radians) * @returns rotated matrix */ CGLM_INLINE mat4s glms_rotate_z(mat4s m, float angle) { mat4s r; glm_rotate_z(m.raw, angle, r.raw); return r; } /*! * @brief rotate existing transform matrix around given axis by angle * * @param[in] m affine transform * @param[in] angle angle (radians) * @param[in] axis axis * @returns affine transform */ CGLM_INLINE mat4s glms_rotate(mat4s m, float angle, vec3s axis) { glm_rotate(m.raw, angle, axis.raw); return m; } /*! * @brief rotate existing transform * around given axis by angle at given pivot point (rotation center) * * @param[in] m affine transform * @param[in] pivot rotation center * @param[in] angle angle (radians) * @param[in] axis axis * @returns affine transform */ CGLM_INLINE mat4s glms_rotate_at(mat4s m, vec3s pivot, float angle, vec3s axis) { glm_rotate_at(m.raw, pivot.raw, angle, axis.raw); return m; } /*! * @brief rotate existing transform matrix around given axis by angle around self (doesn't affected by position) * * @param[in] m affine transform * @param[in] angle angle (radians) * @param[in] axis axis * @returns affine transform */ CGLM_INLINE mat4s glms_spin(mat4s m, float angle, vec3s axis) { glm_spin(m.raw, angle, axis.raw); return m; } #endif /* cglms_affines_pre_h */ cglm-0.9.6/include/cglm/struct/affine.h000066400000000000000000000117031475344456400177640ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ /* Functions: CGLM_INLINE mat4s glms_translate(mat4s m, vec3s v); CGLM_INLINE mat4s glms_translate_x(mat4s m, float x); CGLM_INLINE mat4s glms_translate_y(mat4s m, float y); CGLM_INLINE mat4s glms_translate_z(mat4s m, float z); CGLM_INLINE mat4s glms_translate_make(vec3s v); CGLM_INLINE mat4s glms_scale_to(mat4s m, vec3s v); CGLM_INLINE mat4s glms_scale_make(vec3s v); CGLM_INLINE mat4s glms_scale(mat4s m, vec3s v); CGLM_INLINE mat4s glms_scale_uni(mat4s m, float s); CGLM_INLINE mat4s glms_rotate_x(mat4s m, float angle); CGLM_INLINE mat4s glms_rotate_y(mat4s m, float angle); CGLM_INLINE mat4s glms_rotate_z(mat4s m, float angle); 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_at(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 vec3s glms_decompose_scalev(mat4s m); CGLM_INLINE bool glms_uniscaled(mat4s m); CGLM_INLINE void glms_decompose_rs(mat4s m, mat4s * r, vec3s * s); CGLM_INLINE void glms_decompose(mat4s m, vec4s t, mat4s * r, vec3s * s); */ #ifndef cglms_affines_h #define cglms_affines_h #include "../common.h" #include "../types-struct.h" #include "../affine.h" #include "vec3.h" #include "vec4.h" #include "mat4.h" #include "affine-mat.h" /*! * @brief creates NEW translate transform matrix by v vector * * @param[in] v translate vector [x, y, z] * @returns affine transform */ CGLM_INLINE mat4s glms_translate_make(vec3s v) { mat4s m; glm_translate_make(m.raw, v.raw); return m; } /*! * @brief creates NEW scale matrix by v vector * * @param[in] v scale vector [x, y, z] * @returns affine transform */ CGLM_INLINE mat4s glms_scale_make(vec3s v) { mat4s m; glm_scale_make(m.raw, v.raw); return m; } /*! * @brief scales existing transform matrix by v vector * and stores result in same matrix * * @param[in] m affine transform * @param[in] v scale vector [x, y, z] * @returns affine transform */ CGLM_INLINE mat4s glms_scale(mat4s m, vec3s v) { mat4s r; glm_scale_to(m.raw, v.raw, r.raw); return r; } /*! * @brief applies uniform scale to existing transform matrix v = [s, s, s] * and stores result in same matrix * * @param[in] m affine transform * @param[in] s scale factor * @returns affine transform */ CGLM_INLINE mat4s glms_scale_uni(mat4s m, float s) { glm_scale_uni(m.raw, s); return m; } /*! * @brief creates NEW rotation matrix by angle and axis * * axis will be normalized so you don't need to normalize it * * @param[in] angle angle (radians) * @param[in] axis axis * @returns affine transform */ CGLM_INLINE mat4s glms_rotate_make(float angle, vec3s axis) { mat4s m; glm_rotate_make(m.raw, angle, axis.raw); return m; } /*! * @brief creates NEW rotation matrix by angle and axis at given point * * this creates rotation matrix, it assumes you don't have a matrix * * this should work faster than glm_rotate_at because it reduces * one glm_translate. * * @param[in] pivot rotation center * @param[in] angle angle (radians) * @param[in] axis axis * @returns affine transform */ CGLM_INLINE mat4s glms_rotate_atm(vec3s pivot, float angle, vec3s axis) { mat4s m; glm_rotate_atm(m.raw, pivot.raw, angle, axis.raw); return m; } /*! * @brief decompose scale vector * * @param[in] m affine transform * @returns scale vector (Sx, Sy, Sz) */ CGLM_INLINE vec3s glms_decompose_scalev(mat4s m) { vec3s r; glm_decompose_scalev(m.raw, r.raw); return r; } /*! * @brief returns true if matrix is uniform scaled. This is helpful for * creating normal matrix. * * @param[in] m m * * @return boolean */ CGLM_INLINE bool glms_uniscaled(mat4s m) { return glm_uniscaled(m.raw); } /*! * @brief decompose rotation matrix (mat4) and scale vector [Sx, Sy, Sz] * DON'T pass projected matrix here * * @param[in] m affine transform * @param[out] r rotation matrix * @param[out] s scale matrix */ CGLM_INLINE void glms_decompose_rs(mat4s m, mat4s * __restrict r, vec3s * __restrict s) { glm_decompose_rs(m.raw, r->raw, s->raw); } /*! * @brief decompose affine transform, TODO: extract shear factors. * DON'T pass projected matrix here * * @param[in] m affine transform * @param[out] t translation vector * @param[out] r rotation matrix (mat4) * @param[out] s scaling vector [X, Y, Z] */ CGLM_INLINE void glms_decompose(mat4s m, vec4s * __restrict t, mat4s * __restrict r, vec3s * __restrict s) { glm_decompose(m.raw, t->raw, r->raw, s->raw); } #include "affine-pre.h" #include "affine-post.h" #endif /* cglms_affines_h */ cglm-0.9.6/include/cglm/struct/affine2d.h000066400000000000000000000074421475344456400202170ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ /* Functions: CGLM_INLINE mat3s glms_translate2d(mat3 m, vec2 v) CGLM_INLINE mat3s glms_translate2d_x(mat3s m, float x) CGLM_INLINE mat3s glms_translate2d_y(mat3s m, float y) CGLM_INLINE mat3s glms_translate2d_make(vec2s v) CGLM_INLINE mat3s glms_scale2d_make(vec2s v) CGLM_INLINE mat3s glms_scale2d(mat3s m, vec2s v) CGLM_INLINE mat3s glms_scale2d_uni(mat3s m, float s) CGLM_INLINE mat3s glms_rotate2d_make(float angle) CGLM_INLINE mat3s glms_rotate2d(mat3s m, float angle) CGLM_INLINE mat3s glms_rotate2d_to(mat3s m, float angle) */ #ifndef cglms_affine2ds_h #define cglms_affine2ds_h #include "../common.h" #include "../types-struct.h" #include "../affine2d.h" #include "vec3.h" #include "mat3.h" /*! * @brief translate existing 2d transform matrix by v vector * and stores result in same matrix * * @param[in] m affine transform * @param[in] v translate vector [x, y] * @returns affine transform */ CGLM_INLINE mat3s glms_translate2d(mat3s m, vec2s v) { glm_translate2d(m.raw, v.raw); return m; } /*! * @brief translate existing 2d transform matrix by x factor * * @param[in] m affine transform * @param[in] x x factor * @returns affine transform */ CGLM_INLINE mat3s glms_translate2d_x(mat3s m, float x) { glm_translate2d_x(m.raw, x); return m; } /*! * @brief translate existing 2d transform matrix by y factor * * @param[in] m affine transform * @param[in] y y factor * @returns affine transform */ CGLM_INLINE mat3s glms_translate2d_y(mat3s m, float y) { glm_translate2d_y(m.raw, y); return m; } /*! * @brief creates NEW translate 2d transform matrix by v vector * * @param[in] v translate vector [x, y] * @returns affine transform */ CGLM_INLINE mat3s glms_translate2d_make(vec2s v) { mat3s m; glm_translate2d_make(m.raw, v.raw); return m; } /*! * @brief creates NEW 2d scale matrix by v vector * * @param[in] v scale vector [x, y] * @returns affine transform */ CGLM_INLINE mat3s glms_scale2d_make(vec2s v) { mat3s m; glm_scale2d_make(m.raw, v.raw); return m; } /*! * @brief scales existing 2d transform matrix by v vector * and stores result in same matrix * * @param[in] m affine transform * @param[in] v scale vector [x, y, z] * @returns affine transform */ CGLM_INLINE mat3s glms_scale2d(mat3s m, vec2s v) { mat3s r; glm_scale2d_to(m.raw, v.raw, r.raw); return r; } /*! * @brief applies uniform scale to existing 2d transform matrix v = [s, s, s] * and stores result in same matrix * * @param[in] m affine transform * @param[in] s scale factor * @returns affine transform */ CGLM_INLINE mat3s glms_scale2d_uni(mat3s m, float s) { glm_scale2d_uni(m.raw, s); return m; } /*! * @brief creates NEW 2d rotation matrix by angle and axis * * axis will be normalized so you don't need to normalize it * * @param[in] angle angle (radians) * @returns affine transform */ CGLM_INLINE mat3s glms_rotate2d_make(float angle) { mat3s m; glm_rotate2d_make(m.raw, angle); return m; } /*! * @brief rotate existing 2d transform matrix around given axis by angle * * @param[in] m affine transform * @param[in] angle angle (radians) * @returns affine transform */ CGLM_INLINE mat3s glms_rotate2d(mat3s m, float angle) { glm_rotate2d(m.raw, angle); return m; } /*! * @brief rotate existing 2d transform matrix around given axis by angle * * @param[in] m affine transform * @param[in] angle angle (radians) * @returns affine transform */ CGLM_INLINE mat3s glms_rotate2d_to(mat3s m, float angle) { glm_rotate2d(m.raw, angle); return m; } #endif /* cglms_affine2ds_h */ cglm-0.9.6/include/cglm/struct/box.h000066400000000000000000000135421475344456400173270ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ #ifndef cglms_boxs_h #define cglms_boxs_h #include "../common.h" #include "../types-struct.h" #include "../box.h" #include "vec3.h" #include "vec4.h" #include "mat4.h" /* api definition */ #define glms_aabb_(NAME) CGLM_STRUCTAPI(aabb, NAME) /*! * @brief apply transform to Axis-Aligned Bounding Box * * @param[in] box bounding box * @param[in] m transform matrix * @param[out] dest transformed bounding box */ CGLM_INLINE void glms_aabb_(transform)(vec3s box[2], mat4s m, vec3s dest[2]) { vec3 rawBox[2]; vec3 rawDest[2]; glms_vec3_(unpack)(rawBox, box, 2); glm_aabb_transform(rawBox, m.raw, rawDest); glms_vec3_(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] box1 bounding box 1 * @param[in] box2 bounding box 2 * @param[out] dest merged bounding box */ CGLM_INLINE void glms_aabb_(merge)(vec3s box1[2], vec3s box2[2], vec3s dest[2]) { vec3 rawBox1[2]; vec3 rawBox2[2]; vec3 rawDest[2]; glms_vec3_(unpack)(rawBox1, box1, 2); glms_vec3_(unpack)(rawBox2, box2, 2); glm_aabb_merge(rawBox1, rawBox2, rawDest); glms_vec3_(pack)(dest, rawDest, 2); } /*! * @brief crops a bounding box with another one. * * this could be useful for getting a bbox which fits with view frustum and * object bounding boxes. In this case you crop view frustum box with objects * box * * @param[in] box bounding box 1 * @param[in] cropBox crop box * @param[out] dest cropped bounding box */ CGLM_INLINE void glms_aabb_(crop)(vec3s box[2], vec3s cropBox[2], vec3s dest[2]) { vec3 rawBox[2]; vec3 rawCropBox[2]; vec3 rawDest[2]; glms_vec3_(unpack)(rawBox, box, 2); glms_vec3_(unpack)(rawCropBox, cropBox, 2); glm_aabb_crop(rawBox, rawCropBox, rawDest); glms_vec3_(pack)(dest, rawDest, 2); } /*! * @brief crops a bounding box with another one. * * this could be useful for getting a bbox which fits with view frustum and * object bounding boxes. In this case you crop view frustum box with objects * box * * @param[in] box bounding box * @param[in] cropBox crop box * @param[in] clampBox minimum box * @param[out] dest cropped bounding box */ CGLM_INLINE void glms_aabb_(crop_until)(vec3s box[2], vec3s cropBox[2], vec3s clampBox[2], vec3s dest[2]) { glms_aabb_(crop)(box, cropBox, dest); glms_aabb_(merge)(clampBox, dest, dest); } /*! * @brief check if AABB intersects with frustum planes * * this could be useful for frustum culling using AABB. * * OPTIMIZATION HINT: * if planes order is similar to LEFT, RIGHT, BOTTOM, TOP, NEAR, FAR * then this method should run even faster because it would only use two * planes if object is not inside the two planes * fortunately cglm extracts planes as this order! just pass what you got! * * @param[in] box bounding box * @param[in] planes frustum planes */ CGLM_INLINE bool glms_aabb_(frustum)(vec3s box[2], vec4s planes[6]) { vec3 rawBox[2]; vec4 rawPlanes[6]; glms_vec3_(unpack)(rawBox, box, 2); glms_vec4_(unpack)(rawPlanes, planes, 6); return glm_aabb_frustum(rawBox, rawPlanes); } /*! * @brief invalidate AABB min and max values * * @param[in, out] box bounding box */ CGLM_INLINE void glms_aabb_(invalidate)(vec3s box[2]) { box[0] = glms_vec3_(broadcast)(FLT_MAX); box[1] = glms_vec3_(broadcast)(-FLT_MAX); } /*! * @brief check if AABB is valid or not * * @param[in] box bounding box */ CGLM_INLINE bool glms_aabb_(isvalid)(vec3s box[2]) { vec3 rawBox[2]; glms_vec3_(unpack)(rawBox, box, 2); return glm_aabb_isvalid(rawBox); } /*! * @brief distance between of min and max * * @param[in] box bounding box */ CGLM_INLINE float glms_aabb_(size)(vec3s box[2]) { return glm_vec3_distance(box[0].raw, box[1].raw); } /*! * @brief radius of sphere which surrounds AABB * * @param[in] box bounding box */ CGLM_INLINE float glms_aabb_(radius)(vec3s box[2]) { return glms_aabb_(size)(box) * 0.5f; } /*! * @brief computes center point of AABB * * @param[in] box bounding box * @returns center of bounding box */ CGLM_INLINE vec3s glms_aabb_(center)(vec3s box[2]) { return glms_vec3_(center)(box[0], box[1]); } /*! * @brief check if two AABB intersects * * @param[in] box bounding box * @param[in] other other bounding box */ CGLM_INLINE bool glms_aabb_(aabb)(vec3s box[2], vec3s other[2]) { vec3 rawBox[2]; vec3 rawOther[2]; glms_vec3_(unpack)(rawBox, box, 2); glms_vec3_(unpack)(rawOther, other, 2); return glm_aabb_aabb(rawBox, rawOther); } /*! * @brief check if AABB intersects with sphere * * https://github.com/erich666/GraphicsGems/blob/master/gems/BoxSphere.c * Solid Box - Solid Sphere test. * * @param[in] box solid bounding box * @param[in] s solid sphere */ CGLM_INLINE bool glms_aabb_(sphere)(vec3s box[2], vec4s s) { vec3 rawBox[2]; glms_vec3_(unpack)(rawBox, box, 2); return glm_aabb_sphere(rawBox, s.raw); } /*! * @brief check if point is inside of AABB * * @param[in] box bounding box * @param[in] point point */ CGLM_INLINE bool glms_aabb_(point)(vec3s box[2], vec3s point) { vec3 rawBox[2]; glms_vec3_(unpack)(rawBox, box, 2); return glm_aabb_point(rawBox, point.raw); } /*! * @brief check if AABB contains other AABB * * @param[in] box bounding box * @param[in] other other bounding box */ CGLM_INLINE bool glms_aabb_(contains)(vec3s box[2], vec3s other[2]) { vec3 rawBox[2]; vec3 rawOther[2]; glms_vec3_(unpack)(rawBox, box, 2); glms_vec3_(unpack)(rawOther, other, 2); return glm_aabb_contains(rawBox, rawOther); } #endif /* cglms_boxs_h */ cglm-0.9.6/include/cglm/struct/cam.h000066400000000000000000000535371475344456400173070ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ /* Functions: CGLM_INLINE mat4s glms_frustum(float left, float right, float bottom, float top, float nearZ, float farZ) CGLM_INLINE mat4s glms_ortho(float left, float right, float bottom, float top, float nearZ, float farZ) CGLM_INLINE mat4s glms_ortho_aabb(vec3s box[2]); CGLM_INLINE mat4s glms_ortho_aabb_p(vec3s box[2], float padding); CGLM_INLINE mat4s glms_ortho_aabb_pz(vec3s box[2], float padding); CGLM_INLINE mat4s glms_ortho_default(float aspect) CGLM_INLINE mat4s glms_ortho_default_s(float aspect, float size) CGLM_INLINE mat4s glms_perspective(float fovy, float aspect, float nearZ, float farZ) CGLM_INLINE void glms_persp_move_far(mat4s proj, float deltaFar) CGLM_INLINE mat4s glms_perspective_default(float aspect) CGLM_INLINE void glms_perspective_resize(mat4s proj, float aspect) CGLM_INLINE mat4s glms_lookat(vec3s eye, vec3s center, vec3s up) CGLM_INLINE mat4s glms_look(vec3s eye, vec3s dir, vec3s up) CGLM_INLINE mat4s glms_look_anyup(vec3s eye, vec3s dir) CGLM_INLINE void glms_persp_decomp(mat4s proj, float *nearv, float *farv, float *top, float *bottom, float *left, float *right) CGLM_INLINE void glms_persp_decompv(mat4s proj, float dest[6]) CGLM_INLINE void glms_persp_decomp_x(mat4s proj, float *left, float *right) CGLM_INLINE void glms_persp_decomp_y(mat4s proj, float *top, float *bottom) CGLM_INLINE void glms_persp_decomp_z(mat4s proj, float *nearv, float *farv) CGLM_INLINE void glms_persp_decomp_far(mat4s proj, float *farZ) CGLM_INLINE void glms_persp_decomp_near(mat4s proj, float *nearZ) CGLM_INLINE float glms_persp_fovy(mat4s proj) CGLM_INLINE float glms_persp_aspect(mat4s proj) CGLM_INLINE vec4s glms_persp_sizes(mat4s proj, float fovy) */ #ifndef cglms_cam_h #define cglms_cam_h #include "../common.h" #include "../types-struct.h" #include "../plane.h" #include "../cam.h" #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 /*! * @brief set up perspective peprojection matrix * * @param[in] left viewport.left * @param[in] right viewport.right * @param[in] bottom viewport.bottom * @param[in] top viewport.top * @param[in] nearZ near clipping plane * @param[in] farZ far clipping plane * @returns result matrix */ CGLM_INLINE mat4s glms_frustum(float left, float right, float bottom, float top, float nearZ, float farZ) { #if CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_LH_ZO return glms_frustum_lh_zo(left, right, bottom, top, nearZ, farZ); #elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_LH_NO return glms_frustum_lh_no(left, right, bottom, top, nearZ, farZ); #elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_RH_ZO return glms_frustum_rh_zo(left, right, bottom, top, nearZ, farZ); #elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_RH_NO return glms_frustum_rh_no(left, right, bottom, top, nearZ, farZ); #endif } /*! * @brief set up orthographic projection matrix * * @param[in] left viewport.left * @param[in] right viewport.right * @param[in] bottom viewport.bottom * @param[in] top viewport.top * @param[in] nearZ near clipping plane * @param[in] farZ far clipping plane * @returns result matrix */ CGLM_INLINE mat4s glms_ortho(float left, float right, float bottom, float top, float nearZ, float farZ) { #if CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_LH_ZO return glms_ortho_lh_zo(left, right, bottom, top, nearZ, farZ); #elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_LH_NO return glms_ortho_lh_no(left, right, bottom, top, nearZ, farZ); #elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_RH_ZO return glms_ortho_rh_zo(left, right, bottom, top, nearZ, farZ); #elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_RH_NO return glms_ortho_rh_no(left, right, bottom, top, nearZ, farZ); #endif } /*! * @brief set up orthographic projection matrix using bounding box * * bounding box (AABB) must be in view space * * @param[in] box AABB * @returns result matrix */ CGLM_INLINE mat4s glms_ortho_aabb(vec3s box[2]) { #if CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_LH_ZO return glms_ortho_aabb_lh_zo(box); #elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_LH_NO return glms_ortho_aabb_lh_no(box); #elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_RH_ZO return glms_ortho_aabb_rh_zo(box); #elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_RH_NO return glms_ortho_aabb_rh_no(box); #endif } /*! * @brief set up orthographic projection matrix using bounding box * * bounding box (AABB) must be in view space * * @param[in] box AABB * @param[in] padding padding * @returns result matrix */ CGLM_INLINE mat4s glms_ortho_aabb_p(vec3s box[2], float padding) { #if CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_LH_ZO return glms_ortho_aabb_p_lh_zo(box, padding); #elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_LH_NO return glms_ortho_aabb_p_lh_no(box, padding); #elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_RH_ZO return glms_ortho_aabb_p_rh_zo(box, padding); #elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_RH_NO return glms_ortho_aabb_p_rh_no(box, padding); #endif } /*! * @brief set up orthographic projection matrix using bounding box * * bounding box (AABB) must be in view space * * @param[in] box AABB * @param[in] padding padding for near and far * @returns result matrix */ CGLM_INLINE mat4s glms_ortho_aabb_pz(vec3s box[2], float padding) { #if CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_LH_ZO return glms_ortho_aabb_pz_lh_zo(box, padding); #elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_LH_NO return glms_ortho_aabb_pz_lh_no(box, padding); #elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_RH_ZO return glms_ortho_aabb_pz_rh_zo(box, padding); #elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_RH_NO return glms_ortho_aabb_pz_rh_no(box, padding); #endif } /*! * @brief set up unit orthographic projection matrix * * @param[in] aspect aspect ration ( width / height ) * @returns result matrix */ CGLM_INLINE mat4s glms_ortho_default(float aspect) { #if CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_LH_ZO return glms_ortho_default_lh_zo(aspect); #elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_LH_NO return glms_ortho_default_lh_no(aspect); #elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_RH_ZO return glms_ortho_default_rh_zo(aspect); #elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_RH_NO return glms_ortho_default_rh_no(aspect); #endif } /*! * @brief set up orthographic projection matrix with given CUBE size * * @param[in] aspect aspect ratio ( width / height ) * @param[in] size cube size * @returns result matrix */ CGLM_INLINE mat4s glms_ortho_default_s(float aspect, float size) { #if CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_LH_ZO return glms_ortho_default_s_lh_zo(aspect, size); #elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_LH_NO return glms_ortho_default_s_lh_no(aspect, size); #elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_RH_ZO return glms_ortho_default_s_rh_zo(aspect, size); #elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_RH_NO return glms_ortho_default_s_rh_no(aspect, size); #endif } /*! * @brief set up perspective projection matrix * * @param[in] fovy field of view angle * @param[in] aspect aspect ratio ( width / height ) * @param[in] nearZ near clipping plane * @param[in] farZ far clipping planes * @returns result matrix */ CGLM_INLINE mat4s glms_perspective(float fovy, float aspect, float nearZ, float farZ) { #if CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_LH_ZO return glms_perspective_lh_zo(fovy, aspect, nearZ, farZ); #elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_LH_NO return glms_perspective_lh_no(fovy, aspect, nearZ, farZ); #elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_RH_ZO return glms_perspective_rh_zo(fovy, aspect, nearZ, farZ); #elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_RH_NO return glms_perspective_rh_no(fovy, aspect, nearZ, farZ); #endif } /*! * @brief extend perspective projection matrix's far distance * * NOTE: if you dodn't want to create new matrix then use array api on struct.raw * like glm_persp_move_far(prooj.raw, deltaFar) to avoid create new mat4 * each time * * this function does not guarantee far >= near, be aware of that! * * @param[in, out] proj projection matrix to extend * @param[in] deltaFar distance from existing far (negative to shink) */ CGLM_INLINE mat4s glms_persp_move_far(mat4s proj, float deltaFar) { #if CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_LH_ZO return glms_persp_move_far_lh_zo(proj, deltaFar); #elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_LH_NO return glms_persp_move_far_lh_no(proj, deltaFar); #elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_RH_ZO return glms_persp_move_far_rh_zo(proj, deltaFar); #elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_RH_NO return glms_persp_move_far_rh_no(proj, deltaFar); #endif } /*! * @brief set up perspective projection matrix with default near/far * and angle values * * @param[in] aspect aspect ratio ( width / height ) * @returns result matrix */ CGLM_INLINE mat4s glms_perspective_default(float aspect) { #if CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_LH_ZO return glms_perspective_default_lh_zo(aspect); #elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_LH_NO return glms_perspective_default_lh_no(aspect); #elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_RH_ZO return glms_perspective_default_rh_zo(aspect); #elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_RH_NO return glms_perspective_default_rh_no(aspect); #endif } /*! * @brief resize perspective matrix by aspect ratio ( width / height ) * this makes very easy to resize proj matrix when window /viewport * reized * * NOTE: if you dodn't want to create new matrix then use array api on struct.raw * like glms_perspective_resize(proj.raw, aspect) to avoid create new mat4 * each time * * @param[in, out] proj perspective projection matrix * @param[in] aspect aspect ratio ( width / height ) */ CGLM_INLINE mat4s glms_perspective_resize(mat4s proj, float aspect) { #if CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_LH_ZO return glms_perspective_resize_lh_zo(proj, aspect); #elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_LH_NO return glms_perspective_resize_lh_no(proj, aspect); #elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_RH_ZO return glms_perspective_resize_rh_zo(proj, aspect); #elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_RH_NO return glms_perspective_resize_rh_no(proj, aspect); #endif } /*! * @brief set up view matrix * * NOTE: The UP vector must not be parallel to the line of sight from * the eye point to the reference point * * @param[in] eye eye vector * @param[in] center center vector * @param[in] up up vector * @returns result matrix */ CGLM_INLINE mat4s glms_lookat(vec3s eye, vec3s center, vec3s up) { #if CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_LH_ZO return glms_lookat_lh_zo(eye, center, up); #elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_LH_NO return glms_lookat_lh_no(eye, center, up); #elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_RH_ZO return glms_lookat_rh_zo(eye, center, up); #elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_RH_NO return glms_lookat_rh_no(eye, center, up); #endif } /*! * @brief set up view matrix * * convenient wrapper for lookat: if you only have direction not target self * then this might be useful. Because you need to get target from direction. * * NOTE: The UP vector must not be parallel to the line of sight from * the eye point to the reference point * * @param[in] eye eye vector * @param[in] dir direction vector * @param[in] up up vector * @returns result matrix */ CGLM_INLINE mat4s glms_look(vec3s eye, vec3s dir, vec3s up) { #if CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_LH_ZO return glms_look_lh_zo(eye, dir, up); #elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_LH_NO return glms_look_lh_no(eye, dir, up); #elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_RH_ZO return glms_look_rh_zo(eye, dir, up); #elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_RH_NO return glms_look_rh_no(eye, dir, up); #endif } /*! * @brief set up view matrix * * convenient wrapper for look: if you only have direction and if you don't * care what UP vector is then this might be useful to create view matrix * * @param[in] eye eye vector * @param[in] dir direction vector * @returns result matrix */ CGLM_INLINE mat4s glms_look_anyup(vec3s eye, vec3s dir) { #if CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_LH_ZO return glms_look_anyup_lh_zo(eye, dir); #elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_LH_NO return glms_look_anyup_lh_no(eye, dir); #elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_RH_ZO return glms_look_anyup_rh_zo(eye, dir); #elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_RH_NO return glms_look_anyup_rh_no(eye, dir); #endif } /*! * @brief decomposes frustum values of perspective projection. * * @param[in] proj perspective projection matrix * @param[out] nearZ near * @param[out] farZ far * @param[out] top top * @param[out] bottom bottom * @param[out] left left * @param[out] right right */ CGLM_INLINE void glms_persp_decomp(mat4s proj, float * __restrict nearZ, float * __restrict farZ, float * __restrict top, float * __restrict bottom, float * __restrict left, float * __restrict right) { #if CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_LH_ZO glms_persp_decomp_lh_zo(proj, nearZ, farZ, top, bottom, left, right); #elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_LH_NO glms_persp_decomp_lh_no(proj, nearZ, farZ, top, bottom, left, right); #elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_RH_ZO glms_persp_decomp_rh_zo(proj, nearZ, farZ, top, bottom, left, right); #elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_RH_NO glms_persp_decomp_rh_no(proj, nearZ, farZ, top, bottom, left, right); #endif } /*! * @brief decomposes frustum values of perspective projection. * this makes easy to get all values at once * * @param[in] proj perspective projection matrix * @param[out] dest array */ CGLM_INLINE void glms_persp_decompv(mat4s proj, float dest[6]) { #if CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_LH_ZO glms_persp_decompv_lh_zo(proj, dest); #elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_LH_NO glms_persp_decompv_lh_no(proj, dest); #elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_RH_ZO glms_persp_decompv_rh_zo(proj, dest); #elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_RH_NO glms_persp_decompv_rh_no(proj, dest); #endif } /*! * @brief decomposes left and right values of perspective projection. * x stands for x axis (left / right axis) * * @param[in] proj perspective projection matrix * @param[out] left left * @param[out] right right */ CGLM_INLINE void glms_persp_decomp_x(mat4s proj, float * __restrict left, float * __restrict right) { #if CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_LH_ZO glms_persp_decomp_x_lh_zo(proj, left, right); #elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_LH_NO glms_persp_decomp_x_lh_no(proj, left, right); #elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_RH_ZO glms_persp_decomp_x_rh_zo(proj, left, right); #elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_RH_NO glms_persp_decomp_x_rh_no(proj, left, right); #endif } /*! * @brief decomposes top and bottom values of perspective projection. * y stands for y axis (top / bottom axis) * * @param[in] proj perspective projection matrix * @param[out] top top * @param[out] bottom bottom */ CGLM_INLINE void glms_persp_decomp_y(mat4s proj, float * __restrict top, float * __restrict bottom) { #if CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_LH_ZO glms_persp_decomp_y_lh_zo(proj, top, bottom); #elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_LH_NO glms_persp_decomp_y_lh_no(proj, top, bottom); #elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_RH_ZO glms_persp_decomp_y_rh_zo(proj, top, bottom); #elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_RH_NO glms_persp_decomp_y_rh_no(proj, top, bottom); #endif } /*! * @brief decomposes near and far values of perspective projection. * z stands for z axis (near / far axis) * * @param[in] proj perspective projection matrix * @param[out] nearZ near * @param[out] farZ far */ CGLM_INLINE void glms_persp_decomp_z(mat4s proj, float * __restrict nearZ, float * __restrict farZ) { #if CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_LH_ZO glms_persp_decomp_z_lh_zo(proj, nearZ, farZ); #elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_LH_NO glms_persp_decomp_z_lh_no(proj, nearZ, farZ); #elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_RH_ZO glms_persp_decomp_z_rh_zo(proj, nearZ, farZ); #elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_RH_NO glms_persp_decomp_z_rh_no(proj, nearZ, farZ); #endif } /*! * @brief decomposes far value of perspective projection. * * @param[in] proj perspective projection matrix * @param[out] farZ far */ CGLM_INLINE void glms_persp_decomp_far(mat4s proj, float * __restrict farZ) { #if CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_LH_ZO glms_persp_decomp_far_lh_zo(proj, farZ); #elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_LH_NO glms_persp_decomp_far_lh_no(proj, farZ); #elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_RH_ZO glms_persp_decomp_far_rh_zo(proj, farZ); #elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_RH_NO glms_persp_decomp_far_rh_no(proj, farZ); #endif } /*! * @brief decomposes near value of perspective projection. * * @param[in] proj perspective projection matrix * @param[out] nearZ near */ CGLM_INLINE void glms_persp_decomp_near(mat4s proj, float * __restrict nearZ) { #if CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_LH_ZO glms_persp_decomp_near_lh_zo(proj, nearZ); #elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_LH_NO glms_persp_decomp_near_lh_no(proj, nearZ); #elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_RH_ZO glms_persp_decomp_near_rh_zo(proj, nearZ); #elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_RH_NO glms_persp_decomp_near_rh_no(proj, nearZ); #endif } /*! * @brief returns field of view angle along the Y-axis (in radians) * * if you need to degrees, use glm_deg to convert it or use this: * fovy_deg = glm_deg(glm_persp_fovy(projMatrix)) * * @param[in] proj perspective projection matrix */ CGLM_INLINE float glms_persp_fovy(mat4s proj) { #if CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_LH_ZO return glms_persp_fovy_lh_zo(proj); #elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_LH_NO return glms_persp_fovy_lh_no(proj); #elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_RH_ZO return glms_persp_fovy_rh_zo(proj); #elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_RH_NO return glms_persp_fovy_rh_no(proj); #endif } /*! * @brief returns aspect ratio of perspective projection * * @param[in] proj perspective projection matrix */ CGLM_INLINE float glms_persp_aspect(mat4s proj) { #if CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_LH_ZO return glms_persp_aspect_lh_zo(proj); #elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_LH_NO return glms_persp_aspect_lh_no(proj); #elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_RH_ZO return glms_persp_aspect_rh_zo(proj); #elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_RH_NO return glms_persp_aspect_rh_no(proj); #endif } /*! * @brief returns sizes of near and far planes of perspective projection * * @param[in] proj perspective projection matrix * @param[in] fovy fovy (see brief) * @returns sizes as vector, sizes order: [Wnear, Hnear, Wfar, Hfar] */ CGLM_INLINE vec4s glms_persp_sizes(mat4s proj, float fovy) { #if CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_LH_ZO return glms_persp_sizes_lh_zo(proj, fovy); #elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_LH_NO return glms_persp_sizes_lh_no(proj, fovy); #elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_RH_ZO return glms_persp_sizes_rh_zo(proj, fovy); #elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_RH_NO return glms_persp_sizes_rh_no(proj, fovy); #endif } #endif /* cglms_cam_h */ cglm-0.9.6/include/cglm/struct/clipspace/000077500000000000000000000000001475344456400203245ustar00rootroot00000000000000cglm-0.9.6/include/cglm/struct/clipspace/ortho_lh_no.h000066400000000000000000000075351475344456400230210ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ /* Functions: CGLM_INLINE mat4s glms_ortho_lh_no(float left, float right, float bottom, float top, float nearZ, float farZ) CGLM_INLINE mat4s glms_ortho_aabb_lh_no(vec3s box[2]); CGLM_INLINE mat4s glms_ortho_aabb_p_lh_no(vec3s box[2], float padding); CGLM_INLINE mat4s glms_ortho_aabb_pz_lh_no(vec3s box[2], float padding); CGLM_INLINE mat4s glms_ortho_default_lh_no(float aspect) CGLM_INLINE mat4s glms_ortho_default_s_lh_no(float aspect, float size) */ #ifndef cglms_ortho_lh_no_h #define cglms_ortho_lh_no_h #include "../../common.h" #include "../../types-struct.h" #include "../../plane.h" #include "../../cam.h" #include "../vec3.h" #include "../../clipspace/ortho_lh_no.h" /*! * @brief set up orthographic projection matrix * with a left-hand coordinate system and a * clip-space of [-1, 1]. * * @param[in] left viewport.left * @param[in] right viewport.right * @param[in] bottom viewport.bottom * @param[in] top viewport.top * @param[in] nearZ near clipping plane * @param[in] farZ far clipping plane * @returns result matrix */ CGLM_INLINE mat4s glms_ortho_lh_no(float left, float right, float bottom, float top, float nearZ, float farZ) { mat4s dest; glm_ortho_lh_no(left, right, bottom, top, nearZ, farZ, dest.raw); return dest; } /*! * @brief set up orthographic projection matrix using bounding box * with a left-hand coordinate system and a * clip-space of [-1, 1]. * * bounding box (AABB) must be in view space * * @param[in] box AABB * @returns result matrix */ CGLM_INLINE mat4s glms_ortho_aabb_lh_no(vec3s box[2]) { mat4s dest; vec3 rawBox[2]; glms_vec3_(unpack)(rawBox, box, 2); glm_ortho_aabb_lh_no(rawBox, dest.raw); return dest; } /*! * @brief set up orthographic projection matrix using bounding box * with a left-hand coordinate system and a * clip-space of [-1, 1]. * * bounding box (AABB) must be in view space * * @param[in] box AABB * @param[in] padding padding * @returns result matrix */ CGLM_INLINE mat4s glms_ortho_aabb_p_lh_no(vec3s box[2], float padding) { mat4s dest; vec3 rawBox[2]; glms_vec3_(unpack)(rawBox, box, 2); glm_ortho_aabb_p_lh_no(rawBox, padding, dest.raw); return dest; } /*! * @brief set up orthographic projection matrix using bounding box * with a left-hand coordinate system and a * clip-space of [-1, 1]. * * bounding box (AABB) must be in view space * * @param[in] box AABB * @param[in] padding padding for near and far * @returns result matrix */ CGLM_INLINE mat4s glms_ortho_aabb_pz_lh_no(vec3s box[2], float padding) { mat4s dest; vec3 rawBox[2]; glms_vec3_(unpack)(rawBox, box, 2); glm_ortho_aabb_pz_lh_no(rawBox, padding, dest.raw); return dest; } /*! * @brief set up unit orthographic projection matrix * with a left-hand coordinate system and a * clip-space of [-1, 1]. * * @param[in] aspect aspect ration ( width / height ) * @returns result matrix */ CGLM_INLINE mat4s glms_ortho_default_lh_no(float aspect) { mat4s dest; glm_ortho_default_lh_no(aspect, dest.raw); return dest; } /*! * @brief set up orthographic projection matrix with given CUBE size * with a left-hand coordinate system and a * clip-space of [-1, 1]. * * @param[in] aspect aspect ratio ( width / height ) * @param[in] size cube size * @returns result matrix */ CGLM_INLINE mat4s glms_ortho_default_s_lh_no(float aspect, float size) { mat4s dest; glm_ortho_default_s_lh_no(aspect, size, dest.raw); return dest; } #endif /* cglms_ortho_lh_no_h */ cglm-0.9.6/include/cglm/struct/clipspace/ortho_lh_zo.h000066400000000000000000000075271475344456400230360ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ /* Functions: CGLM_INLINE mat4s glms_ortho_lh_zo(float left, float right, float bottom, float top, float nearZ, float farZ) CGLM_INLINE mat4s glms_ortho_aabb_lh_zo(vec3s box[2]); CGLM_INLINE mat4s glms_ortho_aabb_p_lh_zo(vec3s box[2], float padding); CGLM_INLINE mat4s glms_ortho_aabb_pz_lh_zo(vec3s box[2], float padding); CGLM_INLINE mat4s glms_ortho_default_lh_zo(float aspect) CGLM_INLINE mat4s glms_ortho_default_s_lh_zo(float aspect, float size) */ #ifndef cglms_ortho_lh_zo_h #define cglms_ortho_lh_zo_h #include "../../common.h" #include "../../types-struct.h" #include "../../plane.h" #include "../../cam.h" #include "../vec3.h" #include "../../clipspace/ortho_lh_zo.h" /*! * @brief set up orthographic projection matrix * with a left-hand coordinate system and a * clip-space of [0, 1]. * * @param[in] left viewport.left * @param[in] right viewport.right * @param[in] bottom viewport.bottom * @param[in] top viewport.top * @param[in] nearZ near clipping plane * @param[in] farZ far clipping plane * @returns result matrix */ CGLM_INLINE mat4s glms_ortho_lh_zo(float left, float right, float bottom, float top, float nearZ, float farZ) { mat4s dest; glm_ortho_lh_zo(left, right, bottom, top, nearZ, farZ, dest.raw); return dest; } /*! * @brief set up orthographic projection matrix using bounding box * with a left-hand coordinate system and a * clip-space of [0, 1]. * * bounding box (AABB) must be in view space * * @param[in] box AABB * @returns result matrix */ CGLM_INLINE mat4s glms_ortho_aabb_lh_zo(vec3s box[2]) { mat4s dest; vec3 rawBox[2]; glms_vec3_(unpack)(rawBox, box, 2); glm_ortho_aabb_lh_zo(rawBox, dest.raw); return dest; } /*! * @brief set up orthographic projection matrix using bounding box * with a left-hand coordinate system and a * clip-space of [0, 1]. * * bounding box (AABB) must be in view space * * @param[in] box AABB * @param[in] padding padding * @returns result matrix */ CGLM_INLINE mat4s glms_ortho_aabb_p_lh_zo(vec3s box[2], float padding) { mat4s dest; vec3 rawBox[2]; glms_vec3_(unpack)(rawBox, box, 2); glm_ortho_aabb_p_lh_zo(rawBox, padding, dest.raw); return dest; } /*! * @brief set up orthographic projection matrix using bounding box * with a left-hand coordinate system and a * clip-space of [0, 1]. * * bounding box (AABB) must be in view space * * @param[in] box AABB * @param[in] padding padding for near and far * @returns result matrix */ CGLM_INLINE mat4s glms_ortho_aabb_pz_lh_zo(vec3s box[2], float padding) { mat4s dest; vec3 rawBox[2]; glms_vec3_(unpack)(rawBox, box, 2); glm_ortho_aabb_pz_lh_zo(rawBox, padding, dest.raw); return dest; } /*! * @brief set up unit orthographic projection matrix * with a left-hand coordinate system and a * clip-space of [0, 1]. * * @param[in] aspect aspect ration ( width / height ) * @returns result matrix */ CGLM_INLINE mat4s glms_ortho_default_lh_zo(float aspect) { mat4s dest; glm_ortho_default_lh_zo(aspect, dest.raw); return dest; } /*! * @brief set up orthographic projection matrix with given CUBE size * with a left-hand coordinate system and a * clip-space of [0, 1]. * * @param[in] aspect aspect ratio ( width / height ) * @param[in] size cube size * @returns result matrix */ CGLM_INLINE mat4s glms_ortho_default_s_lh_zo(float aspect, float size) { mat4s dest; glm_ortho_default_s_lh_zo(aspect, size, dest.raw); return dest; } #endif /* cglms_ortho_lh_zo_h */ cglm-0.9.6/include/cglm/struct/clipspace/ortho_rh_no.h000066400000000000000000000075431475344456400230260ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ /* Functions: CGLM_INLINE mat4s glms_ortho_rh_no(float left, float right, float bottom, float top, float nearZ, float farZ) CGLM_INLINE mat4s glms_ortho_aabb_rh_no(vec3s box[2]); CGLM_INLINE mat4s glms_ortho_aabb_p_rh_no(vec3s box[2], float padding); CGLM_INLINE mat4s glms_ortho_aabb_pz_rh_no(vec3s box[2], float padding); CGLM_INLINE mat4s glms_ortho_default_rh_no(float aspect) CGLM_INLINE mat4s glms_ortho_default_s_rh_no(float aspect, float size) */ #ifndef cglms_ortho_rh_no_h #define cglms_ortho_rh_no_h #include "../../common.h" #include "../../types-struct.h" #include "../../plane.h" #include "../../cam.h" #include "../vec3.h" #include "../../clipspace/ortho_rh_no.h" /*! * @brief set up orthographic projection matrix * with a right-hand coordinate system and a * clip-space of [-1, 1]. * * @param[in] left viewport.left * @param[in] right viewport.right * @param[in] bottom viewport.bottom * @param[in] top viewport.top * @param[in] nearZ near clipping plane * @param[in] farZ far clipping plane * @returns result matrix */ CGLM_INLINE mat4s glms_ortho_rh_no(float left, float right, float bottom, float top, float nearZ, float farZ) { mat4s dest; glm_ortho_rh_no(left, right, bottom, top, nearZ, farZ, dest.raw); return dest; } /*! * @brief set up orthographic projection matrix using bounding box * with a right-hand coordinate system and a * clip-space of [-1, 1]. * * bounding box (AABB) must be in view space * * @param[in] box AABB * @returns result matrix */ CGLM_INLINE mat4s glms_ortho_aabb_rh_no(vec3s box[2]) { mat4s dest; vec3 rawBox[2]; glms_vec3_(unpack)(rawBox, box, 2); glm_ortho_aabb_rh_no(rawBox, dest.raw); return dest; } /*! * @brief set up orthographic projection matrix using bounding box * with a right-hand coordinate system and a * clip-space of [-1, 1]. * * bounding box (AABB) must be in view space * * @param[in] box AABB * @param[in] padding padding * @returns result matrix */ CGLM_INLINE mat4s glms_ortho_aabb_p_rh_no(vec3s box[2], float padding) { mat4s dest; vec3 rawBox[2]; glms_vec3_(unpack)(rawBox, box, 2); glm_ortho_aabb_p_rh_no(rawBox, padding, dest.raw); return dest; } /*! * @brief set up orthographic projection matrix using bounding box * with a right-hand coordinate system and a * clip-space of [-1, 1]. * * bounding box (AABB) must be in view space * * @param[in] box AABB * @param[in] padding padding for near and far * @returns result matrix */ CGLM_INLINE mat4s glms_ortho_aabb_pz_rh_no(vec3s box[2], float padding) { mat4s dest; vec3 rawBox[2]; glms_vec3_(unpack)(rawBox, box, 2); glm_ortho_aabb_pz_rh_no(rawBox, padding, dest.raw); return dest; } /*! * @brief set up unit orthographic projection matrix * with a right-hand coordinate system and a * clip-space of [-1, 1]. * * @param[in] aspect aspect ration ( width / height ) * @returns result matrix */ CGLM_INLINE mat4s glms_ortho_default_rh_no(float aspect) { mat4s dest; glm_ortho_default_rh_no(aspect, dest.raw); return dest; } /*! * @brief set up orthographic projection matrix with given CUBE size * with a right-hand coordinate system and a * clip-space of [-1, 1]. * * @param[in] aspect aspect ratio ( width / height ) * @param[in] size cube size * @returns result matrix */ CGLM_INLINE mat4s glms_ortho_default_s_rh_no(float aspect, float size) { mat4s dest; glm_ortho_default_s_rh_no(aspect, size, dest.raw); return dest; } #endif /* cglms_ortho_rh_no_h */ cglm-0.9.6/include/cglm/struct/clipspace/ortho_rh_zo.h000066400000000000000000000075351475344456400230430ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ /* Functions: CGLM_INLINE mat4s glms_ortho_rh_zo(float left, float right, float bottom, float top, float nearZ, float farZ) CGLM_INLINE mat4s glms_ortho_aabb_rh_zo(vec3s box[2]); CGLM_INLINE mat4s glms_ortho_aabb_p_rh_zo(vec3s box[2], float padding); CGLM_INLINE mat4s glms_ortho_aabb_pz_rh_zo(vec3s box[2], float padding); CGLM_INLINE mat4s glms_ortho_default_rh_zo(float aspect) CGLM_INLINE mat4s glms_ortho_default_s_rh_zo(float aspect, float size) */ #ifndef cglms_ortho_rh_zo_h #define cglms_ortho_rh_zo_h #include "../../common.h" #include "../../types-struct.h" #include "../../plane.h" #include "../../cam.h" #include "../vec3.h" #include "../../clipspace/ortho_rh_zo.h" /*! * @brief set up orthographic projection matrix * with a right-hand coordinate system and a * clip-space of [0, 1]. * * @param[in] left viewport.left * @param[in] right viewport.right * @param[in] bottom viewport.bottom * @param[in] top viewport.top * @param[in] nearZ near clipping plane * @param[in] farZ far clipping plane * @returns result matrix */ CGLM_INLINE mat4s glms_ortho_rh_zo(float left, float right, float bottom, float top, float nearZ, float farZ) { mat4s dest; glm_ortho_rh_zo(left, right, bottom, top, nearZ, farZ, dest.raw); return dest; } /*! * @brief set up orthographic projection matrix using bounding box * with a right-hand coordinate system and a * clip-space of [0, 1]. * * bounding box (AABB) must be in view space * * @param[in] box AABB * @returns result matrix */ CGLM_INLINE mat4s glms_ortho_aabb_rh_zo(vec3s box[2]) { mat4s dest; vec3 rawBox[2]; glms_vec3_(unpack)(rawBox, box, 2); glm_ortho_aabb_rh_zo(rawBox, dest.raw); return dest; } /*! * @brief set up orthographic projection matrix using bounding box * with a right-hand coordinate system and a * clip-space of [0, 1]. * * bounding box (AABB) must be in view space * * @param[in] box AABB * @param[in] padding padding * @returns result matrix */ CGLM_INLINE mat4s glms_ortho_aabb_p_rh_zo(vec3s box[2], float padding) { mat4s dest; vec3 rawBox[2]; glms_vec3_(unpack)(rawBox, box, 2); glm_ortho_aabb_p_rh_zo(rawBox, padding, dest.raw); return dest; } /*! * @brief set up orthographic projection matrix using bounding box * with a right-hand coordinate system and a * clip-space of [0, 1]. * * bounding box (AABB) must be in view space * * @param[in] box AABB * @param[in] padding padding for near and far * @returns result matrix */ CGLM_INLINE mat4s glms_ortho_aabb_pz_rh_zo(vec3s box[2], float padding) { mat4s dest; vec3 rawBox[2]; glms_vec3_(unpack)(rawBox, box, 2); glm_ortho_aabb_pz_rh_zo(rawBox, padding, dest.raw); return dest; } /*! * @brief set up unit orthographic projection matrix * with a right-hand coordinate system and a * clip-space of [0, 1]. * * @param[in] aspect aspect ration ( width / height ) * @returns result matrix */ CGLM_INLINE mat4s glms_ortho_default_rh_zo(float aspect) { mat4s dest; glm_ortho_default_rh_zo(aspect, dest.raw); return dest; } /*! * @brief set up orthographic projection matrix with given CUBE size * with a right-hand coordinate system and a * clip-space of [0, 1]. * * @param[in] aspect aspect ratio ( width / height ) * @param[in] size cube size * @returns result matrix */ CGLM_INLINE mat4s glms_ortho_default_s_rh_zo(float aspect, float size) { mat4s dest; glm_ortho_default_s_rh_zo(aspect, size, dest.raw); return dest; } #endif /* cglms_ortho_rh_zo_h */ cglm-0.9.6/include/cglm/struct/clipspace/persp_lh_no.h000066400000000000000000000230351475344456400230100ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ /* Functions: CGLM_INLINE mat4s glms_frustum_lh_no(float left, float right, float bottom, float top, float nearZ, float farZ) CGLM_INLINE mat4s glms_perspective_lh_no(float fovy, float aspect, float nearZ, float farZ) CGLM_INLINE void glms_persp_move_far_lh_no(mat4s proj, float deltaFar) CGLM_INLINE mat4s glms_perspective_default_lh_no(float aspect) CGLM_INLINE void glms_perspective_resize_lh_no(mat4s proj, float aspect) CGLM_INLINE void glms_persp_decomp_lh_no(mat4s proj, float *nearv, float *farv, float *top, float *bottom, float *left, float *right) CGLM_INLINE void glms_persp_decompv_lh_no(mat4s proj, float dest[6]) CGLM_INLINE void glms_persp_decomp_x_lh_no(mat4s proj, float *left, float *right) CGLM_INLINE void glms_persp_decomp_y_lh_no(mat4s proj, float *top, float *bottom) CGLM_INLINE void glms_persp_decomp_z_lh_no(mat4s proj, float *nearv, float *farv) CGLM_INLINE void glms_persp_decomp_far_lh_no(mat4s proj, float *farZ) CGLM_INLINE void glms_persp_decomp_near_lh_no(mat4s proj, float *nearZ) CGLM_INLINE float glms_persp_fovy_lh_no(mat4s proj) CGLM_INLINE float glms_persp_aspect_lh_no(mat4s proj) CGLM_INLINE vec4s glms_persp_sizes_lh_no(mat4s proj, float fovy) */ #ifndef cglms_persp_lh_no_h #define cglms_persp_lh_no_h #include "../../common.h" #include "../../types-struct.h" #include "../../plane.h" #include "../../cam.h" #include "../../clipspace/persp_lh_no.h" /*! * @brief set up perspective peprojection matrix * with a left-hand coordinate system and a * clip-space of [-1, 1]. * * @param[in] left viewport.left * @param[in] right viewport.right * @param[in] bottom viewport.bottom * @param[in] top viewport.top * @param[in] nearZ near clipping plane * @param[in] farZ far clipping plane * @returns result matrix */ CGLM_INLINE mat4s glms_frustum_lh_no(float left, float right, float bottom, float top, float nearZ, float farZ) { mat4s dest; glm_frustum_lh_no(left, right, bottom, top, nearZ, farZ, dest.raw); return dest; } /*! * @brief set up perspective projection matrix * with a left-hand coordinate system and a * clip-space of [-1, 1]. * * @param[in] fovy field of view angle * @param[in] aspect aspect ratio ( width / height ) * @param[in] nearZ near clipping plane * @param[in] farZ far clipping planes * @returns result matrix */ CGLM_INLINE mat4s glms_perspective_lh_no(float fovy, float aspect, float nearZ, float farZ) { mat4s dest; glm_perspective_lh_no(fovy, aspect, nearZ, farZ, dest.raw); return dest; } /*! * @brief extend perspective projection matrix's far distance * with a left-hand coordinate system and a * clip-space of [-1, 1]. * * NOTE: if you dodn't want to create new matrix then use array api on struct.raw * like glms_persp_move_far_lh_no(prooj.raw, deltaFar) to avoid create new mat4 * each time * * this function does not guarantee far >= near, be aware of that! * * @param[in, out] proj projection matrix to extend * @param[in] deltaFar distance from existing far (negative to shink) */ CGLM_INLINE mat4s glms_persp_move_far_lh_no(mat4s proj, float deltaFar) { mat4s dest; dest = proj; glm_persp_move_far_lh_no(dest.raw, deltaFar); return dest; } /*! * @brief set up perspective projection matrix with default near/far * and angle values with a left-hand coordinate system and a * clip-space of [-1, 1]. * * @param[in] aspect aspect ratio ( width / height ) * @returns result matrix */ CGLM_INLINE mat4s glms_perspective_default_lh_no(float aspect) { mat4s dest; glm_perspective_default_lh_no(aspect, dest.raw); return dest; } /*! * @brief resize perspective matrix by aspect ratio ( width / height ) * this makes very easy to resize proj matrix when window /viewport * reized with a left-hand coordinate system and a * clip-space of [-1, 1]. * * NOTE: if you dodn't want to create new matrix then use array api on struct.raw * like glm_perspective_resize_lh_no(proj.raw, aspect) to avoid create new mat4 * each time * * @param[in, out] proj perspective projection matrix * @param[in] aspect aspect ratio ( width / height ) */ CGLM_INLINE mat4s glms_perspective_resize_lh_no(mat4s proj, float aspect) { mat4s dest; dest = proj; glm_perspective_resize_lh_no(aspect, dest.raw); return dest; } /*! * @brief decomposes frustum values of perspective projection. * with a left-hand coordinate system and a * clip-space of [-1, 1]. * * @param[in] proj perspective projection matrix * @param[out] nearZ near * @param[out] farZ far * @param[out] top top * @param[out] bottom bottom * @param[out] left left * @param[out] right right */ CGLM_INLINE void glms_persp_decomp_lh_no(mat4s proj, float * __restrict nearZ, float * __restrict farZ, float * __restrict top, float * __restrict bottom, float * __restrict left, float * __restrict right) { glm_persp_decomp_lh_no(proj.raw, nearZ, farZ, top, bottom, left, right); } /*! * @brief decomposes frustum values of perspective projection. * this makes easy to get all values at once * with a left-hand coordinate system and a * clip-space of [-1, 1]. * * @param[in] proj perspective projection matrix * @param[out] dest array */ CGLM_INLINE void glms_persp_decompv_lh_no(mat4s proj, float dest[6]) { glm_persp_decompv_lh_no(proj.raw, dest); } /*! * @brief decomposes left and right values of perspective projection * with a left-hand coordinate system and a * clip-space of [-1, 1]. * x stands for x axis (left / right axis) * * @param[in] proj perspective projection matrix * @param[out] left left * @param[out] right right */ CGLM_INLINE void glms_persp_decomp_x_lh_no(mat4s proj, float * __restrict left, float * __restrict right) { glm_persp_decomp_x_lh_no(proj.raw, left, right); } /*! * @brief decomposes top and bottom values of perspective projection * with a left-hand coordinate system and a * clip-space of [-1, 1]. * y stands for y axis (top / bottom axis) * * @param[in] proj perspective projection matrix * @param[out] top top * @param[out] bottom bottom */ CGLM_INLINE void glms_persp_decomp_y_lh_no(mat4s proj, float * __restrict top, float * __restrict bottom) { glm_persp_decomp_y_lh_no(proj.raw, top, bottom); } /*! * @brief decomposes near and far values of perspective projection * with a left-hand coordinate system and a * clip-space of [-1, 1]. * z stands for z axis (near / far axis) * * @param[in] proj perspective projection matrix * @param[out] nearZ near * @param[out] farZ far */ CGLM_INLINE void glms_persp_decomp_z_lh_no(mat4s proj, float * __restrict nearZ, float * __restrict farZ) { glm_persp_decomp_z_lh_no(proj.raw, nearZ, farZ); } /*! * @brief decomposes far value of perspective projection * with a left-hand coordinate system and a * clip-space of [-1, 1]. * * @param[in] proj perspective projection matrix * @param[out] farZ far */ CGLM_INLINE void glms_persp_decomp_far_lh_no(mat4s proj, float * __restrict farZ) { glm_persp_decomp_far_lh_no(proj.raw, farZ); } /*! * @brief decomposes near value of perspective projection * with a left-hand coordinate system and a * clip-space of [-1, 1]. * * @param[in] proj perspective projection matrix * @param[out] nearZ near */ CGLM_INLINE void glms_persp_decomp_near_lh_no(mat4s proj, float * __restrict nearZ) { glm_persp_decomp_near_lh_no(proj.raw, nearZ); } /*! * @brief returns field of view angle along the Y-axis (in radians) * with a left-hand coordinate system and a * clip-space of [-1, 1]. * * if you need to degrees, use glm_deg to convert it or use this: * fovy_deg = glm_deg(glm_persp_fovy(projMatrix)) * * @param[in] proj perspective projection matrix */ CGLM_INLINE float glms_persp_fovy_lh_no(mat4s proj) { return glm_persp_fovy_lh_no(proj.raw); } /*! * @brief returns aspect ratio of perspective projection * with a left-hand coordinate system and a * clip-space of [-1, 1]. * * @param[in] proj perspective projection matrix */ CGLM_INLINE float glms_persp_aspect_lh_no(mat4s proj) { return glm_persp_aspect_lh_no(proj.raw); } /*! * @brief returns sizes of near and far planes of perspective projection * with a left-hand coordinate system and a * clip-space of [-1, 1]. * * @param[in] proj perspective projection matrix * @param[in] fovy fovy (see brief) * @returns sizes as vector, sizes order: [Wnear, Hnear, Wfar, Hfar] */ CGLM_INLINE vec4s glms_persp_sizes_lh_no(mat4s proj, float fovy) { vec4s dest; glm_persp_sizes_lh_no(proj.raw, fovy, dest.raw); return dest; } #endif /* cglms_persp_lh_no_h */ cglm-0.9.6/include/cglm/struct/clipspace/persp_lh_zo.h000066400000000000000000000230101475344456400230150ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ /* Functions: CGLM_INLINE mat4s glms_frustum_lh_zo(float left, float right, float bottom, float top, float nearZ, float farZ) CGLM_INLINE mat4s glms_perspective_lh_zo(float fovy, float aspect, float nearZ, float farZ) CGLM_INLINE void glms_persp_move_far_lh_zo(mat4s proj, float deltaFar) CGLM_INLINE mat4s glms_perspective_default_lh_zo(float aspect) CGLM_INLINE void glms_perspective_resize_lh_zo(mat4s proj, float aspect) CGLM_INLINE void glms_persp_decomp_lh_zo(mat4s proj, float *nearv, float *farv, float *top, float *bottom, float *left, float *right) CGLM_INLINE void glms_persp_decompv_lh_zo(mat4s proj, float dest[6]) CGLM_INLINE void glms_persp_decomp_x_lh_zo(mat4s proj, float *left, float *right) CGLM_INLINE void glms_persp_decomp_y_lh_zo(mat4s proj, float *top, float *bottom) CGLM_INLINE void glms_persp_decomp_z_lh_zo(mat4s proj, float *nearv, float *farv) CGLM_INLINE void glms_persp_decomp_far_lh_zo(mat4s proj, float *farZ) CGLM_INLINE void glms_persp_decomp_near_lh_zo(mat4s proj, float *nearZ) CGLM_INLINE float glms_persp_fovy_lh_zo(mat4s proj) CGLM_INLINE float glms_persp_aspect_lh_zo(mat4s proj) CGLM_INLINE vec4s glms_persp_sizes_lh_zo(mat4s proj, float fovy) */ #ifndef cglms_persp_lh_zo_h #define cglms_persp_lh_zo_h #include "../../common.h" #include "../../types-struct.h" #include "../../plane.h" #include "../../cam.h" #include "../../clipspace/persp_lh_zo.h" /*! * @brief set up perspective peprojection matrix * with a left-hand coordinate system and a * clip-space of [0, 1]. * * @param[in] left viewport.left * @param[in] right viewport.right * @param[in] bottom viewport.bottom * @param[in] top viewport.top * @param[in] nearZ near clipping plane * @param[in] farZ far clipping plane * @returns result matrix */ CGLM_INLINE mat4s glms_frustum_lh_zo(float left, float right, float bottom, float top, float nearZ, float farZ) { mat4s dest; glm_frustum_lh_zo(left, right, bottom, top, nearZ, farZ, dest.raw); return dest; } /*! * @brief set up perspective projection matrix * with a left-hand coordinate system and a * clip-space of [0, 1]. * * @param[in] fovy field of view angle * @param[in] aspect aspect ratio ( width / height ) * @param[in] nearZ near clipping plane * @param[in] farZ far clipping planes * @returns result matrix */ CGLM_INLINE mat4s glms_perspective_lh_zo(float fovy, float aspect, float nearZ, float farZ) { mat4s dest; glm_perspective_lh_zo(fovy, aspect, nearZ, farZ, dest.raw); return dest; } /*! * @brief extend perspective projection matrix's far distance * with a left-hand coordinate system and a * clip-space of [0, 1]. * * NOTE: if you dodn't want to create new matrix then use array api on struct.raw * like glms_persp_move_far_lh_zo(prooj.raw, deltaFar) to avoid create new mat4 * each time * * this function does not guarantee far >= near, be aware of that! * * @param[in, out] proj projection matrix to extend * @param[in] deltaFar distance from existing far (negative to shink) */ CGLM_INLINE mat4s glms_persp_move_far_lh_zo(mat4s proj, float deltaFar) { mat4s dest; dest = proj; glm_persp_move_far_lh_zo(dest.raw, deltaFar); return dest; } /*! * @brief set up perspective projection matrix with default near/far * and angle values with a left-hand coordinate system and a * clip-space of [0, 1]. * * @param[in] aspect aspect ratio ( width / height ) * @returns result matrix */ CGLM_INLINE mat4s glms_perspective_default_lh_zo(float aspect) { mat4s dest; glm_perspective_default_lh_zo(aspect, dest.raw); return dest; } /*! * @brief resize perspective matrix by aspect ratio ( width / height ) * this makes very easy to resize proj matrix when window /viewport * reized with a left-hand coordinate system and a * clip-space of [0, 1]. * * NOTE: if you dodn't want to create new matrix then use array api on struct.raw * like glms_perspective_resize_lh_zo(proj.raw, aspect) to avoid create new mat4 * each time * * @param[in, out] proj perspective projection matrix * @param[in] aspect aspect ratio ( width / height ) */ CGLM_INLINE mat4s glms_perspective_resize_lh_zo(mat4s proj, float aspect) { mat4s dest; dest = proj; glm_perspective_resize_lh_zo(aspect, dest.raw); return dest; } /*! * @brief decomposes frustum values of perspective projection. * with a left-hand coordinate system and a * clip-space of [0, 1]. * * @param[in] proj perspective projection matrix * @param[out] nearZ near * @param[out] farZ far * @param[out] top top * @param[out] bottom bottom * @param[out] left left * @param[out] right right */ CGLM_INLINE void glms_persp_decomp_lh_zo(mat4s proj, float * __restrict nearZ, float * __restrict farZ, float * __restrict top, float * __restrict bottom, float * __restrict left, float * __restrict right) { glm_persp_decomp_lh_zo(proj.raw, nearZ, farZ, top, bottom, left, right); } /*! * @brief decomposes frustum values of perspective projection. * this makes easy to get all values at once * with a left-hand coordinate system and a * clip-space of [0, 1]. * * @param[in] proj perspective projection matrix * @param[out] dest array */ CGLM_INLINE void glms_persp_decompv_lh_zo(mat4s proj, float dest[6]) { glm_persp_decompv_lh_zo(proj.raw, dest); } /*! * @brief decomposes left and right values of perspective projection * with a left-hand coordinate system and a * clip-space of [0, 1]. * x stands for x axis (left / right axis) * * @param[in] proj perspective projection matrix * @param[out] left left * @param[out] right right */ CGLM_INLINE void glms_persp_decomp_x_lh_zo(mat4s proj, float * __restrict left, float * __restrict right) { glm_persp_decomp_x_lh_zo(proj.raw, left, right); } /*! * @brief decomposes top and bottom values of perspective projection * with a left-hand coordinate system and a * clip-space of [0, 1]. * y stands for y axis (top / bottom axis) * * @param[in] proj perspective projection matrix * @param[out] top top * @param[out] bottom bottom */ CGLM_INLINE void glms_persp_decomp_y_lh_zo(mat4s proj, float * __restrict top, float * __restrict bottom) { glm_persp_decomp_y_lh_zo(proj.raw, top, bottom); } /*! * @brief decomposes near and far values of perspective projection * with a left-hand coordinate system and a * clip-space of [0, 1]. * z stands for z axis (near / far axis) * * @param[in] proj perspective projection matrix * @param[out] nearZ near * @param[out] farZ far */ CGLM_INLINE void glms_persp_decomp_z_lh_zo(mat4s proj, float * __restrict nearZ, float * __restrict farZ) { glm_persp_decomp_z_lh_zo(proj.raw, nearZ, farZ); } /*! * @brief decomposes far value of perspective projection * with a left-hand coordinate system and a * clip-space of [0, 1]. * * @param[in] proj perspective projection matrix * @param[out] farZ far */ CGLM_INLINE void glms_persp_decomp_far_lh_zo(mat4s proj, float * __restrict farZ) { glm_persp_decomp_far_lh_zo(proj.raw, farZ); } /*! * @brief decomposes near value of perspective projection * with a left-hand coordinate system and a * clip-space of [0, 1]. * * @param[in] proj perspective projection matrix * @param[out] nearZ near */ CGLM_INLINE void glms_persp_decomp_near_lh_zo(mat4s proj, float * __restrict nearZ) { glm_persp_decomp_near_lh_zo(proj.raw, nearZ); } /*! * @brief returns field of view angle along the Y-axis (in radians) * with a left-hand coordinate system and a * clip-space of [0, 1]. * * if you need to degrees, use glm_deg to convert it or use this: * fovy_deg = glm_deg(glm_persp_fovy(projMatrix)) * * @param[in] proj perspective projection matrix */ CGLM_INLINE float glms_persp_fovy_lh_zo(mat4s proj) { return glm_persp_fovy_lh_zo(proj.raw); } /*! * @brief returns aspect ratio of perspective projection * with a left-hand coordinate system and a * clip-space of [0, 1]. * * @param[in] proj perspective projection matrix */ CGLM_INLINE float glms_persp_aspect_lh_zo(mat4s proj) { return glm_persp_aspect_lh_zo(proj.raw); } /*! * @brief returns sizes of near and far planes of perspective projection * with a left-hand coordinate system and a * clip-space of [0, 1]. * * @param[in] proj perspective projection matrix * @param[in] fovy fovy (see brief) * @returns sizes as vector, sizes order: [Wnear, Hnear, Wfar, Hfar] */ CGLM_INLINE vec4s glms_persp_sizes_lh_zo(mat4s proj, float fovy) { vec4s dest; glm_persp_sizes_lh_zo(proj.raw, fovy, dest.raw); return dest; } #endif /* cglms_persp_lh_zo_h */ cglm-0.9.6/include/cglm/struct/clipspace/persp_rh_no.h000066400000000000000000000230551475344456400230200ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ /* Functions: CGLM_INLINE mat4s glms_frustum_rh_no(float left, float right, float bottom, float top, float nearZ, float farZ) CGLM_INLINE mat4s glms_perspective_rh_no(float fovy, float aspect, float nearZ, float farZ) CGLM_INLINE void glms_persp_move_far_rh_no(mat4s proj, float deltaFar) CGLM_INLINE mat4s glms_perspective_default_rh_no(float aspect) CGLM_INLINE void glms_perspective_resize_rh_no(mat4s proj, float aspect) CGLM_INLINE void glms_persp_decomp_rh_no(mat4s proj, float *nearv, float *farv, float *top, float *bottom, float *left, float *right) CGLM_INLINE void glms_persp_decompv_rh_no(mat4s proj, float dest[6]) CGLM_INLINE void glms_persp_decomp_x_rh_no(mat4s proj, float *left, float *right) CGLM_INLINE void glms_persp_decomp_y_rh_no(mat4s proj, float *top, float *bottom) CGLM_INLINE void glms_persp_decomp_z_rh_no(mat4s proj, float *nearv, float *farv) CGLM_INLINE void glms_persp_decomp_far_rh_no(mat4s proj, float *farZ) CGLM_INLINE void glms_persp_decomp_near_rh_no(mat4s proj, float *nearZ) CGLM_INLINE float glms_persp_fovy_rh_no(mat4s proj) CGLM_INLINE float glms_persp_aspect_rh_no(mat4s proj) CGLM_INLINE vec4s glms_persp_sizes_rh_no(mat4s proj, float fovy) */ #ifndef cglms_persp_rh_no_h #define cglms_persp_rh_no_h #include "../../common.h" #include "../../types-struct.h" #include "../../plane.h" #include "../../cam.h" #include "../../clipspace/persp_rh_no.h" /*! * @brief set up perspective peprojection matrix * with a right-hand coordinate system and a * clip-space of [-1, 1]. * * @param[in] left viewport.left * @param[in] right viewport.right * @param[in] bottom viewport.bottom * @param[in] top viewport.top * @param[in] nearZ near clipping plane * @param[in] farZ far clipping plane * @returns result matrix */ CGLM_INLINE mat4s glms_frustum_rh_no(float left, float right, float bottom, float top, float nearZ, float farZ) { mat4s dest; glm_frustum_rh_no(left, right, bottom, top, nearZ, farZ, dest.raw); return dest; } /*! * @brief set up perspective projection matrix * with a right-hand coordinate system and a * clip-space of [-1, 1]. * * @param[in] fovy field of view angle * @param[in] aspect aspect ratio ( width / height ) * @param[in] nearZ near clipping plane * @param[in] farZ far clipping planes * @returns result matrix */ CGLM_INLINE mat4s glms_perspective_rh_no(float fovy, float aspect, float nearZ, float farZ) { mat4s dest; glm_perspective_rh_no(fovy, aspect, nearZ, farZ, dest.raw); return dest; } /*! * @brief extend perspective projection matrix's far distance * with a right-hand coordinate system and a * clip-space of [-1, 1]. * * NOTE: if you dodn't want to create new matrix then use array api on struct.raw * like glms_persp_move_far_rh_no(prooj.raw, deltaFar) to avoid create new mat4 * each time * s * this function does not guarantee far >= near, be aware of that! * * @param[in, out] proj projection matrix to extend * @param[in] deltaFar distance from existing far (negative to shink) */ CGLM_INLINE mat4s glms_persp_move_far_rh_no(mat4s proj, float deltaFar) { mat4s dest; dest = proj; glm_persp_move_far_rh_no(dest.raw, deltaFar); return dest; } /*! * @brief set up perspective projection matrix with default near/far * and angle values with a right-hand coordinate system and a * clip-space of [-1, 1]. * * @param[in] aspect aspect ratio ( width / height ) * @returns result matrix */ CGLM_INLINE mat4s glms_perspective_default_rh_no(float aspect) { mat4s dest; glm_perspective_default_rh_no(aspect, dest.raw); return dest; } /*! * @brief resize perspective matrix by aspect ratio ( width / height ) * this makes very easy to resize proj matrix when window /viewport * reized with a right-hand coordinate system and a * clip-space of [-1, 1]. * * NOTE: if you dodn't want to create new matrix then use array api on struct.raw * like glm_perspective_resize_rh_no(proj.raw, aspect) to avoid create new mat4 * each time * * @param[in, out] proj perspective projection matrix * @param[in] aspect aspect ratio ( width / height ) */ CGLM_INLINE mat4s glms_perspective_resize_rh_no(mat4s proj, float aspect) { mat4s dest; dest = proj; glm_perspective_resize_rh_no(aspect, dest.raw); return dest; } /*! * @brief decomposes frustum values of perspective projection. * with a right-hand coordinate system and a * clip-space of [-1, 1]. * * @param[in] proj perspective projection matrix * @param[out] nearZ near * @param[out] farZ far * @param[out] top top * @param[out] bottom bottom * @param[out] left left * @param[out] right right */ CGLM_INLINE void glms_persp_decomp_rh_no(mat4s proj, float * __restrict nearZ, float * __restrict farZ, float * __restrict top, float * __restrict bottom, float * __restrict left, float * __restrict right) { glm_persp_decomp_rh_no(proj.raw, nearZ, farZ, top, bottom, left, right); } /*! * @brief decomposes frustum values of perspective projection. * this makes easy to get all values at once * with a right-hand coordinate system and a * clip-space of [-1, 1]. * * @param[in] proj perspective projection matrix * @param[out] dest array */ CGLM_INLINE void glms_persp_decompv_rh_no(mat4s proj, float dest[6]) { glm_persp_decompv_rh_no(proj.raw, dest); } /*! * @brief decomposes left and right values of perspective projection * with a right-hand coordinate system and a * clip-space of [-1, 1]. * x stands for x axis (left / right axis) * * @param[in] proj perspective projection matrix * @param[out] left left * @param[out] right right */ CGLM_INLINE void glms_persp_decomp_x_rh_no(mat4s proj, float * __restrict left, float * __restrict right) { glm_persp_decomp_x_rh_no(proj.raw, left, right); } /*! * @brief decomposes top and bottom values of perspective projection * with a right-hand coordinate system and a * clip-space of [-1, 1]. * y stands for y axis (top / bottom axis) * * @param[in] proj perspective projection matrix * @param[out] top top * @param[out] bottom bottom */ CGLM_INLINE void glms_persp_decomp_y_rh_no(mat4s proj, float * __restrict top, float * __restrict bottom) { glm_persp_decomp_y_rh_no(proj.raw, top, bottom); } /*! * @brief decomposes near and far values of perspective projection * with a right-hand coordinate system and a * clip-space of [-1, 1]. * z stands for z axis (near / far axis) * * @param[in] proj perspective projection matrix * @param[out] nearZ near * @param[out] farZ far */ CGLM_INLINE void glms_persp_decomp_z_rh_no(mat4s proj, float * __restrict nearZ, float * __restrict farZ) { glm_persp_decomp_z_rh_no(proj.raw, nearZ, farZ); } /*! * @brief decomposes far value of perspective projection * with a right-hand coordinate system and a * clip-space of [-1, 1]. * * @param[in] proj perspective projection matrix * @param[out] farZ far */ CGLM_INLINE void glms_persp_decomp_far_rh_no(mat4s proj, float * __restrict farZ) { glm_persp_decomp_far_rh_no(proj.raw, farZ); } /*! * @brief decomposes near value of perspective projection * with a right-hand coordinate system and a * clip-space of [-1, 1]. * * @param[in] proj perspective projection matrix * @param[out] nearZ near */ CGLM_INLINE void glms_persp_decomp_near_rh_no(mat4s proj, float * __restrict nearZ) { glm_persp_decomp_near_rh_no(proj.raw, nearZ); } /*! * @brief returns field of view angle along the Y-axis (in radians) * with a right-hand coordinate system and a * clip-space of [-1, 1]. * * if you need to degrees, use glm_deg to convert it or use this: * fovy_deg = glm_deg(glm_persp_fovy(projMatrix)) * * @param[in] proj perspective projection matrix */ CGLM_INLINE float glms_persp_fovy_rh_no(mat4s proj) { return glm_persp_fovy_rh_no(proj.raw); } /*! * @brief returns aspect ratio of perspective projection * with a right-hand coordinate system and a * clip-space of [-1, 1]. * * @param[in] proj perspective projection matrix */ CGLM_INLINE float glms_persp_aspect_rh_no(mat4s proj) { return glm_persp_aspect_rh_no(proj.raw); } /*! * @brief returns sizes of near and far planes of perspective projection * with a right-hand coordinate system and a * clip-space of [-1, 1]. * * @param[in] proj perspective projection matrix * @param[in] fovy fovy (see brief) * @returns sizes as vector, sizes order: [Wnear, Hnear, Wfar, Hfar] */ CGLM_INLINE vec4s glms_persp_sizes_rh_no(mat4s proj, float fovy) { vec4s dest; glm_persp_sizes_rh_no(proj.raw, fovy, dest.raw); return dest; } #endif /* cglms_persp_rh_no_h */ cglm-0.9.6/include/cglm/struct/clipspace/persp_rh_zo.h000066400000000000000000000230351475344456400230320ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ /* Functions: CGLM_INLINE mat4s glms_frustum_rh_zo(float left, float right, float bottom, float top, float nearZ, float farZ) CGLM_INLINE mat4s glms_perspective_rh_zo(float fovy, float aspect, float nearZ, float farZ) CGLM_INLINE void glms_persp_move_far_rh_zo(mat4s proj, float deltaFar) CGLM_INLINE mat4s glms_perspective_default_rh_zo(float aspect) CGLM_INLINE void glms_perspective_resize_rh_zo(mat4s proj, float aspect) CGLM_INLINE void glms_persp_decomp_rh_zo(mat4s proj, float *nearv, float *farv, float *top, float *bottom, float *left, float *right) CGLM_INLINE void glms_persp_decompv_rh_zo(mat4s proj, float dest[6]) CGLM_INLINE void glms_persp_decomp_x_rh_zo(mat4s proj, float *left, float *right) CGLM_INLINE void glms_persp_decomp_y_rh_zo(mat4s proj, float *top, float *bottom) CGLM_INLINE void glms_persp_decomp_z_rh_zo(mat4s proj, float *nearv, float *farv) CGLM_INLINE void glms_persp_decomp_far_rh_zo(mat4s proj, float *farZ) CGLM_INLINE void glms_persp_decomp_near_rh_zo(mat4s proj, float *nearZ) CGLM_INLINE float glms_persp_fovy_rh_zo(mat4s proj) CGLM_INLINE float glms_persp_aspect_rh_zo(mat4s proj) CGLM_INLINE vec4s glms_persp_sizes_rh_zo(mat4s proj, float fovy) */ #ifndef cglms_persp_rh_zo_h #define cglms_persp_rh_zo_h #include "../../common.h" #include "../../types-struct.h" #include "../../plane.h" #include "../../cam.h" #include "../../clipspace/persp_rh_zo.h" /*! * @brief set up perspective peprojection matrix * with a right-hand coordinate system and a * clip-space of [0, 1]. * * @param[in] left viewport.left * @param[in] right viewport.right * @param[in] bottom viewport.bottom * @param[in] top viewport.top * @param[in] nearZ near clipping plane * @param[in] farZ far clipping plane * @returns result matrix */ CGLM_INLINE mat4s glms_frustum_rh_zo(float left, float right, float bottom, float top, float nearZ, float farZ) { mat4s dest; glm_frustum_rh_zo(left, right, bottom, top, nearZ, farZ, dest.raw); return dest; } /*! * @brief set up perspective projection matrix * with a right-hand coordinate system and a * clip-space of [0, 1]. * * @param[in] fovy field of view angle * @param[in] aspect aspect ratio ( width / height ) * @param[in] nearZ near clipping plane * @param[in] farZ far clipping planes * @returns result matrix */ CGLM_INLINE mat4s glms_perspective_rh_zo(float fovy, float aspect, float nearZ, float farZ) { mat4s dest; glm_perspective_rh_zo(fovy, aspect, nearZ, farZ, dest.raw); return dest; } /*! * @brief extend perspective projection matrix's far distance * with a right-hand coordinate system and a * clip-space of [0, 1]. * * NOTE: if you dodn't want to create new matrix then use array api on struct.raw * like glms_persp_move_far_rh_zo(prooj.raw, deltaFar) to avoid create new mat4 * each time * * this function does not guarantee far >= near, be aware of that! * * @param[in, out] proj projection matrix to extend * @param[in] deltaFar distance from existing far (negative to shink) */ CGLM_INLINE mat4s glms_persp_move_far_rh_zo(mat4s proj, float deltaFar) { mat4s dest; dest = proj; glm_persp_move_far_rh_zo(dest.raw, deltaFar); return dest; } /*! * @brief set up perspective projection matrix with default near/far * and angle values with a right-hand coordinate system and a * clip-space of [0, 1]. * * @param[in] aspect aspect ratio ( width / height ) * @returns result matrix */ CGLM_INLINE mat4s glms_perspective_default_rh_zo(float aspect) { mat4s dest; glm_perspective_default_rh_zo(aspect, dest.raw); return dest; } /*! * @brief resize perspective matrix by aspect ratio ( width / height ) * this makes very easy to resize proj matrix when window /viewport * reized with a right-hand coordinate system and a * clip-space of [0, 1]. * * NOTE: if you dodn't want to create new matrix then use array api on struct.raw * like glm_perspective_resize_rh_zo(proj.raw, aspect) to avoid create new mat4 * each time * * @param[in, out] proj perspective projection matrix * @param[in] aspect aspect ratio ( width / height ) */ CGLM_INLINE mat4s glms_perspective_resize_rh_zo(mat4s proj, float aspect) { mat4s dest; dest = proj; glm_perspective_resize_rh_zo(aspect, dest.raw); return dest; } /*! * @brief decomposes frustum values of perspective projection. * with a right-hand coordinate system and a * clip-space of [0, 1]. * * @param[in] proj perspective projection matrix * @param[out] nearZ near * @param[out] farZ far * @param[out] top top * @param[out] bottom bottom * @param[out] left left * @param[out] right right */ CGLM_INLINE void glms_persp_decomp_rh_zo(mat4s proj, float * __restrict nearZ, float * __restrict farZ, float * __restrict top, float * __restrict bottom, float * __restrict left, float * __restrict right) { glm_persp_decomp_rh_zo(proj.raw, nearZ, farZ, top, bottom, left, right); } /*! * @brief decomposes frustum values of perspective projection. * this makes easy to get all values at once * with a right-hand coordinate system and a * clip-space of [0, 1]. * * @param[in] proj perspective projection matrix * @param[out] dest array */ CGLM_INLINE void glms_persp_decompv_rh_zo(mat4s proj, float dest[6]) { glm_persp_decompv_rh_zo(proj.raw, dest); } /*! * @brief decomposes left and right values of perspective projection * with a right-hand coordinate system and a * clip-space of [0, 1]. * x stands for x axis (left / right axis) * * @param[in] proj perspective projection matrix * @param[out] left left * @param[out] right right */ CGLM_INLINE void glms_persp_decomp_x_rh_zo(mat4s proj, float * __restrict left, float * __restrict right) { glm_persp_decomp_x_rh_zo(proj.raw, left, right); } /*! * @brief decomposes top and bottom values of perspective projection * with a right-hand coordinate system and a * clip-space of [0, 1]. * y stands for y axis (top / bottom axis) * * @param[in] proj perspective projection matrix * @param[out] top top * @param[out] bottom bottom */ CGLM_INLINE void glms_persp_decomp_y_rh_zo(mat4s proj, float * __restrict top, float * __restrict bottom) { glm_persp_decomp_y_rh_zo(proj.raw, top, bottom); } /*! * @brief decomposes near and far values of perspective projection * with a right-hand coordinate system and a * clip-space of [0, 1]. * z stands for z axis (near / far axis) * * @param[in] proj perspective projection matrix * @param[out] nearZ near * @param[out] farZ far */ CGLM_INLINE void glms_persp_decomp_z_rh_zo(mat4s proj, float * __restrict nearZ, float * __restrict farZ) { glm_persp_decomp_z_rh_zo(proj.raw, nearZ, farZ); } /*! * @brief decomposes far value of perspective projection * with a right-hand coordinate system and a * clip-space of [0, 1]. * * @param[in] proj perspective projection matrix * @param[out] farZ far */ CGLM_INLINE void glms_persp_decomp_far_rh_zo(mat4s proj, float * __restrict farZ) { glm_persp_decomp_far_rh_zo(proj.raw, farZ); } /*! * @brief decomposes near value of perspective projection * with a right-hand coordinate system and a * clip-space of [0, 1]. * * @param[in] proj perspective projection matrix * @param[out] nearZ near */ CGLM_INLINE void glms_persp_decomp_near_rh_zo(mat4s proj, float * __restrict nearZ) { glm_persp_decomp_near_rh_zo(proj.raw, nearZ); } /*! * @brief returns field of view angle along the Y-axis (in radians) * with a right-hand coordinate system and a * clip-space of [0, 1]. * * if you need to degrees, use glm_deg to convert it or use this: * fovy_deg = glm_deg(glm_persp_fovy(projMatrix)) * * @param[in] proj perspective projection matrix */ CGLM_INLINE float glms_persp_fovy_rh_zo(mat4s proj) { return glm_persp_fovy_rh_zo(proj.raw); } /*! * @brief returns aspect ratio of perspective projection * with a right-hand coordinate system and a * clip-space of [0, 1]. * * @param[in] proj perspective projection matrix */ CGLM_INLINE float glms_persp_aspect_rh_zo(mat4s proj) { return glm_persp_aspect_rh_zo(proj.raw); } /*! * @brief returns sizes of near and far planes of perspective projection * with a right-hand coordinate system and a * clip-space of [0, 1]. * * @param[in] proj perspective projection matrix * @param[in] fovy fovy (see brief) * @returns sizes as vector, sizes order: [Wnear, Hnear, Wfar, Hfar] */ CGLM_INLINE vec4s glms_persp_sizes_rh_zo(mat4s proj, float fovy) { vec4s dest; glm_persp_sizes_rh_zo(proj.raw, fovy, dest.raw); return dest; } #endif /* cglms_persp_rh_zo_h */ cglm-0.9.6/include/cglm/struct/clipspace/project_no.h000066400000000000000000000050341475344456400226410ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ /* Functions: CGLM_INLINE vec3s glms_unprojecti_no(vec3s pos, mat4s invMat, vec4s vp) 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 #define cglms_project_no_h #include "../../common.h" #include "../../types-struct.h" #include "../../plane.h" #include "../../cam.h" #include "../../clipspace/project_no.h" /*! * @brief maps the specified viewport coordinates into specified space [1] * the matrix should contain projection matrix. * * if you don't have ( and don't want to have ) an inverse matrix then use * glm_unproject version. You may use existing inverse of matrix in somewhere * else, this is why glm_unprojecti exists to save save inversion cost * * [1] space: * 1- if m = invProj: View Space * 2- if m = invViewProj: World Space * 3- if m = invMVP: Object Space * * You probably want to map the coordinates into object space * so use invMVP as m * * Computing viewProj: * glm_mat4_mul(proj, view, viewProj); * glm_mat4_mul(viewProj, model, MVP); * glm_mat4_inv(viewProj, invMVP); * * @param[in] pos point/position in viewport coordinates * @param[in] invMat matrix (see brief) * @param[in] vp viewport as [x, y, width, height] * * @returns unprojected coordinates */ CGLM_INLINE vec3s glms_unprojecti_no(vec3s pos, mat4s invMat, vec4s vp) { vec3s dest; glm_unprojecti_no(pos.raw, invMat.raw, vp.raw, dest.raw); return dest; } /*! * @brief map object coordinates to window coordinates * * Computing MVP: * glm_mat4_mul(proj, view, viewProj); * glm_mat4_mul(viewProj, model, MVP); * * @param[in] pos object coordinates * @param[in] m MVP matrix * @param[in] vp viewport as [x, y, width, height] * * @returns projected coordinates */ CGLM_INLINE vec3s glms_project_no(vec3s pos, mat4s m, vec4s vp) { vec3s dest; glm_project_no(pos.raw, m.raw, vp.raw, dest.raw); return dest; } /*! * @brief map object's z coordinate to window coordinates * * Computing MVP: * glm_mat4_mul(proj, view, viewProj); * glm_mat4_mul(viewProj, model, MVP); * * @param[in] v object coordinates * @param[in] m MVP matrix * * @returns projected z coordinate */ CGLM_INLINE float glms_project_z_no(vec3s v, mat4s m) { return glm_project_z_no(v.raw, m.raw); } #endif /* cglms_project_rh_no_h */ cglm-0.9.6/include/cglm/struct/clipspace/project_zo.h000066400000000000000000000050301475344456400226510ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ /* Functions: CGLM_INLINE vec3s glms_unprojecti_no(vec3s pos, mat4s invMat, vec4s vp) 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 #define cglms_project_zo_h #include "../../common.h" #include "../../types-struct.h" #include "../../plane.h" #include "../../cam.h" #include "../../clipspace/project_zo.h" /*! * @brief maps the specified viewport coordinates into specified space [1] * the matrix should contain projection matrix. * * if you don't have ( and don't want to have ) an inverse matrix then use * glm_unproject version. You may use existing inverse of matrix in somewhere * else, this is why glm_unprojecti exists to save save inversion cost * * [1] space: * 1- if m = invProj: View Space * 2- if m = invViewProj: World Space * 3- if m = invMVP: Object Space * * You probably want to map the coordinates into object space * so use invMVP as m * * Computing viewProj: * glm_mat4_mul(proj, view, viewProj); * glm_mat4_mul(viewProj, model, MVP); * glm_mat4_inv(viewProj, invMVP); * * @param[in] pos point/position in viewport coordinates * @param[in] invMat matrix (see brief) * @param[in] vp viewport as [x, y, width, height] * * @returns unprojected coordinates */ CGLM_INLINE vec3s glms_unprojecti_zo(vec3s pos, mat4s invMat, vec4s vp) { vec3s dest; glm_unprojecti_zo(pos.raw, invMat.raw, vp.raw, dest.raw); return dest; } /*! * @brief map object coordinates to window coordinates * * Computing MVP: * glm_mat4_mul(proj, view, viewProj); * glm_mat4_mul(viewProj, model, MVP); * * @param[in] pos object coordinates * @param[in] m MVP matrix * @param[in] vp viewport as [x, y, width, height] * * @returns projected coordinates */ CGLM_INLINE vec3s glms_project_zo(vec3s pos, mat4s m, vec4s vp) { vec3s dest; glm_project_zo(pos.raw, m.raw, vp.raw, dest.raw); return dest; } /*! * @brief map object's z coordinate to window coordinates * * Computing MVP: * glm_mat4_mul(proj, view, viewProj); * glm_mat4_mul(viewProj, model, MVP); * * @param[in] v object coordinates * @param[in] m MVP matrix * * @returns projected z coordinate */ CGLM_INLINE float glms_project_z_zo(vec3s v, mat4s m) { return glm_project_z_zo(v.raw, m.raw); } #endif /* cglm_project_zo_h */ cglm-0.9.6/include/cglm/struct/clipspace/view_lh_no.h000066400000000000000000000044731475344456400226360ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ /* Functions: CGLM_INLINE mat4s glms_lookat_lh_no(vec3s eye, vec3s center, vec3s up) CGLM_INLINE mat4s glms_look_lh_no(vec3s eye, vec3s dir, vec3s up) CGLM_INLINE mat4s glms_look_anyup_lh_no(vec3s eye, vec3s dir) */ #ifndef cglms_view_lh_no_h #define cglms_view_lh_no_h #include "../../common.h" #include "../../types-struct.h" #include "../../plane.h" #include "../../cam.h" #include "../../clipspace/view_lh_no.h" /*! * @brief set up view matrix * with a left-hand coordinate system and a * clip-space of [-1, 1]. * * NOTE: The UP vector must not be parallel to the line of sight from * the eye point to the reference point * * @param[in] eye eye vector * @param[in] center center vector * @param[in] up up vector * @returns result matrix */ CGLM_INLINE mat4s glms_lookat_lh_no(vec3s eye, vec3s center, vec3s up) { mat4s dest; glm_lookat_lh_no(eye.raw, center.raw, up.raw, dest.raw); return dest; } /*! * @brief set up view matrix * with a left-hand coordinate system and a * clip-space of [-1, 1]. * * convenient wrapper for lookat: if you only have direction not target self * then this might be useful. Because you need to get target from direction. * * NOTE: The UP vector must not be parallel to the line of sight from * the eye point to the reference point * * @param[in] eye eye vector * @param[in] dir direction vector * @param[in] up up vector * @returns result matrix */ CGLM_INLINE mat4s glms_look_lh_no(vec3s eye, vec3s dir, vec3s up) { mat4s dest; glm_look_lh_no(eye.raw, dir.raw, up.raw, dest.raw); return dest; } /*! * @brief set up view matrix * with a left-hand coordinate system and a * clip-space of [-1, 1]. * * convenient wrapper for look: if you only have direction and if you don't * care what UP vector is then this might be useful to create view matrix * * @param[in] eye eye vector * @param[in] dir direction vector * @returns result matrix */ CGLM_INLINE mat4s glms_look_anyup_lh_no(vec3s eye, vec3s dir) { mat4s dest; glm_look_anyup_lh_no(eye.raw, dir.raw, dest.raw); return dest; } #endif /* cglms_view_lh_no_h */ cglm-0.9.6/include/cglm/struct/clipspace/view_lh_zo.h000066400000000000000000000044701475344456400226470ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ /* Functions: CGLM_INLINE mat4s glms_lookat_lh_zo(vec3s eye, vec3s center, vec3s up) CGLM_INLINE mat4s glms_look_lh_zo(vec3s eye, vec3s dir, vec3s up) CGLM_INLINE mat4s glms_look_anyup_lh_zo(vec3s eye, vec3s dir) */ #ifndef cglms_view_lh_zo_h #define cglms_view_lh_zo_h #include "../../common.h" #include "../../types-struct.h" #include "../../plane.h" #include "../../cam.h" #include "../../clipspace/view_lh_zo.h" /*! * @brief set up view matrix * with a left-hand coordinate system and a * clip-space of [0, 1]. * * NOTE: The UP vector must not be parallel to the line of sight from * the eye point to the reference point * * @param[in] eye eye vector * @param[in] center center vector * @param[in] up up vector * @returns result matrix */ CGLM_INLINE mat4s glms_lookat_lh_zo(vec3s eye, vec3s center, vec3s up) { mat4s dest; glm_lookat_lh_zo(eye.raw, center.raw, up.raw, dest.raw); return dest; } /*! * @brief set up view matrix * with a left-hand coordinate system and a * clip-space of [0, 1]. * * convenient wrapper for lookat: if you only have direction not target self * then this might be useful. Because you need to get target from direction. * * NOTE: The UP vector must not be parallel to the line of sight from * the eye point to the reference point * * @param[in] eye eye vector * @param[in] dir direction vector * @param[in] up up vector * @returns result matrix */ CGLM_INLINE mat4s glms_look_lh_zo(vec3s eye, vec3s dir, vec3s up) { mat4s dest; glm_look_lh_zo(eye.raw, dir.raw, up.raw, dest.raw); return dest; } /*! * @brief set up view matrix * with a left-hand coordinate system and a * clip-space of [0, 1]. * * convenient wrapper for look: if you only have direction and if you don't * care what UP vector is then this might be useful to create view matrix * * @param[in] eye eye vector * @param[in] dir direction vector * @returns result matrix */ CGLM_INLINE mat4s glms_look_anyup_lh_zo(vec3s eye, vec3s dir) { mat4s dest; glm_look_anyup_lh_zo(eye.raw, dir.raw, dest.raw); return dest; } #endif /* cglms_view_lh_zo_h */ cglm-0.9.6/include/cglm/struct/clipspace/view_rh_no.h000066400000000000000000000044761475344456400226470ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ /* Functions: CGLM_INLINE mat4s glms_lookat_rh_no(vec3s eye, vec3s center, vec3s up) CGLM_INLINE mat4s glms_look_rh_no(vec3s eye, vec3s dir, vec3s up) CGLM_INLINE mat4s glms_look_anyup_rh_no(vec3s eye, vec3s dir) */ #ifndef cglms_view_rh_no_h #define cglms_view_rh_no_h #include "../../common.h" #include "../../types-struct.h" #include "../../plane.h" #include "../../cam.h" #include "../../clipspace/view_rh_no.h" /*! * @brief set up view matrix * with a right-hand coordinate system and a * clip-space of [-1, 1]. * * NOTE: The UP vector must not be parallel to the line of sight from * the eye point to the reference point * * @param[in] eye eye vector * @param[in] center center vector * @param[in] up up vector * @returns result matrix */ CGLM_INLINE mat4s glms_lookat_rh_no(vec3s eye, vec3s center, vec3s up) { mat4s dest; glm_lookat_rh_no(eye.raw, center.raw, up.raw, dest.raw); return dest; } /*! * @brief set up view matrix * with a right-hand coordinate system and a * clip-space of [-1, 1]. * * convenient wrapper for lookat: if you only have direction not target self * then this might be useful. Because you need to get target from direction. * * NOTE: The UP vector must not be parallel to the line of sight from * the eye point to the reference point * * @param[in] eye eye vector * @param[in] dir direction vector * @param[in] up up vector * @returns result matrix */ CGLM_INLINE mat4s glms_look_rh_no(vec3s eye, vec3s dir, vec3s up) { mat4s dest; glm_look_rh_no(eye.raw, dir.raw, up.raw, dest.raw); return dest; } /*! * @brief set up view matrix * with a right-hand coordinate system and a * clip-space of [-1, 1]. * * convenient wrapper for look: if you only have direction and if you don't * care what UP vector is then this might be useful to create view matrix * * @param[in] eye eye vector * @param[in] dir direction vector * @returns result matrix */ CGLM_INLINE mat4s glms_look_anyup_rh_no(vec3s eye, vec3s dir) { mat4s dest; glm_look_anyup_rh_no(eye.raw, dir.raw, dest.raw); return dest; } #endif /* cglms_view_rh_no_h */ cglm-0.9.6/include/cglm/struct/clipspace/view_rh_zo.h000066400000000000000000000044731475344456400226600ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ /* Functions: CGLM_INLINE mat4s glms_lookat_rh_zo(vec3s eye, vec3s center, vec3s up) CGLM_INLINE mat4s glms_look_rh_zo(vec3s eye, vec3s dir, vec3s up) CGLM_INLINE mat4s glms_look_anyup_rh_zo(vec3s eye, vec3s dir) */ #ifndef cglms_view_rh_zo_h #define cglms_view_rh_zo_h #include "../../common.h" #include "../../types-struct.h" #include "../../plane.h" #include "../../cam.h" #include "../../clipspace/view_rh_zo.h" /*! * @brief set up view matrix * with a right-hand coordinate system and a * clip-space of [0, 1]. * * NOTE: The UP vector must not be parallel to the line of sight from * the eye point to the reference point * * @param[in] eye eye vector * @param[in] center center vector * @param[in] up up vector * @returns result matrix */ CGLM_INLINE mat4s glms_lookat_rh_zo(vec3s eye, vec3s center, vec3s up) { mat4s dest; glm_lookat_rh_zo(eye.raw, center.raw, up.raw, dest.raw); return dest; } /*! * @brief set up view matrix * with a right-hand coordinate system and a * clip-space of [0, 1]. * * convenient wrapper for lookat: if you only have direction not target self * then this might be useful. Because you need to get target from direction. * * NOTE: The UP vector must not be parallel to the line of sight from * the eye point to the reference point * * @param[in] eye eye vector * @param[in] dir direction vector * @param[in] up up vector * @returns result matrix */ CGLM_INLINE mat4s glms_look_rh_zo(vec3s eye, vec3s dir, vec3s up) { mat4s dest; glm_look_rh_zo(eye.raw, dir.raw, up.raw, dest.raw); return dest; } /*! * @brief set up view matrix * with a right-hand coordinate system and a * clip-space of [0, 1]. * * convenient wrapper for look: if you only have direction and if you don't * care what UP vector is then this might be useful to create view matrix * * @param[in] eye eye vector * @param[in] dir direction vector * @returns result matrix */ CGLM_INLINE mat4s glms_look_anyup_rh_zo(vec3s eye, vec3s dir) { mat4s dest; glm_look_anyup_rh_zo(eye.raw, dir.raw, dest.raw); return dest; } #endif /* cglms_view_rh_zo_h */ cglm-0.9.6/include/cglm/struct/color.h000066400000000000000000000007561475344456400176600ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ #ifndef cglms_colors_h #define cglms_colors_h #include "../common.h" #include "../types-struct.h" #include "../color.h" #include "vec3.h" /*! * @brief averages the color channels into one value * * @param[in] rgb RGB color */ CGLM_INLINE float glms_luminance(vec3s rgb) { return glm_luminance(rgb.raw); } #endif /* cglms_colors_h */ cglm-0.9.6/include/cglm/struct/curve.h000066400000000000000000000016571475344456400176670ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ #ifndef cglms_curves_h #define cglms_curves_h #include "../common.h" #include "../types-struct.h" #include "../curve.h" #include "vec4.h" #include "mat4.h" /*! * @brief helper function to calculate S*M*C multiplication for curves * * This function does not encourage you to use SMC, * instead it is a helper if you use SMC. * * if you want to specify S as vector then use more generic glm_mat4_rmc() func. * * Example usage: * B(s) = glm_smc(s, GLM_BEZIER_MAT, (vec4){p0, c0, c1, p1}) * * @param[in] s parameter between 0 and 1 (this will be [s3, s2, s, 1]) * @param[in] m basis matrix * @param[in] c position/control vector * * @return B(s) */ CGLM_INLINE float glms_smc(float s, mat4s m, vec4s c) { return glm_smc(s, m.raw, c.raw); } #endif /* cglms_curves_h */ cglm-0.9.6/include/cglm/struct/euler.h000066400000000000000000000127161475344456400176550ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ /* NOTE: angles must be passed as [X-Angle, Y-Angle, Z-angle] order For instance you don't pass angles as [Z-Angle, X-Angle, Y-angle] to glm_euler_zxy function, All RELATED functions accept angles same order which is [X, Y, Z]. */ /* Types: enum glm_euler_seq Functions: CGLM_INLINE vec3s glms_euler_angles(mat4s m) CGLM_INLINE mat4s glms_euler_xyz(vec3s angles) CGLM_INLINE mat4s glms_euler_xzy(vec3s angles) CGLM_INLINE mat4s glms_euler_yxz(vec3s angles) CGLM_INLINE mat4s glms_euler_yzx(vec3s angles) CGLM_INLINE mat4s glms_euler_zxy(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 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 #define cglms_euler_h #include "../common.h" #include "../types-struct.h" #include "../euler.h" /*! * @brief extract euler angles (in radians) using xyz order * * @param[in] m affine transform * @returns angles vector [x, y, z] */ CGLM_INLINE vec3s glms_euler_angles(mat4s m) { vec3s dest; glm_euler_angles(m.raw, dest.raw); return dest; } /*! * @brief build rotation matrix from euler angles * * @param[in] angles angles as vector [Xangle, Yangle, Zangle] * @returns rotation matrix */ CGLM_INLINE mat4s glms_euler_xyz(vec3s angles) { mat4s dest; glm_euler_xyz(angles.raw, dest.raw); return dest; } /*! * @brief build rotation matrix from euler angles * * @param[in] angles angles as vector [Xangle, Yangle, Zangle] * @returns rotation matrix */ CGLM_INLINE mat4s glms_euler_xzy(vec3s angles) { mat4s dest; glm_euler_xzy(angles.raw, dest.raw); return dest; } /*! * @brief build rotation matrix from euler angles * * @param[in] angles angles as vector [Xangle, Yangle, Zangle] * @returns rotation matrix */ CGLM_INLINE mat4s glms_euler_yxz(vec3s angles) { mat4s dest; glm_euler_yxz(angles.raw, dest.raw); return dest; } /*! * @brief build rotation matrix from euler angles * * @param[in] angles angles as vector [Xangle, Yangle, Zangle] * @returns rotation matrix */ CGLM_INLINE mat4s glms_euler_yzx(vec3s angles) { mat4s dest; glm_euler_yzx(angles.raw, dest.raw); return dest; } /*! * @brief build rotation matrix from euler angles * * @param[in] angles angles as vector [Xangle, Yangle, Zangle] * @returns rotation matrix */ CGLM_INLINE mat4s glms_euler_zxy(vec3s angles) { mat4s dest; glm_euler_zxy(angles.raw, dest.raw); return dest; } /*! * @brief build rotation matrix from euler angles * * @param[in] angles angles as vector [Xangle, Yangle, Zangle] * @returns rotation matrix */ CGLM_INLINE mat4s glms_euler_zyx(vec3s angles) { mat4s dest; glm_euler_zyx(angles.raw, dest.raw); return dest; } /*! * @brief build rotation matrix from euler angles * * @param[in] angles angles as vector [Xangle, Yangle, Zangle] * @param[in] ord euler order * @returns rotation matrix */ CGLM_INLINE mat4s glms_euler_by_order(vec3s angles, glm_euler_seq ord) { mat4s dest; glm_euler_by_order(angles.raw, ord, dest.raw); 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 */ cglm-0.9.6/include/cglm/struct/frustum.h000066400000000000000000000103021475344456400202330ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ #ifndef cglms_frustums_h #define cglms_frustums_h #include "../common.h" #include "../types-struct.h" #include "../frustum.h" #include "plane.h" #include "vec3.h" #include "vec4.h" #include "mat4.h" /* you can override clip space coords but you have to provide all with same name e.g.: define GLM_CSCOORD_LBN {0.0f, 0.0f, 1.0f, 1.0f} */ #ifndef GLM_CUSTOM_CLIPSPACE /* near */ #define GLMS_CSCOORD_LBN {-1.0f, -1.0f, -1.0f, 1.0f} #define GLMS_CSCOORD_LTN {-1.0f, 1.0f, -1.0f, 1.0f} #define GLMS_CSCOORD_RTN { 1.0f, 1.0f, -1.0f, 1.0f} #define GLMS_CSCOORD_RBN { 1.0f, -1.0f, -1.0f, 1.0f} /* far */ #define GLMS_CSCOORD_LBF {-1.0f, -1.0f, 1.0f, 1.0f} #define GLMS_CSCOORD_LTF {-1.0f, 1.0f, 1.0f, 1.0f} #define GLMS_CSCOORD_RTF { 1.0f, 1.0f, 1.0f, 1.0f} #define GLMS_CSCOORD_RBF { 1.0f, -1.0f, 1.0f, 1.0f} #endif /*! * @brief extracts view frustum planes * * planes' space: * 1- if m = proj: View Space * 2- if m = viewProj: World Space * 3- if m = MVP: Object Space * * You probably want to extract planes in world space so use viewProj as m * Computing viewProj: * glm_mat4_mul(proj, view, viewProj); * * Exracted planes order: [left, right, bottom, top, near, far] * * @param[in] m matrix (see brief) * @param[out] dest extracted view frustum planes (see brief) */ CGLM_INLINE void glms_frustum_planes(mat4s m, vec4s dest[6]) { vec4 rawDest[6]; glm_frustum_planes(m.raw, rawDest); glms_vec4_(pack)(dest, rawDest, 6); } /*! * @brief extracts view frustum corners using clip-space coordinates * * corners' space: * 1- if m = invViewProj: World Space * 2- if m = invMVP: Object Space * * You probably want to extract corners in world space so use invViewProj * Computing invViewProj: * glm_mat4_mul(proj, view, viewProj); * ... * glm_mat4_inv(viewProj, invViewProj); * * if you have a near coord at i index, you can get it's far coord by i + 4 * * Find center coordinates: * for (j = 0; j < 4; j++) { * glm_vec3_center(corners[i], corners[i + 4], centerCorners[i]); * } * * @param[in] invMat matrix (see brief) * @param[out] dest exracted view frustum corners (see brief) */ CGLM_INLINE void glms_frustum_corners(mat4s invMat, vec4s dest[8]) { vec4 rawDest[8]; glm_frustum_corners(invMat.raw, rawDest); glms_vec4_(pack)(dest, rawDest, 8); } /*! * @brief finds center of view frustum * * @param[in] corners view frustum corners * @returns view frustum center */ CGLM_INLINE vec4s glms_frustum_center(vec4s corners[8]) { vec4 rawCorners[8]; vec4s r; glms_vec4_(unpack)(rawCorners, corners, 8); glm_frustum_center(rawCorners, r.raw); return r; } /*! * @brief finds bounding box of frustum relative to given matrix e.g. view mat * * @param[in] corners view frustum corners * @param[in] m matrix to convert existing conners * @param[out] box bounding box as array [min, max] */ CGLM_INLINE void glms_frustum_box(vec4s corners[8], mat4s m, vec3s box[2]) { vec4 rawCorners[8]; vec3 rawBox[2]; glms_vec4_(unpack)(rawCorners, corners, 8); glm_frustum_box(rawCorners, m.raw, rawBox); glms_vec3_(pack)(box, rawBox, 2); } /*! * @brief finds planes corners which is between near and far planes (parallel) * * this will be helpful if you want to split a frustum e.g. CSM/PSSM. This will * find planes' corners but you will need to one more plane. * Actually you have it, it is near, far or created previously with this func ;) * * @param[in] corners view frustum corners * @param[in] splitDist split distance * @param[in] farDist far distance (zFar) * @param[out] planeCorners plane corners [LB, LT, RT, RB] */ CGLM_INLINE void glms_frustum_corners_at(vec4s corners[8], float splitDist, float farDist, vec4s planeCorners[4]) { vec4 rawCorners[8]; vec4 rawPlaneCorners[4]; glms_vec4_(unpack)(rawCorners, corners, 8); glm_frustum_corners_at(rawCorners, splitDist, farDist, rawPlaneCorners); glms_vec4_(pack)(planeCorners, rawPlaneCorners, 8); } #endif /* cglms_frustums_h */ cglm-0.9.6/include/cglm/struct/handed/000077500000000000000000000000001475344456400176045ustar00rootroot00000000000000cglm-0.9.6/include/cglm/struct/handed/euler_to_quat_lh.h000066400000000000000000000055101475344456400233110ustar00rootroot00000000000000/* * 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 */ cglm-0.9.6/include/cglm/struct/handed/euler_to_quat_rh.h000066400000000000000000000055161475344456400233250ustar00rootroot00000000000000/* * 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 */ cglm-0.9.6/include/cglm/struct/io.h000066400000000000000000000047761475344456400171570ustar00rootroot00000000000000/* * 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_mat4_print(mat4s matrix, FILE *ostream); CGLM_INLINE void glms_mat3_print(mat3s matrix, FILE *ostream); CGLM_INLINE void glms_vec4_print(vec4s vec, FILE *ostream); CGLM_INLINE void glms_ivec4_print(ivec3s vec, FILE *ostream); CGLM_INLINE void glms_vec3_print(vec3s vec, FILE *ostream); CGLM_INLINE void glms_ivec3_print(ivec3s vec, FILE *ostream); CGLM_INLINE void glms_vec2_print(vec2s vec, FILE *ostream); CGLM_INLINE void glms_ivec2_print(ivec3s vec, FILE *ostream); CGLM_INLINE void glms_versor_print(versor vec, FILE *ostream); CGLM_INLINE void glms_aabb_print(vec3s bbox[2], const char *tag, FILE *ostream); */ #ifndef cglms_ios_h #define cglms_ios_h #include "../common.h" #include "../io.h" #include "mat4.h" #include #include CGLM_INLINE void glms_mat4_print(mat4s matrix, FILE * __restrict ostream) { glm_mat4_print(matrix.raw, ostream); } CGLM_INLINE void glms_mat3_print(mat3s matrix, FILE * __restrict ostream) { glm_mat3_print(matrix.raw, ostream); } CGLM_INLINE void glms_vec4_print(vec4s vec, FILE * __restrict ostream) { glm_vec4_print(vec.raw, ostream); } CGLM_INLINE void glms_ivec4_print(ivec4s vec, FILE * __restrict ostream) { glm_ivec4_print(vec.raw, ostream); } CGLM_INLINE void glms_vec3_print(vec3s vec, FILE * __restrict ostream) { glm_vec3_print(vec.raw, ostream); } CGLM_INLINE void glms_ivec3_print(ivec3s vec, FILE * __restrict ostream) { glm_ivec3_print(vec.raw, ostream); } CGLM_INLINE void glms_vec2_print(vec2s vec, FILE * __restrict ostream) { glm_vec2_print(vec.raw, ostream); } CGLM_INLINE void glms_ivec2_print(ivec2s vec, FILE * __restrict ostream) { glm_ivec2_print(vec.raw, ostream); } CGLM_INLINE void glms_versor_print(versors vec, FILE * __restrict ostream) { glm_versor_print(vec.raw, ostream); } CGLM_INLINE void glms_aabb_print(vec3s bbox[2], const char * __restrict tag, FILE * __restrict ostream) { vec3 rawBbox[2]; glms_vec3_(unpack)(rawBbox, bbox, 2); glm_aabb_print(rawBbox, tag, ostream); } #endif /* cglms_ios_h */ cglm-0.9.6/include/cglm/struct/ivec2.h000066400000000000000000000373111475344456400175470ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ /* Macros: GLMS_IVEC2_ONE_INIT GLMS_IVEC2_ZERO_INIT GLMS_IVEC2_ONE GLMS_IVEC2_ZERO Functions: CGLM_INLINE ivec2s glms_ivec2(int * __restrict v) CGLM_INLINE void glms_ivec2_pack(ivec2s dst[], ivec2s src[], size_t len) CGLM_INLINE void glms_ivec2_unpack(ivec2 dst[], ivec2 src[], size_t len) CGLM_INLINE ivec2s glms_ivec2_zero(ivec2s v) CGLM_INLINE ivec2s glms_ivec2_one(ivec2s v) CGLM_INLINE int glms_ivec2_dot(ivec2s a, ivec2s b) CGLM_INLINE int glms_ivec2_cross(ivec2s a, ivec2s b) CGLM_INLINE ivec2s glms_ivec2_add(ivec2s a, ivec2s b) CGLM_INLINE ivec2s glms_ivec2_adds(ivec2s v, int s) CGLM_INLINE ivec2s glms_ivec2_sub(ivec2s a, ivec2s b) CGLM_INLINE ivec2s glms_ivec2_subs(ivec2s v, int s) CGLM_INLINE ivec2s glms_ivec2_mul(ivec2s a, ivec2s b) CGLM_INLINE ivec2s glms_ivec2_scale(ivec2s v, int s) CGLM_INLINE ivec2s glms_ivec2_div(ivec2s a, ivec2s b) CGLM_INLINE ivec2s glms_ivec2_divs(ivec2s v, int s) CGLM_INLINE ivec2s glms_ivec2_mod(ivec2s a, ivec2s b) CGLM_INLINE ivec2s glms_ivec2_addadd(ivec2s a, ivec2s b) CGLM_INLINE ivec2s glms_ivec2_addadds(ivec2s a, int s) CGLM_INLINE ivec2s glms_ivec2_subadd(ivec2s a, ivec2s b) CGLM_INLINE ivec2s glms_ivec2_subadds(ivec2s a, int s) CGLM_INLINE ivec2s glms_ivec2_muladd(ivec2s a, ivec2s b) CGLM_INLINE ivec2s glms_ivec2_muladds(ivec2s a, int s) CGLM_INLINE ivec2s glms_ivec2_maxadd(ivec2s a, ivec2s b) CGLM_INLINE ivec2s glms_ivec2_minadd(ivec2s a, ivec2s b) CGLM_INLINE ivec2s glms_ivec2_subsub(ivec2s a, ivec2s b) CGLM_INLINE ivec2s glms_ivec2_subsubs(ivec2s a, int s) CGLM_INLINE ivec2s glms_ivec2_addsub(ivec2s a, ivec2s b) CGLM_INLINE ivec2s glms_ivec2_addsubs(ivec2s a, int s) CGLM_INLINE ivec2s glms_ivec2_mulsub(ivec2s a, ivec2s b) CGLM_INLINE ivec2s glms_ivec2_mulsubs(ivec2s a, int s) CGLM_INLINE ivec2s glms_ivec2_maxsub(ivec2s a, ivec2s b) CGLM_INLINE ivec2s glms_ivec2_minsub(ivec2s a, ivec2s b) CGLM_INLINE int glms_ivec2_distance2(ivec2s a, ivec2s b) CGLM_INLINE float glms_ivec2_distance(ivec2s a, ivec2s b) CGLM_INLINE ivec2s glms_ivec2_fill(int val) CGLM_INLINE bool glms_ivec2_eq(ivec2s v, int val); CGLM_INLINE bool glms_ivec2_eqv(ivec2s a, ivec2s b); CGLM_INLINE ivec2s glms_ivec2_maxv(ivec2s a, ivec2s b) CGLM_INLINE ivec2s glms_ivec2_minv(ivec2s a, ivec2s b) CGLM_INLINE ivec2s glms_ivec2_clamp(ivec2s v, int minVal, int maxVal) CGLM_INLINE ivec2s glms_ivec2_abs(ivec2s v) */ #ifndef cglms_ivec2_h #define cglms_ivec2_h #include "../common.h" #include "../types-struct.h" #include "../ivec2.h" #define glms_ivec2_(NAME) CGLM_STRUCTAPI(ivec2, NAME) #define GLMS_IVEC2_ONE_INIT {GLM_IVEC2_ONE_INIT} #define GLMS_IVEC2_ZERO_INIT {GLM_IVEC2_ZERO_INIT} #define GLMS_IVEC2_ONE ((ivec2s)GLMS_IVEC2_ONE_INIT) #define GLMS_IVEC2_ZERO ((ivec2s)GLMS_IVEC2_ZERO_INIT) /*! * @brief init ivec2 using ivec3 or ivec4 * * @param[in] v vector * @returns destination */ CGLM_INLINE ivec2s glms_ivec2(int * __restrict v) { ivec2s r; glm_ivec2(v, r.raw); return r; } /*! * @brief pack an array of ivec2 into an array of ivec2s * * @param[out] dst array of ivec2s * @param[in] src array of ivec2 * @param[in] len number of elements */ CGLM_INLINE void glms_ivec2_(pack)(ivec2s dst[], ivec2 src[], size_t len) { size_t i; for (i = 0; i < len; i++) { glm_ivec2_copy(src[i], dst[i].raw); } } /*! * @brief unpack an array of ivec2s into an array of ivec2 * * @param[out] dst array of ivec2 * @param[in] src array of ivec2s * @param[in] len number of elements */ CGLM_INLINE void glms_ivec2_(unpack)(ivec2 dst[], ivec2s src[], size_t len) { size_t i; for (i = 0; i < len; i++) { glm_ivec2_copy(src[i].raw, dst[i]); } } /*! * @brief set all members of [v] to zero * * @returns vector */ CGLM_INLINE ivec2s glms_ivec2_(zero)(void) { ivec2s r; glm_ivec2_zero(r.raw); return r; } /*! * @brief set all members of [v] to one * * @returns vector */ CGLM_INLINE ivec2s glms_ivec2_(one)(void) { ivec2s r; glm_ivec2_one(r.raw); return r; } /*! * @brief ivec2 dot product * * @param[in] a vector1 * @param[in] b vector2 * * @return dot product */ CGLM_INLINE int glms_ivec2_(dot)(ivec2s a, ivec2s b) { return glm_ivec2_dot(a.raw, b.raw); } /*! * @brief ivec2 cross product * * REF: http://allenchou.net/2013/07/cross-product-of-2d-vectors/ * * @param[in] a vector1 * @param[in] b vector2 * * @return Z component of cross product */ CGLM_INLINE int glms_ivec2_(cross)(ivec2s a, ivec2s b) { return glm_ivec2_cross(a.raw, b.raw); } /*! * @brief add vector [a] to vector [b] and store result in [dest] * * @param[in] a first vector * @param[in] b second vector * @returns destination */ CGLM_INLINE ivec2s glms_ivec2_(add)(ivec2s a, ivec2s b) { ivec2s r; glm_ivec2_add(a.raw, b.raw, r.raw); return r; } /*! * @brief add scalar s to vector [v] and store result in [dest] * * @param[in] v vector * @param[in] s scalar * @returns destination */ CGLM_INLINE ivec2s glms_ivec2_(adds)(ivec2s v, int s) { ivec2s r; glm_ivec2_adds(v.raw, s, r.raw); return r; } /*! * @brief subtract vector [b] from vector [a] and store result in [dest] * * @param[in] a first vector * @param[in] b second vector * @returns destination */ CGLM_INLINE ivec2s glms_ivec2_(sub)(ivec2s a, ivec2s b) { ivec2s r; glm_ivec2_sub(a.raw, b.raw, r.raw); return r; } /*! * @brief subtract scalar s from vector [v] and store result in [dest] * * @param[in] v vector * @param[in] s scalar * @returns destination */ CGLM_INLINE ivec2s glms_ivec2_(subs)(ivec2s v, int s) { ivec2s r; glm_ivec2_subs(v.raw, s, r.raw); return r; } /*! * @brief multiply vector [a] with vector [b] and store result in [dest] * * @param[in] a first vector * @param[in] b second vector * @returns destination */ CGLM_INLINE ivec2s glms_ivec2_(mul)(ivec2s a, ivec2s b) { ivec2s r; glm_ivec2_mul(a.raw, b.raw, r.raw); return r; } /*! * @brief multiply vector [a] with scalar s and store result in [dest] * * @param[in] v vector * @param[in] s scalar * @returns destination */ CGLM_INLINE ivec2s glms_ivec2_(scale)(ivec2s v, int s) { ivec2s r; glm_ivec2_scale(v.raw, s, r.raw); return r; } /*! * @brief div vector with another component-wise division: d = a / b * * @param[in] a vector 1 * @param[in] b vector 2 * @returns result = (a[0]/b[0], a[1]/b[1]) */ CGLM_INLINE ivec2s glms_ivec2_(div)(ivec2s a, ivec2s b) { ivec2s r; glm_ivec2_div(a.raw, b.raw, r.raw); return r; } /*! * @brief div vector with scalar: d = v / s * * @param[in] v vector * @param[in] s scalar * @returns result = (a[0]/s, a[1]/s) */ CGLM_INLINE ivec2s glms_ivec2_(divs)(ivec2s v, int s) { ivec2s r; glm_ivec2_divs(v.raw, s, r.raw); return r; } /*! * @brief mod vector with another component-wise modulo: d = a % b * * @param[in] a vector 1 * @param[in] b vector 2 * @returns result = (a[0]%b[0], a[1]%b[1]) */ CGLM_INLINE ivec2s glms_ivec2_(mod)(ivec2s a, ivec2s b) { ivec2s r; glm_ivec2_mod(a.raw, b.raw, r.raw); return r; } /*! * @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[in] dest dest += (a + b) * @returns dest */ CGLM_INLINE ivec2s glms_ivec2_(addadd)(ivec2s a, ivec2s b, ivec2s dest) { glm_ivec2_addadd(a.raw, b.raw, dest.raw); return dest; } /*! * @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[in] dest dest += (a + s) * @returns dest */ CGLM_INLINE ivec2s glms_ivec2_(addadds)(ivec2s a, int s, ivec2s dest) { glm_ivec2_addadds(a.raw, s, dest.raw); return dest; } /*! * @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[in] dest dest += (a - b) * @returns dest */ CGLM_INLINE ivec2s glms_ivec2_(subadd)(ivec2s a, ivec2s b, ivec2s dest) { glm_ivec2_subadd(a.raw, b.raw, dest.raw); return dest; } /*! * @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[in] dest dest += (a - s) * @returns dest */ CGLM_INLINE ivec2s glms_ivec2_(subadds)(ivec2s a, int s, ivec2s dest) { glm_ivec2_subadds(a.raw, s, dest.raw); return dest; } /*! * @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[in] dest dest += (a * b) * @returns dest */ CGLM_INLINE ivec2s glms_ivec2_(muladd)(ivec2s a, ivec2s b, ivec2s dest) { glm_ivec2_muladd(a.raw, b.raw, dest.raw); return dest; } /*! * @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[in] dest dest += (a * s) * @returns dest */ CGLM_INLINE ivec2s glms_ivec2_(muladds)(ivec2s a, int s, ivec2s dest) { glm_ivec2_muladds(a.raw, s, dest.raw); return dest; } /*! * @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[in] dest dest += max(a, b) * @returns dest */ CGLM_INLINE ivec2s glms_ivec2_(maxadd)(ivec2s a, ivec2s b, ivec2s dest) { glm_ivec2_maxadd(a.raw, b.raw, dest.raw); return dest; } /*! * @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[in] dest dest += min(a, b) * @returns dest */ CGLM_INLINE ivec2s glms_ivec2_(minadd)(ivec2s a, ivec2s b, ivec2s dest) { glm_ivec2_minadd(a.raw, b.raw, dest.raw); return dest; } /*! * @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[in] dest dest -= (a - b) * @returns dest */ CGLM_INLINE ivec2s glms_ivec2_(subsub)(ivec2s a, ivec2s b, ivec2s dest) { glm_ivec2_subsub(a.raw, b.raw, dest.raw); return dest; } /*! * @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[in] dest dest -= (a - s) * @returns dest */ CGLM_INLINE ivec2s glms_ivec2_(subsubs)(ivec2s a, int s, ivec2s dest) { glm_ivec2_subsubs(a.raw, s, dest.raw); return dest; } /*! * @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[in] dest dest -= (a + b) * @returns dest */ CGLM_INLINE ivec2s glms_ivec2_(addsub)(ivec2s a, ivec2s b, ivec2s dest) { glm_ivec2_addsub(a.raw, b.raw, dest.raw); return dest; } /*! * @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[in] dest dest -= (a + b) * @returns dest */ CGLM_INLINE ivec2s glms_ivec2_(addsubs)(ivec2s a, int s, ivec2s dest) { glm_ivec2_addsubs(a.raw, s, dest.raw); return dest; } /*! * @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[in] dest dest -= (a * b) * @returns dest */ CGLM_INLINE ivec2s glms_ivec2_(mulsub)(ivec2s a, ivec2s b, ivec2s dest) { glm_ivec2_mulsub(a.raw, b.raw, dest.raw); return dest; } /*! * @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[in] dest dest -= (a * s) * @returns dest */ CGLM_INLINE ivec2s glms_ivec2_(mulsubs)(ivec2s a, int s, ivec2s dest) { glm_ivec2_mulsubs(a.raw, s, dest.raw); return dest; } /*! * @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[in] dest dest -= max(a, b) * @returns dest */ CGLM_INLINE ivec2s glms_ivec2_(maxsub)(ivec2s a, ivec2s b, ivec2s dest) { glm_ivec2_maxsub(a.raw, b.raw, dest.raw); return dest; } /*! * @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[in] dest dest -= min(a, b) * @returns dest */ CGLM_INLINE ivec2s glms_ivec2_(minsub)(ivec2s a, ivec2s b, ivec2s dest) { glm_ivec2_minsub(a.raw, b.raw, dest.raw); return dest; } /*! * @brief squared distance between two vectors * * @param[in] a first vector * @param[in] b second vector * @return returns squared distance (distance * distance) */ CGLM_INLINE int glms_ivec2_(distance2)(ivec2s a, ivec2s b) { return glm_ivec2_distance2(a.raw, b.raw); } /*! * @brief distance between two vectors * * @param[in] a first vector * @param[in] b second vector * @return returns distance */ CGLM_INLINE float glms_ivec2_(distance)(ivec2s a, ivec2s b) { return glm_ivec2_distance(a.raw, b.raw); } /*! * @brief fill a vector with specified value * * @param[in] val value * @returns dest */ CGLM_INLINE ivec2s glms_ivec2_(fill)(int val) { ivec2s r; glm_ivec2_fill(r.raw, val); return r; } /*! * @brief check if vector is equal to value * * @param[in] v vector * @param[in] val value */ CGLM_INLINE bool glms_ivec2_(eq)(ivec2s v, int val) { return glm_ivec2_eq(v.raw, val); } /*! * @brief check if vector is equal to another * * @param[in] a vector * @param[in] b vector */ CGLM_INLINE bool glms_ivec2_(eqv)(ivec2s a, ivec2s b) { return glm_ivec2_eqv(a.raw, b.raw); } /*! * @brief set each member of dest to greater of vector a and b * * @param[in] a first vector * @param[in] b second vector * @returns destination */ CGLM_INLINE ivec2s glms_ivec2_(maxv)(ivec2s a, ivec2s b) { ivec2s r; glm_ivec2_maxv(a.raw, b.raw, r.raw); return r; } /*! * @brief set each member of dest to lesser of vector a and b * * @param[in] a first vector * @param[in] b second vector * @returns destination */ CGLM_INLINE ivec2s glms_ivec2_(minv)(ivec2s a, ivec2s b) { ivec2s r; glm_ivec2_minv(a.raw, b.raw, r.raw); return r; } /*! * @brief clamp each member of [v] between minVal and maxVal (inclusive) * * @param[in] v vector * @param[in] minVal minimum value * @param[in] maxVal maximum value * @returns clamped vector */ CGLM_INLINE ivec2s glms_ivec2_(clamp)(ivec2s v, int minVal, int maxVal) { glm_ivec2_clamp(v.raw, minVal, maxVal); return v; } /*! * @brief absolute value of v * * @param[in] v vector * @returns destination */ CGLM_INLINE ivec2s glms_ivec2_(abs)(ivec2s v) { ivec2s r; glm_ivec2_abs(v.raw, r.raw); return r; } #endif /* cglms_ivec2_h */ cglm-0.9.6/include/cglm/struct/ivec3.h000066400000000000000000000404221475344456400175450ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ /* Macros: GLMS_IVEC3_ONE_INIT GLMS_IVEC3_ZERO_INIT GLMS_IVEC3_ONE GLMS_IVEC3_ZERO Functions: CGLM_INLINE ivec3s glms_ivec3(ivec4s v4) CGLM_INLINE void glms_ivec3_pack(ivec3s dst[], ivec3 src[], size_t len) CGLM_INLINE void glms_ivec3_unpack(ivec3 dst[], ivec3s src[], size_t len) CGLM_INLINE ivec3s glms_ivec3_zero(void) CGLM_INLINE ivec3s glms_ivec3_one(void) CGLM_INLINE int glms_ivec3_dot(ivec3s a, ivec3s b) CGLM_INLINE int glms_ivec3_norm2(ivec3s v) CGLM_INLINE int glms_ivec3_norm(ivec3s v) CGLM_INLINE ivec3s glms_ivec3_add(ivec3s a, ivec3s b) CGLM_INLINE ivec3s glms_ivec3_adds(ivec3s v, int s) CGLM_INLINE ivec3s glms_ivec3_sub(ivec3s a, ivec3s b) CGLM_INLINE ivec3s glms_ivec3_subs(ivec3s v, int s) CGLM_INLINE ivec3s glms_ivec3_mul(ivec3s a, ivec3s b) CGLM_INLINE ivec3s glms_ivec3_scale(ivec3s v, int s) CGLM_INLINE ivec3s glms_ivec3_div(ivec3s a, ivec3s b) CGLM_INLINE ivec3s glms_ivec3_divs(ivec3s v, int s) CGLM_INLINE ivec3s glms_ivec3_mod(ivec3s a, ivec3s b) CGLM_INLINE ivec3s glms_ivec3_addadd(ivec3s a, ivec3s b, ivec3s dest) CGLM_INLINE ivec3s glms_ivec3_addadds(ivec3s a, int s, ivec3s dest) CGLM_INLINE ivec3s glms_ivec3_subadd(ivec3s a, ivec3s b, ivec3s dest) CGLM_INLINE ivec3s glms_ivec3_subadds(ivec3s a, int s, ivec3s dest) CGLM_INLINE ivec3s glms_ivec3_muladd(ivec3s a, ivec3s b, ivec3s dest) CGLM_INLINE ivec3s glms_ivec3_muladds(ivec3s a, int s, ivec3s dest) CGLM_INLINE ivec3s glms_ivec3_minadd(ivec3s a, ivec3s b, ivec3s dest) CGLM_INLINE ivec3s glms_ivec3_subsub(ivec3s a, ivec3s b, ivec3s dest) CGLM_INLINE ivec3s glms_ivec3_subsubs(ivec3s a, int s, ivec3s dest) CGLM_INLINE ivec3s glms_ivec3_addsub(ivec3s a, ivec3s b, ivec3s dest) CGLM_INLINE ivec3s glms_ivec3_addsubs(ivec3s a, int s, ivec3s dest) CGLM_INLINE ivec3s glms_ivec3_mulsub(ivec3s a, ivec3s b, ivec3s dest) CGLM_INLINE ivec3s glms_ivec3_mulsubs(ivec3s a, int s, ivec3s dest) CGLM_INLINE ivec3s glms_ivec3_maxsub(ivec3s a, ivec3s b, ivec3s dest) CGLM_INLINE ivec3s glms_ivec3_minsub(ivec3s a, ivec3s b, ivec3s dest) CGLM_INLINE int glms_ivec3_distance2(ivec3s a, ivec3s b) CGLM_INLINE float glms_ivec3_distance(ivec3s a, ivec3s b) CGLM_INLINE ivec3s glms_ivec3_fill(int val) CGLM_INLINE bool glms_ivec3_eq(ivec3s v, int val) CGLM_INLINE bool glms_ivec3_eqv(ivec3s a, ivec3s b) CGLM_INLINE ivec3s glms_ivec3_maxv(ivec3s a, ivec3s b) CGLM_INLINE ivec3s glms_ivec3_minv(ivec3s a, ivec3s b) CGLM_INLINE ivec3s glms_ivec3_clamp(ivec3s v, int minVal, int maxVal) CGLM_INLINE ivec3s glms_ivec3_abs(ivec3s v) */ #ifndef cglms_ivec3_h #define cglms_ivec3_h #include "../common.h" #include "../types-struct.h" #include "../ivec3.h" #define glms_ivec3_(NAME) CGLM_STRUCTAPI(ivec3, NAME) #define GLMS_IVEC3_ONE_INIT {GLM_IVEC3_ONE_INIT} #define GLMS_IVEC3_ZERO_INIT {GLM_IVEC3_ZERO_INIT} #define GLMS_IVEC3_ONE ((ivec3s)GLMS_IVEC3_ONE_INIT) #define GLMS_IVEC3_ZERO ((ivec3s)GLMS_IVEC3_ZERO_INIT) /*! * @brief init ivec3 using ivec4 * * @param[in] v4 vector4 * @returns destination */ CGLM_INLINE ivec3s glms_ivec3(ivec4s v4) { ivec3s r; glm_ivec3(v4.raw, r.raw); return r; } /*! * @brief pack an array of ivec3 into an array of ivec3s * * @param[out] dst array of ivec3s * @param[in] src array of ivec3 * @param[in] len number of elements */ CGLM_INLINE void glms_ivec3_(pack)(ivec3s dst[], ivec3 src[], size_t len) { size_t i; for (i = 0; i < len; i++) { glm_ivec3_copy(src[i], dst[i].raw); } } /*! * @brief unpack an array of ivec3s into an array of ivec3 * * @param[out] dst array of ivec3 * @param[in] src array of ivec3s * @param[in] len number of elements */ CGLM_INLINE void glms_ivec3_(unpack)(ivec3 dst[], ivec3s src[], size_t len) { size_t i; for (i = 0; i < len; i++) { glm_ivec3_copy(src[i].raw, dst[i]); } } /*! * @brief set all members of [v] to zero * * @returns vector */ CGLM_INLINE ivec3s glms_ivec3_(zero)(void) { ivec3s r; glm_ivec3_zero(r.raw); return r; } /*! * @brief set all members of [v] to one * * @returns vector */ CGLM_INLINE ivec3s glms_ivec3_(one)(void) { ivec3s r; glm_ivec3_one(r.raw); return r; } /*! * @brief ivec3 dot product * * @param[in] a vector1 * @param[in] b vector2 * * @return dot product */ CGLM_INLINE int glms_ivec3_(dot)(ivec3s a, ivec3s b) { return glm_ivec3_dot(a.raw, b.raw); } /*! * @brief norm * norm (magnitude) of vec * * we can use this func instead of calling norm * norm, because it would call * sqrtf function twice but with this func we can avoid func call, maybe this is * not good name for this func * * @param[in] v vector * * @return norm * norm */ CGLM_INLINE int glms_ivec3_(norm2)(ivec3s v) { return glm_ivec3_norm2(v.raw); } /*! * @brief euclidean norm (magnitude), also called L2 norm * this will give magnitude of vector in euclidean space * * @param[in] v vector * * @return norm */ CGLM_INLINE int glms_ivec3_(norm)(ivec3s v) { return glm_ivec3_norm(v.raw); } /*! * @brief add vector [a] to vector [b] and store result in [dest] * * @param[in] a first vector * @param[in] b second vector * @returns destination */ CGLM_INLINE ivec3s glms_ivec3_(add)(ivec3s a, ivec3s b) { ivec3s r; glm_ivec3_add(a.raw, b.raw, r.raw); return r; } /*! * @brief add scalar s to vector [v] and store result in [dest] * * @param[in] v vector * @param[in] s scalar * @returns destination */ CGLM_INLINE ivec3s glms_ivec3_(adds)(ivec3s v, int s) { ivec3s r; glm_ivec3_adds(v.raw, s, r.raw); return r; } /*! * @brief subtract vector [b] from vector [a] and store result in [dest] * * @param[in] a first vector * @param[in] b second vector * @returns destination */ CGLM_INLINE ivec3s glms_ivec3_(sub)(ivec3s a, ivec3s b) { ivec3s r; glm_ivec3_sub(a.raw, b.raw, r.raw); return r; } /*! * @brief subtract scalar s from vector [v] and store result in [dest] * * @param[in] v vector * @param[in] s scalar * @returns destination */ CGLM_INLINE ivec3s glms_ivec3_(subs)(ivec3s v, int s) { ivec3s r; glm_ivec3_subs(v.raw, s, r.raw); return r; } /*! * @brief multiply vector [a] with vector [b] and store result in [dest] * * @param[in] a first vector * @param[in] b second vector * @returns destination */ CGLM_INLINE ivec3s glms_ivec3_(mul)(ivec3s a, ivec3s b) { ivec3s r; glm_ivec3_mul(a.raw, b.raw, r.raw); return r; } /*! * @brief multiply vector [a] with scalar s and store result in [dest] * * @param[in] v vector * @param[in] s scalar * @returns destination */ CGLM_INLINE ivec3s glms_ivec3_(scale)(ivec3s v, int s) { ivec3s r; glm_ivec3_scale(v.raw, s, r.raw); return r; } /*! * @brief div vector with another component-wise division: d = a / b * * @param[in] a vector 1 * @param[in] b vector 2 * @returns result = (a[0]/b[0], a[1]/b[1], a[2]/b[2]) */ CGLM_INLINE ivec3s glms_ivec3_(div)(ivec3s a, ivec3s b) { ivec3s r; glm_ivec3_div(a.raw, b.raw, r.raw); return r; } /*! * @brief div vector with scalar: d = v / s * * @param[in] v vector * @param[in] s scalar * @returns result = (a[0]/s, a[1]/s, a[2]/s) */ CGLM_INLINE ivec3s glms_ivec3_(divs)(ivec3s v, int s) { ivec3s r; glm_ivec3_divs(v.raw, s, r.raw); return r; } /*! * @brief Element-wise modulo operation on ivec3 vectors: dest = a % b * * Performs element-wise modulo on each component of vectors `a` and `b`. * * @param[in] a vector 1 * @param[in] b vector 2 * @returns result = (a[0]%b[0], a[1]%b[1], a[2]%b[2]) */ CGLM_INLINE ivec3s glms_ivec3_(mod)(ivec3s a, ivec3s b) { ivec3s r; glm_ivec3_mod(a.raw, b.raw, r.raw); return r; } /*! * @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[in] dest dest += (a + b) * @returns dest */ CGLM_INLINE ivec3s glms_ivec3_(addadd)(ivec3s a, ivec3s b, ivec3s dest) { glm_ivec3_addadd(a.raw, b.raw, dest.raw); return dest; } /*! * @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[in] dest dest += (a + s) * @returns dest */ CGLM_INLINE ivec3s glms_ivec3_(addadds)(ivec3s a, int s, ivec3s dest) { glm_ivec3_addadds(a.raw, s, dest.raw); return dest; } /*! * @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[in] dest dest += (a - b) * @returns dest */ CGLM_INLINE ivec3s glms_ivec3_(subadd)(ivec3s a, ivec3s b, ivec3s dest) { glm_ivec3_subadd(a.raw, b.raw, dest.raw); return dest; } /*! * @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[in] dest dest += (a - s) * @returns dest */ CGLM_INLINE ivec3s glms_ivec3_(subadds)(ivec3s a, int s, ivec3s dest) { glm_ivec3_subadds(a.raw, s, dest.raw); return dest; } /*! * @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[in] dest dest += (a * b) * @returns dest */ CGLM_INLINE ivec3s glms_ivec3_(muladd)(ivec3s a, ivec3s b, ivec3s dest) { glm_ivec3_muladd(a.raw, b.raw, dest.raw); return dest; } /*! * @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[in] dest dest += (a * s) * @returns dest */ CGLM_INLINE ivec3s glms_ivec3_(muladds)(ivec3s a, int s, ivec3s dest) { glm_ivec3_muladds(a.raw, s, dest.raw); return dest; } /*! * @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[in] dest dest += max(a, b) * @returns dest */ CGLM_INLINE ivec3s glms_ivec3_(maxadd)(ivec3s a, ivec3s b, ivec3s dest) { glm_ivec3_maxadd(a.raw, b.raw, dest.raw); return dest; } /*! * @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[in] dest dest += min(a, b) * @returns dest */ CGLM_INLINE ivec3s glms_ivec3_(minadd)(ivec3s a, ivec3s b, ivec3s dest) { glm_ivec3_minadd(a.raw, b.raw, dest.raw); return dest; } /*! * @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[in] dest dest -= (a - b) * @returns dest */ CGLM_INLINE ivec3s glms_ivec3_(subsub)(ivec3s a, ivec3s b, ivec3s dest) { glm_ivec3_subsub(a.raw, b.raw, dest.raw); return dest; } /*! * @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[in] dest dest -= (a - s) * @returns dest */ CGLM_INLINE ivec3s glms_ivec3_(subsubs)(ivec3s a, int s, ivec3s dest) { glm_ivec3_subsubs(a.raw, s, dest.raw); return dest; } /*! * @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[in] dest dest -= (a + b) * @returns dest */ CGLM_INLINE ivec3s glms_ivec3_(addsub)(ivec3s a, ivec3s b, ivec3s dest) { glm_ivec3_addsub(a.raw, b.raw, dest.raw); return dest; } /*! * @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[in] dest dest -= (a + b) * @returns dest */ CGLM_INLINE ivec3s glms_ivec3_(addsubs)(ivec3s a, int s, ivec3s dest) { glm_ivec3_addsubs(a.raw, s, dest.raw); return dest; } /*! * @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[in] dest dest -= (a * b) * @returns dest */ CGLM_INLINE ivec3s glms_ivec3_(mulsub)(ivec3s a, ivec3s b, ivec3s dest) { glm_ivec3_mulsub(a.raw, b.raw, dest.raw); return dest; } /*! * @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[in] dest dest -= (a * s) * @returns dest */ CGLM_INLINE ivec3s glms_ivec3_(mulsubs)(ivec3s a, int s, ivec3s dest) { glm_ivec3_mulsubs(a.raw, s, dest.raw); return dest; } /*! * @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[in] dest dest -= max(a, b) * @returns dest */ CGLM_INLINE ivec3s glms_ivec3_(maxsub)(ivec3s a, ivec3s b, ivec3s dest) { glm_ivec3_maxsub(a.raw, b.raw, dest.raw); return dest; } /*! * @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[in] dest dest -= min(a, b) * @returns dest */ CGLM_INLINE ivec3s glms_ivec3_(minsub)(ivec3s a, ivec3s b, ivec3s dest) { glm_ivec3_minsub(a.raw, b.raw, dest.raw); return dest; } /*! * @brief squared distance between two vectors * * @param[in] a first vector * @param[in] b second vector * @return returns squared distance (distance * distance) */ CGLM_INLINE int glms_ivec3_(distance2)(ivec3s a, ivec3s b) { return glm_ivec3_distance2(a.raw, b.raw); } /*! * @brief distance between two vectors * * @param[in] a first vector * @param[in] b second vector * @return returns distance */ CGLM_INLINE float glms_ivec3_(distance)(ivec3s a, ivec3s b) { return glm_ivec3_distance(a.raw, b.raw); } /*! * @brief fill a vector with specified value * * @param[in] val value * @returns destination */ CGLM_INLINE ivec3s glms_ivec3_(fill)(int val) { ivec3s r; glm_ivec3_fill(r.raw, val); return r; } /*! * @brief check if vector is equal to value * * @param[in] v vector * @param[in] val value */ CGLM_INLINE bool glms_ivec3_(eq)(ivec3s v, int val) { return glm_ivec3_eq(v.raw, val); } /*! * @brief check if vector is equal to another * * @param[in] a vector * @param[in] b vector */ CGLM_INLINE bool glms_ivec3_(eqv)(ivec3s a, ivec3s b) { return glm_ivec3_eqv(a.raw, b.raw); } /*! * @brief set each member of dest to greater of vector a and b * * @param[in] a first vector * @param[in] b second vector * @returns destination */ CGLM_INLINE ivec3s glms_ivec3_(maxv)(ivec3s a, ivec3s b) { ivec3s r; glm_ivec3_maxv(a.raw, b.raw, r.raw); return r; } /*! * @brief set each member of dest to lesser of vector a and b * * @param[in] a first vector * @param[in] b second vector * @returns destination */ CGLM_INLINE ivec3s glms_ivec3_(minv)(ivec3s a, ivec3s b) { ivec3s r; glm_ivec3_minv(a.raw, b.raw, r.raw); return r; } /*! * @brief clamp each member of [v] between minVal and maxVal (inclusive) * * @param[in] v vector * @param[in] minVal minimum value * @param[in] maxVal maximum value * @returns clamped vector */ CGLM_INLINE ivec3s glms_ivec3_(clamp)(ivec3s v, int minVal, int maxVal) { glm_ivec3_clamp(v.raw, minVal, maxVal); return v; } /*! * @brief absolute value of v * * @param[in] v vector * @returns destination */ CGLM_INLINE ivec3s glms_ivec3_(abs)(ivec3s v) { ivec3s r; glm_ivec3_abs(v.raw, r.raw); return r; } #endif /* cglms_ivec3_h */ cglm-0.9.6/include/cglm/struct/ivec4.h000066400000000000000000000330521475344456400175470ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ /* Macros: GLMS_IVEC4_ONE_INIT GLMS_IVEC4_ZERO_INIT GLMS_IVEC4_ONE GLMS_IVEC4_ZERO Functions: CGLM_INLINE ivec4s glms_ivec4(ivec3s v3, int last) CGLM_INLINE void glms_ivec4_pack(ivec4s dst[], ivec4 src[], size_t len) CGLM_INLINE void glms_ivec4_unpack(ivec4 dst[], ivec4s src[], size_t len) CGLM_INLINE ivec4s glms_ivec4_zero(void) CGLM_INLINE ivec4s glms_ivec4_one(void) CGLM_INLINE ivec4s glms_ivec4_add(ivec4s a, ivec4s b) CGLM_INLINE ivec4s glms_ivec4_adds(ivec4s v, int s) CGLM_INLINE ivec4s glms_ivec4_sub(ivec4s a, ivec4s b) CGLM_INLINE ivec4s glms_ivec4_subs(ivec4s v, int s) CGLM_INLINE ivec4s glms_ivec4_mul(ivec4s a, ivec4s b) CGLM_INLINE ivec4s glms_ivec4_scale(ivec4s v, int s) CGLM_INLINE ivec4s glms_ivec4_addadd(ivec4s a, ivec4s b, ivec4s dest) CGLM_INLINE ivec4s glms_ivec4_addadds(ivec4s a, int s, ivec4s dest) CGLM_INLINE ivec4s glms_ivec4_subadd(ivec4s a, ivec4s b, ivec4s dest) CGLM_INLINE ivec4s glms_ivec4_subadds(ivec4s a, int s, ivec4s dest) CGLM_INLINE ivec4s glms_ivec4_muladd(ivec4s a, ivec4s b, ivec4s dest) CGLM_INLINE ivec4s glms_ivec4_muladds(ivec4s a, int s, ivec4s dest) CGLM_INLINE ivec4s glms_ivec4_maxadd(ivec4s a, ivec4s b, ivec4s dest) CGLM_INLINE ivec4s glms_ivec4_minadd(ivec4s a, ivec4s b, ivec4s dest) CGLM_INLINE ivec4s glms_ivec4_subsub(ivec4s a, ivec4s b, ivec4s dest) CGLM_INLINE ivec4s glms_ivec4_subsubs(ivec4s a, int s, ivec4s dest) CGLM_INLINE ivec4s glms_ivec4_addsub(ivec4s a, ivec4s b, ivec4s dest) CGLM_INLINE ivec4s glms_ivec4_addsubs(ivec4s a, int s, ivec4s dest) CGLM_INLINE ivec4s glms_ivec4_mulsub(ivec4s a, ivec4s b, ivec4s dest) CGLM_INLINE ivec4s glms_ivec4_mulsubs(ivec4s a, int s, ivec4s dest) CGLM_INLINE ivec4s glms_ivec4_maxsub(ivec4s a, ivec4s b, ivec4s dest) CGLM_INLINE ivec4s glms_ivec4_minsub(ivec4s a, ivec4s b, ivec4s dest) CGLM_INLINE int glms_ivec4_distance2(ivec4s a, ivec4s b) CGLM_INLINE float glms_ivec4_distance(ivec4s a, ivec4s b) CGLM_INLINE ivec4s glms_ivec4_maxv(ivec4s a, ivec4s b) CGLM_INLINE ivec4s glms_ivec4_minv(ivec4s a, ivec4s b) CGLM_INLINE ivec4s glms_ivec4_clamp(ivec4s v, int minVal, int maxVal) CGLM_INLINE ivec4s glms_ivec4_abs(ivec4s v) */ #ifndef cglms_ivec4_h #define cglms_ivec4_h #include "../common.h" #include "../types-struct.h" #include "../ivec4.h" #define glms_ivec4_(NAME) CGLM_STRUCTAPI(ivec4, NAME) #define GLMS_IVEC4_ONE_INIT {GLM_IVEC4_ONE_INIT} #define GLMS_IVEC4_ZERO_INIT {GLM_IVEC4_ZERO_INIT} #define GLMS_IVEC4_ONE ((ivec4s)GLMS_IVEC4_ONE_INIT) #define GLMS_IVEC4_ZERO ((ivec4s)GLMS_IVEC4_ZERO_INIT) /*! * @brief init ivec4 using ivec3 * * @param[in] v3 vector3 * @param[in] last last item * @returns destination */ CGLM_INLINE ivec4s glms_ivec4(ivec3s v3, int last) { ivec4s r; glm_ivec4(v3.raw, last, r.raw); return r; } /*! * @brief pack an array of ivec4 into an array of ivec4s * * @param[out] dst array of ivec4s * @param[in] src array of ivec4 * @param[in] len number of elements */ CGLM_INLINE void glms_ivec4_(pack)(ivec4s dst[], ivec4 src[], size_t len) { size_t i; for (i = 0; i < len; i++) { glm_ivec4_copy(src[i], dst[i].raw); } } /*! * @brief unpack an array of ivec4s into an array of ivec4 * * @param[out] dst array of ivec4 * @param[in] src array of ivec4s * @param[in] len number of elements */ CGLM_INLINE void glms_ivec4_(unpack)(ivec4 dst[], ivec4s src[], size_t len) { size_t i; for (i = 0; i < len; i++) { glm_ivec4_copy(src[i].raw, dst[i]); } } /*! * @brief set all members of [v] to zero * * @returns vector */ CGLM_INLINE ivec4s glms_ivec4_(zero)(void) { ivec4s r; glm_ivec4_zero(r.raw); return r; } /*! * @brief set all members of [v] to one * * @returns vector */ CGLM_INLINE ivec4s glms_ivec4_(one)(void) { ivec4s r; glm_ivec4_one(r.raw); return r; } /*! * @brief add vector [a] to vector [b] and store result in [dest] * * @param[in] a first vector * @param[in] b second vector * @returns destination */ CGLM_INLINE ivec4s glms_ivec4_(add)(ivec4s a, ivec4s b) { ivec4s r; glm_ivec4_add(a.raw, b.raw, r.raw); return r; } /*! * @brief add scalar s to vector [v] and store result in [dest] * * @param[in] v vector * @param[in] s scalar * @returns destination */ CGLM_INLINE ivec4s glms_ivec4_(adds)(ivec4s v, int s) { ivec4s r; glm_ivec4_adds(v.raw, s, r.raw); return r; } /*! * @brief subtract vector [b] from vector [a] and store result in [dest] * * @param[in] a first vector * @param[in] b second vector * @returns destination */ CGLM_INLINE ivec4s glms_ivec4_(sub)(ivec4s a, ivec4s b) { ivec4s r; glm_ivec4_sub(a.raw, b.raw, r.raw); return r; } /*! * @brief subtract scalar s from vector [v] and store result in [dest] * * @param[in] v vector * @param[in] s scalar * @returns destination */ CGLM_INLINE ivec4s glms_ivec4_(subs)(ivec4s v, int s) { ivec4s r; glm_ivec4_subs(v.raw, s, r.raw); return r; } /*! * @brief multiply vector [a] with vector [b] and store result in [dest] * * @param[in] a first vector * @param[in] b second vector * @returns destination */ CGLM_INLINE ivec4s glms_ivec4_(mul)(ivec4s a, ivec4s b) { ivec4s r; glm_ivec4_mul(a.raw, b.raw, r.raw); return r; } /*! * @brief multiply vector [a] with scalar s and store result in [dest] * * @param[in] v vector * @param[in] s scalar * @returns destination */ CGLM_INLINE ivec4s glms_ivec4_(scale)(ivec4s v, int s) { ivec4s r; glm_ivec4_scale(v.raw, s, r.raw); return r; } /*! * @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[in] dest dest += (a + b) * @returns dest */ CGLM_INLINE ivec4s glms_ivec4_(addadd)(ivec4s a, ivec4s b, ivec4s dest) { glm_ivec4_addadd(a.raw, b.raw, dest.raw); return dest; } /*! * @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[in] dest dest += (a + s) * @returns dest */ CGLM_INLINE ivec4s glms_ivec4_(addadds)(ivec4s a, int s, ivec4s dest) { glm_ivec4_addadds(a.raw, s, dest.raw); return dest; } /*! * @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[in] dest dest += (a - b) * @returns dest */ CGLM_INLINE ivec4s glms_ivec4_(subadd)(ivec4s a, ivec4s b, ivec4s dest) { glm_ivec4_subadd(a.raw, b.raw, dest.raw); return dest; } /*! * @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[in] dest dest += (a - s) * @returns dest */ CGLM_INLINE ivec4s glms_ivec4_(subadds)(ivec4s a, int s, ivec4s dest) { glm_ivec4_subadds(a.raw, s, dest.raw); return dest; } /*! * @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[in] dest dest += (a * b) * @returns dest */ CGLM_INLINE ivec4s glms_ivec4_(muladd)(ivec4s a, ivec4s b, ivec4s dest) { glm_ivec4_muladd(a.raw, b.raw, dest.raw); return dest; } /*! * @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[in] dest dest += (a * s) * @returns dest */ CGLM_INLINE ivec4s glms_ivec4_(muladds)(ivec4s a, int s, ivec4s dest) { glm_ivec4_muladds(a.raw, s, dest.raw); return dest; } /*! * @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[in] dest dest += max(a, b) * @returns dest */ CGLM_INLINE ivec4s glms_ivec4_(maxadd)(ivec4s a, ivec4s b, ivec4s dest) { glm_ivec4_maxadd(a.raw, b.raw, dest.raw); return dest; } /*! * @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[in] dest dest += min(a, b) * @returns dest */ CGLM_INLINE ivec4s glms_ivec4_(minadd)(ivec4s a, ivec4s b, ivec4s dest) { glm_ivec4_minadd(a.raw, b.raw, dest.raw); return dest; } /*! * @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[in] dest dest -= (a - b) * @returns dest */ CGLM_INLINE ivec4s glms_ivec4_(subsub)(ivec4s a, ivec4s b, ivec4s dest) { glm_ivec4_subsub(a.raw, b.raw, dest.raw); return dest; } /*! * @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[in] dest dest -= (a - s) * @returns dest */ CGLM_INLINE ivec4s glms_ivec4_(subsubs)(ivec4s a, int s, ivec4s dest) { glm_ivec4_subsubs(a.raw, s, dest.raw); return dest; } /*! * @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[in] dest dest -= (a + b) * @returns dest */ CGLM_INLINE ivec4s glms_ivec4_(addsub)(ivec4s a, ivec4s b, ivec4s dest) { glm_ivec4_addsub(a.raw, b.raw, dest.raw); return dest; } /*! * @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[in] dest dest -= (a + b) * @returns dest */ CGLM_INLINE ivec4s glms_ivec4_(addsubs)(ivec4s a, int s, ivec4s dest) { glm_ivec4_addsubs(a.raw, s, dest.raw); return dest; } /*! * @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[in] dest dest -= (a * b) * @returns dest */ CGLM_INLINE ivec4s glms_ivec4_(mulsub)(ivec4s a, ivec4s b, ivec4s dest) { glm_ivec4_mulsub(a.raw, b.raw, dest.raw); return dest; } /*! * @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[in] dest dest -= (a * s) * @returns dest */ CGLM_INLINE ivec4s glms_ivec4_(mulsubs)(ivec4s a, int s, ivec4s dest) { glm_ivec4_mulsubs(a.raw, s, dest.raw); return dest; } /*! * @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[in] dest dest -= max(a, b) * @returns dest */ CGLM_INLINE ivec4s glms_ivec4_(maxsub)(ivec4s a, ivec4s b, ivec4s dest) { glm_ivec4_maxsub(a.raw, b.raw, dest.raw); return dest; } /*! * @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[in] dest dest -= min(a, b) * @returns dest */ CGLM_INLINE ivec4s glms_ivec4_(minsub)(ivec4s a, ivec4s b, ivec4s dest) { glm_ivec4_minsub(a.raw, b.raw, dest.raw); return dest; } /*! * @brief squared distance between two vectors * * @param[in] a first vector * @param[in] b second vector * @return returns squared distance (distance * distance) */ CGLM_INLINE int glms_ivec4_(distance2)(ivec4s a, ivec4s b) { return glm_ivec4_distance2(a.raw, b.raw); } /*! * @brief distance between two vectors * * @param[in] a first vector * @param[in] b second vector * @return returns distance */ CGLM_INLINE float glms_ivec4_(distance)(ivec4s a, ivec4s b) { return glm_ivec4_distance(a.raw, b.raw); } /*! * @brief set each member of dest to greater of vector a and b * * @param[in] a first vector * @param[in] b second vector * @returns destination */ CGLM_INLINE ivec4s glms_ivec4_(maxv)(ivec4s a, ivec4s b) { ivec4s r; glm_ivec4_maxv(a.raw, b.raw, r.raw); return r; } /*! * @brief set each member of dest to lesser of vector a and b * * @param[in] a first vector * @param[in] b second vector * @returns destination */ CGLM_INLINE ivec4s glms_ivec4_(minv)(ivec4s a, ivec4s b) { ivec4s r; glm_ivec4_minv(a.raw, b.raw, r.raw); return r; } /*! * @brief clamp each member of [v] between minVal and maxVal (inclusive) * * @param[in] v vector * @param[in] minVal minimum value * @param[in] maxVal maximum value * @returns clamped vector */ CGLM_INLINE ivec4s glms_ivec4_(clamp)(ivec4s v, int minVal, int maxVal) { glm_ivec4_clamp(v.raw, minVal, maxVal); return v; } /*! * @brief absolute value of v * * @param[in] v vector * @returns destination */ CGLM_INLINE ivec4s glms_ivec4_(abs)(ivec4s v) { ivec4s r; glm_ivec4_abs(v.raw, r.raw); return r; } #endif /* cglms_ivec4_h */ cglm-0.9.6/include/cglm/struct/mat2.h000066400000000000000000000133471475344456400174050ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ /* Macros: GLM_MAT2_IDENTITY_INIT GLM_MAT2_ZERO_INIT GLM_MAT2_IDENTITY GLM_MAT2_ZERO Functions: CGLM_INLINE void glms_mat2_identity(mat2 mat) CGLM_INLINE void glms_mat2_identity_array(mat2 * restrict mat, size_t count) CGLM_INLINE void glms_mat2_zero(mat2 mat) CGLM_INLINE void glms_mat2_mul(mat2 m1, mat2 m2, mat2 dest) CGLM_INLINE void glms_mat2_transpose_to(mat2 m, mat2 dest) CGLM_INLINE void glms_mat2_transpose(mat2 m) CGLM_INLINE void glms_mat2_mulv(mat2 m, vec2 v, vec2 dest) CGLM_INLINE float glms_mat2_trace(mat2 m) CGLM_INLINE void glms_mat2_scale(mat2 m, float s) CGLM_INLINE float glms_mat2_det(mat2 mat) CGLM_INLINE void glms_mat2_inv(mat2 mat, mat2 dest) CGLM_INLINE void glms_mat2_swap_col(mat2 mat, int col1, int col2) CGLM_INLINE void glms_mat2_swap_row(mat2 mat, int row1, int row2) CGLM_INLINE float glms_mat2_rmc(vec2 r, mat2 m, vec2 c) CGLM_INLINE mat2s glms_mat2_make(const float * __restrict src); */ #ifndef cglms_mat2_h #define cglms_mat2_h #include "../common.h" #include "../types-struct.h" #include "../mat2.h" /* api definition */ #define glms_mat2_(NAME) CGLM_STRUCTAPI(mat2, NAME) #define GLMS_MAT2_IDENTITY_INIT {GLM_MAT2_IDENTITY_INIT} #define GLMS_MAT2_ZERO_INIT {GLM_MAT2_ZERO_INIT} /* for C only */ #define GLMS_MAT2_IDENTITY ((mat2s)GLMS_MAT2_IDENTITY_INIT) #define GLMS_MAT2_ZERO ((mat2s)GLMS_MAT2_ZERO_INIT) /*! * @brief make given matrix identity. It is identical with below, * but it is more easy to do that with this func especially for members * e.g. glm_mat2_identity(aStruct->aMatrix); * * @code * glm_mat2_copy(GLM_MAT2_IDENTITY, mat); // C only * * // or * mat2 mat = GLM_MAT2_IDENTITY_INIT; * @endcode * * @returns identity matrix */ CGLM_INLINE mat2s glms_mat2_(identity)(void) { mat2s r; glm_mat2_identity(r.raw); return r; } /*! * @brief make given matrix array's each element identity matrix * * @param[in, out] mat matrix array (must be aligned (16) * if alignment is not disabled) * * @param[in] count count of matrices */ CGLM_INLINE void glms_mat2_(identity_array)(mat2s * __restrict mat, size_t count) { CGLM_ALIGN_MAT mat2s t = GLMS_MAT2_IDENTITY_INIT; size_t i; for (i = 0; i < count; i++) { glm_mat2_copy(t.raw, mat[i].raw); } } /*! * @brief make given matrix zero. * * @returns matrix */ CGLM_INLINE mat2s glms_mat2_(zero)(void) { mat2s r; glm_mat2_zero(r.raw); return r; } /*! * @brief multiply m1 and m2 to dest * * m1, m2 and dest matrices can be same matrix, it is possible to write this: * * @code * mat2 m = GLM_MAT2_IDENTITY_INIT; * r = glms_mat2_mul(m, m); * @endcode * * @param[in] m1 left matrix * @param[in] m2 right matrix * * @returns destination matrix */ CGLM_INLINE mat2s glms_mat2_(mul)(mat2s m1, mat2s m2) { mat2s r; glm_mat2_mul(m1.raw, m2.raw, r.raw); return r; } /*! * @brief transpose mat2 * * @param[in] m matrix to transpose * * @returns transposed matrix */ CGLM_INLINE mat2s glms_mat2_(transpose)(mat2s m) { glm_mat2_transpose(m.raw); return m; } /*! * @brief multiply mat2 with vec2 (column vector) and store in dest vector * * @param[in] m mat2 (left) * @param[in] v vec2 (right, column vector) * @returns vec2 (result, column vector) */ CGLM_INLINE vec2s glms_mat2_(mulv)(mat2s m, vec2s v) { vec2s r; glm_mat2_mulv(m.raw, v.raw, r.raw); return r; } /*! * @brief trace of matrix * * sum of the elements on the main diagonal from upper left to the lower right * * @param[in] m matrix */ CGLM_INLINE float glms_mat2_(trace)(mat2s m) { return glm_mat2_trace(m.raw); } /*! * @brief scale (multiply with scalar) matrix * * multiply matrix with scalar * * @param[in, out] m matrix * @param[in] s scalar * @returns matrix */ CGLM_INLINE mat2s glms_mat2_(scale)(mat2s m, float s) { glm_mat2_scale(m.raw, s); return m; } /*! * @brief mat2 determinant * * @param[in] mat matrix * * @return determinant */ CGLM_INLINE float glms_mat2_(det)(mat2s mat) { return glm_mat2_det(mat.raw); } /*! * @brief inverse mat2 and store in dest * * @param[in] mat matrix * @returns matrix */ CGLM_INLINE mat2s glms_mat2_(inv)(mat2s mat) { mat2s r; glm_mat2_inv(mat.raw, r.raw); return r; } /*! * @brief swap two matrix columns * * @param[in] mat matrix * @param[in] col1 col1 * @param[in] col2 col2 * @returns matrix */ CGLM_INLINE mat2s glms_mat2_(swap_col)(mat2s mat, int col1, int col2) { glm_mat2_swap_col(mat.raw, col1, col2); return mat; } /*! * @brief swap two matrix rows * * @param[in] mat matrix * @param[in] row1 row1 * @param[in] row2 row2 * @returns matrix */ CGLM_INLINE mat2s glms_mat2_(swap_row)(mat2s mat, int row1, int row2) { glm_mat2_swap_row(mat.raw, row1, row2); return mat; } /*! * @brief helper for R (row vector) * M (matrix) * C (column vector) * * rmc stands for Row * Matrix * Column * * the result is scalar because R * M = Matrix1x2 (row vector), * then Matrix1x2 * Vec2 (column vector) = Matrix1x1 (Scalar) * * @param[in] r row vector or matrix1x2 * @param[in] m matrix2x2 * @param[in] c column vector or matrix2x1 * * @return scalar value e.g. Matrix1x1 */ CGLM_INLINE float glms_mat2_(rmc)(vec2s r, mat2s m, vec2s c) { return glm_mat2_rmc(r.raw, m.raw, c.raw); } /*! * @brief Create mat2 matrix from pointer * * @param[in] src pointer to an array of floats * @return constructed matrix from raw pointer */ CGLM_INLINE mat2s glms_mat2_(make)(const float * __restrict src) { mat2s r; glm_mat2_make(src, r.raw); return r; } #endif /* cglms_mat2_h */ cglm-0.9.6/include/cglm/struct/mat2x3.h000066400000000000000000000050361475344456400176540ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ /* Macros: GLMS_MAT2X3_ZERO_INIT GLMS_MAT2X3_ZERO Functions: CGLM_INLINE mat2x3s glms_mat2x3_zero(void); CGLM_INLINE mat2x3s glms_mat2x3_make(const float * __restrict src); CGLM_INLINE mat2s glms_mat2x3_mul(mat2x3s m1, mat3x2s m2); CGLM_INLINE vec3s glms_mat2x3_mulv(mat2x3s m, vec2s v); CGLM_INLINE mat3x2s glms_mat2x3_transpose(mat2x3s m); CGLM_INLINE mat2x3s glms_mat2x3_scale(mat2x3s m, float s); */ #ifndef cglms_mat2x3_h #define cglms_mat2x3_h #include "../common.h" #include "../types-struct.h" #include "../mat2x3.h" /* api definition */ #define glms_mat2x3_(NAME) CGLM_STRUCTAPI(mat2x3, NAME) #define GLMS_MAT2X3_ZERO_INIT {GLM_MAT2X3_ZERO_INIT} /* for C only */ #define GLMS_MAT2X3_ZERO ((mat2x3s)GLMS_MAT2X3_ZERO_INIT) /*! * @brief make given matrix zero. * * @param[in, out] mat matrix */ CGLM_INLINE mat2x3s glms_mat2x3_(zero)(void) { mat2x3s r; glm_mat2x3_zero(r.raw); return r; } /*! * @brief Create mat2x3 matrix from pointer * * @param[in] src pointer to an array of floats * @return constructed matrix from raw pointer */ CGLM_INLINE mat2x3s glms_mat2x3_(make)(const float * __restrict src) { mat2x3s r; glm_mat2x3_make(src, r.raw); return r; } /*! * @brief multiply m1 and m2 to dest * * @code * r = glms_mat2x3_mul(mat2x3s, mat3x2s); * @endcode * * @param[in] m1 left matrix (mat2x3s) * @param[in] m2 right matrix (mat3x2s) * @returns destination matrix (mat2s) */ CGLM_INLINE mat3s glms_mat2x3_(mul)(mat2x3s m1, mat3x2s m2) { mat3s r; glm_mat2x3_mul(m1.raw, m2.raw, r.raw); return r; } /*! * @brief multiply matrix with column vector and store in dest vector * * @param[in] m matrix (left) * @param[in] v vector (right, column vector) * @returns destination vector (vec3s) */ CGLM_INLINE vec3s glms_mat2x3_(mulv)(mat2x3s m, vec2s v) { vec3s r; glm_mat2x3_mulv(m.raw, v.raw, r.raw); return r; } /*! * @brief transpose matrix and store in dest * * @param[in] m matrix * @param[out] dest result */ CGLM_INLINE mat3x2s glms_mat2x3_(transpose)(mat2x3s m) { mat3x2s r; glm_mat2x3_transpose(m.raw, r.raw); return r; } /*! * @brief scale (multiply with scalar) matrix * * multiply matrix with scalar * * @param[in, out] m matrix * @param[in] s scalar */ CGLM_INLINE mat2x3s glms_mat2x3_(scale)(mat2x3s m, float s) { glm_mat2x3_scale(m.raw, s); return m; } #endif /* cglms_mat2x3_h */ cglm-0.9.6/include/cglm/struct/mat2x4.h000066400000000000000000000050401475344456400176500ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ /* Macros: GLMS_MAT2X4_ZERO_INIT GLMS_MAT2X4_ZERO Functions: CGLM_INLINE mat2x4s glms_mat2x4_zero(void); CGLM_INLINE mat2x4s glms_mat2x4_make(const float * __restrict src); CGLM_INLINE mat2s glms_mat2x4_mul(mat2x4s m1, mat4x2s m2); CGLM_INLINE vec4s glms_mat2x4_mulv(mat2x4s m, vec2s v); CGLM_INLINE mat4x2s glms_mat2x4_transpose(mat2x4s m); CGLM_INLINE mat2x4s glms_mat2x4_scale(mat2x4s m, float s); */ #ifndef cglms_mat2x4_h #define cglms_mat2x4_h #include "../common.h" #include "../types-struct.h" #include "../mat2x4.h" /* api definition */ #define glms_mat2x4_(NAME) CGLM_STRUCTAPI(mat2x4, NAME) #define GLMS_MAT2X4_ZERO_INIT {GLM_MAT2X4_ZERO_INIT} /* for C only */ #define GLMS_MAT2X4_ZERO ((mat2x4s)GLMS_MAT2X4_ZERO_INIT) /*! * @brief make given matrix zero. * * @param[in, out] mat matrix */ CGLM_INLINE mat2x4s glms_mat2x4_(zero)(void) { mat2x4s r; glm_mat2x4_zero(r.raw); return r; } /*! * @brief Create mat2x4 matrix from pointer * * @param[in] src pointer to an array of floats * @return constructed matrix from raw pointer */ CGLM_INLINE mat2x4s glms_mat2x4_(make)(const float * __restrict src) { mat2x4s r; glm_mat2x4_make(src, r.raw); return r; } /*! * @brief multiply m1 and m2 to dest * * @code * r = glms_mat2x4_mul(mat2x4s, mat4x2s); * @endcode * * @param[in] m1 left matrix (mat2x4s) * @param[in] m2 right matrix (mat4x2s) * @returns destination matrix (mat2s) */ CGLM_INLINE mat4s glms_mat2x4_(mul)(mat2x4s m1, mat4x2s m2) { mat4s r; glm_mat2x4_mul(m1.raw, m2.raw, r.raw); return r; } /*! * @brief multiply matrix with column vector and store in dest column vector * * @param[in] m matrix (left) * @param[in] v vector (right, column vector) * @param[out] dest result vector */ CGLM_INLINE vec4s glms_mat2x4_(mulv)(mat2x4s m, vec2s v) { vec4s r; glm_mat2x4_mulv(m.raw, v.raw, r.raw); return r; } /*! * @brief transpose matrix and store in dest * * @param[in] m matrix * @param[out] dest result */ CGLM_INLINE mat4x2s glms_mat2x4_(transpose)(mat2x4s m) { mat4x2s r; glm_mat2x4_transpose(m.raw, r.raw); return r; } /*! * @brief scale (multiply with scalar) matrix * * multiply matrix with scalar * * @param[in, out] m matrix * @param[in] s scalar */ CGLM_INLINE mat2x4s glms_mat2x4_(scale)(mat2x4s m, float s) { glm_mat2x4_scale(m.raw, s); return m; } #endif /* cglms_mat2x4_h */ cglm-0.9.6/include/cglm/struct/mat3.h000066400000000000000000000144721475344456400174060ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ /* Macros: GLMS_MAT3_IDENTITY_INIT GLMS_MAT3_ZERO_INIT GLMS_MAT3_IDENTITY GLMS_MAT3_ZERO Functions: CGLM_INLINE mat3s glms_mat3_copy(mat3s mat); CGLM_INLINE mat3s glms_mat3_identity(void); CGLM_INLINE void glms_mat3_identity_array(mat3s * __restrict mat, size_t count); CGLM_INLINE mat3s glms_mat3_zero(void); CGLM_INLINE mat3s glms_mat3_mul(mat3s m1, mat3s m2); CGLM_INLINE ma3s glms_mat3_transpose(mat3s m); CGLM_INLINE vec3s glms_mat3_mulv(mat3s m, vec3s v); CGLM_INLINE float glms_mat3_trace(mat3s m); CGLM_INLINE versor glms_mat3_quat(mat3s m); CGLM_INLINE mat3s glms_mat3_scale(mat3s m, float s); CGLM_INLINE float glms_mat3_det(mat3s mat); CGLM_INLINE mat3s glms_mat3_inv(mat3s mat); CGLM_INLINE mat3s glms_mat3_swap_col(mat3s mat, int col1, int col2); CGLM_INLINE mat3s glms_mat3_swap_row(mat3s mat, int row1, int row2); CGLM_INLINE float glms_mat3_rmc(vec3s r, mat3s m, vec3s c); CGLM_INLINE mat3s glms_mat3_make(const float * __restrict src); */ #ifndef cglms_mat3s_h #define cglms_mat3s_h #include "../common.h" #include "../types-struct.h" #include "../mat3.h" #include "vec3.h" /* api definition */ #define glms_mat3_(NAME) CGLM_STRUCTAPI(mat3, NAME) #define GLMS_MAT3_IDENTITY_INIT {GLM_MAT3_IDENTITY_INIT} #define GLMS_MAT3_ZERO_INIT {GLM_MAT3_ZERO_INIT} /* for C only */ #define GLMS_MAT3_IDENTITY ((mat3s)GLMS_MAT3_IDENTITY_INIT) #define GLMS_MAT3_ZERO ((mat3s)GLMS_MAT3_ZERO_INIT) /*! * @brief copy all members of [mat] to [dest] * * @param[in] mat source * @returns destination */ CGLM_INLINE mat3s glms_mat3_(copy)(mat3s mat) { mat3s r; glm_mat3_copy(mat.raw, r.raw); return r; } /*! * @brief make given matrix identity. It is identical with below, * but it is more easy to do that with this func especially for members * e.g. glm_mat3_identity(aStruct->aMatrix); * * @code * glm_mat3_copy(GLM_MAT3_IDENTITY, mat); // C only * * // or * mat3 mat = GLM_MAT3_IDENTITY_INIT; * @endcode * * @returns destination */ CGLM_INLINE mat3s glms_mat3_(identity)(void) { mat3s r; glm_mat3_identity(r.raw); return r; } /*! * @brief make given matrix array's each element identity matrix * * @param[in, out] mat matrix array (must be aligned (16/32) * if alignment is not disabled) * * @param[in] count count of matrices */ CGLM_INLINE void glms_mat3_(identity_array)(mat3s * __restrict mat, size_t count) { CGLM_ALIGN_MAT mat3s t = GLMS_MAT3_IDENTITY_INIT; size_t i; for (i = 0; i < count; i++) { glm_mat3_copy(t.raw, mat[i].raw); } } /*! * @brief make given matrix zero. * * @returns matrix */ CGLM_INLINE mat3s glms_mat3_(zero)(void) { mat3s r; glm_mat3_zero(r.raw); return r; } /*! * @brief multiply m1 and m2 to dest * * m1, m2 and dest matrices can be same matrix, it is possible to write this: * * @code * mat3 m = GLM_MAT3_IDENTITY_INIT; * r = glms_mat3_mul(m, m); * @endcode * * @param[in] m1 left matrix * @param[in] m2 right matrix * @returns destination matrix */ CGLM_INLINE mat3s glms_mat3_(mul)(mat3s m1, mat3s m2) { mat3s r; glm_mat3_mul(m1.raw, m2.raw, r.raw); return r; } /*! * @brief transpose mat3 and store result in same matrix * * @param[in, out] m source and dest */ CGLM_INLINE mat3s glms_mat3_(transpose)(mat3s m) { glm_mat3_transpose(m.raw); return m; } /*! * @brief multiply mat3 with vec3 (column vector) and store in dest vector * * @param[in] m mat3 (left) * @param[in] v vec3 (right, column vector) * @returns vec3 (result, column vector) */ CGLM_INLINE vec3s glms_mat3_(mulv)(mat3s m, vec3s v) { vec3s r; glm_mat3_mulv(m.raw, v.raw, r.raw); return r; } /*! * @brief trace of matrix * * sum of the elements on the main diagonal from upper left to the lower right * * @param[in] m matrix */ CGLM_INLINE float glms_mat3_(trace)(mat3s m) { return glm_mat3_trace(m.raw); } /*! * @brief convert mat3 to quaternion * * @param[in] m rotation matrix * @returns destination quaternion */ CGLM_INLINE versors glms_mat3_(quat)(mat3s m) { versors r; glm_mat3_quat(m.raw, r.raw); return r; } /*! * @brief scale (multiply with scalar) matrix * * multiply matrix with scalar * * @param[in] m matrix * @param[in] s scalar * @returns scaled matrix */ CGLM_INLINE mat3s glms_mat3_(scale)(mat3s m, float s) { glm_mat3_scale(m.raw, s); return m; } /*! * @brief mat3 determinant * * @param[in] mat matrix * * @return determinant */ CGLM_INLINE float glms_mat3_(det)(mat3s mat) { return glm_mat3_det(mat.raw); } /*! * @brief inverse mat3 and store in dest * * @param[in] mat matrix * @returns inverse matrix */ CGLM_INLINE mat3s glms_mat3_(inv)(mat3s mat) { mat3s r; glm_mat3_inv(mat.raw, r.raw); return r; } /*! * @brief swap two matrix columns * * @param[in] mat matrix * @param[in] col1 col1 * @param[in] col2 col2 * @returns matrix */ CGLM_INLINE mat3s glms_mat3_(swap_col)(mat3s mat, int col1, int col2) { glm_mat3_swap_col(mat.raw, col1, col2); return mat; } /*! * @brief swap two matrix rows * * @param[in] mat matrix * @param[in] row1 row1 * @param[in] row2 row2 * @returns matrix */ CGLM_INLINE mat3s glms_mat3_(swap_row)(mat3s mat, int row1, int row2) { glm_mat3_swap_row(mat.raw, row1, row2); return mat; } /*! * @brief helper for R (row vector) * M (matrix) * C (column vector) * * rmc stands for Row * Matrix * Column * * the result is scalar because R * M = Matrix1x3 (row vector), * then Matrix1x3 * Vec3 (column vector) = Matrix1x1 (Scalar) * * @param[in] r row vector or matrix1x3 * @param[in] m matrix3x3 * @param[in] c column vector or matrix3x1 * * @return scalar value e.g. Matrix1x1 */ CGLM_INLINE float glms_mat3_(rmc)(vec3s r, mat3s m, vec3s c) { return glm_mat3_rmc(r.raw, m.raw, c.raw); } /*! * @brief Create mat3 matrix from pointer * * @param[in] src pointer to an array of floats * @return constructed matrix from raw pointer */ CGLM_INLINE mat3s glms_mat3_(make)(const float * __restrict src) { mat3s r; glm_mat3_make(src, r.raw); return r; } #endif /* cglms_mat3s_h */ cglm-0.9.6/include/cglm/struct/mat3x2.h000066400000000000000000000050311475344456400176470ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ /* Macros: GLMS_MAT3X2_ZERO_INIT GLMS_MAT3X2_ZERO Functions: CGLM_INLINE mat3x2s glms_mat3x2_zero(void); CGLM_INLINE mat3x2s glms_mat3x2_make(const float * __restrict src); CGLM_INLINE mat2s glms_mat3x2_mul(mat3x2s m1, mat2x3s m2); CGLM_INLINE vec2s glms_mat3x2_mulv(mat3x2s m, vec3s v); CGLM_INLINE mat2x3s glms_mat3x2_transpose(mat3x2s m); CGLM_INLINE mat3x2s glms_mat3x2_scale(mat3x2s m, float s); */ #ifndef cglms_mat3x2_h #define cglms_mat3x2_h #include "../common.h" #include "../types-struct.h" #include "../mat3x2.h" /* api definition */ #define glms_mat3x2_(NAME) CGLM_STRUCTAPI(mat3x2, NAME) #define GLMS_MAT3X2_ZERO_INIT {GLM_MAT3X2_ZERO_INIT} /* for C only */ #define GLMS_MAT3X2_ZERO ((mat3x2s)GLMS_MAT3X2_ZERO_INIT) /*! * @brief make given matrix zero. * * @param[in, out] mat matrix */ CGLM_INLINE mat3x2s glms_mat3x2_(zero)(void) { mat3x2s r; glm_mat3x2_zero(r.raw); return r; } /*! * @brief Create mat3x2 matrix from pointer * * @param[in] src pointer to an array of floats * @return constructed matrix from raw pointer */ CGLM_INLINE mat3x2s glms_mat3x2_(make)(const float * __restrict src) { mat3x2s r; glm_mat3x2_make(src, r.raw); return r; } /*! * @brief multiply m1 and m2 to dest * * @code * r = glms_mat3x2_mul(mat3x2s, mat2x3s); * @endcode * * @param[in] m1 left matrix (mat3x2s) * @param[in] m2 right matrix (mat2x3s) * @returns destination matrix (mat3s) */ CGLM_INLINE mat2s glms_mat3x2_(mul)(mat3x2s m1, mat2x3s m2) { mat2s r; glm_mat3x2_mul(m1.raw, m2.raw, r.raw); return r; } /*! * @brief multiply matrix with column vector and store in dest vector * * @param[in] m matrix (left) * @param[in] v vector (right, column vector) * @param[out] dest result vector */ CGLM_INLINE vec2s glms_mat3x2_(mulv)(mat3x2s m, vec3s v) { vec2s r; glm_mat3x2_mulv(m.raw, v.raw, r.raw); return r; } /*! * @brief transpose matrix and store in dest * * @param[in] m matrix * @param[out] dest result */ CGLM_INLINE mat2x3s glms_mat3x2_(transpose)(mat3x2s m) { mat2x3s r; glm_mat3x2_transpose(m.raw, r.raw); return r; } /*! * @brief scale (multiply with scalar) matrix * * multiply matrix with scalar * * @param[in, out] m matrix * @param[in] s scalar */ CGLM_INLINE mat3x2s glms_mat3x2_(scale)(mat3x2s m, float s) { glm_mat3x2_scale(m.raw, s); return m; } #endif /* cglms_mat3x2_h */ cglm-0.9.6/include/cglm/struct/mat3x4.h000066400000000000000000000050451475344456400176560ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ /* Macros: GLMS_MAT3X4_ZERO_INIT GLMS_MAT3X4_ZERO Functions: CGLM_INLINE mat3x4s glms_mat3x4_zero(void); CGLM_INLINE mat3x4s glms_mat3x4_make(const float * __restrict src); CGLM_INLINE mat4s glms_mat3x4_mul(mat3x4s m1, mat4x3s m2); CGLM_INLINE vec4s glms_mat3x4_mulv(mat3x4s m, vec3s v); CGLM_INLINE mat4x3s glms_mat3x4_transpose(mat3x4s m); CGLM_INLINE mat3x4s glms_mat3x4_scale(mat3x4s m, float s); */ #ifndef cglms_mat3x4_h #define cglms_mat3x4_h #include "../common.h" #include "../types-struct.h" #include "../mat3x4.h" /* api definition */ #define glms_mat3x4_(NAME) CGLM_STRUCTAPI(mat3x4, NAME) #define GLMS_MAT3X4_ZERO_INIT {GLM_MAT3X4_ZERO_INIT} /* for C only */ #define GLMS_MAT3X4_ZERO ((mat3x4s)GLMS_MAT3X4_ZERO_INIT) /*! * @brief make given matrix zero. * * @param[in, out] mat matrix */ CGLM_INLINE mat3x4s glms_mat3x4_(zero)(void) { mat3x4s r; glm_mat3x4_zero(r.raw); return r; } /*! * @brief Create mat3x4 matrix from pointer * * @param[in] src pointer to an array of floats * @return constructed matrix from raw pointer */ CGLM_INLINE mat3x4s glms_mat3x4_(make)(const float * __restrict src) { mat3x4s r; glm_mat3x4_make(src, r.raw); return r; } /*! * @brief multiply m1 and m2 to dest * * @code * r = glms_mat3x4_mul(mat3x4s, mat4x3s); * @endcode * * @param[in] m1 left matrix (mat3x4s) * @param[in] m2 right matrix (mat4x3s) * @returns destination matrix (mat4s) */ CGLM_INLINE mat4s glms_mat3x4_(mul)(mat3x4s m1, mat4x3s m2) { mat4s r; glm_mat3x4_mul(m1.raw, m2.raw, r.raw); return r; } /*! * @brief multiply matrix with column vector and store in dest column vector * * @param[in] m matrix (left) * @param[in] v vector (right, column vector) * @returns destination vector (vec4s) */ CGLM_INLINE vec4s glms_mat3x4_(mulv)(mat3x4s m, vec3s v) { vec4s r; glm_mat3x4_mulv(m.raw, v.raw, r.raw); return r; } /*! * @brief transpose matrix and store in dest * * @param[in] m matrix * @param[out] dest result */ CGLM_INLINE mat4x3s glms_mat3x4_(transpose)(mat3x4s m) { mat4x3s r; glm_mat3x4_transpose(m.raw, r.raw); return r; } /*! * @brief scale (multiply with scalar) matrix * * multiply matrix with scalar * * @param[in, out] m matrix * @param[in] s scalar */ CGLM_INLINE mat3x4s glms_mat3x4_(scale)(mat3x4s m, float s) { glm_mat3x4_scale(m.raw, s); return m; } #endif /* cglms_mat3x4_h */ cglm-0.9.6/include/cglm/struct/mat4.h000066400000000000000000000243421475344456400174040ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ /*! * Most of functions in this header are optimized manually with SIMD * if available. You dont need to call/incude SIMD headers manually */ /* Macros: GLMS_MAT4_IDENTITY_INIT GLMS_MAT4_ZERO_INIT GLMS_MAT4_IDENTITY GLMS_MAT4_ZERO Functions: CGLM_INLINE mat4s glms_mat4_ucopy(mat4s mat); CGLM_INLINE mat4s glms_mat4_copy(mat4s mat); CGLM_INLINE mat4s glms_mat4_identity(void); CGLM_INLINE void glms_mat4_identity_array(mat4s * __restrict mat, size_t count); CGLM_INLINE mat4s glms_mat4_zero(void); CGLM_INLINE mat3s glms_mat4_pick3(mat4s mat); CGLM_INLINE mat3s glms_mat4_pick3t(mat4s 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_mulN(mat4s * __restrict matrices[], uint32_t len); CGLM_INLINE vec4s glms_mat4_mulv(mat4s m, vec4s v); CGLM_INLINE float glms_mat4_trace(mat4s m); CGLM_INLINE float glms_mat4_trace3(mat4s m); CGLM_INLINE versors glms_mat4_quat(mat4s m); CGLM_INLINE vec3s glms_mat4_mulv3(mat4s m, vec3s v, float last); CGLM_INLINE mat4s glms_mat4_transpose(mat4s m); CGLM_INLINE mat4s glms_mat4_scale_p(mat4s m, float s); CGLM_INLINE mat4s glms_mat4_scale(mat4s m, float s); CGLM_INLINE float glms_mat4_det(mat4s mat); CGLM_INLINE mat4s glms_mat4_inv(mat4s mat); CGLM_INLINE mat4s glms_mat4_inv_fast(mat4s mat); CGLM_INLINE mat4s glms_mat4_swap_col(mat4s mat, int col1, int col2); CGLM_INLINE mat4s glms_mat4_swap_row(mat4s mat, int row1, int row2); CGLM_INLINE float glms_mat4_rmc(vec4s r, mat4s m, vec4s c); CGLM_INLINE mat4s glms_mat4_make(const float * __restrict src); */ #ifndef cglms_mat4s_h #define cglms_mat4s_h #include "../common.h" #include "../types-struct.h" #include "../mat4.h" #include "vec4.h" #include "vec3.h" /* api definition */ #define glms_mat4_(NAME) CGLM_STRUCTAPI(mat4, NAME) #define GLMS_MAT4_IDENTITY_INIT {GLM_MAT4_IDENTITY_INIT} #define GLMS_MAT4_ZERO_INIT {GLM_MAT4_ZERO_INIT} /* for C only */ #define GLMS_MAT4_IDENTITY ((mat4s)GLMS_MAT4_IDENTITY_INIT) #define GLMS_MAT4_ZERO ((mat4s)GLMS_MAT4_ZERO_INIT) /*! * @brief copy all members of [mat] to [dest] * * matrix may not be aligned, u stands for unaligned, this may be useful when * copying a matrix from external source e.g. asset importer... * * @param[in] mat source * @returns destination */ CGLM_INLINE mat4s glms_mat4_(ucopy)(mat4s mat) { mat4s r; glm_mat4_ucopy(mat.raw, r.raw); return r; } /*! * @brief copy all members of [mat] to [dest] * * @param[in] mat source * @returns destination */ CGLM_INLINE mat4s glms_mat4_(copy)(mat4s mat) { mat4s r; glm_mat4_copy(mat.raw, r.raw); return r; } /*! * @brief make given matrix identity. It is identical with below, * but it is more easy to do that with this func especially for members * e.g. glm_mat4_identity(aStruct->aMatrix); * * @code * glm_mat4_copy(GLM_MAT4_IDENTITY, mat); // C only * * // or * mat4 mat = GLM_MAT4_IDENTITY_INIT; * @endcode * * @returns destination */ CGLM_INLINE mat4s glms_mat4_(identity)(void) { mat4s r; glm_mat4_identity(r.raw); return r; } /*! * @brief make given matrix array's each element identity matrix * * @param[in, out] mat matrix array (must be aligned (16/32) * if alignment is not disabled) * * @param[in] count count of matrices */ CGLM_INLINE void glms_mat4_(identity_array)(mat4s * __restrict mat, size_t count) { CGLM_ALIGN_MAT mat4s t = GLMS_MAT4_IDENTITY_INIT; size_t i; for (i = 0; i < count; i++) { glm_mat4_copy(t.raw, mat[i].raw); } } /*! * @brief make given matrix zero. * * @returns matrix */ CGLM_INLINE mat4s glms_mat4_(zero)(void) { mat4s r; glm_mat4_zero(r.raw); return r; } /*! * @brief copy upper-left of mat4 to mat3 * * @param[in] mat source * @returns destination */ CGLM_INLINE mat3s glms_mat4_(pick3)(mat4s mat) { mat3s r; glm_mat4_pick3(mat.raw, r.raw); return r; } /*! * @brief copy upper-left of mat4 to mat3 (transposed) * * the postfix t stands for transpose * * @param[in] mat source * @returns destination */ CGLM_INLINE mat3s glms_mat4_(pick3t)(mat4s mat) { mat3s r; glm_mat4_pick3t(mat.raw, r.raw); return r; } /*! * @brief copy mat3 to mat4's upper-left * * @param[in] mat source * @param[in] dest destination * @returns destination */ CGLM_INLINE mat4s glms_mat4_(ins3)(mat3s mat, mat4s dest) { glm_mat4_ins3(mat.raw, dest.raw); return dest; } /*! * @brief multiply m1 and m2 to dest * * m1, m2 and dest matrices can be same matrix, it is possible to write this: * * @code * mat4 m = GLM_MAT4_IDENTITY_INIT; * r = glms_mat4_mul(m, m); * @endcode * * @param[in] m1 left matrix * @param[in] m2 right matrix * @returns destination matrix */ CGLM_INLINE mat4s glms_mat4_(mul)(mat4s m1, mat4s m2) { mat4s r; glm_mat4_mul(m1.raw, m2.raw, r.raw); return r; } /*! * @brief mupliply N mat4 matrices and store result in dest * * this function lets you multiply multiple (more than two or more...) matrices *

multiplication will be done in loop, this may reduce instructions * size but if len is too small then compiler may unroll whole loop, * usage: * @code * mat m1, m2, m3, m4, res; * * res = glm_mat4_mulN((mat4 *[]){&m1, &m2, &m3, &m4}, 4); * @endcode * * @warning matrices parameter is pointer array not mat4 array! * * @param[in] matrices mat4 * array * @param[in] len matrices count * @returns result matrix */ CGLM_INLINE mat4s glms_mat4_(mulN)(mat4s * __restrict matrices[], uint32_t len) { CGLM_ALIGN_MAT mat4s r = GLMS_MAT4_IDENTITY_INIT; size_t i; for (i = 0; i < len; i++) { r = glms_mat4_(mul)(r, *matrices[i]); } return r; } /*! * @brief multiply mat4 with vec4 (column vector) and store in dest vector * * @param[in] m mat4 (left) * @param[in] v vec4 (right, column vector) * @returns vec4 (result, column vector) */ CGLM_INLINE vec4s glms_mat4_(mulv)(mat4s m, vec4s v) { vec4s r; glm_mat4_mulv(m.raw, v.raw, r.raw); return r; } /*! * @brief trace of matrix * * sum of the elements on the main diagonal from upper left to the lower right * * @param[in] m matrix */ CGLM_INLINE float glms_mat4_(trace)(mat4s m) { return glm_mat4_trace(m.raw); } /*! * @brief trace of matrix (rotation part) * * sum of the elements on the main diagonal from upper left to the lower right * * @param[in] m matrix */ CGLM_INLINE float glms_mat4_(trace3)(mat4s m) { return glm_mat4_trace3(m.raw); } /*! * @brief convert mat4's rotation part to quaternion * * @param[in] m affine matrix * @returns destination quaternion */ CGLM_INLINE versors glms_mat4_(quat)(mat4s m) { versors r; glm_mat4_quat(m.raw, r.raw); return r; } /*! * @brief multiply vector with mat4 * * @param[in] m mat4(affine transform) * @param[in] v vec3 * @param[in] last 4th item to make it vec4 * @returns result vector (vec3) */ CGLM_INLINE vec3s glms_mat4_(mulv3)(mat4s m, vec3s v, float last) { vec3s r; glm_mat4_mulv3(m.raw, v.raw, last, r.raw); return r; } /*! * @brief transpose mat4 and store result in same matrix * * @param[in] m source * @returns result */ CGLM_INLINE mat4s glms_mat4_(transpose)(mat4s m) { glm_mat4_transpose(m.raw); return m; } /*! * @brief scale (multiply with scalar) matrix without simd optimization * * multiply matrix with scalar * * @param[in] m matrix * @param[in] s scalar * @returns matrix */ CGLM_INLINE mat4s glms_mat4_(scale_p)(mat4s m, float s) { glm_mat4_scale_p(m.raw, s); return m; } /*! * @brief scale (multiply with scalar) matrix * * multiply matrix with scalar * * @param[in] m matrix * @param[in] s scalar * @returns matrix */ CGLM_INLINE mat4s glms_mat4_(scale)(mat4s m, float s) { glm_mat4_scale(m.raw, s); return m; } /*! * @brief mat4 determinant * * @param[in] mat matrix * * @return determinant */ CGLM_INLINE float glms_mat4_(det)(mat4s mat) { return glm_mat4_det(mat.raw); } /*! * @brief inverse mat4 and store in dest * * @param[in] mat matrix * @returns inverse matrix */ CGLM_INLINE mat4s glms_mat4_(inv)(mat4s mat) { mat4s r; glm_mat4_inv(mat.raw, r.raw); return r; } /*! * @brief inverse mat4 and store in dest * * this func uses reciprocal approximation without extra corrections * e.g Newton-Raphson. this should work faster than normal, * to get more precise use glm_mat4_inv version. * * NOTE: You will lose precision, glm_mat4_inv is more accurate * * @param[in] mat matrix * @returns inverse matrix */ CGLM_INLINE mat4s glms_mat4_(inv_fast)(mat4s mat) { mat4s r; glm_mat4_inv_fast(mat.raw, r.raw); return r; } /*! * @brief swap two matrix columns * * @param[in] mat matrix * @param[in] col1 col1 * @param[in] col2 col2 * @returns matrix */ CGLM_INLINE mat4s glms_mat4_(swap_col)(mat4s mat, int col1, int col2) { glm_mat4_swap_col(mat.raw, col1, col2); return mat; } /*! * @brief swap two matrix rows * * @param[in] mat matrix * @param[in] row1 row1 * @param[in] row2 row2 * @returns matrix */ CGLM_INLINE mat4s glms_mat4_(swap_row)(mat4s mat, int row1, int row2) { glm_mat4_swap_row(mat.raw, row1, row2); return mat; } /*! * @brief helper for R (row vector) * M (matrix) * C (column vector) * * rmc stands for Row * Matrix * Column * * the result is scalar because R * M = Matrix1x4 (row vector), * then Matrix1x4 * Vec4 (column vector) = Matrix1x1 (Scalar) * * @param[in] r row vector or matrix1x4 * @param[in] m matrix4x4 * @param[in] c column vector or matrix4x1 * * @return scalar value e.g. B(s) */ CGLM_INLINE float glms_mat4_(rmc)(vec4s r, mat4s m, vec4s c) { return glm_mat4_rmc(r.raw, m.raw, c.raw); } /*! * @brief Create mat4 matrix from pointer * * @param[in] src pointer to an array of floats * @return constructed matrix from raw pointer */ CGLM_INLINE mat4s glms_mat4_(make)(const float * __restrict src) { mat4s r; glm_mat4_make(src, r.raw); return r; } #endif /* cglms_mat4s_h */ cglm-0.9.6/include/cglm/struct/mat4x2.h000066400000000000000000000050461475344456400176560ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ /* Macros: GLMS_MAT4X2_ZERO_INIT GLMS_MAT4X2_ZERO Functions: CGLM_INLINE mat4x2s glms_mat4x2_zero(void); CGLM_INLINE mat4x2s glms_mat4x2_make(const float * __restrict src); CGLM_INLINE mat2s glms_mat4x2_mul(mat4x2s m1, mat2x4s m2); CGLM_INLINE vec2s glms_mat4x2_mulv(mat4x2s m, vec4s v); CGLM_INLINE mat2x4s glms_mat4x2_transpose(mat4x2s m); CGLM_INLINE mat4x2s glms_mat4x2_scale(mat4x2s m, float s); */ #ifndef cglms_mat4x2_h #define cglms_mat4x2_h #include "../common.h" #include "../types-struct.h" #include "../mat4x2.h" /* api definition */ #define glms_mat4x2_(NAME) CGLM_STRUCTAPI(mat4x2, NAME) #define GLMS_MAT4X2_ZERO_INIT {GLM_MAT4X2_ZERO_INIT} /* for C only */ #define GLMS_MAT4X2_ZERO ((mat4x2s)GLMS_MAT4X2_ZERO_INIT) /*! * @brief make given matrix zero. * * @param[in, out] mat matrix */ CGLM_INLINE mat4x2s glms_mat4x2_(zero)(void) { mat4x2s r; glm_mat4x2_zero(r.raw); return r; } /*! * @brief Create mat4x2 matrix from pointer * * @param[in] src pointer to an array of floats * @return constructed matrix from raw pointer */ CGLM_INLINE mat4x2s glms_mat4x2_(make)(const float * __restrict src) { mat4x2s r; glm_mat4x2_make(src, r.raw); return r; } /*! * @brief multiply m1 and m2 to dest * * @code * r = glms_mat4x2_mul(mat4x2s, mat2x4s); * @endcode * * @param[in] m1 left matrix (mat4x2s) * @param[in] m2 right matrix (mat2x4s) * @returns destination matrix (mat2s) */ CGLM_INLINE mat2s glms_mat4x2_(mul)(mat4x2s m1, mat2x4s m2) { mat2s r; glm_mat4x2_mul(m1.raw, m2.raw, r.raw); return r; } /*! * @brief multiply matrix with column vector and store in dest column vector * * @param[in] m matrix (left) * @param[in] v vector (right, column vector) * @returns destination vector (vec2s) */ CGLM_INLINE vec2s glms_mat4x2_(mulv)(mat4x2s m, vec4s v) { vec2s r; glm_mat4x2_mulv(m.raw, v.raw, r.raw); return r; } /*! * @brief transpose matrix and store in dest * * @param[in] m matrix * @param[out] dest result */ CGLM_INLINE mat2x4s glms_mat4x2_(transpose)(mat4x2s m) { mat2x4s r; glm_mat4x2_transpose(m.raw, r.raw); return r; } /*! * @brief scale (multiply with scalar) matrix * * multiply matrix with scalar * * @param[in, out] m matrix * @param[in] s scalar */ CGLM_INLINE mat4x2s glms_mat4x2_(scale)(mat4x2s m, float s) { glm_mat4x2_scale(m.raw, s); return m; } #endif /* cglms_mat4x2_h */ cglm-0.9.6/include/cglm/struct/mat4x3.h000066400000000000000000000050361475344456400176560ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ /* Macros: GLMS_MAT4X3_ZERO_INIT GLMS_MAT4X3_ZERO Functions: CGLM_INLINE mat4x3s glms_mat4x3_zero(void); CGLM_INLINE mat4x3s glms_mat4x3_make(const float * __restrict src); CGLM_INLINE mat3s glms_mat4x3_mul(mat4x3s m1, mat3x4s m2); CGLM_INLINE vec3s glms_mat4x3_mulv(mat4x3s m, vec4s v); CGLM_INLINE mat3x4s glms_mat4x3_transpose(mat4x3s m); CGLM_INLINE mat4x3s glms_mat4x3_scale(mat4x3s m, float s); */ #ifndef cglms_mat4x3_h #define cglms_mat4x3_h #include "../common.h" #include "../types-struct.h" #include "../mat4x3.h" /* api definition */ #define glms_mat4x3_(NAME) CGLM_STRUCTAPI(mat4x3, NAME) #define GLMS_MAT4X3_ZERO_INIT {GLM_MAT4X3_ZERO_INIT} /* for C only */ #define GLMS_MAT4X3_ZERO ((mat4x3s)GLMS_MAT4X3_ZERO_INIT) /*! * @brief make given matrix zero. * * @param[in, out] mat matrix */ CGLM_INLINE mat4x3s glms_mat4x3_(zero)(void) { mat4x3s r; glm_mat4x3_zero(r.raw); return r; } /*! * @brief Create mat4x3 matrix from pointer * * @param[in] src pointer to an array of floats * @return constructed matrix from raw pointer */ CGLM_INLINE mat4x3s glms_mat4x3_(make)(const float * __restrict src) { mat4x3s r; glm_mat4x3_make(src, r.raw); return r; } /*! * @brief multiply m1 and m2 to dest * * @code * r = glms_mat4x3_mul(mat4x3s, mat3x4s); * @endcode * * @param[in] m1 left matrix (mat4x3s) * @param[in] m2 right matrix (mat3x4s) * @returns destination matrix (mat3s) */ CGLM_INLINE mat3s glms_mat4x3_(mul)(mat4x3s m1, mat3x4s m2) { mat3s r; glm_mat4x3_mul(m1.raw, m2.raw, r.raw); return r; } /*! * @brief multiply matrix with column vector and store in dest vector * * @param[in] m matrix (left) * @param[in] v vector (right, column vector) * @returns destination vector (vec3s) */ CGLM_INLINE vec3s glms_mat4x3_(mulv)(mat4x3s m, vec4s v) { vec3s r; glm_mat4x3_mulv(m.raw, v.raw, r.raw); return r; } /*! * @brief transpose matrix and store in dest * * @param[in] m matrix * @param[out] dest result */ CGLM_INLINE mat3x4s glms_mat4x3_(transpose)(mat4x3s m) { mat3x4s r; glm_mat4x3_transpose(m.raw, r.raw); return r; } /*! * @brief scale (multiply with scalar) matrix * * multiply matrix with scalar * * @param[in, out] m matrix * @param[in] s scalar */ CGLM_INLINE mat4x3s glms_mat4x3_(scale)(mat4x3s m, float s) { glm_mat4x3_scale(m.raw, s); return m; } #endif /* cglms_mat4x3_h */ cglm-0.9.6/include/cglm/struct/noise.h000066400000000000000000000017561475344456400176600ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ #ifndef cglms_noises_h #define cglms_noises_h #include "../common.h" #include "../types-struct.h" #include "../noise.h" #include "vec4.h" /* Functions: CGLM_INLINE float glms_perlin_vec4(vec4s point); */ /*! * @brief Classic perlin noise * * @param[in] point 4D vector * @returns perlin noise value */ CGLM_INLINE float glms_perlin_vec4(vec4s point) { return glm_perlin_vec4(point.raw); } /*! * @brief Classic perlin noise * * @param[in] point 3D vector * @returns perlin noise value */ CGLM_INLINE float glms_perlin_vec3(vec3s point) { return glm_perlin_vec3(point.raw); } /*! * @brief Classic perlin noise * * @param[in] point 2D vector * @returns perlin noise value */ CGLM_INLINE float glms_perlin_vec2(vec2s point) { return glm_perlin_vec2(point.raw); } #endif /* cglms_noises_h */ cglm-0.9.6/include/cglm/struct/plane.h000066400000000000000000000013441475344456400176330ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ #ifndef cglms_planes_h #define cglms_planes_h #include "../common.h" #include "../types-struct.h" #include "../plane.h" #include "vec4.h" /* Plane equation: Ax + By + Cz + D = 0; It stored in vec4 as [A, B, C, D]. (A, B, C) is normal and D is distance */ /* Functions: CGLM_INLINE vec4s glms_plane_normalize(vec4s plane); */ /*! * @brief normalizes a plane * * @param[in] plane plane to normalize * @returns normalized plane */ CGLM_INLINE vec4s glms_plane_normalize(vec4s plane) { glm_plane_normalize(plane.raw); return plane; } #endif /* cglms_planes_h */ cglm-0.9.6/include/cglm/struct/project.h000066400000000000000000000104211475344456400201760ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ #ifndef cglms_projects_h #define cglms_projects_h #include "../common.h" #include "../types-struct.h" #include "../project.h" #include "vec3.h" #include "vec4.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] * the matrix should contain projection matrix. * * if you don't have ( and don't want to have ) an inverse matrix then use * glm_unproject version. You may use existing inverse of matrix in somewhere * else, this is why glm_unprojecti exists to save save inversion cost * * [1] space: * 1- if m = invProj: View Space * 2- if m = invViewProj: World Space * 3- if m = invMVP: Object Space * * You probably want to map the coordinates into object space * so use invMVP as m * * Computing viewProj: * glm_mat4_mul(proj, view, viewProj); * glm_mat4_mul(viewProj, model, MVP); * glm_mat4_inv(viewProj, invMVP); * * @param[in] pos point/position in viewport coordinates * @param[in] invMat matrix (see brief) * @param[in] vp viewport as [x, y, width, height] * @returns unprojected coordinates */ CGLM_INLINE vec3s glms_unprojecti(vec3s pos, mat4s invMat, vec4s vp) { vec3s r; glm_unprojecti(pos.raw, invMat.raw, vp.raw, r.raw); return r; } /*! * @brief maps the specified viewport coordinates into specified space [1] * the matrix should contain projection matrix. * * this is same as glm_unprojecti except this function get inverse matrix for * you. * * [1] space: * 1- if m = proj: View Space * 2- if m = viewProj: World Space * 3- if m = MVP: Object Space * * You probably want to map the coordinates into object space * so use MVP as m * * Computing viewProj and 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] pos point/position in viewport coordinates * @param[in] m matrix (see brief) * @param[in] vp viewport as [x, y, width, height] * @returns unprojected coordinates */ CGLM_INLINE vec3s glms_unproject(vec3s pos, mat4s m, vec4s vp) { vec3s r; glm_unproject(pos.raw, m.raw, vp.raw, r.raw); return r; } /*! * @brief map object coordinates 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] pos object coordinates * @param[in] m MVP matrix * @param[in] vp viewport as [x, y, width, height] * @returns projected coordinates */ CGLM_INLINE vec3s glms_project(vec3s pos, mat4s m, vec4s vp) { vec3s r; glm_project(pos.raw, m.raw, vp.raw, r.raw); 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 * * @param[in] center center [x, y] of a picking region in window coordinates * @param[in] size size [width, height] of the picking region in window coordinates * @param[in] vp viewport as [x, y, width, height] * @returns projected coordinates */ CGLM_INLINE mat4s glms_pickmatrix(vec2s center, vec2s size, vec4s vp) { mat4s res; glm_pickmatrix(center.raw, size.raw, vp.raw, res.raw); return res; } #endif /* cglms_projects_h */ cglm-0.9.6/include/cglm/struct/quat.h000066400000000000000000000330071475344456400175070ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ /* Macros: GLMS_QUAT_IDENTITY_INIT GLMS_QUAT_IDENTITY Functions: CGLM_INLINE versors glms_quat_identity(void) CGLM_INLINE void glms_quat_identity_array(versor *q, size_t count) CGLM_INLINE versors glms_quat_init(float x, float y, float z, float w) CGLM_INLINE versors glms_quatv(float angle, vec3s axis) CGLM_INLINE versors glms_quat(float angle, float x, float y, float z) CGLM_INLINE versors glms_quat_from_vecs(vec3s a, vec3s b) CGLM_INLINE float glms_quat_norm(versors q) CGLM_INLINE versors glms_quat_normalize(versors q) CGLM_INLINE float glms_quat_dot(versors p, versors q) CGLM_INLINE versors glms_quat_conjugate(versors q) CGLM_INLINE versors glms_quat_inv(versors q) CGLM_INLINE versors glms_quat_add(versors p, versors q) CGLM_INLINE versors glms_quat_sub(versors p, versors q) CGLM_INLINE vec3s glms_quat_imagn(versors q) CGLM_INLINE float glms_quat_imaglen(versors q) CGLM_INLINE float glms_quat_angle(versors q) CGLM_INLINE vec3s glms_quat_axis(versors q) CGLM_INLINE versors glms_quat_mul(versors p, versors q) CGLM_INLINE mat4s glms_quat_mat4(versors q) CGLM_INLINE mat4s glms_quat_mat4t(versors q) CGLM_INLINE mat3s glms_quat_mat3(versors q) CGLM_INLINE mat3s glms_quat_mat3t(versors q) CGLM_INLINE versors glms_quat_lerp(versors from, versors to, float t) CGLM_INLINE versors glms_quat_lerpc(versors from, versors to, float t) CGLM_INLINE versors glms_quat_nlerp(versors from, versors to, float t) CGLM_INLINE versors glms_quat_slerp(versors from, versors to, float t) CGLM_INLINE versors glms_quat_slerp_longest(versors from, versors to, float t) CGLM_INLINE mat4s. glms_quat_look(vec3s eye, versors ori) CGLM_INLINE versors glms_quat_for(vec3s dir, vec3s fwd, vec3s up) CGLM_INLINE versors glms_quat_forp(vec3s from, vec3s to, vec3s fwd, vec3s up) CGLM_INLINE vec3s glms_quat_rotatev(versors q, vec3s v) CGLM_INLINE mat4s glms_quat_rotate(mat4s m, versors q) CGLM_INLINE mat4s glms_quat_rotate_at(mat4s m, versors q, vec3s pivot) CGLM_INLINE mat4s glms_quat_rotate_atm(versors q, vec3s pivot) CGLM_INLINE versors glms_quat_make(float * restrict src) */ #ifndef cglms_quat_h #define cglms_quat_h #include "../common.h" #include "../types-struct.h" #include "../plane.h" #include "../quat.h" /* api definition */ #define glms_quat_(NAME) CGLM_STRUCTAPI(quat, NAME) /* * IMPORTANT: * ---------------------------------------------------------------------------- * cglm stores quat as [x, y, z, w] since v0.3.6 * * it was [w, x, y, z] before v0.3.6 it has been changed to [x, y, z, w] * with v0.3.6 version. * ---------------------------------------------------------------------------- */ #define GLMS_QUAT_IDENTITY_INIT {GLM_QUAT_IDENTITY_INIT} #define GLMS_QUAT_IDENTITY ((versors)GLMS_QUAT_IDENTITY_INIT) /*! * @brief makes given quat to identity * * @returns identity quaternion */ CGLM_INLINE versors glms_quat_(identity)(void) { versors dest; glm_quat_identity(dest.raw); return dest; } /*! * @brief make given quaternion array's each element identity quaternion * * @param[in, out] q quat array (must be aligned (16) * if alignment is not disabled) * * @param[in] count count of quaternions */ CGLM_INLINE void glms_quat_(identity_array)(versors * __restrict q, size_t count) { CGLM_ALIGN(16) versor v = GLM_QUAT_IDENTITY_INIT; size_t i; for (i = 0; i < count; i++) { glm_vec4_copy(v, q[i].raw); } } /*! * @brief inits quaternion with raw values * * @param[in] x x * @param[in] y y * @param[in] z z * @param[in] w w (real part) * @returns quaternion */ CGLM_INLINE versors glms_quat_(init)(float x, float y, float z, float w) { versors dest; glm_quat_init(dest.raw, x, y, z, w); return dest; } /*! * @brief creates NEW quaternion with axis vector * * @param[in] angle angle (radians) * @param[in] axis axis * @returns quaternion */ CGLM_INLINE versors glms_quatv(float angle, vec3s axis) { versors dest; glm_quatv(dest.raw, angle, axis.raw); return dest; } /*! * @brief creates NEW quaternion with individual axis components * * @param[in] angle angle (radians) * @param[in] x axis.x * @param[in] y axis.y * @param[in] z axis.z * @returns quaternion */ CGLM_INLINE versors glms_quat(float angle, float x, float y, float z) { versors dest; glm_quat(dest.raw, angle, x, y, z); return dest; } /*! * @brief compute quaternion rotating vector A to vector B * * @param[in] a vec3 (must have unit length) * @param[in] b vec3 (must have unit length) * @returns quaternion (of unit length) */ CGLM_INLINE versors glms_quat_(from_vecs)(vec3s a, vec3s b) { versors dest; glm_quat_from_vecs(a.raw, b.raw, dest.raw); return dest; } /*! * @brief returns norm (magnitude) of quaternion * * @param[in] q quaternion */ CGLM_INLINE float glms_quat_(norm)(versors q) { return glm_quat_norm(q.raw); } /*! * @brief normalize quaternion * * @param[in] q quaternion * @returns quaternion */ CGLM_INLINE versors glms_quat_(normalize)(versors q) { versors dest; glm_quat_normalize_to(q.raw, dest.raw); return dest; } /*! * @brief dot product of two quaternion * * @param[in] p quaternion 1 * @param[in] q quaternion 2 * @returns dot product */ CGLM_INLINE float glms_quat_(dot)(versors p, versors q) { return glm_quat_dot(p.raw, q.raw); } /*! * @brief conjugate of quaternion * * @param[in] q quaternion * @returns conjugate */ CGLM_INLINE versors glms_quat_(conjugate)(versors q) { versors dest; glm_quat_conjugate(q.raw, dest.raw); return dest; } /*! * @brief inverse of non-zero quaternion * * @param[in] q quaternion * @returns inverse quaternion */ CGLM_INLINE versors glms_quat_(inv)(versors q) { versors dest; glm_quat_inv(q.raw, dest.raw); return dest; } /*! * @brief add (componentwise) two quaternions and store result in dest * * @param[in] p quaternion 1 * @param[in] q quaternion 2 * @returns result quaternion */ CGLM_INLINE versors glms_quat_(add)(versors p, versors q) { versors dest; glm_quat_add(p.raw, q.raw, dest.raw); return dest; } /*! * @brief subtract (componentwise) two quaternions and store result in dest * * @param[in] p quaternion 1 * @param[in] q quaternion 2 * @returns result quaternion */ CGLM_INLINE versors glms_quat_(sub)(versors p, versors q) { versors dest; glm_quat_sub(p.raw, q.raw, dest.raw); return dest; } /*! * @brief returns normalized imaginary part of quaternion * * @param[in] q quaternion */ CGLM_INLINE vec3s glms_quat_(imagn)(versors q) { vec3s dest; glm_normalize_to(q.raw, dest.raw); return dest; } /*! * @brief returns length of imaginary part of quaternion * * @param[in] q quaternion */ CGLM_INLINE float glms_quat_(imaglen)(versors q) { return glm_quat_imaglen(q.raw); } /*! * @brief returns angle of quaternion * * @param[in] q quaternion */ CGLM_INLINE float glms_quat_(angle)(versors q) { return glm_quat_angle(q.raw); } /*! * @brief axis of quaternion * * @param[in] q quaternion * @returns axis of quaternion */ CGLM_INLINE vec3s glms_quat_(axis)(versors q) { vec3s dest; glm_quat_axis(q.raw, dest.raw); return dest; } /*! * @brief multiplies two quaternion and stores result in dest * this is also called Hamilton Product * * According to WikiPedia: * The product of two rotation quaternions [clarification needed] will be * equivalent to the rotation q followed by the rotation p * * @param[in] p quaternion 1 * @param[in] q quaternion 2 * @returns result quaternion */ CGLM_INLINE versors glms_quat_(mul)(versors p, versors q) { versors dest; glm_quat_mul(p.raw, q.raw, dest.raw); return dest; } /*! * @brief convert quaternion to mat4 * * @param[in] q quaternion * @returns result matrix */ CGLM_INLINE mat4s glms_quat_(mat4)(versors q) { mat4s dest; glm_quat_mat4(q.raw, dest.raw); return dest; } /*! * @brief convert quaternion to mat4 (transposed) * * @param[in] q quaternion * @returns result matrix as transposed */ CGLM_INLINE mat4s glms_quat_(mat4t)(versors q) { mat4s dest; glm_quat_mat4t(q.raw, dest.raw); return dest; } /*! * @brief convert quaternion to mat3 * * @param[in] q quaternion * @returns result matrix */ CGLM_INLINE mat3s glms_quat_(mat3)(versors q) { mat3s dest; glm_quat_mat3(q.raw, dest.raw); return dest; } /*! * @brief convert quaternion to mat3 (transposed) * * @param[in] q quaternion * @returns result matrix */ CGLM_INLINE mat3s glms_quat_(mat3t)(versors q) { mat3s dest; glm_quat_mat3t(q.raw, dest.raw); return dest; } /*! * @brief interpolates between two quaternions * using linear interpolation (LERP) * * @param[in] from from * @param[in] to to * @param[in] t interpolant (amount) * @returns result quaternion */ CGLM_INLINE versors glms_quat_(lerp)(versors from, versors to, float t) { versors dest; glm_quat_lerp(from.raw, to.raw, t, dest.raw); return dest; } /*! * @brief interpolates between two quaternions * using linear interpolation (LERP) * * @param[in] from from * @param[in] to to * @param[in] t interpolant (amount) clamped between 0 and 1 * @returns result quaternion */ CGLM_INLINE versors glms_quat_(lerpc)(versors from, versors to, float t) { versors dest; glm_quat_lerpc(from.raw, to.raw, t, dest.raw); return dest; } /*! * @brief interpolates between two quaternions * taking the shortest rotation path using * normalized linear interpolation (NLERP) * * @param[in] from from * @param[in] to to * @param[in] t interpolant (amount) * @returns result quaternion */ CGLM_INLINE versors glms_quat_(nlerp)(versors from, versors to, float t) { versors dest; glm_quat_nlerp(from.raw, to.raw, t, dest.raw); return dest; } /*! * @brief interpolates between two quaternions * using spherical linear interpolation (SLERP) * * @param[in] from from * @param[in] to to * @param[in] t amount * @returns result quaternion */ CGLM_INLINE versors glms_quat_(slerp)(versors from, versors to, float t) { versors dest; glm_quat_slerp(from.raw, to.raw, t, dest.raw); return dest; } /*! * @brief interpolates between two quaternions * using spherical linear interpolation (SLERP) and always takes the longest path * * @param[in] from from * @param[in] to to * @param[in] t amount * @returns result quaternion */ CGLM_INLINE versors glms_quat_(slerp_longest)(versors from, versors to, float t) { versors dest; glm_quat_slerp_longest(from.raw, to.raw, t, dest.raw); return dest; } /*! * @brief creates view matrix using quaternion as camera orientation * * @param[in] eye eye * @param[in] ori orientation in world space as quaternion * @returns view matrix */ CGLM_INLINE mat4s glms_quat_(look)(vec3s eye, versors ori) { mat4s dest; glm_quat_look(eye.raw, ori.raw, dest.raw); return dest; } /*! * @brief creates look rotation quaternion * * @param[in] dir direction to look * @param[in] up up vector * @returns destination quaternion */ CGLM_INLINE versors glms_quat_(for)(vec3s dir, vec3s up) { versors dest; glm_quat_for(dir.raw, up.raw, dest.raw); return dest; } /*! * @brief creates look rotation quaternion using source and * destination positions p suffix stands for position * * @param[in] from source point * @param[in] to destination point * @param[in] up up vector * @returns destination quaternion */ CGLM_INLINE versors glms_quat_(forp)(vec3s from, vec3s to, vec3s up) { versors dest; glm_quat_forp(from.raw, to.raw, up.raw, dest.raw); return dest; } /*! * @brief rotate vector using using quaternion * * @param[in] q quaternion * @param[in] v vector to rotate * @returns rotated vector */ CGLM_INLINE vec3s glms_quat_(rotatev)(versors q, vec3s v) { vec3s dest; glm_quat_rotatev(q.raw, v.raw, dest.raw); return dest; } /*! * @brief rotate existing transform matrix using quaternion * * @param[in] m existing transform matrix * @param[in] q quaternion * @returns rotated matrix/transform */ CGLM_INLINE mat4s glms_quat_(rotate)(mat4s m, versors q) { glm_quat_rotate(m.raw, q.raw, m.raw); return m; } /*! * @brief rotate existing transform matrix using quaternion at pivot point * * @param[in, out] m existing transform matrix * @param[in] q quaternion * @returns pivot */ CGLM_INLINE mat4s glms_quat_(rotate_at)(mat4s m, versors q, vec3s pivot) { glm_quat_rotate_at(m.raw, q.raw, pivot.raw); return m; } /*! * @brief rotate NEW transform matrix using quaternion at pivot point * * this creates rotation matrix, it assumes you don't have a matrix * * this should work faster than glm_quat_rotate_at because it reduces * one glm_translate. * * @param[in] q quaternion * @returns pivot */ CGLM_INLINE mat4s glms_quat_(rotate_atm)(versors q, vec3s pivot) { mat4s dest; glm_quat_rotate_atm(dest.raw, q.raw, pivot.raw); return dest; } /*! * @brief Create CGLM quaternion from pointer * * @param[in] src pointer to an array of floats * @returns constructed quaternion from raw pointer */ CGLM_INLINE versors glms_quat_(make)(const float * __restrict src) { versors dest; glm_quat_make(src, dest.raw); return dest; } #endif /* cglms_quat_h */ cglm-0.9.6/include/cglm/struct/ray.h000066400000000000000000000047141475344456400173330ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ #ifndef cglms_ray_h #define cglms_ray_h #include "../common.h" #include "../types-struct.h" #include "../ray.h" /* api definition */ #define glms_ray_(NAME) CGLM_STRUCTAPI(ray, NAME) /*! * @brief Möller–Trumbore ray-triangle intersection algorithm * * @param[in] origin origin of ray * @param[in] direction direction of ray * @param[in] v0 first vertex of triangle * @param[in] v1 second vertex of triangle * @param[in] v2 third vertex of triangle * @param[in, out] d distance to intersection * @return whether there is intersection */ CGLM_INLINE bool glms_ray_(triangle)(vec3s origin, vec3s direction, vec3s v0, vec3s v1, vec3s v2, float *d) { return glm_ray_triangle(origin.raw, direction.raw, v0.raw, v1.raw, v2.raw, d); } /*! * @brief ray sphere intersection * * returns false if there is no intersection if true: * * - t1 > 0, t2 > 0: ray intersects the sphere at t1 and t2 both ahead of the origin * - t1 < 0, t2 > 0: ray starts inside the sphere, exits at t2 * - t1 < 0, t2 < 0: no intersection ahead of the ray ( returns false ) * - the caller can check if the intersection points (t1 and t2) fall within a * specific range (for example, tmin < t1, t2 < tmax) to determine if the * intersections are within a desired segment of the ray * * @param[in] origin ray origin * @param[out] dir normalized ray direction * @param[in] s sphere [center.x, center.y, center.z, radii] * @param[in] t1 near point1 (closer to origin) * @param[in] t2 far point2 (farther from origin) * * @returns whether there is intersection */ CGLM_INLINE bool glms_ray_(sphere)(vec3s origin, vec3s dir, vec4s s, float * __restrict t1, float * __restrict t2) { return glm_ray_sphere(origin.raw, dir.raw, s.raw, t1, t2); } /*! * @brief point using t by 𝐏(𝑡)=𝐀+𝑡𝐛 * * @param[in] orig origin of ray * @param[in] dir direction of ray * @param[in] t parameter * @returns point point at t */ CGLM_INLINE vec3s glms_ray_(at)(vec3s orig, vec3s dir, float t) { vec3s r; glm_ray_at(orig.raw, dir.raw, t, r.raw); return r; } #endif /* cglms_ray_h */ cglm-0.9.6/include/cglm/struct/sphere.h000066400000000000000000000035311475344456400200220ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ #ifndef cglms_spheres_h #define cglms_spheres_h #include "../common.h" #include "../types-struct.h" #include "../sphere.h" #include "mat4.h" /* Sphere Representation in cglm: [center.x, center.y, center.z, radii] You could use this representation or you can convert it to vec4 before call any function */ /*! * @brief helper for getting sphere radius * * @param[in] s sphere * * @return returns radii */ CGLM_INLINE float glms_sphere_radii(vec4s s) { return glm_sphere_radii(s.raw); } /*! * @brief apply transform to sphere, it is just wrapper for glm_mat4_mulv3 * * @param[in] s sphere * @param[in] m transform matrix * @returns transformed sphere */ CGLM_INLINE vec4s glms_sphere_transform(vec4s s, mat4s m) { vec4s r; glm_sphere_transform(s.raw, m.raw, r.raw); return r; } /*! * @brief merges two spheres and creates a new one * * two sphere must be in same space, for instance if one in world space then * the other must be in world space too, not in local space. * * @param[in] s1 sphere 1 * @param[in] s2 sphere 2 * returns merged/extended sphere */ CGLM_INLINE vec4s glms_sphere_merge(vec4s s1, vec4s s2) { vec4s r; glm_sphere_merge(s1.raw, s2.raw, r.raw); return r; } /*! * @brief check if two sphere intersects * * @param[in] s1 sphere * @param[in] s2 other sphere */ CGLM_INLINE bool glms_sphere_sphere(vec4s s1, vec4s s2) { return glm_sphere_sphere(s1.raw, s2.raw); } /*! * @brief check if sphere intersects with point * * @param[in] s sphere * @param[in] point point */ CGLM_INLINE bool glms_sphere_point(vec4s s, vec3s point) { return glm_sphere_point(s.raw, point.raw); } #endif /* cglms_spheres_h */ cglm-0.9.6/include/cglm/struct/vec2-ext.h000066400000000000000000000151401475344456400201700ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ /*! * @brief SIMD like functions */ /* Functions: CGLM_INLINE vec2s glms_vec2_fill(float val) CGLM_INLINE bool glms_vec2_eq(vec2s v, float val) CGLM_INLINE bool glms_vec2_eq_eps(vec2s v, float val) CGLM_INLINE bool glms_vec2_eq_all(vec2s v) CGLM_INLINE bool glms_vec2_eqv(vec2s a, vec2s b) CGLM_INLINE bool glms_vec2_eqv_eps(vec2s a, vec2s b) CGLM_INLINE float glms_vec2_max(vec2s v) CGLM_INLINE float glms_vec2_min(vec2s v) CGLM_INLINE bool glms_vec2_isnan(vec2s v) CGLM_INLINE bool glms_vec2_isinf(vec2s v) CGLM_INLINE bool glms_vec2_isvalid(vec2s v) CGLM_INLINE vec2s glms_vec2_sign(vec2s v) CGLM_INLINE vec2s glms_vec2_abs(vec2s v) CGLM_INLINE vec2s glms_vec2_fract(vec2s v) CGLM_INLINE vec2s glms_vec2_floor(vec2s v) CGLM_INLINE vec2s glms_vec2_mods(vec2s v, float s) CGLM_INLINE vec2s glms_vec2_steps(float edge, vec2s v) CGLM_INLINE vec2s glms_vec2_stepr(vec2s edge, float v) CGLM_INLINE vec2s glms_vec2_sqrt(vec2s v) */ #ifndef cglms_vec2s_ext_h #define cglms_vec2s_ext_h #include "../common.h" #include "../types-struct.h" #include "../util.h" #include "../vec2-ext.h" /* api definition */ #define glms_vec2_(NAME) CGLM_STRUCTAPI(vec2, NAME) /*! * @brief fill a vector with specified value * * @param[in] val value * @returns dest */ CGLM_INLINE vec2s glms_vec2_(fill)(float val) { vec2s r; glm_vec2_fill(r.raw, val); return r; } /*! * @brief check if vector is equal to value (without epsilon) * * @param[in] v vector * @param[in] val value */ CGLM_INLINE bool glms_vec2_(eq)(vec2s v, float val) { return glm_vec2_eq(v.raw, val); } /*! * @brief check if vector is equal to value (with epsilon) * * @param[in] v vector * @param[in] val value */ CGLM_INLINE bool glms_vec2_(eq_eps)(vec2s v, float val) { return glm_vec2_eq_eps(v.raw, val); } /*! * @brief check if vector members are equal (without epsilon) * * @param[in] v vector */ CGLM_INLINE bool glms_vec2_(eq_all)(vec2s v) { return glm_vec2_eq_all(v.raw); } /*! * @brief check if vector is equal to another (without epsilon) * * @param[in] a vector * @param[in] b vector */ CGLM_INLINE bool glms_vec2_(eqv)(vec2s a, vec2s b) { return glm_vec2_eqv(a.raw, b.raw); } /*! * @brief check if vector is equal to another (with epsilon) * * @param[in] a vector * @param[in] b vector */ CGLM_INLINE bool glms_vec2_(eqv_eps)(vec2s a, vec2s b) { return glm_vec2_eqv_eps(a.raw, b.raw); } /*! * @brief max value of vector * * @param[in] v vector */ CGLM_INLINE float glms_vec2_(max)(vec2s v) { return glm_vec2_max(v.raw); } /*! * @brief min value of vector * * @param[in] v vector */ CGLM_INLINE float glms_vec2_min(vec2s v) { return glm_vec2_min(v.raw); } /*! * @brief check if one of items is NaN (not a number) * you should only use this in DEBUG mode or very critical asserts * * @param[in] v vector */ CGLM_INLINE bool glms_vec2_(isnan)(vec2s v) { return glm_vec2_isnan(v.raw); } /*! * @brief check if one of items is INFINITY * you should only use this in DEBUG mode or very critical asserts * * @param[in] v vector */ CGLM_INLINE bool glms_vec2_(isinf)(vec2s v) { return glm_vec2_isinf(v.raw); } /*! * @brief check if all items are valid number * you should only use this in DEBUG mode or very critical asserts * * @param[in] v vector */ CGLM_INLINE bool glms_vec2_isvalid(vec2s v) { return glm_vec2_isvalid(v.raw); } /*! * @brief get sign of 32 bit float as +1, -1, 0 * * Important: It returns 0 for zero/NaN input * * @param v vector * @returns sign vector */ CGLM_INLINE vec2s glms_vec2_(sign)(vec2s v) { vec2s r; glm_vec2_sign(v.raw, r.raw); return r; } /*! * @brief fractional part of each vector item * * @param v vector * @returns abs vector */ CGLM_INLINE vec2s glms_vec2_(abs)(vec2s v) { vec2s r; glm_vec2_abs(v.raw, r.raw); return r; } /*! * @brief fractional part of each vector item * * @param[in] v vector * @returns destination vector */ CGLM_INLINE vec2s glms_vec2_(fract)(vec2s v) { vec2s r; glm_vec2_fract(v.raw, r.raw); return r; } /*! * @brief floor of each vector item * * @param[in] v vector * @returns destination vector */ CGLM_INLINE vec2s glms_vec2_(floor)(vec2s v) { vec2s r; glm_vec2_floor(v.raw, r.raw); return r; } /*! * @brief mod of each vector item by scalar * * @param[in] v vector * @param[in] s scalar * @returns destination vector */ CGLM_INLINE vec2s glms_vec2_(mods)(vec2s v, float s) { vec2s r; glm_vec2_mods(v.raw, s, r.raw); return r; } /*! * @brief threshold each vector item with scalar * condition is: (x[i] < edge) ? 0.0 : 1.0 * * @param[in] edge threshold * @param[in] x vector to test against threshold * @returns destination */ CGLM_INLINE vec2s glms_vec2_(steps)(float edge, vec2s x) { vec2s r; glm_vec2_steps(edge, x.raw, r.raw); return r; } /*! * @brief threshold a value with *vector* as the threshold * condition is: (x < edge[i]) ? 0.0 : 1.0 * * @param[in] edge threshold vector * @param[in] x value to test against threshold * @returns destination */ CGLM_INLINE vec2s glms_vec2_(stepr)(vec2s edge, float x) { vec2s r; glm_vec2_stepr(edge.raw, x, r.raw); return r; } /*! * @brief square root of each vector item * * @param[in] v vector * @returns destination vector */ CGLM_INLINE vec2s glms_vec2_(sqrt)(vec2s v) { vec2s r; glm_vec2_sqrt(v.raw, r.raw); return r; } /*! * @brief treat vectors as complex numbers and multiply them as such. * * @param[in] a left number * @param[in] b right number * @param[out] dest destination number */ CGLM_INLINE vec2s glms_vec2_(complex_mul)(vec2s a, vec2s b, vec2s dest) { glm_vec2_complex_mul(a.raw, b.raw, dest.raw); return dest; } /*! * @brief treat vectors as complex numbers and divide them as such. * * @param[in] a left number (numerator) * @param[in] b right number (denominator) * @param[out] dest destination number */ CGLM_INLINE vec2s glms_vec2_(complex_div)(vec2s a, vec2s b, vec2s dest) { glm_vec2_complex_div(a.raw, b.raw, dest.raw); return dest; } /*! * @brief treat the vector as a complex number and conjugate it as such. * * @param[in] a the number * @param[out] dest destination number */ CGLM_INLINE vec2s glms_vec2_(complex_conjugate)(vec2s a, vec2s dest) { glm_vec2_complex_conjugate(a.raw, dest.raw); return dest; } #endif /* cglms_vec2s_ext_h */ cglm-0.9.6/include/cglm/struct/vec2.h000066400000000000000000000404231475344456400173740ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ /* Macros: GLMS_VEC2_ONE_INIT GLMS_VEC2_ZERO_INIT GLMS_VEC2_ONE GLMS_VEC2_ZERO Functions: CGLM_INLINE vec2s glms_vec2(vec3s v3) CGLM_INLINE void glms_vec2_pack(vec2s dst[], vec2 src[], size_t len) CGLM_INLINE void glms_vec2_unpack(vec2 dst[], vec2s src[], size_t len) CGLM_INLINE vec2s glms_vec2_zero(void) CGLM_INLINE vec2s glms_vec2_one(void) CGLM_INLINE float glms_vec2_dot(vec2s a, vec2s b) CGLM_INLINE float glms_vec2_cross(vec2s a, vec2s b) CGLM_INLINE float glms_vec2_norm2(vec2s v) CGLM_INLINE float glms_vec2_norm(vec2s v) CGLM_INLINE vec2s glms_vec2_add(vec2s a, vec2s b) CGLM_INLINE vec2s glms_vec2_adds(vec2s a, float s) CGLM_INLINE vec2s glms_vec2_sub(vec2s a, vec2s b) CGLM_INLINE vec2s glms_vec2_subs(vec2s a, float s) CGLM_INLINE vec2s glms_vec2_mul(vec2s a, vec2s b) CGLM_INLINE vec2s glms_vec2_scale(vec2s v, float s) CGLM_INLINE vec2s glms_vec2_scale_as(vec2s v, float s) CGLM_INLINE vec2s glms_vec2_div(vec2s a, vec2s b) CGLM_INLINE vec2s glms_vec2_divs(vec2s a, float s) CGLM_INLINE vec2s glms_vec2_addadd(vec2s a, vec2s b, vec2s dest) CGLM_INLINE vec2s glms_vec2_subadd(vec2s a, vec2s b, vec2s dest) CGLM_INLINE vec2s glms_vec2_muladd(vec2s a, vec2s b, 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_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_normalize(vec2s v) 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_distance2(vec2s a, vec2s b) CGLM_INLINE vec2s glms_vec2_maxv(vec2s a, vec2s b) CGLM_INLINE vec2s glms_vec2_minv(vec2s a, vec2s b) CGLM_INLINE vec2s glms_vec2_clamp(vec2s v, float minVal, float maxVal) CGLM_INLINE vec2s glms_vec2_lerp(vec2s from, vec2s to, float t) CGLM_INLINE vec2s glms_vec2_step(vec2s edge, vec2s x) CGLM_INLINE vec2s glms_vec2_make(float * restrict src) CGLM_INLINE vec2s glms_vec2_reflect(vec2s v, vec2s n) CGLM_INLINE bool glms_vec2_refract(vec2s v, vec2s n, float eta, vec2s *dest) */ #ifndef cglms_vec2s_h #define cglms_vec2s_h #include "../common.h" #include "../types-struct.h" #include "../util.h" #include "../vec2.h" #include "vec2-ext.h" #define GLMS_VEC2_ONE_INIT {GLM_VEC2_ONE_INIT} #define GLMS_VEC2_ZERO_INIT {GLM_VEC2_ZERO_INIT} #define GLMS_VEC2_ONE ((vec2s)GLMS_VEC2_ONE_INIT) #define GLMS_VEC2_ZERO ((vec2s)GLMS_VEC2_ZERO_INIT) /*! * @brief init vec2 using vec2 * * @param[in] v3 vector3 * @returns destination */ CGLM_INLINE vec2s glms_vec2(vec3s v3) { vec2s r; glm_vec2(v3.raw, r.raw); return r; } /*! * @brief pack an array of vec2 into an array of vec2s * * @param[out] dst array of vec2 * @param[in] src array of vec2s * @param[in] len number of elements */ CGLM_INLINE void glms_vec2_(pack)(vec2s dst[], vec2 src[], size_t len) { size_t i; for (i = 0; i < len; i++) { glm_vec2_copy(src[i], dst[i].raw); } } /*! * @brief unpack an array of vec2s into an array of vec2 * * @param[out] dst array of vec2s * @param[in] src array of vec2 * @param[in] len number of elements */ CGLM_INLINE void glms_vec2_(unpack)(vec2 dst[], vec2s src[], size_t len) { size_t i; for (i = 0; i < len; i++) { glm_vec2_copy(src[i].raw, dst[i]); } } /*! * @brief make vector zero * * @returns zero vector */ CGLM_INLINE vec2s glms_vec2_(zero)(void) { vec2s r; glm_vec2_zero(r.raw); return r; } /*! * @brief make vector one * * @returns one vector */ CGLM_INLINE vec2s glms_vec2_(one)(void) { vec2s r; glm_vec2_one(r.raw); return r; } /*! * @brief vec2 dot product * * @param[in] a vector1 * @param[in] b vector2 * * @return dot product */ CGLM_INLINE float glms_vec2_(dot)(vec2s a, vec2s b) { return glm_vec2_dot(a.raw, b.raw); } /*! * @brief vec2 cross product * * REF: http://allenchou.net/2013/07/cross-product-of-2d-vectors/ * * @param[in] a vector1 * @param[in] b vector2 * * @return Z component of cross product */ CGLM_INLINE float glms_vec2_(cross)(vec2s a, vec2s b) { return glm_vec2_cross(a.raw, b.raw); } /*! * @brief norm * norm (magnitude) of vec * * we can use this func instead of calling norm * norm, because it would call * sqrtf function twice but with this func we can avoid func call, maybe this is * not good name for this func * * @param[in] v vector * * @return norm * norm */ CGLM_INLINE float glms_vec2_(norm2)(vec2s v) { return glm_vec2_norm2(v.raw); } /*! * @brief norm (magnitude) of vec2 * * @param[in] v vector * * @return norm */ CGLM_INLINE float glms_vec2_(norm)(vec2s v) { return glm_vec2_norm(v.raw); } /*! * @brief add a vector to b vector store result in dest * * @param[in] a vector1 * @param[in] b vector2 * @returns destination vector */ CGLM_INLINE vec2s glms_vec2_(add)(vec2s a, vec2s b) { vec2s r; glm_vec2_add(a.raw, b.raw, r.raw); return r; } /*! * @brief add scalar to v vector store result in dest (d = v + s) * * @param[in] a vector * @param[in] s scalar * @returns destination vector */ CGLM_INLINE vec2s glms_vec2_(adds)(vec2s a, float s) { vec2s r; glm_vec2_adds(a.raw, s, r.raw); return r; } /*! * @brief subtract b vector from a vector store result in dest * * @param[in] a vector1 * @param[in] b vector2 * @returns destination vector */ CGLM_INLINE vec2s glms_vec2_(sub)(vec2s a, vec2s b) { vec2s r; glm_vec2_sub(a.raw, b.raw, r.raw); return r; } /*! * @brief subtract scalar from v vector store result in dest (d = v - s) * * @param[in] a vector * @param[in] s scalar * @returns destination vector */ CGLM_INLINE vec2s glms_vec2_(subs)(vec2s a, float s) { vec2s r; glm_vec2_subs(a.raw, s, r.raw); return r; } /*! * @brief multiply two vectors (component-wise multiplication) * * @param a vector1 * @param b vector2 * @returns result = (a[0] * b[0], a[1] * b[1]) */ CGLM_INLINE vec2s glms_vec2_(mul)(vec2s a, vec2s b) { vec2s r; glm_vec2_mul(a.raw, b.raw, r.raw); return r; } /*! * @brief multiply/scale vec2 vector with scalar: result = v * s * * @param[in] v vector * @param[in] s scalar * @returns destination vector */ CGLM_INLINE vec2s glms_vec2_(scale)(vec2s v, float s) { vec2s r; glm_vec2_scale(v.raw, s, r.raw); return r; } /*! * @brief make vec2 vector scale as specified: result = unit(v) * s * * @param[in] v vector * @param[in] s scalar * @returns destination vector */ CGLM_INLINE vec2s glms_vec2_(scale_as)(vec2s v, float s) { vec2s r; glm_vec2_scale_as(v.raw, s, r.raw); return r; } /*! * @brief div vector with another component-wise division: d = a / b * * @param[in] a vector 1 * @param[in] b vector 2 * @returns result = (a[0]/b[0], a[1]/b[1]) */ CGLM_INLINE vec2s glms_vec2_(div)(vec2s a, vec2s b) { vec2s r; glm_vec2_div(a.raw, b.raw, r.raw); return r; } /*! * @brief div vector with scalar: d = v / s * * @param[in] a vector * @param[in] s scalar * @returns result = (a[0]/s, a[1]/s) */ CGLM_INLINE vec2s glms_vec2_(divs)(vec2s a, float s) { vec2s r; glm_vec2_divs(a.raw, s, r.raw); return r; } /*! * @brief add two vectors and add result to sum * * 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_(addadd)(vec2s a, vec2s b, vec2s dest) { glm_vec2_addadd(a.raw, b.raw, dest.raw); return dest; } /*! * @brief sub two vectors and add 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_(subadd)(vec2s a, vec2s b, vec2s dest) { glm_vec2_subadd(a.raw, b.raw, dest.raw); return dest; } /*! * @brief mul two vectors and add 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_(muladd)(vec2s a, vec2s b, vec2s dest) { glm_vec2_muladd(a.raw, b.raw, dest.raw); return dest; } /*! * @brief mul vector with scalar and add result to sum * * 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_(muladds)(vec2s a, float s, vec2s dest) { glm_vec2_muladds(a.raw, s, dest.raw); return dest; } /*! * @brief add 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 * @returns dest += max(a, b) */ CGLM_INLINE vec2s glms_vec2_(maxadd)(vec2s a, vec2s b, vec2s dest) { glm_vec2_maxadd(a.raw, b.raw, dest.raw); return dest; } /*! * @brief add 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 * @returns dest += min(a, b) */ CGLM_INLINE vec2s glms_vec2_(minadd)(vec2s a, vec2s b, vec2s dest) { glm_vec2_minadd(a.raw, b.raw, dest.raw); 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 * * @param[in] v vector * @returns negated vector */ CGLM_INLINE vec2s glms_vec2_(negate)(vec2s v) { glm_vec2_negate(v.raw); return v; } /*! * @brief normalize vec2 and store result in same vec * * @param[in] v vector * @returns normalized vector */ CGLM_INLINE vec2s glms_vec2_(normalize)(vec2s v) { glm_vec2_normalize(v.raw); return v; } /*! * @brief rotate vec2 by angle using Rodrigues' rotation formula * * @param[in] v vector * @param[in] angle angle by radians * @returns rotated vector */ CGLM_INLINE vec2s glms_vec2_(rotate)(vec2s v, float angle) { vec2s r; glm_vec2_rotate(v.raw, angle, r.raw); 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 * * @param[in] a vector1 * @param[in] b vector2 * @return distance */ CGLM_INLINE float glms_vec2_(distance)(vec2s a, vec2s b) { return glm_vec2_distance(a.raw, b.raw); } /** * @brief squared distance between two vectors * * @param[in] a vector1 * @param[in] b vector2 * @return squared distance (distance * distance) */ CGLM_INLINE float glms_vec2_(distance2)(vec2s a, vec2s b) { return glm_vec2_distance2(a.raw, b.raw); } /*! * @brief max values of vectors * * @param[in] a vector1 * @param[in] b vector2 * @returns destination */ CGLM_INLINE vec2s glms_vec2_(maxv)(vec2s a, vec2s b) { vec2s r; glm_vec2_maxv(a.raw, b.raw, r.raw); return r; } /*! * @brief min values of vectors * * @param[in] a vector1 * @param[in] b vector2 * @returns destination */ CGLM_INLINE vec2s glms_vec2_(minv)(vec2s a, vec2s b) { vec2s r; glm_vec2_minv(a.raw, b.raw, r.raw); return r; } /*! * @brief clamp vector's individual members between min and max values * * @param[in] v vector * @param[in] minVal minimum value * @param[in] maxVal maximum value * @returns clamped vector */ CGLM_INLINE vec2s glms_vec2_(clamp)(vec2s v, float minVal, float maxVal) { glm_vec2_clamp(v.raw, minVal, maxVal); return v; } /*! * @brief linear interpolation between two vectors * * formula: from + s * (to - from) * * @param[in] from from value * @param[in] to to value * @param[in] t interpolant (amount) * @returns destination */ CGLM_INLINE vec2s glms_vec2_(lerp)(vec2s from, vec2s to, float t) { vec2s r; glm_vec2_lerp(from.raw, to.raw, t, r.raw); return r; } /*! * @brief threshold function * * @param[in] edge threshold * @param[in] x value to test against threshold * @returns destination */ CGLM_INLINE vec2s glms_vec2_(step)(vec2s edge, vec2s x) { vec2s r; glm_vec2_step(edge.raw, x.raw, r.raw); return r; } /*! * @brief Create two dimensional vector from pointer * * @param[in] src pointer to an array of floats * @returns constructed 2D vector from raw pointer */ CGLM_INLINE vec2s glms_vec2_(make)(const float * __restrict src) { vec2s dest; glm_vec2_make(src, dest.raw); return dest; } /*! * @brief reflection vector using an incident ray and a surface normal * * @param[in] I incident vector * @param[in] N normalized normal vector * @returns reflection result */ CGLM_INLINE vec2s glms_vec2_(reflect)(vec2s v, vec2s n) { vec2s dest; glm_vec2_reflect(v.raw, n.raw, dest.raw); return dest; } /*! * @brief computes refraction vector for an incident vector and a surface normal. * * calculates the refraction vector based on Snell's law. If total internal reflection * occurs (angle too great given eta), dest is set to zero and returns false. * Otherwise, computes refraction vector, stores it in dest, and returns true. * * @param[in] v normalized incident vector * @param[in] n normalized normal vector * @param[in] eta ratio of indices of refraction (incident/transmitted) * @param[out] dest refraction vector if refraction occurs; zero vector otherwise * * @returns true if refraction occurs; false if total internal reflection occurs. */ CGLM_INLINE bool glms_vec2_(refract)(vec2s v, vec2s n, float eta, vec2s * __restrict dest) { return glm_vec2_refract(v.raw, n.raw, eta, dest->raw); } #endif /* cglms_vec2s_h */ cglm-0.9.6/include/cglm/struct/vec3-ext.h000066400000000000000000000143601475344456400201740ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ /*! * @brief SIMD like functions */ /* Functions: CGLM_INLINE vec3s glms_vec3_broadcast(float val); CGLM_INLINE vec3s glms_vec3_fill(float val); CGLM_INLINE bool glms_vec3_eq(vec3s v, float val); CGLM_INLINE bool glms_vec3_eq_eps(vec3s v, float val); CGLM_INLINE bool glms_vec3_eq_all(vec3s v); CGLM_INLINE bool glms_vec3_eqv(vec3s a, vec3s b); CGLM_INLINE bool glms_vec3_eqv_eps(vec3s a, vec3s b); CGLM_INLINE float glms_vec3_max(vec3s v); CGLM_INLINE float glms_vec3_min(vec3s v); CGLM_INLINE bool glms_vec3_isnan(vec3s v); CGLM_INLINE bool glms_vec3_isinf(vec3s v); CGLM_INLINE bool glms_vec3_isvalid(vec3s v); CGLM_INLINE vec3s glms_vec3_sign(vec3s v); CGLM_INLINE vec3s glms_vec3_abs(vec3s v); CGLM_INLINE vec3s glms_vec3_fract(vec3s v); CGLM_INLINE vec3s glms_vec3_floor(vec3s v); CGLM_INLINE vec3s glms_vec3_mods(vec3s v, float s); CGLM_INLINE vec3s glms_vec3_steps(float edge, vec3s v); CGLM_INLINE vec3s glms_vec3_stepr(vec3s edge, float v); CGLM_INLINE float glms_vec3_hadd(vec3s v); CGLM_INLINE vec3s glms_vec3_sqrt(vec3s v); */ #ifndef cglms_vec3s_ext_h #define cglms_vec3s_ext_h #include "../common.h" #include "../types-struct.h" #include "../util.h" #include "../vec3-ext.h" /* api definition */ #define glms_vec3_(NAME) CGLM_STRUCTAPI(vec3, NAME) /*! * @brief fill a vector with specified value * * @param[in] val value * @returns dest */ CGLM_INLINE vec3s glms_vec3_(broadcast)(float val) { vec3s r; glm_vec3_broadcast(val, r.raw); return r; } /*! * @brief fill a vector with specified value * * @param[in] val value * @returns dest */ CGLM_INLINE vec3s glms_vec3_(fill)(float val) { vec3s r; glm_vec3_fill(r.raw, val); return r; } /*! * @brief check if vector is equal to value (without epsilon) * * @param[in] v vector * @param[in] val value */ CGLM_INLINE bool glms_vec3_(eq)(vec3s v, float val) { return glm_vec3_eq(v.raw, val); } /*! * @brief check if vector is equal to value (with epsilon) * * @param[in] v vector * @param[in] val value */ CGLM_INLINE bool glms_vec3_(eq_eps)(vec3s v, float val) { return glm_vec3_eq_eps(v.raw, val); } /*! * @brief check if vector members are equal (without epsilon) * * @param[in] v vector */ CGLM_INLINE bool glms_vec3_(eq_all)(vec3s v) { return glm_vec3_eq_all(v.raw); } /*! * @brief check if vector is equal to another (without epsilon) * * @param[in] a vector * @param[in] b vector */ CGLM_INLINE bool glms_vec3_(eqv)(vec3s a, vec3s b) { return glm_vec3_eqv(a.raw, b.raw); } /*! * @brief check if vector is equal to another (with epsilon) * * @param[in] a vector * @param[in] b vector */ CGLM_INLINE bool glms_vec3_(eqv_eps)(vec3s a, vec3s b) { return glm_vec3_eqv_eps(a.raw, b.raw); } /*! * @brief max value of vector * * @param[in] v vector */ CGLM_INLINE float glms_vec3_(max)(vec3s v) { return glm_vec3_max(v.raw); } /*! * @brief min value of vector * * @param[in] v vector */ CGLM_INLINE float glms_vec3_(min)(vec3s v) { return glm_vec3_min(v.raw); } /*! * @brief check if one of items is NaN (not a number) * you should only use this in DEBUG mode or very critical asserts * * @param[in] v vector */ CGLM_INLINE bool glms_vec3_(isnan)(vec3s v) { return glm_vec3_isnan(v.raw); } /*! * @brief check if one of items is INFINITY * you should only use this in DEBUG mode or very critical asserts * * @param[in] v vector */ CGLM_INLINE bool glms_vec3_(isinf)(vec3s v) { return glm_vec3_isinf(v.raw); } /*! * @brief check if all items are valid number * you should only use this in DEBUG mode or very critical asserts * * @param[in] v vector */ CGLM_INLINE bool glms_vec3_(isvalid)(vec3s v) { return glm_vec3_isvalid(v.raw); } /*! * @brief get sign of 32 bit float as +1, -1, 0 * * Important: It returns 0 for zero/NaN input * * @param v vector * @returns sign vector */ CGLM_INLINE vec3s glms_vec3_(sign)(vec3s v) { vec3s r; glm_vec3_sign(v.raw, r.raw); return r; } /*! * @brief absolute value of each vector item * * @param[in] v vector * @return destination vector */ CGLM_INLINE vec3s glms_vec3_(abs)(vec3s v) { vec3s r; glm_vec3_abs(v.raw, r.raw); return r; } /*! * @brief fractional part of each vector item * * @param[in] v vector * @return dest destination vector */ CGLM_INLINE vec3s glms_vec3_(fract)(vec3s v) { vec3s r; glm_vec3_fract(v.raw, r.raw); return r; } /*! * @brief floor of each vector item * * @param[in] v vector * @return dest destination vector */ CGLM_INLINE vec3s glms_vec3_(floor)(vec3s v) { vec3s r; glm_vec3_floor(v.raw, r.raw); return r; } /*! * @brief mod of each vector item by scalar * * @param[in] v vector * @param[in] s scalar * @returns destination vector */ CGLM_INLINE vec3s glms_vec3_(mods)(vec3s v, float s) { vec3s r; glm_vec3_mods(v.raw, s, r.raw); return r; } /*! * @brief threshold each vector item with scalar * condition is: (x[i] < edge) ? 0.0 : 1.0 * * @param[in] edge threshold * @param[in] x vector to test against threshold * @returns destination */ CGLM_INLINE vec3s glms_vec3_(steps)(float edge, vec3s x) { vec3s r; glm_vec3_steps(edge, x.raw, r.raw); return r; } /*! * @brief threshold a value with *vector* as the threshold * condition is: (x < edge[i]) ? 0.0 : 1.0 * * @param[in] edge threshold vector * @param[in] x value to test against threshold * @returns destination */ CGLM_INLINE vec3s glms_vec3_(stepr)(vec3s edge, float x) { vec3s r; glm_vec3_stepr(edge.raw, x, r.raw); return r; } /*! * @brief vector reduction by summation * @warning could overflow * * @param[in] v vector * @return sum of all vector's elements */ CGLM_INLINE float glms_vec3_(hadd)(vec3s v) { return glm_vec3_hadd(v.raw); } /*! * @brief square root of each vector item * * @param[in] v vector * @returns destination vector */ CGLM_INLINE vec3s glms_vec3_(sqrt)(vec3s v) { vec3s r; glm_vec3_sqrt(v.raw, r.raw); return r; } #endif /* cglms_vec3s_ext_h */ cglm-0.9.6/include/cglm/struct/vec3.h000066400000000000000000000622151475344456400174000ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ /* Macros: GLMS_VEC3_ONE_INIT GLMS_VEC3_ZERO_INIT GLMS_VEC3_ONE GLMS_VEC3_ZERO GLMS_YUP GLMS_ZUP GLMS_XUP Functions: CGLM_INLINE vec3s glms_vec3(vec4s v4); CGLM_INLINE void glms_vec3_pack(vec3s dst[], vec3 src[], size_t len); CGLM_INLINE void glms_vec3_unpack(vec3 dst[], vec3s src[], size_t len); CGLM_INLINE vec3s glms_vec3_zero(void); CGLM_INLINE vec3s glms_vec3_one(void); CGLM_INLINE float glms_vec3_dot(vec3s a, vec3s b); CGLM_INLINE float glms_vec3_norm2(vec3s v); CGLM_INLINE float glms_vec3_norm(vec3s v); CGLM_INLINE float glms_vec3_norm_one(vec3s v); CGLM_INLINE float glms_vec3_norm_inf(vec3s v); CGLM_INLINE vec3s glms_vec3_add(vec3s a, vec3s b); CGLM_INLINE vec3s glms_vec3_adds(vec3s a, float s); CGLM_INLINE vec3s glms_vec3_sub(vec3s a, vec3s b); CGLM_INLINE vec3s glms_vec3_subs(vec3s a, float s); CGLM_INLINE vec3s glms_vec3_mul(vec3s a, vec3s b); CGLM_INLINE vec3s glms_vec3_scale(vec3s v, float s); CGLM_INLINE vec3s glms_vec3_scale_as(vec3s v, float s); CGLM_INLINE vec3s glms_vec3_div(vec3s a, vec3s b); CGLM_INLINE vec3s glms_vec3_divs(vec3s a, float s); CGLM_INLINE vec3s glms_vec3_addadd(vec3s a, vec3s b, vec3s dest); CGLM_INLINE vec3s glms_vec3_subadd(vec3s a, vec3s b, vec3s dest); CGLM_INLINE vec3s glms_vec3_muladd(vec3s a, vec3s b, 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_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_negate(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_crossn(vec3s a, vec3s b); CGLM_INLINE float glms_vec3_angle(vec3s a, vec3s b); CGLM_INLINE vec3s glms_vec3_rotate(vec3s v, float angle, vec3s axis); CGLM_INLINE vec3s glms_vec3_rotate_m4(mat4s m, vec3s v); CGLM_INLINE vec3s glms_vec3_rotate_m3(mat3s m, vec3s v); CGLM_INLINE vec3s glms_vec3_proj(vec3s a, vec3s b); CGLM_INLINE vec3s glms_vec3_center(vec3s a, vec3s b); CGLM_INLINE float glms_vec3_distance(vec3s a, vec3s b); CGLM_INLINE float glms_vec3_distance2(vec3s a, vec3s b); CGLM_INLINE vec3s glms_vec3_maxv(vec3s a, vec3s b); CGLM_INLINE vec3s glms_vec3_minv(vec3s a, vec3s b); CGLM_INLINE vec3s glms_vec3_ortho(vec3s v); CGLM_INLINE vec3s glms_vec3_clamp(vec3s v, float minVal, float maxVal); CGLM_INLINE vec3s glms_vec3_lerp(vec3s from, vec3s to, float t); CGLM_INLINE vec3s glms_vec3_lerpc(vec3s from, vec3s to, float t); CGLM_INLINE vec3s glms_vec3_mix(vec3s from, vec3s to, float t); CGLM_INLINE vec3s glms_vec3_mixc(vec3s from, vec3s to, float t); CGLM_INLINE vec3s glms_vec3_step(vec3s edge, vec3s x); CGLM_INLINE vec3s glms_vec3_smoothstep_uni(float edge0, float edge1, vec3s x); CGLM_INLINE vec3s glms_vec3_smoothstep(vec3s edge0, vec3s edge1, vec3s x); CGLM_INLINE vec3s glms_vec3_smoothinterp(vec3s from, vec3s to, float t); CGLM_INLINE vec3s glms_vec3_smoothinterpc(vec3s from, vec3s to, float t); CGLM_INLINE vec3s glms_vec3_swizzle(vec3s v, int mask); CGLM_INLINE vec3s glms_vec3_make(float * restrict src); CGLM_INLINE vec3s glms_vec3_faceforward(vec3s n, vec3s v, vec3s nref); CGLM_INLINE vec3s glms_vec3_reflect(vec3s v, vec3s n); CGLM_INLINE bool glms_vec3_refract(vec3s v, vec3s n, float eta, vec3s *dest) Convenient: CGLM_INLINE vec3s glms_cross(vec3s a, vec3s b); CGLM_INLINE float glms_dot(vec3s a, vec3s b); CGLM_INLINE vec3s glms_normalize(vec3s v); Deprecated: glms_vec3_step_uni --> use glms_vec3_steps */ #ifndef cglms_vec3s_h #define cglms_vec3s_h #include "../common.h" #include "../types-struct.h" #include "../util.h" #include "../vec3.h" #include "vec3-ext.h" /* DEPRECATED! */ #define glms_vec3_step_uni(edge, x) glms_vec3_steps(edge, x) #define GLMS_VEC3_ONE_INIT {GLM_VEC3_ONE_INIT} #define GLMS_VEC3_ZERO_INIT {GLM_VEC3_ZERO_INIT} #define GLMS_VEC3_ONE ((vec3s)GLMS_VEC3_ONE_INIT) #define GLMS_VEC3_ZERO ((vec3s)GLMS_VEC3_ZERO_INIT) #define GLMS_YUP ((vec3s){{0.0f, 1.0f, 0.0f}}) #define GLMS_ZUP ((vec3s){{0.0f, 0.0f, 1.0f}}) #define GLMS_XUP ((vec3s){{1.0f, 0.0f, 0.0f}}) /*! * @brief init vec3 using vec4 * * @param[in] v4 vector4 * @returns destination */ CGLM_INLINE vec3s glms_vec3(vec4s v4) { vec3s r; glm_vec3(v4.raw, r.raw); return r; } /*! * @brief pack an array of vec3 into an array of vec3s * * @param[out] dst array of vec3 * @param[in] src array of vec3s * @param[in] len number of elements */ CGLM_INLINE void glms_vec3_(pack)(vec3s dst[], vec3 src[], size_t len) { size_t i; for (i = 0; i < len; i++) { glm_vec3_copy(src[i], dst[i].raw); } } /*! * @brief unpack an array of vec3s into an array of vec3 * * @param[out] dst array of vec3s * @param[in] src array of vec3 * @param[in] len number of elements */ CGLM_INLINE void glms_vec3_(unpack)(vec3 dst[], vec3s src[], size_t len) { size_t i; for (i = 0; i < len; i++) { glm_vec3_copy(src[i].raw, dst[i]); } } /*! * @brief make vector zero * * @returns zero vector */ CGLM_INLINE vec3s glms_vec3_(zero)(void) { vec3s r; glm_vec3_zero(r.raw); return r; } /*! * @brief make vector one * * @returns one vector */ CGLM_INLINE vec3s glms_vec3_(one)(void) { vec3s r; glm_vec3_one(r.raw); return r; } /*! * @brief vec3 dot product * * @param[in] a vector1 * @param[in] b vector2 * * @return dot product */ CGLM_INLINE float glms_vec3_(dot)(vec3s a, vec3s b) { return glm_vec3_dot(a.raw, b.raw); } /*! * @brief norm * norm (magnitude) of vec * * we can use this func instead of calling norm * norm, because it would call * sqrtf function twice but with this func we can avoid func call, maybe this is * not good name for this func * * @param[in] v vector * * @return norm * norm */ CGLM_INLINE float glms_vec3_(norm2)(vec3s v) { return glm_vec3_norm2(v.raw); } /*! * @brief norm (magnitude) of vec3 * * @param[in] v vector * * @return norm */ CGLM_INLINE float glms_vec3_(norm)(vec3s v) { return glm_vec3_norm(v.raw); } /*! * @brief L1 norm of vec3 * Also known as Manhattan Distance or Taxicab norm. * L1 Norm is the sum of the magnitudes of the vectors in a space. * It is calculated as the sum of the absolute values of the vector components. * In this norm, all the components of the vector are weighted equally. * * This computes: * R = |v[0]| + |v[1]| + |v[2]| * * @param[in] v vector * * @return L1 norm */ CGLM_INLINE float glms_vec3_(norm_one)(vec3s v) { return glm_vec3_norm_one(v.raw); } /*! * @brief Infinity norm of vec3 * Also known as Maximum norm. * Infinity Norm is the largest magnitude among each element of a vector. * It is calculated as the maximum of the absolute values of the vector components. * * This computes: * inf norm = max(|v[0]|, |v[1]|, |v[2]|) * * @param[in] v vector * * @return Infinity norm */ CGLM_INLINE float glms_vec3_(norm_inf)(vec3s v) { return glm_vec3_norm_inf(v.raw); } /*! * @brief add a vector to b vector store result in dest * * @param[in] a vector1 * @param[in] b vector2 * @returns destination vector */ CGLM_INLINE vec3s glms_vec3_(add)(vec3s a, vec3s b) { vec3s r; glm_vec3_add(a.raw, b.raw, r.raw); return r; } /*! * @brief add scalar to v vector store result in dest (d = v + s) * * @param[in] a vector * @param[in] s scalar * @returns destination vector */ CGLM_INLINE vec3s glms_vec3_(adds)(vec3s a, float s) { vec3s r; glm_vec3_adds(a.raw, s, r.raw); return r; } /*! * @brief subtract b vector from a vector store result in dest * * @param[in] a vector1 * @param[in] b vector2 * @returns destination vector */ CGLM_INLINE vec3s glms_vec3_(sub)(vec3s a, vec3s b) { vec3s r; glm_vec3_sub(a.raw, b.raw, r.raw); return r; } /*! * @brief subtract scalar from v vector store result in dest (d = v - s) * * @param[in] a vector * @param[in] s scalar * @returns destination vector */ CGLM_INLINE vec3s glms_vec3_(subs)(vec3s a, float s) { vec3s r; glm_vec3_subs(a.raw, s, r.raw); return r; } /*! * @brief multiply two vectors (component-wise multiplication) * * @param a vector1 * @param b vector2 * @returns v3 = (a[0] * b[0], a[1] * b[1], a[2] * b[2]) */ CGLM_INLINE vec3s glms_vec3_(mul)(vec3s a, vec3s b) { vec3s r; glm_vec3_mul(a.raw, b.raw, r.raw); return r; } /*! * @brief multiply/scale vec3 vector with scalar: result = v * s * * @param[in] v vector * @param[in] s scalar * @returns destination vector */ CGLM_INLINE vec3s glms_vec3_(scale)(vec3s v, float s) { vec3s r; glm_vec3_scale(v.raw, s, r.raw); return r; } /*! * @brief make vec3 vector scale as specified: result = unit(v) * s * * @param[in] v vector * @param[in] s scalar * @returns destination vector */ CGLM_INLINE vec3s glms_vec3_(scale_as)(vec3s v, float s) { vec3s r; glm_vec3_scale_as(v.raw, s, r.raw); return r; } /*! * @brief div vector with another component-wise division: d = a / b * * @param[in] a vector 1 * @param[in] b vector 2 * @returns result = (a[0]/b[0], a[1]/b[1], a[2]/b[2]) */ CGLM_INLINE vec3s glms_vec3_(div)(vec3s a, vec3s b) { vec3s r; glm_vec3_div(a.raw, b.raw, r.raw); return r; } /*! * @brief div vector with scalar: d = v / s * * @param[in] a vector * @param[in] s scalar * @returns result = (a[0]/s, a[1]/s, a[2]/s) */ CGLM_INLINE vec3s glms_vec3_(divs)(vec3s a, float s) { vec3s r; glm_vec3_divs(a.raw, s, r.raw); return r; } /*! * @brief add two vectors and add result to sum * * 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_(addadd)(vec3s a, vec3s b, vec3s dest) { glm_vec3_addadd(a.raw, b.raw, dest.raw); return dest; } /*! * @brief sub two vectors and add 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_(subadd)(vec3s a, vec3s b, vec3s dest) { glm_vec3_subadd(a.raw, b.raw, dest.raw); return dest; } /*! * @brief mul two vectors and add 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_(muladd)(vec3s a, vec3s b, vec3s dest) { glm_vec3_muladd(a.raw, b.raw, dest.raw); return dest; } /*! * @brief mul vector with scalar and add result to sum * * 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_(muladds)(vec3s a, float s, vec3s dest) { glm_vec3_muladds(a.raw, s, dest.raw); return dest; } /*! * @brief add 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 * @returns dest += max(a, b) */ CGLM_INLINE vec3s glms_vec3_(maxadd)(vec3s a, vec3s b, vec3s dest) { glm_vec3_maxadd(a.raw, b.raw, dest.raw); return dest; } /*! * @brief add 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 * @returns dest += min(a, b) */ CGLM_INLINE vec3s glms_vec3_(minadd)(vec3s a, vec3s b, vec3s dest) { glm_vec3_minadd(a.raw, b.raw, dest.raw); 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 * * @param[in] v vector * @returns result vector */ CGLM_INLINE vec3s glms_vec3_(flipsign)(vec3s v) { glm_vec3_flipsign(v.raw); return v; } /*! * @brief negate vector components * * @param[in] v vector * @returns negated vector */ CGLM_INLINE vec3s glms_vec3_(negate)(vec3s v) { glm_vec3_negate(v.raw); return v; } /*! * @brief normalize vec3 and store result in same vec * * @param[in] v vector * @returns normalized vector */ CGLM_INLINE vec3s glms_vec3_(normalize)(vec3s v) { glm_vec3_normalize(v.raw); return v; } /*! * @brief cross product of two vector (RH) * * @param[in] a vector 1 * @param[in] b vector 2 * @returns destination */ CGLM_INLINE vec3s glms_vec3_(cross)(vec3s a, vec3s b) { vec3s r; glm_vec3_cross(a.raw, b.raw, r.raw); return r; } /*! * @brief cross product of two vector (RH) and normalize the result * * @param[in] a vector 1 * @param[in] b vector 2 * @returns destination */ CGLM_INLINE vec3s glms_vec3_(crossn)(vec3s a, vec3s b) { vec3s r; glm_vec3_crossn(a.raw, b.raw, r.raw); return r; } /*! * @brief angle between two vector * * @param[in] a vector1 * @param[in] b vector2 * * @return angle as radians */ CGLM_INLINE float glms_vec3_(angle)(vec3s a, vec3s b) { return glm_vec3_angle(a.raw, b.raw); } /*! * @brief rotate vec3 around axis by angle using Rodrigues' rotation formula * * @param[in] v vector * @param[in] axis axis vector (must be unit vector) * @param[in] angle angle by radians * @returns rotated vector */ CGLM_INLINE vec3s glms_vec3_(rotate)(vec3s v, float angle, vec3s axis) { glm_vec3_rotate(v.raw, angle, axis.raw); return v; } /*! * @brief apply rotation matrix to vector * * matrix format should be (no perspective): * a b c x * e f g y * i j k z * 0 0 0 w * * @param[in] m affine matrix or rot matrix * @param[in] v vector * @returns rotated vector */ CGLM_INLINE vec3s glms_vec3_(rotate_m4)(mat4s m, vec3s v) { vec3s r; glm_vec3_rotate_m4(m.raw, v.raw, r.raw); return r; } /*! * @brief apply rotation matrix to vector * * @param[in] m affine matrix or rot matrix * @param[in] v vector * @returns rotated vector */ CGLM_INLINE vec3s glms_vec3_(rotate_m3)(mat3s m, vec3s v) { vec3s r; glm_vec3_rotate_m3(m.raw, v.raw, r.raw); return r; } /*! * @brief project a vector onto b vector * * @param[in] a vector1 * @param[in] b vector2 * @returns projected vector */ CGLM_INLINE vec3s glms_vec3_(proj)(vec3s a, vec3s b) { vec3s r; glm_vec3_proj(a.raw, b.raw, r.raw); return r; } /** * @brief find center point of two vector * * @param[in] a vector1 * @param[in] b vector2 * @returns center point */ CGLM_INLINE vec3s glms_vec3_(center)(vec3s a, vec3s b) { vec3s r; glm_vec3_center(a.raw, b.raw, r.raw); return r; } /** * @brief distance between two vectors * * @param[in] a vector1 * @param[in] b vector2 * @return distance */ CGLM_INLINE float glms_vec3_(distance)(vec3s a, vec3s b) { return glm_vec3_distance(a.raw, b.raw); } /** * @brief squared distance between two vectors * * @param[in] a vector1 * @param[in] b vector2 * @return squared distance (distance * distance) */ CGLM_INLINE float glms_vec3_(distance2)(vec3s a, vec3s b) { return glm_vec3_distance2(a.raw, b.raw); } /*! * @brief max values of vectors * * @param[in] a vector1 * @param[in] b vector2 * @returns destination */ CGLM_INLINE vec3s glms_vec3_(maxv)(vec3s a, vec3s b) { vec3s r; glm_vec3_maxv(a.raw, b.raw, r.raw); return r; } /*! * @brief min values of vectors * * @param[in] a vector1 * @param[in] b vector2 * @returns destination */ CGLM_INLINE vec3s glms_vec3_(minv)(vec3s a, vec3s b) { vec3s r; glm_vec3_minv(a.raw, b.raw, r.raw); return r; } /*! * @brief possible orthogonal/perpendicular vector * * @param[in] v vector * @returns orthogonal/perpendicular vector */ CGLM_INLINE vec3s glms_vec3_(ortho)(vec3s v) { vec3s r; glm_vec3_ortho(v.raw, r.raw); return r; } /*! * @brief clamp vector's individual members between min and max values * * @param[in] v vector * @param[in] minVal minimum value * @param[in] maxVal maximum value * @returns clamped vector */ CGLM_INLINE vec3s glms_vec3_(clamp)(vec3s v, float minVal, float maxVal) { glm_vec3_clamp(v.raw, minVal, maxVal); return v; } /*! * @brief linear interpolation between two vectors * * formula: from + s * (to - from) * * @param[in] from from value * @param[in] to to value * @param[in] t interpolant (amount) * @returns destination */ CGLM_INLINE vec3s glms_vec3_(lerp)(vec3s from, vec3s to, float t) { vec3s r; glm_vec3_lerp(from.raw, to.raw, t, r.raw); return r; } /*! * @brief linear interpolation between two vectors (clamped) * * formula: from + s * (to - from) * * @param[in] from from value * @param[in] to to value * @param[in] t interpolant (amount) clamped between 0 and 1 * @returns destination */ CGLM_INLINE vec3s glms_vec3_(lerpc)(vec3s from, vec3s to, float t) { vec3s r; glm_vec3_lerpc(from.raw, to.raw, t, r.raw); return r; } /*! * @brief linear interpolation between two vectors * * formula: from + s * (to - from) * * @param[in] from from value * @param[in] to to value * @param[in] t interpolant (amount) * @returns destination */ CGLM_INLINE vec3s glms_vec3_(mix)(vec3s from, vec3s to, float t) { vec3s r; glm_vec3_mix(from.raw, to.raw, t, r.raw); return r; } /*! * @brief linear interpolation between two vectors (clamped) * * formula: from + s * (to - from) * * @param[in] from from value * @param[in] to to value * @param[in] t interpolant (amount) clamped between 0 and 1 * @returns destination */ CGLM_INLINE vec3s glms_vec3_(mixc)(vec3s from, vec3s to, float t) { vec3s r; glm_vec3_mixc(from.raw, to.raw, t, r.raw); return r; } /*! * @brief threshold function * * @param[in] edge threshold * @param[in] x value to test against threshold * @returns 0.0 if x < edge, else 1.0 */ CGLM_INLINE vec3s glms_vec3_(step)(vec3s edge, vec3s x) { vec3s r; glm_vec3_step(edge.raw, x.raw, r.raw); return r; } /*! * @brief threshold function with a smooth transition (unidimensional) * * @param[in] edge0 low threshold * @param[in] edge1 high threshold * @param[in] x value to test against threshold * @returns destination */ CGLM_INLINE vec3s glms_vec3_(smoothstep_uni)(float edge0, float edge1, vec3s x) { vec3s r; glm_vec3_smoothstep_uni(edge0, edge1, x.raw, r.raw); return r; } /*! * @brief threshold function with a smooth transition * * @param[in] edge0 low threshold * @param[in] edge1 high threshold * @param[in] x value to test against threshold * @returns destination */ CGLM_INLINE vec3s glms_vec3_(smoothstep)(vec3s edge0, vec3s edge1, vec3s x) { vec3s r; glm_vec3_smoothstep(edge0.raw, edge1.raw, x.raw, r.raw); return r; } /*! * @brief smooth Hermite interpolation between two vectors * * formula: from + s * (to - from) * * @param[in] from from value * @param[in] to to value * @param[in] t interpolant (amount) * @returns destination */ CGLM_INLINE vec3s glms_vec3_(smoothinterp)(vec3s from, vec3s to, float t) { vec3s r; glm_vec3_smoothinterp(from.raw, to.raw, t, r.raw); return r; } /*! * @brief smooth Hermite interpolation between two vectors (clamped) * * formula: from + s * (to - from) * * @param[in] from from value * @param[in] to to value * @param[in] t interpolant (amount) clamped between 0 and 1 * @returns destination */ CGLM_INLINE vec3s glms_vec3_(smoothinterpc)(vec3s from, vec3s to, float t) { vec3s r; glm_vec3_smoothinterpc(from.raw, to.raw, t, r.raw); return r; } /*! * @brief vec3 cross product * * this is just convenient wrapper * * @param[in] a source 1 * @param[in] b source 2 * @returns destination */ CGLM_INLINE vec3s glms_cross(vec3s a, vec3s b) { vec3s r; glm_cross(a.raw, b.raw, r.raw); return r; } /*! * @brief vec3 dot product * * this is just convenient wrapper * * @param[in] a vector1 * @param[in] b vector2 * @return dot product */ CGLM_INLINE float glms_dot(vec3s a, vec3s b) { return glm_dot(a.raw, b.raw); } /*! * @brief normalize vec3 and store result in same vec * * this is just convenient wrapper * * @param[in] v vector * @returns normalized vector */ CGLM_INLINE vec3s glms_normalize(vec3s v) { glm_normalize(v.raw); return v; } /*! * @brief swizzle vector components * * you can use existing masks e.g. GLM_XXX, GLM_ZYX * * @param[in] v source * @param[in] mask mask * @returns swizzled vector */ CGLM_INLINE vec3s glms_vec3_(swizzle)(vec3s v, int mask) { vec3s dest; glm_vec3_swizzle(v.raw, mask, dest.raw); return dest; } /*! * @brief Create three dimensional vector from pointer * * @param[in] src pointer to an array of floats * @returns constructed 3D vector from raw pointer */ CGLM_INLINE vec3s glms_vec3_(make)(const float * __restrict src) { vec3s dest; glm_vec3_make(src, dest.raw); return dest; } /*! * @brief a vector pointing in the same direction as another * * orients a vector to point away from a surface as defined by its normal * * @param[in] n vector to orient. * @param[in] v incident vector * @param[in] nref reference vector * @returns oriented vector, pointing away from the surface. */ CGLM_INLINE vec3s glms_vec3_(faceforward)(vec3s n, vec3s v, vec3s nref) { vec3s dest; glm_vec3_faceforward(n.raw, v.raw, nref.raw, dest.raw); return dest; } /*! * @brief reflection vector using an incident ray and a surface normal * * @param[in] I incident vector * @param[in] N normalized normal vector * @returns reflection result */ CGLM_INLINE vec3s glms_vec3_(reflect)(vec3s v, vec3s n) { vec3s dest; glm_vec3_reflect(v.raw, n.raw, dest.raw); return dest; } /*! * @brief computes refraction vector for an incident vector and a surface normal. * * calculates the refraction vector based on Snell's law. If total internal reflection * occurs (angle too great given eta), dest is set to zero and returns false. * Otherwise, computes refraction vector, stores it in dest, and returns true. * * @param[in] v normalized incident vector * @param[in] n normalized normal vector * @param[in] eta ratio of indices of refraction (incident/transmitted) * @param[out] dest refraction vector if refraction occurs; zero vector otherwise * * @returns true if refraction occurs; false if total internal reflection occurs. */ CGLM_INLINE bool glms_vec3_(refract)(vec3s v, vec3s n, float eta, vec3s * __restrict dest) { return glm_vec3_refract(v.raw, n.raw, eta, dest->raw); } #endif /* cglms_vec3s_h */ cglm-0.9.6/include/cglm/struct/vec4-ext.h000066400000000000000000000142561475344456400202010ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ /*! * @brief SIMD like functions */ /* Functions: CGLM_INLINE vec4s glms_vec4_broadcast(float val); CGLM_INLINE vec4s glms_vec4_fill(float val); CGLM_INLINE bool glms_vec4_eq(vec4s v, float val); CGLM_INLINE bool glms_vec4_eq_eps(vec4s v, float val); CGLM_INLINE bool glms_vec4_eq_all(vec4s v); CGLM_INLINE bool glms_vec4_eqv(vec4s a, vec4s b); CGLM_INLINE bool glms_vec4_eqv_eps(vec4s a, vec4s b); CGLM_INLINE float glms_vec4_max(vec4s v); CGLM_INLINE float glms_vec4_min(vec4s v); CGLM_INLINE bool glms_vec4_isnan(vec4s v); CGLM_INLINE bool glms_vec4_isinf(vec4s v); CGLM_INLINE bool glms_vec4_isvalid(vec4s v); CGLM_INLINE vec4s glms_vec4_sign(vec4s v); CGLM_INLINE vec4s glms_vec4_abs(vec4s v); CGLM_INLINE vec4s glms_vec4_fract(vec4s v); CGLM_INLINE float glms_vec4_floor(vec4s v); CGLM_INLINE float glms_vec4_mods(vec4s v, float s); CGLM_INLINE float glms_vec4_steps(float edge, vec4s v); CGLM_INLINE void glms_vec4_stepr(vec4s edge, float v); CGLM_INLINE float glms_vec4_hadd(vec4s v); CGLM_INLINE vec4s glms_vec4_sqrt(vec4s v); */ #ifndef cglms_vec4s_ext_h #define cglms_vec4s_ext_h #include "../common.h" #include "../types-struct.h" #include "../util.h" #include "../vec4-ext.h" /* api definition */ #define glms_vec4_(NAME) CGLM_STRUCTAPI(vec4, NAME) /*! * @brief fill a vector with specified value * * @param val value * @returns dest */ CGLM_INLINE vec4s glms_vec4_(broadcast)(float val) { vec4s r; glm_vec4_broadcast(val, r.raw); return r; } /*! * @brief fill a vector with specified value * * @param val value * @returns dest */ CGLM_INLINE vec4s glms_vec4_(fill)(float val) { vec4s r; glm_vec4_fill(r.raw, val); return r; } /*! * @brief check if vector is equal to value (without epsilon) * * @param v vector * @param val value */ CGLM_INLINE bool glms_vec4_(eq)(vec4s v, float val) { return glm_vec4_eq(v.raw, val); } /*! * @brief check if vector is equal to value (with epsilon) * * @param v vector * @param val value */ CGLM_INLINE bool glms_vec4_(eq_eps)(vec4s v, float val) { return glm_vec4_eq_eps(v.raw, val); } /*! * @brief check if vector members are equal (without epsilon) * * @param v vector */ CGLM_INLINE bool glms_vec4_(eq_all)(vec4s v) { return glm_vec4_eq_all(v.raw); } /*! * @brief check if vector is equal to another (without epsilon) * * @param a vector * @param b vector */ CGLM_INLINE bool glms_vec4_(eqv)(vec4s a, vec4s b) { return glm_vec4_eqv(a.raw, b.raw); } /*! * @brief check if vector is equal to another (with epsilon) * * @param a vector * @param b vector */ CGLM_INLINE bool glms_vec4_(eqv_eps)(vec4s a, vec4s b) { return glm_vec4_eqv_eps(a.raw, b.raw); } /*! * @brief max value of vector * * @param v vector */ CGLM_INLINE float glms_vec4_(max)(vec4s v) { return glm_vec4_max(v.raw); } /*! * @brief min value of vector * * @param v vector */ CGLM_INLINE float glms_vec4_(min)(vec4s v) { return glm_vec4_min(v.raw); } /*! * @brief check if one of items is NaN (not a number) * you should only use this in DEBUG mode or very critical asserts * * @param[in] v vector */ CGLM_INLINE bool glms_vec4_(isnan)(vec4s v) { return glm_vec4_isnan(v.raw); } /*! * @brief check if one of items is INFINITY * you should only use this in DEBUG mode or very critical asserts * * @param[in] v vector */ CGLM_INLINE bool glms_vec4_(isinf)(vec4s v) { return glm_vec4_isinf(v.raw); } /*! * @brief check if all items are valid number * you should only use this in DEBUG mode or very critical asserts * * @param[in] v vector */ CGLM_INLINE bool glms_vec4_(isvalid)(vec4s v) { return glm_vec4_isvalid(v.raw); } /*! * @brief get sign of 32 bit float as +1, -1, 0 * * Important: It returns 0 for zero/NaN input * * @param v vector * @returns sign vector */ CGLM_INLINE vec4s glms_vec4_(sign)(vec4s v) { vec4s r; glm_vec4_sign(v.raw, r.raw); return r; } /*! * @brief absolute value of each vector item * * @param[in] v vector * @returns destination vector */ CGLM_INLINE vec4s glms_vec4_(abs)(vec4s v) { vec4s r; glm_vec4_abs(v.raw, r.raw); return r; } /*! * @brief fractional part of each vector item * * @param[in] v vector * @returns dest destination vector */ CGLM_INLINE vec4s glms_vec4_(fract)(vec4s v) { vec4s r; glm_vec4_fract(v.raw, r.raw); return r; } /*! * @brief floor of each vector item * * @param[in] v vector * @returns dest destination vector */ CGLM_INLINE vec4s glms_vec4_(floor)(vec4s v) { vec4s r; glm_vec4_floor(v.raw, r.raw); return r; } /*! * @brief mod of each vector item by scalar * * @param[in] v vector * @param[in] s scalar * @returns destination vector */ CGLM_INLINE vec4s glms_vec4_(mods)(vec4s v, float s) { vec4s r; glm_vec4_mods(v.raw, s, r.raw); return r; } /*! * @brief threshold each vector item with scalar * condition is: (x[i] < edge) ? 0.0 : 1.0 * * @param[in] edge threshold * @param[in] x vector to test against threshold * @returns destination */ CGLM_INLINE vec4s glms_vec4_(steps)(float edge, vec4s x) { vec4s r; glm_vec4_steps(edge, x.raw, r.raw); return r; } /*! * @brief threshold a value with *vector* as the threshold * condition is: (x < edge[i]) ? 0.0 : 1.0 * * @param[in] edge threshold vector * @param[in] x value to test against threshold * @returns destination */ CGLM_INLINE vec4s glms_vec4_(stepr)(vec4s edge, float x) { vec4s r; glm_vec4_stepr(edge.raw, x, r.raw); return r; } /*! * @brief vector reduction by summation * @warning could overflow * * @param[in] v vector * @return sum of all vector's elements */ CGLM_INLINE float glms_vec4_(hadd)(vec4s v) { return glm_vec4_hadd(v.raw); } /*! * @brief square root of each vector item * * @param[in] v vector * @returns destination vector */ CGLM_INLINE vec4s glms_vec4_(sqrt)(vec4s v) { vec4s r; glm_vec4_sqrt(v.raw, r.raw); return r; } #endif /* cglms_vec4s_ext_h */ cglm-0.9.6/include/cglm/struct/vec4.h000066400000000000000000000532341475344456400174020ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ /* Macros: GLMS_VEC4_ONE_INIT GLMS_VEC4_BLACK_INIT GLMS_VEC4_ZERO_INIT GLMS_VEC4_ONE GLMS_VEC4_BLACK GLMS_VEC4_ZERO Functions: CGLM_INLINE vec4s glms_vec4(vec3s v3, float last); CGLM_INLINE vec3s glms_vec4_copy3(vec4s v); CGLM_INLINE vec4s glms_vec4_copy(vec4s v); CGLM_INLINE vec4s glms_vec4_ucopy(vec4s v); CGLM_INLINE void glms_vec4_pack(vec4s dst[], vec4 src[], size_t len); CGLM_INLINE void glms_vec4_unpack(vec4 dst[], vec4s src[], size_t len); CGLM_INLINE float glms_vec4_dot(vec4s a, vec4s b); CGLM_INLINE float glms_vec4_norm2(vec4s v); CGLM_INLINE float glms_vec4_norm(vec4s v); CGLM_INLINE float glms_vec4_norm_one(vec4s v); CGLM_INLINE float glms_vec4_norm_inf(vec4s v); CGLM_INLINE vec4s glms_vec4_add(vec4s a, vec4s b); CGLM_INLINE vec4s glms_vec4_adds(vec4s v, float s); CGLM_INLINE vec4s glms_vec4_sub(vec4s a, vec4s b); CGLM_INLINE vec4s glms_vec4_subs(vec4s v, float s); CGLM_INLINE vec4s glms_vec4_mul(vec4s a, vec4s b); CGLM_INLINE vec4s glms_vec4_scale(vec4s v, float s); CGLM_INLINE vec4s glms_vec4_scale_as(vec4s v, float s); CGLM_INLINE vec4s glms_vec4_div(vec4s a, vec4s b); CGLM_INLINE vec4s glms_vec4_divs(vec4s v, float s); CGLM_INLINE vec4s glms_vec4_addadd(vec4s a, vec4s b, vec4s dest); CGLM_INLINE vec4s glms_vec4_subadd(vec4s a, vec4s b, vec4s dest); CGLM_INLINE vec4s glms_vec4_muladd(vec4s a, vec4s b, 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_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_normalize(vec4s v); CGLM_INLINE float glms_vec4_distance(vec4s a, vec4s b); CGLM_INLINE float glms_vec4_distance2(vec4s a, vec4s b); CGLM_INLINE vec4s glms_vec4_maxv(vec4s a, vec4s b); CGLM_INLINE vec4s glms_vec4_minv(vec4s a, vec4s b); CGLM_INLINE vec4s glms_vec4_clamp(vec4s v, float minVal, float maxVal); CGLM_INLINE vec4s glms_vec4_lerp(vec4s from, vec4s to, float t); CGLM_INLINE vec4s glms_vec4_lerpc(vec4s from, vec4s to, float t); CGLM_INLINE vec4s glms_vec4_mix(vec4s from, vec4s to, float t); CGLM_INLINE vec4s glms_vec4_mixc(vec4s from, vec4s to, float t); CGLM_INLINE vec4s glms_vec4_step(vec4s edge, vec4s x); CGLM_INLINE vec4s glms_vec4_smoothstep_uni(float edge0, float edge1, vec4s x); CGLM_INLINE vec4s glms_vec4_smoothstep(vec4s edge0, vec4s edge1, vec4s x); CGLM_INLINE vec4s glms_vec4_smoothinterp(vec4s from, vec4s to, float t); CGLM_INLINE vec4s glms_vec4_smoothinterpc(vec4s from, vec4s to, float t); CGLM_INLINE vec4s glms_vec4_cubic(float s); CGLM_INLINE vec4s glms_vec4_swizzle(vec4s v, int mask); CGLM_INLINE vec4s glms_vec4_make(float * restrict src); CGLM_INLINE vec4s glms_vec4_reflect(vec4s v, vec4s n); CGLM_INLINE bool glms_vec4_refract(vec4s v, vec4s n, float eta, vec4s *dest) Deprecated: glms_vec4_step_uni --> use glms_vec4_steps */ #ifndef cglms_vec4s_h #define cglms_vec4s_h #include "../common.h" #include "../types-struct.h" #include "../util.h" #include "../vec4.h" #include "vec4-ext.h" /* DEPRECATED! */ #define glms_vec4_step_uni(edge, x) glms_vec4_steps(edge, x) #define GLMS_VEC4_ONE_INIT {GLM_VEC4_ONE_INIT} #define GLMS_VEC4_BLACK_INIT {GLM_VEC4_BLACK_INIT} #define GLMS_VEC4_ZERO_INIT {GLM_VEC4_ZERO_INIT} #define GLMS_VEC4_ONE ((vec4s)GLM_VEC4_ONE_INIT) #define GLMS_VEC4_BLACK ((vec4s)GLM_VEC4_BLACK_INIT) #define GLMS_VEC4_ZERO ((vec4s)GLM_VEC4_ZERO_INIT) /*! * @brief init vec4 using vec3 * * @param[in] v3 vector3 * @param[in] last last item * @returns destination */ CGLM_INLINE vec4s glms_vec4(vec3s v3, float last) { vec4s r; glm_vec4(v3.raw, last, r.raw); return r; } /*! * @brief copy first 3 members of [a] to [dest] * * @param[in] v source * @returns vec3 */ CGLM_INLINE vec3s glms_vec4_(copy3)(vec4s v) { vec3s r; glm_vec4_copy3(v.raw, r.raw); return r; } /*! * @brief copy all members of [a] to [dest] * * @param[in] v source * @returns destination */ CGLM_INLINE vec4s glms_vec4_(copy)(vec4s v) { vec4s r; glm_vec4_copy(v.raw, r.raw); return r; } /*! * @brief copy all members of [a] to [dest] * * alignment is not required * * @param[in] v source * @returns destination */ CGLM_INLINE vec4s glms_vec4_(ucopy)(vec4s v) { vec4s r; glm_vec4_ucopy(v.raw, r.raw); return r; } /*! * @brief pack an array of vec4 into an array of vec4s * * @param[out] dst array of vec4 * @param[in] src array of vec4s * @param[in] len number of elements */ CGLM_INLINE void glms_vec4_(pack)(vec4s dst[], vec4 src[], size_t len) { size_t i; for (i = 0; i < len; i++) { glm_vec4_copy(src[i], dst[i].raw); } } /*! * @brief unpack an array of vec4s into an array of vec4 * * @param[out] dst array of vec4s * @param[in] src array of vec4 * @param[in] len number of elements */ CGLM_INLINE void glms_vec4_(unpack)(vec4 dst[], vec4s src[], size_t len) { size_t i; for (i = 0; i < len; i++) { glm_vec4_copy(src[i].raw, dst[i]); } } /*! * @brief make vector zero * * @returns zero vector */ CGLM_INLINE vec4s glms_vec4_(zero)(void) { vec4s r; glm_vec4_zero(r.raw); return r; } /*! * @brief make vector one * * @returns one vector */ CGLM_INLINE vec4s glms_vec4_(one)(void) { vec4s r; glm_vec4_one(r.raw); return r; } /*! * @brief vec4 dot product * * @param[in] a vector1 * @param[in] b vector2 * * @return dot product */ CGLM_INLINE float glms_vec4_(dot)(vec4s a, vec4s b) { return glm_vec4_dot(a.raw, b.raw); } /*! * @brief norm * norm (magnitude) of vec * * we can use this func instead of calling norm * norm, because it would call * sqrtf function twice but with this func we can avoid func call, maybe this is * not good name for this func * * @param[in] v vec4 * * @return norm * norm */ CGLM_INLINE float glms_vec4_(norm2)(vec4s v) { return glm_vec4_norm2(v.raw); } /*! * @brief norm (magnitude) of vec4 * * @param[in] v vector * * @return norm */ CGLM_INLINE float glms_vec4_(norm)(vec4s v) { return glm_vec4_norm(v.raw); } /*! * @brief L1 norm of vec4 * Also known as Manhattan Distance or Taxicab norm. * L1 Norm is the sum of the magnitudes of the vectors in a space. * It is calculated as the sum of the absolute values of the vector components. * In this norm, all the components of the vector are weighted equally. * * This computes: * R = |v[0]| + |v[1]| + |v[2]| + |v[3]| * * @param[in] v vector * * @return L1 norm */ CGLM_INLINE float glms_vec4_(norm_one)(vec4s v) { return glm_vec4_norm_one(v.raw); } /*! * @brief Infinity norm of vec4 * Also known as Maximum norm. * Infinity Norm is the largest magnitude among each element of a vector. * It is calculated as the maximum of the absolute values of the vector components. * * This computes: * inf norm = max(|v[0]|, |v[1]|, |v[2]|, |v[3]|) * * @param[in] v vector * * @return Infinity norm */ CGLM_INLINE float glms_vec4_(norm_inf)(vec4s v) { return glm_vec4_norm_inf(v.raw); } /*! * @brief add b vector to a vector store result in dest * * @param[in] a vector1 * @param[in] b vector2 * @returns destination vector */ CGLM_INLINE vec4s glms_vec4_(add)(vec4s a, vec4s b) { vec4s r; glm_vec4_add(a.raw, b.raw, r.raw); return r; } /*! * @brief add scalar to v vector store result in dest (d = v + vec(s)) * * @param[in] v vector * @param[in] s scalar * @returns destination vector */ CGLM_INLINE vec4s glms_vec4_(adds)(vec4s v, float s) { vec4s r; glm_vec4_adds(v.raw, s, r.raw); return r; } /*! * @brief subtract b vector from a vector store result in dest (d = a - b) * * @param[in] a vector1 * @param[in] b vector2 * @returns destination vector */ CGLM_INLINE vec4s glms_vec4_(sub)(vec4s a, vec4s b) { vec4s r; glm_vec4_sub(a.raw, b.raw, r.raw); return r; } /*! * @brief subtract scalar from v vector store result in dest (d = v - vec(s)) * * @param[in] v vector * @param[in] s scalar * @returns destination vector */ CGLM_INLINE vec4s glms_vec4_(subs)(vec4s v, float s) { vec4s r; glm_vec4_subs(v.raw, s, r.raw); return r; } /*! * @brief multiply two vectors (component-wise multiplication) * * @param a vector1 * @param b vector2 * @returns dest = (a[0] * b[0], a[1] * b[1], a[2] * b[2], a[3] * b[3]) */ CGLM_INLINE vec4s glms_vec4_(mul)(vec4s a, vec4s b) { vec4s r; glm_vec4_mul(a.raw, b.raw, r.raw); return r; } /*! * @brief multiply/scale vec4 vector with scalar: result = v * s * * @param[in] v vector * @param[in] s scalar * @returns destination vector */ CGLM_INLINE vec4s glms_vec4_(scale)(vec4s v, float s) { vec4s r; glm_vec4_scale(v.raw, s, r.raw); return r; } /*! * @brief make vec4 vector scale as specified: result = unit(v) * s * * @param[in] v vector * @param[in] s scalar * @returns destination vector */ CGLM_INLINE vec4s glms_vec4_(scale_as)(vec4s v, float s) { vec4s r; glm_vec4_scale_as(v.raw, s, r.raw); return r; } /*! * @brief div vector with another component-wise division: d = a / b * * @param[in] a vector 1 * @param[in] b vector 2 * @returns result = (a[0]/b[0], a[1]/b[1], a[2]/b[2], a[3]/b[3]) */ CGLM_INLINE vec4s glms_vec4_(div)(vec4s a, vec4s b) { vec4s r; glm_vec4_div(a.raw, b.raw, r.raw); return r; } /*! * @brief div vec4 vector with scalar: d = v / s * * @param[in] v vector * @param[in] s scalar * @returns destination vector */ CGLM_INLINE vec4s glms_vec4_(divs)(vec4s v, float s) { vec4s r; glm_vec4_divs(v.raw, s, r.raw); return r; } /*! * @brief add two vectors and add result to sum * * 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_(addadd)(vec4s a, vec4s b, vec4s dest) { glm_vec4_addadd(a.raw, b.raw, dest.raw); return dest; } /*! * @brief sub two vectors and add 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_(subadd)(vec4s a, vec4s b, vec4s dest) { glm_vec4_subadd(a.raw, b.raw, dest.raw); return dest; } /*! * @brief mul two vectors and add 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_(muladd)(vec4s a, vec4s b, vec4s dest) { glm_vec4_muladd(a.raw, b.raw, dest.raw); return dest; } /*! * @brief mul vector with scalar and add result to sum * * 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_(muladds)(vec4s a, float s, vec4s dest) { glm_vec4_muladds(a.raw, s, dest.raw); return dest; } /*! * @brief add 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 * @returns dest += max(a, b) */ CGLM_INLINE vec4s glms_vec4_(maxadd)(vec4s a, vec4s b, vec4s dest) { glm_vec4_maxadd(a.raw, b.raw, dest.raw); return dest; } /*! * @brief add 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 * @returns dest += min(a, b) */ CGLM_INLINE vec4s glms_vec4_(minadd)(vec4s a, vec4s b, vec4s dest) { glm_vec4_minadd(a.raw, b.raw, dest.raw); 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 * * @param[in] v vector * @returns result vector */ CGLM_INLINE vec4s glms_vec4_(negate)(vec4s v) { glm_vec4_negate(v.raw); return v; } /*! * @brief normalize vec4 and store result in same vec * * @param[in] v vector * @returns normalized vector */ CGLM_INLINE vec4s glms_vec4_(normalize)(vec4s v) { glm_vec4_normalize(v.raw); return v; } /** * @brief distance between two vectors * * @param[in] a vector1 * @param[in] b vector2 * @return returns distance */ CGLM_INLINE float glms_vec4_(distance)(vec4s a, vec4s b) { return glm_vec4_distance(a.raw, b.raw); } /** * @brief squared distance between two vectors * * @param[in] a vector1 * @param[in] b vector2 * @return returns squared distance */ CGLM_INLINE float glms_vec4_(distance2)(vec4s a, vec4s b) { return glm_vec4_distance2(a.raw, b.raw); } /*! * @brief max values of vectors * * @param[in] a vector1 * @param[in] b vector2 * @returns destination */ CGLM_INLINE vec4s glms_vec4_(maxv)(vec4s a, vec4s b) { vec4s r; glm_vec4_maxv(a.raw, b.raw, r.raw); return r; } /*! * @brief min values of vectors * * @param[in] a vector1 * @param[in] b vector2 * @returns destination */ CGLM_INLINE vec4s glms_vec4_(minv)(vec4s a, vec4s b) { vec4s r; glm_vec4_minv(a.raw, b.raw, r.raw); return r; } /*! * @brief clamp vector's individual members between min and max values * * @param[in] v vector * @param[in] minVal minimum value * @param[in] maxVal maximum value * @returns clamped vector */ CGLM_INLINE vec4s glms_vec4_(clamp)(vec4s v, float minVal, float maxVal) { glm_vec4_clamp(v.raw, minVal, maxVal); return v; } /*! * @brief linear interpolation between two vectors * * formula: from + s * (to - from) * * @param[in] from from value * @param[in] to to value * @param[in] t interpolant (amount) * @returns destination */ CGLM_INLINE vec4s glms_vec4_(lerp)(vec4s from, vec4s to, float t) { vec4s r; glm_vec4_lerp(from.raw, to.raw, t, r.raw); return r; } /*! * @brief linear interpolation between two vectors (clamped) * * formula: from + s * (to - from) * * @param[in] from from value * @param[in] to to value * @param[in] t interpolant (amount) clamped between 0 and 1 * @returns destination */ CGLM_INLINE vec4s glms_vec4_(lerpc)(vec4s from, vec4s to, float t) { vec4s r; glm_vec4_lerpc(from.raw, to.raw, t, r.raw); return r; } /*! * @brief linear interpolation between two vectors * * formula: from + s * (to - from) * * @param[in] from from value * @param[in] to to value * @param[in] t interpolant (amount) * @returns destination */ CGLM_INLINE vec4s glms_vec4_(mix)(vec4s from, vec4s to, float t) { vec4s r; glm_vec4_mix(from.raw, to.raw, t, r.raw); return r; } /*! * @brief linear interpolation between two vectors (clamped) * * formula: from + s * (to - from) * * @param[in] from from value * @param[in] to to value * @param[in] t interpolant (amount) clamped between 0 and 1 * @returns destination */ CGLM_INLINE vec4s glms_vec4_(mixc)(vec4s from, vec4s to, float t) { vec4s r; glm_vec4_mixc(from.raw, to.raw, t, r.raw); return r; } /*! * @brief threshold function * * @param[in] edge threshold * @param[in] x value to test against threshold * @returns 0.0 if x < edge, else 1.0 */ CGLM_INLINE vec4s glms_vec4_(step)(vec4s edge, vec4s x) { vec4s r; glm_vec4_step(edge.raw, x.raw, r.raw); return r; } /*! * @brief threshold function with a smooth transition (unidimensional) * * @param[in] edge0 low threshold * @param[in] edge1 high threshold * @param[in] x value to test against threshold * @returns destination */ CGLM_INLINE vec4s glms_vec4_(smoothstep_uni)(float edge0, float edge1, vec4s x) { vec4s r; glm_vec4_smoothstep_uni(edge0, edge1, x.raw, r.raw); return r; } /*! * @brief threshold function with a smooth transition * * @param[in] edge0 low threshold * @param[in] edge1 high threshold * @param[in] x value to test against threshold * @returns destination */ CGLM_INLINE vec4s glms_vec4_(smoothstep)(vec4s edge0, vec4s edge1, vec4s x) { vec4s r; glm_vec4_smoothstep(edge0.raw, edge1.raw, x.raw, r.raw); return r; } /*! * @brief smooth Hermite interpolation between two vectors * * formula: from + s * (to - from) * * @param[in] from from value * @param[in] to to value * @param[in] t interpolant (amount) * @returns destination */ CGLM_INLINE vec4s glms_vec4_(smoothinterp)(vec4s from, vec4s to, float t) { vec4s r; glm_vec4_smoothinterp(from.raw, to.raw, t, r.raw); return r; } /*! * @brief smooth Hermite interpolation between two vectors (clamped) * * formula: from + s * (to - from) * * @param[in] from from value * @param[in] to to value * @param[in] t interpolant (amount) clamped between 0 and 1 * @returns destination */ CGLM_INLINE vec4s glms_vec4_(smoothinterpc)(vec4s from, vec4s to, float t) { vec4s r; glm_vec4_smoothinterpc(from.raw, to.raw, t, r.raw); return r; } /*! * @brief helper to fill vec4 as [S^3, S^2, S, 1] * * @param[in] s parameter * @returns destination */ CGLM_INLINE vec4s glms_vec4_(cubic)(float s) { vec4s r; glm_vec4_cubic(s, r.raw); return r; } /*! * @brief swizzle vector components * * you can use existing masks e.g. GLM_XXXX, GLM_WZYX * * @param[in] v source * @param[in] mask mask * @returns swizzled vector */ CGLM_INLINE vec4s glms_vec4_(swizzle)(vec4s v, int mask) { vec4s dest; glm_vec4_swizzle(v.raw, mask, dest.raw); return dest; } /*! * @brief Create four dimensional vector from pointer * * @param[in] src pointer to an array of floats * @returns constructed 4D vector from raw pointer */ CGLM_INLINE vec4s glms_vec4_(make)(const float * __restrict src) { vec4s dest; glm_vec4_make(src, dest.raw); return dest; } /*! * @brief reflection vector using an incident ray and a surface normal * * @param[in] v incident vector * @param[in] n normalized normal vector * @returns reflection result */ CGLM_INLINE vec4s glms_vec4_(reflect)(vec4s v, vec4s n) { vec4s dest; glm_vec4_reflect(v.raw, n.raw, dest.raw); return dest; } /*! * @brief computes refraction vector for an incident vector and a surface normal. * * calculates the refraction vector based on Snell's law. If total internal reflection * occurs (angle too great given eta), dest is set to zero and returns false. * Otherwise, computes refraction vector, stores it in dest, and returns true. * * this implementation does not explicitly preserve the 'w' component of the * incident vector 'I' in the output 'dest', users requiring the preservation of * the 'w' component should manually adjust 'dest' after calling this function. * * @param[in] v normalized incident vector * @param[in] n normalized normal vector * @param[in] eta ratio of indices of refraction (incident/transmitted) * @param[out] dest refraction vector if refraction occurs; zero vector otherwise * * @returns true if refraction occurs; false if total internal reflection occurs. */ CGLM_INLINE bool glms_vec4_(refract)(vec4s v, vec4s n, float eta, vec4s * __restrict dest) { return glm_vec4_refract(v.raw, n.raw, eta, dest->raw); } #endif /* cglms_vec4s_h */ cglm-0.9.6/include/cglm/types-struct.h000066400000000000000000000135501475344456400177000ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ #ifndef cglm_types_struct_h #define cglm_types_struct_h #include "types.h" /* * Anonymous structs are available since C11, but we'd like to be compatible * with C99 and C89 too. So let's figure out if we should be using them or not. * It's simply a convenience feature, you can e.g. build the library with * anonymous structs and your application without them and they'll still be * compatible, cglm doesn't use the anonymous structs internally. */ #ifndef CGLM_USE_ANONYMOUS_STRUCT /* If the user doesn't explicitly specify if they want anonymous structs or * not, then we'll try to intuit an appropriate choice. */ # if defined(CGLM_NO_ANONYMOUS_STRUCT) /* The user has defined CGLM_NO_ANONYMOUS_STRUCT. This used to be the * only #define governing the use of anonymous structs, so for backward * compatibility, we still honor that choice and disable them. */ # define CGLM_USE_ANONYMOUS_STRUCT 0 /* Disable anonymous structs if strict ANSI mode is enabled for C89 or C99 */ # elif defined(__STRICT_ANSI__) && \ (!defined(__STDC_VERSION__) || (__STDC_VERSION__ < 201112L)) /* __STRICT_ANSI__ is defined and we're in C89 * or C99 mode (C11 or later not detected) */ # define CGLM_USE_ANONYMOUS_STRUCT 0 # elif (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L) || \ (defined(__cplusplus) && __cplusplus >= 201103L) /* We're compiling for C11 or this is the MSVC compiler. In either * case, anonymous structs are available, so use them. */ # define CGLM_USE_ANONYMOUS_STRUCT 1 # elif defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) /* GCC 4.6 and onwards support anonymous structs as an extension */ # define CGLM_USE_ANONYMOUS_STRUCT 1 # elif defined(__clang__) && __clang_major__ >= 3 /* Clang 3.0 and onwards support anonymous structs as an extension */ # define CGLM_USE_ANONYMOUS_STRUCT 1 # elif defined(_MSC_VER) && (_MSC_VER >= 1900) /* Visual Studio 2015 */ /* We can support anonymous structs * since Visual Studio 2015 or 2017 (1910) maybe? */ # define CGLM_USE_ANONYMOUS_STRUCT 1 # else /* Otherwise, we're presumably building for C99 or C89 and can't rely * on anonymous structs being available. Turn them off. */ # define CGLM_USE_ANONYMOUS_STRUCT 0 # endif #endif typedef union vec2s { vec2 raw; #if CGLM_USE_ANONYMOUS_STRUCT struct { float x; float y; }; struct { float r; float i; }; struct { float u; float v; }; struct { float s; float t; }; #endif } vec2s; typedef union vec3s { vec3 raw; #if CGLM_USE_ANONYMOUS_STRUCT struct { float x; float y; float z; }; struct { float r; float g; float b; }; #endif } vec3s; typedef union ivec2s { ivec2 raw; #if CGLM_USE_ANONYMOUS_STRUCT struct { int x; int y; }; struct { int r; int i; }; struct { int u; int v; }; struct { int s; int t; }; #endif } ivec2s; typedef union ivec3s { ivec3 raw; #if CGLM_USE_ANONYMOUS_STRUCT struct { int x; int y; int z; }; struct { int r; int g; int b; }; #endif } ivec3s; typedef union ivec4s { ivec4 raw; #if CGLM_USE_ANONYMOUS_STRUCT struct { int x; int y; int z; int w; }; struct { int r; int g; int b; int a; }; #endif } ivec4s; typedef union CGLM_ALIGN_IF(16) vec4s { vec4 raw; #if CGLM_USE_ANONYMOUS_STRUCT struct { float x; float y; float z; float w; }; struct { float r; float g; float b; float a; }; #endif } vec4s; typedef union CGLM_ALIGN_IF(16) versors { vec4 raw; #if CGLM_USE_ANONYMOUS_STRUCT struct { float x; float y; float z; float w; }; struct { vec3s imag; float real; }; #endif } versors; typedef union mat2s { mat2 raw; vec2s col[2]; #if CGLM_USE_ANONYMOUS_STRUCT struct { float m00, m01; float m10, m11; }; #endif } mat2s; typedef union mat2x3s { mat2x3 raw; vec3s col[2]; /* [col (2), row (3)] */ #if CGLM_USE_ANONYMOUS_STRUCT struct { float m00, m01, m02; float m10, m11, m12; }; #endif } mat2x3s; typedef union mat2x4s { mat2x4 raw; vec4s col[2]; /* [col (2), row (4)] */ #if CGLM_USE_ANONYMOUS_STRUCT struct { float m00, m01, m02, m03; float m10, m11, m12, m13; }; #endif } mat2x4s; typedef union mat3s { mat3 raw; vec3s col[3]; #if CGLM_USE_ANONYMOUS_STRUCT struct { float m00, m01, m02; float m10, m11, m12; float m20, m21, m22; }; #endif } mat3s; typedef union mat3x2s { mat3x2 raw; vec2s col[3]; /* [col (3), row (2)] */ #if CGLM_USE_ANONYMOUS_STRUCT struct { float m00, m01; float m10, m11; float m20, m21; }; #endif } mat3x2s; typedef union mat3x4s { mat3x4 raw; vec4s col[3]; /* [col (3), row (4)] */ #if CGLM_USE_ANONYMOUS_STRUCT struct { float m00, m01, m02, m03; float m10, m11, m12, m13; float m20, m21, m22, m23; }; #endif } mat3x4s; typedef union CGLM_ALIGN_MAT mat4s { mat4 raw; vec4s col[4]; #if CGLM_USE_ANONYMOUS_STRUCT struct { float m00, m01, m02, m03; float m10, m11, m12, m13; float m20, m21, m22, m23; float m30, m31, m32, m33; }; #endif } mat4s; typedef union mat4x2s { mat4x2 raw; vec2s col[4]; /* [col (4), row (2)] */ #if CGLM_USE_ANONYMOUS_STRUCT struct { float m00, m01; float m10, m11; float m20, m21; float m30, m31; }; #endif } mat4x2s; typedef union mat4x3s { mat4x3 raw; vec3s col[4]; /* [col (4), row (3)] */ #if CGLM_USE_ANONYMOUS_STRUCT struct { float m00, m01, m02; float m10, m11, m12; float m20, m21, m22; float m30, m31, m32; }; #endif } mat4x3s; #endif /* cglm_types_struct_h */ cglm-0.9.6/include/cglm/types.h000066400000000000000000000113001475344456400163450ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ #ifndef cglm_types_h #define cglm_types_h #if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L) # include #endif #if defined(_MSC_VER) /* do not use alignment for older visual studio versions */ /* also ARM32 also causes similar error, disable it for now on ARM32 too */ # if _MSC_VER < 1913 || _M_ARM /* Visual Studio 2017 version 15.6 */ # define CGLM_ALL_UNALIGNED # define CGLM_ALIGN(X) /* no alignment */ # else # define CGLM_ALIGN(X) __declspec(align(X)) # endif #else # define CGLM_ALIGN(X) __attribute((aligned(X))) #endif #ifndef CGLM_ALL_UNALIGNED # define CGLM_ALIGN_IF(X) CGLM_ALIGN(X) #else # define CGLM_ALIGN_IF(X) /* no alignment */ #endif #ifdef __AVX__ # define CGLM_ALIGN_MAT CGLM_ALIGN(32) #else # define CGLM_ALIGN_MAT CGLM_ALIGN(16) #endif #ifndef CGLM_HAVE_BUILTIN_ASSUME_ALIGNED # if defined(__has_builtin) # if __has_builtin(__builtin_assume_aligned) # define CGLM_HAVE_BUILTIN_ASSUME_ALIGNED 1 # endif # elif defined(__GNUC__) && defined(__GNUC_MINOR__) # if __GNUC__ >= 4 && __GNUC_MINOR__ >= 7 # define CGLM_HAVE_BUILTIN_ASSUME_ALIGNED 1 # endif # endif # ifndef CGLM_HAVE_BUILTIN_ASSUME_ALIGNED # define CGLM_HAVE_BUILTIN_ASSUME_ALIGNED 0 # endif #endif #if CGLM_HAVE_BUILTIN_ASSUME_ALIGNED # define CGLM_ASSUME_ALIGNED(expr, alignment) \ __builtin_assume_aligned((expr), (alignment)) #else # define CGLM_ASSUME_ALIGNED(expr, alignment) (expr) #endif #if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L) # 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 ivec3[3]; typedef int ivec4[4]; typedef float vec2[2]; typedef float vec3[3]; typedef CGLM_ALIGN_IF(16) float vec4[4]; typedef vec4 versor; /* |x, y, z, w| -> w is the last */ typedef vec3 mat3[3]; typedef vec2 mat3x2[3]; /* [col (3), row (2)] */ typedef vec4 mat3x4[3]; /* [col (3), row (4)] */ typedef CGLM_ALIGN_IF(16) vec2 mat2[2]; typedef vec3 mat2x3[2]; /* [col (2), row (3)] */ typedef vec4 mat2x4[2]; /* [col (2), row (4)] */ typedef CGLM_ALIGN_MAT vec4 mat4[4]; typedef vec2 mat4x2[4]; /* [col (4), row (2)] */ typedef vec3 mat4x3[4]; /* [col (4), row (3)] */ /* Important: cglm stores quaternion as [x, y, z, w] in memory since v0.4.0 it was [w, x, y, z] before v0.4.0 ( v0.3.5 and earlier ). w is real part. */ #define GLM_E 2.71828182845904523536028747135266250 /* e */ #define GLM_LOG2E 1.44269504088896340735992468100189214 /* log2(e) */ #define GLM_LOG10E 0.434294481903251827651128918916605082 /* log10(e) */ #define GLM_LN2 0.693147180559945309417232121458176568 /* loge(2) */ #define GLM_LN10 2.30258509299404568401799145468436421 /* loge(10) */ #define GLM_PI 3.14159265358979323846264338327950288 /* pi */ #define GLM_PI_2 1.57079632679489661923132169163975144 /* pi/2 */ #define GLM_PI_4 0.785398163397448309615660845819875721 /* pi/4 */ #define GLM_1_PI 0.318309886183790671537767526745028724 /* 1/pi */ #define GLM_2_PI 0.636619772367581343075535053490057448 /* 2/pi */ #define GLM_2_SQRTPI 1.12837916709551257389615890312154517 /* 2/sqrt(pi) */ #define GLM_SQRT2 1.41421356237309504880168872420969808 /* sqrt(2) */ #define GLM_SQRT1_2 0.707106781186547524400844362104849039 /* 1/sqrt(2) */ #define GLM_Ef ((float)GLM_E) #define GLM_LOG2Ef ((float)GLM_LOG2E) #define GLM_LOG10Ef ((float)GLM_LOG10E) #define GLM_LN2f ((float)GLM_LN2) #define GLM_LN10f ((float)GLM_LN10) #define GLM_PIf ((float)GLM_PI) #define GLM_PI_2f ((float)GLM_PI_2) #define GLM_PI_4f ((float)GLM_PI_4) #define GLM_1_PIf ((float)GLM_1_PI) #define GLM_2_PIf ((float)GLM_2_PI) #define GLM_2_SQRTPIf ((float)GLM_2_SQRTPI) #define GLM_SQRT2f ((float)GLM_SQRT2) #define GLM_SQRT1_2f ((float)GLM_SQRT1_2) /* DEPRECATED! use GLM_PI and friends */ #define CGLM_PI GLM_PIf #define CGLM_PI_2 GLM_PI_2f #define CGLM_PI_4 GLM_PI_4f #endif /* cglm_types_h */ cglm-0.9.6/include/cglm/util.h000066400000000000000000000170471475344456400161740ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ /* Functions: CGLM_INLINE int glm_sign(int val); CGLM_INLINE float glm_signf(float val); CGLM_INLINE float glm_rad(float deg); CGLM_INLINE float glm_deg(float rad); CGLM_INLINE void glm_make_rad(float *deg); CGLM_INLINE void glm_make_deg(float *rad); CGLM_INLINE float glm_pow2(float x); CGLM_INLINE float glm_min(float a, float b); CGLM_INLINE float glm_max(float a, float b); CGLM_INLINE float glm_clamp(float val, float minVal, float maxVal); CGLM_INLINE float glm_clamp_zo(float val, float minVal, float maxVal); CGLM_INLINE float glm_lerp(float from, float to, float t); CGLM_INLINE float glm_lerpc(float from, float to, float t); CGLM_INLINE float glm_step(float edge, float x); CGLM_INLINE float glm_smooth(float t); CGLM_INLINE float glm_smoothstep(float edge0, float edge1, float x); CGLM_INLINE float glm_smoothinterp(float from, float to, float t); CGLM_INLINE float glm_smoothinterpc(float from, float to, float t); CGLM_INLINE bool glm_eq(float a, float b); CGLM_INLINE float glm_percent(float from, float to, float current); CGLM_INLINE float glm_percentc(float from, float to, float current); */ #ifndef cglm_util_h #define cglm_util_h #include "common.h" #define GLM_MIN(X, Y) (((X) < (Y)) ? (X) : (Y)) #define GLM_MAX(X, Y) (((X) > (Y)) ? (X) : (Y)) /*! * @brief get sign of 32 bit integer as +1, -1, 0 * * Important: It returns 0 for zero input * * @param val integer value */ CGLM_INLINE int glm_sign(int val) { return ((val >> 31) - (-val >> 31)); } /*! * @brief get sign of 32 bit float as +1, -1, 0 * * Important: It returns 0 for zero/NaN input * * @param val float value */ CGLM_INLINE float glm_signf(float val) { return (float)((val > 0.0f) - (val < 0.0f)); } /*! * @brief convert degree to radians * * @param[in] deg angle in degrees */ CGLM_INLINE float glm_rad(float deg) { return deg * GLM_PIf / 180.0f; } /*! * @brief convert radians to degree * * @param[in] rad angle in radians */ CGLM_INLINE float glm_deg(float rad) { return rad * 180.0f / GLM_PIf; } /*! * @brief convert existing degree to radians. this will override degrees value * * @param[in, out] deg pointer to angle in degrees */ CGLM_INLINE void glm_make_rad(float *deg) { *deg = *deg * GLM_PIf / 180.0f; } /*! * @brief convert existing radians to degree. this will override radians value * * @param[in, out] rad pointer to angle in radians */ CGLM_INLINE void glm_make_deg(float *rad) { *rad = *rad * 180.0f / GLM_PIf; } /*! * @brief multiplies given parameter with itself = x * x or powf(x, 2) * * @param[in] x x */ CGLM_INLINE float glm_pow2(float x) { return x * x; } /*! * @brief find minimum of given two values * * @param[in] a number 1 * @param[in] b number 2 */ CGLM_INLINE float glm_min(float a, float 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 */ CGLM_INLINE float glm_max(float a, float b) { if (a > b) return a; 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 * * @param[in] val value to clamp * @param[in] minVal minimum value * @param[in] maxVal maximum value */ CGLM_INLINE float glm_clamp(float val, float minVal, float maxVal) { return glm_min(glm_max(val, minVal), maxVal); } /*! * @brief clamp a number to zero and one * * @param[in] val value to clamp */ CGLM_INLINE float glm_clamp_zo(float val) { return glm_clamp(val, 0.0f, 1.0f); } /*! * @brief linear interpolation between two numbers * * formula: from + t * (to - from) * * @param[in] from from value * @param[in] to to value * @param[in] t interpolant (amount) */ CGLM_INLINE float glm_lerp(float from, float to, float t) { return from + t * (to - from); } /*! * @brief clamped linear interpolation between two numbers * * formula: from + t * (to - from) * * @param[in] from from value * @param[in] to to value * @param[in] t interpolant (amount) clamped between 0 and 1 */ CGLM_INLINE float glm_lerpc(float from, float to, float t) { return glm_lerp(from, to, glm_clamp_zo(t)); } /*! * @brief threshold function * * @param[in] edge threshold * @param[in] x value to test against threshold * @return returns 0.0 if x < edge, else 1.0 */ CGLM_INLINE float glm_step(float edge, float x) { /* branching - no type conversion */ return (x < edge) ? 0.0f : 1.0f; /* * An alternative implementation without branching * but with type conversion could be: * return !(x < edge); */ } /*! * @brief smooth Hermite interpolation * * formula: t^2 * (3-2t) * * @param[in] t interpolant (amount) */ CGLM_INLINE float glm_smooth(float t) { return t * t * (3.0f - 2.0f * t); } /*! * @brief threshold function with a smooth transition (according to OpenCL specs) * * formula: t^2 * (3-2t) * * @param[in] edge0 low threshold * @param[in] edge1 high threshold * @param[in] x interpolant (amount) */ CGLM_INLINE float glm_smoothstep(float edge0, float edge1, float x) { float t; t = glm_clamp_zo((x - edge0) / (edge1 - edge0)); return glm_smooth(t); } /*! * @brief smoothstep interpolation between two numbers * * formula: from + smoothstep(t) * (to - from) * * @param[in] from from value * @param[in] to to value * @param[in] t interpolant (amount) */ CGLM_INLINE float glm_smoothinterp(float from, float to, float t) { return from + glm_smooth(t) * (to - from); } /*! * @brief clamped smoothstep interpolation between two numbers * * formula: from + smoothstep(t) * (to - from) * * @param[in] from from value * @param[in] to to value * @param[in] t interpolant (amount) clamped between 0 and 1 */ CGLM_INLINE float glm_smoothinterpc(float from, float to, float t) { return glm_smoothinterp(from, to, glm_clamp_zo(t)); } /*! * @brief check if two float equal with using EPSILON * * @param[in] a a * @param[in] b b */ CGLM_INLINE bool glm_eq(float a, float b) { return fabsf(a - b) <= GLM_FLT_EPSILON; } /*! * @brief percentage of current value between start and end value * * maybe fraction could be alternative name. * * @param[in] from from value * @param[in] to to value * @param[in] current current value */ CGLM_INLINE float glm_percent(float from, float to, float current) { float t; if ((t = to - from) == 0.0f) return 1.0f; return (current - from) / t; } /*! * @brief clamped percentage of current value between start and end value * * @param[in] from from value * @param[in] to to value * @param[in] current current value */ CGLM_INLINE float glm_percentc(float from, float to, float current) { return glm_clamp_zo(glm_percent(from, to, current)); } /*! * @brief swap two float values * * @param[in] a float value 1 (pointer) * @param[in] b float value 2 (pointer) */ CGLM_INLINE void glm_swapf(float * __restrict a, float * __restrict b) { float t; t = *a; *a = *b; *b = t; } #endif /* cglm_util_h */ cglm-0.9.6/include/cglm/vec2-ext.h000066400000000000000000000162271475344456400166530ustar00rootroot00000000000000/* * 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_vec2_fill(vec2 v, float val) CGLM_INLINE bool glm_vec2_eq(vec2 v, float val); CGLM_INLINE bool glm_vec2_eq_eps(vec2 v, float val); CGLM_INLINE bool glm_vec2_eq_all(vec2 v); CGLM_INLINE bool glm_vec2_eqv(vec2 a, vec2 b); CGLM_INLINE bool glm_vec2_eqv_eps(vec2 a, vec2 b); CGLM_INLINE float glm_vec2_max(vec2 v); CGLM_INLINE float glm_vec2_min(vec2 v); CGLM_INLINE bool glm_vec2_isnan(vec2 v); CGLM_INLINE bool glm_vec2_isinf(vec2 v); CGLM_INLINE bool glm_vec2_isvalid(vec2 v); CGLM_INLINE void glm_vec2_sign(vec2 v, vec2 dest); CGLM_INLINE void glm_vec2_abs(vec2 v, vec2 dest); CGLM_INLINE void glm_vec2_fract(vec2 v, vec2 dest); CGLM_INLINE void glm_vec2_floor(vec2 v, vec2 dest); CGLM_INLINE float glm_vec2_mods(vec2 v, float s, vec2 dest); CGLM_INLINE float glm_vec2_steps(float edge, vec2 v, vec2 dest); CGLM_INLINE void glm_vec2_stepr(vec2 edge, float v, vec2 dest); CGLM_INLINE void glm_vec2_sqrt(vec2 v, vec2 dest); CGLM_INLINE void glm_vec2_complex_mul(vec2 a, vec2 b, vec2 dest) CGLM_INLINE void glm_vec2_complex_div(vec2 a, vec2 b, vec2 dest) CGLM_INLINE void glm_vec2_complex_conjugate(vec2 a, vec2 dest) */ #ifndef cglm_vec2_ext_h #define cglm_vec2_ext_h #include "common.h" #include "util.h" /*! * @brief fill a vector with specified value * * @param[out] v dest * @param[in] val value */ CGLM_INLINE void glm_vec2_fill(vec2 v, float val) { v[0] = v[1] = val; } /*! * @brief check if vector is equal to value (without epsilon) * * @param[in] v vector * @param[in] val value */ CGLM_INLINE bool glm_vec2_eq(vec2 v, float val) { return v[0] == val && v[0] == v[1]; } /*! * @brief check if vector is equal to value (with epsilon) * * @param[in] v vector * @param[in] val value */ CGLM_INLINE bool glm_vec2_eq_eps(vec2 v, float val) { return fabsf(v[0] - val) <= GLM_FLT_EPSILON && fabsf(v[1] - val) <= GLM_FLT_EPSILON; } /*! * @brief check if vector members are equal (without epsilon) * * @param[in] v vector */ CGLM_INLINE bool glm_vec2_eq_all(vec2 v) { return glm_vec2_eq_eps(v, v[0]); } /*! * @brief check if vector is equal to another (without epsilon) * * @param[in] a vector * @param[in] b vector */ CGLM_INLINE bool glm_vec2_eqv(vec2 a, vec2 b) { return a[0] == b[0] && a[1] == b[1]; } /*! * @brief check if vector is equal to another (with epsilon) * * @param[in] a vector * @param[in] b vector */ CGLM_INLINE bool glm_vec2_eqv_eps(vec2 a, vec2 b) { return fabsf(a[0] - b[0]) <= GLM_FLT_EPSILON && fabsf(a[1] - b[1]) <= GLM_FLT_EPSILON; } /*! * @brief max value of vector * * @param[in] v vector */ CGLM_INLINE float glm_vec2_max(vec2 v) { return glm_max(v[0], v[1]); } /*! * @brief min value of vector * * @param[in] v vector */ CGLM_INLINE float glm_vec2_min(vec2 v) { return glm_min(v[0], v[1]); } /*! * @brief check if one of items is NaN (not a number) * you should only use this in DEBUG mode or very critical asserts * * @param[in] v vector */ CGLM_INLINE bool glm_vec2_isnan(vec2 v) { #ifndef CGLM_FAST_MATH return isnan(v[0]) || isnan(v[1]); #else return false; #endif } /*! * @brief check if one of items is INFINITY * you should only use this in DEBUG mode or very critical asserts * * @param[in] v vector */ CGLM_INLINE bool glm_vec2_isinf(vec2 v) { #ifndef CGLM_FAST_MATH return isinf(v[0]) || isinf(v[1]); #else return false; #endif } /*! * @brief check if all items are valid number * you should only use this in DEBUG mode or very critical asserts * * @param[in] v vector */ CGLM_INLINE bool glm_vec2_isvalid(vec2 v) { return !glm_vec2_isnan(v) && !glm_vec2_isinf(v); } /*! * @brief get sign of 32 bit float as +1, -1, 0 * * Important: It returns 0 for zero/NaN input * * @param v vector */ CGLM_INLINE void glm_vec2_sign(vec2 v, vec2 dest) { dest[0] = glm_signf(v[0]); dest[1] = glm_signf(v[1]); } /*! * @brief absolute value of v * * @param[in] v vector * @param[out] dest destination */ CGLM_INLINE void glm_vec2_abs(vec2 v, vec2 dest) { dest[0] = fabsf(v[0]); dest[1] = fabsf(v[1]); } /*! * @brief fractional part of each vector item * * @param[in] v vector * @param[out] dest destination vector */ CGLM_INLINE void glm_vec2_fract(vec2 v, vec2 dest) { dest[0] = fminf(v[0] - floorf(v[0]), 0.999999940395355224609375f); dest[1] = fminf(v[1] - floorf(v[1]), 0.999999940395355224609375f); } /*! * @brief floor of each vector item * * @param[in] v vector * @param[out] dest destination vector */ CGLM_INLINE void glm_vec2_floor(vec2 v, vec2 dest) { dest[0] = floorf(v[0]); dest[1] = floorf(v[1]); } /*! * @brief mod of each vector item, result is written to dest (dest = v % s) * * @param[in] v vector * @param[in] s scalar * @param[out] dest destination vector */ CGLM_INLINE void glm_vec2_mods(vec2 v, float s, vec2 dest) { dest[0] = fmodf(v[0], s); dest[1] = fmodf(v[1], s); } /*! * @brief square root of each vector item * * @param[in] v vector * @param[out] dest destination vector */ CGLM_INLINE void glm_vec2_sqrt(vec2 v, vec2 dest) { dest[0] = sqrtf(v[0]); dest[1] = sqrtf(v[1]); } /*! * @brief treat vectors as complex numbers and multiply them as such. * * @param[in] a left number * @param[in] b right number * @param[out] dest destination number */ CGLM_INLINE void glm_vec2_complex_mul(vec2 a, vec2 b, vec2 dest) { float tr, ti; tr = a[0] * b[0] - a[1] * b[1]; ti = a[0] * b[1] + a[1] * b[0]; dest[0] = tr; dest[1] = ti; } /*! * @brief threshold each vector item with scalar * condition is: (x[i] < edge) ? 0.0 : 1.0 * * @param[in] edge threshold * @param[in] x vector to test against threshold * @param[out] dest destination */ CGLM_INLINE void glm_vec2_steps(float edge, vec2 x, vec2 dest) { dest[0] = glm_step(edge, x[0]); dest[1] = glm_step(edge, x[1]); } /*! * @brief threshold a value with *vector* as the threshold * condition is: (x < edge[i]) ? 0.0 : 1.0 * * @param[in] edge threshold vector * @param[in] x value to test against threshold * @param[out] dest destination */ CGLM_INLINE void glm_vec2_stepr(vec2 edge, float x, vec2 dest) { dest[0] = glm_step(edge[0], x); dest[1] = glm_step(edge[1], x); } /*! * @brief treat vectors as complex numbers and divide them as such. * * @param[in] a left number (numerator) * @param[in] b right number (denominator) * @param[out] dest destination number */ CGLM_INLINE void glm_vec2_complex_div(vec2 a, vec2 b, vec2 dest) { float tr, ti; float const ibnorm2 = 1.0f / (b[0] * b[0] + b[1] * b[1]); tr = ibnorm2 * (a[0] * b[0] + a[1] * b[1]); ti = ibnorm2 * (a[1] * b[0] - a[0] * b[1]); dest[0] = tr; dest[1] = ti; } /*! * @brief treat the vector as a complex number and conjugate it as such. * * @param[in] a the number * @param[out] dest destination number */ CGLM_INLINE void glm_vec2_complex_conjugate(vec2 a, vec2 dest) { dest[0] = a[0]; dest[1] = -a[1]; } #endif /* cglm_vec2_ext_h */ cglm-0.9.6/include/cglm/vec2.h000066400000000000000000000424661475344456400160610ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ /* Macros: GLM_VEC2_ONE_INIT GLM_VEC2_ZERO_INIT GLM_VEC2_ONE GLM_VEC2_ZERO Functions: CGLM_INLINE void glm_vec2(float * __restrict v, vec2 dest) CGLM_INLINE void glm_vec2_copy(vec2 a, vec2 dest) CGLM_INLINE void glm_vec2_zero(vec2 v) CGLM_INLINE void glm_vec2_one(vec2 v) CGLM_INLINE float glm_vec2_dot(vec2 a, vec2 b) CGLM_INLINE float glm_vec2_cross(vec2 a, vec2 b) CGLM_INLINE float glm_vec2_norm2(vec2 v) CGLM_INLINE float glm_vec2_norm(vec2 vec) CGLM_INLINE void glm_vec2_add(vec2 a, vec2 b, vec2 dest) CGLM_INLINE void glm_vec2_adds(vec2 v, float s, vec2 dest) CGLM_INLINE void glm_vec2_sub(vec2 a, vec2 b, vec2 dest) CGLM_INLINE void glm_vec2_subs(vec2 v, float s, vec2 dest) CGLM_INLINE void glm_vec2_mul(vec2 a, vec2 b, vec2 d) CGLM_INLINE void glm_vec2_scale(vec2 v, float s, vec2 dest) CGLM_INLINE void glm_vec2_scale_as(vec2 v, float s, vec2 dest) CGLM_INLINE void glm_vec2_div(vec2 a, vec2 b, vec2 dest) CGLM_INLINE void glm_vec2_divs(vec2 v, float s, vec2 dest) CGLM_INLINE void glm_vec2_addadd(vec2 a, vec2 b, vec2 dest) CGLM_INLINE void glm_vec2_subadd(vec2 a, vec2 b, vec2 dest) CGLM_INLINE void glm_vec2_muladd(vec2 a, vec2 b, 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_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(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_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_distance(vec2 a, vec2 b) CGLM_INLINE void glm_vec2_maxv(vec2 v1, vec2 v2, vec2 dest) CGLM_INLINE void glm_vec2_minv(vec2 v1, vec2 v2, vec2 dest) CGLM_INLINE void glm_vec2_clamp(vec2 v, float minVal, float maxVal) CGLM_INLINE void glm_vec2_swizzle(vec2 v, int mask, vec2 dest) CGLM_INLINE void glm_vec2_lerp(vec2 from, vec2 to, float t, vec2 dest) CGLM_INLINE void glm_vec2_step(vec2 edge, vec2 x, vec2 dest) CGLM_INLINE void glm_vec2_make(float * restrict src, vec2 dest) CGLM_INLINE void glm_vec2_reflect(vec2 v, vec2 n, vec2 dest) CGLM_INLINE void glm_vec2_refract(vec2 v, vec2 n, float eta, vec2 dest) */ #ifndef cglm_vec2_h #define cglm_vec2_h #include "common.h" #include "util.h" #include "vec2-ext.h" #define GLM_VEC2_ONE_INIT {1.0f, 1.0f} #define GLM_VEC2_ZERO_INIT {0.0f, 0.0f} #define GLM_VEC2_ONE ((vec2)GLM_VEC2_ONE_INIT) #define GLM_VEC2_ZERO ((vec2)GLM_VEC2_ZERO_INIT) /*! * @brief init vec2 using another vector * * @param[in] v a vector * @param[out] dest destination */ CGLM_INLINE void glm_vec2(float * __restrict v, vec2 dest) { dest[0] = v[0]; dest[1] = v[1]; } /*! * @brief copy all members of [a] to [dest] * * @param[in] a source * @param[out] dest destination */ CGLM_INLINE void glm_vec2_copy(vec2 a, vec2 dest) { dest[0] = a[0]; dest[1] = a[1]; } /*! * @brief make vector zero * * @param[in, out] v vector */ CGLM_INLINE void glm_vec2_zero(vec2 v) { v[0] = v[1] = 0.0f; } /*! * @brief make vector one * * @param[in, out] v vector */ CGLM_INLINE void glm_vec2_one(vec2 v) { v[0] = v[1] = 1.0f; } /*! * @brief vec2 dot product * * @param[in] a vector1 * @param[in] b vector2 * * @return dot product */ CGLM_INLINE float glm_vec2_dot(vec2 a, vec2 b) { return a[0] * b[0] + a[1] * b[1]; } /*! * @brief vec2 cross product * * REF: http://allenchou.net/2013/07/cross-product-of-2d-vectors/ * * @param[in] a vector1 * @param[in] b vector2 * * @return Z component of cross product */ CGLM_INLINE float glm_vec2_cross(vec2 a, vec2 b) { /* just calculate the z-component */ return a[0] * b[1] - a[1] * b[0]; } /*! * @brief norm * norm (magnitude) of vec * * we can use this func instead of calling norm * norm, because it would call * sqrtf function twice but with this func we can avoid func call, maybe this is * not good name for this func * * @param[in] v vector * * @return norm * norm */ CGLM_INLINE float glm_vec2_norm2(vec2 v) { return glm_vec2_dot(v, v); } /*! * @brief norm (magnitude) of vec2 * * @param[in] vec vector * * @return norm */ CGLM_INLINE float glm_vec2_norm(vec2 vec) { return sqrtf(glm_vec2_norm2(vec)); } /*! * @brief add a vector to b vector store result in dest * * @param[in] a vector1 * @param[in] b vector2 * @param[out] dest destination vector */ CGLM_INLINE void glm_vec2_add(vec2 a, vec2 b, vec2 dest) { dest[0] = a[0] + b[0]; dest[1] = a[1] + b[1]; } /*! * @brief add scalar to v vector store result in dest (d = v + s) * * @param[in] v vector * @param[in] s scalar * @param[out] dest destination vector */ CGLM_INLINE void glm_vec2_adds(vec2 v, float s, vec2 dest) { dest[0] = v[0] + s; dest[1] = v[1] + s; } /*! * @brief subtract b vector from a vector store result in dest * * @param[in] a vector1 * @param[in] b vector2 * @param[out] dest destination vector */ CGLM_INLINE void glm_vec2_sub(vec2 a, vec2 b, vec2 dest) { dest[0] = a[0] - b[0]; dest[1] = a[1] - b[1]; } /*! * @brief subtract scalar from v vector store result in dest (d = v - s) * * @param[in] v vector * @param[in] s scalar * @param[out] dest destination vector */ CGLM_INLINE void glm_vec2_subs(vec2 v, float s, vec2 dest) { dest[0] = v[0] - s; dest[1] = v[1] - s; } /*! * @brief multiply two vectors (component-wise multiplication) * * @param a v1 * @param b v2 * @param dest v3 = (a[0] * b[0], a[1] * b[1]) */ CGLM_INLINE void glm_vec2_mul(vec2 a, vec2 b, vec2 dest) { dest[0] = a[0] * b[0]; dest[1] = a[1] * b[1]; } /*! * @brief multiply/scale vector with scalar: result = v * s * * @param[in] v vector * @param[in] s scalar * @param[out] dest destination vector */ CGLM_INLINE void glm_vec2_scale(vec2 v, float s, vec2 dest) { dest[0] = v[0] * s; dest[1] = v[1] * s; } /*! * @brief scale as vector specified: result = unit(v) * s * * @param[in] v vector * @param[in] s scalar * @param[out] dest destination vector */ CGLM_INLINE void glm_vec2_scale_as(vec2 v, float s, vec2 dest) { float norm; norm = glm_vec2_norm(v); if (CGLM_UNLIKELY(norm < FLT_EPSILON)) { glm_vec2_zero(dest); return; } glm_vec2_scale(v, s / norm, dest); } /*! * @brief div vector with another component-wise division: d = a / b * * @param[in] a vector 1 * @param[in] b vector 2 * @param[out] dest result = (a[0]/b[0], a[1]/b[1]) */ CGLM_INLINE void glm_vec2_div(vec2 a, vec2 b, vec2 dest) { dest[0] = a[0] / b[0]; dest[1] = a[1] / b[1]; } /*! * @brief div vector with scalar: d = v / s * * @param[in] v vector * @param[in] s scalar * @param[out] dest result = (a[0]/s, a[1]/s) */ CGLM_INLINE void glm_vec2_divs(vec2 v, float s, vec2 dest) { dest[0] = v[0] / s; dest[1] = v[1] / s; } /*! * @brief add two vectors and add result to sum * * 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_addadd(vec2 a, vec2 b, vec2 dest) { dest[0] += a[0] + b[0]; dest[1] += a[1] + b[1]; } /*! * @brief sub two vectors and add 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_subadd(vec2 a, vec2 b, vec2 dest) { dest[0] += a[0] - b[0]; dest[1] += a[1] - b[1]; } /*! * @brief mul two vectors and add 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_muladd(vec2 a, vec2 b, vec2 dest) { dest[0] += a[0] * b[0]; dest[1] += a[1] * b[1]; } /*! * @brief mul vector with scalar and add 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_muladds(vec2 a, float s, vec2 dest) { dest[0] += a[0] * s; dest[1] += a[1] * s; } /*! * @brief add 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_maxadd(vec2 a, vec2 b, vec2 dest) { dest[0] += glm_max(a[0], b[0]); dest[1] += glm_max(a[1], b[1]); } /*! * @brief add 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_minadd(vec2 a, vec2 b, vec2 dest) { dest[0] += glm_min(a[0], b[0]); 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 * * @param[in] v vector * @param[out] dest result vector */ CGLM_INLINE void glm_vec2_negate_to(vec2 v, vec2 dest) { dest[0] = -v[0]; dest[1] = -v[1]; } /*! * @brief negate vector components * * @param[in, out] v vector */ CGLM_INLINE void glm_vec2_negate(vec2 v) { glm_vec2_negate_to(v, v); } /*! * @brief normalize vector and store result in same vec * * @param[in, out] v vector */ CGLM_INLINE void glm_vec2_normalize(vec2 v) { float norm; norm = glm_vec2_norm(v); if (CGLM_UNLIKELY(norm < FLT_EPSILON)) { v[0] = v[1] = 0.0f; return; } glm_vec2_scale(v, 1.0f / norm, v); } /*! * @brief normalize vector to dest * * @param[in] v source * @param[out] dest destination */ CGLM_INLINE void glm_vec2_normalize_to(vec2 v, vec2 dest) { float norm; norm = glm_vec2_norm(v); if (CGLM_UNLIKELY(norm < FLT_EPSILON)) { glm_vec2_zero(dest); return; } glm_vec2_scale(v, 1.0f / norm, dest); } /*! * @brief rotate vec2 around origin by angle (CCW: counterclockwise) * * Formula: * 𝑥2 = cos(a)𝑥1 − sin(a)𝑦1 * 𝑦2 = sin(a)𝑥1 + cos(a)𝑦1 * * @param[in] v vector to rotate * @param[in] angle angle by radians * @param[out] dest destination vector */ CGLM_INLINE void glm_vec2_rotate(vec2 v, float angle, vec2 dest) { float c, s, x1, y1; c = cosf(angle); s = sinf(angle); x1 = v[0]; y1 = v[1]; dest[0] = c * x1 - s * 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 * * @param[in] a vector1 * @param[in] b vector2 * @return returns squared distance (distance * distance) */ CGLM_INLINE float glm_vec2_distance2(vec2 a, vec2 b) { return glm_pow2(b[0] - a[0]) + glm_pow2(b[1] - a[1]); } /** * @brief distance between two vectors * * @param[in] a vector1 * @param[in] b vector2 * @return returns distance */ CGLM_INLINE float glm_vec2_distance(vec2 a, vec2 b) { return sqrtf(glm_vec2_distance2(a, b)); } /*! * @brief max values of vectors * * @param[in] a vector1 * @param[in] b vector2 * @param[out] dest destination */ CGLM_INLINE void glm_vec2_maxv(vec2 a, vec2 b, vec2 dest) { dest[0] = glm_max(a[0], b[0]); dest[1] = glm_max(a[1], b[1]); } /*! * @brief min values of vectors * * @param[in] a vector1 * @param[in] b vector2 * @param[out] dest destination */ CGLM_INLINE void glm_vec2_minv(vec2 a, vec2 b, vec2 dest) { dest[0] = glm_min(a[0], b[0]); dest[1] = glm_min(a[1], b[1]); } /*! * @brief clamp vector's individual members between min and max values * * @param[in, out] v vector * @param[in] minval minimum value * @param[in] maxval maximum value */ CGLM_INLINE void glm_vec2_clamp(vec2 v, float minval, float maxval) { v[0] = glm_clamp(v[0], minval, maxval); v[1] = glm_clamp(v[1], minval, maxval); } /*! * @brief swizzle vector components * * @param[in] v source * @param[in] mask mask * @param[out] dest destination */ CGLM_INLINE void glm_vec2_swizzle(vec2 v, int mask, vec2 dest) { vec2 t; t[0] = v[(mask & (3 << 0))]; t[1] = v[(mask & (3 << 2)) >> 2]; glm_vec2_copy(t, dest); } /*! * @brief linear interpolation between two vector * * formula: from + s * (to - from) * * @param[in] from from value * @param[in] to to value * @param[in] t interpolant (amount) clamped between 0 and 1 * @param[out] dest destination */ CGLM_INLINE void glm_vec2_lerp(vec2 from, vec2 to, float t, vec2 dest) { vec2 s, v; /* from + s * (to - from) */ glm_vec2_fill(s, glm_clamp_zo(t)); glm_vec2_sub(to, from, v); glm_vec2_mul(s, v, v); glm_vec2_add(from, v, dest); } /*! * @brief threshold function * * @param[in] edge threshold * @param[in] x value to test against threshold * @param[out] dest destination */ CGLM_INLINE void glm_vec2_step(vec2 edge, vec2 x, vec2 dest) { dest[0] = glm_step(edge[0], x[0]); dest[1] = glm_step(edge[1], x[1]); } /*! * @brief Create two dimensional vector from pointer * * @param[in] src pointer to an array of floats * @param[out] dest destination vector */ CGLM_INLINE void glm_vec2_make(const float * __restrict src, vec2 dest) { dest[0] = src[0]; dest[1] = src[1]; } /*! * @brief reflection vector using an incident ray and a surface normal * * @param[in] v incident vector * @param[in] n normalized normal vector * @param[out] dest destination vector for the reflection result */ CGLM_INLINE void glm_vec2_reflect(vec2 v, vec2 n, vec2 dest) { vec2 temp; glm_vec2_scale(n, 2.0f * glm_vec2_dot(v, n), temp); glm_vec2_sub(v, temp, dest); } /*! * @brief computes refraction vector for an incident vector and a surface normal. * * calculates the refraction vector based on Snell's law. If total internal reflection * occurs (angle too great given eta), dest is set to zero and returns false. * Otherwise, computes refraction vector, stores it in dest, and returns true. * * @param[in] v normalized incident vector * @param[in] n normalized normal vector * @param[in] eta ratio of indices of refraction (incident/transmitted) * @param[out] dest refraction vector if refraction occurs; zero vector otherwise * * @returns true if refraction occurs; false if total internal reflection occurs. */ CGLM_INLINE bool glm_vec2_refract(vec2 v, vec2 n, float eta, vec2 dest) { float ndi, eni, k; ndi = glm_vec2_dot(n, v); eni = eta * ndi; k = 1.0f - eta * eta + eni * eni; if (k < 0.0f) { glm_vec2_zero(dest); return false; } glm_vec2_scale(v, eta, dest); glm_vec2_mulsubs(n, eni + sqrtf(k), dest); return true; } #endif /* cglm_vec2_h */ cglm-0.9.6/include/cglm/vec3-ext.h000066400000000000000000000160501475344456400166460ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ /*! * @brief SIMD like functions */ /* Functions: CGLM_INLINE void glm_vec3_broadcast(float val, vec3 d); CGLM_INLINE void glm_vec3_fill(vec3 v, float val); CGLM_INLINE bool glm_vec3_eq(vec3 v, float val); CGLM_INLINE bool glm_vec3_eq_eps(vec3 v, float val); CGLM_INLINE bool glm_vec3_eq_all(vec3 v); CGLM_INLINE bool glm_vec3_eqv(vec3 a, vec3 b); CGLM_INLINE bool glm_vec3_eqv_eps(vec3 a, vec3 b); CGLM_INLINE float glm_vec3_max(vec3 v); CGLM_INLINE float glm_vec3_min(vec3 v); CGLM_INLINE bool glm_vec3_isnan(vec3 v); CGLM_INLINE bool glm_vec3_isinf(vec3 v); CGLM_INLINE bool glm_vec3_isvalid(vec3 v); CGLM_INLINE void glm_vec3_sign(vec3 v, vec3 dest); CGLM_INLINE void glm_vec3_abs(vec3 v, vec3 dest); CGLM_INLINE void glm_vec3_fract(vec3 v, vec3 dest); CGLM_INLINE void glm_vec3_floor(vec3 v, vec3 dest); CGLM_INLINE float glm_vec3_mods(vec3 v, float s, vec3 dest); CGLM_INLINE float glm_vec3_steps(float edge, vec3 v, vec3 dest); CGLM_INLINE void glm_vec3_stepr(vec3 edge, float v, vec3 dest); CGLM_INLINE float glm_vec3_hadd(vec3 v); CGLM_INLINE void glm_vec3_sqrt(vec3 v, vec3 dest); */ #ifndef cglm_vec3_ext_h #define cglm_vec3_ext_h #include "common.h" #include "util.h" /*! * @brief fill a vector with specified value * * @param[in] val value * @param[out] d dest */ CGLM_INLINE void glm_vec3_broadcast(float val, vec3 d) { d[0] = d[1] = d[2] = val; } /*! * @brief fill a vector with specified value * * @param[out] v dest * @param[in] val value */ CGLM_INLINE void glm_vec3_fill(vec3 v, float val) { v[0] = v[1] = v[2] = val; } /*! * @brief check if vector is equal to value (without epsilon) * * @param[in] v vector * @param[in] val value */ CGLM_INLINE bool glm_vec3_eq(vec3 v, float val) { return v[0] == val && v[0] == v[1] && v[0] == v[2]; } /*! * @brief check if vector is equal to value (with epsilon) * * @param[in] v vector * @param[in] val value */ CGLM_INLINE bool glm_vec3_eq_eps(vec3 v, float val) { return fabsf(v[0] - val) <= GLM_FLT_EPSILON && fabsf(v[1] - val) <= GLM_FLT_EPSILON && fabsf(v[2] - val) <= GLM_FLT_EPSILON; } /*! * @brief check if vector members are equal (without epsilon) * * @param[in] v vector */ CGLM_INLINE bool glm_vec3_eq_all(vec3 v) { return glm_vec3_eq_eps(v, v[0]); } /*! * @brief check if vector is equal to another (without epsilon) * * @param[in] a vector * @param[in] b vector */ CGLM_INLINE bool glm_vec3_eqv(vec3 a, vec3 b) { return a[0] == b[0] && a[1] == b[1] && a[2] == b[2]; } /*! * @brief check if vector is equal to another (with epsilon) * * @param[in] a vector * @param[in] b vector */ CGLM_INLINE bool glm_vec3_eqv_eps(vec3 a, vec3 b) { return fabsf(a[0] - b[0]) <= GLM_FLT_EPSILON && fabsf(a[1] - b[1]) <= GLM_FLT_EPSILON && fabsf(a[2] - b[2]) <= GLM_FLT_EPSILON; } /*! * @brief max value of vector * * @param[in] v vector */ CGLM_INLINE float glm_vec3_max(vec3 v) { float max; max = v[0]; if (v[1] > max) max = v[1]; if (v[2] > max) max = v[2]; return max; } /*! * @brief min value of vector * * @param[in] v vector */ CGLM_INLINE float glm_vec3_min(vec3 v) { float min; min = v[0]; if (v[1] < min) min = v[1]; if (v[2] < min) min = v[2]; return min; } /*! * @brief check if one of items is NaN (not a number) * you should only use this in DEBUG mode or very critical asserts * * @param[in] v vector */ CGLM_INLINE bool glm_vec3_isnan(vec3 v) { #ifndef CGLM_FAST_MATH return isnan(v[0]) || isnan(v[1]) || isnan(v[2]); #else return false; #endif } /*! * @brief check if one of items is INFINITY * you should only use this in DEBUG mode or very critical asserts * * @param[in] v vector */ CGLM_INLINE bool glm_vec3_isinf(vec3 v) { #ifndef CGLM_FAST_MATH return isinf(v[0]) || isinf(v[1]) || isinf(v[2]); #else return false; #endif } /*! * @brief check if all items are valid number * you should only use this in DEBUG mode or very critical asserts * * @param[in] v vector */ CGLM_INLINE bool glm_vec3_isvalid(vec3 v) { return !glm_vec3_isnan(v) && !glm_vec3_isinf(v); } /*! * @brief get sign of 32 bit float as +1, -1, 0 * * Important: It returns 0 for zero/NaN input * * @param v vector */ CGLM_INLINE void glm_vec3_sign(vec3 v, vec3 dest) { dest[0] = glm_signf(v[0]); dest[1] = glm_signf(v[1]); dest[2] = glm_signf(v[2]); } /*! * @brief absolute value of each vector item * * @param[in] v vector * @param[out] dest destination vector */ CGLM_INLINE void glm_vec3_abs(vec3 v, vec3 dest) { dest[0] = fabsf(v[0]); dest[1] = fabsf(v[1]); dest[2] = fabsf(v[2]); } /*! * @brief fractional part of each vector item * * @param[in] v vector * @param[out] dest destination vector */ CGLM_INLINE void glm_vec3_fract(vec3 v, vec3 dest) { dest[0] = fminf(v[0] - floorf(v[0]), 0.999999940395355224609375f); dest[1] = fminf(v[1] - floorf(v[1]), 0.999999940395355224609375f); dest[2] = fminf(v[2] - floorf(v[2]), 0.999999940395355224609375f); } /*! * @brief floor of each vector item * * @param[in] v vector * @param[out] dest destination vector */ CGLM_INLINE void glm_vec3_floor(vec3 v, vec3 dest) { dest[0] = floorf(v[0]); dest[1] = floorf(v[1]); dest[2] = floorf(v[2]); } /*! * @brief mod of each vector item, result is written to dest (dest = v % s) * * @param[in] v vector * @param[in] s scalar * @param[out] dest destination vector */ CGLM_INLINE void glm_vec3_mods(vec3 v, float s, vec3 dest) { dest[0] = fmodf(v[0], s); dest[1] = fmodf(v[1], s); dest[2] = fmodf(v[2], s); } /*! * @brief threshold each vector item with scalar * condition is: (x[i] < edge) ? 0.0 : 1.0 * * @param[in] edge threshold * @param[in] x vector to test against threshold * @param[out] dest destination */ CGLM_INLINE void glm_vec3_steps(float edge, vec3 x, vec3 dest) { dest[0] = glm_step(edge, x[0]); dest[1] = glm_step(edge, x[1]); dest[2] = glm_step(edge, x[2]); } /*! * @brief threshold a value with *vector* as the threshold * condition is: (x < edge[i]) ? 0.0 : 1.0 * * @param[in] edge threshold vector * @param[in] x value to test against threshold * @param[out] dest destination */ CGLM_INLINE void glm_vec3_stepr(vec3 edge, float x, vec3 dest) { dest[0] = glm_step(edge[0], x); dest[1] = glm_step(edge[1], x); dest[2] = glm_step(edge[2], x); } /*! * @brief vector reduction by summation * @warning could overflow * * @param[in] v vector * @return sum of all vector's elements */ CGLM_INLINE float glm_vec3_hadd(vec3 v) { return v[0] + v[1] + v[2]; } /*! * @brief square root of each vector item * * @param[in] v vector * @param[out] dest destination vector */ CGLM_INLINE void glm_vec3_sqrt(vec3 v, vec3 dest) { dest[0] = sqrtf(v[0]); dest[1] = sqrtf(v[1]); dest[2] = sqrtf(v[2]); } #endif /* cglm_vec3_ext_h */ cglm-0.9.6/include/cglm/vec3.h000066400000000000000000000717441475344456400160630ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ /* Macros: GLM_VEC3_ONE_INIT GLM_VEC3_ZERO_INIT GLM_VEC3_ONE GLM_VEC3_ZERO GLM_YUP GLM_ZUP GLM_XUP Functions: CGLM_INLINE void glm_vec3(vec4 v4, vec3 dest); CGLM_INLINE void glm_vec3_copy(vec3 a, vec3 dest); CGLM_INLINE void glm_vec3_zero(vec3 v); CGLM_INLINE void glm_vec3_one(vec3 v); CGLM_INLINE float glm_vec3_dot(vec3 a, vec3 b); CGLM_INLINE float glm_vec3_norm2(vec3 v); CGLM_INLINE float glm_vec3_norm(vec3 v); CGLM_INLINE float glm_vec3_norm_one(vec3 v); CGLM_INLINE float glm_vec3_norm_inf(vec3 v); CGLM_INLINE void glm_vec3_add(vec3 a, vec3 b, vec3 dest); CGLM_INLINE void glm_vec3_adds(vec3 a, float s, vec3 dest); CGLM_INLINE void glm_vec3_sub(vec3 a, vec3 b, vec3 dest); CGLM_INLINE void glm_vec3_subs(vec3 a, float s, vec3 dest); CGLM_INLINE void glm_vec3_mul(vec3 a, vec3 b, vec3 dest); CGLM_INLINE void glm_vec3_scale(vec3 v, float s, vec3 dest); CGLM_INLINE void glm_vec3_scale_as(vec3 v, float s, vec3 dest); CGLM_INLINE void glm_vec3_div(vec3 a, vec3 b, vec3 dest); CGLM_INLINE void glm_vec3_divs(vec3 a, float s, vec3 dest); CGLM_INLINE void glm_vec3_addadd(vec3 a, vec3 b, vec3 dest); CGLM_INLINE void glm_vec3_subadd(vec3 a, vec3 b, vec3 dest); CGLM_INLINE void glm_vec3_muladd(vec3 a, vec3 b, 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_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_to(vec3 v, vec3 dest); CGLM_INLINE void glm_vec3_negate_to(vec3 v, vec3 dest); CGLM_INLINE void glm_vec3_negate(vec3 v); CGLM_INLINE void glm_vec3_inv(vec3 v); CGLM_INLINE void glm_vec3_inv_to(vec3 v, vec3 dest); CGLM_INLINE void glm_vec3_normalize(vec3 v); CGLM_INLINE void glm_vec3_normalize_to(vec3 v, vec3 dest); CGLM_INLINE void glm_vec3_cross(vec3 a, vec3 b, vec3 d); CGLM_INLINE void glm_vec3_crossn(vec3 a, vec3 b, vec3 dest); CGLM_INLINE float glm_vec3_angle(vec3 a, vec3 b); CGLM_INLINE void glm_vec3_rotate(vec3 v, float angle, vec3 axis); CGLM_INLINE void glm_vec3_rotate_m4(mat4 m, vec3 v, vec3 dest); CGLM_INLINE void glm_vec3_rotate_m3(mat3 m, vec3 v, vec3 dest); CGLM_INLINE void glm_vec3_proj(vec3 a, vec3 b, vec3 dest); CGLM_INLINE void glm_vec3_center(vec3 a, vec3 b, vec3 dest); CGLM_INLINE float glm_vec3_distance(vec3 a, vec3 b); CGLM_INLINE float glm_vec3_distance2(vec3 a, vec3 b); CGLM_INLINE void glm_vec3_maxv(vec3 a, vec3 b, vec3 dest); CGLM_INLINE void glm_vec3_minv(vec3 a, vec3 b, vec3 dest); CGLM_INLINE void glm_vec3_ortho(vec3 v, vec3 dest); CGLM_INLINE void glm_vec3_clamp(vec3 v, float minVal, float maxVal); CGLM_INLINE void glm_vec3_lerp(vec3 from, vec3 to, float t, vec3 dest); CGLM_INLINE void glm_vec3_lerpc(vec3 from, vec3 to, float t, vec3 dest); CGLM_INLINE void glm_vec3_mix(vec3 from, vec3 to, float t, vec3 dest); CGLM_INLINE void glm_vec3_mixc(vec3 from, vec3 to, float t, vec3 dest); CGLM_INLINE void glm_vec3_step(vec3 edge, vec3 x, vec3 dest); CGLM_INLINE void glm_vec3_smoothstep_uni(float edge0, float edge1, vec3 x, vec3 dest); CGLM_INLINE void glm_vec3_smoothstep(vec3 edge0, vec3 edge1, vec3 x, vec3 dest); CGLM_INLINE void glm_vec3_smoothinterp(vec3 from, vec3 to, float t, vec3 dest); CGLM_INLINE void glm_vec3_smoothinterpc(vec3 from, vec3 to, float t, vec3 dest); CGLM_INLINE void glm_vec3_swizzle(vec3 v, int mask, vec3 dest); CGLM_INLINE void glm_vec3_make(float * restrict src, vec3 dest); CGLM_INLINE void glm_vec3_faceforward(vec3 n, vec3 v, vec3 nref, vec3 dest); CGLM_INLINE void glm_vec3_reflect(vec3 v, vec3 n, vec3 dest); CGLM_INLINE void glm_vec3_refract(vec3 v, vec3 n, float eta, vec3 dest); Convenient: CGLM_INLINE void glm_cross(vec3 a, vec3 b, vec3 d); CGLM_INLINE float glm_dot(vec3 a, vec3 b); CGLM_INLINE void glm_normalize(vec3 v); CGLM_INLINE void glm_normalize_to(vec3 v, vec3 dest); DEPRECATED: glm_vec3_dup glm_vec3_flipsign glm_vec3_flipsign_to glm_vec3_inv glm_vec3_inv_to glm_vec3_mulv glm_vec3_step_uni --> use glm_vec3_steps */ #ifndef cglm_vec3_h #define cglm_vec3_h #include "common.h" #include "vec4.h" #include "vec3-ext.h" #include "util.h" /* DEPRECATED! use _copy, _ucopy versions */ #define glm_vec3_dup(v, dest) glm_vec3_copy(v, dest) #define glm_vec3_flipsign(v) glm_vec3_negate(v) #define glm_vec3_flipsign_to(v, dest) glm_vec3_negate_to(v, dest) #define glm_vec3_inv(v) glm_vec3_negate(v) #define glm_vec3_inv_to(v, dest) glm_vec3_negate_to(v, dest) #define glm_vec3_mulv(a, b, d) glm_vec3_mul(a, b, d) #define glm_vec3_step_uni(edge, x, dest) glm_vec3_steps(edge, x, dest) #define GLM_VEC3_ONE_INIT {1.0f, 1.0f, 1.0f} #define GLM_VEC3_ZERO_INIT {0.0f, 0.0f, 0.0f} #define GLM_VEC3_ONE ((vec3)GLM_VEC3_ONE_INIT) #define GLM_VEC3_ZERO ((vec3)GLM_VEC3_ZERO_INIT) #define GLM_YUP ((vec3){0.0f, 1.0f, 0.0f}) #define GLM_ZUP ((vec3){0.0f, 0.0f, 1.0f}) #define GLM_XUP ((vec3){1.0f, 0.0f, 0.0f}) #define GLM_FORWARD ((vec3){0.0f, 0.0f, -1.0f}) #define GLM_XXX GLM_SHUFFLE3(0, 0, 0) #define GLM_YYY GLM_SHUFFLE3(1, 1, 1) #define GLM_ZZZ GLM_SHUFFLE3(2, 2, 2) #define GLM_ZYX GLM_SHUFFLE3(0, 1, 2) /*! * @brief init vec3 using vec4 * * @param[in] v4 vector4 * @param[out] dest destination */ CGLM_INLINE void glm_vec3(vec4 v4, vec3 dest) { dest[0] = v4[0]; dest[1] = v4[1]; dest[2] = v4[2]; } /*! * @brief copy all members of [a] to [dest] * * @param[in] a source * @param[out] dest destination */ CGLM_INLINE void glm_vec3_copy(vec3 a, vec3 dest) { dest[0] = a[0]; dest[1] = a[1]; dest[2] = a[2]; } /*! * @brief make vector zero * * @param[in, out] v vector */ CGLM_INLINE void glm_vec3_zero(vec3 v) { v[0] = v[1] = v[2] = 0.0f; } /*! * @brief make vector one * * @param[in, out] v vector */ CGLM_INLINE void glm_vec3_one(vec3 v) { v[0] = v[1] = v[2] = 1.0f; } /*! * @brief vec3 dot product * * @param[in] a vector1 * @param[in] b vector2 * * @return dot product */ CGLM_INLINE float glm_vec3_dot(vec3 a, vec3 b) { return a[0] * b[0] + a[1] * b[1] + a[2] * b[2]; } /*! * @brief norm * norm (magnitude) of vec * * we can use this func instead of calling norm * norm, because it would call * sqrtf function twice but with this func we can avoid func call, maybe this is * not good name for this func * * @param[in] v vector * * @return norm * norm */ CGLM_INLINE float glm_vec3_norm2(vec3 v) { return glm_vec3_dot(v, v); } /*! * @brief euclidean norm (magnitude), also called L2 norm * this will give magnitude of vector in euclidean space * * @param[in] v vector * * @return norm */ CGLM_INLINE float glm_vec3_norm(vec3 v) { return sqrtf(glm_vec3_norm2(v)); } /*! * @brief L1 norm of vec3 * Also known as Manhattan Distance or Taxicab norm. * L1 Norm is the sum of the magnitudes of the vectors in a space. * It is calculated as the sum of the absolute values of the vector components. * In this norm, all the components of the vector are weighted equally. * * This computes: * R = |v[0]| + |v[1]| + |v[2]| * * @param[in] v vector * * @return L1 norm */ CGLM_INLINE float glm_vec3_norm_one(vec3 v) { vec3 t; glm_vec3_abs(v, t); return glm_vec3_hadd(t); } /*! * @brief infinity norm of vec3 * Also known as Maximum norm. * Infinity Norm is the largest magnitude among each element of a vector. * It is calculated as the maximum of the absolute values of the vector components. * * This computes: * inf norm = max(|v[0]|, |v[1]|, |v[2]|) * * @param[in] v vector * * @return infinity norm */ CGLM_INLINE float glm_vec3_norm_inf(vec3 v) { vec3 t; glm_vec3_abs(v, t); return glm_vec3_max(t); } /*! * @brief add a vector to b vector store result in dest * * @param[in] a vector1 * @param[in] b vector2 * @param[out] dest destination vector */ CGLM_INLINE void glm_vec3_add(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 scalar to v vector store result in dest (d = v + s) * * @param[in] v vector * @param[in] s scalar * @param[out] dest destination vector */ CGLM_INLINE void glm_vec3_adds(vec3 v, float s, vec3 dest) { dest[0] = v[0] + s; dest[1] = v[1] + s; dest[2] = v[2] + s; } /*! * @brief subtract b vector from a vector store result in dest * * @param[in] a vector1 * @param[in] b vector2 * @param[out] dest destination vector */ CGLM_INLINE void glm_vec3_sub(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 subtract scalar from v vector store result in dest (d = v - s) * * @param[in] v vector * @param[in] s scalar * @param[out] dest destination vector */ CGLM_INLINE void glm_vec3_subs(vec3 v, float s, vec3 dest) { dest[0] = v[0] - s; dest[1] = v[1] - s; dest[2] = v[2] - s; } /*! * @brief multiply two vectors (component-wise multiplication) * * @param a vector1 * @param b vector2 * @param dest v3 = (a[0] * b[0], a[1] * b[1], a[2] * b[2]) */ CGLM_INLINE void glm_vec3_mul(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 multiply/scale vec3 vector with scalar: result = v * s * * @param[in] v vector * @param[in] s scalar * @param[out] dest destination vector */ CGLM_INLINE void glm_vec3_scale(vec3 v, float s, vec3 dest) { dest[0] = v[0] * s; dest[1] = v[1] * s; dest[2] = v[2] * s; } /*! * @brief make vec3 vector scale as specified: result = unit(v) * s * * @param[in] v vector * @param[in] s scalar * @param[out] dest destination vector */ CGLM_INLINE void glm_vec3_scale_as(vec3 v, float s, vec3 dest) { float norm; norm = glm_vec3_norm(v); if (CGLM_UNLIKELY(norm < FLT_EPSILON)) { glm_vec3_zero(dest); return; } glm_vec3_scale(v, s / norm, dest); } /*! * @brief div vector with another component-wise division: d = a / b * * @param[in] a vector 1 * @param[in] b vector 2 * @param[out] dest result = (a[0]/b[0], a[1]/b[1], a[2]/b[2]) */ CGLM_INLINE void glm_vec3_div(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 div vector with scalar: d = v / s * * @param[in] v vector * @param[in] s scalar * @param[out] dest result = (a[0]/s, a[1]/s, a[2]/s) */ CGLM_INLINE void glm_vec3_divs(vec3 v, float s, vec3 dest) { dest[0] = v[0] / s; dest[1] = v[1] / s; dest[2] = v[2] / s; } /*! * @brief add two vectors and add result to sum * * 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_addadd(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 sub two vectors and add 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_subadd(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 add 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_muladd(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 add 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_vec3_muladds(vec3 a, float s, vec3 dest) { dest[0] += a[0] * s; dest[1] += a[1] * s; dest[2] += a[2] * s; } /*! * @brief add 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_maxadd(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 add 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_minadd(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 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 * * @param[in] v vector * @param[out] dest result vector */ CGLM_INLINE void glm_vec3_negate_to(vec3 v, vec3 dest) { dest[0] = -v[0]; dest[1] = -v[1]; dest[2] = -v[2]; } /*! * @brief negate vector components * * @param[in, out] v vector */ CGLM_INLINE void glm_vec3_negate(vec3 v) { glm_vec3_negate_to(v, v); } /*! * @brief normalize vec3 and store result in same vec * * @param[in, out] v vector */ CGLM_INLINE void glm_vec3_normalize(vec3 v) { float norm; norm = glm_vec3_norm(v); if (CGLM_UNLIKELY(norm < FLT_EPSILON)) { v[0] = v[1] = v[2] = 0.0f; return; } glm_vec3_scale(v, 1.0f / norm, v); } /*! * @brief normalize vec3 to dest * * @param[in] v source * @param[out] dest destination */ CGLM_INLINE void glm_vec3_normalize_to(vec3 v, vec3 dest) { float norm; norm = glm_vec3_norm(v); if (CGLM_UNLIKELY(norm < FLT_EPSILON)) { glm_vec3_zero(dest); return; } glm_vec3_scale(v, 1.0f / norm, dest); } /*! * @brief cross product of two vector (RH) * * @param[in] a vector 1 * @param[in] b vector 2 * @param[out] dest destination */ CGLM_INLINE void glm_vec3_cross(vec3 a, vec3 b, vec3 dest) { vec3 c; /* (u2.v3 - u3.v2, u3.v1 - u1.v3, u1.v2 - u2.v1) */ c[0] = a[1] * b[2] - a[2] * b[1]; c[1] = a[2] * b[0] - a[0] * b[2]; c[2] = a[0] * b[1] - a[1] * b[0]; glm_vec3_copy(c, dest); } /*! * @brief cross product of two vector (RH) and normalize the result * * @param[in] a vector 1 * @param[in] b vector 2 * @param[out] dest destination */ CGLM_INLINE void glm_vec3_crossn(vec3 a, vec3 b, vec3 dest) { glm_vec3_cross(a, b, dest); glm_vec3_normalize(dest); } /*! * @brief angle between two vector * * @param[in] a vector1 * @param[in] b vector2 * * @return angle as radians */ CGLM_INLINE float glm_vec3_angle(vec3 a, vec3 b) { float norm, dot; /* maybe compiler generate approximation instruction (rcp) */ norm = 1.0f / (glm_vec3_norm(a) * glm_vec3_norm(b)); dot = glm_vec3_dot(a, b) * norm; if (dot > 1.0f) return 0.0f; else if (dot < -1.0f) return CGLM_PI; return acosf(dot); } /*! * @brief rotate vec3 around axis by angle using Rodrigues' rotation formula * * @param[in, out] v vector * @param[in] axis axis vector (must be unit vector) * @param[in] angle angle by radians */ CGLM_INLINE void glm_vec3_rotate(vec3 v, float angle, vec3 axis) { vec3 v1, v2, k; float c, s; c = cosf(angle); s = sinf(angle); glm_vec3_normalize_to(axis, k); /* Right Hand, Rodrigues' rotation formula: v = v*cos(t) + (kxv)sin(t) + k*(k.v)(1 - cos(t)) */ glm_vec3_scale(v, c, v1); glm_vec3_cross(k, v, v2); glm_vec3_scale(v2, s, v2); glm_vec3_add(v1, v2, v1); glm_vec3_scale(k, glm_vec3_dot(k, v) * (1.0f - c), v2); glm_vec3_add(v1, v2, v); } /*! * @brief apply rotation matrix to vector * * matrix format should be (no perspective): * a b c x * e f g y * i j k z * 0 0 0 w * * @param[in] m affine matrix or rot matrix * @param[in] v vector * @param[out] dest rotated vector */ CGLM_INLINE void glm_vec3_rotate_m4(mat4 m, vec3 v, vec3 dest) { vec4 x, y, z, res; glm_vec4_normalize_to(m[0], x); glm_vec4_normalize_to(m[1], y); glm_vec4_normalize_to(m[2], z); glm_vec4_scale(x, v[0], res); glm_vec4_muladds(y, v[1], res); glm_vec4_muladds(z, v[2], res); glm_vec3(res, dest); } /*! * @brief apply rotation matrix to vector * * @param[in] m affine matrix or rot matrix * @param[in] v vector * @param[out] dest rotated vector */ CGLM_INLINE void glm_vec3_rotate_m3(mat3 m, vec3 v, vec3 dest) { vec4 res, x, y, z; glm_vec4(m[0], 0.0f, x); glm_vec4(m[1], 0.0f, y); glm_vec4(m[2], 0.0f, z); glm_vec4_normalize(x); glm_vec4_normalize(y); glm_vec4_normalize(z); glm_vec4_scale(x, v[0], res); glm_vec4_muladds(y, v[1], res); glm_vec4_muladds(z, v[2], res); glm_vec3(res, dest); } /*! * @brief project a vector onto b vector * * @param[in] a vector1 * @param[in] b vector2 * @param[out] dest projected vector */ CGLM_INLINE void glm_vec3_proj(vec3 a, vec3 b, vec3 dest) { glm_vec3_scale(b, glm_vec3_dot(a, b) / glm_vec3_norm2(b), dest); } /** * @brief find center point of two vector * * @param[in] a vector1 * @param[in] b vector2 * @param[out] dest center point */ CGLM_INLINE void glm_vec3_center(vec3 a, vec3 b, vec3 dest) { glm_vec3_add(a, b, dest); glm_vec3_scale(dest, 0.5f, dest); } /** * @brief squared distance between two vectors * * @param[in] a vector1 * @param[in] b vector2 * @return returns squared distance (distance * distance) */ CGLM_INLINE float glm_vec3_distance2(vec3 a, vec3 b) { return glm_pow2(a[0] - b[0]) + glm_pow2(a[1] - b[1]) + glm_pow2(a[2] - b[2]); } /** * @brief distance between two vectors * * @param[in] a vector1 * @param[in] b vector2 * @return returns distance */ CGLM_INLINE float glm_vec3_distance(vec3 a, vec3 b) { return sqrtf(glm_vec3_distance2(a, b)); } /*! * @brief max values of vectors * * @param[in] a vector1 * @param[in] b vector2 * @param[out] dest destination */ CGLM_INLINE void glm_vec3_maxv(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 min values of vectors * * @param[in] a vector1 * @param[in] b vector2 * @param[out] dest destination */ CGLM_INLINE void glm_vec3_minv(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 possible orthogonal/perpendicular vector * * @param[in] v vector * @param[out] dest orthogonal/perpendicular vector */ CGLM_INLINE void glm_vec3_ortho(vec3 v, vec3 dest) { float ignore; float f = modff(fabsf(v[0]) + 0.5f, &ignore); vec3 result = {-v[1], v[0] - f * v[2], f * v[1]}; glm_vec3_copy(result, dest); } /*! * @brief clamp vector's individual members between min and max values * * @param[in, out] v vector * @param[in] minVal minimum value * @param[in] maxVal maximum value */ CGLM_INLINE void glm_vec3_clamp(vec3 v, float minVal, float maxVal) { v[0] = glm_clamp(v[0], minVal, maxVal); v[1] = glm_clamp(v[1], minVal, maxVal); v[2] = glm_clamp(v[2], minVal, maxVal); } /*! * @brief linear interpolation between two vectors * * formula: from + s * (to - from) * * @param[in] from from value * @param[in] to to value * @param[in] t interpolant (amount) * @param[out] dest destination */ CGLM_INLINE void glm_vec3_lerp(vec3 from, vec3 to, float t, vec3 dest) { vec3 s, v; /* from + s * (to - from) */ glm_vec3_broadcast(t, s); glm_vec3_sub(to, from, v); glm_vec3_mul(s, v, v); glm_vec3_add(from, v, dest); } /*! * @brief linear interpolation between two vectors (clamped) * * formula: from + s * (to - from) * * @param[in] from from value * @param[in] to to value * @param[in] t interpolant (amount) clamped between 0 and 1 * @param[out] dest destination */ CGLM_INLINE void glm_vec3_lerpc(vec3 from, vec3 to, float t, vec3 dest) { glm_vec3_lerp(from, to, glm_clamp_zo(t), dest); } /*! * @brief linear interpolation between two vectors * * formula: from + s * (to - from) * * @param[in] from from value * @param[in] to to value * @param[in] t interpolant (amount) * @param[out] dest destination */ CGLM_INLINE void glm_vec3_mix(vec3 from, vec3 to, float t, vec3 dest) { glm_vec3_lerp(from, to, t, dest); } /*! * @brief linear interpolation between two vectors (clamped) * * formula: from + s * (to - from) * * @param[in] from from value * @param[in] to to value * @param[in] t interpolant (amount) clamped between 0 and 1 * @param[out] dest destination */ CGLM_INLINE void glm_vec3_mixc(vec3 from, vec3 to, float t, vec3 dest) { glm_vec3_lerpc(from, to, t, dest); } /*! * @brief threshold function * * @param[in] edge threshold * @param[in] x value to test against threshold * @param[out] dest destination */ CGLM_INLINE void glm_vec3_step(vec3 edge, vec3 x, vec3 dest) { dest[0] = glm_step(edge[0], x[0]); dest[1] = glm_step(edge[1], x[1]); dest[2] = glm_step(edge[2], x[2]); } /*! * @brief threshold function with a smooth transition (unidimensional) * * @param[in] edge0 low threshold * @param[in] edge1 high threshold * @param[in] x value to test against threshold * @param[out] dest destination */ CGLM_INLINE void glm_vec3_smoothstep_uni(float edge0, float edge1, vec3 x, vec3 dest) { dest[0] = glm_smoothstep(edge0, edge1, x[0]); dest[1] = glm_smoothstep(edge0, edge1, x[1]); dest[2] = glm_smoothstep(edge0, edge1, x[2]); } /*! * @brief threshold function with a smooth transition * * @param[in] edge0 low threshold * @param[in] edge1 high threshold * @param[in] x value to test against threshold * @param[out] dest destination */ CGLM_INLINE void glm_vec3_smoothstep(vec3 edge0, vec3 edge1, vec3 x, vec3 dest) { dest[0] = glm_smoothstep(edge0[0], edge1[0], x[0]); dest[1] = glm_smoothstep(edge0[1], edge1[1], x[1]); dest[2] = glm_smoothstep(edge0[2], edge1[2], x[2]); } /*! * @brief smooth Hermite interpolation between two vectors * * formula: from + s * (to - from) * * @param[in] from from value * @param[in] to to value * @param[in] t interpolant (amount) * @param[out] dest destination */ CGLM_INLINE void glm_vec3_smoothinterp(vec3 from, vec3 to, float t, vec3 dest) { vec3 s, v; /* from + s * (to - from) */ glm_vec3_broadcast(glm_smooth(t), s); glm_vec3_sub(to, from, v); glm_vec3_mul(s, v, v); glm_vec3_add(from, v, dest); } /*! * @brief smooth Hermite interpolation between two vectors (clamped) * * formula: from + s * (to - from) * * @param[in] from from value * @param[in] to to value * @param[in] t interpolant (amount) clamped between 0 and 1 * @param[out] dest destination */ CGLM_INLINE void glm_vec3_smoothinterpc(vec3 from, vec3 to, float t, vec3 dest) { glm_vec3_smoothinterp(from, to, glm_clamp_zo(t), dest); } /*! * @brief swizzle vector components * * you can use existing masks e.g. GLM_XXX, GLM_ZYX * * @param[in] v source * @param[in] mask mask * @param[out] dest destination */ CGLM_INLINE void glm_vec3_swizzle(vec3 v, int mask, vec3 dest) { vec3 t; t[0] = v[(mask & (3 << 0))]; t[1] = v[(mask & (3 << 2)) >> 2]; t[2] = v[(mask & (3 << 4)) >> 4]; glm_vec3_copy(t, dest); } /*! * @brief vec3 cross product * * this is just convenient wrapper * * @param[in] a source 1 * @param[in] b source 2 * @param[out] d destination */ CGLM_INLINE void glm_cross(vec3 a, vec3 b, vec3 d) { glm_vec3_cross(a, b, d); } /*! * @brief vec3 dot product * * this is just convenient wrapper * * @param[in] a vector1 * @param[in] b vector2 * * @return dot product */ CGLM_INLINE float glm_dot(vec3 a, vec3 b) { return glm_vec3_dot(a, b); } /*! * @brief normalize vec3 and store result in same vec * * this is just convenient wrapper * * @param[in, out] v vector */ CGLM_INLINE void glm_normalize(vec3 v) { glm_vec3_normalize(v); } /*! * @brief normalize vec3 to dest * * this is just convenient wrapper * * @param[in] v source * @param[out] dest destination */ CGLM_INLINE void glm_normalize_to(vec3 v, vec3 dest) { glm_vec3_normalize_to(v, dest); } /*! * @brief Create three dimensional vector from pointer * * @param[in] src pointer to an array of floats * @param[out] dest destination vector */ CGLM_INLINE void glm_vec3_make(const float * __restrict src, vec3 dest) { dest[0] = src[0]; dest[1] = src[1]; dest[2] = src[2]; } /*! * @brief a vector pointing in the same direction as another * * orients a vector to point away from a surface as defined by its normal * * @param[in] n vector to orient * @param[in] v incident vector * @param[in] nref reference vector * @param[out] dest oriented vector, pointing away from the surface */ CGLM_INLINE void glm_vec3_faceforward(vec3 n, vec3 v, vec3 nref, vec3 dest) { if (glm_vec3_dot(v, nref) < 0.0f) { /* N is facing away from I */ glm_vec3_copy(n, dest); } else { /* N is facing towards I, negate it */ glm_vec3_negate_to(n, dest); } } /*! * @brief reflection vector using an incident ray and a surface normal * * @param[in] v incident vector * @param[in] n normalized normal vector * @param[out] dest reflection result */ CGLM_INLINE void glm_vec3_reflect(vec3 v, vec3 n, vec3 dest) { vec3 temp; glm_vec3_scale(n, 2.0f * glm_vec3_dot(v, n), temp); glm_vec3_sub(v, temp, dest); } /*! * @brief computes refraction vector for an incident vector and a surface normal. * * calculates the refraction vector based on Snell's law. If total internal reflection * occurs (angle too great given eta), dest is set to zero and returns false. * Otherwise, computes refraction vector, stores it in dest, and returns true. * * @param[in] v normalized incident vector * @param[in] n normalized normal vector * @param[in] eta ratio of indices of refraction (incident/transmitted) * @param[out] dest refraction vector if refraction occurs; zero vector otherwise * * @returns true if refraction occurs; false if total internal reflection occurs. */ CGLM_INLINE bool glm_vec3_refract(vec3 v, vec3 n, float eta, vec3 dest) { float ndi, eni, k; ndi = glm_vec3_dot(n, v); eni = eta * ndi; k = 1.0f - eta * eta + eni * eni; if (k < 0.0f) { glm_vec3_zero(dest); return false; } glm_vec3_scale(v, eta, dest); glm_vec3_mulsubs(n, eni + sqrtf(k), dest); return true; } #endif /* cglm_vec3_h */ cglm-0.9.6/include/cglm/vec4-ext.h000066400000000000000000000214051475344456400166470ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ /*! * @brief SIMD like functions */ /* Functions: CGLM_INLINE void glm_vec4_broadcast(float val, vec4 d); CGLM_INLINE void glm_vec4_fill(vec4 v, float val); CGLM_INLINE bool glm_vec4_eq(vec4 v, float val); CGLM_INLINE bool glm_vec4_eq_eps(vec4 v, float val); CGLM_INLINE bool glm_vec4_eq_all(vec4 v); CGLM_INLINE bool glm_vec4_eqv(vec4 a, vec4 b); CGLM_INLINE bool glm_vec4_eqv_eps(vec4 a, vec4 b); CGLM_INLINE float glm_vec4_max(vec4 v); CGLM_INLINE float glm_vec4_min(vec4 v); CGLM_INLINE bool glm_vec4_isnan(vec4 v); CGLM_INLINE bool glm_vec4_isinf(vec4 v); CGLM_INLINE bool glm_vec4_isvalid(vec4 v); CGLM_INLINE void glm_vec4_sign(vec4 v, vec4 dest); CGLM_INLINE void glm_vec4_abs(vec4 v, vec4 dest); CGLM_INLINE void glm_vec4_fract(vec4 v, vec4 dest); CGLM_INLINE void glm_vec4_floor(vec4 v, vec4 dest); CGLM_INLINE float glm_vec4_mods(vec4 v, float s, vec4 dest); CGLM_INLINE float glm_vec4_steps(float edge, vec4 v, vec4 dest); CGLM_INLINE void glm_vec4_stepr(vec4 edge, float v, vec4 dest); CGLM_INLINE float glm_vec4_hadd(vec4 v); CGLM_INLINE void glm_vec4_sqrt(vec4 v, vec4 dest); */ #ifndef cglm_vec4_ext_h #define cglm_vec4_ext_h #include "common.h" #include "vec3-ext.h" /*! * @brief fill a vector with specified value * * @param val value * @param d dest */ CGLM_INLINE void glm_vec4_broadcast(float val, vec4 d) { #if defined(__wasm__) && defined(__wasm_simd128__) glmm_store(d, wasm_f32x4_splat(val)); #elif defined( __SSE__ ) || defined( __SSE2__ ) glmm_store(d, glmm_set1(val)); #else d[0] = d[1] = d[2] = d[3] = val; #endif } /*! * @brief fill a vector with specified value * * @param v dest * @param val value */ CGLM_INLINE void glm_vec4_fill(vec4 v, float val) { #if defined(__wasm__) && defined(__wasm_simd128__) glmm_store(v, wasm_f32x4_splat(val)); #elif defined( __SSE__ ) || defined( __SSE2__ ) glmm_store(v, glmm_set1(val)); #else v[0] = v[1] = v[2] = v[3] = val; #endif } /*! * @brief check if vector is equal to value (without epsilon) * * @param v vector * @param val value */ CGLM_INLINE bool glm_vec4_eq(vec4 v, float val) { return v[0] == val && v[0] == v[1] && v[0] == v[2] && v[0] == v[3]; } /*! * @brief check if vector is equal to value (with epsilon) * * @param v vector * @param val value */ CGLM_INLINE bool glm_vec4_eq_eps(vec4 v, float val) { return fabsf(v[0] - val) <= GLM_FLT_EPSILON && fabsf(v[1] - val) <= GLM_FLT_EPSILON && fabsf(v[2] - val) <= GLM_FLT_EPSILON && fabsf(v[3] - val) <= GLM_FLT_EPSILON; } /*! * @brief check if vector members are equal (without epsilon) * * @param v vector */ CGLM_INLINE bool glm_vec4_eq_all(vec4 v) { return glm_vec4_eq_eps(v, v[0]); } /*! * @brief check if vector is equal to another (without epsilon) * * @param a vector * @param b vector */ CGLM_INLINE bool glm_vec4_eqv(vec4 a, vec4 b) { return a[0] == b[0] && a[1] == b[1] && a[2] == b[2] && a[3] == b[3]; } /*! * @brief check if vector is equal to another (with epsilon) * * @param a vector * @param b vector */ CGLM_INLINE bool glm_vec4_eqv_eps(vec4 a, vec4 b) { return fabsf(a[0] - b[0]) <= GLM_FLT_EPSILON && fabsf(a[1] - b[1]) <= GLM_FLT_EPSILON && fabsf(a[2] - b[2]) <= GLM_FLT_EPSILON && fabsf(a[3] - b[3]) <= GLM_FLT_EPSILON; } /*! * @brief max value of vector * * @param v vector */ CGLM_INLINE float glm_vec4_max(vec4 v) { float max; max = glm_vec3_max(v); if (v[3] > max) max = v[3]; return max; } /*! * @brief min value of vector * * @param v vector */ CGLM_INLINE float glm_vec4_min(vec4 v) { float min; min = glm_vec3_min(v); if (v[3] < min) min = v[3]; return min; } /*! * @brief check if one of items is NaN (not a number) * you should only use this in DEBUG mode or very critical asserts * * @param[in] v vector */ CGLM_INLINE bool glm_vec4_isnan(vec4 v) { #ifndef CGLM_FAST_MATH return isnan(v[0]) || isnan(v[1]) || isnan(v[2]) || isnan(v[3]); #else return false; #endif } /*! * @brief check if one of items is INFINITY * you should only use this in DEBUG mode or very critical asserts * * @param[in] v vector */ CGLM_INLINE bool glm_vec4_isinf(vec4 v) { #ifndef CGLM_FAST_MATH return isinf(v[0]) || isinf(v[1]) || isinf(v[2]) || isinf(v[3]); #else return false; #endif } /*! * @brief check if all items are valid number * you should only use this in DEBUG mode or very critical asserts * * @param[in] v vector */ CGLM_INLINE bool glm_vec4_isvalid(vec4 v) { return !glm_vec4_isnan(v) && !glm_vec4_isinf(v); } /*! * @brief get sign of 32 bit float as +1, -1, 0 * * Important: It returns 0 for zero/NaN input * * @param v vector */ CGLM_INLINE void glm_vec4_sign(vec4 v, vec4 dest) { #if defined( __SSE__ ) || defined( __SSE2__ ) __m128 x0, x1, x2, x3, x4; x0 = glmm_load(v); x1 = _mm_set_ps(0.0f, 0.0f, 1.0f, -1.0f); x2 = glmm_splat(x1, 2); x3 = _mm_and_ps(_mm_cmpgt_ps(x0, x2), glmm_splat(x1, 1)); x4 = _mm_and_ps(_mm_cmplt_ps(x0, x2), glmm_splat(x1, 0)); glmm_store(dest, _mm_or_ps(x3, x4)); #else dest[0] = glm_signf(v[0]); dest[1] = glm_signf(v[1]); dest[2] = glm_signf(v[2]); dest[3] = glm_signf(v[3]); #endif } /*! * @brief absolute value of each vector item * * @param[in] v vector * @param[out] dest destination vector */ CGLM_INLINE void glm_vec4_abs(vec4 v, vec4 dest) { #if defined(__wasm__) && defined(__wasm_simd128__) glmm_store(dest, glmm_abs(glmm_load(v))); #elif defined( __SSE__ ) || defined( __SSE2__ ) glmm_store(dest, glmm_abs(glmm_load(v))); #elif defined(CGLM_NEON_FP) vst1q_f32(dest, vabsq_f32(vld1q_f32(v))); #else dest[0] = fabsf(v[0]); dest[1] = fabsf(v[1]); dest[2] = fabsf(v[2]); dest[3] = fabsf(v[3]); #endif } /*! * @brief fractional part of each vector item * * @param[in] v vector * @param[out] dest destination vector */ CGLM_INLINE void glm_vec4_fract(vec4 v, vec4 dest) { dest[0] = fminf(v[0] - floorf(v[0]), 0.999999940395355224609375f); dest[1] = fminf(v[1] - floorf(v[1]), 0.999999940395355224609375f); dest[2] = fminf(v[2] - floorf(v[2]), 0.999999940395355224609375f); dest[3] = fminf(v[3] - floorf(v[3]), 0.999999940395355224609375f); } /*! * @brief floor of each vector item * * @param[in] v vector * @param[out] dest destination vector */ CGLM_INLINE void glm_vec4_floor(vec4 v, vec4 dest) { dest[0] = floorf(v[0]); dest[1] = floorf(v[1]); dest[2] = floorf(v[2]); dest[3] = floorf(v[3]); } /*! * @brief mod of each vector item, result is written to dest (dest = v % s) * * @param[in] v vector * @param[in] s scalar * @param[out] dest destination vector */ CGLM_INLINE void glm_vec4_mods(vec4 v, float s, vec4 dest) { dest[0] = fmodf(v[0], s); dest[1] = fmodf(v[1], s); dest[2] = fmodf(v[2], s); dest[3] = fmodf(v[3], s); } /*! * @brief threshold each vector item with scalar * condition is: (x[i] < edge) ? 0.0 : 1.0 * * @param[in] edge threshold * @param[in] x vector to test against threshold * @param[out] dest destination */ CGLM_INLINE void glm_vec4_steps(float edge, vec4 x, vec4 dest) { dest[0] = glm_step(edge, x[0]); dest[1] = glm_step(edge, x[1]); dest[2] = glm_step(edge, x[2]); dest[3] = glm_step(edge, x[3]); } /*! * @brief threshold a value with *vector* as the threshold * condition is: (x < edge[i]) ? 0.0 : 1.0 * * @param[in] edge threshold vector * @param[in] x value to test against threshold * @param[out] dest destination */ CGLM_INLINE void glm_vec4_stepr(vec4 edge, float x, vec4 dest) { dest[0] = glm_step(edge[0], x); dest[1] = glm_step(edge[1], x); dest[2] = glm_step(edge[2], x); dest[3] = glm_step(edge[3], x); } /*! * @brief vector reduction by summation * @warning could overflow * * @param[in] v vector * @return sum of all vector's elements */ CGLM_INLINE float glm_vec4_hadd(vec4 v) { #if defined(__wasm__) && defined(__wasm_simd128__) return glmm_hadd(glmm_load(v)); #elif defined( __SSE__ ) || defined( __SSE2__ ) return glmm_hadd(glmm_load(v)); #else return v[0] + v[1] + v[2] + v[3]; #endif } /*! * @brief square root of each vector item * * @param[in] v vector * @param[out] dest destination vector */ CGLM_INLINE void glm_vec4_sqrt(vec4 v, vec4 dest) { #if defined(__wasm__) && defined(__wasm_simd128__) glmm_store(dest, wasm_f32x4_sqrt(glmm_load(v))); #elif defined( __SSE__ ) || defined( __SSE2__ ) glmm_store(dest, _mm_sqrt_ps(glmm_load(v))); #else dest[0] = sqrtf(v[0]); dest[1] = sqrtf(v[1]); dest[2] = sqrtf(v[2]); dest[3] = sqrtf(v[3]); #endif } #endif /* cglm_vec4_ext_h */ cglm-0.9.6/include/cglm/vec4.h000066400000000000000000001055411475344456400160550ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ /* Macros: GLM_VEC4_ONE_INIT GLM_VEC4_BLACK_INIT GLM_VEC4_ZERO_INIT GLM_VEC4_ONE GLM_VEC4_BLACK GLM_VEC4_ZERO Functions: CGLM_INLINE void glm_vec4(vec3 v3, float last, vec4 dest); CGLM_INLINE void glm_vec4_copy3(vec4 a, vec3 dest); CGLM_INLINE void glm_vec4_copy(vec4 v, vec4 dest); CGLM_INLINE void glm_vec4_ucopy(vec4 v, vec4 dest); CGLM_INLINE float glm_vec4_dot(vec4 a, vec4 b); CGLM_INLINE float glm_vec4_norm2(vec4 v); CGLM_INLINE float glm_vec4_norm(vec4 v); CGLM_INLINE float glm_vec4_norm_one(vec4 v); CGLM_INLINE float glm_vec4_norm_inf(vec4 v); CGLM_INLINE void glm_vec4_add(vec4 a, vec4 b, vec4 dest); CGLM_INLINE void glm_vec4_adds(vec4 v, float s, vec4 dest); CGLM_INLINE void glm_vec4_sub(vec4 a, vec4 b, vec4 dest); CGLM_INLINE void glm_vec4_subs(vec4 v, float s, vec4 dest); CGLM_INLINE void glm_vec4_mul(vec4 a, vec4 b, vec4 dest); CGLM_INLINE void glm_vec4_scale(vec4 v, float s, vec4 dest); CGLM_INLINE void glm_vec4_scale_as(vec4 v, float s, vec4 dest); CGLM_INLINE void glm_vec4_div(vec4 a, vec4 b, vec4 dest); CGLM_INLINE void glm_vec4_divs(vec4 v, float s, vec4 dest); CGLM_INLINE void glm_vec4_addadd(vec4 a, vec4 b, vec4 dest); CGLM_INLINE void glm_vec4_subadd(vec4 a, vec4 b, vec4 dest); CGLM_INLINE void glm_vec4_muladd(vec4 a, vec4 b, 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_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_inv(vec4 v); CGLM_INLINE void glm_vec4_inv_to(vec4 v, vec4 dest); CGLM_INLINE void glm_vec4_normalize(vec4 v); CGLM_INLINE void glm_vec4_normalize_to(vec4 vec, vec4 dest); CGLM_INLINE float glm_vec4_distance(vec4 a, vec4 b); CGLM_INLINE float glm_vec4_distance2(vec4 a, vec4 b); CGLM_INLINE void glm_vec4_maxv(vec4 a, vec4 b, vec4 dest); CGLM_INLINE void glm_vec4_minv(vec4 a, vec4 b, vec4 dest); CGLM_INLINE void glm_vec4_clamp(vec4 v, float minVal, float maxVal); CGLM_INLINE void glm_vec4_lerp(vec4 from, vec4 to, float t, vec4 dest); CGLM_INLINE void glm_vec4_lerpc(vec4 from, vec4 to, float t, vec4 dest); CGLM_INLINE void glm_vec4_step(vec4 edge, vec4 x, vec4 dest); CGLM_INLINE void glm_vec4_smoothstep_uni(float edge0, float edge1, vec4 x, vec4 dest); CGLM_INLINE void glm_vec4_smoothstep(vec4 edge0, vec4 edge1, vec4 x, vec4 dest); CGLM_INLINE void glm_vec4_smoothinterp(vec4 from, vec4 to, float t, vec4 dest); CGLM_INLINE void glm_vec4_smoothinterpc(vec4 from, vec4 to, float t, vec4 dest); CGLM_INLINE void glm_vec4_swizzle(vec4 v, int mask, vec4 dest); CGLM_INLINE void glm_vec4_make(float * restrict src, vec4 dest); CGLM_INLINE void glm_vec4_reflect(vec4 v, vec4 n, vec4 dest); CGLM_INLINE void glm_vec4_refract(vec4 v, vec4 n, float eta, vec4 dest); DEPRECATED: glm_vec4_dup glm_vec4_flipsign glm_vec4_flipsign_to glm_vec4_inv glm_vec4_inv_to glm_vec4_mulv glm_vec4_step_uni --> use glm_vec4_steps */ #ifndef cglm_vec4_h #define cglm_vec4_h #include "common.h" #include "vec4-ext.h" #include "util.h" /* DEPRECATED! functions */ #define glm_vec4_dup3(v, dest) glm_vec4_copy3(v, dest) #define glm_vec4_dup(v, dest) glm_vec4_copy(v, dest) #define glm_vec4_flipsign(v) glm_vec4_negate(v) #define glm_vec4_flipsign_to(v, dest) glm_vec4_negate_to(v, dest) #define glm_vec4_inv(v) glm_vec4_negate(v) #define glm_vec4_inv_to(v, dest) glm_vec4_negate_to(v, dest) #define glm_vec4_mulv(a, b, d) glm_vec4_mul(a, b, d) #define glm_vec4_step_uni(edge, x, dest) glm_vec4_steps(edge, x, dest) #define GLM_VEC4_ONE_INIT {1.0f, 1.0f, 1.0f, 1.0f} #define GLM_VEC4_BLACK_INIT {0.0f, 0.0f, 0.0f, 1.0f} #define GLM_VEC4_ZERO_INIT {0.0f, 0.0f, 0.0f, 0.0f} #define GLM_VEC4_ONE ((vec4)GLM_VEC4_ONE_INIT) #define GLM_VEC4_BLACK ((vec4)GLM_VEC4_BLACK_INIT) #define GLM_VEC4_ZERO ((vec4)GLM_VEC4_ZERO_INIT) #define GLM_XXXX GLM_SHUFFLE4(0, 0, 0, 0) #define GLM_YYYY GLM_SHUFFLE4(1, 1, 1, 1) #define GLM_ZZZZ GLM_SHUFFLE4(2, 2, 2, 2) #define GLM_WWWW GLM_SHUFFLE4(3, 3, 3, 3) #define GLM_WZYX GLM_SHUFFLE4(0, 1, 2, 3) /*! * @brief init vec4 using vec3 * * @param[in] v3 vector3 * @param[in] last last item * @param[out] dest destination */ CGLM_INLINE void glm_vec4(vec3 v3, float last, vec4 dest) { dest[0] = v3[0]; dest[1] = v3[1]; dest[2] = v3[2]; dest[3] = last; } /*! * @brief copy first 3 members of [a] to [dest] * * @param[in] a source * @param[out] dest destination */ CGLM_INLINE void glm_vec4_copy3(vec4 a, vec3 dest) { dest[0] = a[0]; dest[1] = a[1]; dest[2] = a[2]; } /*! * @brief copy all members of [a] to [dest] * * @param[in] v source * @param[out] dest destination */ CGLM_INLINE void glm_vec4_copy(vec4 v, vec4 dest) { #if defined(__wasm__) && defined(__wasm_simd128__) glmm_store(dest, glmm_load(v)); #elif defined( __SSE__ ) || defined( __SSE2__ ) glmm_store(dest, glmm_load(v)); #elif defined(CGLM_NEON_FP) vst1q_f32(dest, vld1q_f32(v)); #else dest[0] = v[0]; dest[1] = v[1]; dest[2] = v[2]; dest[3] = v[3]; #endif } /*! * @brief copy all members of [a] to [dest] * * alignment is not required * * @param[in] v source * @param[out] dest destination */ CGLM_INLINE void glm_vec4_ucopy(vec4 v, vec4 dest) { #if defined(__wasm__) && defined(__wasm_simd128__) /* note here wasm v128.load/v128.store support unaligned loads and stores */ wasm_v128_store(dest, wasm_v128_load(v)); #else dest[0] = v[0]; dest[1] = v[1]; dest[2] = v[2]; dest[3] = v[3]; #endif } /*! * @brief make vector zero * * @param[in, out] v vector */ CGLM_INLINE void glm_vec4_zero(vec4 v) { #if defined(__wasm__) && defined(__wasm_simd128__) glmm_store(v, wasm_f32x4_const_splat(0.f)); #elif defined( __SSE__ ) || defined( __SSE2__ ) glmm_store(v, _mm_setzero_ps()); #elif defined(CGLM_NEON_FP) vst1q_f32(v, vdupq_n_f32(0.0f)); #else v[0] = 0.0f; v[1] = 0.0f; v[2] = 0.0f; v[3] = 0.0f; #endif } /*! * @brief make vector one * * @param[in, out] v vector */ CGLM_INLINE void glm_vec4_one(vec4 v) { #if defined(__wasm__) && defined(__wasm_simd128__) glmm_store(v, wasm_f32x4_const_splat(1.0f)); #elif defined( __SSE__ ) || defined( __SSE2__ ) glmm_store(v, glmm_set1_rval(1.0f)); #elif defined(CGLM_NEON_FP) vst1q_f32(v, vdupq_n_f32(1.0f)); #else v[0] = 1.0f; v[1] = 1.0f; v[2] = 1.0f; v[3] = 1.0f; #endif } /*! * @brief vec4 dot product * * @param[in] a vector1 * @param[in] b vector2 * * @return dot product */ CGLM_INLINE float glm_vec4_dot(vec4 a, vec4 b) { #if defined(CGLM_SIMD) return glmm_dot(glmm_load(a), glmm_load(b)); #else return a[0] * b[0] + a[1] * b[1] + a[2] * b[2] + a[3] * b[3]; #endif } /*! * @brief norm * norm (magnitude) of vec * * we can use this func instead of calling norm * norm, because it would call * sqrtf function twice but with this func we can avoid func call, maybe this is * not good name for this func * * @param[in] v vec4 * * @return norm * norm */ CGLM_INLINE float glm_vec4_norm2(vec4 v) { return glm_vec4_dot(v, v); } /*! * @brief euclidean norm (magnitude), also called L2 norm * this will give magnitude of vector in euclidean space * * @param[in] v vector * * @return norm */ CGLM_INLINE float glm_vec4_norm(vec4 v) { #if defined(CGLM_SIMD) return glmm_norm(glmm_load(v)); #else return sqrtf(glm_vec4_dot(v, v)); #endif } /*! * @brief L1 norm of vec4 * Also known as Manhattan Distance or Taxicab norm. * L1 Norm is the sum of the magnitudes of the vectors in a space. * It is calculated as the sum of the absolute values of the vector components. * In this norm, all the components of the vector are weighted equally. * * This computes: * L1 norm = |v[0]| + |v[1]| + |v[2]| + |v[3]| * * @param[in] v vector * * @return L1 norm */ CGLM_INLINE float glm_vec4_norm_one(vec4 v) { #if defined(CGLM_SIMD) return glmm_norm_one(glmm_load(v)); #else vec4 t; glm_vec4_abs(v, t); return glm_vec4_hadd(t); #endif } /*! * @brief infinity norm of vec4 * Also known as Maximum norm. * Infinity Norm is the largest magnitude among each element of a vector. * It is calculated as the maximum of the absolute values of the vector components. * * This computes: * inf norm = max(|v[0]|, |v[1]|, |v[2]|, |v[3]|) * * @param[in] v vector * * @return infinity norm */ CGLM_INLINE float glm_vec4_norm_inf(vec4 v) { #if defined(CGLM_SIMD) return glmm_norm_inf(glmm_load(v)); #else vec4 t; glm_vec4_abs(v, t); return glm_vec4_max(t); #endif } /*! * @brief add b vector to a vector store result in dest * * @param[in] a vector1 * @param[in] b vector2 * @param[out] dest destination vector */ CGLM_INLINE void glm_vec4_add(vec4 a, vec4 b, vec4 dest) { #if defined(__wasm__) && defined(__wasm_simd128__) glmm_store(dest, wasm_f32x4_add(glmm_load(a), glmm_load(b))); #elif defined( __SSE__ ) || defined( __SSE2__ ) glmm_store(dest, _mm_add_ps(glmm_load(a), glmm_load(b))); #elif defined(CGLM_NEON_FP) vst1q_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 add scalar to v vector store result in dest (d = v + vec(s)) * * @param[in] v vector * @param[in] s scalar * @param[out] dest destination vector */ CGLM_INLINE void glm_vec4_adds(vec4 v, float s, vec4 dest) { #if defined(__wasm__) && defined(__wasm_simd128__) glmm_store(dest, wasm_f32x4_add(glmm_load(v), wasm_f32x4_splat(s))); #elif defined( __SSE__ ) || defined( __SSE2__ ) glmm_store(dest, _mm_add_ps(glmm_load(v), glmm_set1(s))); #elif defined(CGLM_NEON_FP) vst1q_f32(dest, vaddq_f32(vld1q_f32(v), vdupq_n_f32(s))); #else dest[0] = v[0] + s; dest[1] = v[1] + s; dest[2] = v[2] + s; dest[3] = v[3] + s; #endif } /*! * @brief subtract b vector from a vector store result in dest (d = a - b) * * @param[in] a vector1 * @param[in] b vector2 * @param[out] dest destination vector */ CGLM_INLINE void glm_vec4_sub(vec4 a, vec4 b, vec4 dest) { #if defined(__wasm__) && defined(__wasm_simd128__) glmm_store(dest, wasm_f32x4_sub(glmm_load(a), glmm_load(b))); #elif defined( __SSE__ ) || defined( __SSE2__ ) glmm_store(dest, _mm_sub_ps(glmm_load(a), glmm_load(b))); #elif defined(CGLM_NEON_FP) vst1q_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 subtract scalar from v vector store result in dest (d = v - vec(s)) * * @param[in] v vector * @param[in] s scalar * @param[out] dest destination vector */ CGLM_INLINE void glm_vec4_subs(vec4 v, float s, vec4 dest) { #if defined(__wasm__) && defined(__wasm_simd128__) glmm_store(dest, wasm_f32x4_sub(glmm_load(v), wasm_f32x4_splat(s))); #elif defined( __SSE__ ) || defined( __SSE2__ ) glmm_store(dest, _mm_sub_ps(glmm_load(v), glmm_set1(s))); #elif defined(CGLM_NEON_FP) vst1q_f32(dest, vsubq_f32(vld1q_f32(v), vdupq_n_f32(s))); #else dest[0] = v[0] - s; dest[1] = v[1] - s; dest[2] = v[2] - s; dest[3] = v[3] - s; #endif } /*! * @brief multiply two vectors (component-wise multiplication) * * @param a vector1 * @param b vector2 * @param dest dest = (a[0] * b[0], a[1] * b[1], a[2] * b[2], a[3] * b[3]) */ CGLM_INLINE void glm_vec4_mul(vec4 a, vec4 b, vec4 dest) { #if defined(__wasm__) && defined(__wasm_simd128__) glmm_store(dest, wasm_f32x4_mul(glmm_load(a), glmm_load(b))); #elif defined( __SSE__ ) || defined( __SSE2__ ) glmm_store(dest, _mm_mul_ps(glmm_load(a), glmm_load(b))); #elif defined(CGLM_NEON_FP) vst1q_f32(dest, vmulq_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 multiply/scale vec4 vector with scalar: result = v * s * * @param[in] v vector * @param[in] s scalar * @param[out] dest destination vector */ CGLM_INLINE void glm_vec4_scale(vec4 v, float s, vec4 dest) { #if defined(__wasm__) && defined(__wasm_simd128__) glmm_store(dest, wasm_f32x4_mul(glmm_load(v), wasm_f32x4_splat(s))); #elif defined( __SSE__ ) || defined( __SSE2__ ) glmm_store(dest, _mm_mul_ps(glmm_load(v), glmm_set1(s))); #elif defined(CGLM_NEON_FP) vst1q_f32(dest, vmulq_f32(vld1q_f32(v), vdupq_n_f32(s))); #else dest[0] = v[0] * s; dest[1] = v[1] * s; dest[2] = v[2] * s; dest[3] = v[3] * s; #endif } /*! * @brief make vec4 vector scale as specified: result = unit(v) * s * * @param[in] v vector * @param[in] s scalar * @param[out] dest destination vector */ CGLM_INLINE void glm_vec4_scale_as(vec4 v, float s, vec4 dest) { float norm; norm = glm_vec4_norm(v); if (CGLM_UNLIKELY(norm < FLT_EPSILON)) { glm_vec4_zero(dest); return; } glm_vec4_scale(v, s / norm, dest); } /*! * @brief div vector with another component-wise division: d = a / b * * @param[in] a vector 1 * @param[in] b vector 2 * @param[out] dest result = (a[0]/b[0], a[1]/b[1], a[2]/b[2], a[3]/b[3]) */ CGLM_INLINE void glm_vec4_div(vec4 a, vec4 b, vec4 dest) { #if defined(CGLM_SIMD) glmm_store(dest, glmm_div(glmm_load(a), glmm_load(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 div vec4 vector with scalar: d = v / s * * @param[in] v vector * @param[in] s scalar * @param[out] dest destination vector */ CGLM_INLINE void glm_vec4_divs(vec4 v, float s, vec4 dest) { #if defined(CGLM_SIMD) glmm_store(dest, glmm_div(glmm_load(v), glmm_set1(s))); #else glm_vec4_scale(v, 1.0f / s, dest); #endif } /*! * @brief add two vectors and add result to sum * * 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_addadd(vec4 a, vec4 b, vec4 dest) { #if defined(__wasm__) && defined(__wasm_simd128__) glmm_store(dest, wasm_f32x4_add( glmm_load(dest), wasm_f32x4_add(glmm_load(a), glmm_load(b)))); #elif defined( __SSE__ ) || defined( __SSE2__ ) glmm_store(dest, _mm_add_ps(glmm_load(dest), _mm_add_ps(glmm_load(a), glmm_load(b)))); #elif defined(CGLM_NEON_FP) vst1q_f32(dest, vaddq_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 sub two vectors and add 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_subadd(vec4 a, vec4 b, vec4 dest) { #if defined(__wasm__) && defined(__wasm_simd128__) glmm_store(dest, wasm_f32x4_add( glmm_load(dest), wasm_f32x4_sub(glmm_load(a), glmm_load(b)))); #elif defined( __SSE__ ) || defined( __SSE2__ ) glmm_store(dest, _mm_add_ps(glmm_load(dest), _mm_sub_ps(glmm_load(a), glmm_load(b)))); #elif defined(CGLM_NEON_FP) vst1q_f32(dest, vaddq_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 mul two vectors and add 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_muladd(vec4 a, vec4 b, vec4 dest) { #if defined(CGLM_SIMD) glmm_store(dest, glmm_fmadd(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 add 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_vec4_muladds(vec4 a, float s, vec4 dest) { #if defined(CGLM_SIMD) glmm_store(dest, glmm_fmadd(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 add 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_vec4_maxadd(vec4 a, vec4 b, vec4 dest) { #if defined(__wasm__) && defined(__wasm_simd128__) glmm_store(dest, wasm_f32x4_add(glmm_load(dest), glmm_max(glmm_load(a), glmm_load(b)))); #elif defined( __SSE__ ) || defined( __SSE2__ ) glmm_store(dest, _mm_add_ps(glmm_load(dest), glmm_max(glmm_load(a), glmm_load(b)))); #elif defined(CGLM_NEON_FP) glmm_store(dest, vaddq_f32(glmm_load(dest), glmm_max(glmm_load(a), glmm_load(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 add 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_vec4_minadd(vec4 a, vec4 b, vec4 dest) { #if defined(__wasm__) && defined(__wasm_simd128__) glmm_store(dest, wasm_f32x4_add(glmm_load(dest), glmm_min(glmm_load(a), glmm_load(b)))); #elif defined( __SSE__ ) || defined( __SSE2__ ) glmm_store(dest, _mm_add_ps(glmm_load(dest), glmm_min(glmm_load(a), glmm_load(b)))); #elif defined(CGLM_NEON_FP) glmm_store(dest, vaddq_f32(glmm_load(dest), glmm_min(glmm_load(a), glmm_load(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 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), glmm_max(glmm_load(a), glmm_load(b)))); #elif defined( __SSE__ ) || defined( __SSE2__ ) glmm_store(dest, _mm_sub_ps(glmm_load(dest), glmm_max(glmm_load(a), glmm_load(b)))); #elif defined(CGLM_NEON_FP) glmm_store(dest, vsubq_f32(glmm_load(dest), glmm_max(glmm_load(a), glmm_load(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), glmm_min(glmm_load(a), glmm_load(b)))); #elif defined( __SSE__ ) || defined( __SSE2__ ) glmm_store(dest, _mm_sub_ps(glmm_load(dest), glmm_min(glmm_load(a), glmm_load(b)))); #elif defined(CGLM_NEON_FP) glmm_store(dest, vsubq_f32(vld1q_f32(dest), glmm_min(glmm_load(a), glmm_load(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 * * @param[in] v vector * @param[out] dest result vector */ CGLM_INLINE void glm_vec4_negate_to(vec4 v, vec4 dest) { #if defined(__wasm__) && defined(__wasm_simd128__) glmm_store(dest, wasm_f32x4_neg(glmm_load(v))); #elif defined( __SSE__ ) || defined( __SSE2__ ) glmm_store(dest, _mm_xor_ps(glmm_load(v), glmm_float32x4_SIGNMASK_NEG)); #elif defined(CGLM_NEON_FP) vst1q_f32(dest, vnegq_f32(vld1q_f32(v))); #else dest[0] = -v[0]; dest[1] = -v[1]; dest[2] = -v[2]; dest[3] = -v[3]; #endif } /*! * @brief flip sign of all vec4 members * * @param[in, out] v vector */ CGLM_INLINE void glm_vec4_negate(vec4 v) { glm_vec4_negate_to(v, v); } /*! * @brief normalize vec4 to dest * * @param[in] v source * @param[out] dest destination */ CGLM_INLINE void glm_vec4_normalize_to(vec4 v, vec4 dest) { #if defined(__wasm__) && defined(__wasm_simd128__) glmm_128 xdot, x0; float dot; x0 = glmm_load(v); xdot = glmm_vdot(x0, x0); /* dot = _mm_cvtss_f32(xdot); */ dot = wasm_f32x4_extract_lane(xdot, 0); if (CGLM_UNLIKELY(dot < FLT_EPSILON)) { glmm_store(dest, wasm_f32x4_const_splat(0.f)); return; } glmm_store(dest, glmm_div(x0, wasm_f32x4_sqrt(xdot))); #elif defined( __SSE__ ) || defined( __SSE2__ ) __m128 xdot, x0; float dot; x0 = glmm_load(v); xdot = glmm_vdot(x0, x0); dot = _mm_cvtss_f32(xdot); if (CGLM_UNLIKELY(dot < FLT_EPSILON)) { glmm_store(dest, _mm_setzero_ps()); return; } glmm_store(dest, glmm_div(x0, _mm_sqrt_ps(xdot))); #else float norm; norm = glm_vec4_norm(v); if (CGLM_UNLIKELY(norm < FLT_EPSILON)) { glm_vec4_zero(dest); return; } glm_vec4_scale(v, 1.0f / norm, dest); #endif } /*! * @brief normalize vec4 and store result in same vec * * @param[in, out] v vector */ CGLM_INLINE void glm_vec4_normalize(vec4 v) { glm_vec4_normalize_to(v, v); } /** * @brief distance between two vectors * * @param[in] a vector1 * @param[in] b vector2 * @return returns distance */ CGLM_INLINE float glm_vec4_distance(vec4 a, vec4 b) { #if defined(__wasm__) && defined(__wasm_simd128__) return glmm_norm(wasm_f32x4_sub(glmm_load(a), glmm_load(b))); #elif defined( __SSE__ ) || defined( __SSE2__ ) return glmm_norm(_mm_sub_ps(glmm_load(a), glmm_load(b))); #elif defined(CGLM_NEON_FP) return glmm_norm(vsubq_f32(glmm_load(a), glmm_load(b))); #else return sqrtf(glm_pow2(a[0] - b[0]) + glm_pow2(a[1] - b[1]) + glm_pow2(a[2] - b[2]) + glm_pow2(a[3] - b[3])); #endif } /** * @brief squared distance between two vectors * * @param[in] a vector1 * @param[in] b vector2 * @return returns squared distance */ CGLM_INLINE float glm_vec4_distance2(vec4 a, vec4 b) { #if defined(__wasm__) && defined(__wasm_simd128__) return glmm_norm2(wasm_f32x4_sub(glmm_load(a), glmm_load(b))); #elif defined( __SSE__ ) || defined( __SSE2__ ) return glmm_norm2(_mm_sub_ps(glmm_load(a), glmm_load(b))); #elif defined(CGLM_NEON_FP) return glmm_norm2(vsubq_f32(glmm_load(a), glmm_load(b))); #else return glm_pow2(a[0] - b[0]) + glm_pow2(a[1] - b[1]) + glm_pow2(a[2] - b[2]) + glm_pow2(a[3] - b[3]); #endif } /*! * @brief max values of vectors * * @param[in] a vector1 * @param[in] b vector2 * @param[out] dest destination */ CGLM_INLINE void glm_vec4_maxv(vec4 a, vec4 b, vec4 dest) { #if defined(CGLM_SIMD) glmm_store(dest, glmm_max(glmm_load(a), glmm_load(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 min values of vectors * * @param[in] a vector1 * @param[in] b vector2 * @param[out] dest destination */ CGLM_INLINE void glm_vec4_minv(vec4 a, vec4 b, vec4 dest) { #if defined(CGLM_SIMD) glmm_store(dest, glmm_min(glmm_load(a), glmm_load(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 clamp vector's individual members between min and max values * * @param[in, out] v vector * @param[in] minVal minimum value * @param[in] maxVal maximum value */ CGLM_INLINE void glm_vec4_clamp(vec4 v, float minVal, float maxVal) { #if defined(__wasm__) && defined(__wasm_simd128__) glmm_store(v, glmm_min(glmm_max(glmm_load(v), wasm_f32x4_splat(minVal)), wasm_f32x4_splat(maxVal))); #elif defined( __SSE__ ) || defined( __SSE2__ ) glmm_store(v, glmm_min(glmm_max(glmm_load(v), glmm_set1(minVal)), glmm_set1(maxVal))); #elif defined(CGLM_NEON_FP) glmm_store(v, glmm_min(glmm_max(vld1q_f32(v), vdupq_n_f32(minVal)), vdupq_n_f32(maxVal))); #else v[0] = glm_clamp(v[0], minVal, maxVal); v[1] = glm_clamp(v[1], minVal, maxVal); v[2] = glm_clamp(v[2], minVal, maxVal); v[3] = glm_clamp(v[3], minVal, maxVal); #endif } /*! * @brief linear interpolation between two vectors * * formula: from + t * (to - from) * * @param[in] from from value * @param[in] to to value * @param[in] t interpolant (amount) * @param[out] dest destination */ CGLM_INLINE void glm_vec4_lerp(vec4 from, vec4 to, float t, vec4 dest) { vec4 s, v; /* from + s * (to - from) */ glm_vec4_broadcast(t, s); glm_vec4_sub(to, from, v); glm_vec4_mul(s, v, v); glm_vec4_add(from, v, dest); } /*! * @brief linear interpolation between two vectors (clamped) * * formula: from + t * (to - from) * * @param[in] from from value * @param[in] to to value * @param[in] t interpolant (amount) clamped between 0 and 1 * @param[out] dest destination */ CGLM_INLINE void glm_vec4_lerpc(vec4 from, vec4 to, float t, vec4 dest) { glm_vec4_lerp(from, to, glm_clamp_zo(t), dest); } /*! * @brief linear interpolation between two vectors * * formula: from + t * (to - from) * * @param[in] from from value * @param[in] to to value * @param[in] t interpolant (amount) * @param[out] dest destination */ CGLM_INLINE void glm_vec4_mix(vec4 from, vec4 to, float t, vec4 dest) { glm_vec4_lerp(from, to, t, dest); } /*! * @brief linear interpolation between two vectors (clamped) * * formula: from + t * (to - from) * * @param[in] from from value * @param[in] to to value * @param[in] t interpolant (amount) clamped between 0 and 1 * @param[out] dest destination */ CGLM_INLINE void glm_vec4_mixc(vec4 from, vec4 to, float t, vec4 dest) { glm_vec4_lerpc(from, to, t, dest); } /*! * @brief threshold function * * @param[in] edge threshold * @param[in] x value to test against threshold * @param[out] dest destination */ CGLM_INLINE void glm_vec4_step(vec4 edge, vec4 x, vec4 dest) { dest[0] = glm_step(edge[0], x[0]); dest[1] = glm_step(edge[1], x[1]); dest[2] = glm_step(edge[2], x[2]); dest[3] = glm_step(edge[3], x[3]); } /*! * @brief threshold function with a smooth transition (unidimensional) * * @param[in] edge0 low threshold * @param[in] edge1 high threshold * @param[in] x value to test against threshold * @param[out] dest destination */ CGLM_INLINE void glm_vec4_smoothstep_uni(float edge0, float edge1, vec4 x, vec4 dest) { dest[0] = glm_smoothstep(edge0, edge1, x[0]); dest[1] = glm_smoothstep(edge0, edge1, x[1]); dest[2] = glm_smoothstep(edge0, edge1, x[2]); dest[3] = glm_smoothstep(edge0, edge1, x[3]); } /*! * @brief threshold function with a smooth transition * * @param[in] edge0 low threshold * @param[in] edge1 high threshold * @param[in] x value to test against threshold * @param[out] dest destination */ CGLM_INLINE void glm_vec4_smoothstep(vec4 edge0, vec4 edge1, vec4 x, vec4 dest) { dest[0] = glm_smoothstep(edge0[0], edge1[0], x[0]); dest[1] = glm_smoothstep(edge0[1], edge1[1], x[1]); dest[2] = glm_smoothstep(edge0[2], edge1[2], x[2]); dest[3] = glm_smoothstep(edge0[3], edge1[3], x[3]); } /*! * @brief smooth Hermite interpolation between two vectors * * formula: t^2 * (3 - 2*t) * * @param[in] from from value * @param[in] to to value * @param[in] t interpolant (amount) * @param[out] dest destination */ CGLM_INLINE void glm_vec4_smoothinterp(vec4 from, vec4 to, float t, vec4 dest) { vec4 s, v; /* from + smoothstep * (to - from) */ glm_vec4_broadcast(glm_smooth(t), s); glm_vec4_sub(to, from, v); glm_vec4_mul(s, v, v); glm_vec4_add(from, v, dest); } /*! * @brief smooth Hermite interpolation between two vectors (clamped) * * formula: t^2 * (3 - 2*t) * * @param[in] from from value * @param[in] to to value * @param[in] t interpolant (amount) clamped between 0 and 1 * @param[out] dest destination */ CGLM_INLINE void glm_vec4_smoothinterpc(vec4 from, vec4 to, float t, vec4 dest) { glm_vec4_smoothinterp(from, to, glm_clamp_zo(t), dest); } /*! * @brief helper to fill vec4 as [S^3, S^2, S, 1] * * @param[in] s parameter * @param[out] dest destination */ CGLM_INLINE void glm_vec4_cubic(float s, vec4 dest) { float ss; ss = s * s; dest[0] = ss * s; dest[1] = ss; dest[2] = s; dest[3] = 1.0f; } /*! * @brief swizzle vector components * * you can use existing masks e.g. GLM_XXXX, GLM_WZYX * * @param[in] v source * @param[in] mask mask * @param[out] dest destination */ CGLM_INLINE void glm_vec4_swizzle(vec4 v, int mask, vec4 dest) { vec4 t; t[0] = v[(mask & (3 << 0))]; t[1] = v[(mask & (3 << 2)) >> 2]; t[2] = v[(mask & (3 << 4)) >> 4]; t[3] = v[(mask & (3 << 6)) >> 6]; glm_vec4_copy(t, dest); } /*! * @brief Create four dimensional vector from pointer * * @param[in] src pointer to an array of floats * @param[out] dest destination vector */ CGLM_INLINE void glm_vec4_make(const float * __restrict src, vec4 dest) { dest[0] = src[0]; dest[1] = src[1]; dest[2] = src[2]; dest[3] = src[3]; } /*! * @brief reflection vector using an incident ray and a surface normal * * @param[in] v incident vector * @param[in] n normalized normal vector * @param[out] dest destination vector for the reflection result */ CGLM_INLINE void glm_vec4_reflect(vec4 v, vec4 n, vec4 dest) { vec4 temp; /* TODO: direct simd touch */ glm_vec4_scale(n, 2.0f * glm_vec4_dot(v, n), temp); glm_vec4_sub(v, temp, dest); dest[3] = v[3]; } /*! * @brief computes refraction vector for an incident vector and a surface normal. * * calculates the refraction vector based on Snell's law. If total internal reflection * occurs (angle too great given eta), dest is set to zero and returns false. * Otherwise, computes refraction vector, stores it in dest, and returns true. * * this implementation does not explicitly preserve the 'w' component of the * incident vector 'I' in the output 'dest', users requiring the preservation of * the 'w' component should manually adjust 'dest' after calling this function. * * @param[in] v normalized incident vector * @param[in] n normalized normal vector * @param[in] eta ratio of indices of refraction (incident/transmitted) * @param[out] dest refraction vector if refraction occurs; zero vector otherwise * * @returns true if refraction occurs; false if total internal reflection occurs. */ CGLM_INLINE bool glm_vec4_refract(vec4 v, vec4 n, float eta, vec4 dest) { float ndi, eni, k; ndi = glm_vec4_dot(n, v); eni = eta * ndi; k = 1.0f - eta * eta + eni * eni; if (k < 0.0f) { glm_vec4_zero(dest); return false; } glm_vec4_scale(v, eta, dest); glm_vec4_mulsubs(n, eni + sqrtf(k), dest); return true; } #endif /* cglm_vec4_h */ cglm-0.9.6/include/cglm/version.h000066400000000000000000000004721475344456400166760ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ #ifndef cglm_version_h #define cglm_version_h #define CGLM_VERSION_MAJOR 0 #define CGLM_VERSION_MINOR 9 #define CGLM_VERSION_PATCH 6 #endif /* cglm_version_h */ cglm-0.9.6/include/module.modulemap000066400000000000000000000003071475344456400173050ustar00rootroot00000000000000module cglm { header "cglm/cglm.h" header "cglm/struct.h" export * } module cglmc { header "cglm/cglm.h" header "cglm/struct.h" header "cglm/call.h" export * } cglm-0.9.6/meson.build000066400000000000000000000064741475344456400146450ustar00rootroot00000000000000project('cglm', 'c', version : '0.9.6', license : 'mit', default_options : [ 'c_std=c11', 'warning_level=2', 'buildtype=release' ] ) cc = meson.get_compiler('c') cglm_install = get_option('install') cglm_deps = cc.find_library('m', required : false) cglm_args = [] build_args = [] if get_option('default_library') == 'static' cglm_args += '-DCGLM_STATIC' endif if cc.compiles( 'int *test(char *p) { return (int*)__builtin_assume_aligned(p, 4); }', name : '__builtin_assume_aligned test') cglm_args += '-DCGLM_HAVE_BUILTIN_ASSUME_ALIGNED=1' else cglm_args += '-DCGLM_HAVE_BUILTIN_ASSUME_ALIGNED=0' endif if host_machine.system() == 'windows' build_args += '-DCGLM_EXPORTS' endif cglm_inc = include_directories('include') cglm_src = files( 'src/euler.c', 'src/affine.c', 'src/io.c', 'src/quat.c', 'src/cam.c', 'src/vec2.c', 'src/ivec2.c', 'src/vec3.c', 'src/ivec3.c', 'src/vec4.c', 'src/ivec4.c', 'src/mat2.c', 'src/mat2x3.c', 'src/mat2x4.c', 'src/mat3.c', 'src/mat3x2.c', 'src/mat3x4.c', 'src/mat4.c', 'src/mat4x2.c', 'src/mat4x3.c', 'src/plane.c', 'src/noise.c', 'src/frustum.c', 'src/box.c', 'src/aabb2d.c', 'src/project.c', 'src/sphere.c', 'src/ease.c', 'src/curve.c', 'src/bezier.c', 'src/ray.c', 'src/affine2d.c', 'src/clipspace/ortho_lh_no.c', 'src/clipspace/ortho_lh_zo.c', 'src/clipspace/ortho_rh_no.c', 'src/clipspace/ortho_rh_zo.c', 'src/clipspace/persp_lh_no.c', 'src/clipspace/persp_lh_zo.c', 'src/clipspace/persp_rh_no.c', 'src/clipspace/persp_rh_zo.c', 'src/clipspace/view_lh_no.c', 'src/clipspace/view_lh_zo.c', 'src/clipspace/view_rh_no.c', 'src/clipspace/view_rh_zo.c', 'src/clipspace/project_no.c', 'src/clipspace/project_zo.c' ) cglm_lib = library('cglm', cglm_src, install : cglm_install, dependencies : cglm_deps, c_args : [ build_args, cglm_args ], version : meson.project_version(), soversion : '0', build_by_default: not meson.is_subproject() ) cglm_dep = declare_dependency( link_with : cglm_lib, dependencies : cglm_deps, compile_args : cglm_args, include_directories : cglm_inc, version : meson.project_version() ) if meson.version().version_compare('>= 0.54.0') meson.override_dependency('cglm', cglm_dep) endif if cglm_install install_subdir('include/cglm', install_dir : get_option('includedir')) pkg = import('pkgconfig') pkg.generate( name : 'cglm', libraries : cglm_lib, extra_cflags : cglm_args, version : meson.project_version(), url : 'https://github.com/recp/cglm', description : 'OpenGL Mathematics (glm) for C' ) endif if get_option('build_tests') == true test_src = files( 'test/runner.c', 'test/src/test_bezier.c', 'test/src/test_clamp.c', 'test/src/test_common.c', 'test/src/test_euler.c', 'test/src/tests.c', 'test/src/test_struct.c', ) test_exe = executable('tests', test_src, dependencies : cglm_dep, c_args : '-DGLM_TESTS_NO_COLORFUL_OUTPUT' ) test('cglm.tests', test_exe) endif cglm-0.9.6/meson_options.txt000066400000000000000000000003371475344456400161300ustar00rootroot00000000000000option('build_tests', type : 'boolean', value : false, description : 'Build tests') option('install', type : 'boolean', value : true, description : 'Include the library, headers, and pkg-config file in the install target') cglm-0.9.6/src/000077500000000000000000000000001475344456400132575ustar00rootroot00000000000000cglm-0.9.6/src/aabb2d.c000066400000000000000000000036701475344456400145440ustar00rootroot00000000000000/* * 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_zero(vec2 aabb[2]) { glm_aabb2d_zero(aabb); } 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_diag(vec2 aabb[2]) { return glm_aabb2d_diag(aabb); } CGLM_EXPORT void glmc_aabb2d_sizev(vec2 aabb[2], vec2 dest) { glm_aabb2d_sizev(aabb, dest); } 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); } cglm-0.9.6/src/affine.c000066400000000000000000000066741475344456400146700ustar00rootroot00000000000000/* * 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_translate_make(mat4 m, vec3 v) { glm_translate_make(m, v); } CGLM_EXPORT void glmc_translate_to(mat4 m, vec3 v, mat4 dest) { glm_translate_to(m, v, dest); } CGLM_EXPORT void glmc_translate(mat4 m, vec3 v) { glm_translate(m, v); } CGLM_EXPORT void glmc_translate_x(mat4 m, float to) { glm_translate_x(m, to); } CGLM_EXPORT void glmc_translate_y(mat4 m, float to) { glm_translate_y(m, to); } CGLM_EXPORT void glmc_translate_z(mat4 m, float to) { glm_translate_z(m, to); } CGLM_EXPORT void glmc_scale_make(mat4 m, vec3 v) { glm_scale_make(m, v); } CGLM_EXPORT void glmc_scale_to(mat4 m, vec3 v, mat4 dest) { glm_scale_to(m, v, dest); } CGLM_EXPORT void glmc_scale(mat4 m, vec3 v) { glm_scale(m, v); } CGLM_EXPORT void glmc_scale_uni(mat4 m, float s) { glm_scale_uni(m, s); } CGLM_EXPORT void glmc_rotate_x(mat4 m, float rad, mat4 dest) { glm_rotate_x(m, rad, dest); } CGLM_EXPORT void glmc_rotate_y(mat4 m, float rad, mat4 dest) { glm_rotate_y(m, rad, dest); } CGLM_EXPORT void glmc_rotate_z(mat4 m, float rad, mat4 dest) { glm_rotate_z(m, rad, dest); } CGLM_EXPORT void glmc_rotate_make(mat4 m, float angle, vec3 axis) { glm_rotate_make(m, angle, axis); } CGLM_EXPORT void glmc_rotate(mat4 m, float angle, vec3 axis) { glm_rotate(m, angle, axis); } CGLM_EXPORT void glmc_rotate_at(mat4 m, vec3 pivot, float angle, vec3 axis) { glm_rotate_at(m, pivot, angle, axis); } CGLM_EXPORT void glmc_rotate_atm(mat4 m, vec3 pivot, float angle, vec3 axis) { glm_rotate_atm(m, pivot, angle, axis); } CGLM_EXPORT void glmc_spin(mat4 m, float angle, vec3 axis) { glm_spin(m, angle, axis); } CGLM_EXPORT void glmc_decompose_scalev(mat4 m, vec3 s) { glm_decompose_scalev(m, s); } CGLM_EXPORT bool glmc_uniscaled(mat4 m) { return glm_uniscaled(m); } CGLM_EXPORT void glmc_decompose_rs(mat4 m, mat4 r, vec3 s) { glm_decompose_rs(m, r, s); } CGLM_EXPORT void glmc_translated(mat4 m, vec3 v) { glm_translated(m, v); } CGLM_EXPORT void glmc_translated_to(mat4 m, vec3 v, mat4 dest) { glm_translated_to(m, v, dest); } CGLM_EXPORT void glmc_translated_x(mat4 m, float x) { glm_translated_x(m, x); } CGLM_EXPORT void glmc_translated_y(mat4 m, float y) { glm_translated_y(m, y); } CGLM_EXPORT void glmc_translated_z(mat4 m, float z) { glm_translated_z(m, z); } CGLM_EXPORT void glmc_rotated_x(mat4 m, float angle, mat4 dest) { glm_rotated_x(m, angle, dest); } CGLM_EXPORT void glmc_rotated_y(mat4 m, float angle, mat4 dest) { glm_rotated_y(m, angle, dest); } CGLM_EXPORT void glmc_rotated_z(mat4 m, float angle, mat4 dest) { glm_rotated_z(m, angle, dest); } CGLM_EXPORT void glmc_rotated(mat4 m, float angle, vec3 axis) { glm_rotated(m, angle, axis); } CGLM_EXPORT void glmc_rotated_at(mat4 m, vec3 pivot, float angle, vec3 axis) { glm_rotated_at(m, pivot, angle, axis); } CGLM_EXPORT void glmc_spinned(mat4 m, float angle, vec3 axis) { glm_spinned(m, angle, axis); } CGLM_EXPORT void glmc_decompose(mat4 m, vec4 t, mat4 r, vec3 s) { glm_decompose(m, t, r, s); } CGLM_EXPORT void glmc_mul(mat4 m1, mat4 m2, mat4 dest) { glm_mul(m1, m2, dest); } CGLM_EXPORT void glmc_mul_rot(mat4 m1, mat4 m2, mat4 dest) { glm_mul_rot(m1, m2, dest); } CGLM_EXPORT void glmc_inv_tr(mat4 mat) { glm_inv_tr(mat); } cglm-0.9.6/src/affine2d.c000066400000000000000000000023761475344456400151110ustar00rootroot00000000000000/* * 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_translate2d_make(mat3 m, vec2 v) { glm_translate2d_make(m, v); } CGLM_EXPORT void glmc_translate2d_to(mat3 m, vec2 v, mat3 dest) { glm_translate2d_to(m, v, dest); } CGLM_EXPORT void glmc_translate2d(mat3 m, vec2 v) { glm_translate2d(m, v); } CGLM_EXPORT void glmc_translate2d_x(mat3 m, float to) { glm_translate2d_x(m, to); } CGLM_EXPORT void glmc_translate2d_y(mat3 m, float to) { glm_translate2d_y(m, to); } CGLM_EXPORT void glmc_scale2d_to(mat3 m, vec2 v, mat3 dest) { glm_scale2d_to(m, v, dest); } CGLM_EXPORT void glmc_scale2d_make(mat3 m, vec2 v) { glm_scale2d_make(m, v); } CGLM_EXPORT void glmc_scale2d(mat3 m, vec2 v) { glm_scale2d(m, v); } CGLM_EXPORT void glmc_scale2d_uni(mat3 m, float s) { glm_scale2d_uni(m, s); } CGLM_EXPORT void glmc_rotate2d_make(mat3 m, float angle) { glm_rotate2d_make(m, angle); } CGLM_EXPORT void glmc_rotate2d(mat3 m, float angle) { glm_rotate2d(m, angle); } CGLM_EXPORT void glmc_rotate2d_to(mat3 m, float angle, mat3 dest) { glm_rotate2d_to(m, angle, dest); } cglm-0.9.6/src/bezier.c000066400000000000000000000011371475344456400147050ustar00rootroot00000000000000/* * 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 float glmc_bezier(float s, float p0, float c0, float c1, float p1) { return glm_bezier(s, p0, c0, c1, p1); } CGLM_EXPORT float glmc_hermite(float s, float p0, float t0, float t1, float p1) { return glm_hermite(s, p0, t0, t1, p1); } CGLM_EXPORT float glmc_decasteljau(float prm, float p0, float c0, float c1, float p1) { return glm_decasteljau(prm, p0, c0, c1, p1); } cglm-0.9.6/src/box.c000066400000000000000000000032761475344456400142230ustar00rootroot00000000000000/* * 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_aabb_transform(vec3 box[2], mat4 m, vec3 dest[2]) { glm_aabb_transform(box, m, dest); } CGLM_EXPORT void glmc_aabb_merge(vec3 box1[2], vec3 box2[2], vec3 dest[2]) { glm_aabb_merge(box1, box2, dest); } CGLM_EXPORT void glmc_aabb_crop(vec3 box[2], vec3 cropBox[2], vec3 dest[2]) { glm_aabb_crop(box, cropBox, dest); } CGLM_EXPORT void glmc_aabb_crop_until(vec3 box[2], vec3 cropBox[2], vec3 clampBox[2], vec3 dest[2]) { glm_aabb_crop_until(box, cropBox, clampBox, dest); } CGLM_EXPORT bool glmc_aabb_frustum(vec3 box[2], vec4 planes[6]) { return glm_aabb_frustum(box, planes); } CGLM_EXPORT void glmc_aabb_invalidate(vec3 box[2]) { glm_aabb_invalidate(box); } CGLM_EXPORT bool glmc_aabb_isvalid(vec3 box[2]) { return glm_aabb_isvalid(box); } CGLM_EXPORT float glmc_aabb_size(vec3 box[2]) { return glm_aabb_size(box); } CGLM_EXPORT float glmc_aabb_radius(vec3 box[2]) { return glm_aabb_radius(box); } CGLM_EXPORT void glmc_aabb_center(vec3 box[2], vec3 dest) { glm_aabb_center(box, dest); } CGLM_EXPORT bool glmc_aabb_aabb(vec3 box[2], vec3 other[2]) { return glm_aabb_aabb(box, other); } CGLM_EXPORT bool glmc_aabb_point(vec3 box[2], vec3 point) { return glm_aabb_point(box, point); } CGLM_EXPORT bool glmc_aabb_contains(vec3 box[2], vec3 other[2]) { return glm_aabb_contains(box, other); } CGLM_EXPORT bool glmc_aabb_sphere(vec3 box[2], vec4 s) { return glm_aabb_sphere(box, s); } cglm-0.9.6/src/cam.c000066400000000000000000000067501475344456400141730ustar00rootroot00000000000000/* * 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_frustum(float left, float right, float bottom, float top, float nearZ, float farZ, mat4 dest) { glm_frustum(left, right, bottom, top, nearZ, farZ, dest); } CGLM_EXPORT void glmc_ortho(float left, float right, float bottom, float top, float nearZ, float farZ, mat4 dest) { glm_ortho(left, right, bottom, top, nearZ, farZ, dest); } CGLM_EXPORT void glmc_ortho_aabb(vec3 box[2], mat4 dest) { glm_ortho_aabb(box, dest); } CGLM_EXPORT void glmc_ortho_aabb_p(vec3 box[2], float padding, mat4 dest) { glm_ortho_aabb_p(box, padding, dest); } CGLM_EXPORT void glmc_ortho_aabb_pz(vec3 box[2], float padding, mat4 dest) { glm_ortho_aabb_pz(box, padding, dest); } CGLM_EXPORT void glmc_ortho_default(float aspect, mat4 dest) { glm_ortho_default(aspect, dest); } CGLM_EXPORT void glmc_ortho_default_s(float aspect, float size, mat4 dest) { glm_ortho_default_s(aspect, size, dest); } CGLM_EXPORT void glmc_perspective(float fovy, float aspect, float nearZ, float farZ, mat4 dest) { glm_perspective(fovy, aspect, nearZ, farZ, dest); } CGLM_EXPORT void glmc_persp_move_far(mat4 proj, float deltaFar) { glm_persp_move_far(proj, deltaFar); } CGLM_EXPORT void glmc_perspective_default(float aspect, mat4 dest) { glm_perspective_default(aspect, dest); } CGLM_EXPORT void glmc_perspective_resize(float aspect, mat4 proj) { glm_perspective_resize(aspect, proj); } CGLM_EXPORT void glmc_lookat(vec3 eye, vec3 center, vec3 up, mat4 dest) { glm_lookat(eye, center, up, dest); } CGLM_EXPORT void glmc_look(vec3 eye, vec3 dir, vec3 up, mat4 dest) { glm_look(eye, dir, up, dest); } CGLM_EXPORT void glmc_look_anyup(vec3 eye, vec3 dir, mat4 dest) { glm_look_anyup(eye, dir, dest); } CGLM_EXPORT void glmc_persp_decomp(mat4 proj, float * __restrict nearZ, float * __restrict farZ, float * __restrict top, float * __restrict bottom, float * __restrict left, float * __restrict right) { glm_persp_decomp(proj, nearZ, farZ, top, bottom, left, right); } CGLM_EXPORT void glmc_persp_decompv(mat4 proj, float dest[6]) { glm_persp_decompv(proj, dest); } CGLM_EXPORT void glmc_persp_decomp_x(mat4 proj, float * __restrict left, float * __restrict right) { glm_persp_decomp_x(proj, left, right); } CGLM_EXPORT void glmc_persp_decomp_y(mat4 proj, float * __restrict top, float * __restrict bottom) { glm_persp_decomp_y(proj, top, bottom); } CGLM_EXPORT void glmc_persp_decomp_z(mat4 proj, float * __restrict nearZ, float * __restrict farZ) { glm_persp_decomp_z(proj, nearZ, farZ); } CGLM_EXPORT void glmc_persp_decomp_far(mat4 proj, float * __restrict farZ) { glm_persp_decomp_far(proj, farZ); } CGLM_EXPORT void glmc_persp_decomp_near(mat4 proj, float * __restrict nearZ) { glm_persp_decomp_near(proj, nearZ); } CGLM_EXPORT float glmc_persp_fovy(mat4 proj) { return glm_persp_fovy(proj); } CGLM_EXPORT float glmc_persp_aspect(mat4 proj) { return glm_persp_aspect(proj); } CGLM_EXPORT void glmc_persp_sizes(mat4 proj, float fovy, vec4 dest) { glm_persp_sizes(proj, fovy, dest); } cglm-0.9.6/src/clipspace/000077500000000000000000000000001475344456400152225ustar00rootroot00000000000000cglm-0.9.6/src/clipspace/ortho_lh_no.c000066400000000000000000000022351475344456400177020ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ #include "../../include/cglm/clipspace/ortho_lh_no.h" #include "../../include/cglm/call/clipspace/ortho_lh_no.h" CGLM_EXPORT void glmc_ortho_lh_no(float left, float right, float bottom, float top, float nearZ, float farZ, mat4 dest) { glm_ortho_lh_no(left, right, bottom, top, nearZ, farZ, dest); } CGLM_EXPORT void glmc_ortho_aabb_lh_no(vec3 box[2], mat4 dest) { glm_ortho_aabb_lh_no(box, dest); } CGLM_EXPORT void glmc_ortho_aabb_p_lh_no(vec3 box[2], float padding, mat4 dest) { glm_ortho_aabb_p_lh_no(box, padding, dest); } CGLM_EXPORT void glmc_ortho_aabb_pz_lh_no(vec3 box[2], float padding, mat4 dest) { glm_ortho_aabb_pz_lh_no(box, padding, dest); } CGLM_EXPORT void glmc_ortho_default_lh_no(float aspect, mat4 dest) { glm_ortho_default_lh_no(aspect, dest); } CGLM_EXPORT void glmc_ortho_default_s_lh_no(float aspect, float size, mat4 dest) { glm_ortho_default_s_lh_no(aspect, size, dest); } cglm-0.9.6/src/clipspace/ortho_lh_zo.c000066400000000000000000000022351475344456400177160ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ #include "../../include/cglm/clipspace/ortho_lh_zo.h" #include "../../include/cglm/call/clipspace/ortho_lh_zo.h" CGLM_EXPORT void glmc_ortho_lh_zo(float left, float right, float bottom, float top, float nearZ, float farZ, mat4 dest) { glm_ortho_lh_zo(left, right, bottom, top, nearZ, farZ, dest); } CGLM_EXPORT void glmc_ortho_aabb_lh_zo(vec3 box[2], mat4 dest) { glm_ortho_aabb_lh_zo(box, dest); } CGLM_EXPORT void glmc_ortho_aabb_p_lh_zo(vec3 box[2], float padding, mat4 dest) { glm_ortho_aabb_p_lh_zo(box, padding, dest); } CGLM_EXPORT void glmc_ortho_aabb_pz_lh_zo(vec3 box[2], float padding, mat4 dest) { glm_ortho_aabb_pz_lh_zo(box, padding, dest); } CGLM_EXPORT void glmc_ortho_default_lh_zo(float aspect, mat4 dest) { glm_ortho_default_lh_zo(aspect, dest); } CGLM_EXPORT void glmc_ortho_default_s_lh_zo(float aspect, float size, mat4 dest) { glm_ortho_default_s_lh_zo(aspect, size, dest); } cglm-0.9.6/src/clipspace/ortho_rh_no.c000066400000000000000000000022351475344456400177100ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ #include "../../include/cglm/clipspace/ortho_rh_no.h" #include "../../include/cglm/call/clipspace/ortho_rh_no.h" CGLM_EXPORT void glmc_ortho_rh_no(float left, float right, float bottom, float top, float nearZ, float farZ, mat4 dest) { glm_ortho_rh_no(left, right, bottom, top, nearZ, farZ, dest); } CGLM_EXPORT void glmc_ortho_aabb_rh_no(vec3 box[2], mat4 dest) { glm_ortho_aabb_rh_no(box, dest); } CGLM_EXPORT void glmc_ortho_aabb_p_rh_no(vec3 box[2], float padding, mat4 dest) { glm_ortho_aabb_p_rh_no(box, padding, dest); } CGLM_EXPORT void glmc_ortho_aabb_pz_rh_no(vec3 box[2], float padding, mat4 dest) { glm_ortho_aabb_pz_rh_no(box, padding, dest); } CGLM_EXPORT void glmc_ortho_default_rh_no(float aspect, mat4 dest) { glm_ortho_default_rh_no(aspect, dest); } CGLM_EXPORT void glmc_ortho_default_s_rh_no(float aspect, float size, mat4 dest) { glm_ortho_default_s_rh_no(aspect, size, dest); } cglm-0.9.6/src/clipspace/ortho_rh_zo.c000066400000000000000000000022351475344456400177240ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ #include "../../include/cglm/clipspace/ortho_rh_zo.h" #include "../../include/cglm/call/clipspace/ortho_rh_zo.h" CGLM_EXPORT void glmc_ortho_rh_zo(float left, float right, float bottom, float top, float nearZ, float farZ, mat4 dest) { glm_ortho_rh_zo(left, right, bottom, top, nearZ, farZ, dest); } CGLM_EXPORT void glmc_ortho_aabb_rh_zo(vec3 box[2], mat4 dest) { glm_ortho_aabb_rh_zo(box, dest); } CGLM_EXPORT void glmc_ortho_aabb_p_rh_zo(vec3 box[2], float padding, mat4 dest) { glm_ortho_aabb_p_rh_zo(box, padding, dest); } CGLM_EXPORT void glmc_ortho_aabb_pz_rh_zo(vec3 box[2], float padding, mat4 dest) { glm_ortho_aabb_pz_rh_zo(box, padding, dest); } CGLM_EXPORT void glmc_ortho_default_rh_zo(float aspect, mat4 dest) { glm_ortho_default_rh_zo(aspect, dest); } CGLM_EXPORT void glmc_ortho_default_s_rh_zo(float aspect, float size, mat4 dest) { glm_ortho_default_s_rh_zo(aspect, size, dest); } cglm-0.9.6/src/clipspace/persp_lh_no.c000066400000000000000000000052461475344456400177050ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ #include "../../include/cglm/clipspace/persp_lh_no.h" #include "../../include/cglm/call/clipspace/persp_lh_no.h" CGLM_EXPORT void glmc_frustum_lh_no(float left, float right, float bottom, float top, float nearZ, float farZ, mat4 dest) { glm_frustum_lh_no(left, right, bottom, top, nearZ, farZ, dest); } CGLM_EXPORT void glmc_perspective_lh_no(float fovy, float aspect, float nearVal, float farVal, mat4 dest) { glm_perspective_lh_no(fovy, aspect, nearVal, farVal, dest); } CGLM_EXPORT void glmc_persp_move_far_lh_no(mat4 proj, float deltaFar) { glm_persp_move_far_lh_no(proj, deltaFar); } CGLM_EXPORT void glmc_persp_decomp_lh_no(mat4 proj, float * __restrict nearZ, float * __restrict farZ, float * __restrict top, float * __restrict bottom, float * __restrict left, float * __restrict right) { glm_persp_decomp_lh_no(proj, nearZ, farZ, top, bottom, left, right); } CGLM_EXPORT void glmc_persp_decompv_lh_no(mat4 proj, float dest[6]) { glm_persp_decompv_lh_no(proj, dest); } CGLM_EXPORT void glmc_persp_decomp_x_lh_no(mat4 proj, float * __restrict left, float * __restrict right) { glm_persp_decomp_x_lh_no(proj, left, right); } CGLM_EXPORT void glmc_persp_decomp_y_lh_no(mat4 proj, float * __restrict top, float * __restrict bottom) { glm_persp_decomp_y_lh_no(proj, top, bottom); } CGLM_EXPORT void glmc_persp_decomp_z_lh_no(mat4 proj, float * __restrict nearZ, float * __restrict farZ) { glm_persp_decomp_z_lh_no(proj, nearZ, farZ); } CGLM_EXPORT void glmc_persp_decomp_far_lh_no(mat4 proj, float * __restrict farZ) { glm_persp_decomp_far_lh_no(proj, farZ); } CGLM_EXPORT void glmc_persp_decomp_near_lh_no(mat4 proj, float * __restrict nearZ) { glm_persp_decomp_near_lh_no(proj, nearZ); } CGLM_EXPORT void glmc_persp_sizes_lh_no(mat4 proj, float fovy, vec4 dest) { glm_persp_sizes_lh_no(proj, fovy, dest); } CGLM_EXPORT float glmc_persp_fovy_lh_no(mat4 proj) { return glm_persp_fovy_lh_no(proj); } CGLM_EXPORT float glmc_persp_aspect_lh_no(mat4 proj) { return glm_persp_aspect_lh_no(proj); } cglm-0.9.6/src/clipspace/persp_lh_zo.c000066400000000000000000000052461475344456400177210ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ #include "../../include/cglm/clipspace/persp_lh_zo.h" #include "../../include/cglm/call/clipspace/persp_lh_zo.h" CGLM_EXPORT void glmc_frustum_lh_zo(float left, float right, float bottom, float top, float nearZ, float farZ, mat4 dest) { glm_frustum_lh_zo(left, right, bottom, top, nearZ, farZ, dest); } CGLM_EXPORT void glmc_perspective_lh_zo(float fovy, float aspect, float nearVal, float farVal, mat4 dest) { glm_perspective_lh_zo(fovy, aspect, nearVal, farVal, dest); } CGLM_EXPORT void glmc_persp_move_far_lh_zo(mat4 proj, float deltaFar) { glm_persp_move_far_lh_zo(proj, deltaFar); } CGLM_EXPORT void glmc_persp_decomp_lh_zo(mat4 proj, float * __restrict nearZ, float * __restrict farZ, float * __restrict top, float * __restrict bottom, float * __restrict left, float * __restrict right) { glm_persp_decomp_lh_zo(proj, nearZ, farZ, top, bottom, left, right); } CGLM_EXPORT void glmc_persp_decompv_lh_zo(mat4 proj, float dest[6]) { glm_persp_decompv_lh_zo(proj, dest); } CGLM_EXPORT void glmc_persp_decomp_x_lh_zo(mat4 proj, float * __restrict left, float * __restrict right) { glm_persp_decomp_x_lh_zo(proj, left, right); } CGLM_EXPORT void glmc_persp_decomp_y_lh_zo(mat4 proj, float * __restrict top, float * __restrict bottom) { glm_persp_decomp_y_lh_zo(proj, top, bottom); } CGLM_EXPORT void glmc_persp_decomp_z_lh_zo(mat4 proj, float * __restrict nearZ, float * __restrict farZ) { glm_persp_decomp_z_lh_zo(proj, nearZ, farZ); } CGLM_EXPORT void glmc_persp_decomp_far_lh_zo(mat4 proj, float * __restrict farZ) { glm_persp_decomp_far_lh_zo(proj, farZ); } CGLM_EXPORT void glmc_persp_decomp_near_lh_zo(mat4 proj, float * __restrict nearZ) { glm_persp_decomp_near_lh_zo(proj, nearZ); } CGLM_EXPORT void glmc_persp_sizes_lh_zo(mat4 proj, float fovy, vec4 dest) { glm_persp_sizes_lh_zo(proj, fovy, dest); } CGLM_EXPORT float glmc_persp_fovy_lh_zo(mat4 proj) { return glm_persp_fovy_lh_zo(proj); } CGLM_EXPORT float glmc_persp_aspect_lh_zo(mat4 proj) { return glm_persp_aspect_lh_zo(proj); } cglm-0.9.6/src/clipspace/persp_rh_no.c000066400000000000000000000052461475344456400177130ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ #include "../../include/cglm/clipspace/persp_rh_no.h" #include "../../include/cglm/call/clipspace/persp_rh_no.h" CGLM_EXPORT void glmc_frustum_rh_no(float left, float right, float bottom, float top, float nearZ, float farZ, mat4 dest) { glm_frustum_rh_no(left, right, bottom, top, nearZ, farZ, dest); } CGLM_EXPORT void glmc_perspective_rh_no(float fovy, float aspect, float nearVal, float farVal, mat4 dest) { glm_perspective_rh_no(fovy, aspect, nearVal, farVal, dest); } CGLM_EXPORT void glmc_persp_move_far_rh_no(mat4 proj, float deltaFar) { glm_persp_move_far_rh_no(proj, deltaFar); } CGLM_EXPORT void glmc_persp_decomp_rh_no(mat4 proj, float * __restrict nearZ, float * __restrict farZ, float * __restrict top, float * __restrict bottom, float * __restrict left, float * __restrict right) { glm_persp_decomp_rh_no(proj, nearZ, farZ, top, bottom, left, right); } CGLM_EXPORT void glmc_persp_decompv_rh_no(mat4 proj, float dest[6]) { glm_persp_decompv_rh_no(proj, dest); } CGLM_EXPORT void glmc_persp_decomp_x_rh_no(mat4 proj, float * __restrict left, float * __restrict right) { glm_persp_decomp_x_rh_no(proj, left, right); } CGLM_EXPORT void glmc_persp_decomp_y_rh_no(mat4 proj, float * __restrict top, float * __restrict bottom) { glm_persp_decomp_y_rh_no(proj, top, bottom); } CGLM_EXPORT void glmc_persp_decomp_z_rh_no(mat4 proj, float * __restrict nearZ, float * __restrict farZ) { glm_persp_decomp_z_rh_no(proj, nearZ, farZ); } CGLM_EXPORT void glmc_persp_decomp_far_rh_no(mat4 proj, float * __restrict farZ) { glm_persp_decomp_far_rh_no(proj, farZ); } CGLM_EXPORT void glmc_persp_decomp_near_rh_no(mat4 proj, float * __restrict nearZ) { glm_persp_decomp_near_rh_no(proj, nearZ); } CGLM_EXPORT void glmc_persp_sizes_rh_no(mat4 proj, float fovy, vec4 dest) { glm_persp_sizes_rh_no(proj, fovy, dest); } CGLM_EXPORT float glmc_persp_fovy_rh_no(mat4 proj) { return glm_persp_fovy_rh_no(proj); } CGLM_EXPORT float glmc_persp_aspect_rh_no(mat4 proj) { return glm_persp_aspect_rh_no(proj); } cglm-0.9.6/src/clipspace/persp_rh_zo.c000066400000000000000000000052461475344456400177270ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ #include "../../include/cglm/clipspace/persp_rh_zo.h" #include "../../include/cglm/call/clipspace/persp_rh_zo.h" CGLM_EXPORT void glmc_frustum_rh_zo(float left, float right, float bottom, float top, float nearZ, float farZ, mat4 dest) { glm_frustum_rh_zo(left, right, bottom, top, nearZ, farZ, dest); } CGLM_EXPORT void glmc_perspective_rh_zo(float fovy, float aspect, float nearVal, float farVal, mat4 dest) { glm_perspective_rh_zo(fovy, aspect, nearVal, farVal, dest); } CGLM_EXPORT void glmc_persp_move_far_rh_zo(mat4 proj, float deltaFar) { glm_persp_move_far_rh_zo(proj, deltaFar); } CGLM_EXPORT void glmc_persp_decomp_rh_zo(mat4 proj, float * __restrict nearZ, float * __restrict farZ, float * __restrict top, float * __restrict bottom, float * __restrict left, float * __restrict right) { glm_persp_decomp_rh_zo(proj, nearZ, farZ, top, bottom, left, right); } CGLM_EXPORT void glmc_persp_decompv_rh_zo(mat4 proj, float dest[6]) { glm_persp_decompv_rh_zo(proj, dest); } CGLM_EXPORT void glmc_persp_decomp_x_rh_zo(mat4 proj, float * __restrict left, float * __restrict right) { glm_persp_decomp_x_rh_zo(proj, left, right); } CGLM_EXPORT void glmc_persp_decomp_y_rh_zo(mat4 proj, float * __restrict top, float * __restrict bottom) { glm_persp_decomp_y_rh_zo(proj, top, bottom); } CGLM_EXPORT void glmc_persp_decomp_z_rh_zo(mat4 proj, float * __restrict nearZ, float * __restrict farZ) { glm_persp_decomp_z_rh_zo(proj, nearZ, farZ); } CGLM_EXPORT void glmc_persp_decomp_far_rh_zo(mat4 proj, float * __restrict farZ) { glm_persp_decomp_far_rh_zo(proj, farZ); } CGLM_EXPORT void glmc_persp_decomp_near_rh_zo(mat4 proj, float * __restrict nearZ) { glm_persp_decomp_near_rh_zo(proj, nearZ); } CGLM_EXPORT void glmc_persp_sizes_rh_zo(mat4 proj, float fovy, vec4 dest) { glm_persp_sizes_rh_zo(proj, fovy, dest); } CGLM_EXPORT float glmc_persp_fovy_rh_zo(mat4 proj) { return glm_persp_fovy_rh_zo(proj); } CGLM_EXPORT float glmc_persp_aspect_rh_zo(mat4 proj) { return glm_persp_aspect_rh_zo(proj); } cglm-0.9.6/src/clipspace/project_no.c000066400000000000000000000011241475344456400175260ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ #include "../../include/cglm/clipspace/project_no.h" #include "../../include/cglm/call/clipspace/project_no.h" CGLM_EXPORT void glmc_unprojecti_no(vec3 pos, mat4 invMat, vec4 vp, vec3 dest) { glm_unprojecti_no(pos, invMat, vp, dest); } CGLM_EXPORT void glmc_project_no(vec3 pos, mat4 m, vec4 vp, vec3 dest) { glm_project_no(pos, m, vp, dest); } CGLM_EXPORT float glmc_project_z_no(vec3 pos, mat4 m) { return glm_project_z_no(pos, m); } cglm-0.9.6/src/clipspace/project_zo.c000066400000000000000000000011241475344456400175420ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ #include "../../include/cglm/clipspace/project_zo.h" #include "../../include/cglm/call/clipspace/project_zo.h" CGLM_EXPORT void glmc_unprojecti_zo(vec3 pos, mat4 invMat, vec4 vp, vec3 dest) { glm_unprojecti_zo(pos, invMat, vp, dest); } CGLM_EXPORT void glmc_project_zo(vec3 pos, mat4 m, vec4 vp, vec3 dest) { glm_project_zo(pos, m, vp, dest); } CGLM_EXPORT float glmc_project_z_zo(vec3 pos, mat4 m) { return glm_project_z_zo(pos, m); } cglm-0.9.6/src/clipspace/view_lh_no.c000066400000000000000000000011531475344456400175170ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ #include "../../include/cglm/clipspace/view_lh_no.h" #include "../../include/cglm/call/clipspace/view_lh_no.h" CGLM_EXPORT void glmc_lookat_lh_no(vec3 eye, vec3 center, vec3 up, mat4 dest) { glm_lookat_lh_no(eye, center, up, dest); } CGLM_EXPORT void glmc_look_lh_no(vec3 eye, vec3 dir, vec3 up, mat4 dest) { glm_look_lh_no(eye, dir, up, dest); } CGLM_EXPORT void glmc_look_anyup_lh_no(vec3 eye, vec3 dir, mat4 dest) { glm_look_anyup_lh_no(eye, dir, dest); } cglm-0.9.6/src/clipspace/view_lh_zo.c000066400000000000000000000011531475344456400175330ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ #include "../../include/cglm/clipspace/view_lh_zo.h" #include "../../include/cglm/call/clipspace/view_lh_zo.h" CGLM_EXPORT void glmc_lookat_lh_zo(vec3 eye, vec3 center, vec3 up, mat4 dest) { glm_lookat_lh_zo(eye, center, up, dest); } CGLM_EXPORT void glmc_look_lh_zo(vec3 eye, vec3 dir, vec3 up, mat4 dest) { glm_look_lh_zo(eye, dir, up, dest); } CGLM_EXPORT void glmc_look_anyup_lh_zo(vec3 eye, vec3 dir, mat4 dest) { glm_look_anyup_lh_zo(eye, dir, dest); } cglm-0.9.6/src/clipspace/view_rh_no.c000066400000000000000000000011531475344456400175250ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ #include "../../include/cglm/clipspace/view_rh_no.h" #include "../../include/cglm/call/clipspace/view_rh_no.h" CGLM_EXPORT void glmc_lookat_rh_no(vec3 eye, vec3 center, vec3 up, mat4 dest) { glm_lookat_rh_no(eye, center, up, dest); } CGLM_EXPORT void glmc_look_rh_no(vec3 eye, vec3 dir, vec3 up, mat4 dest) { glm_look_rh_no(eye, dir, up, dest); } CGLM_EXPORT void glmc_look_anyup_rh_no(vec3 eye, vec3 dir, mat4 dest) { glm_look_anyup_rh_no(eye, dir, dest); } cglm-0.9.6/src/clipspace/view_rh_zo.c000066400000000000000000000011531475344456400175410ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ #include "../../include/cglm/clipspace/view_rh_zo.h" #include "../../include/cglm/call/clipspace/view_rh_zo.h" CGLM_EXPORT void glmc_lookat_rh_zo(vec3 eye, vec3 center, vec3 up, mat4 dest) { glm_lookat_rh_zo(eye, center, up, dest); } CGLM_EXPORT void glmc_look_rh_zo(vec3 eye, vec3 dir, vec3 up, mat4 dest) { glm_look_rh_zo(eye, dir, up, dest); } CGLM_EXPORT void glmc_look_anyup_rh_zo(vec3 eye, vec3 dir, mat4 dest) { glm_look_anyup_rh_zo(eye, dir, dest); } cglm-0.9.6/src/config.h000066400000000000000000000006711475344456400147010ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ #ifndef cglm__config__h_ #define cglm__config__h_ #if defined(_WIN32) || defined(WIN32) /* Exclude rarely-used stuff from Windows headers */ # define WIN32_LEAN_AND_MEAN # include /* Windows Header Files: */ # include #endif #endif /* cglm__config__h_ */ cglm-0.9.6/src/curve.c000066400000000000000000000004571475344456400145550ustar00rootroot00000000000000/* * 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 float glmc_smc(float s, mat4 m, vec4 c) { return glm_smc(s, m, c); } cglm-0.9.6/src/ease.c000066400000000000000000000053671475344456400143530ustar00rootroot00000000000000/* * 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 float glmc_ease_linear(float t) { return glm_ease_linear(t); } CGLM_EXPORT float glmc_ease_sine_in(float t) { return glm_ease_sine_in(t); } CGLM_EXPORT float glmc_ease_sine_out(float t) { return glm_ease_sine_out(t); } CGLM_EXPORT float glmc_ease_sine_inout(float t) { return glm_ease_sine_inout(t); } CGLM_EXPORT float glmc_ease_quad_in(float t) { return glm_ease_quad_in(t); } CGLM_EXPORT float glmc_ease_quad_out(float t) { return glm_ease_quad_out(t); } CGLM_EXPORT float glmc_ease_quad_inout(float t) { return glm_ease_quad_inout(t); } CGLM_EXPORT float glmc_ease_cubic_in(float t) { return glm_ease_cubic_in(t); } CGLM_EXPORT float glmc_ease_cubic_out(float t) { return glm_ease_cubic_out(t); } CGLM_EXPORT float glmc_ease_cubic_inout(float t) { return glm_ease_cubic_inout(t); } CGLM_EXPORT float glmc_ease_quart_in(float t) { return glm_ease_quart_in(t); } CGLM_EXPORT float glmc_ease_quart_out(float t) { return glm_ease_quart_out(t); } CGLM_EXPORT float glmc_ease_quart_inout(float t) { return glm_ease_quart_inout(t); } CGLM_EXPORT float glmc_ease_quint_in(float t) { return glm_ease_quint_in(t); } CGLM_EXPORT float glmc_ease_quint_out(float t) { return glm_ease_quint_out(t); } CGLM_EXPORT float glmc_ease_quint_inout(float t) { return glm_ease_quint_inout(t); } CGLM_EXPORT float glmc_ease_exp_in(float t) { return glm_ease_exp_in(t); } CGLM_EXPORT float glmc_ease_exp_out(float t) { return glm_ease_exp_out(t); } CGLM_EXPORT float glmc_ease_exp_inout(float t) { return glm_ease_exp_inout(t); } CGLM_EXPORT float glmc_ease_circ_in(float t) { return glm_ease_circ_in(t); } CGLM_EXPORT float glmc_ease_circ_out(float t) { return glm_ease_circ_out(t); } CGLM_EXPORT float glmc_ease_circ_inout(float t) { return glm_ease_circ_inout(t); } CGLM_EXPORT float glmc_ease_back_in(float t) { return glm_ease_back_in(t); } CGLM_EXPORT float glmc_ease_back_out(float t) { return glm_ease_back_out(t); } CGLM_EXPORT float glmc_ease_back_inout(float t) { return glm_ease_back_inout(t); } CGLM_EXPORT float glmc_ease_elast_in(float t) { return glm_ease_elast_in(t); } CGLM_EXPORT float glmc_ease_elast_out(float t) { return glm_ease_elast_out(t); } CGLM_EXPORT float glmc_ease_elast_inout(float t) { return glm_ease_elast_inout(t); } CGLM_EXPORT float glmc_ease_bounce_out(float t) { return glm_ease_bounce_out(t); } CGLM_EXPORT float glmc_ease_bounce_in(float t) { return glm_ease_bounce_in(t); } CGLM_EXPORT float glmc_ease_bounce_inout(float t) { return glm_ease_bounce_inout(t); } cglm-0.9.6/src/euler.c000066400000000000000000000032411475344456400145370ustar00rootroot00000000000000/* * 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_euler_angles(mat4 m, vec3 dest) { glm_euler_angles(m, dest); } CGLM_EXPORT void glmc_euler(vec3 angles, mat4 dest) { glm_euler(angles, dest); } CGLM_EXPORT void glmc_euler_xyz(vec3 angles, mat4 dest) { glm_euler_xyz(angles, dest); } CGLM_EXPORT void glmc_euler_zyx(vec3 angles, mat4 dest) { glm_euler_zyx(angles, dest); } CGLM_EXPORT void glmc_euler_zxy(vec3 angles, mat4 dest) { glm_euler_zxy(angles, dest); } CGLM_EXPORT void glmc_euler_xzy(vec3 angles, mat4 dest) { glm_euler_xzy(angles, dest); } CGLM_EXPORT void glmc_euler_yzx(vec3 angles, mat4 dest) { glm_euler_yzx(angles, dest); } CGLM_EXPORT void glmc_euler_yxz(vec3 angles, mat4 dest) { glm_euler_yxz(angles, dest); } CGLM_EXPORT void glmc_euler_by_order(vec3 angles, glm_euler_seq axis, mat4 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); } cglm-0.9.6/src/frustum.c000066400000000000000000000016051475344456400151320ustar00rootroot00000000000000/* * 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_frustum_planes(mat4 m, vec4 dest[6]) { glm_frustum_planes(m, dest); } CGLM_EXPORT void glmc_frustum_corners(mat4 invMat, vec4 dest[8]) { glm_frustum_corners(invMat, dest); } CGLM_EXPORT void glmc_frustum_center(vec4 corners[8], vec4 dest) { glm_frustum_center(corners, dest); } CGLM_EXPORT void glmc_frustum_box(vec4 corners[8], mat4 m, vec3 box[2]) { glm_frustum_box(corners, m, box); } CGLM_EXPORT void glmc_frustum_corners_at(vec4 corners[8], float splitDist, float farDist, vec4 planeCorners[4]) { glm_frustum_corners_at(corners, splitDist, farDist, planeCorners); } cglm-0.9.6/src/io.c000066400000000000000000000015561475344456400140410ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ #define CGLM_LIB_SRC #include "../include/cglm/cglm.h" #include "../include/cglm/call.h" CGLM_EXPORT void glmc_mat4_print(mat4 matrix, FILE * __restrict ostream) { glm_mat4_print(matrix, ostream); } CGLM_EXPORT void glmc_mat3_print(mat3 matrix, FILE * __restrict ostream) { glm_mat3_print(matrix, ostream); } CGLM_EXPORT void glmc_vec4_print(vec4 vec, FILE * __restrict ostream) { glm_vec4_print(vec, ostream); } CGLM_EXPORT void glmc_vec3_print(vec3 vec, FILE * __restrict ostream) { glm_vec3_print(vec, ostream); } CGLM_EXPORT void glmc_versor_print(versor vec, FILE * __restrict ostream) { glm_versor_print(vec, ostream); } cglm-0.9.6/src/ivec2.c000066400000000000000000000076761475344456400144530ustar00rootroot00000000000000/* * 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_ivec2(int * __restrict v, ivec2 dest) { glm_ivec2(v, dest); } CGLM_EXPORT void glmc_ivec2_copy(ivec2 a, ivec2 dest) { glm_ivec2_copy(a, dest); } CGLM_EXPORT void glmc_ivec2_zero(ivec2 v) { glm_ivec2_zero(v); } CGLM_EXPORT void glmc_ivec2_one(ivec2 v) { glm_ivec2_one(v); } CGLM_EXPORT int glmc_ivec2_dot(ivec2 a, ivec2 b) { return glm_ivec2_dot(a, b); } CGLM_EXPORT int glmc_ivec2_cross(ivec2 a, ivec2 b) { return glm_ivec2_cross(a, b); } CGLM_EXPORT void glmc_ivec2_add(ivec2 a, ivec2 b, ivec2 dest) { glm_ivec2_add(a, b, dest); } CGLM_EXPORT void glmc_ivec2_adds(ivec2 v, int s, ivec2 dest) { glm_ivec2_adds(v, s, dest); } CGLM_EXPORT void glmc_ivec2_sub(ivec2 a, ivec2 b, ivec2 dest) { glm_ivec2_sub(a, b, dest); } CGLM_EXPORT void glmc_ivec2_subs(ivec2 v, int s, ivec2 dest) { glm_ivec2_subs(v, s, dest); } CGLM_EXPORT void glmc_ivec2_mul(ivec2 a, ivec2 b, ivec2 dest) { glm_ivec2_mul(a, b, dest); } CGLM_EXPORT void glmc_ivec2_scale(ivec2 v, int s, ivec2 dest) { glm_ivec2_scale(v, s, dest); } CGLM_EXPORT void glmc_ivec2_div(ivec2 a, ivec2 b, ivec2 dest) { glm_ivec2_div(a, b, dest); } CGLM_EXPORT void glmc_ivec2_divs(ivec2 v, int s, ivec2 dest) { glm_ivec2_divs(v, s, dest); } CGLM_EXPORT void glmc_ivec2_mod(ivec2 a, ivec2 b, ivec2 dest) { glm_ivec2_mod(a, b, 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 int glmc_ivec2_distance2(ivec2 a, ivec2 b) { return glm_ivec2_distance2(a, b); } CGLM_EXPORT float glmc_ivec2_distance(ivec2 a, ivec2 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 void glmc_ivec2_maxv(ivec2 a, ivec2 b, ivec2 dest) { glm_ivec2_maxv(a, b, dest); } CGLM_EXPORT void glmc_ivec2_minv(ivec2 a, ivec2 b, ivec2 dest) { glm_ivec2_minv(a, b, dest); } CGLM_EXPORT void glmc_ivec2_clamp(ivec2 v, int minVal, int maxVal) { glm_ivec2_clamp(v, minVal, maxVal); } CGLM_EXPORT void glmc_ivec2_abs(ivec2 v, ivec2 dest) { glm_ivec2_abs(v, dest); } cglm-0.9.6/src/ivec3.c000066400000000000000000000100241475344456400144310ustar00rootroot00000000000000/* * 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_ivec3(ivec4 v4, ivec3 dest) { glm_ivec3(v4, dest); } CGLM_EXPORT void glmc_ivec3_copy(ivec3 a, ivec3 dest) { glm_ivec3_copy(a, dest); } CGLM_EXPORT void glmc_ivec3_zero(ivec3 v) { glm_ivec3_zero(v); } CGLM_EXPORT void glmc_ivec3_one(ivec3 v) { glm_ivec3_one(v); } CGLM_EXPORT int glmc_ivec3_dot(ivec3 a, ivec3 b) { return glm_ivec3_dot(a, b); } CGLM_EXPORT int glmc_ivec3_norm2(ivec3 v) { return glm_ivec3_norm2(v); } CGLM_EXPORT int glmc_ivec3_norm(ivec3 v) { return glm_ivec3_norm(v); } CGLM_EXPORT void glmc_ivec3_add(ivec3 a, ivec3 b, ivec3 dest) { glm_ivec3_add(a, b, dest); } CGLM_EXPORT void glmc_ivec3_adds(ivec3 v, int s, ivec3 dest) { glm_ivec3_adds(v, s, dest); } CGLM_EXPORT void glmc_ivec3_sub(ivec3 a, ivec3 b, ivec3 dest) { glm_ivec3_sub(a, b, dest); } CGLM_EXPORT void glmc_ivec3_subs(ivec3 v, int s, ivec3 dest) { glm_ivec3_subs(v, s, dest); } CGLM_EXPORT void glmc_ivec3_mul(ivec3 a, ivec3 b, ivec3 dest) { glm_ivec3_mul(a, b, dest); } CGLM_EXPORT void glmc_ivec3_scale(ivec3 v, int s, ivec3 dest) { glm_ivec3_scale(v, s, dest); } CGLM_EXPORT void glmc_ivec3_div(ivec3 a, ivec3 b, ivec3 dest) { glm_ivec3_div(a, b, dest); } CGLM_EXPORT void glmc_ivec3_divs(ivec3 v, int s, ivec3 dest) { glm_ivec3_divs(v, s, dest); } CGLM_EXPORT void glmc_ivec3_mod(ivec3 a, ivec3 b, ivec3 dest) { glm_ivec3_mod(a, b, 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 int glmc_ivec3_distance2(ivec3 a, ivec3 b) { return glm_ivec3_distance2(a, b); } CGLM_EXPORT float glmc_ivec3_distance(ivec3 a, ivec3 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 void glmc_ivec3_maxv(ivec3 a, ivec3 b, ivec3 dest) { glm_ivec3_maxv(a, b, dest); } CGLM_EXPORT void glmc_ivec3_minv(ivec3 a, ivec3 b, ivec3 dest) { glm_ivec3_minv(a, b, dest); } CGLM_EXPORT void glmc_ivec3_clamp(ivec3 v, int minVal, int maxVal) { glm_ivec3_clamp(v, minVal, maxVal); } CGLM_EXPORT void glmc_ivec3_abs(ivec3 v, ivec3 dest) { glm_ivec3_abs(v, dest); } cglm-0.9.6/src/ivec4.c000066400000000000000000000064361475344456400144460ustar00rootroot00000000000000/* * 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_ivec4(ivec3 v3, int last, ivec4 dest) { glm_ivec4(v3, last, dest); } CGLM_EXPORT void glmc_ivec4_copy(ivec4 a, ivec4 dest) { glm_ivec4_copy(a, dest); } CGLM_EXPORT void glmc_ivec4_zero(ivec4 v) { glm_ivec4_zero(v); } CGLM_EXPORT void glmc_ivec4_one(ivec4 v) { glm_ivec4_one(v); } CGLM_EXPORT void glmc_ivec4_add(ivec4 a, ivec4 b, ivec4 dest) { glm_ivec4_add(a, b, dest); } CGLM_EXPORT void glmc_ivec4_adds(ivec4 v, int s, ivec4 dest) { glm_ivec4_adds(v, s, dest); } CGLM_EXPORT void glmc_ivec4_sub(ivec4 a, ivec4 b, ivec4 dest) { glm_ivec4_sub(a, b, dest); } CGLM_EXPORT void glmc_ivec4_subs(ivec4 v, int s, ivec4 dest) { glm_ivec4_subs(v, s, dest); } CGLM_EXPORT void glmc_ivec4_mul(ivec4 a, ivec4 b, ivec4 dest) { glm_ivec4_mul(a, b, dest); } CGLM_EXPORT void glmc_ivec4_scale(ivec4 v, int s, ivec4 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 int glmc_ivec4_distance2(ivec4 a, ivec4 b) { return glm_ivec4_distance2(a, b); } CGLM_EXPORT float glmc_ivec4_distance(ivec4 a, ivec4 b) { return glm_ivec4_distance(a, b); } CGLM_EXPORT void glmc_ivec4_maxv(ivec4 a, ivec4 b, ivec4 dest) { glm_ivec4_maxv(a, b, dest); } CGLM_EXPORT void glmc_ivec4_minv(ivec4 a, ivec4 b, ivec4 dest) { glm_ivec4_minv(a, b, dest); } CGLM_EXPORT void glmc_ivec4_clamp(ivec4 v, int minVal, int maxVal) { glm_ivec4_clamp(v, minVal, maxVal); } CGLM_EXPORT void glmc_ivec4_abs(ivec4 v, ivec4 dest) { glm_ivec4_abs(v, dest); } cglm-0.9.6/src/mat2.c000066400000000000000000000032011475344456400142620ustar00rootroot00000000000000/* * 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_mat2_copy(mat2 mat, mat2 dest) { glm_mat2_copy(mat, dest); } CGLM_EXPORT void glmc_mat2_identity(mat2 mat) { glm_mat2_identity(mat); } CGLM_EXPORT void glmc_mat2_identity_array(mat2 * __restrict mat, size_t count) { glm_mat2_identity_array(mat, count); } CGLM_EXPORT void glmc_mat2_zero(mat2 mat) { glm_mat2_zero(mat); } CGLM_EXPORT void glmc_mat2_mul(mat2 m1, mat2 m2, mat2 dest) { glm_mat2_mul(m1, m2, dest); } CGLM_EXPORT void glmc_mat2_transpose_to(mat2 m, mat2 dest) { glm_mat2_transpose_to(m, dest); } CGLM_EXPORT void glmc_mat2_transpose(mat2 m) { glm_mat2_transpose(m); } CGLM_EXPORT void glmc_mat2_mulv(mat2 m, vec2 v, vec2 dest) { glm_mat2_mulv(m, v, dest); } CGLM_EXPORT float glmc_mat2_trace(mat2 m) { return glm_mat2_trace(m); } CGLM_EXPORT void glmc_mat2_scale(mat2 m, float s) { glm_mat2_scale(m, s); } CGLM_EXPORT float glmc_mat2_det(mat2 mat) { return glm_mat2_det(mat); } CGLM_EXPORT void glmc_mat2_inv(mat2 mat, mat2 dest) { glm_mat2_inv(mat, dest); } CGLM_EXPORT void glmc_mat2_swap_col(mat2 mat, int col1, int col2) { glm_mat2_swap_col(mat, col1, col2); } CGLM_EXPORT void glmc_mat2_swap_row(mat2 mat, int row1, int row2) { glm_mat2_swap_row(mat, row1, row2); } CGLM_EXPORT float glmc_mat2_rmc(vec2 r, mat2 m, vec2 c) { return glm_mat2_rmc(r, m, c); } CGLM_EXPORT void glmc_mat2_make(const float * __restrict src, mat2 dest) { glm_mat2_make(src, dest); } cglm-0.9.6/src/mat2x3.c000066400000000000000000000015671475344456400145520ustar00rootroot00000000000000/* * 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_mat2x3_copy(mat2x3 mat, mat2x3 dest) { glm_mat2x3_copy(mat, dest); } CGLM_EXPORT void glmc_mat2x3_zero(mat2x3 mat) { glm_mat2x3_zero(mat); } CGLM_EXPORT void glmc_mat2x3_make(const float * __restrict src, mat2x3 dest) { glm_mat2x3_make(src, dest); } CGLM_EXPORT void glmc_mat2x3_mul(mat2x3 m1, mat3x2 m2, mat3 dest) { glm_mat2x3_mul(m1, m2, dest); } CGLM_EXPORT void glmc_mat2x3_mulv(mat2x3 m, vec2 v, vec3 dest) { glm_mat2x3_mulv(m, v, dest); } CGLM_EXPORT void glmc_mat2x3_transpose(mat2x3 m, mat3x2 dest) { glm_mat2x3_transpose(m, dest); } CGLM_EXPORT void glmc_mat2x3_scale(mat2x3 m, float s) { glm_mat2x3_scale(m, s); } cglm-0.9.6/src/mat2x4.c000066400000000000000000000015671475344456400145530ustar00rootroot00000000000000/* * 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_mat2x4_copy(mat2x4 mat, mat2x4 dest) { glm_mat2x4_copy(mat, dest); } CGLM_EXPORT void glmc_mat2x4_zero(mat2x4 mat) { glm_mat2x4_zero(mat); } CGLM_EXPORT void glmc_mat2x4_make(const float * __restrict src, mat2x4 dest) { glm_mat2x4_make(src, dest); } CGLM_EXPORT void glmc_mat2x4_mul(mat2x4 m1, mat4x2 m2, mat4 dest) { glm_mat2x4_mul(m1, m2, dest); } CGLM_EXPORT void glmc_mat2x4_mulv(mat2x4 m, vec2 v, vec4 dest) { glm_mat2x4_mulv(m, v, dest); } CGLM_EXPORT void glmc_mat2x4_transpose(mat2x4 m, mat4x2 dest) { glm_mat2x4_transpose(m, dest); } CGLM_EXPORT void glmc_mat2x4_scale(mat2x4 m, float s) { glm_mat2x4_scale(m, s); } cglm-0.9.6/src/mat3.c000066400000000000000000000033251475344456400142720ustar00rootroot00000000000000/* * 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_mat3_copy(mat3 mat, mat3 dest) { glm_mat3_copy(mat, dest); } CGLM_EXPORT void glmc_mat3_identity(mat3 mat) { glm_mat3_identity(mat); } CGLM_EXPORT void glmc_mat3_zero(mat3 mat) { glm_mat3_zero(mat); } CGLM_EXPORT void glmc_mat3_identity_array(mat3 * __restrict mat, size_t count) { glm_mat3_identity_array(mat, count); } CGLM_EXPORT void glmc_mat3_mul(mat3 m1, mat3 m2, mat3 dest) { glm_mat3_mul(m1, m2, dest); } CGLM_EXPORT void glmc_mat3_transpose_to(mat3 m, mat3 dest) { glm_mat3_transpose_to(m, dest); } CGLM_EXPORT void glmc_mat3_transpose(mat3 m) { glm_mat3_transpose(m); } CGLM_EXPORT void glmc_mat3_mulv(mat3 m, vec3 v, vec3 dest) { glm_mat3_mulv(m, v, dest); } CGLM_EXPORT float glmc_mat3_trace(mat3 m) { return glm_mat3_trace(m); } CGLM_EXPORT void glmc_mat3_quat(mat3 m, versor dest) { glm_mat3_quat(m, dest); } CGLM_EXPORT void glmc_mat3_scale(mat3 m, float s) { glm_mat3_scale(m, s); } CGLM_EXPORT float glmc_mat3_det(mat3 mat) { return glm_mat3_det(mat); } CGLM_EXPORT void glmc_mat3_inv(mat3 mat, mat3 dest) { glm_mat3_inv(mat, dest); } CGLM_EXPORT void glmc_mat3_swap_col(mat3 mat, int col1, int col2) { glm_mat3_swap_col(mat, col1, col2); } CGLM_EXPORT void glmc_mat3_swap_row(mat3 mat, int row1, int row2) { glm_mat3_swap_row(mat, row1, row2); } CGLM_EXPORT float glmc_mat3_rmc(vec3 r, mat3 m, vec3 c) { return glm_mat3_rmc(r, m, c); } CGLM_EXPORT void glmc_mat3_make(const float * __restrict src, mat3 dest) { glm_mat3_make(src, dest); } cglm-0.9.6/src/mat3x2.c000066400000000000000000000015671475344456400145520ustar00rootroot00000000000000/* * 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_mat3x2_copy(mat3x2 mat, mat3x2 dest) { glm_mat3x2_copy(mat, dest); } CGLM_EXPORT void glmc_mat3x2_zero(mat3x2 mat) { glm_mat3x2_zero(mat); } CGLM_EXPORT void glmc_mat3x2_make(const float * __restrict src, mat3x2 dest) { glm_mat3x2_make(src, dest); } CGLM_EXPORT void glmc_mat3x2_mul(mat3x2 m1, mat2x3 m2, mat2 dest) { glm_mat3x2_mul(m1, m2, dest); } CGLM_EXPORT void glmc_mat3x2_mulv(mat3x2 m, vec3 v, vec2 dest) { glm_mat3x2_mulv(m, v, dest); } CGLM_EXPORT void glmc_mat3x2_transpose(mat3x2 m, mat2x3 dest) { glm_mat3x2_transpose(m, dest); } CGLM_EXPORT void glmc_mat3x2_scale(mat3x2 m, float s) { glm_mat3x2_scale(m, s); } cglm-0.9.6/src/mat3x4.c000066400000000000000000000015671475344456400145540ustar00rootroot00000000000000/* * 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_mat3x4_copy(mat3x4 mat, mat3x4 dest) { glm_mat3x4_copy(mat, dest); } CGLM_EXPORT void glmc_mat3x4_zero(mat3x4 mat) { glm_mat3x4_zero(mat); } CGLM_EXPORT void glmc_mat3x4_make(const float * __restrict src, mat3x4 dest) { glm_mat3x4_make(src, dest); } CGLM_EXPORT void glmc_mat3x4_mul(mat3x4 m1, mat4x3 m2, mat4 dest) { glm_mat3x4_mul(m1, m2, dest); } CGLM_EXPORT void glmc_mat3x4_mulv(mat3x4 m, vec3 v, vec4 dest) { glm_mat3x4_mulv(m, v, dest); } CGLM_EXPORT void glmc_mat3x4_transpose(mat3x4 m, mat4x3 dest) { glm_mat3x4_transpose(m, dest); } CGLM_EXPORT void glmc_mat3x4_scale(mat3x4 m, float s) { glm_mat3x4_scale(m, s); } cglm-0.9.6/src/mat4.c000066400000000000000000000052111475344456400142670ustar00rootroot00000000000000/* * 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_mat4_ucopy(mat4 mat, mat4 dest) { glm_mat4_copy(mat, dest); } CGLM_EXPORT void glmc_mat4_copy(mat4 mat, mat4 dest) { glm_mat4_copy(mat, dest); } CGLM_EXPORT void glmc_mat4_identity(mat4 mat) { glm_mat4_identity(mat); } CGLM_EXPORT void glmc_mat4_identity_array(mat4 * __restrict mat, size_t count) { glm_mat4_identity_array(mat, count); } CGLM_EXPORT void glmc_mat4_zero(mat4 mat) { glm_mat4_zero(mat); } CGLM_EXPORT void glmc_mat4_pick3(mat4 mat, mat3 dest) { glm_mat4_pick3(mat, dest); } CGLM_EXPORT void glmc_mat4_pick3t(mat4 mat, mat3 dest) { glm_mat4_pick3t(mat, dest); } CGLM_EXPORT void glmc_mat4_ins3(mat3 mat, mat4 dest) { glm_mat4_ins3(mat, dest); } CGLM_EXPORT void glmc_mat4_mul(mat4 m1, mat4 m2, mat4 dest) { glm_mat4_mul(m1, m2, dest); } CGLM_EXPORT void glmc_mat4_mulN(mat4 * __restrict matrices[], uint32_t len, mat4 dest) { glm_mat4_mulN(matrices, len, dest); } CGLM_EXPORT void glmc_mat4_mulv(mat4 m, vec4 v, vec4 dest) { glm_mat4_mulv(m, v, dest); } CGLM_EXPORT void glmc_mat4_mulv3(mat4 m, vec3 v, float last, vec3 dest) { glm_mat4_mulv3(m, v, last, dest); } CGLM_EXPORT float glmc_mat4_trace(mat4 m) { return glm_mat4_trace(m); } CGLM_EXPORT float glmc_mat4_trace3(mat4 m) { return glm_mat4_trace3(m); } CGLM_EXPORT void glmc_mat4_quat(mat4 m, versor dest) { glm_mat4_quat(m, dest); } CGLM_EXPORT void glmc_mat4_transpose_to(mat4 m, mat4 dest) { glm_mat4_transpose_to(m, dest); } CGLM_EXPORT void glmc_mat4_transpose(mat4 m) { glm_mat4_transpose(m); } CGLM_EXPORT void glmc_mat4_scale_p(mat4 m, float s) { glm_mat4_scale_p(m, s); } CGLM_EXPORT void glmc_mat4_scale(mat4 m, float s) { glm_mat4_scale(m, s); } CGLM_EXPORT float glmc_mat4_det(mat4 mat) { return glm_mat4_det(mat); } CGLM_EXPORT void glmc_mat4_inv(mat4 mat, mat4 dest) { glm_mat4_inv(mat, dest); } CGLM_EXPORT void glmc_mat4_inv_precise(mat4 mat, mat4 dest) { glm_mat4_inv_precise(mat, dest); } CGLM_EXPORT void glmc_mat4_inv_fast(mat4 mat, mat4 dest) { glm_mat4_inv_fast(mat, dest); } CGLM_EXPORT void glmc_mat4_swap_col(mat4 mat, int col1, int col2) { glm_mat4_swap_col(mat, col1, col2); } CGLM_EXPORT void glmc_mat4_swap_row(mat4 mat, int row1, int row2) { glm_mat4_swap_row(mat, row1, row2); } CGLM_EXPORT float glmc_mat4_rmc(vec4 r, mat4 m, vec4 c) { return glm_mat4_rmc(r, m, c); } CGLM_EXPORT void glmc_mat4_make(const float * __restrict src, mat4 dest) { glm_mat4_make(src, dest); } cglm-0.9.6/src/mat4x2.c000066400000000000000000000015671475344456400145530ustar00rootroot00000000000000/* * 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_mat4x2_copy(mat4x2 mat, mat4x2 dest) { glm_mat4x2_copy(mat, dest); } CGLM_EXPORT void glmc_mat4x2_zero(mat4x2 mat) { glm_mat4x2_zero(mat); } CGLM_EXPORT void glmc_mat4x2_make(const float * __restrict src, mat4x2 dest) { glm_mat4x2_make(src, dest); } CGLM_EXPORT void glmc_mat4x2_mul(mat4x2 m1, mat2x4 m2, mat2 dest) { glm_mat4x2_mul(m1, m2, dest); } CGLM_EXPORT void glmc_mat4x2_mulv(mat4x2 m, vec4 v, vec2 dest) { glm_mat4x2_mulv(m, v, dest); } CGLM_EXPORT void glmc_mat4x2_transpose(mat4x2 m, mat2x4 dest) { glm_mat4x2_transpose(m, dest); } CGLM_EXPORT void glmc_mat4x2_scale(mat4x2 m, float s) { glm_mat4x2_scale(m, s); } cglm-0.9.6/src/mat4x3.c000066400000000000000000000015671475344456400145540ustar00rootroot00000000000000/* * 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_mat4x3_copy(mat4x3 mat, mat4x3 dest) { glm_mat4x3_copy(mat, dest); } CGLM_EXPORT void glmc_mat4x3_zero(mat4x3 mat) { glm_mat4x3_zero(mat); } CGLM_EXPORT void glmc_mat4x3_make(const float * __restrict src, mat4x3 dest) { glm_mat4x3_make(src, dest); } CGLM_EXPORT void glmc_mat4x3_mul(mat4x3 m1, mat3x4 m2, mat3 dest) { glm_mat4x3_mul(m1, m2, dest); } CGLM_EXPORT void glmc_mat4x3_mulv(mat4x3 m, vec4 v, vec3 dest) { glm_mat4x3_mulv(m, v, dest); } CGLM_EXPORT void glmc_mat4x3_transpose(mat4x3 m, mat3x4 dest) { glm_mat4x3_transpose(m, dest); } CGLM_EXPORT void glmc_mat4x3_scale(mat4x3 m, float s) { glm_mat4x3_scale(m, s); } cglm-0.9.6/src/noise.c000066400000000000000000000007011475344456400145360ustar00rootroot00000000000000/* * 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 float glmc_perlin_vec4(vec4 p) { return glm_perlin_vec4(p); } CGLM_EXPORT float glmc_perlin_vec3(vec3 p) { return glm_perlin_vec3(p); } CGLM_EXPORT float glmc_perlin_vec2(vec2 p) { return glm_perlin_vec2(p); }cglm-0.9.6/src/plane.c000066400000000000000000000004601475344456400145220ustar00rootroot00000000000000/* * 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_plane_normalize(vec4 plane) { glm_plane_normalize(plane); } cglm-0.9.6/src/project.c000066400000000000000000000014011475344456400150650ustar00rootroot00000000000000/* * 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_unprojecti(vec3 pos, mat4 invMat, vec4 vp, vec3 dest) { glm_unprojecti(pos, invMat, vp, dest); } CGLM_EXPORT void glmc_unproject(vec3 pos, mat4 m, vec4 vp, vec3 dest) { glm_unproject(pos, m, vp, dest); } CGLM_EXPORT void glmc_project(vec3 pos, mat4 m, vec4 vp, vec3 dest) { glm_project(pos, m, vp, dest); } CGLM_EXPORT float glmc_project_z(vec3 pos, mat4 m) { return glm_project_z(pos, m); } CGLM_EXPORT void glmc_pickmatrix(vec2 center, vec2 size, vec4 vp, mat4 dest) { glm_pickmatrix(center, size, vp, dest); } cglm-0.9.6/src/quat.c000066400000000000000000000077051475344456400144060ustar00rootroot00000000000000/* * 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_quat_identity(versor q) { glm_quat_identity(q); } CGLM_EXPORT void glmc_quat_identity_array(versor * __restrict q, size_t count) { glm_quat_identity_array(q, count); } CGLM_EXPORT void glmc_quat_init(versor q, float x, float y, float z, float w) { glm_quat_init(q, x, y, z, w); } CGLM_EXPORT void glmc_quat(versor q, float angle, float x, float y, float z) { glm_quat(q, angle, x, y, z); } CGLM_EXPORT void glmc_quatv(versor q, float angle, vec3 axis) { glm_quatv(q, angle, axis); } CGLM_EXPORT void glmc_quat_copy(versor q, versor dest) { glm_quat_copy(q, dest); } CGLM_EXPORT void glmc_quat_from_vecs(vec3 a, vec3 b, versor dest) { glm_quat_from_vecs(a, b, dest); } CGLM_EXPORT float glmc_quat_norm(versor q) { return glm_quat_norm(q); } CGLM_EXPORT void glmc_quat_normalize_to(versor q, versor dest) { glm_quat_normalize_to(q, dest); } CGLM_EXPORT void glmc_quat_normalize(versor q) { glm_quat_normalize(q); } CGLM_EXPORT float glmc_quat_dot(versor p, versor q) { return glm_quat_dot(p, q); } CGLM_EXPORT void glmc_quat_conjugate(versor q, versor dest) { glm_quat_conjugate(q, dest); } CGLM_EXPORT void glmc_quat_inv(versor q, versor dest) { glm_quat_inv(q, dest); } CGLM_EXPORT void glmc_quat_add(versor p, versor q, versor dest) { glm_quat_add(p, q, dest); } CGLM_EXPORT void glmc_quat_sub(versor p, versor q, versor dest) { glm_quat_sub(p, q, dest); } CGLM_EXPORT float glmc_quat_real(versor q) { return glm_quat_real(q); } CGLM_EXPORT void glmc_quat_imag(versor q, vec3 dest) { glm_quat_imag(q, dest); } CGLM_EXPORT void glmc_quat_imagn(versor q, vec3 dest) { glm_quat_imagn(q, dest); } CGLM_EXPORT float glmc_quat_imaglen(versor q) { return glm_quat_imaglen(q); } CGLM_EXPORT float glmc_quat_angle(versor q) { return glm_quat_angle(q); } CGLM_EXPORT void glmc_quat_axis(versor q, vec3 dest) { glm_quat_axis(q, dest); } CGLM_EXPORT void glmc_quat_mul(versor p, versor q, versor dest) { glm_quat_mul(p, q, dest); } CGLM_EXPORT void glmc_quat_mat4(versor q, mat4 dest) { glm_quat_mat4(q, dest); } CGLM_EXPORT void glmc_quat_mat4t(versor q, mat4 dest) { glm_quat_mat4t(q, dest); } CGLM_EXPORT void glmc_quat_mat3(versor q, mat3 dest) { glm_quat_mat3(q, dest); } CGLM_EXPORT void glmc_quat_mat3t(versor q, mat3 dest) { glm_quat_mat3t(q, dest); } CGLM_EXPORT void glmc_quat_lerp(versor from, versor to, float t, versor dest) { glm_quat_lerp(from, to, t, dest); } CGLM_EXPORT void glmc_quat_lerpc(versor from, versor to, float t, versor dest) { glm_quat_lerpc(from, to, t, dest); } CGLM_EXPORT void glmc_quat_nlerp(versor from, versor to, float t, versor dest) { glm_quat_nlerp(from, to, t, dest); } CGLM_EXPORT void glmc_quat_slerp(versor from, versor to, float t, versor dest) { glm_quat_slerp(from, to, t, dest); } CGLM_EXPORT void glmc_quat_slerp_longest(versor from, versor to, float t, versor dest) { glm_quat_slerp_longest(from, to, t, dest); } CGLM_EXPORT void glmc_quat_look(vec3 eye, versor ori, mat4 dest) { glm_quat_look(eye, ori, dest); } CGLM_EXPORT void glmc_quat_for(vec3 dir, vec3 up, versor dest) { glm_quat_for(dir, up, dest); } CGLM_EXPORT void glmc_quat_forp(vec3 from, vec3 to, vec3 up, versor dest) { glm_quat_forp(from, to, up, dest); } CGLM_EXPORT void glmc_quat_rotatev(versor q, vec3 v, vec3 dest) { glm_quat_rotatev(q, v, dest); } CGLM_EXPORT void glmc_quat_rotate(mat4 m, versor q, mat4 dest) { glm_quat_rotate(m, q, dest); } CGLM_EXPORT void glmc_quat_rotate_at(mat4 model, versor q, vec3 pivot) { glm_quat_rotate_at(model, q, pivot); } CGLM_EXPORT void glmc_quat_rotate_atm(mat4 m, versor q, vec3 pivot) { glm_quat_rotate_atm(m, q, pivot); } CGLM_EXPORT void glmc_quat_make(const float * __restrict src, versor dest) { glm_quat_make(src, dest); } cglm-0.9.6/src/ray.c000066400000000000000000000012421475344456400142150ustar00rootroot00000000000000#include "../include/cglm/cglm.h" #include "../include/cglm/call.h" CGLM_EXPORT bool glmc_ray_triangle(vec3 origin, vec3 direction, vec3 v0, vec3 v1, vec3 v2, float *d) { return glm_ray_triangle(origin, direction, v0, v1, v2, d); } CGLM_EXPORT bool glmc_ray_sphere(vec3 origin, vec3 dir, vec4 s, float * __restrict t1, float * __restrict t2) { return glm_ray_sphere(origin, dir, s, t1, t2); } CGLM_EXPORT void glmc_ray_at(vec3 orig, vec3 dir, float t, vec3 point) { glm_ray_at(orig, dir, t, point); } cglm-0.9.6/src/sphere.c000066400000000000000000000012741475344456400147150ustar00rootroot00000000000000/* * 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 float glmc_sphere_radii(vec4 s) { return glm_sphere_radii(s); } CGLM_EXPORT void glmc_sphere_transform(vec4 s, mat4 m, vec4 dest) { glm_sphere_transform(s, m, dest); } CGLM_EXPORT void glmc_sphere_merge(vec4 s1, vec4 s2, vec4 dest) { glm_sphere_merge(s1, s2, dest); } CGLM_EXPORT bool glmc_sphere_sphere(vec4 s1, vec4 s2) { return glm_sphere_sphere(s1, s2); } CGLM_EXPORT bool glmc_sphere_point(vec4 s, vec3 point) { return glm_sphere_point(s, point); } cglm-0.9.6/src/swift/000077500000000000000000000000001475344456400144135ustar00rootroot00000000000000cglm-0.9.6/src/swift/empty.c000066400000000000000000000002421475344456400157130ustar00rootroot00000000000000// This empty file is needed to trick swiftpm to build the header-only version of cglm as swiftpm itself does not support C targets that have no source code filescglm-0.9.6/src/vec2.c000066400000000000000000000127671475344456400142770ustar00rootroot00000000000000/* * 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_vec2(float * __restrict v, vec2 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 void glmc_vec2_copy(vec2 a, vec2 dest) { glm_vec2_copy(a, dest); } CGLM_EXPORT void glmc_vec2_zero(vec2 v) { glm_vec2_zero(v); } CGLM_EXPORT void glmc_vec2_one(vec2 v) { glm_vec2_one(v); } CGLM_EXPORT float glmc_vec2_dot(vec2 a, vec2 b) { return glm_vec2_dot(a, b); } CGLM_EXPORT float glmc_vec2_cross(vec2 a, vec2 b) { return glm_vec2_cross(a, b); } CGLM_EXPORT float glmc_vec2_norm2(vec2 v) { return glm_vec2_norm2(v); } CGLM_EXPORT float glmc_vec2_norm(vec2 v) { return glm_vec2_norm(v); } CGLM_EXPORT void glmc_vec2_add(vec2 a, vec2 b, vec2 dest) { glm_vec2_add(a, b, dest); } CGLM_EXPORT void glmc_vec2_adds(vec2 v, float s, vec2 dest) { glm_vec2_adds(v, s, dest); } CGLM_EXPORT void glmc_vec2_sub(vec2 a, vec2 b, vec2 dest) { glm_vec2_sub(a, b, dest); } CGLM_EXPORT void glmc_vec2_subs(vec2 v, float s, vec2 dest) { glm_vec2_subs(v, s, dest); } CGLM_EXPORT void glmc_vec2_mul(vec2 a, vec2 b, vec2 dest) { glm_vec2_mul(a, b, dest); } CGLM_EXPORT void glmc_vec2_scale(vec2 v, float s, vec2 dest) { glm_vec2_scale(v, s, dest); } CGLM_EXPORT void glmc_vec2_scale_as(vec2 v, float s, vec2 dest) { glm_vec2_scale_as(v, s, dest); } CGLM_EXPORT void glmc_vec2_div(vec2 a, vec2 b, vec2 dest) { glm_vec2_div(a, b, dest); } CGLM_EXPORT void glmc_vec2_divs(vec2 v, float s, vec2 dest) { glm_vec2_divs(v, s, dest); } CGLM_EXPORT void glmc_vec2_addadd(vec2 a, vec2 b, vec2 dest) { glm_vec2_addadd(a, b, dest); } CGLM_EXPORT void glmc_vec2_subadd(vec2 a, vec2 b, vec2 dest) { glm_vec2_subadd(a, b, dest); } CGLM_EXPORT void glmc_vec2_muladd(vec2 a, vec2 b, vec2 dest) { glm_vec2_muladd(a, b, dest); } CGLM_EXPORT void glmc_vec2_muladds(vec2 a, float s, vec2 dest) { glm_vec2_muladds(a, s, dest); } CGLM_EXPORT void glmc_vec2_maxadd(vec2 a, vec2 b, vec2 dest) { glm_vec2_maxadd(a, b, dest); } CGLM_EXPORT void glmc_vec2_minadd(vec2 a, vec2 b, vec2 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 void glmc_vec2_negate_to(vec2 v, vec2 dest) { glm_vec2_negate_to(v, dest); } CGLM_EXPORT void glmc_vec2_negate(vec2 v) { glm_vec2_negate(v); } CGLM_EXPORT void glmc_vec2_normalize(vec2 v) { glm_vec2_normalize(v); } CGLM_EXPORT void glmc_vec2_normalize_to(vec2 v, vec2 dest) { glm_vec2_normalize_to(v, dest); } CGLM_EXPORT void glmc_vec2_rotate(vec2 v, float angle, vec2 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 float glmc_vec2_distance2(vec2 a, vec2 b) { return glm_vec2_distance2(a, b); } CGLM_EXPORT float glmc_vec2_distance(vec2 a, vec2 b) { return glm_vec2_distance(a, b); } CGLM_EXPORT void glmc_vec2_maxv(vec2 a, vec2 b, vec2 dest) { glm_vec2_maxv(a, b, dest); } CGLM_EXPORT void glmc_vec2_minv(vec2 a, vec2 b, vec2 dest) { glm_vec2_minv(a, b, dest); } CGLM_EXPORT void glmc_vec2_clamp(vec2 v, float minval, float maxval) { glm_vec2_clamp(v, minval, maxval); } CGLM_EXPORT void glmc_vec2_abs(vec2 v, vec2 dest) { glm_vec2_abs(v, dest); } CGLM_EXPORT void glmc_vec2_fract(vec2 v, vec2 dest) { glm_vec2_fract(v, dest); } CGLM_EXPORT void glmc_vec2_floor(vec2 v, vec2 dest) { glm_vec2_floor(v, dest); } CGLM_EXPORT void glmc_vec2_mods(vec2 v, float s, vec2 dest) { glm_vec2_mods(v, s, dest); } CGLM_EXPORT void glmc_vec2_step(vec2 edge, vec2 v, vec2 dest) { glm_vec2_step(edge, v, dest); } CGLM_EXPORT void glmc_vec2_steps(float edge, vec2 v, vec2 dest) { glm_vec2_steps(edge, v, dest); } CGLM_EXPORT void glmc_vec2_stepr(vec2 edge, float v, vec2 dest) { glm_vec2_stepr(edge, v, dest); } CGLM_EXPORT void glmc_vec2_swizzle(vec2 v, int mask, vec2 dest) { glm_vec2_swizzle(v, mask, dest); } CGLM_EXPORT void glmc_vec2_lerp(vec2 from, vec2 to, float t, vec2 dest) { glm_vec2_lerp(from, to, t, dest); } CGLM_EXPORT void glmc_vec2_complex_mul(vec2 a, vec2 b, vec2 dest) { glm_vec2_complex_mul(a, b, dest); } CGLM_EXPORT void glmc_vec2_complex_div(vec2 a, vec2 b, vec2 dest) { glm_vec2_complex_div(a, b, dest); } CGLM_EXPORT void glmc_vec2_complex_conjugate(vec2 a, vec2 dest) { glm_vec2_complex_conjugate(a, dest); } CGLM_EXPORT void glmc_vec2_make(const float * __restrict src, vec2 dest) { glm_vec2_make(src, dest); } CGLM_EXPORT void glmc_vec2_reflect(vec2 v, vec2 n, vec2 dest) { glm_vec2_reflect(v, n, dest); } CGLM_EXPORT bool glmc_vec2_refract(vec2 v, vec2 n, float eta, vec2 dest) { return glm_vec2_refract(v, n, eta, dest); } cglm-0.9.6/src/vec3.c000066400000000000000000000172431475344456400142720ustar00rootroot00000000000000/* * 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_vec3(vec4 v4, vec3 dest) { glm_vec3(v4, dest); } CGLM_EXPORT void glmc_vec3_copy(vec3 a, vec3 dest) { glm_vec3_copy(a, dest); } CGLM_EXPORT void glmc_vec3_zero(vec3 v) { glm_vec3_zero(v); } CGLM_EXPORT void glmc_vec3_one(vec3 v) { glm_vec3_one(v); } CGLM_EXPORT float glmc_vec3_dot(vec3 a, vec3 b) { return glm_vec3_dot(a, b); } CGLM_EXPORT void glmc_vec3_cross(vec3 a, vec3 b, vec3 dest) { glm_vec3_cross(a, b, dest); } CGLM_EXPORT void glmc_vec3_crossn(vec3 a, vec3 b, vec3 dest) { glm_vec3_crossn(a, b, dest); } CGLM_EXPORT float glmc_vec3_norm(vec3 v) { return glm_vec3_norm(v); } CGLM_EXPORT void glmc_vec3_normalize_to(vec3 v, vec3 dest) { glm_vec3_normalize_to(v, dest); } CGLM_EXPORT void glmc_vec3_normalize(vec3 v) { glm_vec3_normalize(v); } CGLM_EXPORT float glmc_vec3_norm2(vec3 v) { return glm_vec3_norm2(v); } CGLM_EXPORT float glmc_vec3_norm_one(vec3 v) { return glm_vec3_norm_one(v); } CGLM_EXPORT float glmc_vec3_norm_inf(vec3 v) { return glm_vec3_norm_inf(v); } CGLM_EXPORT void glmc_vec3_add(vec3 a, vec3 b, vec3 dest) { glm_vec3_add(a, b, dest); } CGLM_EXPORT void glmc_vec3_adds(vec3 v, float s, vec3 dest) { glm_vec3_adds(v, s, dest); } CGLM_EXPORT void glmc_vec3_sub(vec3 a, vec3 b, vec3 dest) { glm_vec3_sub(a, b, dest); } CGLM_EXPORT void glmc_vec3_subs(vec3 v, float s, vec3 dest) { glm_vec3_subs(v, s, dest); } CGLM_EXPORT void glmc_vec3_mul(vec3 a, vec3 b, vec3 d) { glm_vec3_mul(a, b, d); } CGLM_EXPORT void glmc_vec3_scale(vec3 v, float s, vec3 dest) { glm_vec3_scale(v, s, dest); } CGLM_EXPORT void glmc_vec3_scale_as(vec3 v, float s, vec3 dest) { glm_vec3_scale_as(v, s, dest); } CGLM_EXPORT void glmc_vec3_div(vec3 a, vec3 b, vec3 dest) { glm_vec3_div(a, b, dest); } CGLM_EXPORT void glmc_vec3_divs(vec3 a, float s, vec3 dest) { glm_vec3_divs(a, s, dest); } CGLM_EXPORT void glmc_vec3_addadd(vec3 a, vec3 b, vec3 dest) { glm_vec3_addadd(a, b, dest); } CGLM_EXPORT void glmc_vec3_subadd(vec3 a, vec3 b, vec3 dest) { glm_vec3_subadd(a, b, dest); } CGLM_EXPORT void glmc_vec3_muladd(vec3 a, vec3 b, vec3 dest) { glm_vec3_muladd(a, b, dest); } CGLM_EXPORT void glmc_vec3_muladds(vec3 a, float s, vec3 dest) { glm_vec3_muladds(a, s, dest); } CGLM_EXPORT void glmc_vec3_maxadd(vec3 a, vec3 b, vec3 dest) { glm_vec3_maxadd(a, b, dest); } CGLM_EXPORT void glmc_vec3_minadd(vec3 a, vec3 b, vec3 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 void glmc_vec3_negate(vec3 v) { glm_vec3_negate(v); } CGLM_EXPORT void glmc_vec3_negate_to(vec3 v, vec3 dest) { glm_vec3_negate_to(v, dest); } CGLM_EXPORT float glmc_vec3_angle(vec3 a, vec3 b) { return glm_vec3_angle(a, b); } CGLM_EXPORT void glmc_vec3_rotate(vec3 v, float angle, vec3 axis) { glm_vec3_rotate(v, angle, axis); } CGLM_EXPORT void glmc_vec3_rotate_m4(mat4 m, vec3 v, vec3 dest) { glm_vec3_rotate_m4(m, v, dest); } CGLM_EXPORT void glmc_vec3_rotate_m3(mat3 m, vec3 v, vec3 dest) { glm_vec3_rotate_m3(m, v, dest); } CGLM_EXPORT void glmc_vec3_proj(vec3 a, vec3 b, vec3 dest) { glm_vec3_proj(a, b, dest); } CGLM_EXPORT void glmc_vec3_center(vec3 a, vec3 b, vec3 dest) { glm_vec3_center(a, b, dest); } CGLM_EXPORT float glmc_vec3_distance(vec3 a, vec3 b) { return glm_vec3_distance(a, b); } CGLM_EXPORT float glmc_vec3_distance2(vec3 a, vec3 b) { return glm_vec3_distance2(a, b); } CGLM_EXPORT void glmc_vec3_maxv(vec3 a, vec3 b, vec3 dest) { glm_vec3_maxv(a, b, dest); } CGLM_EXPORT void glmc_vec3_minv(vec3 a, vec3 b, vec3 dest) { glm_vec3_minv(a, b, dest); } CGLM_EXPORT void glmc_vec3_clamp(vec3 v, float minVal, float maxVal) { glm_vec3_clamp(v, minVal, maxVal); } CGLM_EXPORT void glmc_vec3_ortho(vec3 v, vec3 dest) { glm_vec3_ortho(v, dest); } CGLM_EXPORT void glmc_vec3_lerp(vec3 from, vec3 to, float t, vec3 dest) { glm_vec3_lerp(from, to, t, dest); } CGLM_EXPORT void glmc_vec3_lerpc(vec3 from, vec3 to, float t, vec3 dest) { glm_vec3_lerpc(from, to, t, dest); } CGLM_EXPORT void glmc_vec3_step(vec3 edge, vec3 x, vec3 dest) { glm_vec3_step(edge, x, dest); } CGLM_EXPORT void glmc_vec3_smoothstep_uni(float edge0, float edge1, vec3 x, vec3 dest) { glm_vec3_smoothstep_uni(edge0, edge1, x, dest); } CGLM_EXPORT void glmc_vec3_smoothstep(vec3 edge0, vec3 edge1, vec3 x, vec3 dest) { glm_vec3_smoothstep(edge0, edge1, x, dest); } CGLM_EXPORT void glmc_vec3_smoothinterp(vec3 from, vec3 to, float t, vec3 dest) { glm_vec3_smoothinterp(from, to, t, dest); } CGLM_EXPORT void glmc_vec3_smoothinterpc(vec3 from, vec3 to, float t, vec3 dest) { glm_vec3_smoothinterpc(from, to, t, dest); } CGLM_EXPORT void glmc_vec3_swizzle(vec3 v, int mask, vec3 dest) { glm_vec3_swizzle(v, mask, dest); } /* ext */ CGLM_EXPORT void glmc_vec3_mulv(vec3 a, vec3 b, vec3 d) { glm_vec3_mulv(a, b, d); } CGLM_EXPORT void glmc_vec3_broadcast(float val, vec3 d) { glm_vec3_broadcast(val, d); } CGLM_EXPORT void glmc_vec3_fill(vec3 v, float val) { glm_vec3_fill(v, val); } CGLM_EXPORT bool glmc_vec3_eq(vec3 v, float val) { return glm_vec3_eq(v, val); } CGLM_EXPORT bool glmc_vec3_eq_eps(vec3 v, float val) { return glm_vec3_eq_eps(v, val); } CGLM_EXPORT bool glmc_vec3_eq_all(vec3 v) { return glm_vec3_eq_all(v); } CGLM_EXPORT bool glmc_vec3_eqv(vec3 a, vec3 b) { return glm_vec3_eqv(a, b); } CGLM_EXPORT bool glmc_vec3_eqv_eps(vec3 a, vec3 b) { return glm_vec3_eqv_eps(a, b); } CGLM_EXPORT float glmc_vec3_max(vec3 v) { return glm_vec3_max(v); } CGLM_EXPORT float glmc_vec3_min(vec3 v) { return glm_vec3_min(v); } CGLM_EXPORT bool glmc_vec3_isnan(vec3 v) { return glm_vec3_isnan(v); } CGLM_EXPORT bool glmc_vec3_isinf(vec3 v) { return glm_vec3_isinf(v); } CGLM_EXPORT bool glmc_vec3_isvalid(vec3 v) { return glm_vec3_isvalid(v); } CGLM_EXPORT void glmc_vec3_sign(vec3 v, vec3 dest) { glm_vec3_sign(v, dest); } CGLM_EXPORT void glmc_vec3_abs(vec3 v, vec3 dest) { glm_vec3_abs(v, dest); } CGLM_EXPORT void glmc_vec3_fract(vec3 v, vec3 dest) { glm_vec3_fract(v, dest); } CGLM_EXPORT void glmc_vec3_floor(vec3 v, vec3 dest) { glm_vec3_floor(v, dest); } CGLM_EXPORT void glmc_vec3_mods(vec3 v, float s, vec3 dest) { glm_vec3_mods(v, s, dest); } CGLM_EXPORT void glmc_vec3_steps(float edge, vec3 v, vec3 dest) { glm_vec3_steps(edge, v, dest); } CGLM_EXPORT void glmc_vec3_stepr(vec3 edge, float v, vec3 dest) { glm_vec3_stepr(edge, v, dest); } CGLM_EXPORT float glmc_vec3_hadd(vec3 v) { return glm_vec3_hadd(v); } CGLM_EXPORT void glmc_vec3_sqrt(vec3 v, vec3 dest) { glm_vec3_sqrt(v, dest); } CGLM_EXPORT void glmc_vec3_make(const float * __restrict src, vec3 dest) { glm_vec3_make(src, dest); } CGLM_EXPORT void glmc_vec3_faceforward(vec3 n, vec3 v, vec3 nref, vec3 dest) { glm_vec3_faceforward(n, v, nref, dest); } CGLM_EXPORT void glmc_vec3_reflect(vec3 v, vec3 n, vec3 dest) { glm_vec3_reflect(v, n, dest); } CGLM_EXPORT bool glmc_vec3_refract(vec3 v, vec3 n, float eta, vec3 dest) { return glm_vec3_refract(v, n, eta, dest); } cglm-0.9.6/src/vec4.c000066400000000000000000000157261475344456400142770ustar00rootroot00000000000000/* * 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_vec4(vec3 v3, float last, vec4 dest) { glm_vec4(v3, last, dest); } CGLM_EXPORT void glmc_vec4_zero(vec4 v) { glm_vec4_zero(v); } CGLM_EXPORT void glmc_vec4_one(vec4 v) { glm_vec4_one(v); } CGLM_EXPORT void glmc_vec4_copy3(vec4 v, vec3 dest) { glm_vec4_copy3(v, dest); } CGLM_EXPORT void glmc_vec4_copy(vec4 v, vec4 dest) { glm_vec4_copy(v, dest); } CGLM_EXPORT void glmc_vec4_ucopy(vec4 v, vec4 dest) { glm_vec4_ucopy(v, dest); } CGLM_EXPORT float glmc_vec4_dot(vec4 a, vec4 b) { return glm_vec4_dot(a, b); } CGLM_EXPORT float glmc_vec4_norm(vec4 v) { return glm_vec4_norm(v); } CGLM_EXPORT void glmc_vec4_normalize_to(vec4 v, vec4 dest) { glm_vec4_normalize_to(v, dest); } CGLM_EXPORT void glmc_vec4_normalize(vec4 v) { glm_vec4_normalize(v); } CGLM_EXPORT float glmc_vec4_norm2(vec4 v) { return glm_vec4_norm2(v); } CGLM_EXPORT float glmc_vec4_norm_one(vec4 v) { return glm_vec4_norm_one(v); } CGLM_EXPORT float glmc_vec4_norm_inf(vec4 v) { return glm_vec4_norm_inf(v); } CGLM_EXPORT void glmc_vec4_add(vec4 a, vec4 b, vec4 dest) { glm_vec4_add(a, b, dest); } CGLM_EXPORT void glmc_vec4_adds(vec4 v, float s, vec4 dest) { glm_vec4_adds(v, s, dest); } CGLM_EXPORT void glmc_vec4_sub(vec4 a, vec4 b, vec4 dest) { glm_vec4_sub(a, b, dest); } CGLM_EXPORT void glmc_vec4_subs(vec4 v, float s, vec4 dest) { glm_vec4_subs(v, s, dest); } CGLM_EXPORT void glmc_vec4_mul(vec4 a, vec4 b, vec4 d) { glm_vec4_mul(a, b, d); } CGLM_EXPORT void glmc_vec4_scale(vec4 v, float s, vec4 dest) { glm_vec4_scale(v, s, dest); } CGLM_EXPORT void glmc_vec4_scale_as(vec4 v, float s, vec4 dest) { glm_vec4_scale_as(v, s, dest); } CGLM_EXPORT void glmc_vec4_div(vec4 a, vec4 b, vec4 dest) { glm_vec4_div(a, b, dest); } CGLM_EXPORT void glmc_vec4_divs(vec4 v, float s, vec4 dest) { glm_vec4_divs(v, s, dest); } CGLM_EXPORT void glmc_vec4_addadd(vec4 a, vec4 b, vec4 dest) { glm_vec4_addadd(a, b, dest); } CGLM_EXPORT void glmc_vec4_subadd(vec4 a, vec4 b, vec4 dest) { glm_vec4_subadd(a, b, dest); } CGLM_EXPORT void glmc_vec4_muladd(vec4 a, vec4 b, vec4 dest) { glm_vec4_muladd(a, b, dest); } CGLM_EXPORT void glmc_vec4_muladds(vec4 a, float s, vec4 dest) { glm_vec4_muladds(a, s, dest); } CGLM_EXPORT void glmc_vec4_maxadd(vec4 a, vec4 b, vec4 dest) { glm_vec4_maxadd(a, b, dest); } CGLM_EXPORT void glmc_vec4_minadd(vec4 a, vec4 b, vec4 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 void glmc_vec4_negate(vec4 v) { glm_vec4_negate(v); } CGLM_EXPORT void glmc_vec4_negate_to(vec4 v, vec4 dest) { glm_vec4_negate_to(v, dest); } CGLM_EXPORT float glmc_vec4_distance(vec4 a, vec4 b) { return glm_vec4_distance(a, b); } CGLM_EXPORT float glmc_vec4_distance2(vec4 a, vec4 b) { return glm_vec4_distance2(a, b); } CGLM_EXPORT void glmc_vec4_maxv(vec4 a, vec4 b, vec4 dest) { glm_vec4_maxv(a, b, dest); } CGLM_EXPORT void glmc_vec4_minv(vec4 a, vec4 b, vec4 dest) { glm_vec4_minv(a, b, dest); } CGLM_EXPORT void glmc_vec4_clamp(vec4 v, float minVal, float maxVal) { glm_vec4_clamp(v, minVal, maxVal); } CGLM_EXPORT void glmc_vec4_lerp(vec4 from, vec4 to, float t, vec4 dest) { glm_vec4_lerp(from, to, t, dest); } CGLM_EXPORT void glmc_vec4_lerpc(vec4 from, vec4 to, float t, vec4 dest) { glm_vec4_lerpc(from, to, t, dest); } CGLM_EXPORT void glmc_vec4_step(vec4 edge, vec4 x, vec4 dest) { glm_vec4_step(edge, x, dest); } CGLM_EXPORT void glmc_vec4_smoothstep_uni(float edge0, float edge1, vec4 x, vec4 dest) { glm_vec4_smoothstep_uni(edge0, edge1, x, dest); } CGLM_EXPORT void glmc_vec4_smoothstep(vec4 edge0, vec4 edge1, vec4 x, vec4 dest) { glm_vec4_smoothstep(edge0, edge1, x, dest); } CGLM_EXPORT void glmc_vec4_smoothinterp(vec4 from, vec4 to, float t, vec4 dest) { glm_vec4_smoothinterp(from, to, t, dest); } CGLM_EXPORT void glmc_vec4_smoothinterpc(vec4 from, vec4 to, float t, vec4 dest) { glm_vec4_smoothinterpc(from, to, t, dest); } CGLM_EXPORT void glmc_vec4_cubic(float s, vec4 dest) { glm_vec4_cubic(s, dest); } CGLM_EXPORT void glmc_vec4_swizzle(vec4 v, int mask, vec4 dest) { glm_vec4_swizzle(v, mask, dest); } /* ext */ CGLM_EXPORT void glmc_vec4_mulv(vec4 a, vec4 b, vec4 d) { glm_vec4_mulv(a, b, d); } CGLM_EXPORT void glmc_vec4_broadcast(float val, vec4 d) { glm_vec4_broadcast(val, d); } CGLM_EXPORT void glmc_vec4_fill(vec4 v, float val) { glm_vec4_fill(v, val); } CGLM_EXPORT bool glmc_vec4_eq(vec4 v, float val) { return glm_vec4_eq(v, val); } CGLM_EXPORT bool glmc_vec4_eq_eps(vec4 v, float val) { return glm_vec4_eq_eps(v, val); } CGLM_EXPORT bool glmc_vec4_eq_all(vec4 v) { return glm_vec4_eq_all(v); } CGLM_EXPORT bool glmc_vec4_eqv(vec4 a, vec4 b) { return glm_vec4_eqv(a, b); } CGLM_EXPORT bool glmc_vec4_eqv_eps(vec4 a, vec4 b) { return glm_vec4_eqv_eps(a, b); } CGLM_EXPORT float glmc_vec4_max(vec4 v) { return glm_vec4_max(v); } CGLM_EXPORT float glmc_vec4_min(vec4 v) { return glm_vec4_min(v); } CGLM_EXPORT bool glmc_vec4_isnan(vec4 v) { return glm_vec4_isnan(v); } CGLM_EXPORT bool glmc_vec4_isinf(vec4 v) { return glm_vec4_isinf(v); } CGLM_EXPORT bool glmc_vec4_isvalid(vec4 v) { return glm_vec4_isvalid(v); } CGLM_EXPORT void glmc_vec4_sign(vec4 v, vec4 dest) { glm_vec4_sign(v, dest); } CGLM_EXPORT void glmc_vec4_abs(vec4 v, vec4 dest) { glm_vec4_abs(v, dest); } CGLM_EXPORT void glmc_vec4_fract(vec4 v, vec4 dest) { glm_vec4_fract(v, dest); } CGLM_EXPORT void glmc_vec4_floor(vec4 v, vec4 dest) { glm_vec4_floor(v, dest); } CGLM_EXPORT void glmc_vec4_mods(vec4 v, float s, vec4 dest) { glm_vec4_mods(v, s, dest); } CGLM_EXPORT void glmc_vec4_steps(float edge, vec4 v, vec4 dest) { glm_vec4_steps(edge, v, dest); } CGLM_EXPORT void glmc_vec4_stepr(vec4 edge, float v, vec4 dest) { glm_vec4_stepr(edge, v, dest); } CGLM_EXPORT float glmc_vec4_hadd(vec4 v) { return glm_vec4_hadd(v); } CGLM_EXPORT void glmc_vec4_sqrt(vec4 v, vec4 dest) { glm_vec4_sqrt(v, dest); } CGLM_EXPORT void glmc_vec4_make(const float * __restrict src, vec4 dest) { glm_vec4_make(src, dest); } CGLM_EXPORT void glmc_vec4_reflect(vec4 v, vec4 n, vec4 dest) { glm_vec4_reflect(v, n, dest); } CGLM_EXPORT bool glmc_vec4_refract(vec4 v, vec4 n, float eta, vec4 dest) { return glm_vec4_refract(v, n, eta, dest); } cglm-0.9.6/test/000077500000000000000000000000001475344456400134475ustar00rootroot00000000000000cglm-0.9.6/test/CMakeLists.txt000066400000000000000000000022411475344456400162060ustar00rootroot00000000000000cmake_minimum_required(VERSION 3.8.2) # List all files containing tests. (Change as needed) set(TESTFILES runner.c src/test_euler.c src/test_bezier.c src/test_struct.c src/test_clamp.c src/test_common.c src/tests.c ) set(TEST_MAIN tests) set(TEST_RUNNER_PARAMS "") add_executable(${TEST_MAIN} ${TESTFILES}) target_compile_definitions(${TEST_MAIN} PRIVATE CGLM_DEFINE_PRINTS=1) if(CMAKE_SYSTEM_NAME STREQUAL WASI) target_compile_definitions(${TEST_MAIN} PRIVATE _WASI_EMULATED_PROCESS_CLOCKS=1) target_link_options(${TEST_MAIN} PRIVATE "-lwasi-emulated-process-clocks") endif() if(NOT MSVC) target_link_libraries(${TEST_MAIN} PRIVATE m) endif() target_link_libraries(${TEST_MAIN} PRIVATE cglm) target_include_directories(${TEST_MAIN} PRIVATE ${CMAKE_CURRENT_LIST_DIR}/include ${CMAKE_CURRENT_LIST_DIR}/src ) set_target_properties(${TEST_MAIN} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}) if(LDFLAGS) target_compile_options(${TEST_MAIN} PRIVATE ${LDFLAGS}) endif() add_test( NAME cglm.${TEST_MAIN} COMMAND ${TEST_MAIN} ${TEST_RUNNER_PARAMS}) add_custom_target(check make COMMAND ${CMAKE_CTEST_COMMAND} -V DEPENDS cglm) cglm-0.9.6/test/include/000077500000000000000000000000001475344456400150725ustar00rootroot00000000000000cglm-0.9.6/test/include/common.h000066400000000000000000000125771475344456400165470ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ #ifndef tests_common_h #define tests_common_h #ifndef _USE_MATH_DEFINES # define _USE_MATH_DEFINES /* for windows */ #endif #ifndef _CRT_SECURE_NO_WARNINGS # define _CRT_SECURE_NO_WARNINGS /* for windows */ #endif #ifndef _GNU_SOURCE # define _GNU_SOURCE /* for drand48() */ #endif #ifndef CGLM_CLIPSPACE_INCLUDE_ALL # define CGLM_CLIPSPACE_INCLUDE_ALL #endif #include #include #include #include #include #include typedef struct test_status_t { const char *msg; int status; } test_status_t; typedef test_status_t (*fntest)(void); typedef struct test_entry_t { char *name; fntest entry; int ret; int show_output; } test_entry_t; #ifndef GLM_TESTS_NO_COLORFUL_OUTPUT #define RESET "\033[0m" #define BLACK "\033[30m" /* Black */ #define RED "\033[31m" /* Red */ #define GREEN "\033[32m" /* Green */ #define YELLOW "\033[33m" /* Yellow */ #define BLUE "\033[34m" /* Blue */ #define MAGENTA "\033[35m" /* Magenta */ #define CYAN "\033[36m" /* Cyan */ #define WHITE "\033[37m" /* White */ #define BOLDBLACK "\033[1m\033[30m" /* Bold Black */ #define BOLDRED "\033[1m\033[31m" /* Bold Red */ #define BOLDGREEN "\033[1m\033[32m" /* Bold Green */ #define BOLDYELLOW "\033[1m\033[33m" /* Bold Yellow */ #define BOLDBLUE "\033[1m\033[34m" /* Bold Blue */ #define BOLDMAGENTA "\033[1m\033[35m" /* Bold Magenta */ #define BOLDCYAN "\033[1m\033[36m" /* Bold Cyan */ #define BOLDWHITE "\033[1m\033[37m" /* Bold White */ #else #define RESET #define BLACK #define RED #define GREEN #define YELLOW #define BLUE #define MAGENTA #define CYAN #define WHITE #define BOLDBLACK #define BOLDRED #define BOLDGREEN #define BOLDYELLOW #define BOLDBLUE #define BOLDMAGENTA #define BOLDCYAN #define BOLDWHITE #endif #define TEST_DECLARE(FUN) test_status_t test_ ## FUN(void); #define TEST_ENTRY(FUN) { #FUN, test_ ## FUN, 0, 0 }, #define TEST_LIST static test_entry_t tests[] = /* __VA_ARGS__ workaround for MSVC: https://stackoverflow.com/a/5134656 */ #define EXPAND(x) x #define TEST_OK 1 #define TEST_SUCCESS return (test_status_t){NULL, TEST_OK}; #define TEST_IMPL_ARG1(FUN) \ test_status_t test_ ## FUN (void); \ test_status_t test_ ## FUN() #define TEST_IMPL_ARG2(PREFIX, FUN) TEST_IMPL_ARG1(PREFIX ## FUN) #define TEST_IMPL_ARG3(arg1, arg2, arg3, ...) arg3 #define TEST_IMPL_CHOOSER(...) \ EXPAND(TEST_IMPL_ARG3(__VA_ARGS__, TEST_IMPL_ARG2, TEST_IMPL_ARG1,)) #define TEST_IMPL(...) EXPAND(TEST_IMPL_CHOOSER(__VA_ARGS__)(__VA_ARGS__)) #define ASSERT_EXT(expr, msg) \ if (!(expr)) { \ fprintf(stderr, \ RED " assert fail" RESET \ " in " BOLDCYAN "%s " RESET \ "on " BOLDMAGENTA "line %d" RESET \ " : " BOLDWHITE " ASSERT(%s)\n" RESET, \ __FILE__, \ __LINE__, \ #expr); \ return (test_status_t){msg, 0}; \ } #define ASSERT_ARG1(expr) ASSERT_EXT(expr, NULL) #define ASSERT_ARG2(expr, msg) ASSERT_EXT(expr, msg) #define ASSERT_ARG3(arg1, arg2, arg3, ...) arg3 #define ASSERT_CHOOSER(...) ASSERT_ARG3(__VA_ARGS__, ASSERT_ARG2, ASSERT_ARG1,) #define ASSERT(...) do { ASSERT_CHOOSER(__VA_ARGS__)(__VA_ARGS__) } while(0); #define ASSERTIFY(expr) do { \ test_status_t ts; \ ts = expr; \ if (ts.status != TEST_OK) { \ fprintf(stderr, \ RED " assert fail" RESET \ " in " BOLDCYAN "%s " RESET \ "on " BOLDMAGENTA "line %d" RESET \ " : " BOLDWHITE " ASSERTIFY(%s)\n" RESET, \ __FILE__, \ __LINE__, \ #expr); \ return (test_status_t){ts.msg, 0}; \ } \ } while(0); #if defined(_WIN32) || defined(__MINGW32__) || defined(__MINGW64__) # define drand48() ((float)(rand() / (RAND_MAX + 1.0))) # define OK_TEXT "ok:" # define FAIL_TEXT "fail:" # define FINAL_TEXT "^_^" #else # define OK_TEXT "✔︎" # define FAIL_TEXT "𐄂" # define FINAL_TEXT "🎉" #endif #endif /* common_h */ cglm-0.9.6/test/runner.c000066400000000000000000000042641475344456400151320ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ #include "include/common.h" #include "tests.h" #include #include #include int main(int argc, const char * argv[]) { test_entry_t *entry; test_status_t st; int32_t i, count, passed, failed, maxlen; double start, end, elapsed, total; (void)argc; (void)argv; passed = failed = maxlen = 0; total = 0.0; count = sizeof(tests) / sizeof(tests[0]); fprintf(stderr, CYAN "\nWelcome to cglm tests ( " RESET); glm_arch_print(stderr); fprintf(stderr, CYAN " )\n\n" RESET); srand((unsigned int)time(NULL)); for (i = 0; i < count; i++) { int32_t len; entry = tests + i; len = (int32_t)strlen(entry->name); maxlen = GLM_MAX(maxlen, len); } maxlen += 5; fprintf(stderr, BOLDWHITE " %-*s %-*s\n", maxlen, "Test Name", maxlen, "Elapsed Time"); for (i = 0; i < count; i++) { entry = tests + i; start = clock(); st = entry->entry(); end = clock(); elapsed = (end - start) / CLOCKS_PER_SEC; total += elapsed; if (!st.status) { fprintf(stderr, BOLDRED " " FAIL_TEXT BOLDWHITE " %s " RESET, entry->name); if (st.msg) { fprintf(stderr, YELLOW "- %s" RESET, st.msg); } fprintf(stderr, "\n"); failed++; } else { fprintf(stderr, GREEN " " OK_TEXT RESET " %-*s ", maxlen, entry->name); if (elapsed > 0.01) fprintf(stderr, YELLOW "%.2fs", elapsed); else fprintf(stderr, "0"); fprintf(stderr, "\n" RESET); passed++; } } if (failed == 0) { fprintf(stderr, BOLDGREEN "\n All tests passed " FINAL_TEXT "\n" RESET); } fprintf(stderr, CYAN "\ncglm test results (%0.2fs):\n" RESET "--------------------------\n" MAGENTA "%d" RESET " tests ran, " GREEN "%d" RESET " passed, " RED "%d" RESET " failed\n\n" RESET, total, count, passed, failed); return failed; } cglm-0.9.6/test/src/000077500000000000000000000000001475344456400142365ustar00rootroot00000000000000cglm-0.9.6/test/src/test_aabb2d.h000066400000000000000000000010211475344456400165530ustar00rootroot00000000000000/* * 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" #ifndef CGLM_TEST_AABB2D_ONCE #define CGLM_TEST_AABB2D_ONCE /* Macros */ /* Deprecated */ #endif /* CGLM_TEST_VEC4_ONCE */ /* --- */ TEST_IMPL(GLM_PREFIX, aabb2d_sizev) { vec2 a[2] = {{10.0f, 10.0f}, {20.0f, 20.0f}}; vec2 size = {0}; GLM(aabb2d_sizev)(a, size); ASSERTIFY(test_assert_vec2_eq(size, (vec2){10.0f, 10.0f})) TEST_SUCCESS } cglm-0.9.6/test/src/test_affine.h000066400000000000000000000342211475344456400167000ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ #include "test_common.h" TEST_IMPL(GLM_PREFIX, translate) { mat4 m1; vec4 v1 = {1.0f, 2.0f, 3.0f, 1.0f}, v2; glm_mat4_identity(m1); GLM(translate)(m1, (vec3){13.0f, 11.0f, 7.0f}); glm_mat4_mulv(m1, v1, v2); ASSERT(test_eq(v2[0], 14.0f)) ASSERT(test_eq(v2[1], 13.0f)) ASSERT(test_eq(v2[2], 10.0f)) ASSERT(test_eq(v2[3], 1.0f)) glm_mat4_identity(m1); GLM(translate)(m1, (vec3){1.0f, -1.0f, -5.0f}); glm_mat4_mulv(m1, v2, v2); ASSERT(test_eq(v2[0], 15.0f)) ASSERT(test_eq(v2[1], 12.0f)) ASSERT(test_eq(v2[2], 5.0f)) ASSERT(test_eq(v2[3], 1.0f)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, translate_to) { mat4 m1, m2; vec4 v1 = {1.0f, 2.0f, 3.0f, 1.0f}, v2; glm_mat4_identity(m1); GLM(translate_to)(m1, (vec3){13.0f, 11.0f, 7.0f}, m2); glm_mat4_mulv(m2, v1, v2); ASSERT(test_eq(v2[0], 14.0f)) ASSERT(test_eq(v2[1], 13.0f)) ASSERT(test_eq(v2[2], 10.0f)) ASSERT(test_eq(v2[3], 1.0f)) glm_mat4_identity(m1); GLM(translate_to)(m1, (vec3){1.0f, -1.0f, -5.0f}, m2); glm_mat4_mulv(m2, v2, v2); ASSERT(test_eq(v2[0], 15.0f)) ASSERT(test_eq(v2[1], 12.0f)) ASSERT(test_eq(v2[2], 5.0f)) ASSERT(test_eq(v2[3], 1.0f)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, translate_x) { mat4 m1; vec4 v1 = {1.0f, 2.0f, 3.0f, 1.0f}, v2; glm_mat4_identity(m1); GLM(translate_x)(m1, 13.0f); glm_mat4_mulv(m1, v1, v2); ASSERT(test_eq(v2[0], 14.0f)) ASSERT(test_eq(v2[1], 2.0f)) ASSERT(test_eq(v2[2], 3.0f)) ASSERT(test_eq(v2[3], 1.0f)) glm_mat4_identity(m1); GLM(translate_x)(m1, -1.0f); glm_mat4_mulv(m1, v2, v2); ASSERT(test_eq(v2[0], 13.0f)) ASSERT(test_eq(v2[1], 2.0f)) ASSERT(test_eq(v2[2], 3.0f)) ASSERT(test_eq(v2[3], 1.0f)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, translate_y) { mat4 m1; vec4 v1 = {1.0f, 2.0f, 3.0f, 1.0f}, v2; glm_mat4_identity(m1); GLM(translate_y)(m1, 11.0f); glm_mat4_mulv(m1, v1, v2); ASSERT(test_eq(v2[0], 1.0f)) ASSERT(test_eq(v2[1], 13.0f)) ASSERT(test_eq(v2[2], 3.0f)) ASSERT(test_eq(v2[3], 1.0f)) glm_mat4_identity(m1); GLM(translate_y)(m1, -1.0f); glm_mat4_mulv(m1, v2, v2); ASSERT(test_eq(v2[0], 1.0f)) ASSERT(test_eq(v2[1], 12.0f)) ASSERT(test_eq(v2[2], 3.0f)) ASSERT(test_eq(v2[3], 1.0f)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, translate_z) { mat4 m1; vec4 v1 = {1.0f, 2.0f, 3.0f, 1.0f}, v2; glm_mat4_identity(m1); GLM(translate_z)(m1, 7.0f); glm_mat4_mulv(m1, v1, v2); ASSERT(test_eq(v2[0], 1.0f)) ASSERT(test_eq(v2[1], 2.0f)) ASSERT(test_eq(v2[2], 10.0f)) ASSERT(test_eq(v2[3], 1.0f)) glm_mat4_identity(m1); GLM(translate_z)(m1, -5.0f); glm_mat4_mulv(m1, v2, v2); ASSERT(test_eq(v2[0], 1.0f)) ASSERT(test_eq(v2[1], 2.0f)) ASSERT(test_eq(v2[2], 5.0f)) ASSERT(test_eq(v2[3], 1.0f)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, translate_make) { mat4 m1; vec4 v1 = {1.0f, 2.0f, 3.0f, 1.0f}, v2; glm_mat4_identity(m1); GLM(translate_make)(m1, (vec3){13.0f, 11.0f, 7.0f}); glm_mat4_mulv(m1, v1, v2); ASSERT(test_eq(v2[0], 14.0f)) ASSERT(test_eq(v2[1], 13.0f)) ASSERT(test_eq(v2[2], 10.0f)) ASSERT(test_eq(v2[3], 1.0f)) glm_mat4_identity(m1); GLM(translate_make)(m1, (vec3){1.0f, -1.0f, -5.0f}); glm_mat4_mulv(m1, v2, v2); ASSERT(test_eq(v2[0], 15.0f)) ASSERT(test_eq(v2[1], 12.0f)) ASSERT(test_eq(v2[2], 5.0f)) ASSERT(test_eq(v2[3], 1.0f)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, scale_to) { mat4 m1, m2; vec4 v1 = {1.0f, 2.0f, 3.0f, 1.0f}, v2; glm_mat4_identity(m1); GLM(scale_to)(m1, (vec3){13.0f, 11.0f, 7.0f}, m2); glm_mat4_mulv(m2, v1, v2); ASSERT(test_eq(v2[0], 13.0f)) ASSERT(test_eq(v2[1], 22.0f)) ASSERT(test_eq(v2[2], 21.0f)) ASSERT(test_eq(v2[3], 1.0f)) glm_mat4_identity(m1); GLM(scale_to)(m1, (vec3){1.0f, -1.0f, -5.0f}, m2); glm_mat4_mulv(m2, v2, v2); ASSERT(test_eq(v2[0], 13.0f)) ASSERT(test_eq(v2[1], -22.0f)) ASSERT(test_eq(v2[2], -105.0f)) ASSERT(test_eq(v2[3], 1.0f)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, scale_make) { mat4 m1; vec4 v1 = {1.0f, 2.0f, 3.0f, 1.0f}, v2; GLM(scale_make)(m1, (vec3){13.0f, 11.0f, 7.0f}); glm_mat4_mulv(m1, v1, v2); ASSERT(test_eq(v2[0], 13.0f)) ASSERT(test_eq(v2[1], 22.0f)) ASSERT(test_eq(v2[2], 21.0f)) ASSERT(test_eq(v2[3], 1.0f)) GLM(scale_make)(m1, (vec3){1.0f, -1.0f, -5.0f}); glm_mat4_mulv(m1, v2, v2); ASSERT(test_eq(v2[0], 13.0f)) ASSERT(test_eq(v2[1], -22.0f)) ASSERT(test_eq(v2[2], -105.0f)) ASSERT(test_eq(v2[3], 1.0f)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, scale) { mat4 m1; vec4 v1 = {1.0f, 2.0f, 3.0f, 1.0f}, v2; glm_mat4_identity(m1); GLM(scale)(m1, (vec3){13.0f, 11.0f, 7.0f}); glm_mat4_mulv(m1, v1, v2); ASSERT(test_eq(v2[0], 13.0f)) ASSERT(test_eq(v2[1], 22.0f)) ASSERT(test_eq(v2[2], 21.0f)) ASSERT(test_eq(v2[3], 1.0f)) glm_mat4_identity(m1); GLM(scale)(m1, (vec3){1.0f, -1.0f, -5.0f}); glm_mat4_mulv(m1, v2, v2); ASSERT(test_eq(v2[0], 13.0f)) ASSERT(test_eq(v2[1], -22.0f)) ASSERT(test_eq(v2[2], -105.0f)) ASSERT(test_eq(v2[3], 1.0f)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, scale_uni) { mat4 m1; vec4 v1 = {1.0f, 2.0f, 3.0f, 1.0f}, v2; glm_mat4_identity(m1); GLM(scale_uni)(m1, 13.0f); glm_mat4_mulv(m1, v1, v2); ASSERT(test_eq(v2[0], 13.0f)) ASSERT(test_eq(v2[1], 26.0f)) ASSERT(test_eq(v2[2], 39.0f)) ASSERT(test_eq(v2[3], 1.0f)) glm_mat4_identity(m1); GLM(scale_uni)(m1, -5.0f); glm_mat4_mulv(m1, v2, v2); ASSERT(test_eq(v2[0], -65.0f)) ASSERT(test_eq(v2[1], -130.0f)) ASSERT(test_eq(v2[2], -195.0f)) ASSERT(test_eq(v2[3], 1.0f)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, rotate_x) { mat4 m1 = GLM_MAT4_IDENTITY_INIT; vec4 v1 = {0.0f, 1.0f, 0.0f, 1.0f}, v2 = {0.0f, 1.0f, 0.0f, 1.0f}; GLM(rotate_x)(m1, GLM_PI_2f, m1); glm_mat4_mulv(m1, v1, v1); ASSERT(test_eq(v1[0], 0.0f)) ASSERT(test_eq(v1[1], 0.0f)) ASSERT(test_eq(v1[2], 1.0f)) glm_vec3_copy(v2, v1); GLM(rotate_x)(m1, GLM_PI_2f, m1); glm_mat4_mulv(m1, v1, v1); ASSERT(test_eq(v1[0], 0.0f)) ASSERT(test_eq(v1[1], -1.0f)) ASSERT(test_eq(v1[2], 0.0f)) glm_vec3_copy(v2, v1); GLM(rotate_x)(m1, GLM_PI_2f, m1); glm_mat4_mulv(m1, v1, v1); ASSERT(test_eq(v1[0], 0.0f)) ASSERT(test_eq(v1[1], 0.0f)) ASSERT(test_eq(v1[2], -1.0f)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, rotate_y) { mat4 m1 = GLM_MAT4_IDENTITY_INIT; vec4 v1 = {1.0f, 0.0f, 0.0f, 1.0f}, v2 = {1.0f, 0.0f, 0.0f, 1.0f}; GLM(rotate_y)(m1, GLM_PI_2f, m1); glm_mat4_mulv(m1, v1, v1); ASSERT(test_eq(v1[0], 0.0f)) ASSERT(test_eq(v1[1], 0.0f)) ASSERT(test_eq(v1[2], -1.0f)) glm_vec3_copy(v2, v1); GLM(rotate_y)(m1, GLM_PI_2f, m1); glm_mat4_mulv(m1, v1, v1); ASSERT(test_eq(v1[0], -1.0f)) ASSERT(test_eq(v1[1], 0.0f)) ASSERT(test_eq(v1[2], 0.0f)) glm_vec3_copy(v2, v1); GLM(rotate_y)(m1, GLM_PI_2f, m1); glm_mat4_mulv(m1, v1, v1); ASSERT(test_eq(v1[0], 0.0f)) ASSERT(test_eq(v1[1], 0.0f)) ASSERT(test_eq(v1[2], 1.0f)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, rotate_z) { mat4 m1 = GLM_MAT4_IDENTITY_INIT; vec4 v1 = {0.0f, 1.0f, 0.0f, 1.0f}, v2 = {0.0f, 1.0f, 0.0f, 1.0f}; GLM(rotate_z)(m1, GLM_PI_2f, m1); glm_mat4_mulv(m1, v1, v1); ASSERT(test_eq(v1[0], -1.0f)) ASSERT(test_eq(v1[1], 0.0f)) ASSERT(test_eq(v1[2], 0.0f)) glm_vec3_copy(v2, v1); GLM(rotate_z)(m1, GLM_PI_2f, m1); glm_mat4_mulv(m1, v1, v1); ASSERT(test_eq(v1[0], 0.0f)) ASSERT(test_eq(v1[1], -1.0f)) ASSERT(test_eq(v1[2], 0.0f)) glm_vec3_copy(v2, v1); GLM(rotate_z)(m1, GLM_PI_2f, m1); glm_mat4_mulv(m1, v1, v1); ASSERT(test_eq(v1[0], 1.0f)) ASSERT(test_eq(v1[1], 0.0f)) ASSERT(test_eq(v1[2], 0.0f)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, rotate_make) { mat4 m1 = GLM_MAT4_IDENTITY_INIT; vec4 v1 = {1.0f, 0.0f, 0.0f, 1.0f}; /* rotate X around Y = -Z */ GLM(rotate_make)(m1, GLM_PI_2f, GLM_YUP); glm_mat4_mulv(m1, v1, v1); ASSERT(test_eq(v1[0], 0.0f)) ASSERT(test_eq(v1[1], 0.0f)) ASSERT(test_eq(v1[2], -1.0f)) /* rotate -Z around X = Y */ GLM(rotate_make)(m1, GLM_PI_2f, GLM_XUP); glm_mat4_mulv(m1, v1, v1); ASSERT(test_eq(v1[0], 0.0f)) ASSERT(test_eq(v1[1], 1.0f)) ASSERT(test_eq(v1[2], 0.0f)) /* rotate Y around X = +Z */ GLM(rotate_make)(m1, GLM_PI_2f, GLM_XUP); glm_mat4_mulv(m1, v1, v1); ASSERT(test_eq(v1[0], 0.0f)) ASSERT(test_eq(v1[1], 0.0f)) ASSERT(test_eq(v1[2], 1.0f)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, rotate) { mat4 m1 = GLM_MAT4_IDENTITY_INIT, m2 = GLM_MAT4_IDENTITY_INIT; vec4 v1 = {1.0f, 0.0f, 0.0f, 1.0f}; /* 360 deg */ glm_rotate(m1, GLM_PI_2f, GLM_YUP); glm_rotate(m1, GLM_PI_2f, GLM_YUP); glm_rotate(m1, GLM_PI_2f, GLM_YUP); glm_rotate(m1, GLM_PI_2f, GLM_YUP); ASSERTIFY(test_assert_mat4_eq(m1, m2)) /* rotate X around Y = -Z */ GLM(rotate)(m1, GLM_PI_2f, GLM_YUP); glm_mat4_mulv(m1, v1, v1); ASSERT(test_eq(v1[0], 0.0f)) ASSERT(test_eq(v1[1], 0.0f)) ASSERT(test_eq(v1[2], -1.0f)) glm_mat4_identity(m1); /* rotate -Z around X = Y */ GLM(rotate)(m1, GLM_PI_2f, GLM_XUP); glm_mat4_mulv(m1, v1, v1); ASSERT(test_eq(v1[0], 0.0f)) ASSERT(test_eq(v1[1], 1.0f)) ASSERT(test_eq(v1[2], 0.0f)) glm_mat4_identity(m1); /* rotate Y around X = +Z */ GLM(rotate)(m1, GLM_PI_2f, GLM_XUP); glm_mat4_mulv(m1, v1, v1); ASSERT(test_eq(v1[0], 0.0f)) ASSERT(test_eq(v1[1], 0.0f)) ASSERT(test_eq(v1[2], 1.0f)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, rotate_at) { mat4 m1 = GLM_MAT4_IDENTITY_INIT; vec4 v1 = {1.0f, 0.0f, 0.0f, 1.0f}; GLM(rotate_at)(m1, (vec3){0.5f, 0.0f, 0.0f}, GLM_PI_2f, GLM_YUP); glm_mat4_mulv(m1, v1, v1); ASSERT(test_eq(v1[0], 0.5f)) ASSERT(test_eq(v1[1], 0.0f)) ASSERT(test_eq(v1[2], -0.5f)) glm_mat4_identity(m1); GLM(rotate_at)(m1, GLM_VEC3_ZERO, GLM_PI_2f, GLM_ZUP); glm_mat4_mulv(m1, v1, v1); ASSERT(test_eq(v1[0], 0.0f)) ASSERT(test_eq(v1[1], 0.5f)) ASSERT(test_eq(v1[2], -0.5f)) glm_mat4_identity(m1); v1[0] = 1.0f; v1[1] = 1.0f; v1[2] = 1.0f; GLM(rotate_at)(m1, GLM_VEC3_ZERO, GLM_PI_2f, GLM_XUP); glm_mat4_mulv(m1, v1, v1); ASSERT(test_eq(v1[0], 1.0f)) ASSERT(test_eq(v1[1], -1.0f)) ASSERT(test_eq(v1[2], 1.0f)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, rotate_atm) { mat4 m1 = GLM_MAT4_IDENTITY_INIT; vec4 v1 = {1.0f, 0.0f, 0.0f, 1.0f}; GLM(rotate_atm)(m1, (vec3){0.5f, 0.0f, 0.0f}, GLM_PI_2f, GLM_YUP); glm_mat4_mulv(m1, v1, v1); ASSERT(test_eq(v1[0], 0.5f)) ASSERT(test_eq(v1[1], 0.0f)) ASSERT(test_eq(v1[2], -0.5f)) GLM(rotate_atm)(m1, GLM_VEC3_ZERO, GLM_PI_2f, GLM_ZUP); glm_mat4_mulv(m1, v1, v1); ASSERT(test_eq(v1[0], 0.0f)) ASSERT(test_eq(v1[1], 0.5f)) ASSERT(test_eq(v1[2], -0.5f)) v1[0] = 1.0f; v1[1] = 1.0f; v1[2] = 1.0f; GLM(rotate_atm)(m1, GLM_VEC3_ZERO, GLM_PI_2f, GLM_XUP); glm_mat4_mulv(m1, v1, v1); ASSERT(test_eq(v1[0], 1.0f)) ASSERT(test_eq(v1[1], -1.0f)) ASSERT(test_eq(v1[2], 1.0f)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, decompose_scalev) { mat4 m1; vec3 s1; GLM(scale_make)(m1, (vec3){7.0f, 8.0f, 9.0f}); GLM(decompose_scalev)(m1, s1); ASSERT(test_eq(s1[0], 7.0f)) ASSERT(test_eq(s1[1], 8.0f)) ASSERT(test_eq(s1[2], 9.0f)) GLM(scale)(m1, (vec3){7.0f, 8.0f, 9.0f}); GLM(decompose_scalev)(m1, s1); ASSERT(test_eq(s1[0], 49.0f)) ASSERT(test_eq(s1[1], 64.0f)) ASSERT(test_eq(s1[2], 81.0f)) glm_rotate(m1, GLM_PI_4f, (vec3){23.0f, 45.0f, 66.0f}); ASSERT(test_eq(s1[0], 49.0f)) ASSERT(test_eq(s1[1], 64.0f)) ASSERT(test_eq(s1[2], 81.0f)) glm_translate(m1, (vec3){4.0f, 5.0f, 6.0f}); ASSERT(test_eq(s1[0], 49.0f)) ASSERT(test_eq(s1[1], 64.0f)) ASSERT(test_eq(s1[2], 81.0f)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, uniscaled) { mat4 m1; GLM(scale_make)(m1, (vec3){7.0f, 8.0f, 9.0f}); ASSERT(!GLM(uniscaled)(m1)) GLM(scale_make)(m1, (vec3){7.0f, 7.0f, 7.0f}); ASSERT(GLM(uniscaled)(m1)) glm_rotate(m1, GLM_PI_4f, (vec3){23.0f, 45.0f, 66.0f}); ASSERT(GLM(uniscaled)(m1)) glm_translate(m1, (vec3){4.0f, 5.0f, 6.0f}); ASSERT(GLM(uniscaled)(m1)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, decompose_rs) { mat4 m1, m2, r; vec3 s1; GLM(scale_make)(m1, (vec3){7.0f, 8.0f, 9.0f}); GLM(decompose_rs)(m1, r, s1); ASSERT(test_eq(s1[0], 7.0f)) ASSERT(test_eq(s1[1], 8.0f)) ASSERT(test_eq(s1[2], 9.0f)) ASSERTIFY(test_assert_mat4_eq_identity(r)); GLM(scale)(m1, (vec3){7.0f, 8.0f, 9.0f}); GLM(decompose_rs)(m1, r, s1); ASSERT(test_eq(s1[0], 49.0f)) ASSERT(test_eq(s1[1], 64.0f)) ASSERT(test_eq(s1[2], 81.0f)) ASSERTIFY(test_assert_mat4_eq_identity(r)); glm_rotate(m1, GLM_PI_4f, (vec3){23.0f, 45.0f, 66.0f}); ASSERT(test_eq(s1[0], 49.0f)) ASSERT(test_eq(s1[1], 64.0f)) ASSERT(test_eq(s1[2], 81.0f)) GLM(decompose_rs)(m1, r, s1); glm_mat4_identity(m2); glm_mat4_mul(m2, r, m2); glm_scale(m2, s1); ASSERTIFY(test_assert_mat4_eq2(m1, m2, 0.00001f)); TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, decompose) { mat4 m1, m2, r; vec4 t; vec3 s; GLM(scale_make)(m1, (vec3){7.0f, 8.0f, 9.0f}); GLM(decompose)(m1, t, r, s); ASSERT(test_eq(s[0], 7.0f)) ASSERT(test_eq(s[1], 8.0f)) ASSERT(test_eq(s[2], 9.0f)) ASSERTIFY(test_assert_mat4_eq_identity(r)); GLM(scale)(m1, (vec3){7.0f, 8.0f, 9.0f}); GLM(decompose)(m1, t, r, s); ASSERT(test_eq(s[0], 49.0f)) ASSERT(test_eq(s[1], 64.0f)) ASSERT(test_eq(s[2], 81.0f)) ASSERTIFY(test_assert_mat4_eq_identity(r)); glm_rotate(m1, GLM_PI_4f, (vec3){23.0f, 45.0f, 66.0f}); ASSERT(test_eq(s[0], 49.0f)) ASSERT(test_eq(s[1], 64.0f)) ASSERT(test_eq(s[2], 81.0f)) GLM(decompose)(m1, t, r, s); glm_mat4_identity(m2); glm_mat4_mul(m2, r, m2); glm_scale(m2, s); ASSERTIFY(test_assert_mat4_eq2(m1, m2, 0.00001f)); glm_mat4_identity(m1); glm_translate(m1, (vec3){56.0f, 13.0f, 90.0f}); glm_rotate(m1, GLM_PI_4f, (vec3){23.0f, 45.0f, 66.0f}); glm_scale(m1, (vec3){12.0f, 34.0f, 23.0f}); GLM(decompose)(m1, t, r, s); ASSERT(test_eq(t[0], 56.0f)) ASSERT(test_eq(t[1], 13.0f)) ASSERT(test_eq(t[2], 90.0f)) ASSERT(test_eq(s[0], 12.0f)) ASSERT(test_eq(s[1], 34.0f)) ASSERT(test_eq(s[2], 23.0f)) glm_mat4_identity(m2); glm_translate(m2, t); glm_mat4_mul(m2, r, m2); glm_scale(m2, s); ASSERTIFY(test_assert_mat4_eq2(m1, m2, 0.00001f)); TEST_SUCCESS } cglm-0.9.6/test/src/test_affine2d.h000066400000000000000000000147641475344456400171400ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ #include "test_common.h" TEST_IMPL(GLM_PREFIX, translate2d) { mat3 m1; vec3 v1 = {2.0f, 3.0f, 1.0f}, v2; glm_mat3_identity(m1); GLM(translate2d)(m1, (vec2){13.0f, 11.0f}); glm_mat3_mulv(m1, v1, v2); ASSERT(test_eq(v2[0], 15.0f)) ASSERT(test_eq(v2[1], 14.0f)) ASSERT(test_eq(v2[2], 1.0f)) glm_mat3_identity(m1); GLM(translate2d)(m1, (vec2){1.0f, -1.0f}); glm_mat3_mulv(m1, v2, v2); ASSERT(test_eq(v2[0], 16.0f)) ASSERT(test_eq(v2[1], 13.0f)) ASSERT(test_eq(v2[2], 1.0f)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, translate2d_to) { mat3 m1, m2; vec3 v1 = {2.0f, 3.0f, 1.0f}, v2; glm_mat3_identity(m1); GLM(translate2d_to)(m1, (vec2){13.0f, 11.0f}, m2); glm_mat3_mulv(m2, v1, v2); ASSERT(test_eq(v2[0], 15.0f)) ASSERT(test_eq(v2[1], 14.0f)) ASSERT(test_eq(v2[2], 1.0f)) glm_mat3_identity(m1); GLM(translate2d_to)(m1, (vec2){1.0f, -1.0f}, m2); glm_mat3_mulv(m2, v2, v2); ASSERT(test_eq(v2[0], 16.0f)) ASSERT(test_eq(v2[1], 13.0f)) ASSERT(test_eq(v2[2], 1.0f)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, translate2d_x) { mat3 m1; vec3 v1 = {2.0f, 3.0f, 1.0f}, v2; glm_mat3_identity(m1); GLM(translate2d_x)(m1, 13.0f); glm_mat3_mulv(m1, v1, v2); ASSERT(test_eq(v2[0], 15.0f)) ASSERT(test_eq(v2[1], 3.0f)) ASSERT(test_eq(v2[2], 1.0f)) glm_mat3_identity(m1); GLM(translate2d_x)(m1, -1.0f); glm_mat3_mulv(m1, v2, v2); ASSERT(test_eq(v2[0], 14.0f)) ASSERT(test_eq(v2[1], 3.0f)) ASSERT(test_eq(v2[2], 1.0f)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, translate2d_y) { mat3 m1; vec3 v1 = {2.0f, 3.0f, 1.0f}, v2; glm_mat3_identity(m1); GLM(translate2d_y)(m1, 11.0f); glm_mat3_mulv(m1, v1, v2); ASSERT(test_eq(v2[0], 2.0f)) ASSERT(test_eq(v2[1], 14.0f)) ASSERT(test_eq(v2[2], 1.0f)) glm_mat3_identity(m1); GLM(translate2d_y)(m1, -1.0f); glm_mat3_mulv(m1, v2, v2); ASSERT(test_eq(v2[0], 2.0f)) ASSERT(test_eq(v2[1], 13.0f)) ASSERT(test_eq(v2[2], 1.0f)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, translate2d_make) { mat3 m1; vec3 v1 = {2.0f, 3.0f, 1.0f}, v2; glm_mat3_identity(m1); GLM(translate2d_make)(m1, (vec2){13.0f, 11.0f}); glm_mat3_mulv(m1, v1, v2); ASSERT(test_eq(v2[0], 15.0f)) ASSERT(test_eq(v2[1], 14.0f)) ASSERT(test_eq(v2[2], 1.0f)) glm_mat3_identity(m1); GLM(translate2d_make)(m1, (vec2){-1.0f, -5.0f}); glm_mat3_mulv(m1, v2, v2); ASSERT(test_eq(v2[0], 14.0f)) ASSERT(test_eq(v2[1], 9.0f)) ASSERT(test_eq(v2[2], 1.0f)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, scale2d_to) { mat3 m1, m2; vec3 v1 = {2.0f, 3.0f, 1.0f}, v2; glm_mat3_identity(m1); GLM(scale2d_to)(m1, (vec2){13.0f, 11.0f}, m2); glm_mat3_mulv(m2, v1, v2); ASSERT(test_eq(v2[0], 26.0f)) ASSERT(test_eq(v2[1], 33.0f)) ASSERT(test_eq(v2[2], 1.0f)) glm_mat3_identity(m1); GLM(scale2d_to)(m1, (vec2){-1.0f, -5.0f}, m2); glm_mat3_mulv(m2, v2, v2); ASSERT(test_eq(v2[0], -26.0f)) ASSERT(test_eq(v2[1], -165.0f)) ASSERT(test_eq(v2[2], 1.0f)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, scale2d_make) { mat3 m1; vec3 v1 = {2.0f, 3.0f, 1.0f}, v2; GLM(scale2d_make)(m1, (vec2){13.0f, 11.0f}); glm_mat3_mulv(m1, v1, v2); ASSERT(test_eq(v2[0], 26.0f)) ASSERT(test_eq(v2[1], 33.0f)) ASSERT(test_eq(v2[2], 1.0f)) GLM(scale2d_make)(m1, (vec3){-1.0f, -5.0f}); glm_mat3_mulv(m1, v2, v2); ASSERT(test_eq(v2[0], -26.0f)) ASSERT(test_eq(v2[1], -165.0f)) ASSERT(test_eq(v2[2], 1.0f)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, scale2d) { mat3 m1; vec3 v1 = {2.0f, 3.0f, 1.0f}, v2; glm_mat3_identity(m1); GLM(scale2d)(m1, (vec2){13.0f, 11.0f}); glm_mat3_mulv(m1, v1, v2); ASSERT(test_eq(v2[0], 26.0f)) ASSERT(test_eq(v2[1], 33.0f)) ASSERT(test_eq(v2[2], 1.0f)) glm_mat3_identity(m1); GLM(scale2d)(m1, (vec2){-1.0f, -5.0f}); glm_mat3_mulv(m1, v2, v2); ASSERT(test_eq(v2[0], -26.0f)) ASSERT(test_eq(v2[1], -165.0f)) ASSERT(test_eq(v2[2], 1.0f)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, scale2d_uni) { mat3 m1; vec3 v1 = {2.0f, 3.0f, 1.0f}, v2; glm_mat3_identity(m1); GLM(scale2d_uni)(m1, 13.0f); glm_mat3_mulv(m1, v1, v2); ASSERT(test_eq(v2[0], 26.0f)) ASSERT(test_eq(v2[1], 39.0f)) ASSERT(test_eq(v2[2], 1.0f)) glm_mat3_identity(m1); GLM(scale2d_uni)(m1, -5.0f); glm_mat3_mulv(m1, v2, v2); ASSERT(test_eq(v2[0], -130.0f)) ASSERT(test_eq(v2[1], -195.0f)) ASSERT(test_eq(v2[2], 1.0f)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, rotate2d_make) { mat3 m1 = GLM_MAT3_IDENTITY_INIT; vec3 v1 = {0.0f, 1.0f, 1.0f}, v2 = {0.0f, 1.0f, 1.0f}; GLM(rotate2d_make)(m1, GLM_PI_2f); glm_mat3_mulv(m1, v1, v1); ASSERT(test_eq(v1[0], -1.0f)) ASSERT(test_eq(v1[1], 0.0f)) ASSERT(test_eq(v1[2], 1.0f)) glm_vec3_copy(v2, v1); GLM(rotate2d_make)(m1, -GLM_PI_2f); glm_mat3_mulv(m1, v1, v1); ASSERT(test_eq(v1[0], 1.0f)) ASSERT(test_eq(v1[1], 0.0f)) ASSERT(test_eq(v1[2], 1.0f)) glm_vec3_copy(v2, v1); GLM(rotate2d_make)(m1, GLM_PIf); glm_mat3_mulv(m1, v1, v1); ASSERT(test_eq(v1[0], 0.0f)) ASSERT(test_eq(v1[1], -1.0f)) ASSERT(test_eq(v1[2], 1.0f)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, rotate2d) { mat3 m1 = GLM_MAT3_IDENTITY_INIT; vec3 v1 = {0.0f, 1.0f, 1.0f}, v2 = {0.0f, 1.0f, 1.0f}; GLM(rotate2d)(m1, GLM_PI_2f); glm_mat3_mulv(m1, v1, v1); ASSERT(test_eq(v1[0], -1.0f)) ASSERT(test_eq(v1[1], 0.0f)) ASSERT(test_eq(v1[2], 1.0f)) glm_vec3_copy(v2, v1); GLM(rotate2d)(m1, GLM_PI_2f); glm_mat3_mulv(m1, v1, v1); ASSERT(test_eq(v1[0], 0.0f)) ASSERT(test_eq(v1[1], -1.0f)) ASSERT(test_eq(v1[2], 1.0f)) glm_vec3_copy(v2, v1); GLM(rotate2d)(m1, GLM_PI_2f); glm_mat3_mulv(m1, v1, v1); ASSERT(test_eq(v1[0], 1.0f)) ASSERT(test_eq(v1[1], 0.0f)) ASSERT(test_eq(v1[2], 1.0f)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, rotate2d_to) { mat3 m1 = GLM_MAT3_IDENTITY_INIT, m2; vec3 v1 = {0.0f, 1.0f, 1.0f}, v2 = {0.0f, 1.0f, 1.0f}; GLM(rotate2d_to)(m1, GLM_PI_2f, m1); glm_mat3_mulv(m1, v1, v1); ASSERT(test_eq(v1[0], -1.0f)) ASSERT(test_eq(v1[1], 0.0f)) ASSERT(test_eq(v1[2], 1.0f)) glm_vec3_copy(v2, v1); GLM(rotate2d_to)(m1, GLM_PI_2f, m2); glm_mat3_mulv(m2, v1, v1); ASSERT(test_eq(v1[0], 0.0f)) ASSERT(test_eq(v1[1], -1.0f)) ASSERT(test_eq(v1[2], 1.0f)) glm_vec3_copy(v2, v1); GLM(rotate2d_to)(m2, GLM_PI_2f, m1); glm_mat3_mulv(m1, v1, v1); ASSERT(test_eq(v1[0], 1.0f)) ASSERT(test_eq(v1[1], 0.0f)) ASSERT(test_eq(v1[2], 1.0f)) TEST_SUCCESS } cglm-0.9.6/test/src/test_affine_mat.h000066400000000000000000000043371475344456400175460ustar00rootroot00000000000000/* * 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" #ifndef glm_affine_mat_test_guard #define glm_affine_mat_test_guard CGLM_INLINE void glm_inv_tr_raw(mat4 mat) { CGLM_ALIGN_MAT mat3 r; CGLM_ALIGN(8) vec3 t; /* rotate */ glm_mat4_pick3t(mat, r); glm_mat4_ins3(r, mat); /* translate */ glm_mat3_mulv(r, mat[3], t); glm_vec3_negate(t); glm_vec3_copy(t, mat[3]); } #endif TEST_IMPL(GLM_PREFIX, mul) { mat4 m1 = GLM_MAT4_IDENTITY_INIT; mat4 m2 = GLM_MAT4_IDENTITY_INIT; mat4 m3; mat4 m4 = GLM_MAT4_ZERO_INIT; int i, j, k; test_rand_mat4(m1); test_rand_mat4(m2); GLM(mul)(m1, m2, m3); for (i = 0; i < 4; i++) { for (j = 0; j < 4; j++) { for (k = 0; k < 4; k++) /* column-major */ m4[i][j] += m1[k][j] * m2[i][k]; } } ASSERTIFY(test_assert_mat4_eq(m3, m4)) /* test pre compiled */ GLM(mul)(m1, m2, m3); ASSERTIFY(test_assert_mat4_eq(m3, m4)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, mul_rot) { mat4 m1 = GLM_MAT4_IDENTITY_INIT; mat4 m2 = GLM_MAT4_IDENTITY_INIT; mat4 m3; mat4 m4 = GLM_MAT4_ZERO_INIT; int i, j, k; glm_rotate(m1, drand48(), (vec3){drand48(), drand48(), drand48()}); glm_rotate(m2, drand48(), (vec3){drand48(), drand48(), drand48()}); GLM(mul_rot)(m1, m2, m3); for (i = 0; i < 4; i++) { for (j = 0; j < 4; j++) { for (k = 0; k < 4; k++) /* column-major */ m4[i][j] += m1[k][j] * m2[i][k]; } } ASSERTIFY(test_assert_mat4_eq(m3, m4)) /* test pre compiled */ GLM(mul_rot)(m1, m2, m3); ASSERTIFY(test_assert_mat4_eq(m3, m4)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, inv_tr) { mat4 m1, m2; int i; for (i = 0; i < 10000; i++) { test_rand_mat4(m1); glm_mat4_copy(m1, m2); /* test inverse precise */ GLM(inv_tr)(m1); GLM(inv_tr)(m1); ASSERTIFY(test_assert_mat4_eq(m1, m2)) /* test inverse precise */ GLM(mat4_inv)(m1, m2); GLM(inv_tr)(m2); ASSERTIFY(test_assert_mat4_eq(m1, m2)) /* test with raw */ glm_mat4_copy(m1, m2); glm_inv_tr_raw(m2); GLM(inv_tr)(m1); ASSERTIFY(test_assert_mat4_eq(m1, m2)) } TEST_SUCCESS } cglm-0.9.6/test/src/test_bezier.c000066400000000000000000000030121475344456400167150ustar00rootroot00000000000000/* * 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" CGLM_INLINE float test_bezier_plain(float s, float p0, float c0, float c1, float p1) { float x, xx, xxx, ss, sss; x = 1.0f - s; xx = x * x; xxx = xx * x; ss = s * s; sss = ss * s; return p0 * xxx + 3.0f * (c0 * s * xx + c1 * ss * x) + p1 * sss; } CGLM_INLINE float test_hermite_plain(float s, float p0, float t0, float t1, float p1) { float ss, sss; ss = s * s; sss = ss * s; return p0 * (2.0f * sss - 3.0f * ss + 1.0f) + t0 * (sss - 2.0f * ss + s) + p1 * (-2.0f * sss + 3.0f * ss) + t1 * (sss - ss); } TEST_IMPL(bezier) { float s, p0, p1, c0, c1, smc, Bs, Bs_plain; s = test_rand(); p0 = test_rand(); p1 = test_rand(); c0 = test_rand(); c1 = test_rand(); /* test cubic bezier */ smc = glm_smc(s, GLM_BEZIER_MAT, (vec4){p0, c0, c1, p1}); Bs = glm_bezier(s, p0, c0, c1, p1); Bs_plain = test_bezier_plain(s, p0, c0, c1, p1); ASSERT(test_eq(Bs, Bs_plain)); ASSERTIFY(test_assert_eqf(smc, Bs_plain)) ASSERTIFY(test_assert_eqf(Bs, smc)) /* test cubic hermite */ smc = glm_smc(s, GLM_HERMITE_MAT, (vec4){p0, p1, c0, c1}); Bs = glm_hermite(s, p0, c0, c1, p1); Bs_plain = test_hermite_plain(s, p0, c0, c1, p1); ASSERT(test_eq(Bs, Bs_plain)); ASSERT(test_eq(smc, Bs_plain)); ASSERT(test_eq(Bs, smc)); TEST_SUCCESS } cglm-0.9.6/test/src/test_cam.h000066400000000000000000000051511475344456400162100ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ #include "test_common.h" TEST_IMPL(GLM_PREFIX, frustum) { mat4 proj; vec4 vp = {0.0f, 0.0f, 800.0f, 600.0f}; float left, right, top, bottom, znear, zfar; znear = 0.1f; zfar = 100.0f; left = -100.0f; right = 100.0f; bottom = -100.0f; top = 100.0f; GLM(frustum)(left, right, bottom, top, znear, zfar, proj); ASSERT(test_eq(proj[0][1], 0.0f)) ASSERT(test_eq(proj[0][2], 0.0f)) ASSERT(test_eq(proj[0][3], 0.0f)) ASSERT(test_eq(proj[1][0], 0.0f)) ASSERT(test_eq(proj[1][2], 0.0f)) ASSERT(test_eq(proj[1][3], 0.0f)) ASSERT(test_eq(proj[2][3], -1.0f)) ASSERT(test_eq(proj[3][0], 0.0f)) ASSERT(test_eq(proj[3][1], 0.0f)) ASSERT(test_eq(proj[3][3], 0.0f)) vec4 v1 = {1.0f, 20.0f, znear}; vec4 v2 = {1.0f, 20.0f, zfar}; vec4 v3, v4; /* perspective test */ GLM(mat4_mulv)(proj, v1, v3); GLM(project)(v3, proj, vp, v3); ASSERT(v3[0] > v1[0]) ASSERT(v3[1] > v1[1]) GLM(mat4_mulv)(proj, v2, v4); GLM(project)(v4, proj, vp, v4); ASSERT(v4[0] < v3[0]) ASSERT(v4[1] < v3[1]) /* not infinity */ ASSERT(!GLM(vec4_isinf)(proj[0])) ASSERT(!GLM(vec4_isinf)(proj[1])) ASSERT(!GLM(vec4_isinf)(proj[2])) ASSERT(!GLM(vec4_isinf)(proj[3])) /* not NaN */ ASSERT(!GLM(vec4_isnan)(proj[0])) ASSERT(!GLM(vec4_isnan)(proj[1])) ASSERT(!GLM(vec4_isnan)(proj[2])) ASSERT(!GLM(vec4_isnan)(proj[3])) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, camera_lookat) { mat4 view1, view2; vec3 center, eye = {0.024f, 14.6f, 67.04f}, dir = {0.0f, 0.0f, -1.0f}, up = {0.0f, 1.0f, 0.0f}; glm_vec3_add(eye, dir, center); glm_lookat(eye, center, up, view1); glm_look(eye, dir, up, view2); ASSERTIFY(test_assert_mat4_eq(view1, view2)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, camera_decomp) { mat4 proj, proj2; vec4 sizes; float aspect, fovy, nearZ, farZ; aspect = 0.782f; fovy = glm_rad(49.984f); nearZ = 0.1f; farZ = 100.0f; glm_perspective(fovy, aspect, nearZ, farZ, proj); ASSERT(fabsf(aspect - glm_persp_aspect(proj)) < GLM_FLT_EPSILON) ASSERT(fabsf(fovy - glm_persp_fovy(proj)) < GLM_FLT_EPSILON) ASSERT(fabsf(49.984f - glm_deg(glm_persp_fovy(proj))) < GLM_FLT_EPSILON) glm_persp_sizes(proj, fovy, sizes); glm_frustum(-sizes[0] * 0.5f, sizes[0] * 0.5f, -sizes[1] * 0.5f, sizes[1] * 0.5f, nearZ, farZ, proj2); ASSERTIFY(test_assert_mat4_eq(proj, proj2)) TEST_SUCCESS } cglm-0.9.6/test/src/test_cam_lh_no.h000066400000000000000000000022201475344456400173610ustar00rootroot00000000000000/* * 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/clipspace/persp_lh_no.h" #include "../../include/cglm/call/clipspace/persp_lh_no.h" TEST_IMPL(GLM_PREFIX, perspective_lh_no) { mat4 dst; const float fovy = glm_rad(45.0f); const float aspect = 640/480.0f; const float zNearVal = 0.1f; const float zFarVal = 100.0f; GLM(perspective_lh_no)(fovy, aspect, zNearVal, zFarVal, dst); /* Sanity mk. I: longhand version */ ASSERT(test_eq(dst[0][0], 1.0f / (tanf(fovy / 2) * aspect))) ASSERT(test_eq(dst[1][1], 1.0f / tanf(fovy / 2))) ASSERT(test_eq(dst[2][2], (zFarVal + zNearVal) / (zFarVal - zNearVal))) ASSERT(test_eq(dst[2][3], 1.0f)) ASSERT(test_eq(dst[3][2], -2 * zFarVal * zNearVal / (zFarVal - zNearVal))) /* Sanity mk. II */ /*reference test data for glm_perspective_lh_no*/ mat4 cmp = {0}; cmp[0][0] = 1.8106601f; cmp[1][1] = 2.4142134f; cmp[2][2] = 1.0020020f; cmp[2][3] = 1.0000000f; cmp[3][2] = -0.2002002f; return test_assert_mat4_eq(dst, cmp); } cglm-0.9.6/test/src/test_cam_lh_zo.h000066400000000000000000000022231475344456400174000ustar00rootroot00000000000000/* * 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/clipspace/persp_lh_zo.h" #include "../../include/cglm/call/clipspace/persp_lh_zo.h" TEST_IMPL(GLM_PREFIX, perspective_lh_zo) { mat4 dst; const float fovy = glm_rad(45.0f); const float aspect = 640/480.0f; const float zNearVal = 0.1f; const float zFarVal = 100.0f; GLM(perspective_lh_zo)(fovy, aspect, zNearVal, zFarVal, dst); /* Sanity mk. I: longhand version */ ASSERT(test_eq(dst[0][0], 1.0f / (tanf(fovy / 2) * aspect))) ASSERT(test_eq(dst[1][1], 1.0f / tanf(fovy / 2))) ASSERT(test_eq(dst[2][2], zFarVal / (zFarVal - zNearVal))) ASSERT(test_eq(dst[2][3], 1.0f)) ASSERT(test_eq(dst[3][2], -1 * zFarVal * zNearVal / (zFarVal - zNearVal))) /* Sanity mk. II */ /* "Reference values" generated by GLM's glm::perspectiveLH_ZO */ mat4 cmp = {0}; cmp[0][0] = 1.8106601f; cmp[1][1] = 2.4142134f; cmp[2][2] = 1.0010010f; cmp[2][3] = 1.0000000f; cmp[3][2] = -0.1001001f; return test_assert_mat4_eq(dst, cmp); } cglm-0.9.6/test/src/test_cam_rh_no.h000066400000000000000000000022271475344456400173760ustar00rootroot00000000000000/* * 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/clipspace/persp_rh_no.h" #include "../../include/cglm/call/clipspace/persp_rh_no.h" TEST_IMPL(GLM_PREFIX, perspective_rh_no) { mat4 dst; const float fovy = glm_rad(45.0f); const float aspect = 640/480.0f; const float zNearVal = 0.1f; const float zFarVal = 100.0f; GLM(perspective_rh_no)(fovy, aspect, zNearVal, zFarVal, dst); /* Sanity mk. I: longhand version */ ASSERT(test_eq(dst[0][0], 1.0f / (tanf(fovy / 2) * aspect))) ASSERT(test_eq(dst[1][1], 1.0f / tanf(fovy / 2))) ASSERT(test_eq(dst[2][2], -1.0f * (zFarVal + zNearVal) / (zFarVal - zNearVal))) ASSERT(test_eq(dst[2][3], -1.0f)) ASSERT(test_eq(dst[3][2], -2 * zFarVal * zNearVal / (zFarVal - zNearVal))) /* Sanity mk. II */ /*reference test data for glm_perspective_rh_no*/ mat4 cmp = {0}; cmp[0][0] = 1.8106601f; cmp[1][1] = 2.4142134f; cmp[2][2] = -1.0020020f; cmp[2][3] = -1.0000000f; cmp[3][2] = -0.2002002f; return test_assert_mat4_eq(dst, cmp); } cglm-0.9.6/test/src/test_cam_rh_zo.h000066400000000000000000000021741475344456400174130ustar00rootroot00000000000000/* * 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/clipspace/persp_rh_zo.h" #include "../../include/cglm/call/clipspace/persp_rh_zo.h" TEST_IMPL(GLM_PREFIX, perspective_rh_zo) { mat4 dst; const float fovy = glm_rad(45.0f); const float aspect = 640/480.0f; const float zNearVal = 0.1f; const float zFarVal = 100.0f; GLM(perspective_rh_zo)(fovy, aspect, zNearVal, zFarVal, dst); /* Sanity mk. I: longhand version */ ASSERT(test_eq(dst[0][0], 1 / (tanf(fovy / 2) * aspect))) ASSERT(test_eq(dst[1][1], 1 / tanf(fovy / 2))) ASSERT(test_eq(dst[2][2], zFarVal / (zNearVal - zFarVal))) ASSERT(test_eq(dst[2][3], -1.0f)) ASSERT(test_eq(dst[3][2], -1 * zFarVal * zNearVal / (zFarVal - zNearVal))) /* Sanity mk. II */ /*reference test data for glm_perspective_rh_zo*/ mat4 cmp = {0}; cmp[0][0] = 1.8106601f; cmp[1][1] = 2.4142134f; cmp[2][2] = -1.0010010f; cmp[2][3] = -1.0000000f; cmp[3][2] = -0.1001001f; return test_assert_mat4_eq(dst, cmp); } cglm-0.9.6/test/src/test_clamp.c000066400000000000000000000013301475344456400165320ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ #include "test_common.h" TEST_IMPL(clamp) { vec3 v3 = {15.07f, 0.4f, 17.3f}; vec4 v4 = {5.07f, 2.3f, 1.3f, 1.4f}; ASSERT(glm_eq(glm_clamp(1.6f, 0.0f, 1.0f), 1.0f)) ASSERT(glm_eq(glm_clamp(-1.6f, 0.0f, 1.0f), 0.0f)) ASSERT(glm_eq(glm_clamp(0.6f, 0.0f, 1.0f), 0.6f)) glm_vec3_clamp(v3, 0.0, 1.0); glm_vec4_clamp(v4, 1.5, 3.0); ASSERT(glm_eq(v3[0], 1.0f)) ASSERT(glm_eq(v3[1], 0.4f)) ASSERT(glm_eq(v3[2], 1.0f)) ASSERT(glm_eq(v4[0], 3.0f)) ASSERT(glm_eq(v4[1], 2.3f)) ASSERT(glm_eq(v4[2], 1.5f)) ASSERT(glm_eq(v4[3], 1.5f)) TEST_SUCCESS } cglm-0.9.6/test/src/test_common.c000066400000000000000000000241311475344456400167320ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * MIT License (MIT), http://opensource.org/licenses/MIT */ #include "test_common.h" #include void test_rand_mat4(mat4 dest) { glm_mat4_copy(GLM_MAT4_IDENTITY, dest); /* random position */ dest[3][0] = drand48(); dest[3][1] = drand48(); dest[3][2] = drand48(); /* random rotatation around random axis with random angle */ glm_rotate(dest, drand48(), (vec3){drand48(), drand48(), drand48()}); /* random scale */ /* glm_scale(dest, (vec3){drand48(), drand48(), drand48()}); */ } void test_rand_mat4x2(mat4x2 dest) { dest[0][0] = drand48(); dest[0][1] = drand48(); dest[1][0] = drand48(); dest[1][1] = drand48(); dest[2][0] = drand48(); dest[2][1] = drand48(); dest[3][0] = drand48(); dest[3][1] = drand48(); } void test_rand_mat4x3(mat4x3 dest) { dest[0][0] = drand48(); dest[0][1] = drand48(); dest[0][2] = drand48(); dest[1][0] = drand48(); dest[1][1] = drand48(); dest[1][2] = drand48(); dest[2][0] = drand48(); dest[2][1] = drand48(); dest[2][2] = drand48(); dest[3][0] = drand48(); dest[3][1] = drand48(); dest[3][2] = drand48(); } void test_rand_mat3(mat3 dest) { mat4 m4; /* random rotatation around random axis with random angle */ glm_rotate_make(m4, drand48(), (vec3){drand48(), drand48(), drand48()}); glm_mat4_pick3(m4, dest); } void test_rand_mat3x2(mat3x2 dest) { dest[0][0] = drand48(); dest[0][1] = drand48(); dest[1][0] = drand48(); dest[1][1] = drand48(); dest[2][0] = drand48(); dest[2][1] = drand48(); } void test_rand_mat3x4(mat3x4 dest) { dest[0][0] = drand48(); dest[0][1] = drand48(); dest[0][2] = drand48(); dest[0][3] = drand48(); dest[1][0] = drand48(); dest[1][1] = drand48(); dest[1][2] = drand48(); dest[1][3] = drand48(); dest[2][0] = drand48(); dest[2][1] = drand48(); dest[2][2] = drand48(); dest[2][3] = drand48(); } void test_rand_mat2(mat2 dest) { dest[0][0] = drand48(); dest[0][1] = drand48(); dest[1][0] = drand48(); dest[1][1] = drand48(); } void test_rand_mat2x3(mat2x3 dest) { dest[0][0] = drand48(); dest[0][1] = drand48(); dest[0][2] = drand48(); dest[1][0] = drand48(); dest[1][1] = drand48(); dest[1][2] = drand48(); } void test_rand_mat2x4(mat2x4 dest) { dest[0][0] = drand48(); dest[0][1] = drand48(); dest[0][2] = drand48(); dest[0][3] = drand48(); dest[1][0] = drand48(); dest[1][1] = drand48(); dest[1][2] = drand48(); dest[1][3] = drand48(); } void test_rand_vec3(vec3 dest) { dest[0] = drand48(); dest[1] = drand48(); dest[2] = drand48(); } vec3s test_rand_vec3s(void) { vec3s r; test_rand_vec3(r.raw); return r; } void test_rand_vec4(vec4 dest) { dest[0] = drand48(); dest[1] = drand48(); dest[2] = drand48(); dest[3] = drand48(); } vec4s test_rand_vec4s(void) { vec4s r; test_rand_vec4(r.raw); return r; } float test_rand(void) { return drand48(); } void test_rand_quat(versor q) { glm_quat(q, drand48(), drand48(), drand48(), drand48()); glm_quat_normalize(q); } test_status_t test_assert_mat4_eq(mat4 m1, mat4 m2) { int i, j; for (i = 0; i < 4; i++) { for (j = 0; j < 4; j++) { ASSERT(fabsf(m1[i][j] - m2[i][j]) <= 0.0000009) } } TEST_SUCCESS } test_status_t test_assert_mat4_eqt(mat4 m1, mat4 m2) { int i, j; for (i = 0; i < 4; i++) { for (j = 0; j < 4; j++) { ASSERT(fabsf(m1[j][i] - m2[i][j]) <= 0.0000009) } } TEST_SUCCESS } test_status_t test_assert_mat4_eq2(mat4 m1, mat4 m2, float eps) { int i, j; for (i = 0; i < 4; i++) { for (j = 0; j < 4; j++) { ASSERT(fabsf(m1[i][j] - m2[i][j]) <= eps); } } TEST_SUCCESS } test_status_t test_assert_mat2_eqt(mat2 m1, mat2 m2) { int i, j; for (i = 0; i < 2; i++) { for (j = 0; j < 2; j++) { ASSERT(fabsf(m1[j][i] - m2[i][j]) <= 0.0000009); } } TEST_SUCCESS } test_status_t test_assert_mat2_eq(mat2 m1, mat2 m2) { int i, j; for (i = 0; i < 2; i++) { for (j = 0; j < 2; j++) { ASSERT(fabsf(m1[i][j] - m2[i][j]) <= 0.0000009); } } TEST_SUCCESS } test_status_t test_assert_mat2_eq_identity(mat2 m2) { int i, j; for (i = 0; i < 2; i++) { for (j = 0; j < 2; j++) { if (i == j) { ASSERT(test_eq(m2[i][j], 1.0f)) } else { ASSERT(test_eq(m2[i][j], 0.0f)) } } } TEST_SUCCESS } test_status_t test_assert_mat2_eq_zero(mat2 m2) { int i, j; for (i = 0; i < 2; i++) { for (j = 0; j < 2; j++) { ASSERT(test_eq(m2[i][j], 0.0f)) } } TEST_SUCCESS } test_status_t test_assert_mat2x3_eq_zero(mat2x3 m2x3) { int i, j; for (i = 0; i < 2; i++) { for (j = 0; j < 3; j++) { ASSERT(test_eq(m2x3[i][j], 0.0f)) } } TEST_SUCCESS } test_status_t test_assert_mat2x3_eq(mat2x3 m1, mat2x3 m2) { int i, j; for (i = 0; i < 2; i++) { for (j = 0; j < 3; j++) { ASSERT(fabsf(m1[i][j] - m2[i][j]) <= 0.0000009) } } TEST_SUCCESS } test_status_t test_assert_mat2x4_eq_zero(mat2x4 m2x4) { int i, j; for (i = 0; i < 2; i++) { for (j = 0; j < 4; j++) { ASSERT(test_eq(m2x4[i][j], 0.0f)) } } TEST_SUCCESS } test_status_t test_assert_mat2x4_eq(mat2x4 m1, mat2x4 m2) { int i, j; for (i = 0; i < 2; i++) { for (j = 0; j < 4; j++) { ASSERT(fabsf(m1[i][j] - m2[i][j]) <= 0.0000009) } } TEST_SUCCESS } test_status_t test_assert_mat3_eq(mat3 m1, mat3 m2) { int i, j; for (i = 0; i < 3; i++) { for (j = 0; j < 3; j++) { ASSERT(fabsf(m1[i][j] - m2[i][j]) <= 0.0000009); } } TEST_SUCCESS } test_status_t test_assert_mat3_eqt(mat3 m1, mat3 m2) { int i, j; for (i = 0; i < 3; i++) { for (j = 0; j < 3; j++) { ASSERT(fabsf(m1[j][i] - m2[i][j]) <= 0.0000009); } } TEST_SUCCESS } test_status_t test_assert_mat3_eq_identity(mat3 m3) { int i, j; for (i = 0; i < 3; i++) { for (j = 0; j < 3; j++) { if (i == j) { ASSERT(test_eq(m3[i][j], 1.0f)) } else { ASSERT(test_eq(m3[i][j], 0.0f)) } } } TEST_SUCCESS } test_status_t test_assert_mat3_eq_zero(mat3 m3) { int i, j; for (i = 0; i < 3; i++) { for (j = 0; j < 3; j++) { ASSERT(test_eq(m3[i][j], 0.0f)) } } TEST_SUCCESS } test_status_t test_assert_mat3x2_eq_zero(mat3x2 m3x2) { int i, j; for (i = 0; i < 3; i++) { for (j = 0; j < 2; j++) { ASSERT(test_eq(m3x2[i][j], 0.0f)) } } TEST_SUCCESS } test_status_t test_assert_mat3x2_eq(mat3x2 m1, mat3x2 m2) { int i, j; for (i = 0; i < 3; i++) { for (j = 0; j < 2; j++) { ASSERT(fabsf(m1[i][j] - m2[i][j]) <= 0.0000009) } } TEST_SUCCESS } test_status_t test_assert_mat3x4_eq_zero(mat3x4 m3x4) { int i, j; for (i = 0; i < 3; i++) { for (j = 0; j < 4; j++) { ASSERT(test_eq(m3x4[i][j], 0.0f)) } } TEST_SUCCESS } test_status_t test_assert_mat3x4_eq(mat3x4 m1, mat3x4 m2) { int i, j; for (i = 0; i < 3; i++) { for (j = 0; j < 4; j++) { ASSERT(fabsf(m1[i][j] - m2[i][j]) <= 0.0000009) } } TEST_SUCCESS } test_status_t test_assert_mat4_eq_identity(mat4 m4) { int i, j; for (i = 0; i < 4; i++) { for (j = 0; j < 4; j++) { if (i == j) { ASSERT(test_eq(m4[i][j], 1.0f)) } else { ASSERT(test_eq(m4[i][j], 0.0f)) } } } TEST_SUCCESS } test_status_t test_assert_mat4_eq_zero(mat4 m4) { int i, j; for (i = 0; i < 4; i++) { for (j = 0; j < 4; j++) { ASSERT(test_eq(m4[i][j], 0.0f)) } } TEST_SUCCESS } test_status_t test_assert_mat4x2_eq_zero(mat4x2 m4x2) { int i, j; for (i = 0; i < 4; i++) { for (j = 0; j < 2; j++) { ASSERT(test_eq(m4x2[i][j], 0.0f)) } } TEST_SUCCESS } test_status_t test_assert_mat4x2_eq(mat4x2 m1, mat4x2 m2) { int i, j; for (i = 0; i < 4; i++) { for (j = 0; j < 2; j++) { ASSERT(fabsf(m1[i][j] - m2[i][j]) <= 0.0000009) } } TEST_SUCCESS } test_status_t test_assert_mat4x3_eq_zero(mat4x3 m4x3) { int i, j; for (i = 0; i < 4; i++) { for (j = 0; j < 3; j++) { ASSERT(test_eq(m4x3[i][j], 0.0f)) } } TEST_SUCCESS } test_status_t test_assert_mat4x3_eq(mat4x3 m1, mat4x3 m2) { int i, j; for (i = 0; i < 4; i++) { for (j = 0; j < 3; j++) { ASSERT(fabsf(m1[i][j] - m2[i][j]) <= 0.0000009) } } TEST_SUCCESS } test_status_t test_assert_eqf(float a, float b) { ASSERT(fabsf(a - b) <= 0.000009); /* rounding errors */ TEST_SUCCESS } test_status_t test_assert_vec2_eq(vec2 v1, vec2 v2) { ASSERT(fabsf(v1[0] - v2[0]) <= 0.000009); /* rounding errors */ ASSERT(fabsf(v1[1] - v2[1]) <= 0.000009); TEST_SUCCESS } test_status_t test_assert_vec3_eq(vec3 v1, vec3 v2) { ASSERT(fabsf(v1[0] - v2[0]) <= 0.000009); /* rounding errors */ ASSERT(fabsf(v1[1] - v2[1]) <= 0.000009); ASSERT(fabsf(v1[2] - v2[2]) <= 0.000009); TEST_SUCCESS } test_status_t test_assert_vec3s_eq(vec3s v1, vec3s v2) { test_assert_vec3_eq(v1.raw, v2.raw); TEST_SUCCESS } test_status_t test_assert_vec4_eq(vec4 v1, vec4 v2) { ASSERT(fabsf(v1[0] - v2[0]) <= 0.000009); /* rounding errors */ ASSERT(fabsf(v1[1] - v2[1]) <= 0.000009); ASSERT(fabsf(v1[2] - v2[2]) <= 0.000009); ASSERT(fabsf(v1[3] - v2[3]) <= 0.000009); TEST_SUCCESS } test_status_t test_assert_vec4s_eq(vec4s v1, vec4s v2) { test_assert_vec4_eq(v1.raw, v2.raw); TEST_SUCCESS } test_status_t test_assert_quat_eq_abs(versor v1, versor v2) { ASSERT(fabsf(fabsf(v1[0]) - fabsf(v2[0])) <= 0.0009); /* rounding errors */ ASSERT(fabsf(fabsf(v1[1]) - fabsf(v2[1])) <= 0.0009); ASSERT(fabsf(fabsf(v1[2]) - fabsf(v2[2])) <= 0.0009); ASSERT(fabsf(fabsf(v1[3]) - fabsf(v2[3])) <= 0.0009); TEST_SUCCESS } test_status_t test_assert_quat_eq(versor v1, versor v2) { ASSERT(fabsf(v1[0] - v2[0]) <= 0.000009); /* rounding errors */ ASSERT(fabsf(v1[1] - v2[1]) <= 0.000009); ASSERT(fabsf(v1[2] - v2[2]) <= 0.000009); ASSERT(fabsf(v1[3] - v2[3]) <= 0.000009); TEST_SUCCESS } test_status_t test_assert_quat_eq_identity(versor q) { versor p = GLM_QUAT_IDENTITY_INIT; ASSERT(fabsf(q[0] - p[0]) <= 0.000009); /* rounding errors */ ASSERT(fabsf(q[1] - p[1]) <= 0.000009); ASSERT(fabsf(q[2] - p[2]) <= 0.000009); ASSERT(fabsf(q[3] - p[3]) <= 0.000009); TEST_SUCCESS } cglm-0.9.6/test/src/test_common.h000066400000000000000000000056101475344456400167400ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ #ifndef test_common_h #define test_common_h #include "../include/common.h" #if !defined(_WIN32) && !defined(_MSC_VER) # pragma GCC diagnostic ignored "-Wstrict-prototypes" #endif void test_rand_mat4(mat4 dest); void test_rand_mat4x2(mat4x2 dest); void test_rand_mat4x3(mat4x3 dest); void test_rand_mat3(mat3 dest); void test_rand_mat3x2(mat3x2 dest); void test_rand_mat3x4(mat3x4 dest); void test_rand_mat2(mat2 dest); void test_rand_mat2x3(mat2x3 dest); void test_rand_mat2x4(mat2x4 dest); test_status_t test_assert_eqf(float a, float b); test_status_t test_assert_mat4_eq(mat4 m1, mat4 m2); test_status_t test_assert_mat4_eqt(mat4 m1, mat4 m2); test_status_t test_assert_mat4_eq2(mat4 m1, mat4 m2, float eps); test_status_t test_assert_mat4_eq_identity(mat4 m4); test_status_t test_assert_mat4_eq_zero(mat4 m4); test_status_t test_assert_mat4x2_eq_zero(mat4x2 m4x2); test_status_t test_assert_mat4x2_eq(mat4x2 m1, mat4x2 m2); test_status_t test_assert_mat4x3_eq_zero(mat4x3 m4x3); test_status_t test_assert_mat4x3_eq(mat4x3 m1, mat4x3 m2); test_status_t test_assert_mat2_eqt(mat2 m1, mat2 m2); test_status_t test_assert_mat2_eq(mat2 m1, mat2 m2); test_status_t test_assert_mat2_eq_identity(mat2 m2); test_status_t test_assert_mat2_eq_zero(mat2 m2); test_status_t test_assert_mat2x3_eq_zero(mat2x3 m2x3); test_status_t test_assert_mat2x3_eq(mat2x3 m1, mat2x3 m2); test_status_t test_assert_mat2x4_eq_zero(mat2x4 m2x4); test_status_t test_assert_mat2x4_eq(mat2x4 m1, mat2x4 m2); test_status_t test_assert_mat3_eq(mat3 m1, mat3 m2); test_status_t test_assert_vec2_eq(vec2 v1, vec2 v2); test_status_t test_assert_mat3_eqt(mat3 m1, mat3 m2); test_status_t test_assert_mat3_eq_identity(mat3 m3); test_status_t test_assert_mat3_eq_zero(mat3 m3); test_status_t test_assert_mat3x2_eq_zero(mat3x2 m3x2); test_status_t test_assert_mat3x2_eq(mat3x2 m1, mat3x2 m2); test_status_t test_assert_mat3x4_eq_zero(mat3x4 m3x4); test_status_t test_assert_mat3x4_eq(mat3x4 m1, mat3x4 m2); test_status_t test_assert_vec3_eq(vec3 v1, vec3 v2); test_status_t test_assert_vec3s_eq(vec3s v1, vec3s v2); test_status_t test_assert_vec4_eq(vec4 v1, vec4 v2); test_status_t test_assert_vec4s_eq(vec4s v1, vec4s v2); test_status_t test_assert_quat_eq(versor v1, versor v2); test_status_t test_assert_quat_eq_identity(versor q) ; test_status_t test_assert_quat_eq_abs(versor v1, versor v2); void test_rand_vec3(vec3 dest); vec3s test_rand_vec3s(void); void test_rand_vec4(vec4 dest); vec4s test_rand_vec4s(void); float test_rand(void); void test_rand_quat(versor q); CGLM_INLINE bool test_eq(float a, float b) { return fabsf(a - b) <= GLM_FLT_EPSILON * 10; } CGLM_INLINE bool test_eq_th(float a, float b, float th) { return fabsf(a - b) <= th; } #endif /* test_common_h */ cglm-0.9.6/test/src/test_euler.c000066400000000000000000000021351475344456400165560ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ #include "test_common.h" TEST_IMPL(euler) { mat4 rot1, rot2; vec3 inAngles, outAngles; inAngles[0] = glm_rad(-45.0f); /* X angle */ inAngles[1] = glm_rad(88.0f); /* Y angle */ inAngles[2] = glm_rad(18.0f); /* Z angle */ glm_euler_xyz(inAngles, rot1); /* extract angles */ glmc_euler_angles(rot1, outAngles); /* angles must be equal in that range */ ASSERTIFY(test_assert_vec3_eq(inAngles, outAngles)) /* matrices must be equal */ glmc_euler_xyz(outAngles, rot2); ASSERTIFY(test_assert_mat4_eq(rot1, rot2)) /* change range */ inAngles[0] = glm_rad(-145.0f); /* X angle */ inAngles[1] = glm_rad(818.0f); /* Y angle */ inAngles[2] = glm_rad(181.0f); /* Z angle */ glm_euler_xyz(inAngles, rot1); glmc_euler_angles(rot1, outAngles); /* angles may not be equal but matrices MUST! */ /* matrices must be equal */ glmc_euler_xyz(outAngles, rot2); ASSERTIFY(test_assert_mat4_eq(rot1, rot2)) TEST_SUCCESS } cglm-0.9.6/test/src/test_euler_to_quat_lh.h000066400000000000000000000347461475344456400210170ustar00rootroot00000000000000/* * 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 } cglm-0.9.6/test/src/test_euler_to_quat_rh.h000066400000000000000000000421441475344456400210140ustar00rootroot00000000000000/* * 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 } cglm-0.9.6/test/src/test_ivec2.h000066400000000000000000000213431475344456400164610ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ #include "test_common.h" TEST_IMPL(GLM_PREFIX, ivec2) { ivec4 v4 = {2, 3, 5, 7}; ivec3 v3 = {11, 13, 17}; ivec2 v2; GLM(ivec2)(v4, v2); ASSERT(v2[0] == 2) ASSERT(v2[1] == 3) GLM(ivec2)(v3, v2); ASSERT(v2[0] == 11) ASSERT(v2[1] == 13) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, ivec2_copy) { ivec2 src = {7, 5}; ivec2 dst = {99, 99}; GLM(ivec2_copy)(src, dst); ASSERT(dst[0] == 7) ASSERT(dst[1] == 5) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, ivec2_zero) { ivec2 v = {2, 3}; GLM(ivec2_zero)(v); ASSERT(v[0] == 0) ASSERT(v[1] == 0) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, ivec2_one) { ivec2 v = {-2, 9}; GLM(ivec2_one)(v); ASSERT(v[0] == 1) ASSERT(v[1] == 1) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, ivec2_dot) { ivec2 a = {2, 3}; ivec2 b = {4, 4}; int dot1, dot2; dot1 = GLM(ivec2_dot)(a, b); dot2 = a[0] * b[0] + a[1] * b[1]; ASSERT(dot1 == dot2) ASSERT(dot1 == 20) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, ivec2_cross) { ivec2 a = {10, 9}; ivec2 b = {1, 2}; int cross1, cross2; cross1 = GLM(ivec2_cross)(a, b); cross2 = a[0] * b[1] - a[1] * b[0]; ASSERT(cross1 == cross2) ASSERT(cross1 == 11) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, ivec2_add) { ivec2 a = {14, 3}; ivec2 b = {-3, 2}; ivec2 v = {99, 99}; GLM(ivec2_add)(a, b, v); ASSERT(v[0] == 11) ASSERT(v[1] == 5) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, ivec2_adds) { ivec2 a = {-3, 1}; ivec2 v = {99, 99}; int s = 2; GLM(ivec2_adds)(a, s, v); ASSERT(v[0] == -1) ASSERT(v[1] == 3) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, ivec2_sub) { ivec2 a = {-2, 9}; ivec2 b = {3, 2}; ivec2 v = {99, 99}; GLM(ivec2_sub)(a, b, v); ASSERT(v[0] == -5) ASSERT(v[1] == 7) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, ivec2_subs) { ivec2 a = {5, -2}; ivec2 v = {99, 99}; int s = -3; GLM(ivec2_subs)(a, s, v); ASSERT(v[0] == 8) ASSERT(v[1] == 1) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, ivec2_mul) { ivec2 a = {3, 4}; ivec2 b = {-2, 3}; ivec2 v = {99, 99}; GLM(ivec2_mul)(a, b, v); ASSERT(v[0] == -6) ASSERT(v[1] == 12) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, ivec2_scale) { ivec2 a = {-9, 2}; ivec2 v = {99, 99}; int s = -2; GLM(ivec2_scale)(a, s, v); ASSERT(v[0] == 18) ASSERT(v[1] == -4) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, ivec2_div) { ivec2 v1 = {6, 5}, v2 = {-2, 4}, v3; GLM(ivec2_div)(v1, v2, v3); ASSERT(v1[0] / v2[0] == v3[0]) ASSERT(v1[1] / v2[1] == v3[1]) ASSERT(v3[0] == -3) ASSERT(v3[1] == 1) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, ivec2_divs) { ivec2 v1 = {16, -8}, v2; int s = 4; GLM(ivec2_divs)(v1, s, v2); ASSERT(v1[0] / s == v2[0]) ASSERT(v1[1] / s == v2[1]) ASSERT(v2[0] == 4) ASSERT(v2[1] == -2) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, ivec2_mod) { ivec2 a = {16, -8}; ivec2 b = {3, 5}; ivec2 dest; GLM(ivec2_mod)(a, b, dest); ASSERT(a[0] % b[0] == dest[0]) ASSERT(a[1] % b[1] == dest[1]) ASSERT(dest[0] == 1) ASSERT(dest[1] == -3) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, ivec2_addadd) { ivec2 a = {2, -3}, b = {-3, 4}, c = {1, 2}, d = {1, 2}; GLM(ivec2_addadd)(a, b, c); ASSERT(d[0] + a[0] + b[0] == c[0]) ASSERT(d[1] + a[1] + b[1] == c[1]) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, ivec2_addadds) { ivec2 a = {2, -3}, c = {1, 2}, d = {1, 2}; int s = 9; GLM(ivec2_addadds)(a, s, c); ASSERT(d[0] + a[0] + s == c[0]) ASSERT(d[1] + a[1] + s == c[1]) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, ivec2_subadd) { ivec2 a = {2, -3}, b = {-3, 4}, c = {1, 2}, d = {1, 2}; GLM(ivec2_subadd)(a, b, c); ASSERT(d[0] + (a[0] - b[0]) == c[0]) ASSERT(d[1] + (a[1] - b[1]) == c[1]) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, ivec2_subadds) { ivec2 a = {2, -3}, c = {1, 2}, d = {1, 2}; int s = 9; GLM(ivec2_subadds)(a, s, c); ASSERT(d[0] + a[0] - s == c[0]) ASSERT(d[1] + a[1] - s == c[1]) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, ivec2_muladd) { ivec2 a = {2, -3}, b = {-3, 4}, c = {1, 2}, d = {1, 2}; GLM(ivec2_muladd)(a, b, c); ASSERT(d[0] + a[0] * b[0] == c[0]) ASSERT(d[1] + a[1] * b[1] == c[1]) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, ivec2_muladds) { ivec2 a = {2, -3}, c = {1, 2}, d = {1, 2}; int s = 9; GLM(ivec2_muladds)(a, s, c); ASSERT(d[0] + a[0] * s == c[0]) ASSERT(d[1] + a[1] * s == c[1]) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, ivec2_maxadd) { ivec2 a = {2, -3}, b = {-3, 4}, c = {1, 2}, d = {1, 2}; GLM(ivec2_maxadd)(a, b, c); ASSERT(d[0] += glm_imax(a[0], b[0]) == c[0]) ASSERT(d[1] += glm_imax(a[1], b[1]) == c[1]) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, ivec2_minadd) { ivec2 a = {2, -3}, b = {-3, 4}, c = {1, 2}, d = {1, 2}; GLM(ivec2_minadd)(a, b, c); ASSERT(d[0] += glm_imin(a[0], b[0]) == c[0]) ASSERT(d[1] += glm_imin(a[1], b[1]) == c[1]) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, ivec2_subsub) { ivec2 a = {2, -3}, b = {-3, 4}, c = {1, 2}, d = {1, 2}; GLM(ivec2_subsub)(a, b, c); ASSERT(d[0] - (a[0] - b[0]) == c[0]) ASSERT(d[1] - (a[1] - b[1]) == c[1]) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, ivec2_subsubs) { ivec2 a = {2, -3}, c = {1, 2}, d = {1, 2}; int s = 9; GLM(ivec2_subsubs)(a, s, c); ASSERT(d[0] - (a[0] - s) == c[0]) ASSERT(d[1] - (a[1] - s) == c[1]) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, ivec2_addsub) { ivec2 a = {2, -3}, b = {-3, 4}, c = {1, 2}, d = {1, 2}; GLM(ivec2_addsub)(a, b, c); ASSERT(d[0] - (a[0] + b[0]) == c[0]) ASSERT(d[1] - (a[1] + b[1]) == c[1]) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, ivec2_addsubs) { ivec2 a = {2, -3}, c = {1, 2}, d = {1, 2}; int s = 9; GLM(ivec2_addsubs)(a, s, c); ASSERT(d[0] - (a[0] + s) == c[0]) ASSERT(d[1] - (a[1] + s) == c[1]) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, ivec2_mulsub) { ivec2 a = {2, -3}, b = {-3, 4}, c = {1, 2}, d = {1, 2}; GLM(ivec2_mulsub)(a, b, c); ASSERT(d[0] - a[0] * b[0] == c[0]) ASSERT(d[1] - a[1] * b[1] == c[1]) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, ivec2_mulsubs) { ivec2 a = {2, -3}, c = {1, 2}, d = {1, 2}; int s = 9; GLM(ivec2_mulsubs)(a, s, c); ASSERT(d[0] - a[0] * s == c[0]) ASSERT(d[1] - a[1] * s == c[1]) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, ivec2_maxsub) { ivec2 a = {2, -3}, b = {-3, 4}, c = {1, 2}, d = {1, 2}; GLM(ivec2_maxsub)(a, b, c); ASSERT(d[0] -= glm_imax(a[0], b[0]) == c[0]) ASSERT(d[1] -= glm_imax(a[1], b[1]) == c[1]) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, ivec2_minsub) { ivec2 a = {2, -3}, b = {-3, 4}, c = {1, 2}, d = {1, 2}; GLM(ivec2_minsub)(a, b, c); ASSERT(d[0] -= glm_imin(a[0], b[0]) == c[0]) ASSERT(d[1] -= glm_imin(a[1], b[1]) == c[1]) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, ivec2_distance2) { ivec2 a = {-1, 3}; ivec2 b = {5, 4}; int v; v = GLM(ivec2_distance2)(a, b); ASSERT(v == 37) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, ivec2_distance) { ivec2 a = {3, 2}; ivec2 b = {-2, 5}; float v; v = GLM(ivec2_distance)(a, b); ASSERT(test_eq(v, 5.8309518948f)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, ivec2_fill) { ivec2 v1; ivec2 v2 = {-1, 3}; GLM(ivec2_fill)(v1, 1); GLM(ivec2_fill)(v2, 2); ASSERT(GLM(ivec2_eq)(v1, 1)) ASSERT(GLM(ivec2_eq)(v2, 2)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, ivec2_eq) { ivec2 v1 = {-1, 2}; GLM(ivec2_fill)(v1, 2); ASSERT(GLM(ivec2_eq)(v1, 2)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, ivec2_eqv) { ivec2 v1, v2, v3; GLM(ivec2_fill)(v1, 1); GLM(ivec2_fill)(v2, 2); GLM(ivec2_fill)(v3, 1); ASSERT(GLM(ivec2_eqv)(v1, v3)) ASSERT(!GLM(ivec2_eqv)(v1, v2)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, ivec2_maxv) { ivec2 a = {9, -20}; ivec2 b = {8, -1}; ivec2 v = {99, 99}; GLM(ivec2_maxv)(a, b, v); ASSERT(v[0] == 9) ASSERT(v[1] == -1) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, ivec2_minv) { ivec2 a = {16, 0}; ivec2 b = {-15, 10}; ivec2 v = {99, 99}; GLM(ivec2_minv)(a, b, v); ASSERT(v[0] == -15) ASSERT(v[1] == 0) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, ivec2_clamp) { ivec2 v = {3, -1}; GLM(ivec2_clamp)(v, -2, 4); ASSERT(v[0] == 3) ASSERT(v[1] == -1) v[0] = -15; v[1] = 4; GLM(ivec2_clamp)(v, -9, 3); ASSERT(v[0] == -9) ASSERT(v[1] == 3) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, ivec2_abs) { ivec2 v1 = {2, -3}, v2 = {-12, -31}; ivec2 v3, v4; GLM(ivec2_abs)(v1, v3); GLM(ivec2_abs)(v2, v4); ASSERT(v3[0] == 2) ASSERT(v3[1] == 3) ASSERT(v4[0] == 12) ASSERT(v4[1] == 31) TEST_SUCCESS } cglm-0.9.6/test/src/test_ivec3.h000066400000000000000000000244761475344456400164740ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ #include "test_common.h" TEST_IMPL(GLM_PREFIX, ivec3) { ivec4 v4 = {2, 3, 5, 7}; ivec3 v3 = {99, 99, 99}; GLM(ivec3)(v4, v3); ASSERT(v3[0] == 2) ASSERT(v3[1] == 3) ASSERT(v3[2] == 5) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, ivec3_copy) { ivec3 src = {7, 5, 2}; ivec3 dst = {99, 99, 99}; GLM(ivec3_copy)(src, dst); ASSERT(dst[0] == 7) ASSERT(dst[1] == 5) ASSERT(dst[2] == 2) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, ivec3_zero) { ivec3 v = {2, 3, 5}; GLM(ivec3_zero)(v); ASSERT(v[0] == 0) ASSERT(v[1] == 0) ASSERT(v[2] == 0) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, ivec3_one) { ivec3 v = {-2, 9, 12}; GLM(ivec3_one)(v); ASSERT(v[0] == 1) ASSERT(v[1] == 1) ASSERT(v[2] == 1) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, ivec3_dot) { ivec3 a = {2, 3, 1}; ivec3 b = {4, 4, 2}; int dot1, dot2; dot1 = GLM(ivec3_dot)(a, b); dot2 = a[0] * b[0] + a[1] * b[1] + a[2] * b[2]; ASSERT(dot1 == dot2) ASSERT(dot1 == 22) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, ivec3_norm2) { ivec3 v = {2, 3, 4}; int norm2_1, norm2_2; norm2_1 = GLM(ivec3_norm2)(v); norm2_2 = v[0] * v[0] + v[1] * v[1] + v[2] * v[2]; ASSERT(norm2_1 == norm2_2) ASSERT(norm2_1 == 29) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, ivec3_norm) { ivec3 v = {2, 3, 4}; int norm1, norm2; norm1 = GLM(ivec3_norm)(v); norm2 = (int)sqrtf((float)(v[0] * v[0] + v[1] * v[1] + v[2] * v[2])); ASSERT(norm1 == norm2) ASSERT(norm1 == 5) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, ivec3_add) { ivec3 a = {14, 3, 2}; ivec3 b = {-3, 2, 1}; ivec3 v = {99, 99, 99}; GLM(ivec3_add)(a, b, v); ASSERT(v[0] == 11) ASSERT(v[1] == 5) ASSERT(v[2] == 3) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, ivec3_adds) { ivec3 a = {-3, 1, 4}; ivec3 v = {99, 99, 99}; int s = 2; GLM(ivec3_adds)(a, s, v); ASSERT(v[0] == -1) ASSERT(v[1] == 3) ASSERT(v[2] == 6) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, ivec3_sub) { ivec3 a = {-2, 9, 1}; ivec3 b = {3, 2, -1}; ivec3 v = {99, 99, 99}; GLM(ivec3_sub)(a, b, v); ASSERT(v[0] == -5) ASSERT(v[1] == 7) ASSERT(v[2] == 2) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, ivec3_subs) { ivec3 a = {5, -2, 6}; ivec3 v = {99, 99, 99}; int s = -3; GLM(ivec3_subs)(a, s, v); ASSERT(v[0] == 8) ASSERT(v[1] == 1) ASSERT(v[2] == 9) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, ivec3_mul) { ivec3 a = {3, 4, 5}; ivec3 b = {-2, 3, 1}; ivec3 v = {99, 99, 99}; GLM(ivec3_mul)(a, b, v); ASSERT(v[0] == -6) ASSERT(v[1] == 12) ASSERT(v[2] == 5) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, ivec3_scale) { ivec3 a = {-9, 2, 3}; ivec3 v = {99, 99, 99}; int s = -2; GLM(ivec3_scale)(a, s, v); ASSERT(v[0] == 18) ASSERT(v[1] == -4) ASSERT(v[2] == -6) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, ivec3_div) { ivec3 v1 = {6, 5, 8}, v2 = {-2, 4, 2}, v3; GLM(ivec3_div)(v1, v2, v3); ASSERT(v1[0] / v2[0] == v3[0]) ASSERT(v1[1] / v2[1] == v3[1]) ASSERT(v1[2] / v2[2] == v3[2]) ASSERT(v3[0] == -3) ASSERT(v3[1] == 1) ASSERT(v3[2] == 4) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, ivec3_divs) { ivec3 v1 = {16, -8, 12}, v2; int s = 4; GLM(ivec3_divs)(v1, s, v2); ASSERT(v1[0] / s == v2[0]) ASSERT(v1[1] / s == v2[1]) ASSERT(v1[2] / s == v2[2]) ASSERT(v2[0] == 4) ASSERT(v2[1] == -2) ASSERT(v2[2] == 3) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, ivec3_mod) { ivec3 a = {16, -8, 10}; ivec3 b = {3, 5, 4}; ivec3 dest; GLM(ivec3_mod)(a, b, dest); ASSERT(a[0] % b[0] == dest[0]) ASSERT(a[1] % b[1] == dest[1]) ASSERT(a[2] % b[2] == dest[2]) ASSERT(dest[0] == 1) ASSERT(dest[1] == -3) ASSERT(dest[2] == 2) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, ivec3_addadd) { ivec3 a = {2, -3, 8}, b = {-3, 4, 5}, c = {1, 2, 6}, d = {1, 2, 6}; GLM(ivec3_addadd)(a, b, c); ASSERT(d[0] + a[0] + b[0] == c[0]) ASSERT(d[1] + a[1] + b[1] == c[1]) ASSERT(d[2] + a[2] + b[2] == c[2]) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, ivec3_addadds) { ivec3 a = {2, -3, 5}, c = {1, 2, -9}, d = {1, 2, -9}; int s = 9; GLM(ivec3_addadds)(a, s, c); ASSERT(d[0] + a[0] + s == c[0]) ASSERT(d[1] + a[1] + s == c[1]) ASSERT(d[2] + a[2] + s == c[2]) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, ivec3_subadd) { ivec3 a = {2, -3, 8}, b = {-3, 4, 5}, c = {1, 2, 6}, d = {1, 2, 6}; GLM(ivec3_subadd)(a, b, c); ASSERT(d[0] + a[0] - b[0] == c[0]) ASSERT(d[1] + a[1] - b[1] == c[1]) ASSERT(d[2] + a[2] - b[2] == c[2]) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, ivec3_subadds) { ivec3 a = {2, -3, 5}, c = {1, 2, -9}, d = {1, 2, -9}; int s = 9; GLM(ivec3_subadds)(a, s, c); ASSERT(d[0] + a[0] - s == c[0]) ASSERT(d[1] + a[1] - s == c[1]) ASSERT(d[2] + a[2] - s == c[2]) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, ivec3_muladd) { ivec3 a = {2, -3, 8}, b = {-3, 4, 5}, c = {1, 2, 6}, d = {1, 2, 6}; GLM(ivec3_muladd)(a, b, c); ASSERT(d[0] + a[0] * b[0] == c[0]) ASSERT(d[1] + a[1] * b[1] == c[1]) ASSERT(d[2] + a[2] * b[2] == c[2]) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, ivec3_muladds) { ivec3 a = {2, -3, 5}, c = {1, 2, -9}, d = {1, 2, -9}; int s = 9; GLM(ivec3_muladds)(a, s, c); ASSERT(d[0] + a[0] * s == c[0]) ASSERT(d[1] + a[1] * s == c[1]) ASSERT(d[2] + a[2] * s == c[2]) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, ivec3_maxadd) { ivec3 a = {2, -3, 8}, b = {-3, 4, 5}, c = {1, 2, 6}, d = {1, 2, 6}; GLM(ivec3_maxadd)(a, b, c); ASSERT(d[0] += glm_imax(a[0], b[0]) == c[0]) ASSERT(d[1] += glm_imax(a[1], b[1]) == c[1]) ASSERT(d[2] += glm_imax(a[2], b[2]) == c[2]) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, ivec3_minadd) { ivec3 a = {2, -3, 8}, b = {-3, 4, 5}, c = {1, 2, 6}, d = {1, 2, 6}; GLM(ivec3_minadd)(a, b, c); ASSERT(d[0] += glm_imin(a[0], b[0]) == c[0]) ASSERT(d[1] += glm_imin(a[1], b[1]) == c[1]) ASSERT(d[2] += glm_imin(a[2], b[2]) == c[2]) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, ivec3_subsub) { ivec3 a = {2, -3, 8}, b = {-3, 4, 5}, c = {1, 2, 6}, d = {1, 2, 6}; GLM(ivec3_subsub)(a, b, c); ASSERT(d[0] - (a[0] - b[0]) == c[0]) ASSERT(d[1] - (a[1] - b[1]) == c[1]) ASSERT(d[2] - (a[2] - b[2]) == c[2]) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, ivec3_subsubs) { ivec3 a = {2, -3, 5}, c = {1, 2, -9}, d = {1, 2, -9}; int s = 9; GLM(ivec3_subsubs)(a, s, c); ASSERT(d[0] - (a[0] - s) == c[0]) ASSERT(d[1] - (a[1] - s) == c[1]) ASSERT(d[2] - (a[2] - s) == c[2]) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, ivec3_addsub) { ivec3 a = {2, -3, 8}, b = {-3, 4, 5}, c = {1, 2, 6}, d = {1, 2, 6}; GLM(ivec3_addsub)(a, b, c); ASSERT(d[0] - (a[0] + b[0]) == c[0]) ASSERT(d[1] - (a[1] + b[1]) == c[1]) ASSERT(d[2] - (a[2] + b[2]) == c[2]) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, ivec3_addsubs) { ivec3 a = {2, -3, 5}, c = {1, 2, -9}, d = {1, 2, -9}; int s = 9; GLM(ivec3_addsubs)(a, s, c); ASSERT(d[0] - (a[0] + s) == c[0]) ASSERT(d[1] - (a[1] + s) == c[1]) ASSERT(d[2] - (a[2] + s) == c[2]) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, ivec3_mulsub) { ivec3 a = {2, -3, 8}, b = {-3, 4, 5}, c = {1, 2, 6}, d = {1, 2, 6}; GLM(ivec3_mulsub)(a, b, c); ASSERT(d[0] - a[0] * b[0] == c[0]) ASSERT(d[1] - a[1] * b[1] == c[1]) ASSERT(d[2] - a[2] * b[2] == c[2]) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, ivec3_mulsubs) { ivec3 a = {2, -3, 5}, c = {1, 2, -9}, d = {1, 2, -9}; int s = 9; GLM(ivec3_mulsubs)(a, s, c); ASSERT(d[0] - a[0] * s == c[0]) ASSERT(d[1] - a[1] * s == c[1]) ASSERT(d[2] - a[2] * s == c[2]) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, ivec3_maxsub) { ivec3 a = {2, -3, 8}, b = {-3, 4, 5}, c = {1, 2, 6}, d = {1, 2, 6}; GLM(ivec3_maxsub)(a, b, c); ASSERT(d[0] -= glm_imax(a[0], b[0]) == c[0]) ASSERT(d[1] -= glm_imax(a[1], b[1]) == c[1]) ASSERT(d[2] -= glm_imax(a[2], b[2]) == c[2]) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, ivec3_minsub) { ivec3 a = {2, -3, 8}, b = {-3, 4, 5}, c = {1, 2, 6}, d = {1, 2, 6}; GLM(ivec3_minsub)(a, b, c); ASSERT(d[0] -= glm_imin(a[0], b[0]) == c[0]) ASSERT(d[1] -= glm_imin(a[1], b[1]) == c[1]) ASSERT(d[2] -= glm_imin(a[2], b[2]) == c[2]) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, ivec3_distance2) { ivec3 a = {-1, 3, 0}; ivec3 b = {5, 4, 2}; int v; v = GLM(ivec3_distance2)(a, b); ASSERT(v == 41) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, ivec3_distance) { ivec3 a = {3, 2, 4}; ivec3 b = {-2, 5, 2}; float v; v = GLM(ivec3_distance)(a, b); ASSERT(test_eq(v, 6.1644140029f)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, ivec3_fill) { ivec3 v1; ivec3 v2 = {-1, 3, 4}; GLM(ivec3_fill)(v1, 1); GLM(ivec3_fill)(v2, 2); ASSERT(GLM(ivec3_eq)(v1, 1)) ASSERT(GLM(ivec3_eq)(v2, 2)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, ivec3_eq) { ivec3 v1 = { -1, 2, 4 }; GLM(ivec3_fill)(v1, 2); ASSERT(GLM(ivec3_eq)(v1, 2)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, ivec3_eqv) { ivec3 v1, v2, v3; GLM(ivec3_fill)(v1, 1); GLM(ivec3_fill)(v2, 2); GLM(ivec3_fill)(v3, 1); ASSERT(GLM(ivec3_eqv)(v1, v3)) ASSERT(!GLM(ivec3_eqv)(v1, v2)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, ivec3_maxv) { ivec3 a = {9, -20, 5}; ivec3 b = {8, -1, 2}; ivec3 v = {99, 99, 99}; GLM(ivec3_maxv)(a, b, v); ASSERT(v[0] == 9) ASSERT(v[1] == -1) ASSERT(v[2] == 5) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, ivec3_minv) { ivec3 a = {16, 0, 4}; ivec3 b = {-15, 10, 8}; ivec3 v = {99, 99, 99}; GLM(ivec3_minv)(a, b, v); ASSERT(v[0] == -15) ASSERT(v[1] == 0) ASSERT(v[2] == 4) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, ivec3_clamp) { ivec3 v = {3, -1, 10}; GLM(ivec3_clamp)(v, -2, 4); ASSERT(v[0] == 3) ASSERT(v[1] == -1) ASSERT(v[2] == 4) v[0] = -15; v[1] = 4; v[2] = 1; GLM(ivec3_clamp)(v, -9, 3); ASSERT(v[0] == -9) ASSERT(v[1] == 3) ASSERT(v[2] == 1) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, ivec3_abs) { ivec3 v1 = {2, -3, 4}, v2 = {-12, -31, -42}; ivec3 v3, v4; GLM(ivec3_abs)(v1, v3); GLM(ivec3_abs)(v2, v4); ASSERT(v3[0] == 2) ASSERT(v3[1] == 3) ASSERT(v3[2] == 4) ASSERT(v4[0] == 12) ASSERT(v4[1] == 31) ASSERT(v4[2] == 42) TEST_SUCCESS } cglm-0.9.6/test/src/test_ivec4.h000066400000000000000000000226151475344456400164660ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ #include "test_common.h" TEST_IMPL(GLM_PREFIX, ivec4) { ivec4 v3 = {2, 3, 5}; ivec4 v4; GLM(ivec4)(v3, 7, v4); ASSERT(v4[0] == 2) ASSERT(v4[1] == 3) ASSERT(v4[2] == 5) ASSERT(v4[3] == 7) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, ivec4_copy) { ivec4 src = {7, 5, 2, 11}; ivec4 dst = {99, 99, 99, 99}; GLM(ivec4_copy)(src, dst); ASSERT(dst[0] == 7) ASSERT(dst[1] == 5) ASSERT(dst[2] == 2) ASSERT(dst[3] == 11) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, ivec4_zero) { ivec4 v = {2, 3, 5, 7}; GLM(ivec4_zero)(v); ASSERT(v[0] == 0) ASSERT(v[1] == 0) ASSERT(v[2] == 0) ASSERT(v[3] == 0) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, ivec4_one) { ivec4 v = {-2, 9, 12, 7}; GLM(ivec4_one)(v); ASSERT(v[0] == 1) ASSERT(v[1] == 1) ASSERT(v[2] == 1) ASSERT(v[3] == 1) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, ivec4_add) { ivec4 a = {14, 3, 2, -4}; ivec4 b = {-3, 2, 1, -1}; ivec4 v = {99, 99, 99, 99}; GLM(ivec4_add)(a, b, v); ASSERT(v[0] == 11) ASSERT(v[1] == 5) ASSERT(v[2] == 3) ASSERT(v[3] == -5) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, ivec4_adds) { ivec4 a = {-3, 1, 4, 2}; ivec4 v = {99, 99, 99, 99}; int s = -2; GLM(ivec4_adds)(a, s, v); ASSERT(v[0] == -5) ASSERT(v[1] == -1) ASSERT(v[2] == 2) ASSERT(v[3] == 0) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, ivec4_sub) { ivec4 a = {-2, 9, 1, 5}; ivec4 b = {3, 2, -1, 2}; ivec4 v = {99, 99, 99, 99}; GLM(ivec4_sub)(a, b, v); ASSERT(v[0] == -5) ASSERT(v[1] == 7) ASSERT(v[2] == 2) ASSERT(v[3] == 3) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, ivec4_subs) { ivec4 a = {5, -2, 6, 1}; ivec4 v = {99, 99, 99, 99}; int s = 2; GLM(ivec4_subs)(a, s, v); ASSERT(v[0] == 3) ASSERT(v[1] == -4) ASSERT(v[2] == 4) ASSERT(v[3] == -1) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, ivec4_mul) { ivec4 a = {3, 4, 5, -3}; ivec4 b = {-2, 3, 1, 2}; ivec4 v = {99, 99, 99, 99}; GLM(ivec4_mul)(a, b, v); ASSERT(v[0] == -6) ASSERT(v[1] == 12) ASSERT(v[2] == 5) ASSERT(v[3] == -6) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, ivec4_scale) { ivec4 a = {-9, 2, 3, 0}; ivec4 v = {99, 99, 99, 99}; int s = -2; GLM(ivec4_scale)(a, s, v); ASSERT(v[0] == 18) ASSERT(v[1] == -4) ASSERT(v[2] == -6) ASSERT(v[3] == 0) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, ivec4_addadd) { ivec4 a = {2, -3, 8, -7}, b = {-3, 4, 5, -2}, c = {1, 2, 6, 15}, d = {1, 2, 6, 15}; GLM(ivec4_addadd)(a, b, c); ASSERT(d[0] + a[0] + b[0] == c[0]) ASSERT(d[1] + a[1] + b[1] == c[1]) ASSERT(d[2] + a[2] + b[2] == c[2]) ASSERT(d[3] + a[3] + b[3] == c[3]) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, ivec4_addadds) { ivec4 a = {2, -3, 4, 7}, c = {1, 2, -8, 5}, d = {1, 2, -8, 5}; int s = 9; GLM(ivec4_addadds)(a, s, c); ASSERT(d[0] + a[0] + s == c[0]) ASSERT(d[1] + a[1] + s == c[1]) ASSERT(d[2] + a[2] + s == c[2]) ASSERT(d[3] + a[3] + s == c[3]) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, ivec4_subadd) { ivec4 a = {2, -3, 8, -7}, b = {-3, 4, 5, -2}, c = {1, 2, 6, 15}, d = {1, 2, 6, 15}; GLM(ivec4_subadd)(a, b, c); ASSERT(d[0] + a[0] - b[0] == c[0]) ASSERT(d[1] + a[1] - b[1] == c[1]) ASSERT(d[2] + a[2] - b[2] == c[2]) ASSERT(d[3] + a[3] - b[3] == c[3]) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, ivec4_subadds) { ivec4 a = {2, -3, 4, 7}, c = {1, 2, -8, 5}, d = {1, 2, -8, 5}; int s = 9; GLM(ivec4_subadds)(a, s, c); ASSERT(d[0] + a[0] - s == c[0]) ASSERT(d[1] + a[1] - s == c[1]) ASSERT(d[2] + a[2] - s == c[2]) ASSERT(d[3] + a[3] - s == c[3]) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, ivec4_muladd) { ivec4 a = {2, -3, 8, -7}, b = {-3, 4, 5, -2}, c = {1, 2, 6, 15}, d = {1, 2, 6, 15}; GLM(ivec4_muladd)(a, b, c); ASSERT(d[0] + a[0] * b[0] == c[0]) ASSERT(d[1] + a[1] * b[1] == c[1]) ASSERT(d[2] + a[2] * b[2] == c[2]) ASSERT(d[3] + a[3] * b[3] == c[3]) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, ivec4_muladds) { ivec4 a = {2, -3, 4, 7}, c = {1, 2, -8, 5}, d = {1, 2, -8, 5}; int s = 9; GLM(ivec4_muladds)(a, s, c); ASSERT(d[0] + a[0] * s == c[0]) ASSERT(d[1] + a[1] * s == c[1]) ASSERT(d[2] + a[2] * s == c[2]) ASSERT(d[3] + a[3] * s == c[3]) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, ivec4_maxadd) { ivec4 a = {2, -3, 8, -7}, b = {-3, 4, 5, -2}, c = {1, 2, 6, 15}, d = {1, 2, 6, 15}; GLM(ivec4_maxadd)(a, b, c); ASSERT(d[0] += glm_imax(a[0], b[0]) == c[0]) ASSERT(d[1] += glm_imax(a[1], b[1]) == c[1]) ASSERT(d[2] += glm_imax(a[2], b[2]) == c[2]) ASSERT(d[3] += glm_imax(a[3], b[3]) == c[3]) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, ivec4_minadd) { ivec4 a = {2, -3, 8, -7}, b = {-3, 4, 5, -2}, c = {1, 2, 6, 15}, d = {1, 2, 6, 15}; GLM(ivec4_minadd)(a, b, c); ASSERT(d[0] += glm_imin(a[0], b[0]) == c[0]) ASSERT(d[1] += glm_imin(a[1], b[1]) == c[1]) ASSERT(d[2] += glm_imin(a[2], b[2]) == c[2]) ASSERT(d[3] += glm_imin(a[3], b[3]) == c[3]) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, ivec4_subsub) { ivec4 a = {2, -3, 8, -7}, b = {-3, 4, 5, -2}, c = {1, 2, 6, 15}, d = {1, 2, 6, 15}; GLM(ivec4_subsub)(a, b, c); ASSERT(d[0] - (a[0] - b[0]) == c[0]) ASSERT(d[1] - (a[1] - b[1]) == c[1]) ASSERT(d[2] - (a[2] - b[2]) == c[2]) ASSERT(d[3] - (a[3] - b[3]) == c[3]) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, ivec4_subsubs) { ivec4 a = {2, -3, 4, 7}, c = {1, 2, -8, 5}, d = {1, 2, -8, 5}; int s = 9; GLM(ivec4_subsubs)(a, s, c); ASSERT(d[0] - (a[0] - s) == c[0]) ASSERT(d[1] - (a[1] - s) == c[1]) ASSERT(d[2] - (a[2] - s) == c[2]) ASSERT(d[3] - (a[3] - s) == c[3]) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, ivec4_addsub) { ivec4 a = {2, -3, 8, -7}, b = {-3, 4, 5, -2}, c = {1, 2, 6, 15}, d = {1, 2, 6, 15}; GLM(ivec4_addsub)(a, b, c); ASSERT(d[0] - (a[0] + b[0]) == c[0]) ASSERT(d[1] - (a[1] + b[1]) == c[1]) ASSERT(d[2] - (a[2] + b[2]) == c[2]) ASSERT(d[3] - (a[3] + b[3]) == c[3]) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, ivec4_addsubs) { ivec4 a = {2, -3, 4, 7}, c = {1, 2, -8, 5}, d = {1, 2, -8, 5}; int s = 9; GLM(ivec4_addsubs)(a, s, c); ASSERT(d[0] - (a[0] + s) == c[0]) ASSERT(d[1] - (a[1] + s) == c[1]) ASSERT(d[2] - (a[2] + s) == c[2]) ASSERT(d[3] - (a[3] + s) == c[3]) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, ivec4_mulsub) { ivec4 a = {2, -3, 8, -7}, b = {-3, 4, 5, -2}, c = {1, 2, 6, 15}, d = {1, 2, 6, 15}; GLM(ivec4_mulsub)(a, b, c); ASSERT(d[0] - a[0] * b[0] == c[0]) ASSERT(d[1] - a[1] * b[1] == c[1]) ASSERT(d[2] - a[2] * b[2] == c[2]) ASSERT(d[3] - a[3] * b[3] == c[3]) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, ivec4_mulsubs) { ivec4 a = {2, -3, 4, 7}, c = {1, 2, -8, 5}, d = {1, 2, -8, 5}; int s = 9; GLM(ivec4_mulsubs)(a, s, c); ASSERT(d[0] - a[0] * s == c[0]) ASSERT(d[1] - a[1] * s == c[1]) ASSERT(d[2] - a[2] * s == c[2]) ASSERT(d[3] - a[3] * s == c[3]) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, ivec4_maxsub) { ivec4 a = {2, -3, 8, -7}, b = {-3, 4, 5, -2}, c = {1, 2, 6, 15}, d = {1, 2, 6, 15}; GLM(ivec4_maxsub)(a, b, c); ASSERT(d[0] -= glm_imax(a[0], b[0]) == c[0]) ASSERT(d[1] -= glm_imax(a[1], b[1]) == c[1]) ASSERT(d[2] -= glm_imax(a[2], b[2]) == c[2]) ASSERT(d[3] -= glm_imax(a[3], b[3]) == c[3]) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, ivec4_minsub) { ivec4 a = {2, -3, 8, -7}, b = {-3, 4, 5, -2}, c = {1, 2, 6, 15}, d = {1, 2, 6, 15}; GLM(ivec4_minsub)(a, b, c); ASSERT(d[0] -= glm_imin(a[0], b[0]) == c[0]) ASSERT(d[1] -= glm_imin(a[1], b[1]) == c[1]) ASSERT(d[2] -= glm_imin(a[2], b[2]) == c[2]) ASSERT(d[3] -= glm_imin(a[3], b[3]) == c[3]) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, ivec4_distance2) { ivec4 a = {-1, 3, 0, 4}; ivec4 b = {5, 4, 2, 6}; int v; v = GLM(ivec4_distance2)(a, b); ASSERT(v == 45) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, ivec4_distance) { ivec4 a = {3, 2, 4, -1}; ivec4 b = {-2, 5, 2, 4}; float v; v = GLM(ivec4_distance)(a, b); ASSERT(test_eq(v, 7.9372539331f)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, ivec4_maxv) { ivec4 a = {9, -20, 5, -3}; ivec4 b = {8, -1, 2, 2}; ivec4 v = {99, 99, 99, 99}; GLM(ivec4_maxv)(a, b, v); ASSERT(v[0] == 9) ASSERT(v[1] == -1) ASSERT(v[2] == 5) ASSERT(v[3] == 2) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, ivec4_minv) { ivec4 a = {16, 0, 4, 5}; ivec4 b = {-15, 10, 8, 2}; ivec4 v = {99, 99, 99, 99}; GLM(ivec4_minv)(a, b, v); ASSERT(v[0] == -15) ASSERT(v[1] == 0) ASSERT(v[2] == 4) ASSERT(v[3] == 2) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, ivec4_clamp) { ivec4 v = {3, -1, 10, -100}; GLM(ivec4_clamp)(v, -2, 4); ASSERT(v[0] == 3) ASSERT(v[1] == -1) ASSERT(v[2] == 4) ASSERT(v[3] == -2) v[0] = -15; v[1] = 4; v[2] = 1; v[3] = 0; GLM(ivec4_clamp)(v, -9, 3); ASSERT(v[0] == -9) ASSERT(v[1] == 3) ASSERT(v[2] == 1) ASSERT(v[3] == 0) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, ivec4_abs) { ivec4 v1 = {2, -3, 4, -5}, v2 = {-12, -31, -42, -50}; ivec4 v3, v4; GLM(ivec4_abs)(v1, v3); GLM(ivec4_abs)(v2, v4); ASSERT(v3[0] == 2) ASSERT(v3[1] == 3) ASSERT(v3[2] == 4) ASSERT(v3[3] == 5) ASSERT(v4[0] == 12) ASSERT(v4[1] == 31) ASSERT(v4[2] == 42) ASSERT(v4[3] == 50) TEST_SUCCESS } cglm-0.9.6/test/src/test_mat2.h000066400000000000000000000131411475344456400163110ustar00rootroot00000000000000/* * 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" #define A_MATRIX2x2 {{1,2},{5,6}} #define MAT2_ARRAY {1, 5, 2, 7} #ifndef CGLM_TEST_MAT2_ONCE #define CGLM_TEST_MAT2_ONCE TEST_IMPL(MACRO_GLM_MAT2_IDENTITY_INIT) { mat2 m = GLM_MAT2_IDENTITY_INIT; ASSERT(test_eq(m[0][0], 1.0f)) ASSERT(test_eq(m[0][1], 0.0f)) ASSERT(test_eq(m[1][0], 0.0f)) ASSERT(test_eq(m[1][1], 1.0f)) TEST_SUCCESS } TEST_IMPL(MACRO_GLM_MAT2_ZERO_INIT) { mat2 m = GLM_MAT2_ZERO_INIT; ASSERT(test_eq(m[0][0], 0.0f)) ASSERT(test_eq(m[0][1], 0.0f)) ASSERT(test_eq(m[1][0], 0.0f)) ASSERT(test_eq(m[1][1], 0.0f)) TEST_SUCCESS } TEST_IMPL(MACRO_GLM_MAT2_IDENTITY) { ASSERT(test_eq(GLM_MAT2_IDENTITY[0][0], 1.0f)) ASSERT(test_eq(GLM_MAT2_IDENTITY[0][1], 0.0f)) ASSERT(test_eq(GLM_MAT2_IDENTITY[1][0], 0.0f)) ASSERT(test_eq(GLM_MAT2_IDENTITY[1][1], 1.0f)) TEST_SUCCESS } TEST_IMPL(MACRO_GLM_MAT2_ZERO) { ASSERT(test_eq(GLM_MAT2_ZERO[0][0], 0.0f)) ASSERT(test_eq(GLM_MAT2_ZERO[0][1], 0.0f)) ASSERT(test_eq(GLM_MAT2_ZERO[1][0], 0.0f)) ASSERT(test_eq(GLM_MAT2_ZERO[1][1], 0.0f)) TEST_SUCCESS } #endif /* CGLM_TEST_MAT2_ONCE */ TEST_IMPL(GLM_PREFIX, mat2_copy) { mat2 m1 = A_MATRIX2x2; mat2 m2 = GLM_MAT2_IDENTITY_INIT; GLM(mat2_copy)(m1, m2); test_assert_mat2_eq(m1, m2); TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, mat2_identity) { mat2 m1 = GLM_MAT2_IDENTITY_INIT; mat2 m2 = GLM_MAT2_IDENTITY_INIT; mat2 m3; GLM(mat2_identity)(m3); ASSERTIFY(test_assert_mat2_eq_identity(m1)) ASSERTIFY(test_assert_mat2_eq_identity(m2)) ASSERTIFY(test_assert_mat2_eq_identity(m3)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, mat2_identity_array) { size_t i, count; mat2 matrices[4] = { A_MATRIX2x2, A_MATRIX2x2, A_MATRIX2x2, A_MATRIX2x2 }; count = 4; GLM(mat2_identity_array)(matrices, count); for (i = 0; i < count; i++) { ASSERTIFY(test_assert_mat2_eq_identity(matrices[i])) } TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, mat2_zero) { mat2 m1 = GLM_MAT2_ZERO_INIT; mat2 m2 = GLM_MAT2_ZERO_INIT; mat2 m3; GLM(mat2_zero)(m3); ASSERTIFY(test_assert_mat2_eq_zero(m1)) ASSERTIFY(test_assert_mat2_eq_zero(m2)) ASSERTIFY(test_assert_mat2_eq_zero(m3)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, mat2_mul) { mat2 m1 = GLM_MAT2_IDENTITY_INIT; mat2 m2 = GLM_MAT2_IDENTITY_INIT; mat2 m3; mat2 m4 = GLM_MAT2_ZERO_INIT; int i, j, k; /* test random matrices */ /* random matrices */ test_rand_mat2(m1); test_rand_mat2(m2); GLM(mat2_mul)(m1, m2, m3); for (i = 0; i < 2; i++) { for (j = 0; j < 2; j++) { for (k = 0; k < 2; k++) /* column-major */ m4[i][j] += m1[k][j] * m2[i][k]; } } ASSERTIFY(test_assert_mat2_eq(m3, m4)) /* test pre compiled */ GLM(mat2_mul)(m1, m2, m3); ASSERTIFY(test_assert_mat2_eq(m3, m4)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, mat2_transpose_to) { mat2 mat = A_MATRIX2x2; mat2 m1; GLM(mat2_transpose_to)(mat, m1); ASSERTIFY(test_assert_mat2_eqt(mat, m1)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, mat2_transpose) { mat2 mat = A_MATRIX2x2; mat2 m1; GLM(mat2_copy)(mat, m1); GLM(mat2_transpose)(m1); ASSERTIFY(test_assert_mat2_eqt(mat, m1)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, mat2_mulv) { vec2 res; mat2 mat = A_MATRIX2x2; vec2 v = {11.0f, 21.0f}; int i; GLM(mat2_mulv)(mat, v, res); for (i = 0; i < 2; i++) { ASSERT(test_eq(res[i], v[0] * mat[0][i] + v[1] * mat[1][i])) } TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, mat2_trace) { mat2 mat = A_MATRIX2x2; float trace; trace = GLM(mat2_trace)(mat); ASSERT(test_eq(trace, mat[0][0] + mat[1][1])) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, mat2_scale) { mat2 m1 = A_MATRIX2x2; mat2 m2 = A_MATRIX2x2; int i, j, scale; scale = rand() % 100; GLM(mat2_scale)(m1, (float)scale); for (i = 0; i < 2; i++) { for (j = 0; j < 2; j++) { ASSERT(test_eq(m1[i][j], m2[i][j] * scale)) } } TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, mat2_det) { TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, mat2_inv) { mat2 m1 = GLM_MAT2_IDENTITY_INIT; mat2 m2 = GLM_MAT2_IDENTITY_INIT; mat2 m3; int i; m1[0][0] = 41.0f; m1[0][1] = 0.0f; m1[1][0] = 0.0f; m1[1][1] = 70.0f; for (i = 0; i < 10000; i++) { /* test inverse precise */ GLM(mat2_inv)(m1, m2); GLM(mat2_inv)(m2, m3); ASSERTIFY(test_assert_mat2_eq(m1, m3)) } TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, mat2_swap_col) { mat2 m1 = A_MATRIX2x2; mat2 m2 = A_MATRIX2x2; GLM(mat2_swap_col)(m1, 0, 1); ASSERTIFY(test_assert_vec2_eq(m1[0], m2[1])) ASSERTIFY(test_assert_vec2_eq(m1[1], m2[0])) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, mat2_swap_row) { mat2 m1 = A_MATRIX2x2; mat2 m2 = A_MATRIX2x2; GLM(mat2_swap_row)(m1, 0, 1); ASSERT(test_eq(m1[0][0], m2[0][1])) ASSERT(test_eq(m1[0][1], m2[0][0])) ASSERT(test_eq(m1[1][0], m2[1][1])) ASSERT(test_eq(m1[1][1], m2[1][0])) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, mat2_rmc) { mat2 mat = A_MATRIX2x2; vec2 v = {11.0f, 12.0f}; vec2 v1; float r1, r2; int i; r1 = GLM(mat2_rmc)(v, mat, v); for (i = 0; i < 2; i++) { v1[i] = v[0] * mat[i][0] + v[1] * mat[i][1]; } r2 = v[0] * v1[0] + v[1] * v1[1]; ASSERT(test_eq(r1, r2)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, mat2_make) { mat2 dest; unsigned int i, j; float src[4] = MAT2_ARRAY; GLM(mat2_make)(src, dest); for (i = 0, j = 0; i < sizeof(src) / sizeof(float); i+=2, j++) { ASSERT(test_eq(dest[j][0], src[i])) ASSERT(test_eq(dest[j][1], src[i+1])) } TEST_SUCCESS } #undef A_MATRIX2x2 cglm-0.9.6/test/src/test_mat2x3.h000066400000000000000000000061431475344456400165700ustar00rootroot00000000000000/* * 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" #define A_MATRIX2X3 {{1,2,3},{5,6,7}} #define A_MATRIX2X3_TRANSPOSE {{1,5}, {2,6}, {3,7}} #ifndef CGLM_TEST_MAT2X3_ONCE #define CGLM_TEST_MAT2X3_ONCE TEST_IMPL(MACRO_GLM_MAT2X3_ZERO_INIT) { mat2x3 mat2x3_zero = GLM_MAT2X3_ZERO_INIT; test_assert_mat2x3_eq_zero(mat2x3_zero); TEST_SUCCESS } TEST_IMPL(MACRO_GLM_MAT2X3_ZERO) { mat2x3 mat2x3_zero = GLM_MAT2X3_ZERO; test_assert_mat2x3_eq_zero(mat2x3_zero); TEST_SUCCESS } #endif /* CGLM_TEST_MAT2X3_ONCE */ TEST_IMPL(GLM_PREFIX, mat2x3_copy) { mat2x3 m1 = A_MATRIX2X3; mat2x3 m2 = GLM_MAT2X3_ZERO_INIT; GLM(mat2x3_copy)(m1, m2); test_assert_mat2x3_eq(m1, m2); TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, mat2x3_zero) { mat2x3 m1 = GLM_MAT2X3_ZERO_INIT; mat2x3 m2 = GLM_MAT2X3_ZERO_INIT; mat2x3 m3; GLM(mat2x3_zero)(m3); ASSERTIFY(test_assert_mat2x3_eq_zero(m1)) ASSERTIFY(test_assert_mat2x3_eq_zero(m2)) ASSERTIFY(test_assert_mat2x3_eq_zero(m3)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, mat2x3_make) { float src[18] = { 0.5f, 1.7f, 10.3f, 4.2f, 8.9f, 1.1f, 2.3f, 4.2f, 66.5f, 23.7f, 6.6f, 8.9f, 5.3f, 4.8f, 96.3f, 13.7f, 4.7f, 5.5f }; mat2x3 dest[3]; float *srcp = src; unsigned int i, j, k; for (i = 0, j = 0, k = 0; i < sizeof(src) / sizeof(float); i+=6,j++) { GLM(mat2x3_make)(srcp + i, dest[j]); ASSERT(test_eq(src[ i ], dest[j][k][0])); ASSERT(test_eq(src[i+1], dest[j][k][1])); ASSERT(test_eq(src[i+2], dest[j][k][2])); ASSERT(test_eq(src[i+3], dest[j][k+1][0])); ASSERT(test_eq(src[i+4], dest[j][k+1][1])); ASSERT(test_eq(src[i+5], dest[j][k+1][2])); } TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, mat2x3_mul) { mat2x3 m1 = GLM_MAT2X3_ZERO_INIT; mat3x2 m2 = GLM_MAT3X2_ZERO_INIT; mat3 m3 = GLM_MAT3_ZERO_INIT; mat3 m4 = GLM_MAT3_ZERO_INIT; int c, r, k; /* test random matrices */ /* random matrices */ test_rand_mat2x3(m1); test_rand_mat3x2(m2); for (r = 0; r < 3; r++) { for (c = 0; c < 3; c++) { for (k = 0; k < 2; k++) { m4[c][r] += m1[k][r] * m2[c][k]; } } } GLM(mat2x3_mul)(m1, m2, m3); ASSERTIFY(test_assert_mat3_eq(m3, m4)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, mat2x3_mulv) { mat2x3 mat = A_MATRIX2X3; vec2 v = {11.0f, 21.0f}; int i; vec3 dest; float res = 0.0; GLM(mat2x3_mulv)(mat, v, dest); for (i = 0; i < 3; i++) { res = mat[0][i] * v[0] + mat[1][i] * v[1]; ASSERT(test_eq(dest[i], res)) } TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, mat2x3_transpose) { mat2x3 m1 = A_MATRIX2X3; mat3x2 m2; mat3x2 m3 = A_MATRIX2X3_TRANSPOSE; GLM(mat2x3_transpose)(m1, m2); ASSERTIFY(test_assert_mat3x2_eq(m2, m3)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, mat2x3_scale) { mat2x3 m1 = A_MATRIX2X3; mat2x3 m2 = A_MATRIX2X3; int i, j, scale; scale = rand() % 100; GLM(mat2x3_scale)(m1, (float) scale); for (i = 0; i < 2; i++) { for (j = 0; j < 3; j++) { ASSERT(test_eq(m1[i][j], m2[i][j] * scale)) } } TEST_SUCCESS } cglm-0.9.6/test/src/test_mat2x4.h000066400000000000000000000063621475344456400165740ustar00rootroot00000000000000 /* * 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" #define A_MATRIX2X4 {{1,2,3,4},{5,6,7,8}} #define A_MATRIX2X4_TRANSPOSE {{1,5}, {2,6}, {3,7}, {4,8}} #ifndef CGLM_TEST_MAT2X4_ONCE #define CGLM_TEST_MAT2X4_ONCE TEST_IMPL(MACRO_GLM_MAT2X4_ZERO_INIT) { mat2x4 mat2x4_zero = GLM_MAT2X4_ZERO_INIT; test_assert_mat2x4_eq_zero(mat2x4_zero); TEST_SUCCESS } TEST_IMPL(MACRO_GLM_MAT2X4_ZERO) { mat2x4 mat2x4_zero = GLM_MAT2X4_ZERO; test_assert_mat2x4_eq_zero(mat2x4_zero); TEST_SUCCESS } #endif /* CGLM_TEST_MAT2X4_ONCE */ TEST_IMPL(GLM_PREFIX, mat2x4_copy) { mat2x4 m1 = A_MATRIX2X4; mat2x4 m2 = GLM_MAT2X4_ZERO_INIT; GLM(mat2x4_copy)(m1, m2); test_assert_mat2x4_eq(m1, m2); TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, mat2x4_zero) { mat2x4 m1 = GLM_MAT2X4_ZERO_INIT; mat2x4 m2 = GLM_MAT2X4_ZERO_INIT; mat2x4 m3; GLM(mat2x4_zero)(m3); ASSERTIFY(test_assert_mat2x4_eq_zero(m1)) ASSERTIFY(test_assert_mat2x4_eq_zero(m2)) ASSERTIFY(test_assert_mat2x4_eq_zero(m3)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, mat2x4_make) { float src[24] = { 0.5f, 1.7f, 10.3f, 4.2f, 8.9f, 1.1f, 77.3f, 88.4f, 2.3f, 4.2f, 66.5f, 23.7f, 6.6f, 8.9f, 90.3f, 34.2f, 5.3f, 4.8f, 96.3f, 13.7f, 4.7f, 5.5f, 22.9f, 5.5f }; mat2x4 dest[3]; float *srcp = src; unsigned int i, j, k; for (i = 0, j = 0, k = 0; i < sizeof(src) / sizeof(float); i+=8,j++) { GLM(mat2x4_make)(srcp + i, dest[j]); ASSERT(test_eq(src[ i ], dest[j][k][0])); ASSERT(test_eq(src[i+1], dest[j][k][1])); ASSERT(test_eq(src[i+2], dest[j][k][2])); ASSERT(test_eq(src[i+3], dest[j][k][3])); ASSERT(test_eq(src[i+4], dest[j][k+1][0])); ASSERT(test_eq(src[i+5], dest[j][k+1][1])); ASSERT(test_eq(src[i+6], dest[j][k+1][2])); ASSERT(test_eq(src[i+7], dest[j][k+1][3])); } TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, mat2x4_mul) { mat2x4 m1 = GLM_MAT2X4_ZERO_INIT; mat4x2 m2 = GLM_MAT4X2_ZERO_INIT; mat4 m3 = GLM_MAT4_ZERO_INIT; mat4 m4 = GLM_MAT4_ZERO_INIT; int c, r, k; /* test random matrices */ /* random matrices */ test_rand_mat2x4(m1); test_rand_mat4x2(m2); for (r = 0; r < 4; r++) { for (c = 0; c < 4; c++) { for (k = 0; k < 2; k++) { m4[c][r] += m1[k][r] * m2[c][k]; } } } GLM(mat2x4_mul)(m1, m2, m3); ASSERTIFY(test_assert_mat4_eq(m3, m4)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, mat2x4_mulv) { mat2x4 mat = A_MATRIX2X4; vec2 v = {11.0f, 21.0f}; int i; vec4 dest; float res = 0.0; GLM(mat2x4_mulv)(mat, v, dest); for (i = 0; i < 4; i++) { res = mat[0][i] * v[0] + mat[1][i] * v[1]; ASSERT(test_eq(dest[i], res)) } TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, mat2x4_transpose) { mat2x4 m1 = A_MATRIX2X4; mat4x2 m2; mat4x2 m3 = A_MATRIX2X4_TRANSPOSE; GLM(mat2x4_transpose)(m1, m2); ASSERTIFY(test_assert_mat4x2_eq(m2, m3)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, mat2x4_scale) { mat2x4 m1 = A_MATRIX2X4; mat2x4 m2 = A_MATRIX2X4; int i, j, scale; scale = rand() % 100; GLM(mat2x4_scale)(m1, (float) scale); for (i = 0; i < 2; i++) { for (j = 0; j < 4; j++) { ASSERT(test_eq(m1[i][j], m2[i][j] * scale)) } } TEST_SUCCESS } cglm-0.9.6/test/src/test_mat3.h000066400000000000000000000145351475344456400163220ustar00rootroot00000000000000/* * 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" #define A_MATRIX {{1,2,3},{5,6,7},{9,10,11}} #define MAT3_ARRAY {1, 5, 2, 7, 12, 1, 4, 6, 0} TEST_IMPL(GLM_PREFIX, mat3_copy) { mat3 m1 = A_MATRIX; mat3 m2 = GLM_MAT3_IDENTITY_INIT; GLM(mat3_copy)(m1, m2); test_assert_mat3_eq(m1, m2); TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, mat3_identity) { mat3 m1 = GLM_MAT3_IDENTITY_INIT; mat3 m2 = GLM_MAT3_IDENTITY_INIT; mat3 m3; GLM(mat3_identity)(m3); ASSERTIFY(test_assert_mat3_eq_identity(m1)) ASSERTIFY(test_assert_mat3_eq_identity(m2)) ASSERTIFY(test_assert_mat3_eq_identity(m3)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, mat3_identity_array) { size_t i, count; mat3 matrices[4] = { A_MATRIX, A_MATRIX, A_MATRIX, A_MATRIX }; count = 4; GLM(mat3_identity_array)(matrices, count); for (i = 0; i < count; i++) { ASSERTIFY(test_assert_mat3_eq_identity(matrices[i])) } TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, mat3_zero) { mat3 m1 = GLM_MAT3_ZERO_INIT; mat3 m2 = GLM_MAT3_ZERO_INIT; mat3 m3; GLM(mat3_zero)(m3); ASSERTIFY(test_assert_mat3_eq_zero(m1)) ASSERTIFY(test_assert_mat3_eq_zero(m2)) ASSERTIFY(test_assert_mat3_eq_zero(m3)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, mat3_mul) { mat3 m1 = GLM_MAT3_IDENTITY_INIT; mat3 m2 = GLM_MAT3_IDENTITY_INIT; mat3 m3; mat3 m4 = GLM_MAT3_ZERO_INIT; int i, j, k; /* test random matrices */ /* random matrices */ test_rand_mat3(m1); test_rand_mat3(m2); GLM(mat3_mul)(m1, m2, m3); for (i = 0; i < 3; i++) { for (j = 0; j < 3; j++) { for (k = 0; k < 3; k++) /* column-major */ m4[i][j] += m1[k][j] * m2[i][k]; } } ASSERTIFY(test_assert_mat3_eq(m3, m4)) /* test pre compiled */ GLM(mat3_mul)(m1, m2, m3); ASSERTIFY(test_assert_mat3_eq(m3, m4)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, mat3_mulv) { vec4 res; mat3 mat = A_MATRIX; vec4 v = {1.0f, 2.0f, 3.0f, 4.0f}; int i; GLM(mat3_mulv)(mat, v, res); for (i = 0; i < 3; i++) { ASSERT(test_eq(res[i], v[0] * mat[0][i] + v[1] * mat[1][i] + v[2] * mat[2][i])) } TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, mat3_trace) { mat3 mat = A_MATRIX; float trace; trace = GLM(mat3_trace)(mat); ASSERT(test_eq(trace, mat[0][0] + mat[1][1] + mat[2][2])) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, mat3_quat) { mat3 m1, m3; mat4 m2; versor q1, q2, q3; vec3 axis1; vec3 axis2 = {1.9f, 2.3f, 4.5f}; GLM(quat)(q1, GLM_PI_4f, 1.9f, 2.3f, 4.5f); GLM(quat_mat3)(q1, m1); GLM(mat3_quat)(m1, q2); GLM(rotate_make)(m2, GLM_PI_4f, axis2); GLM(mat3_quat)(m1, q3); GLM(quat_axis)(q3, axis1); GLM(vec3_normalize)(axis1); GLM(vec3_normalize)(axis2); GLM(mat4_pick3)(m2, m3); ASSERT(test_eq(glm_quat_angle(q3), GLM_PI_4f)) ASSERTIFY(test_assert_vec3_eq(axis1, axis2)) ASSERTIFY(test_assert_vec4_eq(q1, q2)) ASSERTIFY(test_assert_mat3_eq(m1, m3)) ASSERTIFY(test_assert_vec4_eq(q1, q3)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, mat3_transpose_to) { mat3 mat = A_MATRIX; mat3 m1; GLM(mat3_transpose_to)(mat, m1); ASSERTIFY(test_assert_mat3_eqt(mat, m1)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, mat3_transpose) { mat3 mat = A_MATRIX; mat3 m1; GLM(mat3_copy)(mat, m1); GLM(mat3_transpose)(m1); ASSERTIFY(test_assert_mat3_eqt(mat, m1)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, mat3_scale) { mat3 m1 = A_MATRIX; mat3 m2 = A_MATRIX; int i, j, k, scale; scale = rand() % 100; GLM(mat3_scale)(m1, (float)scale); for (i = 0; i < 3; i++) { for (j = 0; j < 3; j++) { for (k = 0; k < 3; k++) ASSERT(test_eq(m1[i][j], m2[i][j] * scale)) } } TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, mat3_det) { mat3 mat; float a, b, c, d, e, f, g, h, i; float det1, det2; test_rand_mat3(mat); a = mat[0][0]; b = mat[0][1]; c = mat[0][2]; d = mat[1][0]; e = mat[1][1]; f = mat[1][2]; g = mat[2][0]; h = mat[2][1]; i = mat[2][2]; det1 = a * (e * i - h * f) - d * (b * i - c * h) + g * (b * f - c * e); det2 = GLM(mat3_det)(mat); ASSERT(test_eq(det1, det2)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, mat3_inv) { mat3 m1 = GLM_MAT3_IDENTITY_INIT; mat3 m2 = GLM_MAT3_IDENTITY_INIT; mat3 m3; int i; for (i = 0; i < 100000; i++) { test_rand_mat3(m1); test_rand_mat3(m2); /* test inverse precise */ GLM(mat3_inv)(m1, m2); GLM(mat3_inv)(m2, m3); ASSERTIFY(test_assert_mat3_eq(m1, m3)) } TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, mat3_swap_col) { mat3 m1 = A_MATRIX; mat3 m2 = A_MATRIX; GLM(mat3_swap_col)(m1, 0, 1); ASSERTIFY(test_assert_vec3_eq(m1[0], m2[1])) ASSERTIFY(test_assert_vec3_eq(m1[1], m2[0])) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, mat3_swap_row) { mat3 m1 = A_MATRIX; mat3 m2 = A_MATRIX; GLM(mat3_swap_row)(m1, 0, 1); ASSERT(test_eq(m1[0][0], m2[0][1])) ASSERT(test_eq(m1[0][1], m2[0][0])) ASSERT(test_eq(m1[0][2], m2[0][2])) ASSERT(test_eq(m1[1][0], m2[1][1])) ASSERT(test_eq(m1[1][1], m2[1][0])) ASSERT(test_eq(m1[1][2], m2[1][2])) ASSERT(test_eq(m1[2][0], m2[2][1])) ASSERT(test_eq(m1[2][1], m2[2][0])) ASSERT(test_eq(m1[2][2], m2[2][2])) GLM(mat3_swap_row)(m1, 1, 2); ASSERT(test_eq(m1[0][0], m2[0][1])) ASSERT(test_eq(m1[0][1], m2[0][2])) ASSERT(test_eq(m1[0][2], m2[0][0])) ASSERT(test_eq(m1[1][0], m2[1][1])) ASSERT(test_eq(m1[1][1], m2[1][2])) ASSERT(test_eq(m1[1][2], m2[1][0])) ASSERT(test_eq(m1[2][0], m2[2][1])) ASSERT(test_eq(m1[2][1], m2[2][2])) ASSERT(test_eq(m1[2][2], m2[2][0])) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, mat3_rmc) { mat3 mat = A_MATRIX; vec3 v = {11.0f, 12.0f, 13.0f}; vec3 v1; float r1, r2; int i; r1 = GLM(mat3_rmc)(v, mat, v); for (i = 0; i < 3; i++) { v1[i] = v[0] * mat[i][0] + v[1] * mat[i][1] + v[2] * mat[i][2]; } r2 = v[0] * v1[0] + v[1] * v1[1] + v[2] * v1[2]; ASSERT(test_eq(r1, r2)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, mat3_make) { mat3 dest; unsigned int i, j; float src[9] = MAT3_ARRAY; GLM(mat3_make)(src, dest); for (i = 0, j = 0; i < sizeof(src) / sizeof(float); i+=3, j++) { ASSERT(test_eq(dest[j][0], src[i])) ASSERT(test_eq(dest[j][1], src[i+1])) ASSERT(test_eq(dest[j][2], src[i+2])) } TEST_SUCCESS } #undef A_MATRIX cglm-0.9.6/test/src/test_mat3x2.h000066400000000000000000000061061475344456400165670ustar00rootroot00000000000000/* * 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" #define A_MATRIX3X2 {{1,2},{5,6},{3,7}} #define A_MATRIX3X2_TRANSPOSE {{1,5,3}, {2,6,7}} #ifndef CGLM_TEST_MAT3X2_ONCE #define CGLM_TEST_MAT3X2_ONCE TEST_IMPL(MACRO_GLM_MAT3X2_ZERO_INIT) { mat3x2 mat3x2_zero = GLM_MAT3X2_ZERO_INIT; test_assert_mat3x2_eq_zero(mat3x2_zero); TEST_SUCCESS } TEST_IMPL(MACRO_GLM_MAT3X2_ZERO) { mat3x2 mat3x2_zero = GLM_MAT3X2_ZERO; test_assert_mat3x2_eq_zero(mat3x2_zero); TEST_SUCCESS } #endif /* CGLM_TEST_MAT3X2_ONCE */ TEST_IMPL(GLM_PREFIX, mat3x2_copy) { mat3x2 m1 = A_MATRIX3X2; mat3x2 m2 = GLM_MAT3X2_ZERO_INIT; GLM(mat3x2_copy)(m1, m2); test_assert_mat3x2_eq(m1, m2); TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, mat3x2_zero) { mat3x2 m1 = GLM_MAT3X2_ZERO_INIT; mat3x2 m2 = GLM_MAT3X2_ZERO_INIT; mat3x2 m3; GLM(mat3x2_zero)(m3); ASSERTIFY(test_assert_mat3x2_eq_zero(m1)) ASSERTIFY(test_assert_mat3x2_eq_zero(m2)) ASSERTIFY(test_assert_mat3x2_eq_zero(m3)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, mat3x2_make) { float src[18] = { 0.5f, 1.7f, 10.3f, 4.2f, 8.9f, 1.1f, 2.3f, 4.2f, 66.5f, 23.7f, 6.6f, 8.9f, 5.3f, 4.8f, 96.3f, 13.7f, 4.7f, 5.5f }; mat3x2 dest[3]; float *srcp = src; unsigned int i, j, k; for (i = 0, j = 0, k = 0; i < sizeof(src) / sizeof(float); i+=6,j++) { GLM(mat3x2_make)(srcp + i, dest[j]); ASSERT(test_eq(src[ i ], dest[j][k][0])); ASSERT(test_eq(src[i+1], dest[j][k][1])); ASSERT(test_eq(src[i+2], dest[j][k+1][0])); ASSERT(test_eq(src[i+3], dest[j][k+1][1])); ASSERT(test_eq(src[i+4], dest[j][k+2][0])); ASSERT(test_eq(src[i+5], dest[j][k+2][1])); } TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, mat3x2_mul) { mat3x2 m1 = GLM_MAT3X2_ZERO_INIT; mat2x3 m2 = GLM_MAT2X3_ZERO_INIT; mat2 m3 = GLM_MAT2_ZERO_INIT; mat2 m4 = GLM_MAT2_ZERO_INIT; int c, r, k; test_rand_mat3x2(m1); test_rand_mat2x3(m2); for (r = 0; r < 2; r++) { for (c = 0; c < 2; c++) { for (k = 0; k < 3; k++) { m4[c][r] += m1[k][r] * m2[c][k]; } } } GLM(mat3x2_mul)(m1, m2, m3); ASSERTIFY(test_assert_mat2_eq(m3, m4)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, mat3x2_mulv) { mat3x2 mat = A_MATRIX3X2; vec3 v = {11.0f, 21.0f, 31.0f}; int i; vec2 dest; float res = 0.0; GLM(mat3x2_mulv)(mat, v, dest); for (i = 0; i < 2; i++) { res = mat[0][i] * v[0] + mat[1][i] * v[1] + mat[2][i] * v[2]; ASSERT(test_eq(dest[i], res)) } TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, mat3x2_transpose) { mat3x2 m1 = A_MATRIX3X2; mat2x3 m2; mat2x3 m3 = A_MATRIX3X2_TRANSPOSE; GLM(mat3x2_transpose)(m1, m2); ASSERTIFY(test_assert_mat2x3_eq(m2, m3)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, mat3x2_scale) { mat3x2 m1 = A_MATRIX3X2; mat3x2 m2 = A_MATRIX3X2; int i, j, scale; scale = rand() % 100; GLM(mat3x2_scale)(m1, (float) scale); for (i = 0; i < 3; i++) { for (j = 0; j < 2; j++) { ASSERT(test_eq(m1[i][j], m2[i][j] * scale)) } } TEST_SUCCESS } cglm-0.9.6/test/src/test_mat3x4.h000066400000000000000000000067731475344456400166030ustar00rootroot00000000000000/* * 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" #define A_MATRIX3X4 {{1,2,4,5},{6,7,8,9},{10,11,12,13}} #define A_MATRIX3X4_TRANSPOSE {{1,6,10}, {2,7,1}, {4,8,12}, {5,9,13}} #ifndef CGLM_TEST_MAT3X4_ONCE #define CGLM_TEST_MAT3X4_ONCE TEST_IMPL(MACRO_GLM_MAT3X4_ZERO_INIT) { mat3x4 mat3x4_zero = GLM_MAT3X4_ZERO_INIT; test_assert_mat3x4_eq_zero(mat3x4_zero); TEST_SUCCESS } TEST_IMPL(MACRO_GLM_MAT3X4_ZERO) { mat3x4 mat3x4_zero = GLM_MAT3X4_ZERO; test_assert_mat3x4_eq_zero(mat3x4_zero); TEST_SUCCESS } #endif /* CGLM_TEST_MAT3X4_ONCE */ TEST_IMPL(GLM_PREFIX, mat3x4_copy) { mat3x4 m1 = A_MATRIX3X4; mat3x4 m2 = GLM_MAT3X4_ZERO_INIT; GLM(mat3x4_copy)(m1, m2); test_assert_mat3x4_eq(m1, m2); TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, mat3x4_zero) { mat3x4 m1 = GLM_MAT3X4_ZERO_INIT; mat3x4 m2 = GLM_MAT3X4_ZERO_INIT; mat3x4 m3; GLM(mat3x4_zero)(m3); ASSERTIFY(test_assert_mat3x4_eq_zero(m1)) ASSERTIFY(test_assert_mat3x4_eq_zero(m2)) ASSERTIFY(test_assert_mat3x4_eq_zero(m3)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, mat3x4_make) { float src[36] = { 0.5f, 1.7f, 10.3f, 4.2f, 8.9f, 1.1f, 2.3f, 4.2f, 66.5f, 23.7f, 6.6f, 8.9f, 2.3f, 4.2f, 66.5f, 23.7f, 6.6f, 8.9f, 0.5f, 1.7f, 10.3f, 4.2f, 8.9f, 1.1f, 5.3f, 4.8f, 96.3f, 13.7f, 4.7f, 5.5f, 2.3f, 4.2f, 66.5f, 23.7f, 6.6f, 8.9f }; mat3x4 dest[3]; float *srcp = src; unsigned int i, j, k; for (i = 0, j = 0, k = 0; i < sizeof(src) / sizeof(float); i+=12,j++) { GLM(mat3x4_make)(srcp + i, dest[j]); ASSERT(test_eq(src[ i ], dest[j][k][0])); ASSERT(test_eq(src[i+1], dest[j][k][1])); ASSERT(test_eq(src[i+2], dest[j][k][2])); ASSERT(test_eq(src[i+3], dest[j][k][3])); ASSERT(test_eq(src[i+4], dest[j][k+1][0])); ASSERT(test_eq(src[i+5], dest[j][k+1][1])); ASSERT(test_eq(src[i+6], dest[j][k+1][2])); ASSERT(test_eq(src[i+7], dest[j][k+1][3])); ASSERT(test_eq(src[i+8], dest[j][k+2][0])); ASSERT(test_eq(src[i+9], dest[j][k+2][1])); ASSERT(test_eq(src[i+10], dest[j][k+2][2])); ASSERT(test_eq(src[i+11], dest[j][k+2][3])); } TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, mat3x4_mul) { mat3x4 m1 = GLM_MAT3X4_ZERO_INIT; mat4x3 m2 = GLM_MAT4X3_ZERO_INIT; mat4 m3 = GLM_MAT4_ZERO_INIT; mat4 m4 = GLM_MAT4_ZERO_INIT; int c, r, k; test_rand_mat3x4(m1); test_rand_mat4x3(m2); for (r = 0; r < 4; r++) { for (c = 0; c < 4; c++) { for (k = 0; k < 3; k++) { m4[c][r] += m1[k][r] * m2[c][k]; } } } GLM(mat3x4_mul)(m1, m2, m3); ASSERTIFY(test_assert_mat4_eq(m3, m4)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, mat3x4_mulv) { mat3x4 mat = A_MATRIX3X4; vec4 v = {11.0f, 21.0f, 31.0f}; int i; vec4 dest; float res = 0.0; GLM(mat3x4_mulv)(mat, v, dest); for (i = 0; i < 4; i++) { res = mat[0][i] * v[0] + mat[1][i] * v[1] + mat[2][i] * v[2]; ASSERT(test_eq(dest[i], res)) } TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, mat3x4_transpose) { mat3x4 m1 = A_MATRIX3X4; mat4x3 m2; mat4x3 m3 = A_MATRIX3X2_TRANSPOSE; GLM(mat3x4_transpose)(m1, m2); ASSERTIFY(test_assert_mat4x3_eq(m2, m3)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, mat3x4_scale) { mat3x4 m1 = A_MATRIX3X4; mat3x4 m2 = A_MATRIX3X4; int i, j, scale; scale = rand() % 100; GLM(mat3x4_scale)(m1, (float) scale); for (i = 0; i < 3; i++) { for (j = 0; j < 4; j++) { ASSERT(test_eq(m1[i][j], m2[i][j] * scale)) } } TEST_SUCCESS } cglm-0.9.6/test/src/test_mat4.h000066400000000000000000000240341475344456400163160ustar00rootroot00000000000000/* * 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" #define A_MATRIX {{1,2,3,4},{5,6,7,8},{9,10,11,12},{13,14,15,16}} #define A_MATRIX3 {{1,2,3},{5,6,7},{9,10,11}} #define MAT4_ARRAY {1, 5, 2, 7, 12, 1, 4, 6, 0, 8, 1, 0, 6, 5, 0, 1} TEST_IMPL(GLM_PREFIX, mat4_ucopy) { mat4 m1 = A_MATRIX; mat4 m2 = GLM_MAT4_IDENTITY_INIT; GLM(mat4_ucopy)(m1, m2); ASSERTIFY(test_assert_mat4_eq(m1, m2)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, mat4_copy) { mat4 m1 = A_MATRIX; mat4 m2 = GLM_MAT4_IDENTITY_INIT; GLM(mat4_copy)(m1, m2); test_assert_mat4_eq(m1, m2); TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, mat4_identity) { mat4 m1 = GLM_MAT4_IDENTITY_INIT; mat4 m2 = GLM_MAT4_IDENTITY_INIT; mat4 m3; GLM(mat4_identity)(m3); ASSERTIFY(test_assert_mat4_eq_identity(m1)) ASSERTIFY(test_assert_mat4_eq_identity(m2)) ASSERTIFY(test_assert_mat4_eq_identity(m3)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, mat4_identity_array) { size_t i, count; mat4 matrices[4] = { A_MATRIX, A_MATRIX, A_MATRIX, A_MATRIX }; count = 4; GLM(mat4_identity_array)(matrices, count); for (i = 0; i < count; i++) { ASSERTIFY(test_assert_mat4_eq_identity(matrices[i])) } TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, mat4_zero) { mat4 m1 = GLM_MAT4_ZERO_INIT; mat4 m2 = GLM_MAT4_ZERO_INIT; mat4 m3; GLM(mat4_zero)(m3); ASSERTIFY(test_assert_mat4_eq_zero(m1)) ASSERTIFY(test_assert_mat4_eq_zero(m2)) ASSERTIFY(test_assert_mat4_eq_zero(m3)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, mat4_pick3) { mat4 m1 = A_MATRIX; mat3 m2 = GLM_MAT3_ZERO_INIT; mat3 m3 = A_MATRIX3; GLM(mat4_pick3)(m1, m2); ASSERTIFY(test_assert_mat3_eq(m2, m3)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, mat4_pick3t) { mat4 m1 = A_MATRIX; mat3 m2 = GLM_MAT3_ZERO_INIT; mat3 m3 = A_MATRIX3; GLM(mat4_pick3t)(m1, m2); ASSERTIFY(test_assert_mat3_eqt(m2, m3)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, mat4_ins3) { mat4 m1 = GLM_MAT4_IDENTITY_INIT; mat3 m2 = A_MATRIX3; int i, j; GLM(mat4_ins3)(m2, m1); for (i = 0; i < 3; i++) { for (j = 0; j < 3; j++) { ASSERT(m1[i][j] == m2[i][j]) } } ASSERT(test_eq(m1[3][0], 0.0f)) ASSERT(test_eq(m1[3][1], 0.0f)) ASSERT(test_eq(m1[3][2], 0.0f)) ASSERT(test_eq(m1[3][3], 1.0f)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, mat4_mul) { mat4 m1 = GLM_MAT4_IDENTITY_INIT; mat4 m2 = GLM_MAT4_IDENTITY_INIT; mat4 m3; mat4 m4 = GLM_MAT4_ZERO_INIT; int i, j, k; /* test random matrices */ /* random matrices */ test_rand_mat4(m1); test_rand_mat4(m2); GLM(mat4_mul)(m1, m2, m3); for (i = 0; i < 4; i++) { for (j = 0; j < 4; j++) { for (k = 0; k < 4; k++) /* column-major */ m4[i][j] += m1[k][j] * m2[i][k]; } } ASSERTIFY(test_assert_mat4_eq(m3, m4)) /* test pre compiled */ GLM(mat4_mul)(m1, m2, m3); ASSERTIFY(test_assert_mat4_eq(m3, m4)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, mat4_mulN) { mat4 res1, res2; mat4 m1 = A_MATRIX; mat4 m2 = A_MATRIX; mat4 m3 = A_MATRIX; mat4 *matrices[] = { &m1, &m2, &m3 }; GLM(mat4_mulN)(matrices, sizeof(matrices) / sizeof(matrices[0]), res1); GLM(mat4_mul)(*matrices[0], *matrices[1], res2); GLM(mat4_mul)(res2, *matrices[2], res2); ASSERTIFY(test_assert_mat4_eq(res1, res1)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, mat4_mulv) { vec4 res; mat4 mat = A_MATRIX; vec4 v = {1.0f, 2.0f, 3.0f, 4.0f}; int i; GLM(mat4_mulv)(mat, v, res); for (i = 0; i < 4; i++) { ASSERT(test_eq(res[i], v[0] * mat[0][i] + v[1] * mat[1][i] + v[2] * mat[2][i] + v[3] * mat[3][i])) } TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, mat4_mulv3) { vec4 res; mat4 mat = A_MATRIX; vec3 v = {1.0f, 2.0f, 3.0f}; float last; int i; last = 1.0f; GLM(mat4_mulv3)(mat, v, last, res); for (i = 0; i < 3; i++) { ASSERT(test_eq(res[i], v[0] * mat[0][i] + v[1] * mat[1][i] + v[2] * mat[2][i] + last * mat[3][i])) } TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, mat4_trace) { mat4 mat = A_MATRIX; float trace; trace = GLM(mat4_trace)(mat); ASSERT(test_eq(trace, mat[0][0] + mat[1][1] + mat[2][2] + mat[3][3])) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, mat4_trace3) { mat4 mat = A_MATRIX; float trace; trace = GLM(mat4_trace3)(mat); ASSERT(test_eq(trace, mat[0][0] + mat[1][1] + mat[2][2])) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, mat4_quat) { mat4 m1, m2; versor q1, q2, q3; vec3 axis1; vec3 axis2 = {1.9f, 2.3f, 4.5f}; GLM(quat)(q1, GLM_PI_4f, 1.9f, 2.3f, 4.5f); GLM(quat_mat4)(q1, m1); GLM(mat4_quat)(m1, q2); GLM(rotate_make)(m2, GLM_PI_4f, axis2); GLM(mat4_quat)(m1, q3); GLM(quat_axis)(q3, axis1); GLM(vec3_normalize)(axis1); GLM(vec3_normalize)(axis2); ASSERT(test_eq(glm_quat_angle(q3), GLM_PI_4f)) ASSERTIFY(test_assert_vec3_eq(axis1, axis2)) ASSERTIFY(test_assert_vec4_eq(q1, q2)) ASSERTIFY(test_assert_mat4_eq(m1, m2)) ASSERTIFY(test_assert_vec4_eq(q1, q3)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, mat4_transpose_to) { mat4 mat = A_MATRIX; mat4 m1; GLM(mat4_transpose_to)(mat, m1); ASSERTIFY(test_assert_mat4_eqt(mat, m1)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, mat4_transpose) { mat4 mat = A_MATRIX; mat4 m1; GLM(mat4_copy)(mat, m1); GLM(mat4_transpose)(m1); ASSERTIFY(test_assert_mat4_eqt(mat, m1)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, mat4_scale_p) { mat4 m1 = A_MATRIX; mat4 m2 = A_MATRIX; int i, j, k, scale; scale = rand() % 100; GLM(mat4_scale_p)(m1, (float)scale); for (i = 0; i < 4; i++) { for (j = 0; j < 4; j++) { for (k = 0; k < 4; k++) ASSERT(test_eq(m1[i][j], m2[i][j] * scale)) } } TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, mat4_scale) { mat4 m1 = A_MATRIX; mat4 m2 = A_MATRIX; int i, j, k, scale; scale = rand() % 100; GLM(mat4_scale)(m1, (float)scale); for (i = 0; i < 4; i++) { for (j = 0; j < 4; j++) { for (k = 0; k < 4; k++) ASSERT(test_eq(m1[i][j], m2[i][j] * scale)) } } TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, mat4_det) { mat4 mat = GLM_MAT4_IDENTITY_INIT; float t[6]; float a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p; float det1, det2; test_rand_mat4(mat); a = mat[0][0]; b = mat[0][1]; c = mat[0][2]; d = mat[0][3]; e = mat[1][0]; f = mat[1][1]; g = mat[1][2]; h = mat[1][3]; i = mat[2][0]; j = mat[2][1]; k = mat[2][2]; l = mat[2][3]; m = mat[3][0]; n = mat[3][1]; o = mat[3][2]; p = mat[3][3]; t[0] = k * p - o * l; t[1] = j * p - n * l; t[2] = j * o - n * k; t[3] = i * p - m * l; t[4] = i * o - m * k; t[5] = i * n - m * j; det1 = a * (f * t[0] - g * t[1] + h * t[2]) - b * (e * t[0] - g * t[3] + h * t[4]) + c * (e * t[1] - f * t[3] + h * t[5]) - d * (e * t[2] - f * t[4] + g * t[5]); det2 = GLM(mat4_det(mat)); ASSERT(test_eq(det1, det2)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, mat4_inv) { mat4 m1, m2, m3; int i; for (i = 0; i < 100000; i++) { test_rand_mat4(m1); test_rand_mat4(m2); /* test inverse precise */ GLM(mat4_inv)(m1, m2); GLM(mat4_inv)(m2, m3); ASSERTIFY(test_assert_mat4_eq(m1, m3)) } TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, mat4_inv_precise) { mat4 m1, m2, m3; mat4 m4, m5, m6; int i; for (i = 0; i < 100000; i++) { test_rand_mat4(m1); test_rand_mat4(m2); glm_mat4_inv_precise(m1, m2); glm_mat4_inv_precise(m2, m3); ASSERTIFY(test_assert_mat4_eq(m1, m3)) test_rand_mat4(m4); test_rand_mat4(m5); glmc_mat4_inv_precise(m4, m5); glmc_mat4_inv_precise(m5, m6); ASSERTIFY(test_assert_mat4_eq(m4, m6)) } TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, mat4_inv_fast) { mat4 m1, m2, m3; int i; for (i = 0; i < 100000; i++) { test_rand_mat4(m1); test_rand_mat4(m2); /* test inverse precise */ GLM(mat4_inv_fast)(m1, m2); GLM(mat4_inv_fast)(m2, m3); ASSERTIFY(test_assert_mat4_eq2(m1, m3, 0.0009f)) } TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, mat4_swap_col) { mat4 m1 = A_MATRIX; mat4 m2 = A_MATRIX; GLM(mat4_swap_col)(m1, 0, 1); GLM(mat4_swap_col)(m1, 2, 3); ASSERTIFY(test_assert_vec4_eq(m1[0], m2[1])) ASSERTIFY(test_assert_vec4_eq(m1[1], m2[0])) ASSERTIFY(test_assert_vec4_eq(m1[2], m2[3])) ASSERTIFY(test_assert_vec4_eq(m1[3], m2[2])) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, mat4_swap_row) { mat4 m1 = A_MATRIX; mat4 m2 = A_MATRIX; GLM(mat4_swap_row)(m1, 0, 1); GLM(mat4_swap_row)(m1, 2, 3); ASSERT(test_eq(m1[0][0], m2[0][1])) ASSERT(test_eq(m1[0][1], m2[0][0])) ASSERT(test_eq(m1[0][2], m2[0][3])) ASSERT(test_eq(m1[0][3], m2[0][2])) ASSERT(test_eq(m1[1][0], m2[1][1])) ASSERT(test_eq(m1[1][1], m2[1][0])) ASSERT(test_eq(m1[1][2], m2[1][3])) ASSERT(test_eq(m1[1][3], m2[1][2])) ASSERT(test_eq(m1[2][0], m2[2][1])) ASSERT(test_eq(m1[2][1], m2[2][0])) ASSERT(test_eq(m1[2][2], m2[2][3])) ASSERT(test_eq(m1[2][3], m2[2][2])) ASSERT(test_eq(m1[3][0], m2[3][1])) ASSERT(test_eq(m1[3][1], m2[3][0])) ASSERT(test_eq(m1[3][2], m2[3][3])) ASSERT(test_eq(m1[3][3], m2[3][2])) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, mat4_rmc) { mat4 mat = A_MATRIX; vec4 v = {1.0f, 2.0f, 3.0f, 4.0f}; vec4 v1; float r1, r2; int i; r1 = GLM(mat4_rmc)(v, mat, v); for (i = 0; i < 4; i++) { v1[i] = v[0] * mat[i][0] + v[1] * mat[i][1] + v[2] * mat[i][2] + v[3] * mat[i][3]; } r2 = v[0] * v1[0] + v[1] * v1[1] + v[2] * v1[2] + v[3] * v1[3]; ASSERT(test_eq(r1, r2)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, mat4_make) { mat4 dest; unsigned int i, j; float src[16] = MAT4_ARRAY; GLM(mat4_make)(src, dest); for (i = 0, j = 0; i < sizeof(src) / sizeof(float); i+=4, j++) { ASSERT(test_eq(dest[j][0], src[i])) ASSERT(test_eq(dest[j][1], src[i+1])) ASSERT(test_eq(dest[j][2], src[i+2])) ASSERT(test_eq(dest[j][3], src[i+3])) } TEST_SUCCESS } #undef A_MATRIX #undef A_MATRIX3 cglm-0.9.6/test/src/test_mat4x2.h000066400000000000000000000063501475344456400165710ustar00rootroot00000000000000/* * 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" #define A_MATRIX4X2 {{1,2},{3,4},{5,6},{7,8}} #define A_MATRIX4X2_TRANSPOSE {{1,3,5,7}, {2,4,6,8}} #ifndef CGLM_TEST_MAT4X2_ONCE #define CGLM_TEST_MAT4X2_ONCE TEST_IMPL(MACRO_GLM_MAT4X2_ZERO_INIT) { mat4x2 mat4x2_zero = GLM_MAT4X2_ZERO_INIT; test_assert_mat4x2_eq_zero(mat4x2_zero); TEST_SUCCESS } TEST_IMPL(MACRO_GLM_MAT4X2_ZERO) { mat4x2 mat4x2_zero = GLM_MAT4X2_ZERO; test_assert_mat4x2_eq_zero(mat4x2_zero); TEST_SUCCESS } #endif /* CGLM_TEST_MAT4X2_ONCE */ TEST_IMPL(GLM_PREFIX, mat4x2_copy) { mat4x2 m1 = A_MATRIX4X2; mat4x2 m2 = GLM_MAT4X2_ZERO_INIT; GLM(mat4x2_copy)(m1, m2); test_assert_mat4x2_eq(m1, m2); TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, mat4x2_zero) { mat4x2 m1 = GLM_MAT4X2_ZERO_INIT; mat4x2 m2 = GLM_MAT4X2_ZERO_INIT; mat4x2 m3; GLM(mat4x2_zero)(m3); ASSERTIFY(test_assert_mat4x2_eq_zero(m1)) ASSERTIFY(test_assert_mat4x2_eq_zero(m2)) ASSERTIFY(test_assert_mat4x2_eq_zero(m3)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, mat4x2_make) { float src[24] = { 0.5f, 1.7f, 10.3f, 4.2f, 8.9f, 1.1f, 2.3f, 4.2f, 2.3f, 4.2f, 66.5f, 23.7f, 6.6f, 8.9f, 0.5f, 1.7f, 5.3f, 4.8f, 96.3f, 13.7f, 4.7f, 5.5f, 2.3f, 4.2f }; mat4x2 dest[3]; float *srcp = src; unsigned int i, j, k; for (i = 0, j = 0, k = 0; i < sizeof(src) / sizeof(float); i+=8,j++) { GLM(mat4x2_make)(srcp + i, dest[j]); ASSERT(test_eq(src[ i ], dest[j][k][0])); ASSERT(test_eq(src[i+1], dest[j][k][1])); ASSERT(test_eq(src[i+2], dest[j][k+1][0])); ASSERT(test_eq(src[i+3], dest[j][k+1][1])); ASSERT(test_eq(src[i+4], dest[j][k+2][0])); ASSERT(test_eq(src[i+5], dest[j][k+2][1])); ASSERT(test_eq(src[i+6], dest[j][k+3][0])); ASSERT(test_eq(src[i+7], dest[j][k+3][1])); } TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, mat4x2_mul) { mat4x2 m1 = GLM_MAT4X2_ZERO_INIT; mat2x4 m2 = GLM_MAT2X4_ZERO_INIT; mat2 m3 = GLM_MAT2_ZERO_INIT; mat2 m4 = GLM_MAT2_ZERO_INIT; int c, r, k; test_rand_mat4x2(m1); test_rand_mat2x4(m2); for (r = 0; r < 2; r++) { for (c = 0; c < 2; c++) { for (k = 0; k < 4; k++) { m4[c][r] += m1[k][r] * m2[c][k]; } } } GLM(mat4x2_mul)(m1, m2, m3); ASSERTIFY(test_assert_mat2_eq(m3, m4)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, mat4x2_mulv) { mat4x2 mat = A_MATRIX4X2; vec4 v = {11.0f, 21.0f, 31.0f, 41.0f}; int i; vec2 dest; float res = 0.0; GLM(mat4x2_mulv)(mat, v, dest); for (i = 0; i < 2; i++) { res = mat[0][i] * v[0] + mat[1][i] * v[1] + mat[2][i] * v[2] + mat[3][i] * v[3]; ASSERT(test_eq(dest[i], res)) } TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, mat4x2_transpose) { mat4x2 m1 = A_MATRIX4X2; mat2x4 m2; mat2x4 m3 = A_MATRIX4X2_TRANSPOSE; GLM(mat4x2_transpose)(m1, m2); ASSERTIFY(test_assert_mat2x4_eq(m2, m3)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, mat4x2_scale) { mat4x2 m1 = A_MATRIX4X2; mat4x2 m2 = A_MATRIX4X2; int i, j, scale; scale = rand() % 100; GLM(mat4x2_scale)(m1, (float) scale); for (i = 0; i < 4; i++) { for (j = 0; j < 2; j++) { ASSERT(test_eq(m1[i][j], m2[i][j] * scale)) } } TEST_SUCCESS } cglm-0.9.6/test/src/test_mat4x3.h000066400000000000000000000070221475344456400165670ustar00rootroot00000000000000/* * 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" #define A_MATRIX4X3 {{1,2,3},{4,5,6},{7,8,9},{10,11,12}} #define A_MATRIX4X3_TRANSPOSE {{1,4,7,10},{2,5,8,11},{3,6,9,12}} #ifndef CGLM_TEST_MAT4X3_ONCE #define CGLM_TEST_MAT4X3_ONCE TEST_IMPL(MACRO_GLM_MAT4X3_ZERO_INIT) { mat4x3 mat4x3_zero = GLM_MAT4X3_ZERO_INIT; test_assert_mat4x3_eq_zero(mat4x3_zero); TEST_SUCCESS } TEST_IMPL(MACRO_GLM_MAT4X3_ZERO) { mat4x3 mat4x3_zero = GLM_MAT4X3_ZERO; test_assert_mat4x3_eq_zero(mat4x3_zero); TEST_SUCCESS } #endif /* CGLM_TEST_MAT4X3_ONCE */ TEST_IMPL(GLM_PREFIX, mat4x3_copy) { mat4x3 m1 = A_MATRIX4X3; mat4x3 m2 = GLM_MAT4X3_ZERO_INIT; GLM(mat4x3_copy)(m1, m2); test_assert_mat4x3_eq(m1, m2); TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, mat4x3_zero) { mat4x3 m1 = GLM_MAT4X3_ZERO_INIT; mat4x3 m2 = GLM_MAT4X3_ZERO_INIT; mat4x3 m3; GLM(mat4x3_zero)(m3); ASSERTIFY(test_assert_mat4x3_eq_zero(m1)) ASSERTIFY(test_assert_mat4x3_eq_zero(m2)) ASSERTIFY(test_assert_mat4x3_eq_zero(m3)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, mat4x3_make) { float src[36] = { 0.5f, 1.7f, 10.3f, 4.2f, 8.9f, 1.1f, 2.3f, 4.2f, 5.3f, 4.8f, 96.3f, 13.7f, 4.7f, 5.5f, 2.3f, 4.2f, 2.3f, 4.2f, 66.5f, 23.7f, 6.6f, 8.9f, 0.5f, 1.7f, 5.3f, 4.8f, 96.3f, 13.7f, 4.7f, 5.5f, 2.3f, 4.2f, 0.5f, 1.7f, 10.3f, 4.2f }; mat4x3 dest[3]; float *srcp = src; unsigned int i, j, k; for (i = 0, j = 0, k = 0; i < sizeof(src) / sizeof(float); i+=12,j++) { GLM(mat4x3_make)(srcp + i, dest[j]); ASSERT(test_eq(src[ i ], dest[j][k][0])); ASSERT(test_eq(src[i+1], dest[j][k][1])); ASSERT(test_eq(src[i+2], dest[j][k][2])); ASSERT(test_eq(src[i+3], dest[j][k+1][0])); ASSERT(test_eq(src[i+4], dest[j][k+1][1])); ASSERT(test_eq(src[i+5], dest[j][k+1][2])); ASSERT(test_eq(src[i+6], dest[j][k+2][0])); ASSERT(test_eq(src[i+7], dest[j][k+2][1])); ASSERT(test_eq(src[i+8], dest[j][k+2][2])); ASSERT(test_eq(src[i+9], dest[j][k+3][0])); ASSERT(test_eq(src[i+10], dest[j][k+3][1])); ASSERT(test_eq(src[i+11], dest[j][k+3][2])); } TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, mat4x3_mul) { mat4x3 m1 = GLM_MAT4X3_ZERO_INIT; mat3x4 m2 = GLM_MAT3X4_ZERO_INIT; mat3 m3 = GLM_MAT3_ZERO_INIT; mat3 m4 = GLM_MAT3_ZERO_INIT; int c, r, k; test_rand_mat4x3(m1); test_rand_mat3x4(m2); for (r = 0; r < 3; r++) { for (c = 0; c < 3; c++) { for (k = 0; k < 4; k++) { m4[c][r] += m1[k][r] * m2[c][k]; } } } GLM(mat4x3_mul)(m1, m2, m3); ASSERTIFY(test_assert_mat3_eq(m3, m4)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, mat4x3_mulv) { mat4x3 mat = A_MATRIX4X3; vec4 v = {11.0f, 21.0f, 31.0f, 41.0f}; int i; vec3 dest; float res = 0.0; GLM(mat4x3_mulv)(mat, v, dest); for (i = 0; i < 3; i++) { res = mat[0][i] * v[0] + mat[1][i] * v[1] + mat[2][i] * v[2] + mat[3][i] * v[3]; ASSERT(test_eq(dest[i], res)) } TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, mat4x3_transpose) { mat4x3 m1 = A_MATRIX4X3; mat3x4 m2; mat3x4 m3 = A_MATRIX4X3_TRANSPOSE; GLM(mat4x3_transpose)(m1, m2); ASSERTIFY(test_assert_mat3x4_eq(m2, m3)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, mat4x3_scale) { mat4x3 m1 = A_MATRIX4X3; mat4x3 m2 = A_MATRIX4X3; int i, j, scale; scale = rand() % 100; GLM(mat4x3_scale)(m1, (float) scale); for (i = 0; i < 4; i++) { for (j = 0; j < 3; j++) { ASSERT(test_eq(m1[i][j], m2[i][j] * scale)) } } TEST_SUCCESS } cglm-0.9.6/test/src/test_noise.h000066400000000000000000000045251475344456400165710ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ #include "test_common.h" TEST_IMPL(GLM_PREFIX, perlin_vec4) { vec4 p1[] = { {0.1f, 0.2f, 0.3f, 0.4f}, {0.2f, 0.3f, 0.4f, 0.5f}, {0.3f, 0.4f, 0.5f, 0.6f}, {0.4f, 0.5f, 0.6f, 0.7f}, {0.5f, 0.6f, 0.7f, 0.8f}, {0.6f, 0.7f, 0.8f, 0.9f}, {0.7f, 0.8f, 0.9f, 1.0f}, {0.8f, 0.9f, 1.0f, 1.1f}, {0.9f, 1.0f, 1.1f, 1.2f}, {1.0f, 1.1f, 1.2f, 1.3f}, }; /* expected values calculated by glm::perlin */ float e[] = { -0.5091819763183594f, -0.4375732541084290f, -0.3212279379367828f, -0.2279999703168869f, -0.1577337533235550f, -0.0445968918502331f, 0.1069696992635727f, 0.2067739963531494f, 0.2106968611478806f, 0.1397782564163208f }; for (int i = 0; i < 10; i++) { ASSERT(test_eq(GLM(perlin_vec4)(p1[i]), e[i])); } TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, perlin_vec3) { vec3 p1[] = { {0.1f, 0.2f, 0.3f}, {0.2f, 0.3f, 0.4f}, {0.3f, 0.4f, 0.5f}, {0.4f, 0.5f, 0.6f}, {0.5f, 0.6f, 0.7f}, {0.6f, 0.7f, 0.8f}, {0.7f, 0.8f, 0.9f}, {0.8f, 0.9f, 1.0f}, {0.9f, 1.0f, 1.1f}, {1.0f, 1.1f, 1.2f}, }; /* expected values calculated by glm::perlin */ float e[] = { -0.2909241318702698f, -0.4667602181434631f, -0.4679279625415802f, -0.2616460621356964f, 0.0562822706997395f, 0.3178773224353790f, 0.3981811404228210f, 0.3011017739772797f, 0.1263920217752457f, -0.0602480024099350f }; for (int i = 0; i < 10; i++) { ASSERT(test_eq(GLM(perlin_vec3)(p1[i]), e[i])); } TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, perlin_vec2) { vec2 p1[] = { {0.1f, 0.2f}, {0.2f, 0.3f}, {0.3f, 0.4f}, {0.4f, 0.5f}, {0.5f, 0.6f}, {0.6f, 0.7f}, {0.7f, 0.8f}, {0.8f, 0.9f}, {0.9f, 1.0f}, {1.0f, 1.1f}, }; /* expected values calculated by glm::perlin */ float e[] = { 0.2841092348098755f, 0.2328013032674789f, -0.0017980185803026f, -0.3300299644470215f, -0.5998955368995667f, -0.6914522647857666f, -0.5896517634391785f, -0.3778679668903351f, -0.1557840555906296f, 0.0453133136034012f }; for (int i = 0; i < 10; i++) { ASSERT(test_eq(GLM(perlin_vec2)(p1[i]), e[i])); } TEST_SUCCESS } cglm-0.9.6/test/src/test_plane.h000066400000000000000000000015751475344456400165550ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ #include "test_common.h" TEST_IMPL(GLM_PREFIX, plane_normalize) { vec4 p1 = {2.0f, -3.0f, 4.0f, 5.0f}, p2 = {2.0f, -3.0f, 4.0f, 5.0f}; float s = 1.0f; float norm; GLM(plane_normalize)(p2); norm = sqrtf(p1[0] * p1[0] + p1[1] * p1[1] + p1[2] * p1[2]); if (norm == 0.0f) { ASSERT(test_eq(p1[0], 0.0f)) ASSERT(test_eq(p1[1], 0.0f)) ASSERT(test_eq(p1[2], 0.0f)) ASSERT(test_eq(p1[3], 0.0f)) TEST_SUCCESS } norm = s / norm; ASSERT(test_eq(p1[0] * norm, p2[0])) ASSERT(test_eq(p1[1] * norm, p2[1])) ASSERT(test_eq(p1[2] * norm, p2[2])) ASSERT(test_eq(p1[3] * norm, p2[3])) glm_vec4_zero(p1); GLM(plane_normalize)(p1); ASSERTIFY(test_assert_vec4_eq(p1, GLM_VEC4_ZERO)) TEST_SUCCESS } cglm-0.9.6/test/src/test_project.h000066400000000000000000000065651475344456400171300ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ #include "test_common.h" TEST_IMPL(GLM_PREFIX, unprojecti) { mat4 model, view, proj, mvp; vec4 viewport = {0.0f, 0.0f, 800.0f, 600.0f}; vec3 pos = {13.0f, 45.0f, 0.74f}; vec3 projected, unprojected; glm_translate_make(model, (vec3){0.0f, 0.0f, -10.0f}); glm_lookat((vec3){0.0f, 0.0f, 0.0f}, pos, GLM_YUP, view); glm_perspective_default(0.5f, proj); glm_mat4_mulN((mat4 *[]){&proj, &view, &model}, 3, mvp); GLM(project)(pos, mvp, viewport, projected); glm_mat4_inv(mvp, mvp); GLM(unprojecti)(projected, mvp, viewport, unprojected); /* unprojected of projected vector must be same as original one */ /* we used 0.01 because of projection floating point errors */ #ifndef CGLM_FAST_MATH ASSERT(fabsf(pos[0] - unprojected[0]) < 0.01) ASSERT(fabsf(pos[1] - unprojected[1]) < 0.01) ASSERT(fabsf(pos[2] - unprojected[2]) < 0.01) #else ASSERT(fabsf(pos[0] - unprojected[0]) < 0.1) ASSERT(fabsf(pos[1] - unprojected[1]) < 0.1) ASSERT(fabsf(pos[2] - unprojected[2]) < 0.1) #endif TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, unproject) { mat4 model, view, proj, mvp; vec4 viewport = {0.0f, 0.0f, 800.0f, 600.0f}; vec3 pos = {13.0f, 45.0f, 0.74f}; vec3 projected, unprojected; glm_translate_make(model, (vec3){0.0f, 0.0f, -10.0f}); glm_lookat((vec3){0.0f, 0.0f, 0.0f}, pos, GLM_YUP, view); glm_perspective_default(0.5f, proj); glm_mat4_mulN((mat4 *[]){&proj, &view, &model}, 3, mvp); GLM(project)(pos, mvp, viewport, projected); GLM(unproject)(projected, mvp, viewport, unprojected); /* unprojected of projected vector must be same as original one */ /* we used 0.01 because of projection floating point errors */ #ifndef CGLM_FAST_MATH ASSERT(fabsf(pos[0] - unprojected[0]) < 0.01) ASSERT(fabsf(pos[1] - unprojected[1]) < 0.01) ASSERT(fabsf(pos[2] - unprojected[2]) < 0.01) #else ASSERT(fabsf(pos[0] - unprojected[0]) < 0.1) ASSERT(fabsf(pos[1] - unprojected[1]) < 0.1) ASSERT(fabsf(pos[2] - unprojected[2]) < 0.1) #endif TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, project) { mat4 model, view, proj, mvp; vec4 viewport = {0.0f, 0.0f, 800.0f, 600.0f}; vec3 pos = {13.0f, 45.0f, 0.74f}; vec3 projected, unprojected; glm_translate_make(model, (vec3){0.0f, 0.0f, -10.0f}); glm_lookat((vec3){0.0f, 0.0f, 0.0f}, pos, GLM_YUP, view); glm_perspective_default(0.5f, proj); glm_mat4_mulN((mat4 *[]){&proj, &view, &model}, 3, mvp); GLM(project)(pos, mvp, viewport, projected); GLM(unproject)(projected, mvp, viewport, unprojected); /* unprojected of projected vector must be same as original one */ /* we used 0.01 because of projection floating point errors */ #ifndef CGLM_FAST_MATH ASSERT(fabsf(pos[0] - unprojected[0]) < 0.01) ASSERT(fabsf(pos[1] - unprojected[1]) < 0.01) ASSERT(fabsf(pos[2] - unprojected[2]) < 0.01) #else ASSERT(fabsf(pos[0] - unprojected[0]) < 0.1) ASSERT(fabsf(pos[1] - unprojected[1]) < 0.1) ASSERT(fabsf(pos[2] - unprojected[2]) < 0.1) #endif /* test with no projection */ glm_mat4_identity(mvp); GLM(project)(pos, mvp, viewport, projected); GLM(unproject)(projected, mvp, viewport, unprojected); ASSERT(test_eq(pos[0], unprojected[0])) ASSERT(test_eq(pos[1], unprojected[1])) ASSERT(test_eq(pos[2], unprojected[2])) TEST_SUCCESS } cglm-0.9.6/test/src/test_quat.h000066400000000000000000000634301475344456400164260ustar00rootroot00000000000000/* * 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" #ifndef CGLM_TEST_QUAT_ONCE #define CGLM_TEST_QUAT_ONCE /* Macros */ TEST_IMPL(MACRO_GLM_QUAT_IDENTITY_INIT) { versor v = GLM_QUAT_IDENTITY_INIT; ASSERT(test_eq(v[0], 0.0f)) ASSERT(test_eq(v[1], 0.0f)) ASSERT(test_eq(v[2], 0.0f)) ASSERT(test_eq(v[3], 1.0f)) TEST_SUCCESS } TEST_IMPL(MACRO_GLM_QUAT_IDENTITY) { ASSERT(test_eq(GLM_QUAT_IDENTITY[0], 0.0f)) ASSERT(test_eq(GLM_QUAT_IDENTITY[1], 0.0f)) ASSERT(test_eq(GLM_QUAT_IDENTITY[2], 0.0f)) ASSERT(test_eq(GLM_QUAT_IDENTITY[3], 1.0f)) TEST_SUCCESS } #endif /* CGLM_TEST_QUAT_ONCE */ TEST_IMPL(GLM_PREFIX, quat_identity) { versor a = GLM_QUAT_IDENTITY_INIT; versor b = GLM_QUAT_IDENTITY_INIT; versor c; mat4 r; GLM(quat_identity)(c); ASSERTIFY(test_assert_quat_eq_identity(a)) ASSERTIFY(test_assert_quat_eq_identity(b)) ASSERTIFY(test_assert_quat_eq_identity(c)) glm_quat_identity(c); ASSERT(test_eq(glm_quat_real(c), cosf(glm_rad(0.0f) * 0.5f))) glm_quat_mat4(c, r); ASSERTIFY(test_assert_mat4_eq2(r, GLM_MAT4_IDENTITY, 0.000009f)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, quat_identity_array) { size_t i, count; versor quats[4] = { {1.0f, 2.0f, 3.0f, 4.0f}, {1.0f, 2.0f, 3.0f, 4.0f}, {1.0f, 2.0f, 3.0f, 4.0f}, {1.0f, 2.0f, 3.0f, 4.0f}, }; count = 4; GLM(quat_identity_array)(quats, count); for (i = 0; i < count; i++) { ASSERTIFY(test_assert_quat_eq_identity(quats[i])) } TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, quat_init) { versor q1 = {1.0f, 2.0f, 3.0f, 4.0f}; versor q2 = {1.0f, 2.0f, 3.0f, 4.0f}; versor q3 = {1.0f, 2.0f, 3.0f, 4.0f}; GLM(quat_init)(q1, 10.0f, 11.0f, 12.0f, 13.0f); GLM(quat_init)(q2, 100.0f, 110.0f, 120.0f, 130.0f); GLM(quat_init)(q3, 1000.0f, 1100.0f, 1200.0f, 1300.0f); ASSERT(q1[0] == 10.0f) ASSERT(q1[1] == 11.0f) ASSERT(q1[2] == 12.0f) ASSERT(q1[3] == 13.0f) ASSERT(q2[0] == 100.0f) ASSERT(q2[1] == 110.0f) ASSERT(q2[2] == 120.0f) ASSERT(q2[3] == 130.0f) ASSERT(q3[0] == 1000.0f) ASSERT(q3[1] == 1100.0f) ASSERT(q3[2] == 1200.0f) ASSERT(q3[3] == 1300.0f) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, quatv) { versor q1 = {1.0f, 2.0f, 3.0f, 4.0f}; vec3 v1, v2; float a1; test_rand_vec3(v1); GLM(quatv)(q1, glm_rad(60.0f), v1); glm_quat_axis(q1, v2); a1 = glm_quat_angle(q1); ASSERT(test_eq(a1, glm_rad(60.0f))) glm_vec3_normalize(v1); ASSERTIFY(test_assert_vec3_eq(v1, v2)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, quat) { versor q1 = {1.0f, 2.0f, 3.0f, 4.0f}; vec3 v1, v2; float a1; test_rand_vec3(v1); GLM(quat)(q1, glm_rad(60.0f), v1[0], v1[1], v1[2]); glm_quat_axis(q1, v2); a1 = glm_quat_angle(q1); ASSERT(test_eq(a1, glm_rad(60.0f))) glm_vec3_normalize(v1); ASSERTIFY(test_assert_vec3_eq(v1, v2)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, quat_copy) { versor v1 = {10.0f, 9.0f, 8.0f, 78.0f}; versor v2 = {1.0f, 2.0f, 3.0f, 4.0f}; GLM(quat_copy)(v1, v2); ASSERTIFY(test_assert_vec4_eq(v1, v2)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, quat_from_vecs) { versor q1, q2, q3, q4, q5, q6, q7; vec3 v1 = {1.f, 0.f, 0.f}, v2 = {1.f, 0.f, 0.f}; /* parallel */ vec3 v3 = {0.f, 1.f, 0.f}, v4 = {1.f, 0.f, 0.f}; /* perpendicular */ vec3 v5 = {0.f, 0.f, 1.f}, v6 = {0.f, 0.f, -1.f}; /* straight */ vec3 v7, v8; /* random */ vec3 v9 = {0.57735026f, 0.57735026f, 0.57735026f}, /* acute */ v10 = {0.70710678f, 0.70710678f, 0.f}; vec3 v11 = {0.87287156f, 0.21821789f, 0.43643578f}, /* obtuse */ v12 = {-0.87287156f, 0.21821789f, 0.43643578f}; vec3 v13 = GLM_VEC3_ZERO_INIT; /* zero */ GLM(quat_from_vecs)(v1, v2, q1); ASSERTIFY(test_assert_quat_eq_identity(q1)) GLM(quat_from_vecs)(v3, v4, q2); GLM(quat_rotatev)(q2, v3, v3); ASSERT(test_eq(GLM(vec3_dot)(v3, v4), 1.f)) ASSERT(test_eq(q2[0], 0.f)) ASSERT(test_eq(q2[1], 0.f)) ASSERT(test_eq(q2[2], -0.707106781187f)) ASSERT(test_eq(q2[3], 0.707106781187f)) GLM(quat_from_vecs)(v5, v6, q3); GLM(quat_rotatev)(q3, v5, v5); ASSERT(test_eq(GLM(vec3_dot)(v5, v6), 1.f)) ASSERT(test_eq(q3[0], 0.f)) ASSERT(test_eq(q3[1], -1.f)) ASSERT(test_eq(q3[2], 0.f)) ASSERT(test_eq(q3[3], 0.f)) test_rand_vec3(v7); test_rand_vec3(v8); GLM(vec3_normalize(v7)); GLM(vec3_normalize(v8)); GLM(quat_from_vecs)(v7, v8, q4); GLM(quat_rotatev)(q4, v7, v7); ASSERT(test_eq(GLM(vec3_dot)(v7, v8), 1.f)) GLM(quat_from_vecs)(v9, v10, q5); GLM(quat_rotatev)(q5, v9, v9); ASSERT(test_eq(GLM(vec3_dot)(v9, v10), 1.f)) GLM(quat_from_vecs)(v11, v12, q6); GLM(quat_rotatev)(q6, v11, v11); ASSERT(test_eq(GLM(vec3_dot)(v11, v12), 1.f)) GLM(quat_from_vecs)(v13, v1, q7); ASSERTIFY(test_assert_quat_eq_identity(q7)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, quat_norm) { versor a = {10.0f, 9.0f, 8.0f, 78.0f}; float n1, n2; n1 = GLM(quat_norm)(a); n2 = sqrtf(a[0] * a[0] + a[1] * a[1] + a[2] * a[2] + a[3] * a[3]); ASSERT(test_eq(n1, n2)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, quat_normalize_to) { versor v1 = {2.0f, -3.0f, 4.0f, 5.0f}, v2; float s = 1.0f; float norm; GLM(quat_normalize_to)(v1, v2); norm = sqrtf(v1[0] * v1[0] + v1[1] * v1[1] + v1[2] * v1[2] + v1[3] * v1[3]); if (norm <= 0.0f) { ASSERTIFY(test_assert_quat_eq_identity(v1)) TEST_SUCCESS } norm = s / norm; ASSERT(test_eq(v1[0] * norm, v2[0])) ASSERT(test_eq(v1[1] * norm, v2[1])) ASSERT(test_eq(v1[2] * norm, v2[2])) ASSERT(test_eq(v1[3] * norm, v2[3])) glm_vec4_zero(v1); GLM(quat_normalize_to)(v1, v2); ASSERTIFY(test_assert_quat_eq_identity(v2)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, quat_normalize) { versor v1 = {2.0f, -3.0f, 4.0f, 5.0f}, v2 = {2.0f, -3.0f, 4.0f, 5.0f}; float s = 1.0f; float norm; GLM(quat_normalize)(v2); norm = sqrtf(v1[0] * v1[0] + v1[1] * v1[1] + v1[2] * v1[2] + v1[3] * v1[3]); if (norm <= 0.0f) { ASSERTIFY(test_assert_quat_eq_identity(v1)) TEST_SUCCESS } norm = s / norm; ASSERT(test_eq(v1[0] * norm, v2[0])) ASSERT(test_eq(v1[1] * norm, v2[1])) ASSERT(test_eq(v1[2] * norm, v2[2])) ASSERT(test_eq(v1[3] * norm, v2[3])) glm_vec4_zero(v1); GLM(quat_normalize)(v1); ASSERTIFY(test_assert_quat_eq_identity(v1)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, quat_dot) { versor a = {10.0f, 9.0f, 8.0f, 78.0f}; versor b = {1.0f, 2.0f, 3.0f, 4.0f}; float dot1, dot2; dot1 = GLM(quat_dot)(a, b); dot2 = a[0] * b[0] + a[1] * b[1] + a[2] * b[2] + a[3] * b[3]; ASSERT(test_eq(dot1, dot2)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, quat_conjugate) { versor a = {10.0f, 9.0f, 8.0f, 78.0f}; versor b = {1.0f, 2.0f, 3.0f, 4.0f}; versor d, e; GLM(quat_conjugate)(a, d); GLM(quat_conjugate)(b, e); ASSERT(test_eq(d[0], -a[0])) ASSERT(test_eq(d[1], -a[1])) ASSERT(test_eq(d[2], -a[2])) ASSERT(test_eq(d[3], a[3])) ASSERT(test_eq(e[0], -b[0])) ASSERT(test_eq(e[1], -b[1])) ASSERT(test_eq(e[2], -b[2])) ASSERT(test_eq(e[3], b[3])) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, quat_inv) { versor a = {10.0f, 9.0f, 8.0f, 78.0f}; versor b = {1.0f, 2.0f, 3.0f, 4.0f}; versor d, e; float n1, n2; n1 = 1.0f / glm_vec4_norm2(a); n2 = 1.0f / glm_vec4_norm2(b); GLM(quat_inv)(a, d); GLM(quat_inv)(b, e); ASSERT(test_eq(d[0], -a[0] * n1)) ASSERT(test_eq(d[1], -a[1] * n1)) ASSERT(test_eq(d[2], -a[2] * n1)) ASSERT(test_eq(d[3], a[3] * n1)) ASSERT(test_eq(e[0], -b[0] * n2)) ASSERT(test_eq(e[1], -b[1] * n2)) ASSERT(test_eq(e[2], -b[2] * n2)) ASSERT(test_eq(e[3], b[3] * n2)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, quat_add) { versor a = {-10.0f, 9.0f, -8.0f, 56.0f}; versor b = {12.0f, 19.0f, -18.0f, 1.0f}; versor c, d; c[0] = a[0] + b[0]; c[1] = a[1] + b[1]; c[2] = a[2] + b[2]; c[3] = a[3] + b[3]; GLM(quat_add)(a, b, d); ASSERTIFY(test_assert_quat_eq(c, d)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, quat_sub) { vec4 a = {-10.0f, 9.0f, -8.0f, 56.0f}; vec4 b = {12.0f, 19.0f, -18.0f, 1.0f}; vec4 c, d; c[0] = a[0] - b[0]; c[1] = a[1] - b[1]; c[2] = a[2] - b[2]; c[3] = a[3] - b[3]; GLM(quat_sub)(a, b, d); ASSERTIFY(test_assert_quat_eq(c, d)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, quat_real) { versor a = {10.0f, 9.0f, 8.0f, 78.0f}; versor b = {1.0f, 2.0f, 3.0f, 4.0f}; ASSERT(test_eq(GLM(quat_real)(a), 78.0f)) ASSERT(test_eq(GLM(quat_real)(b), 4.0f)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, quat_imag) { versor a = {10.0f, 9.0f, 8.0f, 78.0f}; versor b = {1.0f, 2.0f, 3.0f, 4.0f}; vec3 d, e; GLM(quat_imag)(a, d); GLM(quat_imag)(b, e); ASSERT(test_eq(d[0], a[0])) ASSERT(test_eq(d[1], a[1])) ASSERT(test_eq(d[2], a[2])) ASSERT(test_eq(e[0], b[0])) ASSERT(test_eq(e[1], b[1])) ASSERT(test_eq(e[2], b[2])) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, quat_imagn) { versor a = {10.0f, 9.0f, 8.0f, 78.0f}; versor b = {1.0f, 2.0f, 3.0f, 4.0f}; vec3 d, e; GLM(quat_imagn)(a, d); GLM(quat_imagn)(b, e); glm_vec3_normalize(a); glm_vec3_normalize(b); glm_vec3_normalize(d); glm_vec3_normalize(e); ASSERT(test_eq(d[0], a[0])) ASSERT(test_eq(d[1], a[1])) ASSERT(test_eq(d[2], a[2])) ASSERT(test_eq(e[0], b[0])) ASSERT(test_eq(e[1], b[1])) ASSERT(test_eq(e[2], b[2])) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, quat_imaglen) { versor a = {10.0f, 9.0f, 8.0f, 78.0f}; versor b = {1.0f, 2.0f, 3.0f, 4.0f}; ASSERT(test_eq(GLM(quat_imaglen)(a), glm_vec3_norm(a))); ASSERT(test_eq(GLM(quat_imaglen)(b), glm_vec3_norm(b))); TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, quat_angle) { versor q1 = {1.0f, 2.0f, 3.0f, 4.0f}, q2, q3; vec3 v1; float a1, a2, a3; test_rand_vec3(v1); GLM(quatv)(q1, glm_rad(60.140f), v1); GLM(quatv)(q2, glm_rad(160.04f), v1); GLM(quatv)(q3, glm_rad(20.350f), v1); a1 = GLM(quat_angle)(q1); a2 = GLM(quat_angle)(q2); a3 = GLM(quat_angle)(q3); ASSERT(test_eq(a1, glm_rad(60.140f))) ASSERT(test_eq(a2, glm_rad(160.04f))) ASSERT(test_eq(a3, glm_rad(20.350f))) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, quat_axis) { versor q1 = {1.0f, 2.0f, 3.0f, 4.0f}, q2, q3; vec3 v1, v2; test_rand_vec3(v1); GLM(quatv)(q1, glm_rad(60.0f), v1); glm_quat_axis(q1, v2); glm_vec3_normalize(v1); ASSERTIFY(test_assert_vec3_eq(v1, v2)) test_rand_vec3(v1); GLM(quatv)(q2, glm_rad(60.0f), v1); glm_quat_axis(q2, v2); glm_vec3_normalize(v1); ASSERTIFY(test_assert_vec3_eq(v1, v2)) test_rand_vec3(v1); GLM(quatv)(q3, glm_rad(60.0f), v1); glm_quat_axis(q3, v2); glm_vec3_normalize(v1); ASSERTIFY(test_assert_vec3_eq(v1, v2)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, quat_mul) { versor q1 = {2.0f, 3.0f, 4.0f, 5.0f}; versor q2 = {6.0f, 7.0f, 8.0f, 9.0f}; versor q3; versor q4; vec3 v1 = {1.5f, 2.5f, 3.5f}; GLM(quat_mul)(q1, q2, q3); ASSERT(test_eq(q3[0], q1[3] * q2[0] + q1[0] * q2[3] + q1[1] * q2[2] - q1[2] * q2[1])) ASSERT(test_eq(q3[1], q1[3] * q2[1] - q1[0] * q2[2] + q1[1] * q2[3] + q1[2] * q2[0])) ASSERT(test_eq(q3[2], q1[3] * q2[2] + q1[0] * q2[1] - q1[1] * q2[0] + q1[2] * q2[3])) ASSERT(test_eq(q3[3], q1[3] * q2[3] - q1[0] * q2[0] - q1[1] * q2[1] - q1[2] * q2[2])) glm_quatv(q1, glm_rad(30.0f), v1); glm_quatv(q2, glm_rad(20.0f), v1); glm_quatv(q3, glm_rad(50.0f), v1); GLM(quat_mul)(q1, q2, q4); ASSERTIFY(test_assert_quat_eq(q3, q4)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, quat_mat4) { mat4 m1, m2; versor q1, q2, q3; vec3 axis1; vec3 axis2 = {1.9f, 2.3f, 4.5f}; int i; GLM(quat)(q1, GLM_PI_4f, 1.9f, 2.3f, 4.5f); GLM(quat_mat4)(q1, m1); GLM(mat4_quat)(m1, q2); GLM(rotate_make)(m2, GLM_PI_4f, axis2); GLM(mat4_quat)(m1, q3); GLM(quat_axis)(q3, axis1); GLM(vec3_normalize)(axis1); GLM(vec3_normalize)(axis2); ASSERT(test_eq(glm_quat_angle(q3), GLM_PI_4f)) ASSERTIFY(test_assert_vec3_eq(axis1, axis2)) ASSERTIFY(test_assert_vec4_eq(q1, q2)) ASSERTIFY(test_assert_mat4_eq(m1, m2)) ASSERTIFY(test_assert_vec4_eq(q1, q3)) /* 1. test quat to mat and mat to quat */ for (i = 0; i < 1000; i++) { test_rand_quat(q1); GLM(quat_mat4)(q1, m1); GLM(mat4_quat)(m1, q2); GLM(quat_mat4)(q2, m2); /* 2. test first quat and generated one equality */ ASSERTIFY(test_assert_quat_eq_abs(q1, q2)); /* 3. test first rot and second rotation */ /* almost equal */ ASSERTIFY(test_assert_mat4_eq2(m1, m2, 0.000009f)); } TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, quat_mat4t) { mat4 m1, m2; versor q1, q2, q3; vec3 axis1; vec3 axis2 = {1.9f, 2.3f, 4.5f}; int i; GLM(quat)(q1, GLM_PI_4f, 1.9f, 2.3f, 4.5f); GLM(quat_mat4t)(q1, m1); glm_mat4_transpose(m1); GLM(mat4_quat)(m1, q2); GLM(rotate_make)(m2, GLM_PI_4f, axis2); GLM(mat4_quat)(m1, q3); GLM(quat_axis)(q3, axis1); GLM(vec3_normalize)(axis1); GLM(vec3_normalize)(axis2); ASSERT(test_eq(glm_quat_angle(q3), GLM_PI_4f)) ASSERTIFY(test_assert_vec3_eq(axis1, axis2)) ASSERTIFY(test_assert_vec4_eq(q1, q2)) ASSERTIFY(test_assert_mat4_eq(m1, m2)) ASSERTIFY(test_assert_vec4_eq(q1, q3)) /* 1. test quat to mat and mat to quat */ for (i = 0; i < 1000; i++) { test_rand_quat(q1); GLM(quat_mat4t)(q1, m1); glm_mat4_transpose(m1); GLM(mat4_quat)(m1, q2); GLM(quat_mat4t)(q2, m2); glm_mat4_transpose(m2); /* 2. test first quat and generated one equality */ ASSERTIFY(test_assert_quat_eq_abs(q1, q2)); /* 3. test first rot and second rotation */ /* almost equal */ ASSERTIFY(test_assert_mat4_eq2(m1, m2, 0.000009f)); } TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, quat_mat3) { mat4 m1, m2; mat3 m3; versor q1, q2, q3; vec3 axis1; vec3 axis2 = {1.9f, 2.3f, 4.5f}; int i; GLM(quat)(q1, GLM_PI_4f, 1.9f, 2.3f, 4.5f); GLM(quat_mat3)(q1, m3); glm_mat4_identity(m1); glm_mat4_ins3(m3, m1); GLM(mat4_quat)(m1, q2); GLM(rotate_make)(m2, GLM_PI_4f, axis2); GLM(mat4_quat)(m1, q3); GLM(quat_axis)(q3, axis1); GLM(vec3_normalize)(axis1); GLM(vec3_normalize)(axis2); ASSERT(test_eq(glm_quat_angle(q3), GLM_PI_4f)) ASSERTIFY(test_assert_vec3_eq(axis1, axis2)) ASSERTIFY(test_assert_vec4_eq(q1, q2)) ASSERTIFY(test_assert_mat4_eq(m1, m2)) ASSERTIFY(test_assert_vec4_eq(q1, q3)) /* 1. test quat to mat and mat to quat */ for (i = 0; i < 1000; i++) { test_rand_quat(q1); GLM(quat_mat3)(q1, m3); glm_mat4_identity(m1); glm_mat4_ins3(m3, m1); GLM(mat4_quat)(m1, q2); GLM(quat_mat3)(q2, m3); glm_mat4_identity(m2); glm_mat4_ins3(m3, m2); /* 2. test first quat and generated one equality */ ASSERTIFY(test_assert_quat_eq_abs(q1, q2)); /* 3. test first rot and second rotation */ /* almost equal */ ASSERTIFY(test_assert_mat4_eq2(m1, m2, 0.000009f)); } TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, quat_mat3t) { mat4 m1, m2; mat3 m3; versor q1, q2, q3; vec3 axis1; vec3 axis2 = {1.9f, 2.3f, 4.5f}; int i; GLM(quat)(q1, GLM_PI_4f, 1.9f, 2.3f, 4.5f); GLM(quat_mat3t)(q1, m3); glm_mat3_transpose(m3); glm_mat4_identity(m1); glm_mat4_ins3(m3, m1); GLM(mat4_quat)(m1, q2); GLM(rotate_make)(m2, GLM_PI_4f, axis2); GLM(mat4_quat)(m1, q3); GLM(quat_axis)(q3, axis1); GLM(vec3_normalize)(axis1); GLM(vec3_normalize)(axis2); ASSERT(test_eq(glm_quat_angle(q3), GLM_PI_4f)) ASSERTIFY(test_assert_vec3_eq(axis1, axis2)) ASSERTIFY(test_assert_vec4_eq(q1, q2)) ASSERTIFY(test_assert_mat4_eq(m1, m2)) ASSERTIFY(test_assert_vec4_eq(q1, q3)) /* 1. test quat to mat and mat to quat */ for (i = 0; i < 1000; i++) { test_rand_quat(q1); GLM(quat_mat3t)(q1, m3); glm_mat3_transpose(m3); glm_mat4_identity(m1); glm_mat4_ins3(m3, m1); GLM(mat4_quat)(m1, q2); GLM(quat_mat3t)(q2, m3); glm_mat3_transpose(m3); glm_mat4_identity(m2); glm_mat4_ins3(m3, m2); /* 2. test first quat and generated one equality */ ASSERTIFY(test_assert_quat_eq_abs(q1, q2)); /* 3. test first rot and second rotation */ /* almost equal */ ASSERTIFY(test_assert_mat4_eq2(m1, m2, 0.000009f)); } TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, quat_lerp) { versor v1 = {-100.0f, -200.0f, -10.0f, -10.0f}; versor v2 = {100.0f, 200.0f, 10.0f, 10.0f}; versor v3; GLM(quat_lerp)(v1, v2, 0.5f, v3); ASSERT(test_eq(v3[0], 0.0f)) ASSERT(test_eq(v3[1], 0.0f)) ASSERT(test_eq(v3[2], 0.0f)) ASSERT(test_eq(v3[3], 0.0f)) GLM(quat_lerp)(v1, v2, 0.75f, v3); ASSERT(test_eq(v3[0], 50.0f)) ASSERT(test_eq(v3[1], 100.0f)) ASSERT(test_eq(v3[2], 5.0f)) ASSERT(test_eq(v3[3], 5.0f)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, quat_lerpc) { versor v1 = {-100.0f, -200.0f, -10.0f, -10.0f}; versor v2 = {100.0f, 200.0f, 10.0f, 10.0f}; versor v3; GLM(quat_lerpc)(v1, v2, 0.5f, v3); ASSERT(test_eq(v3[0], 0.0f)) ASSERT(test_eq(v3[1], 0.0f)) ASSERT(test_eq(v3[2], 0.0f)) ASSERT(test_eq(v3[3], 0.0f)) GLM(quat_lerpc)(v1, v2, 0.75f, v3); ASSERT(test_eq(v3[0], 50.0f)) ASSERT(test_eq(v3[1], 100.0f)) ASSERT(test_eq(v3[2], 5.0f)) ASSERT(test_eq(v3[3], 5.0f)) GLM(quat_lerpc)(v1, v2, -1.75f, v3); ASSERT(test_eq(v3[0], -100.0f)) ASSERT(test_eq(v3[1], -200.0f)) ASSERT(test_eq(v3[2], -10.0f)) ASSERT(test_eq(v3[3], -10.0f)) GLM(quat_lerpc)(v1, v2, 1.75f, v3); ASSERT(test_eq(v3[0], 100.0f)) ASSERT(test_eq(v3[1], 200.0f)) ASSERT(test_eq(v3[2], 10.0f)) ASSERT(test_eq(v3[3], 10.0f)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, quat_nlerp) { versor q1, q2, q3, q4; vec3 v1 = {10.0f, 0.0f, 0.0f}, v2; glm_quatv(q1, glm_rad(30.0f), v1); glm_quatv(q2, glm_rad(90.0f), v1); GLM(quat_nlerp)(q1, q2, 1.0f, q3); glm_quat_normalize(q2); ASSERTIFY(test_assert_quat_eq(q2, q3)); glm_quatv(q1, glm_rad(30.001f), v1); glm_quatv(q2, glm_rad(30.002f), v1); GLM(quat_nlerp)(q1, q2, 0.7f, q3); glm_quat_lerp(q1, q2, 0.7f, q4); ASSERTIFY(test_assert_quat_eq(q3, q4)); glm_quatv(q1, glm_rad(30.0f), v1); glm_quatv(q2, glm_rad(90.0f), v1); GLM(quat_nlerp)(q1, q2, 0.5f, q3); glm_quat_axis(q3, v2); glm_vec3_normalize(v1); glm_vec3_normalize(v2); ASSERT(glm_quat_angle(q3) > glm_rad(30.0f)); ASSERT(glm_quat_angle(q3) < glm_rad(90.0f)); ASSERTIFY(test_assert_vec3_eq(v1, v2)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, quat_slerp) { versor q1, q2, q3, q4; vec3 v1 = {10.0f, 0.0f, 0.0f}, v2; glm_quatv(q1, glm_rad(30.0f), v1); glm_quatv(q2, glm_rad(90.0f), v1); q1[0] = 10.0f; GLM(quat_slerp)(q1, q2, 1.0f, q3); ASSERTIFY(test_assert_quat_eq(q1, q3)); glm_quatv(q1, glm_rad(30.001f), v1); glm_quatv(q2, glm_rad(30.002f), v1); GLM(quat_slerp)(q1, q2, 0.7f, q3); glm_quat_lerp(q1, q2, 0.7f, q4); ASSERTIFY(test_assert_quat_eq(q3, q4)); glm_quatv(q1, glm_rad(30.0f), v1); glm_quatv(q2, glm_rad(90.0f), v1); GLM(quat_slerp)(q1, q2, 0.5f, q3); glm_quat_axis(q3, v2); glm_vec3_normalize(v1); glm_vec3_normalize(v2); ASSERT(glm_quat_angle(q3) > glm_rad(30.0f)); ASSERT(glm_quat_angle(q3) < glm_rad(90.0f)); ASSERTIFY(test_assert_vec3_eq(v1, v2)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, quat_look) { versor q1; vec3 v1 = {0.0f, 1.0f, 0.0f}; mat4 m1, m2; glm_quat(q1, glm_rad(90.0f), 0.0f, 1.0f, 0.0f); GLM(quat_look)(v1, q1, m1); glm_look(v1, (vec3){-1.0f, 0.0f, 0.0f}, GLM_YUP, m2); ASSERTIFY(test_assert_mat4_eq(m1, m2)); glm_quat(q1, glm_rad(180.0f), 1.0f, 0.0f, 0.0f); GLM(quat_look)(v1, q1, m1); glm_look(v1, (vec3){0.0f, 0.0f, 1.0f}, (vec3){0.0f, -1.0f, 0.0f}, m2); ASSERTIFY(test_assert_mat4_eq(m1, m2)); TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, quat_for) { versor q1, q2; glm_quat(q1, glm_rad(90.0f), 0.0f, 1.0f, 0.0f); GLM(quat_for)((vec3){-1.0f, 0.0f, 0.0f}, (vec3){0.0f, 1.0f, 0.0f}, q2); ASSERTIFY(test_assert_quat_eq(q1, q2)); glm_quat(q2, glm_rad(90.0f), 1.0f, 0.0f, 0.0f); GLM(quat_for)((vec3){0.0f, 1.0f, 0.0f}, (vec3){0.0f, 0.0f, 1.0f}, q1); ASSERTIFY(test_assert_quat_eq(q1, q2)); glm_quat(q2, glm_rad(180.0f), 1.0f, 0.0f, 0.0f); GLM(quat_for)((vec3){0.0f, 0.0f, 1.0f}, (vec3){0.0f, -1.0f, 0.0f}, q1); ASSERTIFY(test_assert_quat_eq(q1, q2)); TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, quat_forp) { versor q1, q2; glm_quat(q1, glm_rad(90.0f), 0.0f, 1.0f, 0.0f); GLM(quat_forp)((vec3){2.0f, 0.0f, 0.0f}, (vec3){1.0f, 0.0f, 0.0f}, (vec3){0.0f, 1.0f, 0.0f}, q2); ASSERTIFY(test_assert_quat_eq(q1, q2)); glm_quat(q2, glm_rad(90.0f), 1.0f, 0.0f, 0.0f); GLM(quat_forp)((vec3){0.0f, 1.0f, 0.0f}, (vec3){0.0f, 2.0f, 0.0f}, (vec3){0.0f, 0.0f, 1.0f}, q1); ASSERTIFY(test_assert_quat_eq(q1, q2)); glm_quat(q2, glm_rad(180.0f), 1.0f, 0.0f, 0.0f); GLM(quat_forp)((vec3){0.0f, 1.0f, 1.0f}, (vec3){0.0f, 1.0f, 2.0f}, (vec3){0.0f, -1.0f, 0.0f}, q1); ASSERTIFY(test_assert_quat_eq(q1, q2)); TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, quat_rotatev) { vec3 v1 = {1.0f, 0.0f, 0.0f}, v2 = {1.0f, 1.0f, 1.0f}; versor q; /* rotate X around Y = -Z */ glm_quatv(q, GLM_PI_2f, GLM_YUP); GLM(quat_rotatev)(q, v1, v1); ASSERT(test_eq(v1[0], 0.0f)) ASSERT(test_eq(v1[1], 0.0f)) ASSERT(test_eq(v1[2], -1.0f)) /* rotate -Z around X = Y */ glm_quatv(q, GLM_PI_2f, GLM_XUP); GLM(quat_rotatev)(q, v1, v1); ASSERT(test_eq(v1[0], 0.0f)) ASSERT(test_eq(v1[1], 1.0f)) ASSERT(test_eq(v1[2], 0.0f)) /* rotate Y around Z = -X */ glm_quatv(q, GLM_PI_2f, GLM_ZUP); GLM(quat_rotatev)(q, v1, v1); ASSERT(test_eq(v1[0], -1.0f)) ASSERT(test_eq(v1[1], 0.0f)) ASSERT(test_eq(v1[2], 0.0f)) /* rotate v2 around Y by 90deg */ glm_quatv(q, GLM_PI_2f, GLM_YUP); GLM(quat_rotatev)(q, v2, v2); ASSERT(test_eq(v2[0], 1.0f)) ASSERT(test_eq(v2[1], 1.0f)) ASSERT(test_eq(v2[2], -1.0f)) /* rotate v2 around Y by 90deg */ glm_quatv(q, GLM_PI_2f, GLM_YUP); GLM(quat_rotatev)(q, v2, v2); ASSERT(test_eq(v2[0], -1.0f)) ASSERT(test_eq(v2[1], 1.0f)) ASSERT(test_eq(v2[2], -1.0f)) /* rotate v2 around Y by 90deg */ glm_quatv(q, GLM_PI_2f, GLM_YUP); GLM(quat_rotatev)(q, v2, v2); ASSERT(test_eq(v2[0], -1.0f)) ASSERT(test_eq(v2[1], 1.0f)) ASSERT(test_eq(v2[2], 1.0f)) /* rotate v2 around X by 90deg */ glm_quatv(q, GLM_PI_2f, GLM_XUP); GLM(quat_rotatev)(q, v2, v2); ASSERT(test_eq(v2[0], -1.0f)) ASSERT(test_eq(v2[1], -1.0f)) ASSERT(test_eq(v2[2], 1.0f)) /* rotate v2 around Z by 90deg */ glm_quatv(q, GLM_PI_2f, GLM_ZUP); GLM(quat_rotatev)(q, v2, v2); ASSERT(test_eq(v2[0], 1.0f)) ASSERT(test_eq(v2[1], -1.0f)) ASSERT(test_eq(v2[2], 1.0f)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, quat_rotate) { mat4 m1 = GLM_MAT4_IDENTITY_INIT, m2; versor q1; vec4 v1 = {1.0f, 0.0f, 0.0f, 1.0f}; /* rotate X around Y = -Z */ glm_quatv(q1, GLM_PI_2f, GLM_YUP); GLM(quat_rotate)(m1, q1, m1); glm_rotate_make(m2, GLM_PI_2f, GLM_YUP); ASSERTIFY(test_assert_mat4_eq(m1, m2)) glm_mat4_mulv(m1, v1, v1); ASSERT(test_eq(v1[0], 0.0f)) ASSERT(test_eq(v1[1], 0.0f)) ASSERT(test_eq(v1[2], -1.0f)) glm_mat4_identity(m1); glm_mat4_identity(m2); /* rotate -Z around X = Y */ glm_quatv(q1, GLM_PI_2f, GLM_XUP); GLM(quat_rotate)(m1, q1, m1); glm_rotate(m2, GLM_PI_2f, GLM_XUP); ASSERTIFY(test_assert_mat4_eq(m1, m2)) glm_mat4_mulv(m1, v1, v1); ASSERT(test_eq(v1[0], 0.0f)) ASSERT(test_eq(v1[1], 1.0f)) ASSERT(test_eq(v1[2], 0.0f)) glm_mat4_identity(m1); glm_mat4_identity(m2); /* rotate Y around X = +Z */ glm_quatv(q1, GLM_PI_2f, GLM_XUP); GLM(quat_rotate)(m1, q1, m1); glm_rotate(m2, GLM_PI_2f, GLM_XUP); ASSERTIFY(test_assert_mat4_eq(m1, m2)) glm_mat4_mulv(m1, v1, v1); ASSERT(test_eq(v1[0], 0.0f)) ASSERT(test_eq(v1[1], 0.0f)) ASSERT(test_eq(v1[2], 1.0f)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, quat_rotate_at) { mat4 m1 = GLM_MAT4_IDENTITY_INIT; versor q1; vec4 v1 = {1.0f, 0.0f, 0.0f, 1.0f}; glm_quatv(q1, GLM_PI_2f, GLM_YUP); GLM(quat_rotate_at)(m1, q1, (vec3){0.5f, 0.0f, 0.0f}); glm_mat4_mulv(m1, v1, v1); ASSERT(test_eq(v1[0], 0.5f)) ASSERT(test_eq(v1[1], 0.0f)) ASSERT(test_eq(v1[2], -0.5f)) glm_mat4_identity(m1); glm_quatv(q1, GLM_PI_2f, GLM_ZUP); GLM(quat_rotate_at)(m1, q1, (vec3){0.0f, 0.0f, 0.0f}); glm_mat4_mulv(m1, v1, v1); ASSERT(test_eq(v1[0], 0.0f)) ASSERT(test_eq(v1[1], 0.5f)) ASSERT(test_eq(v1[2], -0.5f)) glm_mat4_identity(m1); v1[0] = 1.0f; v1[1] = 1.0f; v1[2] = 1.0f; glm_quatv(q1, GLM_PI_2f, GLM_XUP); GLM(quat_rotate_at)(m1, q1, GLM_VEC3_ZERO); glm_mat4_mulv(m1, v1, v1); ASSERT(test_eq(v1[0], 1.0f)) ASSERT(test_eq(v1[1], -1.0f)) ASSERT(test_eq(v1[2], 1.0f)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, quat_rotate_atm) { mat4 m1 = GLM_MAT4_IDENTITY_INIT; versor q1; vec4 v1 = {1.0f, 0.0f, 0.0f, 1.0f}; glm_quatv(q1, GLM_PI_2f, GLM_YUP); GLM(quat_rotate_atm)(m1, q1, (vec3){0.5f, 0.0f, 0.0f}); glm_mat4_mulv(m1, v1, v1); ASSERT(test_eq(v1[0], 0.5f)) ASSERT(test_eq(v1[1], 0.0f)) ASSERT(test_eq(v1[2], -0.5f)) glm_quatv(q1, GLM_PI_2f, GLM_ZUP); GLM(quat_rotate_atm)(m1, q1, (vec3){0.0f, 0.0f, 0.0f}); glm_mat4_mulv(m1, v1, v1); ASSERT(test_eq(v1[0], 0.0f)) ASSERT(test_eq(v1[1], 0.5f)) ASSERT(test_eq(v1[2], -0.5f)) v1[0] = 1.0f; v1[1] = 1.0f; v1[2] = 1.0f; glm_quatv(q1, GLM_PI_2f, GLM_XUP); GLM(quat_rotate_atm)(m1, q1, GLM_VEC3_ZERO); glm_mat4_mulv(m1, v1, v1); ASSERT(test_eq(v1[0], 1.0f)) ASSERT(test_eq(v1[1], -1.0f)) ASSERT(test_eq(v1[2], 1.0f)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, quat_make) { versor dest[3]; float src[12] = { 7.2f, 1.0f, 2.5f, 6.1f, 0.2f, 2.8f, 17.3f, 5.1f, 4.2f, 7.3f, 6.6f, 8.8f }; float *srcp = src; unsigned int i, j; for (i = 0, j = 0; i < sizeof(src) / sizeof(float); i+=4,j++) { GLM(quat_make)(srcp + i, dest[j]); ASSERT(test_eq(src[ i ], dest[j][0])); ASSERT(test_eq(src[i+1], dest[j][1])); ASSERT(test_eq(src[i+2], dest[j][2])); ASSERT(test_eq(src[i+3], dest[j][3])); } TEST_SUCCESS } cglm-0.9.6/test/src/test_ray.h000066400000000000000000000050061475344456400162420ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ #include "test_common.h" TEST_IMPL(GLM_PREFIX, ray_triangle) { /* Check whether a simple hit is recognized with the right distance */ vec3 origin = { 0.0f, 0.0f, 0.0f}; vec3 direction = { 1.0f, 0.0f, 0.0f}; vec3 opposite = {-1.0f, 0.0f, 0.0f}; vec3 v0 = { 5.0f, -1.0f, 1.0f}; vec3 v1 = { 5.0f, -1.0f, -1.0f}; vec3 v2 = { 5.0f, 1.0f, 0.0f}; float d; bool hit; hit = GLM(ray_triangle)(origin, direction, v0, v1, v2, &d); ASSERT(hit); ASSERT(fabsf(d - 5.0f) <= 0.0000009); /* Check whether a simple miss works */ hit = GLM(ray_triangle)(origin, opposite, v0, v1, v2, &d); ASSERT(!hit); /* Check that we can disregard distance and pass NULL pointer instead */ hit = GLM(ray_triangle)(origin, direction, v0, v1, v2, NULL); ASSERT(hit); TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, ray_sphere) { vec4 sphere = {5.0f, 0.0f, 0.0f, 1.0f}; /* Sphere: center at (5, 0, 0) with radius 1 */ float t1, t2; bool hit; /* Case 1: Ray misses the sphere */ hit = GLM(ray_sphere)((vec3){10.0f, 3.0f, 0.0f}, (vec3){1.0f, 0.0f, 0.0f}, sphere, &t1, &t2); ASSERT(!hit); /* Expect no intersection */ /* Case 2: Ray starts inside the sphere */ hit = GLM(ray_sphere)((vec3){5.0f, 0.5f, 0.0f}, (vec3){1.0f, 0.0f, 0.0f}, sphere, &t1, &t2); ASSERT(hit); /* Expect an intersection */ ASSERT(t1 < 0 && t2 > 0); /* Ray exits at t2 */ /* Case 3: Ray intersects the sphere from outside */ hit = GLM(ray_sphere)((vec3){0.0f, 0.0f, 0.0f}, (vec3){1.0f, 0.0f, 0.0f}, sphere, &t1, &t2); ASSERT(hit); /* Expect an intersection */ ASSERT(t1 > 0 && t2 > 0); /* Intersections at t1 and t2 */ TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, ray_at) { vec3 origin = {0.0f, 0.0f, 0.0f}; vec3 direction = {1.0f, 1.0f, 1.0f}; /* Diagonal direction */ float distance = sqrtf(3.0f); /* Distance along the ray; sqrt(3) for unit length due to direction normalization */ vec3 result; /* Normalize the direction to ensure accurate distance measurement */ glm_vec3_normalize(direction); GLM(ray_at)(origin, direction, distance, result); ASSERT(fabsf(result[0] - 1.0f) <= 0.0000009); /* Expecting to be 1 unit along the x-axis */ ASSERT(fabsf(result[1] - 1.0f) <= 0.0000009); /* Expecting to be 1 unit along the y-axis */ ASSERT(fabsf(result[2] - 1.0f) <= 0.0000009); /* Expecting to be 1 unit along the z-axis */ TEST_SUCCESS } cglm-0.9.6/test/src/test_struct.c000066400000000000000000000072551475344456400167760ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ #include "test_common.h" TEST_IMPL(mat2x3s_zero_init) { mat2x3s mat2x3_zero = GLMS_MAT2X3_ZERO_INIT; test_assert_mat2x3_eq_zero(mat2x3_zero.raw); TEST_SUCCESS } TEST_IMPL(mat2x3s_zero) { mat2x3s mat2x3_zero = GLMS_MAT2X3_ZERO; test_assert_mat2x3_eq_zero(mat2x3_zero.raw); TEST_SUCCESS } TEST_IMPL(mat2x4s_zero_init) { mat2x4s mat2x4_zero = GLMS_MAT2X4_ZERO_INIT; test_assert_mat2x4_eq_zero(mat2x4_zero.raw); TEST_SUCCESS } TEST_IMPL(mat2x4s_zero) { mat2x4s mat2x4_zero = GLMS_MAT2X4_ZERO; test_assert_mat2x4_eq_zero(mat2x4_zero.raw); TEST_SUCCESS } TEST_IMPL(mat3s_identity_init) { mat3s mat3_identity = GLMS_MAT3_IDENTITY_INIT; mat3 mat3_identity_a = GLM_MAT3_IDENTITY_INIT; test_assert_mat3_eq(mat3_identity.raw, mat3_identity_a); TEST_SUCCESS } TEST_IMPL(mat3s_zero_init) { mat3s mat3_zero = GLMS_MAT3_ZERO_INIT; mat3 mat3_zero_a = GLM_MAT3_ZERO_INIT; test_assert_mat3_eq(mat3_zero.raw, mat3_zero_a); TEST_SUCCESS } TEST_IMPL(mat3x2s_zero_init) { mat3x2s mat3x2_zero = GLMS_MAT3X2_ZERO_INIT; test_assert_mat3x2_eq_zero(mat3x2_zero.raw); TEST_SUCCESS } TEST_IMPL(mat3x2s_zero) { mat3x2s mat3x2_zero = GLMS_MAT3X2_ZERO; test_assert_mat3x2_eq_zero(mat3x2_zero.raw); TEST_SUCCESS } TEST_IMPL(mat3x4s_zero_init) { mat3x4s mat3x4_zero = GLMS_MAT3X4_ZERO_INIT; test_assert_mat3x4_eq_zero(mat3x4_zero.raw); TEST_SUCCESS } TEST_IMPL(mat3x4s_zero) { mat3x4s mat3x4_zero = GLMS_MAT3X4_ZERO; test_assert_mat3x4_eq_zero(mat3x4_zero.raw); TEST_SUCCESS } TEST_IMPL(mat4s_identity_init) { mat4s mat4_identity = GLMS_MAT4_IDENTITY_INIT; mat4 mat4_identity_a = GLM_MAT4_IDENTITY_INIT; test_assert_mat4_eq(mat4_identity.raw, mat4_identity_a); TEST_SUCCESS } TEST_IMPL(mat4s_zero_init) { mat4s mat4_zero = GLMS_MAT4_ZERO_INIT; mat4 mat4_zero_a = GLM_MAT4_ZERO_INIT; test_assert_mat4_eq(mat4_zero.raw, mat4_zero_a); TEST_SUCCESS } TEST_IMPL(mat4x2s_zero_init) { mat4x2s mat4x2_zero = GLMS_MAT4X2_ZERO_INIT; test_assert_mat4x2_eq_zero(mat4x2_zero.raw); TEST_SUCCESS } TEST_IMPL(mat4x2s_zero) { mat4x2s mat4x2_zero = GLMS_MAT4X2_ZERO; test_assert_mat4x2_eq_zero(mat4x2_zero.raw); TEST_SUCCESS } TEST_IMPL(mat4x3s_zero_init) { mat4x3s mat4x3_zero = GLMS_MAT4X3_ZERO_INIT; test_assert_mat4x3_eq_zero(mat4x3_zero.raw); TEST_SUCCESS } TEST_IMPL(mat4x3s_zero) { mat4x3s mat4x3_zero = GLMS_MAT4X3_ZERO; test_assert_mat4x3_eq_zero(mat4x3_zero.raw); TEST_SUCCESS } TEST_IMPL(quats_zero_init) { versors quat_zero = GLMS_QUAT_IDENTITY_INIT; versor quat_zero_a = GLM_QUAT_IDENTITY_INIT; test_assert_quat_eq(quat_zero.raw, quat_zero_a); TEST_SUCCESS } TEST_IMPL(vec3s_one_init) { vec3s vec3_one = GLMS_VEC3_ONE_INIT; vec3 vec3_one_a = GLM_VEC3_ONE_INIT; test_assert_vec3_eq(vec3_one.raw, vec3_one_a); TEST_SUCCESS } TEST_IMPL(vec3s_zero_init) { vec3s vec3_zero = GLMS_VEC3_ZERO_INIT; vec3 vec3_zero_a = GLM_VEC3_ZERO_INIT; test_assert_vec3_eq(vec3_zero.raw, vec3_zero_a); TEST_SUCCESS } TEST_IMPL(vec4s_black_init) { vec4s vec4_black = GLMS_VEC4_BLACK_INIT; vec4 vec4_black_a = GLM_VEC4_BLACK_INIT; test_assert_vec4_eq(vec4_black.raw, vec4_black_a); TEST_SUCCESS } TEST_IMPL(vec4s_one_init) { vec4s vec4_one = GLMS_VEC4_ONE_INIT; vec4 vec4_one_a = GLM_VEC4_ONE_INIT; test_assert_vec4_eq(vec4_one.raw, vec4_one_a); TEST_SUCCESS } TEST_IMPL(vec4s_zero_init) { vec4s vec4_zero = GLMS_VEC4_ZERO_INIT; vec4 vec4_zero_a = GLM_VEC4_ZERO_INIT; test_assert_vec4_eq(vec4_zero.raw, vec4_zero_a); TEST_SUCCESS } cglm-0.9.6/test/src/test_vec2.h000066400000000000000000000475061475344456400163210ustar00rootroot00000000000000/* * 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" #ifndef CGLM_TEST_VEC2_ONCE #define CGLM_TEST_VEC2_ONCE /* Macros */ TEST_IMPL(MACRO_GLM_VEC2_ONE_INIT) { vec2 v = GLM_VEC2_ONE_INIT; ASSERT(test_eq(v[0], 1.0f)) ASSERT(test_eq(v[1], 1.0f)) TEST_SUCCESS } TEST_IMPL(MACRO_GLM_VEC2_ZERO_INIT) { vec2 v = GLM_VEC2_ZERO_INIT; ASSERT(test_eq(v[0], 0.0f)) ASSERT(test_eq(v[1], 0.0f)) TEST_SUCCESS } TEST_IMPL(MACRO_GLM_VEC2_ONE) { ASSERT(test_eq(GLM_VEC2_ONE[0], 1.0f)) ASSERT(test_eq(GLM_VEC2_ONE[1], 1.0f)) TEST_SUCCESS } TEST_IMPL(MACRO_GLM_VEC2_ZERO) { ASSERT(test_eq(GLM_VEC2_ZERO[0], 0.0f)) ASSERT(test_eq(GLM_VEC2_ZERO[0], 0.0f)) TEST_SUCCESS } #endif /* CGLM_TEST_VEC2_ONCE */ TEST_IMPL(GLM_PREFIX, vec2) { vec4 v4 = {10.0f, 9.0f, 8.0f, 7.0f}; vec3 v3 = {11.0f, 12.0f, 13.0f}; vec2 v2; GLM(vec2)(v4, v2); ASSERT(test_eq(v2[0], v4[0])) ASSERT(test_eq(v2[1], v4[1])) GLM(vec2)(v3, v2); ASSERT(test_eq(v2[0], v3[0])) ASSERT(test_eq(v2[1], v3[1])) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec2_copy) { vec2 v1 = {10.0f, 9.0f}; vec2 v2 = {1.0f, 2.0f}; GLM(vec2_copy)(v1, v2); ASSERTIFY(test_assert_vec2_eq(v1, v2)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec2_zero) { vec2 v1 = {10.0f, 9.0f}; vec2 v2 = {1.0f, 2.0f}; GLM(vec2_zero)(v1); GLM(vec2_zero)(v2); ASSERTIFY(test_assert_vec2_eq(v1, GLM_VEC2_ZERO)) ASSERTIFY(test_assert_vec2_eq(v2, GLM_VEC2_ZERO)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec2_one) { vec2 v1 = {10.0f, 9.0f}; vec2 v2 = {1.0f, 2.0f}; GLM(vec2_one)(v1); GLM(vec2_one)(v2); ASSERTIFY(test_assert_vec2_eq(v1, GLM_VEC2_ONE)) ASSERTIFY(test_assert_vec2_eq(v2, GLM_VEC2_ONE)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec2_dot) { vec2 a = {10.0f, 9.0f}; vec2 b = {1.0f, 2.0f}; float dot1, dot2; dot1 = GLM(vec2_dot)(a, b); dot2 = a[0] * b[0] + a[1] * b[1]; ASSERT(test_eq(dot1, dot2)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec2_cross) { vec2 a = {10.0f, 9.0f}; vec2 b = {1.0f, 2.0f}; float cprod; cprod = a[0] * b[1] - a[1] * b[0]; ASSERT(test_eq(glm_vec2_cross(a, b), cprod)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec2_norm2) { vec2 a = {10.0f, 9.0f}; float n1, n2; n1 = GLM(vec2_norm2)(a); n2 = a[0] * a[0] + a[1] * a[1]; ASSERT(test_eq(n1, n2)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec2_norm) { vec2 a = {10.0f, 9.0f}; float n1, n2; n1 = GLM(vec2_norm)(a); n2 = sqrtf(a[0] * a[0] + a[1] * a[1]); ASSERT(test_eq(n1, n2)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec2_add) { vec2 a = {-10.0f, 9.0f}; vec2 b = {12.0f, 19.0f}; vec2 c, d; c[0] = a[0] + b[0]; c[1] = a[1] + b[1]; GLM(vec2_add)(a, b, d); ASSERTIFY(test_assert_vec2_eq(c, d)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec2_adds) { vec4 a = {-10.0f, 9.0f}; vec4 c, d; float s = 7.0f; c[0] = a[0] + s; c[1] = a[1] + s; GLM(vec2_adds)(a, s, d); ASSERTIFY(test_assert_vec2_eq(c, d)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec2_sub) { vec2 a = {-10.0f, 9.0f}; vec2 b = {12.0f, 19.0f}; vec2 c, d; c[0] = a[0] - b[0]; c[1] = a[1] - b[1]; GLM(vec2_sub)(a, b, d); ASSERTIFY(test_assert_vec2_eq(c, d)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec2_subs) { vec2 a = {-10.0f, 9.0f}; vec2 c, d; float s = 7.0f; c[0] = a[0] - s; c[1] = a[1] - s; GLM(vec2_subs)(a, s, d); ASSERTIFY(test_assert_vec2_eq(c, d)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec2_mul) { vec2 v1 = {2.0f, -3.0f}, v2 = {-3.0f, 4.0f}, v3; GLM(vec2_mul)(v1, v2, v3); ASSERT(test_eq(v1[0] * v2[0], v3[0])) ASSERT(test_eq(v1[1] * v2[1], v3[1])) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec2_scale) { vec2 v1 = {2.0f, -3.0f}, v2; float s = 7.0f; GLM(vec2_scale)(v1, s, v2); ASSERT(test_eq(v1[0] * s, v2[0])) ASSERT(test_eq(v1[1] * s, v2[1])) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec2_scale_as) { vec2 v1 = {2.0f, -3.0f}, v2; float s = 7.0f; float norm; GLM(vec2_scale_as)(v1, s, v2); norm = sqrtf(v1[0] * v1[0] + v1[1] * v1[1]); if (norm < FLT_EPSILON) { ASSERT(test_eq(v1[0], 0.0f)) ASSERT(test_eq(v1[1], 0.0f)) TEST_SUCCESS } norm = s / norm; ASSERT(test_eq(v1[0] * norm, v2[0])) ASSERT(test_eq(v1[1] * norm, v2[1])) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec2_div) { vec2 v1 = {2.0f, -3.0f}, v2 = {-3.0f, 4.0f}, v3; GLM(vec2_div)(v1, v2, v3); ASSERT(test_eq(v1[0] / v2[0], v3[0])) ASSERT(test_eq(v1[1] / v2[1], v3[1])) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec2_divs) { vec2 v1 = {2.0f, -3.0f}, v2; float s = 7.0f; GLM(vec2_divs)(v1, s, v2); ASSERT(test_eq(v1[0] / s, v2[0])) ASSERT(test_eq(v1[1] / s, v2[1])) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec2_addadd) { vec2 v1 = {2.0f, -3.0f}, v2 = {-3.0f, 4.0f}, v3 = {1.0f, 2.0f}, v4 = {1.0f, 2.0f}; GLM(vec2_addadd)(v1, v2, v4); ASSERT(test_eq(v3[0] + v1[0] + v2[0], v4[0])) ASSERT(test_eq(v3[1] + v1[1] + v2[1], v4[1])) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec2_subadd) { vec2 v1 = {2.0f, -3.0f}, v2 = {-3.0f, 4.0f}, v3 = {1.0f, 2.0f}, v4 = {1.0f, 2.0f}; GLM(vec2_subadd)(v1, v2, v4); ASSERT(test_eq(v3[0] + v1[0] - v2[0], v4[0])) ASSERT(test_eq(v3[1] + v1[1] - v2[1], v4[1])) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec2_muladd) { vec2 v1 = {2.0f, -3.0f}, v2 = {-3.0f, 4.0f}, v3 = {1.0f, 2.0f}, v4 = {1.0f, 2.0f}; GLM(vec2_muladd)(v1, v2, v4); ASSERT(test_eq(v3[0] + v1[0] * v2[0], v4[0])) ASSERT(test_eq(v3[1] + v1[1] * v2[1], v4[1])) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec2_muladds) { vec2 v1 = {2.0f, -3.0f}, v2 = {1.0f, 2.0f}, v3 = {1.0f, 2.0f}; float s = 9.0f; GLM(vec2_muladds)(v1, s, v3); ASSERT(test_eq(v2[0] + v1[0] * s, v3[0])) ASSERT(test_eq(v2[1] + v1[1] * s, v3[1])) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec2_maxadd) { vec2 v1 = {2.0f, -3.0f}, v2 = {-3.0f, 4.0f}, v3 = {1.0f, 2.0f}, v4 = {1.0f, 2.0f}; GLM(vec2_maxadd)(v1, v2, v4); ASSERT(test_eq(v3[0] + glm_max(v1[0], v2[0]), v4[0])) ASSERT(test_eq(v3[1] + glm_max(v1[1], v2[1]), v4[1])) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec2_minadd) { vec2 v1 = {2.0f, -3.0f}, v2 = {-3.0f, 4.0f}, v3 = {1.0f, 2.0f}, v4 = {1.0f, 2.0f}; GLM(vec2_minadd)(v1, v2, v4); ASSERT(test_eq(v3[0] + glm_min(v1[0], v2[0]), v4[0])) ASSERT(test_eq(v3[1] + glm_min(v1[1], v2[1]), v4[1])) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec2_subsub) { vec2 v1 = {2.0f, -3.0f}, v2 = {-3.0f, 4.0f}, v3 = {1.0f, 2.0f}, v4 = {1.0f, 2.0f}; GLM(vec2_subsub)(v1, v2, v4); ASSERT(test_eq(v3[0] - (v1[0] - v2[0]), v4[0])) ASSERT(test_eq(v3[1] - (v1[1] - v2[1]), v4[1])) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec2_addsub) { vec2 v1 = {2.0f, -3.0f}, v2 = {-3.0f, 4.0f}, v3 = {1.0f, 2.0f}, v4 = {1.0f, 2.0f}; GLM(vec2_addsub)(v1, v2, v4); ASSERT(test_eq(v3[0] - (v1[0] + v2[0]), v4[0])) ASSERT(test_eq(v3[1] - (v1[1] + v2[1]), v4[1])) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec2_mulsub) { vec2 v1 = {2.0f, -3.0f}, v2 = {-3.0f, 4.0f}, v3 = {1.0f, 2.0f}, v4 = {1.0f, 2.0f}; GLM(vec2_mulsub)(v1, v2, v4); ASSERT(test_eq(v3[0] - v1[0] * v2[0], v4[0])) ASSERT(test_eq(v3[1] - v1[1] * v2[1], v4[1])) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec2_mulsubs) { vec2 v1 = {2.0f, -3.0f}, v2 = {1.0f, 2.0f}, v3 = {1.0f, 2.0f}; float s = 9.0f; GLM(vec2_mulsubs)(v1, s, v3); ASSERT(test_eq(v2[0] - v1[0] * s, v3[0])) ASSERT(test_eq(v2[1] - v1[1] * s, v3[1])) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec2_maxsub) { vec2 v1 = {2.0f, -3.0f}, v2 = {-3.0f, 4.0f}, v3 = {1.0f, 2.0f}, v4 = {1.0f, 2.0f}; GLM(vec2_maxsub)(v1, v2, v4); ASSERT(test_eq(v3[0] - glm_max(v1[0], v2[0]), v4[0])) ASSERT(test_eq(v3[1] - glm_max(v1[1], v2[1]), v4[1])) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec2_minsub) { vec2 v1 = {2.0f, -3.0f}, v2 = {-3.0f, 4.0f}, v3 = {1.0f, 2.0f}, v4 = {1.0f, 2.0f}; GLM(vec2_minsub)(v1, v2, v4); ASSERT(test_eq(v3[0] - glm_min(v1[0], v2[0]), v4[0])) ASSERT(test_eq(v3[1] - glm_min(v1[1], v2[1]), v4[1])) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec2_negate_to) { vec2 v1 = {2.0f, -3.0f}, v2 = {-3.0f, 4.0f}, v3, v4; GLM(vec2_negate_to)(v1, v3); GLM(vec2_negate_to)(v2, v4); ASSERT(test_eq(-v1[0], v3[0])) ASSERT(test_eq(-v1[1], v3[1])) ASSERT(test_eq(-v2[0], v4[0])) ASSERT(test_eq(-v2[1], v4[1])) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec2_negate) { vec2 v1 = {2.0f, -3.0f}, v2 = {-3.0f, 4.0f}, v3 = {2.0f, -3.0f}, v4 = {-3.0f, 4.0f}; GLM(vec2_negate)(v1); GLM(vec2_negate)(v2); ASSERT(test_eq(-v1[0], v3[0])) ASSERT(test_eq(-v1[1], v3[1])) ASSERT(test_eq(-v2[0], v4[0])) ASSERT(test_eq(-v2[1], v4[1])) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec2_normalize) { vec2 v1 = {2.0f, -3.0f}, v2 = {2.0f, -3.0f}; float s = 1.0f; float norm; GLM(vec2_normalize)(v2); norm = sqrtf(v1[0] * v1[0] + v1[1] * v1[1]); if (norm < FLT_EPSILON) { ASSERT(test_eq(v1[0], 0.0f)) ASSERT(test_eq(v1[1], 0.0f)) TEST_SUCCESS } norm = s / norm; ASSERT(test_eq(v1[0] * norm, v2[0])) ASSERT(test_eq(v1[1] * norm, v2[1])) glm_vec2_zero(v1); GLM(vec2_normalize)(v1); ASSERTIFY(test_assert_vec2_eq(v1, GLM_VEC2_ZERO)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec2_normalize_to) { vec2 v1 = {2.0f, -3.0f}, v2; float s = 1.0f; float norm; GLM(vec2_normalize_to)(v1, v2); norm = sqrtf(v1[0] * v1[0] + v1[1] * v1[1]); if (norm < FLT_EPSILON) { ASSERT(test_eq(v1[0], 0.0f)) ASSERT(test_eq(v1[1], 0.0f)) TEST_SUCCESS } norm = s / norm; ASSERT(test_eq(v1[0] * norm, v2[0])) ASSERT(test_eq(v1[1] * norm, v2[1])) glm_vec2_zero(v1); GLM(vec2_normalize_to)(v1, v2); ASSERTIFY(test_assert_vec2_eq(v2, GLM_VEC2_ZERO)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec2_rotate) { vec2 v1 = {1.0f, 0.0f}; GLM(vec2_rotate)(v1, GLM_PI_2f, v1); ASSERT(test_eq(v1[0], 0.0f)) ASSERT(test_eq(v1[1], 1.0f)) GLM(vec2_rotate)(v1, GLM_PI_2f, v1); ASSERT(test_eq(v1[0], -1.0f)) ASSERT(test_eq(v1[1], 0.0f)) GLM(vec2_rotate)(v1, GLM_PI_2f, v1); ASSERT(test_eq(v1[0], 0.0f)) ASSERT(test_eq(v1[1], -1.0f)) GLM(vec2_rotate)(v1, GLM_PI_2f, v1); ASSERT(test_eq(v1[0], 1.0f)) ASSERT(test_eq(v1[1], 0.0f)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec2_center) { vec2 v1 = {1.0f, 1.0f}, v2 = {0.0f, 0.0f}; vec2 dest; GLM(vec2_center)(v1, v2, dest); ASSERTIFY(test_assert_vec2_eq(dest, (vec2){ 0.5f, 0.5f })) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec2_distance2) { vec2 v1 = {30.0f, 0.0f}, v2 = {0.0f, 0.0f}, v3 = {3.0f, 10.0f}, v4 = {0.46f, 4.0f}; float d; d = GLM(vec2_distance2)(v1, v2); ASSERT(test_eq(d, 30.0f * 30.0f)) d = GLM(vec2_distance2)(v3, v4); ASSERT(test_eq(powf(v3[0] - v4[0], 2.0f) + powf(v3[1] - v4[1], 2.0f), d)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec2_distance) { vec2 v1 = {30.0f, 0.0f}, v2 = {0.0f, 0.0f}, v3 = {3.0f, 10.0f}, v4 = {0.46f, 4.0f}; float d; d = GLM(vec2_distance)(v1, v2); ASSERT(test_eq(d, 30.0f)) d = GLM(vec2_distance)(v3, v4); ASSERT(test_eq(sqrtf(powf(v3[0] - v4[0], 2.0f) + powf(v3[1] - v4[1], 2.0f)), d)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec2_maxv) { vec2 v1, v2, v3; vec2 v5 = {-1.456f, -1.456f}; vec2 v6 = {11.0f, 11.0f}; vec2 v7 = {78.0f, -78.0f}; GLM(vec2_maxv)(v5, v6, v1); GLM(vec2_maxv)(v5, v7, v2); GLM(vec2_maxv)(v6, v7, v3); ASSERT(test_eq(v1[0], 11.0f)) ASSERT(test_eq(v1[1], 11.0f)) ASSERT(test_eq(v2[0], 78.0f)) ASSERT(test_eq(v2[1], -1.456f)) ASSERT(test_eq(v3[0], 78.0f)) ASSERT(test_eq(v3[1], 11.0f)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec2_minv) { vec2 v1, v2, v3; vec2 v5 = {-1.456f, -1.456f}; vec2 v6 = {11.0f, 11.0f}; vec2 v7 = {78.0f, -78.0f}; GLM(vec2_minv)(v5, v6, v1); GLM(vec2_minv)(v5, v7, v2); GLM(vec2_minv)(v6, v7, v3); ASSERT(test_eq(v1[0], -1.456f)) ASSERT(test_eq(v1[1], -1.456f)) ASSERT(test_eq(v2[0], -1.456f)) ASSERT(test_eq(v2[1], -78.0f)) ASSERT(test_eq(v3[0], 11.0f)) ASSERT(test_eq(v3[1], -78.0f)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec2_clamp) { vec2 v1 = {-1.456f, -11.456f}; vec2 v2 = {0.110f, 111.0f}; vec2 v3 = {78.0f, 32.0f}; GLM(vec2_clamp)(v1, -1.03f, 30.0f); GLM(vec2_clamp)(v2, 0.11f, 111.0f); GLM(vec2_clamp)(v3, -88.0f, 70.0f); ASSERT(test_eq(v1[0], -1.03f)) ASSERT(test_eq(v1[1], -1.03f)) ASSERT(test_eq(v2[0], 0.11f)) ASSERT(test_eq(v2[1], 111.0f)) ASSERT(test_eq(v3[0], 70.0f)) ASSERT(test_eq(v3[1], 32.0f)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec2_abs) { vec2 v1 = {2, -3}, v2 = {-12, -31}; vec2 v3, v4; vec2 v5 = {2, 3}, v6 = {12, 31}; GLM(vec2_abs)(v1, v3); GLM(vec2_abs)(v2, v4); ASSERTIFY(test_assert_vec2_eq(v3, v5)) ASSERTIFY(test_assert_vec2_eq(v4, v6)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec2_fract) { vec2 v1 = {2.104f, 3.012f}, v2 = {12.35f, 31.140f}, v3, v4; vec2 v5 = {0.104f, 0.012f}, v6 = {0.35f, 0.140f}; GLM(vec2_fract)(v1, v3); GLM(vec2_fract)(v2, v4); ASSERTIFY(test_assert_vec2_eq(v3, v5)) ASSERTIFY(test_assert_vec2_eq(v4, v6)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec2_floor) { vec2 v1 = {2.104f, 3.012f}, v2 = {12.35f, 31.140f}, v3, v4; vec2 v5 = {2.0f, 3.0f}, v6 = {12.0f, 31.0f}; GLM(vec2_floor)(v1, v3); GLM(vec2_floor)(v2, v4); ASSERTIFY(test_assert_vec2_eq(v3, v5)) ASSERTIFY(test_assert_vec2_eq(v4, v6)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec2_mods) { vec2 v1 = {2.104f, 3.012f}, v2 = {12.35f, 31.140f}, v3, v4; vec2 v5 = {0.104f, 0.012f}, v6 = {0.35f, 0.140f}; /* Mod 1 - leaves just the fractional part */ GLM(vec2_mods)(v1, 1.0f, v3); GLM(vec2_mods)(v2, 1.0f, v4); ASSERTIFY(test_assert_vec2_eq(v3, v5)) ASSERTIFY(test_assert_vec2_eq(v4, v6)) /* Mod 2 - parity + fractional part */ GLM(vec2_mods)(v1, 2.0f, v3); GLM(vec2_mods)(v2, 2.0f, v4); vec2 v7 = {0.104f, 1.012f}, v8 = {0.35f, 1.140f}; ASSERTIFY(test_assert_vec2_eq(v3, v7)) ASSERTIFY(test_assert_vec2_eq(v4, v8)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec2_swizzle) { vec2 v; v[0] = 1; v[1] = 2; GLM(vec2_swizzle)(v, GLM_SHUFFLE2(1, 0), v); ASSERTIFY(test_assert_vec2_eq(v, (vec2){2, 1})) GLM(vec2_swizzle)(v, GLM_SHUFFLE2(0, 0), v); ASSERTIFY(test_assert_vec2_eq(v, (vec2){1, 1})) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec2_lerp) { vec2 v1 = {-100.0f, -200.0f}; vec2 v2 = {100.0f, 200.0f}; vec2 v3; GLM(vec2_lerp)(v1, v2, 0.5f, v3); ASSERT(test_eq(v3[0], 0.0f)) ASSERT(test_eq(v3[1], 0.0f)) GLM(vec2_lerp)(v1, v2, 0.75f, v3); ASSERT(test_eq(v3[0], 50.0f)) ASSERT(test_eq(v3[1], 100.0f)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec2_steps) { vec2 v1 = {-100.0f, -200.0f}; vec2 v2; GLM(vec2_steps)(-2.5f, v1, v2); ASSERT(test_eq(v2[0], 0.0f)) ASSERT(test_eq(v2[1], 0.0f)) GLM(vec2_steps)(-150.0f, v1, v2); ASSERT(test_eq(v2[0], 1.0f)) ASSERT(test_eq(v2[1], 0.0f)) GLM(vec2_steps)(-300.0f, v1, v2); ASSERT(test_eq(v2[0], 1.0f)) ASSERT(test_eq(v2[1], 1.0f)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec2_stepr) { vec2 v1 = {-2.5f, -150.0f}; vec2 v2; GLM(vec2_stepr)(v1, -200.0f, v2); ASSERT(test_eq(v2[0], 0.0f)) ASSERT(test_eq(v2[1], 0.0f)) GLM(vec2_stepr)(v1, -150.0f, v2); ASSERT(test_eq(v2[0], 0.0f)) ASSERT(test_eq(v2[1], 1.0f)) GLM(vec2_stepr)(v1, 0.0f, v2); ASSERT(test_eq(v2[0], 1.0f)) ASSERT(test_eq(v2[1], 1.0f)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec2_step) { vec2 v1 = {-100.0f, -200.0f}; vec2 s1 = {-100.0f, 0.0f}; vec2 s2 = {100.0f, -220.0f}; vec2 s3 = {100.0f, 200.0f}; vec2 v2; GLM(vec2_step)(s1, v1, v2); ASSERT(test_eq(v2[0], 1.0f)) ASSERT(test_eq(v2[1], 0.0f)) GLM(vec2_step)(s2, v1, v2); ASSERT(test_eq(v2[0], 0.0f)) ASSERT(test_eq(v2[1], 1.0f)) GLM(vec2_step)(s3, v1, v2); ASSERT(test_eq(v2[0], 0.0f)) ASSERT(test_eq(v2[1], 0.0f)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec2_complex_mul) { vec2 v1 = { 3.0f, 5.0f }, v2 = { 7.0f, 11.0f }, v3 = { cosf(GLM_PIf/4.0f), sinf(GLM_PIf/4.0f) }; GLM(vec2_complex_mul)(v1, v2, v2); ASSERTIFY(test_assert_vec2_eq(v2, (vec2){ -34, 68 })) GLM(vec2_complex_mul)(v3, v3, v3); ASSERTIFY(test_assert_vec2_eq(v3, (vec2){ 0.0f, 1.0f })) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec2_complex_div) { vec2 v1 = { -34.0f, 68.0f }, v2 = { 3.0f, 5.0f }, v3 = { cosf(GLM_PIf/4.0f), sinf(GLM_PIf/4.0f) }, v4 = { cosf(GLM_PIf/4.0f), -sinf(GLM_PIf/4.0f) }; GLM(vec2_complex_div)(v1, v2, v2); ASSERTIFY(test_assert_vec2_eq(v2, (vec2){ 7.0f, 11.0f })) GLM(vec2_complex_div)(v3, v4, v4); ASSERTIFY(test_assert_vec2_eq(v4, (vec2){ 0.0f, 1.0f })) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec2_make) { float src[6] = { 7.2f, 1.0f, 2.5f, 6.1f, 17.7f, 4.3f }; vec2 dest[3]; float *srcp = src; unsigned int i, j; for (i = 0, j = 0; i < sizeof(src) / sizeof(float); i+=2,j++) { GLM(vec2_make)(srcp + i, dest[j]); ASSERT(test_eq(src[ i ], dest[j][0])); ASSERT(test_eq(src[i+1], dest[j][1])); } TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec2_reflect) { vec2 dest; /* Reflecting off a "horizontal" surface in 2D */ vec2 I1 = {1.0f, -1.0f}; /* Incoming vector */ vec2 N1 = {0.0f, 1.0f}; /* Normal vector */ GLM(vec2_reflect)(I1, N1, dest); ASSERT(fabsf(dest[0] - 1.0f) < 0.00001f && fabsf(dest[1] - 1.0f) < 0.00001f); /* Expect reflection upwards */ /* Reflecting at an angle in 2D */ vec2 I2 = {sqrtf(2)/2, -sqrtf(2)/2}; /* Incoming vector at 45 degrees */ vec2 N2 = {0.0f, 1.0f}; /* Upwards normal vector */ GLM(vec2_reflect)(I2, N2, dest); ASSERT(fabsf(dest[0] - sqrtf(2)/2) < 0.00001f && fabsf(dest[1] - sqrtf(2)/2) < 0.00001f); /* Expect reflection upwards */ /* Reflecting off a line in 2D representing a "vertical" surface analogy */ vec2 I3 = {1.0f, 0.0f}; /* Incoming vector */ vec2 N3 = {-1.0f, 0.0f}; /* Normal vector representing a "vertical" line */ GLM(vec2_reflect)(I3, N3, dest); ASSERT(fabsf(dest[0] + 1.0f) < 0.00001f && fabsf(dest[1]) < 0.00001f); /* Expect reflection to the left */ TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec2_refract) { vec2 v = {sqrtf(0.5f), -sqrtf(0.5f)}; /* Incoming vector at 45 degrees to normal */ vec2 N = {0.0f, 1.0f}; /* Surface normal */ vec2 dest; float eta; float r; /* Water to Air (eta = 1.33/1.0) */ eta = 1.33f / 1.0f; r = GLM(vec2_refract)(v, N, eta, dest); // In 2D, we expect a similar bending behavior as in 3D, so we check dest[1] if (!(dest[0] == 0.0f && dest[1] == 0.0f)) { ASSERT(dest[1] < -0.3f); // Refracted ray bends away from the normal ASSERT(r == true); } else { ASSERT(dest[0] == 0.0f && dest[1] == 0.0f); // Total internal reflection ASSERT(r == false); } /* Air to Glass (eta = 1.0 / 1.5) */ eta = 1.0f / 1.5f; r = GLM(vec2_refract)(v, N, eta, dest); ASSERT(r == true); ASSERT(dest[1] < -sqrtf(0.5f)); // Expect bending towards the normal /* Glass to Water (eta = 1.5 / 1.33) */ eta = 1.5f / 1.33f; r = GLM(vec2_refract)(v, N, eta, dest); ASSERT(r == true); ASSERT(dest[1] < -0.6f); // Expect bending towards the normal, less bending than air to glass /* Diamond to Air (eta = 2.42 / 1.0) */ eta = 2.42f / 1.0f; r = GLM(vec2_refract)(v, N, eta, dest); if (!(dest[0] == 0.0f && dest[1] == 0.0f)) { /* High potential for total internal reflection, but if it occurs, expect significant bending */ ASSERT(dest[1] < -sqrtf(0.5f)); ASSERT(r == true); } else { ASSERT(dest[0] == 0.0f && dest[1] == 0.0f); // Total internal reflection ASSERT(r == false); } TEST_SUCCESS } cglm-0.9.6/test/src/test_vec3.h000066400000000000000000001341101475344456400163060ustar00rootroot00000000000000/* * 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" #define TEST_GLM_SHUFFLE3(z, y, x) (((z) << 4) | ((y) << 2) | (x)) #ifndef CGLM_TEST_VEC3_ONCE #define CGLM_TEST_VEC3_ONCE /* Macros */ TEST_IMPL(MACRO_GLM_VEC3_ONE_INIT) { vec3 v = GLM_VEC3_ONE_INIT; ASSERT(test_eq(v[0], 1.0f)) ASSERT(test_eq(v[1], 1.0f)) ASSERT(test_eq(v[2], 1.0f)) TEST_SUCCESS } TEST_IMPL(MACRO_GLM_VEC3_ZERO_INIT) { vec3 v = GLM_VEC3_ZERO_INIT; ASSERT(test_eq(v[0], 0.0f)) ASSERT(test_eq(v[1], 0.0f)) ASSERT(test_eq(v[2], 0.0f)) TEST_SUCCESS } TEST_IMPL(MACRO_GLM_VEC3_ONE) { ASSERT(test_eq(GLM_VEC3_ONE[0], 1.0f)) ASSERT(test_eq(GLM_VEC3_ONE[1], 1.0f)) ASSERT(test_eq(GLM_VEC3_ONE[2], 1.0f)) TEST_SUCCESS } TEST_IMPL(MACRO_GLM_VEC3_ZERO) { ASSERT(test_eq(GLM_VEC3_ZERO[0], 0.0f)) ASSERT(test_eq(GLM_VEC3_ZERO[1], 0.0f)) ASSERT(test_eq(GLM_VEC3_ZERO[2], 0.0f)) TEST_SUCCESS } TEST_IMPL(MACRO_GLM_YUP) { ASSERT(test_eq(GLM_YUP[0], 0.0f)) ASSERT(test_eq(GLM_YUP[1], 1.0f)) ASSERT(test_eq(GLM_YUP[2], 0.0f)) TEST_SUCCESS } TEST_IMPL(MACRO_GLM_ZUP) { ASSERT(test_eq(GLM_ZUP[0], 0.0f)) ASSERT(test_eq(GLM_ZUP[1], 0.0f)) ASSERT(test_eq(GLM_ZUP[2], 1.0f)) TEST_SUCCESS } TEST_IMPL(MACRO_GLM_XUP) { ASSERT(test_eq(GLM_XUP[0], 1.0f)) ASSERT(test_eq(GLM_XUP[1], 0.0f)) ASSERT(test_eq(GLM_XUP[2], 0.0f)) TEST_SUCCESS } TEST_IMPL(MACRO_GLM_FORWARD_RH) { ASSERT(test_eq(GLM_FORWARD[0], 0.0f)) ASSERT(test_eq(GLM_FORWARD[1], 0.0f)) ASSERT(test_eq(GLM_FORWARD[2], -1.0f)) TEST_SUCCESS } TEST_IMPL(MACRO_GLM_SHUFFLE3) { ASSERT(TEST_GLM_SHUFFLE3(1, 0, 0) == GLM_SHUFFLE3(1, 0, 0)) ASSERT(TEST_GLM_SHUFFLE3(0, 1, 0) == GLM_SHUFFLE3(0, 1, 0)) ASSERT(TEST_GLM_SHUFFLE3(0, 0, 1) == GLM_SHUFFLE3(0, 0, 1)) ASSERT(TEST_GLM_SHUFFLE3(1, 0, 0) == GLM_SHUFFLE3(1, 0, 0)) ASSERT(TEST_GLM_SHUFFLE3(1, 0, 1) == GLM_SHUFFLE3(1, 0, 1)) TEST_SUCCESS } TEST_IMPL(MACRO_GLM_XXX) { ASSERT(TEST_GLM_SHUFFLE3(0, 0, 0) == GLM_XXX) TEST_SUCCESS } TEST_IMPL(MACRO_GLM_YYY) { ASSERT(TEST_GLM_SHUFFLE3(1, 1, 1) == GLM_YYY) TEST_SUCCESS } TEST_IMPL(MACRO_GLM_ZZZ) { ASSERT(TEST_GLM_SHUFFLE3(2, 2, 2) == GLM_ZZZ) TEST_SUCCESS } TEST_IMPL(MACRO_GLM_ZYX) { ASSERT(TEST_GLM_SHUFFLE3(0, 1, 2) == GLM_ZYX) TEST_SUCCESS } /* Deprecated */ TEST_IMPL(MACRO_glm_vec3_dup) { vec3 v1 = {13.0f, 12.0f, 11.0f}, v2; glm_vec3_dup(v1, v2); ASSERTIFY(test_assert_vec3_eq(v1, v2)) TEST_SUCCESS } TEST_IMPL(MACRO_glm_vec3_flipsign) { vec3 v1 = {13.0f, -12.0f, 11.0f}, v2 = {13.0f, -12.0f, 11.0f}, v3 = {-13.0f, 12.0f, -11.0f}; glm_vec3_flipsign(v1); glmc_vec3_flipsign(v2); ASSERTIFY(test_assert_vec3_eq(v1, v3)) ASSERTIFY(test_assert_vec3_eq(v2, v3)) TEST_SUCCESS } TEST_IMPL(MACRO_glm_vec3_flipsign_to) { vec3 v1 = {13.0f, -12.0f, 11.0f}, v2 = {-13.0f, 12.0f, -11.0f}, v3, v4; glm_vec3_flipsign_to(v1, v3); glmc_vec3_flipsign_to(v1, v4); ASSERTIFY(test_assert_vec3_eq(v2, v3)) ASSERTIFY(test_assert_vec3_eq(v2, v4)) TEST_SUCCESS } TEST_IMPL(MACRO_glm_vec3_inv) { vec3 v1 = {13.0f, -12.0f, 11.0f}, v2 = {13.0f, -12.0f, 11.0f}, v3 = {-13.0f, 12.0f, -11.0f}; glm_vec3_inv(v1); glmc_vec3_inv(v2); ASSERTIFY(test_assert_vec3_eq(v1, v3)) ASSERTIFY(test_assert_vec3_eq(v2, v3)) TEST_SUCCESS } TEST_IMPL(MACRO_glm_vec3_inv_to) { vec3 v1 = {13.0f, -12.0f, 11.0f}, v2 = {-13.0f, 12.0f, -11.0f}, v3, v4; glm_vec3_inv_to(v1, v3); glmc_vec3_inv_to(v1, v4); ASSERTIFY(test_assert_vec3_eq(v3, v4)) ASSERTIFY(test_assert_vec3_eq(v2, v3)) TEST_SUCCESS } TEST_IMPL(MACRO_glm_vec3_mulv) { vec3 v1 = {2.0f, -3.0f, 4.0f}, v2 = {-3.0f, 4.0f, -5.0f}, v3, v4; glm_vec3_mulv(v1, v2, v3); glmc_vec3_mulv(v1, v2, v4); ASSERTIFY(test_assert_vec3_eq(v3, v4)) ASSERT(test_eq(v1[0] * v2[0], v3[0])) ASSERT(test_eq(v1[1] * v2[1], v3[1])) ASSERT(test_eq(v1[2] * v2[2], v3[2])) TEST_SUCCESS } #endif /* CGLM_TEST_VEC3_ONCE */ /* --- */ TEST_IMPL(GLM_PREFIX, vec3) { vec4 v4 = {10.0f, 9.0f, 8.0f, 7.0f}; vec3 v3; GLM(vec3)(v4, v3); ASSERT(test_eq(v3[0], v4[0])) ASSERT(test_eq(v3[1], v4[1])) ASSERT(test_eq(v3[2], v4[2])) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec3_copy) { vec3 v1 = {10.0f, 9.0f, 8.0f}; vec3 v2 = {1.0f, 2.0f, 3.0f}; GLM(vec3_copy)(v1, v2); ASSERTIFY(test_assert_vec3_eq(v1, v2)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec3_zero) { vec3 v1 = {10.0f, 9.0f, 8.0f}; vec3 v2 = {1.0f, 2.0f, 3.0f}; GLM(vec3_zero)(v1); GLM(vec3_zero)(v2); ASSERTIFY(test_assert_vec3_eq(v1, GLM_VEC3_ZERO)) ASSERTIFY(test_assert_vec3_eq(v2, GLM_VEC3_ZERO)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec3_one) { vec3 v1 = {10.0f, 9.0f, 8.0f}; vec3 v2 = {1.0f, 2.0f, 3.0f}; GLM(vec3_one)(v1); GLM(vec3_one)(v2); ASSERTIFY(test_assert_vec3_eq(v1, GLM_VEC3_ONE)) ASSERTIFY(test_assert_vec3_eq(v1, GLM_VEC3_ONE)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec3_dot) { vec3 a = {10.0f, 9.0f, 8.0f}; vec3 b = {1.0f, 2.0f, 3.0f}; float dot1, dot2; dot1 = GLM(vec3_dot)(a, b); dot2 = a[0] * b[0] + a[1] * b[1] + a[2] * b[2]; ASSERT(test_eq(dot1, dot2)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, dot) { /* SAME AS VEC3_DOT */ vec3 a = {10.0f, 9.0f, 8.0f}; vec3 b = {1.0f, 2.0f, 3.0f}; float dot1, dot2; dot1 = GLM(vec3_dot)(a, b); dot2 = a[0] * b[0] + a[1] * b[1] + a[2] * b[2]; ASSERT(test_eq(dot1, dot2)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec3_norm2) { vec3 a = {10.0f, 9.0f, 8.0f}; float n1, n2; n1 = GLM(vec3_norm2)(a); n2 = a[0] * a[0] + a[1] * a[1] + a[2] * a[2]; ASSERT(test_eq(n1, n2)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec3_norm) { vec3 a = {10.0f, 9.0f, 8.0f}; float n1, n2; n1 = GLM(vec3_norm)(a); n2 = sqrtf(a[0] * a[0] + a[1] * a[1] + a[2] * a[2]); ASSERT(test_eq(n1, n2)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec3_norm_one) { vec3 a = {-10.0f, 9.0f, -8.0f}; float n1, n2; n1 = GLM(vec3_norm_one)(a); n2 = fabsf(a[0]) + fabsf(a[1]) + fabsf(a[2]); ASSERT(test_eq(n1, n2)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec3_norm_inf) { vec3 a = {-10.0f, 9.0f, -8.0f}; float n1, n2; n1 = GLM(vec3_norm_inf)(a); n2 = fabsf(a[0]); if (n2 < fabsf(a[1])) n2 = fabsf(a[1]); if (n2 < fabsf(a[2])) n2 = fabsf(a[2]); ASSERT(test_eq(n1, n2)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec3_add) { vec3 a = {-10.0f, 9.0f, -8.0f}; vec3 b = {12.0f, 19.0f, -18.0f}; vec3 c, d; c[0] = a[0] + b[0]; c[1] = a[1] + b[1]; c[2] = a[2] + b[2]; GLM(vec3_add)(a, b, d); ASSERTIFY(test_assert_vec3_eq(c, d)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec3_adds) { vec3 a = {-10.0f, 9.0f, -8.0f}; vec3 c, d; float s = 7.0f; c[0] = a[0] + s; c[1] = a[1] + s; c[2] = a[2] + s; GLM(vec3_adds)(a, s, d); ASSERTIFY(test_assert_vec3_eq(c, d)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec3_sub) { vec3 a = {-10.0f, 9.0f, -8.0f}; vec3 b = {12.0f, 19.0f, -18.0f}; vec3 c, d; c[0] = a[0] - b[0]; c[1] = a[1] - b[1]; c[2] = a[2] - b[2]; GLM(vec3_sub)(a, b, d); ASSERTIFY(test_assert_vec3_eq(c, d)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec3_subs) { vec3 a = {-10.0f, 9.0f, -8.0f}; vec3 c, d; float s = 7.0f; c[0] = a[0] - s; c[1] = a[1] - s; c[2] = a[2] - s; GLM(vec3_subs)(a, s, d); ASSERTIFY(test_assert_vec3_eq(c, d)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec3_mul) { vec3 v1 = {2.0f, -3.0f, 4.0f}, v2 = {-3.0f, 4.0f, -5.0f}, v3; GLM(vec3_mul)(v1, v2, v3); ASSERT(test_eq(v1[0] * v2[0], v3[0])) ASSERT(test_eq(v1[1] * v2[1], v3[1])) ASSERT(test_eq(v1[2] * v2[2], v3[2])) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec3_scale) { vec3 v1 = {2.0f, -3.0f, 4.0f}, v2; float s = 7.0f; GLM(vec3_scale)(v1, s, v2); ASSERT(test_eq(v1[0] * s, v2[0])) ASSERT(test_eq(v1[1] * s, v2[1])) ASSERT(test_eq(v1[2] * s, v2[2])) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec3_scale_as) { vec3 v1 = {2.0f, -3.0f, 4.0f}, v2; float s = 7.0f; float norm; GLM(vec3_scale_as)(v1, s, v2); norm = sqrtf(v1[0] * v1[0] + v1[1] * v1[1] + v1[2] * v1[2]); if (norm < FLT_EPSILON) { ASSERT(test_eq(v1[0], 0.0f)) ASSERT(test_eq(v1[1], 0.0f)) ASSERT(test_eq(v1[2], 0.0f)) TEST_SUCCESS } norm = s / norm; ASSERT(test_eq(v1[0] * norm, v2[0])) ASSERT(test_eq(v1[1] * norm, v2[1])) ASSERT(test_eq(v1[2] * norm, v2[2])) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec3_div) { vec3 v1 = {2.0f, -3.0f, 4.0f}, v2 = {-3.0f, 4.0f, -5.0f}, v3; GLM(vec3_div)(v1, v2, v3); ASSERT(test_eq(v1[0] / v2[0], v3[0])) ASSERT(test_eq(v1[1] / v2[1], v3[1])) ASSERT(test_eq(v1[2] / v2[2], v3[2])) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec3_divs) { vec3 v1 = {2.0f, -3.0f, 4.0f}, v2; float s = 7.0f; GLM(vec3_divs)(v1, s, v2); ASSERT(test_eq(v1[0] / s, v2[0])) ASSERT(test_eq(v1[1] / s, v2[1])) ASSERT(test_eq(v1[2] / s, v2[2])) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec3_addadd) { vec3 v1 = {2.0f, -3.0f, 4.0f}, v2 = {-3.0f, 4.0f, -5.0f}, v3 = {1.0f, 2.0f, 3.0f}, v4 = {1.0f, 2.0f, 3.0f}; GLM(vec3_addadd)(v1, v2, v4); ASSERT(test_eq(v3[0] + v1[0] + v2[0], v4[0])) ASSERT(test_eq(v3[1] + v1[1] + v2[1], v4[1])) ASSERT(test_eq(v3[2] + v1[2] + v2[2], v4[2])) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec3_subadd) { vec3 v1 = {2.0f, -3.0f, 4.0f}, v2 = {-3.0f, 4.0f, -5.0f}, v3 = {1.0f, 2.0f, 3.0f}, v4 = {1.0f, 2.0f, 3.0f}; GLM(vec3_subadd)(v1, v2, v4); ASSERT(test_eq(v3[0] + v1[0] - v2[0], v4[0])) ASSERT(test_eq(v3[1] + v1[1] - v2[1], v4[1])) ASSERT(test_eq(v3[2] + v1[2] - v2[2], v4[2])) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec3_muladd) { vec3 v1 = {2.0f, -3.0f, 4.0f}, v2 = {-3.0f, 4.0f, -5.0f}, v3 = {1.0f, 2.0f, 3.0f}, v4 = {1.0f, 2.0f, 3.0f}; GLM(vec3_muladd)(v1, v2, v4); ASSERT(test_eq(v3[0] + v1[0] * v2[0], v4[0])) ASSERT(test_eq(v3[1] + v1[1] * v2[1], v4[1])) ASSERT(test_eq(v3[2] + v1[2] * v2[2], v4[2])) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec3_muladds) { vec3 v1 = {2.0f, -3.0f, 4.0f}, v2 = {1.0f, 2.0f, 3.0f}, v3 = {1.0f, 2.0f, 3.0f}; float s = 9.0f; GLM(vec3_muladds)(v1, s, v3); ASSERT(test_eq(v2[0] + v1[0] * s, v3[0])) ASSERT(test_eq(v2[1] + v1[1] * s, v3[1])) ASSERT(test_eq(v2[2] + v1[2] * s, v3[2])) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec3_maxadd) { vec3 v1 = {2.0f, -3.0f, 4.0f}, v2 = {-3.0f, 4.0f, -5.0f}, v3 = {1.0f, 2.0f, 3.0f}, v4 = {1.0f, 2.0f, 3.0f}; GLM(vec3_maxadd)(v1, v2, v4); ASSERT(test_eq(v3[0] + glm_max(v1[0], v2[0]), v4[0])) ASSERT(test_eq(v3[1] + glm_max(v1[1], v2[1]), v4[1])) ASSERT(test_eq(v3[2] + glm_max(v1[2], v2[2]), v4[2])) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec3_minadd) { vec3 v1 = {2.0f, -3.0f, 4.0f}, v2 = {-3.0f, 4.0f, -5.0f}, v3 = {1.0f, 2.0f, 3.0f}, v4 = {1.0f, 2.0f, 3.0f}; GLM(vec3_minadd)(v1, v2, v4); ASSERT(test_eq(v3[0] + glm_min(v1[0], v2[0]), v4[0])) ASSERT(test_eq(v3[1] + glm_min(v1[1], v2[1]), v4[1])) ASSERT(test_eq(v3[2] + glm_min(v1[2], v2[2]), v4[2])) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec3_subsub) { vec3 v1 = {2.0f, -3.0f, 4.0f}, v2 = {-3.0f, 4.0f, -5.0f}, v3 = {1.0f, 2.0f, 3.0f}, v4 = {1.0f, 2.0f, 3.0f}; GLM(vec3_subsub)(v1, v2, v4); ASSERT(test_eq(v3[0] - (v1[0] - v2[0]), v4[0])) ASSERT(test_eq(v3[1] - (v1[1] - v2[1]), v4[1])) ASSERT(test_eq(v3[2] - (v1[2] - v2[2]), v4[2])) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec3_addsub) { vec3 v1 = {2.0f, -3.0f, 4.0f}, v2 = {-3.0f, 4.0f, -5.0f}, v3 = {1.0f, 2.0f, 3.0f}, v4 = {1.0f, 2.0f, 3.0f}; GLM(vec3_addsub)(v1, v2, v4); ASSERT(test_eq(v3[0] - (v1[0] + v2[0]), v4[0])) ASSERT(test_eq(v3[1] - (v1[1] + v2[1]), v4[1])) ASSERT(test_eq(v3[2] - (v1[2] + v2[2]), v4[2])) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec3_mulsub) { vec3 v1 = {2.0f, -3.0f, 4.0f}, v2 = {-3.0f, 4.0f, -5.0f}, v3 = {1.0f, 2.0f, 3.0f}, v4 = {1.0f, 2.0f, 3.0f}; GLM(vec3_mulsub)(v1, v2, v4); ASSERT(test_eq(v3[0] - v1[0] * v2[0], v4[0])) ASSERT(test_eq(v3[1] - v1[1] * v2[1], v4[1])) ASSERT(test_eq(v3[2] - v1[2] * v2[2], v4[2])) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec3_mulsubs) { vec3 v1 = {2.0f, -3.0f, 4.0f}, v2 = {1.0f, 2.0f, 3.0f}, v3 = {1.0f, 2.0f, 3.0f}; float s = 9.0f; GLM(vec3_mulsubs)(v1, s, v3); ASSERT(test_eq(v2[0] - v1[0] * s, v3[0])) ASSERT(test_eq(v2[1] - v1[1] * s, v3[1])) ASSERT(test_eq(v2[2] - v1[2] * s, v3[2])) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec3_maxsub) { vec3 v1 = {2.0f, -3.0f, 4.0f}, v2 = {-3.0f, 4.0f, -5.0f}, v3 = {1.0f, 2.0f, 3.0f}, v4 = {1.0f, 2.0f, 3.0f}; GLM(vec3_maxsub)(v1, v2, v4); ASSERT(test_eq(v3[0] - glm_max(v1[0], v2[0]), v4[0])) ASSERT(test_eq(v3[1] - glm_max(v1[1], v2[1]), v4[1])) ASSERT(test_eq(v3[2] - glm_max(v1[2], v2[2]), v4[2])) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec3_minsub) { vec3 v1 = {2.0f, -3.0f, 4.0f}, v2 = {-3.0f, 4.0f, -5.0f}, v3 = {1.0f, 2.0f, 3.0f}, v4 = {1.0f, 2.0f, 3.0f}; GLM(vec3_minsub)(v1, v2, v4); ASSERT(test_eq(v3[0] - glm_min(v1[0], v2[0]), v4[0])) ASSERT(test_eq(v3[1] - glm_min(v1[1], v2[1]), v4[1])) ASSERT(test_eq(v3[2] - glm_min(v1[2], v2[2]), v4[2])) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec3_negate_to) { vec3 v1 = {2.0f, -3.0f, 4.0f}, v2 = {-3.0f, 4.0f, -5.0f}, v3, v4; GLM(vec3_negate_to)(v1, v3); GLM(vec3_negate_to)(v2, v4); ASSERT(test_eq(-v1[0], v3[0])) ASSERT(test_eq(-v1[1], v3[1])) ASSERT(test_eq(-v1[2], v3[2])) ASSERT(test_eq(-v2[0], v4[0])) ASSERT(test_eq(-v2[1], v4[1])) ASSERT(test_eq(-v2[2], v4[2])) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec3_negate) { vec3 v1 = {2.0f, -3.0f, 4.0f}, v2 = {-3.0f, 4.0f, -5.0f}, v3 = {2.0f, -3.0f, 4.0f}, v4 = {-3.0f, 4.0f, -5.0f}; GLM(vec3_negate)(v1); GLM(vec3_negate)(v2); ASSERT(test_eq(-v1[0], v3[0])) ASSERT(test_eq(-v1[1], v3[1])) ASSERT(test_eq(-v1[2], v3[2])) ASSERT(test_eq(-v2[0], v4[0])) ASSERT(test_eq(-v2[1], v4[1])) ASSERT(test_eq(-v2[2], v4[2])) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec3_normalize) { vec3 v1 = {2.0f, -3.0f, 4.0f}, v2 = {2.0f, -3.0f, 4.0f}; float s = 1.0f; float norm; GLM(vec3_normalize)(v2); norm = sqrtf(v1[0] * v1[0] + v1[1] * v1[1] + v1[2] * v1[2]); if (norm < FLT_EPSILON) { ASSERT(test_eq(v1[0], 0.0f)) ASSERT(test_eq(v1[1], 0.0f)) ASSERT(test_eq(v1[2], 0.0f)) TEST_SUCCESS } norm = s / norm; ASSERT(test_eq(v1[0] * norm, v2[0])) ASSERT(test_eq(v1[1] * norm, v2[1])) ASSERT(test_eq(v1[2] * norm, v2[2])) glm_vec3_zero(v1); GLM(vec3_normalize)(v1); ASSERTIFY(test_assert_vec3_eq(v1, GLM_VEC3_ZERO)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec3_normalize_to) { vec3 v1 = {2.0f, -3.0f, 4.0f}, v2; float s = 1.0f; float norm; GLM(vec3_normalize_to)(v1, v2); norm = sqrtf(v1[0] * v1[0] + v1[1] * v1[1] + v1[2] * v1[2]); if (norm < FLT_EPSILON) { ASSERT(test_eq(v1[0], 0.0f)) ASSERT(test_eq(v1[1], 0.0f)) ASSERT(test_eq(v1[2], 0.0f)) TEST_SUCCESS } norm = s / norm; ASSERT(test_eq(v1[0] * norm, v2[0])) ASSERT(test_eq(v1[1] * norm, v2[1])) ASSERT(test_eq(v1[2] * norm, v2[2])) glm_vec3_zero(v1); GLM(vec3_normalize_to)(v1, v2); ASSERTIFY(test_assert_vec3_eq(v2, GLM_VEC3_ZERO)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, normalize) { /* SAME AS VEC3_NORMALIZE */ vec3 v1 = {2.0f, -3.0f, 4.0f}, v2 = {2.0f, -3.0f, 4.0f}; float s = 1.0f; float norm; GLM(vec3_normalize)(v2); norm = sqrtf(v1[0] * v1[0] + v1[1] * v1[1] + v1[2] * v1[2]); if (norm < FLT_EPSILON) { ASSERT(test_eq(v1[0], 0.0f)) ASSERT(test_eq(v1[1], 0.0f)) ASSERT(test_eq(v1[2], 0.0f)) TEST_SUCCESS } norm = s / norm; ASSERT(test_eq(v1[0] * norm, v2[0])) ASSERT(test_eq(v1[1] * norm, v2[1])) ASSERT(test_eq(v1[2] * norm, v2[2])) glm_vec3_zero(v1); GLM(vec3_normalize)(v1); ASSERTIFY(test_assert_vec3_eq(v1, GLM_VEC3_ZERO)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, normalize_to) { /* SAME AS VEC3_NORMALIZE_TO */ vec3 v1 = {2.0f, -3.0f, 4.0f}, v2; float s = 1.0f; float norm; GLM(vec3_normalize_to)(v1, v2); norm = sqrtf(v1[0] * v1[0] + v1[1] * v1[1] + v1[2] * v1[2]); if (norm < FLT_EPSILON) { ASSERT(test_eq(v1[0], 0.0f)) ASSERT(test_eq(v1[1], 0.0f)) ASSERT(test_eq(v1[2], 0.0f)) TEST_SUCCESS } norm = s / norm; ASSERT(test_eq(v1[0] * norm, v2[0])) ASSERT(test_eq(v1[1] * norm, v2[1])) ASSERT(test_eq(v1[2] * norm, v2[2])) glm_vec3_zero(v1); GLM(vec3_normalize_to)(v1, v2); ASSERTIFY(test_assert_vec3_eq(v2, GLM_VEC3_ZERO)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec3_cross) { /* (u2.v3 - u3.v2, u3.v1 - u1.v3, u1.v2 - u2.v1) */ vec3 v1 = {2.0f, -3.0f, 4.0f}, v2 = {12.0f, -31.0f, 43.0f}, v3, v4; GLM(vec3_cross)(v1, v2, v3); v4[0] = v1[1] * v2[2] - v1[2] * v2[1]; v4[1] = v1[2] * v2[0] - v1[0] * v2[2]; v4[2] = v1[0] * v2[1] - v1[1] * v2[0]; ASSERTIFY(test_assert_vec3_eq(v3, v4)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec3_crossn) { /* (u2.v3 - u3.v2, u3.v1 - u1.v3, u1.v2 - u2.v1) */ vec3 v1 = {2.0f, -3.0f, 4.0f}, v2 = {12.0f, -31.0f, 43.0f}, v3, v4; GLM(vec3_crossn)(v1, v2, v3); v4[0] = v1[1] * v2[2] - v1[2] * v2[1]; v4[1] = v1[2] * v2[0] - v1[0] * v2[2]; v4[2] = v1[0] * v2[1] - v1[1] * v2[0]; glm_normalize(v4); ASSERTIFY(test_assert_vec3_eq(v3, v4)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, cross) { /* SAME AS VEC3_CROSS */ /* (u2.v3 - u3.v2, u3.v1 - u1.v3, u1.v2 - u2.v1) */ vec3 v1 = {2.0f, -3.0f, 4.0f}, v2 = {12.0f, -31.0f, 43.0f}, v3, v4; GLM(vec3_cross)(v1, v2, v3); v4[0] = v1[1] * v2[2] - v1[2] * v2[1]; v4[1] = v1[2] * v2[0] - v1[0] * v2[2]; v4[2] = v1[0] * v2[1] - v1[1] * v2[0]; ASSERTIFY(test_assert_vec3_eq(v3, v4)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec3_angle) { vec3 v1 = {1.0f, 0.0f, 0.0f}, v2 = {1.0f, 0.0f, 1.0f}, v3 = {0.0f, 1.0f, 0.0f}; float a; a = GLM(vec3_angle)(v1, v1); #ifndef CGLM_FAST_MATH ASSERT(!isinf(a)) ASSERT(!isnan(a)) #endif ASSERT(test_eq(a, 0.0f)) a = GLM(vec3_angle)(v1, v2); #ifndef CGLM_FAST_MATH ASSERT(!isinf(a)) ASSERT(!isnan(a)) #endif ASSERT(test_eq(a, GLM_PI_4f)) a = GLM(vec3_angle)(v1, v3); #ifndef CGLM_FAST_MATH ASSERT(!isinf(a)) ASSERT(!isnan(a)) #endif ASSERT(test_eq(a, GLM_PI_2f)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec3_rotate) { vec3 v1 = {1.0f, 0.0f, 0.0f}, v2 = {1.0f, 1.0f, 1.0f}; /* rotate X around Y = -Z */ GLM(vec3_rotate)(v1, GLM_PI_2f, GLM_YUP); ASSERT(test_eq(v1[0], 0.0f)) ASSERT(test_eq(v1[1], 0.0f)) ASSERT(test_eq(v1[2], -1.0f)) /* rotate -Z around X = Y */ GLM(vec3_rotate)(v1, GLM_PI_2f, GLM_XUP); ASSERT(test_eq(v1[0], 0.0f)) ASSERT(test_eq(v1[1], 1.0f)) ASSERT(test_eq(v1[2], 0.0f)) /* rotate Y around Z = -X */ GLM(vec3_rotate)(v1, GLM_PI_2f, GLM_ZUP); ASSERT(test_eq(v1[0], -1.0f)) ASSERT(test_eq(v1[1], 0.0f)) ASSERT(test_eq(v1[2], 0.0f)) /* rotate v2 around Y by 90deg */ GLM(vec3_rotate)(v2, GLM_PI_2f, GLM_YUP); ASSERT(test_eq(v2[0], 1.0f)) ASSERT(test_eq(v2[1], 1.0f)) ASSERT(test_eq(v2[2], -1.0f)) /* rotate v2 around Y by 90deg */ GLM(vec3_rotate)(v2, GLM_PI_2f, GLM_YUP); ASSERT(test_eq(v2[0], -1.0f)) ASSERT(test_eq(v2[1], 1.0f)) ASSERT(test_eq(v2[2], -1.0f)) /* rotate v2 around Y by 90deg */ GLM(vec3_rotate)(v2, GLM_PI_2f, GLM_YUP); ASSERT(test_eq(v2[0], -1.0f)) ASSERT(test_eq(v2[1], 1.0f)) ASSERT(test_eq(v2[2], 1.0f)) /* rotate v2 around X by 90deg */ GLM(vec3_rotate)(v2, GLM_PI_2f, GLM_XUP); ASSERT(test_eq(v2[0], -1.0f)) ASSERT(test_eq(v2[1], -1.0f)) ASSERT(test_eq(v2[2], 1.0f)) /* rotate v2 around Z by 90deg */ GLM(vec3_rotate)(v2, GLM_PI_2f, GLM_ZUP); ASSERT(test_eq(v2[0], 1.0f)) ASSERT(test_eq(v2[1], -1.0f)) ASSERT(test_eq(v2[2], 1.0f)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec3_rotate_m4) { vec3 v1 = {1.0f, 0.0f, 0.0f}, v2 = {1.0f, 1.0f, 1.0f}; mat4 x, y, z; glm_rotate_make(x, GLM_PI_2f, GLM_XUP); glm_rotate_make(y, GLM_PI_2f, GLM_YUP); glm_rotate_make(z, GLM_PI_2f, GLM_ZUP); /* rotate X around Y = -Z */ GLM(vec3_rotate_m4)(y, v1, v1); ASSERT(test_eq(v1[0], 0.0f)) ASSERT(test_eq(v1[1], 0.0f)) ASSERT(test_eq(v1[2], -1.0f)) /* rotate -Z around X = Y */ GLM(vec3_rotate_m4)(x, v1, v1); ASSERT(test_eq(v1[0], 0.0f)) ASSERT(test_eq(v1[1], 1.0f)) ASSERT(test_eq(v1[2], 0.0f)) /* rotate Y around X = -X */ GLM(vec3_rotate_m4)(z, v1, v1); ASSERT(test_eq(v1[0], -1.0f)) ASSERT(test_eq(v1[1], 0.0f)) ASSERT(test_eq(v1[2], 0.0f)) /* rotate v2 around Y by 90deg */ GLM(vec3_rotate_m4)(y, v2, v2); ASSERT(test_eq(v2[0], 1.0f)) ASSERT(test_eq(v2[1], 1.0f)) ASSERT(test_eq(v2[2], -1.0f)) /* rotate v2 around Y by 90deg */ GLM(vec3_rotate_m4)(y, v2, v2); ASSERT(test_eq(v2[0], -1.0f)) ASSERT(test_eq(v2[1], 1.0f)) ASSERT(test_eq(v2[2], -1.0f)) /* rotate v2 around Y by 90deg */ GLM(vec3_rotate_m4)(y, v2, v2); ASSERT(test_eq(v2[0], -1.0f)) ASSERT(test_eq(v2[1], 1.0f)) ASSERT(test_eq(v2[2], 1.0f)) /* rotate v2 around X by 90deg */ GLM(vec3_rotate_m4)(x, v2, v2); ASSERT(test_eq(v2[0], -1.0f)) ASSERT(test_eq(v2[1], -1.0f)) ASSERT(test_eq(v2[2], 1.0f)) /* rotate v2 around Z by 90deg */ GLM(vec3_rotate_m4)(z, v2, v2); ASSERT(test_eq(v2[0], 1.0f)) ASSERT(test_eq(v2[1], -1.0f)) ASSERT(test_eq(v2[2], 1.0f)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec3_rotate_m3) { vec3 v1 = {1.0f, 0.0f, 0.0f}, v2 = {1.0f, 1.0f, 1.0f}; mat4 x0, y0, z0; mat3 x, y, z; glm_rotate_make(x0, GLM_PI_2f, GLM_XUP); glm_rotate_make(y0, GLM_PI_2f, GLM_YUP); glm_rotate_make(z0, GLM_PI_2f, GLM_ZUP); glm_mat4_pick3(x0, x); glm_mat4_pick3(y0, y); glm_mat4_pick3(z0, z); /* rotate X around Y = -Z */ GLM(vec3_rotate_m3)(y, v1, v1); ASSERT(test_eq(v1[0], 0.0f)) ASSERT(test_eq(v1[1], 0.0f)) ASSERT(test_eq(v1[2], -1.0f)) /* rotate -Z around X = Y */ GLM(vec3_rotate_m3)(x, v1, v1); ASSERT(test_eq(v1[0], 0.0f)) ASSERT(test_eq(v1[1], 1.0f)) ASSERT(test_eq(v1[2], 0.0f)) /* rotate Y around Z = -X */ GLM(vec3_rotate_m3)(z, v1, v1); ASSERT(test_eq(v1[0], -1.0f)) ASSERT(test_eq(v1[1], 0.0f)) ASSERT(test_eq(v1[2], 0.0f)) /* rotate v2 around Y by 90deg */ GLM(vec3_rotate_m3)(y, v2, v2); ASSERT(test_eq(v2[0], 1.0f)) ASSERT(test_eq(v2[1], 1.0f)) ASSERT(test_eq(v2[2], -1.0f)) /* rotate v2 around Y by 90deg */ GLM(vec3_rotate_m3)(y, v2, v2); ASSERT(test_eq(v2[0], -1.0f)) ASSERT(test_eq(v2[1], 1.0f)) ASSERT(test_eq(v2[2], -1.0f)) /* rotate v2 around Y by 90deg */ GLM(vec3_rotate_m3)(y, v2, v2); ASSERT(test_eq(v2[0], -1.0f)) ASSERT(test_eq(v2[1], 1.0f)) ASSERT(test_eq(v2[2], 1.0f)) /* rotate v2 around X by 90deg */ GLM(vec3_rotate_m3)(x, v2, v2); ASSERT(test_eq(v2[0], -1.0f)) ASSERT(test_eq(v2[1], -1.0f)) ASSERT(test_eq(v2[2], 1.0f)) /* rotate v2 around Z by 90deg */ GLM(vec3_rotate_m3)(z, v2, v2); ASSERT(test_eq(v2[0], 1.0f)) ASSERT(test_eq(v2[1], -1.0f)) ASSERT(test_eq(v2[2], 1.0f)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec3_proj) { vec3 v1 = {3.0f, 4.0f, 0.0f}, v2 = {10.0f, 0.0f, 0.0f}, v3 = {0.0f, 10.0f, 0.0f}, v4 = {3.0f, 0.0f, 0.0f}, v5 = {0.0f, 4.0f, 0.0f}, v6; GLM(vec3_proj)(v1, v2, v6); ASSERTIFY(test_assert_vec3_eq(v4, v6)) GLM(vec3_proj)(v1, v3, v6); ASSERTIFY(test_assert_vec3_eq(v5, v6)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec3_center) { vec3 v1 = {30.0f, 0.0f, 0.0f}, v2 = {0.0f, 0.0f, 0.0f}, v3 = {15.0f, 0.0f, 0.0f}, v4 = {3.0f, 10.0f, 120.0f}, v5 = {0.46f, 4.0f, 14.0f}, v6; GLM(vec3_center)(v1, v2, v6); ASSERTIFY(test_assert_vec3_eq(v3, v6)) GLM(vec3_center)(v4, v5, v6); ASSERT(test_eq((v4[0] + v5[0]) * 0.5f, v6[0])) ASSERT(test_eq((v4[1] + v5[1]) * 0.5f, v6[1])) ASSERT(test_eq((v4[2] + v5[2]) * 0.5f, v6[2])) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec3_distance2) { vec3 v1 = {30.0f, 0.0f, 0.0f}, v2 = {0.0f, 0.0f, 0.0f}, v3 = {3.0f, 10.0f, 120.0f}, v4 = {0.46f, 4.0f, 14.0f}; float d; d = GLM(vec3_distance2)(v1, v2); ASSERT(test_eq(d, 30.0f * 30.0f)) d = GLM(vec3_distance2)(v3, v4); ASSERT(test_eq(powf(v3[0] - v4[0], 2.0f) + powf(v3[1] - v4[1], 2.0f) + powf(v3[2] - v4[2], 2.0f), d)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec3_distance) { vec3 v1 = {30.0f, 0.0f, 0.0f}, v2 = {0.0f, 0.0f, 0.0f}, v3 = {3.0f, 10.0f, 120.0f}, v4 = {0.46f, 4.0f, 14.0f}; float d; d = GLM(vec3_distance)(v1, v2); ASSERT(test_eq(d, 30.0f)) d = GLM(vec3_distance)(v3, v4); ASSERT(test_eq(sqrtf(powf(v3[0] - v4[0], 2.0f) + powf(v3[1] - v4[1], 2.0f) + powf(v3[2] - v4[2], 2.0f)), d)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec3_maxv) { vec3 v1, v2, v3; vec3 v5 = {-1.456f, -1.456f, 241.456f}; vec3 v6 = {11.0f, 11.0f, 11.0f}; vec3 v7 = {78.0f, -78.0f, 7.0f}; GLM(vec3_maxv)(v5, v6, v1); GLM(vec3_maxv)(v5, v7, v2); GLM(vec3_maxv)(v6, v7, v3); ASSERT(test_eq(v1[0], 11.0f)) ASSERT(test_eq(v1[1], 11.0f)) ASSERT(test_eq(v1[2], 241.456f)) ASSERT(test_eq(v2[0], 78.0f)) ASSERT(test_eq(v2[1], -1.456f)) ASSERT(test_eq(v2[2], 241.456f)) ASSERT(test_eq(v3[0], 78.0f)) ASSERT(test_eq(v3[1], 11.0f)) ASSERT(test_eq(v3[2], 11.0f)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec3_minv) { vec3 v1, v2, v3; vec3 v5 = {-1.456f, -1.456f, 241.456f}; vec3 v6 = {11.0f, 11.0f, 11.0f}; vec3 v7 = {78.0f, -78.0f, 7.0f}; GLM(vec3_minv)(v5, v6, v1); GLM(vec3_minv)(v5, v7, v2); GLM(vec3_minv)(v6, v7, v3); ASSERT(test_eq(v1[0], -1.456f)) ASSERT(test_eq(v1[1], -1.456f)) ASSERT(test_eq(v1[2], 11.0f)) ASSERT(test_eq(v2[0], -1.456f)) ASSERT(test_eq(v2[1], -78.0f)) ASSERT(test_eq(v2[2], 7.0f)) ASSERT(test_eq(v3[0], 11.0f)) ASSERT(test_eq(v3[1], -78.0f)) ASSERT(test_eq(v3[2], 7.0f)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec3_ortho) { vec3 v1, v2, v3, v4 = {1.f, 1.f, 1.f}; vec3 v5, v6, v7, v8; float a; test_rand_vec3(v1); test_rand_vec3(v2); test_rand_vec3(v3); GLM(vec3_ortho)(v1, v5); GLM(vec3_ortho)(v2, v6); GLM(vec3_ortho)(v3, v7); GLM(vec3_ortho)(v4, v8); a = glm_vec3_angle(v1, v5); #ifndef CGLM_FAST_MATH ASSERT(!isinf(a)) ASSERT(!isnan(a)) #endif ASSERT(test_eq(a, GLM_PI_2f)) a = glm_vec3_angle(v2, v6); #ifndef CGLM_FAST_MATH ASSERT(!isinf(a)) ASSERT(!isnan(a)) #endif ASSERT(test_eq(a, GLM_PI_2f)) a = glm_vec3_angle(v3, v7); #ifndef CGLM_FAST_MATH ASSERT(!isinf(a)) ASSERT(!isnan(a)) #endif ASSERT(test_eq(a, GLM_PI_2f)) a = glm_vec3_angle(v4, v8); #ifndef CGLM_FAST_MATH ASSERT(!isinf(a)) ASSERT(!isnan(a)) #endif ASSERT(test_eq(a, GLM_PI_2f)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec3_clamp) { vec3 v1 = {-1.456f, -11.456f, 31.456f}; vec3 v2 = {0.110f, 111.0f, 11.0f}; vec3 v3 = {78.0f, 32.0f, -78.0f}; GLM(vec3_clamp)(v1, -1.03f, 30.0f); GLM(vec3_clamp)(v2, 0.11f, 111.0f); GLM(vec3_clamp)(v3, -88.0f, 70.0f); ASSERT(test_eq(v1[0], -1.03f)) ASSERT(test_eq(v1[1], -1.03f)) ASSERT(test_eq(v1[2], 30.0f)) ASSERT(test_eq(v2[0], 0.11f)) ASSERT(test_eq(v2[1], 111.0f)) ASSERT(test_eq(v2[2], 11.0f)) ASSERT(test_eq(v3[0], 70.0f)) ASSERT(test_eq(v3[1], 32.0f)) ASSERT(test_eq(v3[2], -78.0f)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec3_lerp) { vec3 v1 = {-100.0f, -200.0f, -10.0f}; vec3 v2 = {100.0f, 200.0f, 10.0f}; vec3 v3; GLM(vec3_lerp)(v1, v2, 0.5f, v3); ASSERT(test_eq(v3[0], 0.0f)) ASSERT(test_eq(v3[1], 0.0f)) ASSERT(test_eq(v3[2], 0.0f)) GLM(vec3_lerp)(v1, v2, 0.75f, v3); ASSERT(test_eq(v3[0], 50.0f)) ASSERT(test_eq(v3[1], 100.0f)) ASSERT(test_eq(v3[2], 5.0f)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec3_lerpc) { vec3 v1 = {-100.0f, -200.0f, -10.0f}; vec3 v2 = {100.0f, 200.0f, 10.0f}; vec3 v3; GLM(vec3_lerpc)(v1, v2, 0.5f, v3); ASSERT(test_eq(v3[0], 0.0f)) ASSERT(test_eq(v3[1], 0.0f)) ASSERT(test_eq(v3[2], 0.0f)) GLM(vec3_lerpc)(v1, v2, 0.75f, v3); ASSERT(test_eq(v3[0], 50.0f)) ASSERT(test_eq(v3[1], 100.0f)) ASSERT(test_eq(v3[2], 5.0f)) GLM(vec3_lerpc)(v1, v2, -1.75f, v3); ASSERT(test_eq(v3[0], -100.0f)) ASSERT(test_eq(v3[1], -200.0f)) ASSERT(test_eq(v3[2], -10.0f)) GLM(vec3_lerpc)(v1, v2, 1.75f, v3); ASSERT(test_eq(v3[0], 100.0f)) ASSERT(test_eq(v3[1], 200.0f)) ASSERT(test_eq(v3[2], 10.0f)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec3_mix) { vec3 v1 = {-100.0f, -200.0f, -10.0f}; vec3 v2 = {100.0f, 200.0f, 10.0f}; vec3 v3; GLM(vec3_mix)(v1, v2, 0.5f, v3); ASSERT(test_eq(v3[0], 0.0f)) ASSERT(test_eq(v3[1], 0.0f)) ASSERT(test_eq(v3[2], 0.0f)) GLM(vec3_mix)(v1, v2, 0.75f, v3); ASSERT(test_eq(v3[0], 50.0f)) ASSERT(test_eq(v3[1], 100.0f)) ASSERT(test_eq(v3[2], 5.0f)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec3_mixc) { vec3 v1 = {-100.0f, -200.0f, -10.0f}; vec3 v2 = {100.0f, 200.0f, 10.0f}; vec3 v3; GLM(vec3_mixc)(v1, v2, 0.5f, v3); ASSERT(test_eq(v3[0], 0.0f)) ASSERT(test_eq(v3[1], 0.0f)) ASSERT(test_eq(v3[2], 0.0f)) GLM(vec3_mixc)(v1, v2, 0.75f, v3); ASSERT(test_eq(v3[0], 50.0f)) ASSERT(test_eq(v3[1], 100.0f)) ASSERT(test_eq(v3[2], 5.0f)) GLM(vec3_mixc)(v1, v2, -1.75f, v3); ASSERT(test_eq(v3[0], -100.0f)) ASSERT(test_eq(v3[1], -200.0f)) ASSERT(test_eq(v3[2], -10.0f)) GLM(vec3_mixc)(v1, v2, 1.75f, v3); ASSERT(test_eq(v3[0], 100.0f)) ASSERT(test_eq(v3[1], 200.0f)) ASSERT(test_eq(v3[2], 10.0f)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec3_steps) { vec3 v1 = {-100.0f, -200.0f, -10.0f}; vec3 v2; GLM(vec3_steps)(-2.5f, v1, v2); ASSERT(test_eq(v2[0], 0.0f)) ASSERT(test_eq(v2[1], 0.0f)) ASSERT(test_eq(v2[2], 0.0f)) GLM(vec3_steps)(-10.0f, v1, v2); ASSERT(test_eq(v2[0], 0.0f)) ASSERT(test_eq(v2[1], 0.0f)) ASSERT(test_eq(v2[2], 1.0f)) GLM(vec3_steps)(-1000.0f, v1, v2); ASSERT(test_eq(v2[0], 1.0f)) ASSERT(test_eq(v2[1], 1.0f)) ASSERT(test_eq(v2[2], 1.0f)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec3_stepr) { vec3 v1 = {-2.5f, -10.0f, -1000.0f}; vec3 v2; GLM(vec3_stepr)(v1, -100.0f, v2); ASSERT(test_eq(v2[0], 0.0f)) ASSERT(test_eq(v2[1], 0.0f)) ASSERT(test_eq(v2[2], 1.0f)) GLM(vec3_stepr)(v1, -5.0f, v2); ASSERT(test_eq(v2[0], 0.0f)) ASSERT(test_eq(v2[1], 1.0f)) ASSERT(test_eq(v2[2], 1.0f)) GLM(vec3_stepr)(v1, -1.0f, v2); ASSERT(test_eq(v2[0], 1.0f)) ASSERT(test_eq(v2[1], 1.0f)) ASSERT(test_eq(v2[2], 1.0f)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec3_step) { vec3 v1 = {-100.0f, -200.0f, -10.0f}; vec3 s1 = {-100.0f, 0.0f, 10.0f}; vec3 s2 = {100.0f, -220.0f, -10.0f}; vec3 s3 = {100.0f, 200.0f, 10.0f}; vec3 v2; GLM(vec3_step)(s1, v1, v2); ASSERT(test_eq(v2[0], 1.0f)) ASSERT(test_eq(v2[1], 0.0f)) ASSERT(test_eq(v2[2], 0.0f)) GLM(vec3_step)(s2, v1, v2); ASSERT(test_eq(v2[0], 0.0f)) ASSERT(test_eq(v2[1], 1.0f)) ASSERT(test_eq(v2[2], 1.0f)) GLM(vec3_step)(s3, v1, v2); ASSERT(test_eq(v2[0], 0.0f)) ASSERT(test_eq(v2[1], 0.0f)) ASSERT(test_eq(v2[2], 0.0f)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec3_smoothstep_uni) { vec3 v1 = {-100.0f, -200.0f, -10.0f}; vec3 v2; GLM(vec3_smoothstep_uni)(-200.0f, -100.0f, v1, v2); ASSERT(test_eq_th(v2[0], 1.0f, 1e-5f)) ASSERT(test_eq_th(v2[1], 0.0f, 1e-5f)) ASSERT(test_eq_th(v2[2], 1.0f, 1e-5f)) GLM(vec3_smoothstep_uni)(-250.0f, -200.0f, v1, v2); ASSERT(test_eq_th(v2[0], 1.0f, 1e-5f)) ASSERT(test_eq_th(v2[1], 1.0f, 1e-5f)) ASSERT(test_eq_th(v2[2], 1.0f, 1e-5f)) GLM(vec3_smoothstep_uni)(-200.0f, 200, v1, v2); ASSERT(v2[0] > 0.0f && v2[0] < 0.25f) ASSERT(test_eq(v2[1], 0.0f)) ASSERT(v2[2] > 0.0f && v2[2] < 0.5f) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec3_smoothstep) { vec3 v1 = {-100.0f, -200.0f, -10.0f}; vec3 e1_0 = {-100.0f, 0.0f, -11.0f}; vec3 e1_1 = {50.0f, 10.0f, 20.0f}; vec3 e2_0 = {-180.0f, -300.0f, -93.0f}; vec3 e2_1 = {100.0f, 120.0f, -10.0f}; vec3 e3_0 = {-12.0f, 100.0f, 0.0f}; vec3 e3_1 = {100.0f, 200.0f, 10.0f}; vec3 v2; GLM(vec3_smoothstep)(e1_0, e1_1, v1, v2); ASSERT(test_eq_th(v2[0], 0.0f, 1e-5f)) ASSERT(test_eq_th(v2[1], 0.0f, 1e-5f)) ASSERT(v2[2] > 0.0f && v2[2] < 0.1f) GLM(vec3_smoothstep)(e2_0, e2_1, v1, v2); ASSERT(v2[0] > 0.0f && v2[0] < 0.25f) ASSERT(v2[1] > 0.0f && v2[1] < 0.15f) ASSERT(test_eq_th(v2[2], 1.0f, 1e-5f)) GLM(vec3_smoothstep)(e3_0, e3_1, v1, v2); ASSERT(test_eq_th(v2[0], 0.0f, 1e-5f)) ASSERT(test_eq_th(v2[1], 0.0f, 1e-5f)) ASSERT(test_eq_th(v2[2], 0.0f, 1e-5f)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec3_smoothinterp) { vec3 e1_0 = {-100.0f, 0.0f, -11.0f}; vec3 e1_1 = {50.0f, 10.0f, 20.0f}; vec3 e2_0 = {80.0f, -220.0f, -19.0f}; vec3 e2_1 = {100.0f, -200.0f, -10.0f}; vec3 e3_0 = {-12.0f, 100.0f, 0.0f}; vec3 e3_1 = {100.0f, 200.0f, 10.0f}; vec3 v2; GLM(vec3_smoothinterp)(e1_0, e1_1, 0.5f, v2); ASSERT(v2[0] >= e1_0[0] && v2[0] <= e1_1[0]) ASSERT(v2[1] >= e1_0[1] && v2[1] <= e1_1[1]) ASSERT(v2[2] >= e1_0[2] && v2[2] <= e1_1[2]) GLM(vec3_smoothinterp)(e2_0, e2_1, 0.5, v2); ASSERT(v2[0] >= e2_0[0] && v2[0] <= e2_1[0]) ASSERT(v2[1] >= e2_0[1] && v2[1] <= e2_1[1]) ASSERT(v2[2] >= e2_0[2] && v2[2] <= e2_1[2]) GLM(vec3_smoothinterp)(e3_0, e3_1, 1.0, v2); ASSERT(v2[0] >= e3_0[0] && v2[0] <= e3_1[0]) ASSERT(v2[1] >= e3_0[1] && v2[1] <= e3_1[1]) ASSERT(v2[2] >= e3_0[2] && v2[2] <= e3_1[2]) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec3_smoothinterpc) { vec3 e1_0 = {-100.0f, 0.0f, -11.0f}; vec3 e1_1 = {50.0f, 10.0f, 20.0f}; vec3 e2_0 = {80.0f, -220.0f, -19.0f}; vec3 e2_1 = {100.0f, -200.0f, -10.0f}; vec3 e3_0 = {-12.0f, 100.0f, 0.0f}; vec3 e3_1 = {100.0f, 200.0f, 10.0f}; vec3 v2; GLM(vec3_smoothinterpc)(e1_0, e1_1, -0.5f, v2); ASSERT(v2[0] >= e1_0[0] && v2[0] <= e1_1[0]) ASSERT(v2[1] >= e1_0[1] && v2[1] <= e1_1[1]) ASSERT(v2[2] >= e1_0[2] && v2[2] <= e1_1[2]) GLM(vec3_smoothinterpc)(e2_0, e2_1, 0.5f, v2); ASSERT(v2[0] >= e2_0[0] && v2[0] <= e2_1[0]) ASSERT(v2[1] >= e2_0[1] && v2[1] <= e2_1[1]) ASSERT(v2[2] >= e2_0[2] && v2[2] <= e2_1[2]) GLM(vec3_smoothinterpc)(e3_0, e3_1, 2.0f, v2); ASSERT(v2[0] >= e3_0[0] && v2[0] <= e3_1[0]) ASSERT(v2[1] >= e3_0[1] && v2[1] <= e3_1[1]) ASSERT(v2[2] >= e3_0[2] && v2[2] <= e3_1[2]) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec3_swizzle) { vec3 v; /* ZYX */ v[0] = 1; v[1] = 2; v[2] = 3; GLM(vec3_swizzle)(v, GLM_ZYX, v); ASSERTIFY(test_assert_vec3_eq(v, (vec3){3, 2, 1})) GLM(vec3_swizzle)(v, GLM_XXX, v); ASSERTIFY(test_assert_vec3_eq(v, (vec3){3, 3, 3})) v[0] = 1; v[1] = 2; v[2] = 3; GLM(vec3_swizzle)(v, GLM_YYY, v); ASSERTIFY(test_assert_vec3_eq(v, (vec3){2, 2, 2})) v[0] = 1; v[1] = 2; v[2] = 3; GLM(vec3_swizzle)(v, GLM_ZZZ, v); ASSERTIFY(test_assert_vec3_eq(v, (vec3){3, 3, 3})) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec3_broadcast) { vec3 v1, v2, v3; vec3 v5 = {-1.456f, -1.456f, -1.456f}; vec3 v6 = {11.0f, 11.0f, 11.0f}; vec3 v7 = {78.0f, 78.0f, 78.0f}; GLM(vec3_broadcast)(-1.456f, v1); GLM(vec3_broadcast)(11.0f, v2); GLM(vec3_broadcast)(78.0f, v3); ASSERTIFY(test_assert_vec3_eq(v1, v5)) ASSERTIFY(test_assert_vec3_eq(v2, v6)) ASSERTIFY(test_assert_vec3_eq(v3, v7)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec3_fill) { vec3 v1, v2, v3; vec3 v5 = {-1.456f, -1.456f, -1.456f}; vec3 v6 = {11.0f, 11.0f, 11.0f}; vec3 v7 = {78.0f, 78.0f, 78.0f}; GLM(vec3_fill)(v1, -1.456f); GLM(vec3_fill)(v2, 11.0f); GLM(vec3_fill)(v3, 78.0f); ASSERTIFY(test_assert_vec3_eq(v1, v5)) ASSERTIFY(test_assert_vec3_eq(v2, v6)) ASSERTIFY(test_assert_vec3_eq(v3, v7)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec3_eq) { vec3 v1, v2, v3; GLM(vec3_fill)(v1, -1.456f); GLM(vec3_fill)(v2, 11.0f); GLM(vec3_fill)(v3, 78.1f); ASSERT(GLM(vec3_eq)(v1, -1.456f)) ASSERT(GLM(vec3_eq)(v2, 11.0f)) ASSERT(!GLM(vec3_eq)(v3, 78.0f)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec3_eq_eps) { vec3 v1, v2, v3; GLM(vec3_fill)(v1, -1.456f); GLM(vec3_fill)(v2, 11.0f); GLM(vec3_fill)(v3, 78.1f); ASSERT(GLM(vec3_eq_eps)(v1, -1.456f)) ASSERT(GLM(vec3_eq_eps)(v2, 11.0f)) ASSERT(!GLM(vec3_eq_eps)(v3, 78.0f)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec3_eq_all) { vec3 v1, v2, v3; vec3 v4 = {2.104f, -3.012f, -4.10f}; vec3 v5 = {-12.35f, -31.140f, -43.502f}; GLM(vec3_fill)(v1, -1.456f); GLM(vec3_fill)(v2, 11.0f); GLM(vec3_fill)(v3, 78.0f); ASSERT(GLM(vec3_eq_all)(v1)) ASSERT(GLM(vec3_eq_all)(v2)) ASSERT(GLM(vec3_eq_all)(v3)) ASSERT(!GLM(vec3_eq_all)(v4)) ASSERT(!GLM(vec3_eq_all)(v5)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec3_eqv) { vec3 v1, v2, v3, v4, v5; vec3 v6 = {-1.456f, -1.456f, -1.456f}; vec3 v7 = {11.0f, 11.0f, 11.0f}; vec3 v8 = {78.0f, 78.0f, -43.502f}; GLM(vec3_fill)(v1, -1.456f); GLM(vec3_fill)(v2, 11.0f); GLM(vec3_fill)(v3, 78.0f); test_rand_vec3(v4); test_rand_vec3(v5); ASSERT(GLM(vec3_eqv)(v1, v6)) ASSERT(GLM(vec3_eqv)(v2, v7)) ASSERT(!GLM(vec3_eqv)(v3, v8)) ASSERT(!GLM(vec3_eqv)(v4, v5)) ASSERT(GLM(vec3_eqv)(v5, v5)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec3_eqv_eps) { vec3 v1, v2, v3, v4, v5; vec3 v6 = {-1.456f, -1.456f, -1.456f}; vec3 v7 = {11.0f, 11.0f, 11.0f}; vec3 v8 = {78.0f, 78.0f, -43.502f}; GLM(vec3_fill)(v1, -1.456f); GLM(vec3_fill)(v2, 11.0f); GLM(vec3_fill)(v3, 78.0f); test_rand_vec3(v4); test_rand_vec3(v5); ASSERT(GLM(vec3_eqv_eps)(v1, v6)) ASSERT(GLM(vec3_eqv_eps)(v2, v7)) ASSERT(!GLM(vec3_eqv_eps)(v3, v8)) ASSERT(!GLM(vec3_eqv_eps)(v4, v5)) ASSERT(GLM(vec3_eqv_eps)(v5, v5)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec3_max) { vec3 v1 = {2.104f, -3.012f, -4.10f}, v2 = {-12.35f, -31.140f, -43.502f}; #ifndef CGLM_FAST_MATH vec3 v3 = {INFINITY, 0.0f, 0.0f}/*, v4 = {NAN, INFINITY, 2.0f}*/; #endif vec3 /*v5 = {NAN, -1.0f, -1.0f}, */v6 = {-1.0f, -11.0f, 11.0f}; ASSERT(test_eq(GLM(vec3_max)(v1), 2.104f)) ASSERT(test_eq(GLM(vec3_max)(v2), -12.35f)) #ifndef CGLM_FAST_MATH ASSERT(isinf(GLM(vec3_max)(v3))) #endif // ASSERT(isnan(GLM(vec3_max)(v4))) // ASSERT(isnan(GLM(vec3_max)(v5))) ASSERT(test_eq(GLM(vec3_max)(v6), 11.0f)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec3_min) { vec3 v1 = {2.104f, -3.012f, -4.10f}, v2 = {-12.35f, -31.140f, -43.502f}; #ifndef CGLM_FAST_MATH vec3 v3 = {INFINITY, 0.0f, 0.0f}/*, v4 = {NAN, INFINITY, 2.0f}*/; #endif vec3 /*v5 = {NAN, -1.0f, -1.0f},*/ v6 = {-1.0f, -11.0f, 11.0f}; ASSERT(test_eq(GLM(vec3_min)(v1), -4.10f)) ASSERT(test_eq(GLM(vec3_min)(v2), -43.502f)) #ifndef CGLM_FAST_MATH ASSERT(test_eq(GLM(vec3_min)(v3), 0.0f)) #endif // ASSERT(isnan(GLM(vec3_min)(v4))) // ASSERT(isnan(GLM(vec3_min)(v5))) ASSERT(test_eq(GLM(vec3_min)(v6), -11.0f)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec3_isnan) { #ifndef CGLM_FAST_MATH vec3 v1 = {2.104f, -3.012f, -4.10f}, v2 = {-12.35f, -31.140f, -43.502f}; vec3 v3 = {INFINITY, 0.0f, 0.0f}, v4 = {NAN, INFINITY, 2.0f}; vec3 v5 = {NAN, -1.0f, -1.0f}, v6 = {-1.0f, -1.0f, 11.0f}; ASSERT(!GLM(vec3_isnan)(v1)) ASSERT(!GLM(vec3_isnan)(v2)) ASSERT(!GLM(vec3_isnan)(v3)) ASSERT(GLM(vec3_isnan)(v4)) ASSERT(GLM(vec3_isnan)(v5)) ASSERT(!GLM(vec3_isnan)(v6)) #endif TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec3_isinf) { #ifndef CGLM_FAST_MATH vec3 v1 = {2.104f, -3.012f, -4.10f}, v2 = {-12.35f, -31.140f, -43.502f}; vec3 v3 = {INFINITY, 0.0f, 0.0f}, v4 = {NAN, INFINITY, 2.0f}; vec3 v5 = {NAN, -1.0f, -1.0f}, v6 = {-1.0f, -1.0f, 11.0f}; ASSERT(!GLM(vec3_isinf)(v1)) ASSERT(!GLM(vec3_isinf)(v2)) ASSERT(GLM(vec3_isinf)(v3)) ASSERT(GLM(vec3_isinf)(v4)) ASSERT(!GLM(vec3_isinf)(v5)) ASSERT(!GLM(vec3_isinf)(v6)) #endif TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec3_isvalid) { #ifndef CGLM_FAST_MATH vec3 v1 = {2.104f, -3.012f, -4.10f}, v2 = {-12.35f, -31.140f, -43.502f}; vec3 v3 = {INFINITY, 0.0f, 0.0f}, v4 = {NAN, INFINITY, 2.0f}; vec3 v5 = {NAN, -1.0f, -1.0f}, v6 = {-1.0f, -1.0f, 11.0f}; ASSERT(GLM(vec3_isvalid)(v1)) ASSERT(GLM(vec3_isvalid)(v2)) ASSERT(!GLM(vec3_isvalid)(v3)) ASSERT(!GLM(vec3_isvalid)(v4)) ASSERT(!GLM(vec3_isvalid)(v5)) ASSERT(GLM(vec3_isvalid)(v6)) #endif TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec3_sign) { vec3 v1 = {2.104f, -3.012f, -4.10f}, v2 = {-12.35f, -31.140f, -43.502f}; vec3 v3, v4; vec3 v5 = {1.0f, -1.0f, -1.0f}, v6 = {-1.0f, -1.0f, -1.0f}; GLM(vec3_sign)(v1, v3); GLM(vec3_sign)(v2, v4); ASSERTIFY(test_assert_vec3_eq(v3, v5)) ASSERTIFY(test_assert_vec3_eq(v4, v6)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec3_abs) { vec3 v1 = {2.104f, -3.012f, -4.10f}, v2 = {-12.35f, -31.140f, -43.502f}; vec3 v3, v4; vec3 v5 = {2.104f, 3.012f, 4.10f}, v6 = {12.35f, 31.140f, 43.502f}; GLM(vec3_abs)(v1, v3); GLM(vec3_abs)(v2, v4); ASSERTIFY(test_assert_vec3_eq(v3, v5)) ASSERTIFY(test_assert_vec3_eq(v4, v6)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec3_fract) { vec3 v1 = {2.104f, 3.012f, 4.10f}, v2 = {12.35f, 31.140f, 43.502f}, v3, v4; vec3 v5 = {0.104f, 0.012f, 0.10f}, v6 = {0.35f, 0.140f, 0.502f}; GLM(vec3_fract)(v1, v3); GLM(vec3_fract)(v2, v4); ASSERTIFY(test_assert_vec3_eq(v3, v5)) ASSERTIFY(test_assert_vec3_eq(v4, v6)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec3_floor) { vec3 v1 = {2.104f, 3.012f, 4.10f}, v2 = {12.35f, 31.140f, 43.502f}, v3, v4; vec3 v5 = {2.0f, 3.0f, 4.0f}, v6 = {12.0f, 31.0f, 43.0f}; GLM(vec3_floor)(v1, v3); GLM(vec3_floor)(v2, v4); ASSERTIFY(test_assert_vec3_eq(v3, v5)) ASSERTIFY(test_assert_vec3_eq(v4, v6)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec3_mods) { vec3 v1 = {2.104f, 3.012f, 4.10f}, v2 = {12.35f, 31.140f, 43.502f}, v3, v4; vec3 v5 = {0.104f, 0.012f, 0.10f}, v6 = {0.35f, 0.140f, 0.502f}; /* Mod 1 - leaves just the fractional part */ GLM(vec3_mods)(v1, 1.0f, v3); GLM(vec3_mods)(v2, 1.0f, v4); ASSERTIFY(test_assert_vec3_eq(v3, v5)) ASSERTIFY(test_assert_vec3_eq(v4, v6)) /* Mod 2 - parity + fractional part */ GLM(vec3_mods)(v1, 2.0f, v3); GLM(vec3_mods)(v2, 2.0f, v4); vec3 v7 = {0.104f, 1.012f, 0.10f}, v8 = {0.35f, 1.140f, 1.502f}; ASSERTIFY(test_assert_vec3_eq(v3, v7)) ASSERTIFY(test_assert_vec3_eq(v4, v8)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec3_hadd) { vec3 v1 = {2.0f, 3.0f, 4.0f}, v2 = {12.0f, 31.0f, 43.0f}; float r1, r2, r3, r4; r1 = GLM(vec3_hadd)(v1); r2 = GLM(vec3_hadd)(v2); r3 = v1[0] + v1[1] + v1[2]; r4 = v2[0] + v2[1] + v2[2]; ASSERT(test_eq(r1, r3)) ASSERT(test_eq(r2, r4)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec3_sqrt) { vec3 v1 = {2.0f, 3.0f, 4.0f}, v2 = {12.0f, 31.0f, 43.0f}, v3, v4; GLM(vec3_sqrt)(v1, v3); GLM(vec3_sqrt)(v2, v4); ASSERT(test_eq(sqrtf(v1[0]), v3[0])) ASSERT(test_eq(sqrtf(v1[1]), v3[1])) ASSERT(test_eq(sqrtf(v1[2]), v3[2])) ASSERT(test_eq(sqrtf(v2[0]), v4[0])) ASSERT(test_eq(sqrtf(v2[1]), v4[1])) ASSERT(test_eq(sqrtf(v2[2]), v4[2])) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec3_make) { float src[9] = { 7.2f, 1.0f, 5.8f, 2.5f, 6.1f, 9.9f, 17.7f, 4.3f, 3.2f }; vec3 dest[3]; float *srcp = src; unsigned int i, j; for (i = 0, j = 0; i < sizeof(src) / sizeof(float); i+=3,j++) { GLM(vec3_make)(srcp + i, dest[j]); ASSERT(test_eq(src[ i ], dest[j][0])); ASSERT(test_eq(src[i+1], dest[j][1])); ASSERT(test_eq(src[i+2], dest[j][2])); } TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec3_faceforward) { vec3 N = {0.0f, 1.0f, 0.0f}; vec3 v = {1.0f, -1.0f, 0.0f}; vec3 Nref = {0.0f, -1.0f, 0.0f}; vec3 dest; GLM(vec3_faceforward)(N, v, Nref, dest); ASSERT(dest[0] == 0.0f && dest[1] == -1.0f && dest[2] == 0.0f); /* Expect N flipped */ TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec3_reflect) { vec3 dest; /* Original test: Reflecting off a horizontal surface */ vec3 I1 = {1.0f, -1.0f, 0.0f}; /* Incoming vector */ vec3 N1 = {0.0f, 1.0f, 0.0f}; /* Normal vector */ GLM(vec3_reflect)(I1, N1, dest); ASSERT(fabsf(dest[0] - 1.0f) < 0.00001f && fabsf(dest[1] - 1.0f) < 0.00001f && fabsf(dest[2] - 0.0f) < 0.00001f); /* Expect reflection */ /* Scenario 2: Reflecting off a vertical surface */ vec3 I2 = {1.0f, 0.0f, 0.0f}; /* Incoming vector */ vec3 N2 = {-1.0f, 0.0f, 0.0f}; /* Normal vector */ GLM(vec3_reflect)(I2, N2, dest); ASSERT(fabsf(dest[0] + 1.0f) < 0.00001f && fabsf(dest[1]) < 0.00001f && fabsf(dest[2]) < 0.00001f); /* Expect reflection to the left */ /* Scenario 3: Reflecting at an angle */ vec3 I3 = {sqrtf(2)/2, -sqrtf(2)/2, 0.0f}; /* Incoming vector at 45 degrees */ vec3 N3 = {0.0f, 1.0f, 0.0f}; /* Upwards normal vector */ GLM(vec3_reflect)(I3, N3, dest); ASSERT(fabsf(dest[0] - sqrtf(2)/2) < 0.00001f && fabsf(dest[1] - sqrtf(2)/2) < 0.00001f && fabsf(dest[2]) < 0.00001f); /* Expect reflection upwards */ TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec3_refract) { vec3 v = {sqrtf(0.5f), -sqrtf(0.5f), 0.0f}; /* Incoming vector at 45 degrees to normal */ vec3 N = {0.0f, 1.0f, 0.0f}; /* Surface normal */ vec3 dest; float eta; bool r; /* Water to Air (eta = 1.33/1.0) */ eta = 1.33f / 1.0f; r = GLM(vec3_refract)(v, N, eta, dest); if (!(dest[0] == 0.0f && dest[1] == 0.0f && dest[2] == 0.0f)) { ASSERT(dest[1] < -0.3f); ASSERT(r == true); } else { ASSERT(dest[0] == 0.0f && dest[1] == 0.0f && dest[2] == 0.0f); ASSERT(r == false); } /* Air to Glass (eta = 1.0 / 1.5) */ eta = 1.0f / 1.5f; r = GLM(vec3_refract)(v, N, eta, dest); /* Expect bending towards the normal */ ASSERT(r == true); ASSERT(dest[1] < -sqrtf(0.5f)); /* Glass to Water (eta = 1.5 / 1.33) */ eta = 1.5f / 1.33f; r = GLM(vec3_refract)(v, N, eta, dest); /* Expect bending towards the normal, less bending than air to glass */ ASSERT(r == true); ASSERT(dest[1] < -0.6f); /* Diamond to Air (eta = 2.42 / 1.0) */ eta = 2.42f / 1.0f; r = GLM(vec3_refract)(v, N, eta, dest); if (!(dest[0] == 0.0f && dest[1] == 0.0f && dest[2] == 0.0f)) { /* High potential for total internal reflection, but if it occurs, expect significant bending */ ASSERT(dest[1] < -sqrtf(0.5f)); ASSERT(r == true); } else { ASSERT(dest[0] == 0.0f && dest[1] == 0.0f && dest[2] == 0.0f); ASSERT(r == false); } TEST_SUCCESS } cglm-0.9.6/test/src/test_vec4.h000066400000000000000000001235071475344456400163170ustar00rootroot00000000000000/* * 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" #define TEST_GLM_SHUFFLE4(z, y, x, w) (((z) << 6) | ((y) << 4) | ((x) << 2)|(w)) #ifndef CGLM_TEST_VEC4_ONCE #define CGLM_TEST_VEC4_ONCE /* Macros */ TEST_IMPL(MACRO_GLM_VEC4_ONE_INIT) { vec4 v = GLM_VEC4_ONE_INIT; ASSERT(test_eq(v[0], 1.0f)) ASSERT(test_eq(v[1], 1.0f)) ASSERT(test_eq(v[2], 1.0f)) ASSERT(test_eq(v[3], 1.0f)) TEST_SUCCESS } TEST_IMPL(MACRO_GLM_VEC4_ZERO_INIT) { vec4 v = GLM_VEC4_ZERO_INIT; ASSERT(test_eq(v[0], 0.0f)) ASSERT(test_eq(v[1], 0.0f)) ASSERT(test_eq(v[2], 0.0f)) ASSERT(test_eq(v[3], 0.0f)) TEST_SUCCESS } TEST_IMPL(MACRO_GLM_VEC4_ONE) { ASSERT(test_eq(GLM_VEC4_ONE[0], 1.0f)) ASSERT(test_eq(GLM_VEC4_ONE[1], 1.0f)) ASSERT(test_eq(GLM_VEC4_ONE[2], 1.0f)) ASSERT(test_eq(GLM_VEC4_ONE[3], 1.0f)) TEST_SUCCESS } TEST_IMPL(MACRO_GLM_VEC4_ZERO) { ASSERT(test_eq(GLM_VEC4_ZERO[0], 0.0f)) ASSERT(test_eq(GLM_VEC4_ZERO[1], 0.0f)) ASSERT(test_eq(GLM_VEC4_ZERO[2], 0.0f)) ASSERT(test_eq(GLM_VEC4_ZERO[3], 0.0f)) TEST_SUCCESS } TEST_IMPL(MACRO_GLM_XXXX) { ASSERT(TEST_GLM_SHUFFLE4(0, 0, 0, 0) == GLM_XXXX) TEST_SUCCESS } TEST_IMPL(MACRO_GLM_YYYY) { ASSERT(TEST_GLM_SHUFFLE4(1, 1, 1, 1) == GLM_YYYY) TEST_SUCCESS } TEST_IMPL(MACRO_GLM_ZZZZ) { ASSERT(TEST_GLM_SHUFFLE4(2, 2, 2, 2) == GLM_ZZZZ) TEST_SUCCESS } TEST_IMPL(MACRO_GLM_WZYX) { ASSERT(TEST_GLM_SHUFFLE4(0, 1, 2, 3) == GLM_WZYX) TEST_SUCCESS } /* Deprecated */ TEST_IMPL(MACRO_glm_vec4_dup) { vec4 v1 = {13.0f, 12.0f, 11.0f, 56.0f}, v2; glm_vec4_dup(v1, v2); ASSERTIFY(test_assert_vec4_eq(v1, v2)) TEST_SUCCESS } TEST_IMPL(MACRO_glm_vec4_flipsign) { vec4 v1 = {13.0f, -12.0f, 11.0f, 56.0f}, v2 = {13.0f, -12.0f, 11.0f, 56.0f}, v3 = {-13.0f, 12.0f, -11.0f, -56.0f}; glm_vec4_flipsign(v1); glmc_vec4_flipsign(v2); ASSERTIFY(test_assert_vec4_eq(v1, v3)) ASSERTIFY(test_assert_vec4_eq(v2, v3)) TEST_SUCCESS } TEST_IMPL(MACRO_glm_vec4_flipsign_to) { vec4 v1 = {13.0f, -12.0f, 11.0f, 56.0f}, v2 = {-13.0f, 12.0f, -11.0f, -56.0f}, v3, v4; glm_vec4_flipsign_to(v1, v3); glmc_vec4_flipsign_to(v1, v4); ASSERTIFY(test_assert_vec4_eq(v2, v3)) ASSERTIFY(test_assert_vec4_eq(v2, v4)) TEST_SUCCESS } TEST_IMPL(MACRO_glm_vec4_inv) { vec4 v1 = {13.0f, -12.0f, 11.0f, 56.0f}, v2 = {13.0f, -12.0f, 11.0f, 56.0f}, v3 = {-13.0f, 12.0f, -11.0f, -56.0f}; glm_vec4_inv(v1); glmc_vec4_inv(v2); ASSERTIFY(test_assert_vec4_eq(v1, v3)) ASSERTIFY(test_assert_vec4_eq(v2, v3)) TEST_SUCCESS } TEST_IMPL(MACRO_glm_vec4_inv_to) { vec4 v1 = {13.0f, -12.0f, 11.0f, 56.0f}, v2 = {-13.0f, 12.0f, -11.0f, -56.0f}, v3, v4; glm_vec4_inv_to(v1, v3); glmc_vec4_inv_to(v1, v4); ASSERTIFY(test_assert_vec4_eq(v3, v4)) ASSERTIFY(test_assert_vec4_eq(v2, v3)) TEST_SUCCESS } TEST_IMPL(MACRO_glm_vec4_mulv) { vec4 v1 = {2.0f, -3.0f, 4.0f, 56.0f}, v2 = {-3.0f, 4.0f, -5.0f, 56.0f}, v3, v4; glm_vec4_mulv(v1, v2, v3); glmc_vec4_mulv(v1, v2, v4); ASSERTIFY(test_assert_vec4_eq(v3, v4)) ASSERT(test_eq(v1[0] * v2[0], v3[0])) ASSERT(test_eq(v1[1] * v2[1], v3[1])) ASSERT(test_eq(v1[2] * v2[2], v3[2])) ASSERT(test_eq(v1[3] * v2[3], v3[3])) TEST_SUCCESS } #endif /* CGLM_TEST_VEC4_ONCE */ /* --- */ TEST_IMPL(GLM_PREFIX, vec4) { vec4 v1 = {10.0f, 9.0f, 8.0f}; vec4 v2 = {10.0f, 9.0f, 8.0f, 7.0f}; vec4 v3; GLM(vec4)(v1, 7.0f, v3); ASSERTIFY(test_assert_vec4_eq(v2, v3)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec4_copy3) { vec4 v4 = {10.0f, 9.0f, 8.0f, 7.0f}; vec3 v3; GLM(vec4_copy3)(v4, v3); ASSERTIFY(test_assert_vec3_eq(v3, v4)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec4_copy) { vec4 v1 = {10.0f, 9.0f, 8.0f, 78.0f}; vec4 v2 = {1.0f, 2.0f, 3.0f, 4.0f}; GLM(vec4_copy)(v1, v2); ASSERTIFY(test_assert_vec4_eq(v1, v2)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec4_ucopy) { vec4 v1 = {10.0f, 9.0f, 8.0f, 78.0f}; vec4 v2 = {1.0f, 2.0f, 3.0f, 4.0f}; GLM(vec4_ucopy)(v1, v2); ASSERTIFY(test_assert_vec4_eq(v1, v2)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec4_zero) { vec4 v1 = {10.0f, 9.0f, 8.0f, 78.0f}; vec4 v2 = {1.0f, 2.0f, 3.0f, 4.0f}; GLM(vec4_zero)(v1); GLM(vec4_zero)(v2); ASSERTIFY(test_assert_vec4_eq(v1, GLM_VEC4_ZERO)) ASSERTIFY(test_assert_vec4_eq(v2, GLM_VEC4_ZERO)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec4_one) { vec4 v1 = {10.0f, 9.0f, 8.0f, 78.0f}; vec4 v2 = {1.0f, 2.0f, 3.0f, 4.0f}; GLM(vec4_one)(v1); GLM(vec4_one)(v2); ASSERTIFY(test_assert_vec4_eq(v1, GLM_VEC4_ONE)) ASSERTIFY(test_assert_vec4_eq(v2, GLM_VEC4_ONE)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec4_dot) { vec4 a = {10.0f, 9.0f, 8.0f, 78.0f}; vec4 b = {1.0f, 2.0f, 3.0f, 4.0f}; float dot1, dot2; dot1 = GLM(vec4_dot)(a, b); dot2 = a[0] * b[0] + a[1] * b[1] + a[2] * b[2] + a[3] * b[3]; ASSERT(test_eq(dot1, dot2)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec4_norm2) { vec4 a = {10.0f, 9.0f, 8.0f, 78.0f}; float n1, n2; n1 = GLM(vec4_norm2)(a); n2 = a[0] * a[0] + a[1] * a[1] + a[2] * a[2] + a[3] * a[3]; ASSERT(test_eq(n1, n2)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec4_norm) { vec4 a = {10.0f, 9.0f, 8.0f, 78.0f}; float n1, n2; n1 = GLM(vec4_norm)(a); n2 = sqrtf(a[0] * a[0] + a[1] * a[1] + a[2] * a[2] + a[3] * a[3]); ASSERT(test_eq(n1, n2)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec4_norm_one) { vec4 a = {-10.0f, 9.0f, -8.0f, 78.0f}; float n1, n2; n1 = GLM(vec4_norm_one)(a); n2 = fabsf(a[0]) + fabsf(a[1]) + fabsf(a[2]) + fabsf(a[3]); ASSERT(test_eq(n1, n2)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec4_norm_inf) { vec4 a = {-10.0f, 9.0f, -8.0f, 78.0f}; float n1, n2; n1 = GLM(vec4_norm_inf)(a); n2 = fabsf(a[0]); if (n2 < fabsf(a[1])) n2 = fabsf(a[1]); if (n2 < fabsf(a[2])) n2 = fabsf(a[2]); if (n2 < fabsf(a[3])) n2 = fabsf(a[3]); ASSERT(test_eq(n1, n2)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec4_add) { vec4 a = {-10.0f, 9.0f, -8.0f, 56.0f}; vec4 b = {12.0f, 19.0f, -18.0f, 1.0f}; vec4 c, d; c[0] = a[0] + b[0]; c[1] = a[1] + b[1]; c[2] = a[2] + b[2]; c[3] = a[3] + b[3]; GLM(vec4_add)(a, b, d); ASSERTIFY(test_assert_vec4_eq(c, d)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec4_adds) { vec4 a = {-10.0f, 9.0f, -8.0f, 56.0f}; vec4 c, d; float s = 7.0f; c[0] = a[0] + s; c[1] = a[1] + s; c[2] = a[2] + s; c[3] = a[3] + s; GLM(vec4_adds)(a, s, d); ASSERTIFY(test_assert_vec4_eq(c, d)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec4_sub) { vec4 a = {-10.0f, 9.0f, -8.0f, 56.0f}; vec4 b = {12.0f, 19.0f, -18.0f, 1.0f}; vec4 c, d; c[0] = a[0] - b[0]; c[1] = a[1] - b[1]; c[2] = a[2] - b[2]; c[3] = a[3] - b[3]; GLM(vec4_sub)(a, b, d); ASSERTIFY(test_assert_vec4_eq(c, d)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec4_subs) { vec4 a = {-10.0f, 9.0f, -8.0f, 74.0f}; vec4 c, d; float s = 7.0f; c[0] = a[0] - s; c[1] = a[1] - s; c[2] = a[2] - s; c[3] = a[3] - s; GLM(vec4_subs)(a, s, d); ASSERTIFY(test_assert_vec4_eq(c, d)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec4_mul) { vec4 v1 = {2.0f, -3.0f, 4.0f, 56.0f}, v2 = {-3.0f, 4.0f, -5.0f, 46.0f}, v3; GLM(vec4_mul)(v1, v2, v3); ASSERT(test_eq(v1[0] * v2[0], v3[0])) ASSERT(test_eq(v1[1] * v2[1], v3[1])) ASSERT(test_eq(v1[2] * v2[2], v3[2])) ASSERT(test_eq(v1[3] * v2[3], v3[3])) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec4_scale) { vec4 v1 = {2.0f, -3.0f, 4.0f, 5.0f}, v2; float s = 7.0f; GLM(vec4_scale)(v1, s, v2); ASSERT(test_eq(v1[0] * s, v2[0])) ASSERT(test_eq(v1[1] * s, v2[1])) ASSERT(test_eq(v1[2] * s, v2[2])) ASSERT(test_eq(v1[3] * s, v2[3])) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec4_scale_as) { vec4 v1 = {2.0f, -3.0f, 4.0f, 5.0f}, v2; float s = 7.0f; float norm; GLM(vec4_scale_as)(v1, s, v2); norm = sqrtf(v1[0] * v1[0] + v1[1] * v1[1] + v1[2] * v1[2] + v1[3] * v1[3]); if (norm < FLT_EPSILON) { ASSERT(test_eq(v1[0], 0.0f)) ASSERT(test_eq(v1[1], 0.0f)) ASSERT(test_eq(v1[2], 0.0f)) ASSERT(test_eq(v1[3], 0.0f)) TEST_SUCCESS } norm = s / norm; ASSERT(test_eq(v1[0] * norm, v2[0])) ASSERT(test_eq(v1[1] * norm, v2[1])) ASSERT(test_eq(v1[2] * norm, v2[2])) ASSERT(test_eq(v1[3] * norm, v2[3])) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec4_div) { vec4 v1 = {2.0f, -3.0f, 4.0f, 40.0f}, v2 = {-3.0f, 4.0f, -5.0f, 2.0f}, v3; GLM(vec4_div)(v1, v2, v3); ASSERT(test_eq(v1[0] / v2[0], v3[0])) ASSERT(test_eq(v1[1] / v2[1], v3[1])) ASSERT(test_eq(v1[2] / v2[2], v3[2])) ASSERT(test_eq(v1[3] / v2[3], v3[3])) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec4_divs) { vec4 v1 = {2.0f, -3.0f, 4.0f, 40.0f}, v2; float s = 7.0f; GLM(vec4_divs)(v1, s, v2); ASSERT(test_eq(v1[0] / s, v2[0])) ASSERT(test_eq(v1[1] / s, v2[1])) ASSERT(test_eq(v1[2] / s, v2[2])) ASSERT(test_eq(v1[3] / s, v2[3])) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec4_addadd) { vec4 v1 = {2.0f, -3.0f, 4.0f, 4.0f}, v2 = {-3.0f, 4.0f, -5.0f, 20.0f}, v3 = {1.0f, 2.0f, 3.0f, 130.0f}, v4 = {1.0f, 2.0f, 3.0f, 130.0f}; GLM(vec4_addadd)(v1, v2, v4); ASSERT(test_eq(v3[0] + v1[0] + v2[0], v4[0])) ASSERT(test_eq(v3[1] + v1[1] + v2[1], v4[1])) ASSERT(test_eq(v3[2] + v1[2] + v2[2], v4[2])) ASSERT(test_eq(v3[3] + v1[3] + v2[3], v4[3])) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec4_subadd) { vec4 v1 = {2.0f, -3.0f, 4.0f, 4.0f}, v2 = {-3.0f, 4.0f, -5.0f, 20.0f}, v3 = {1.0f, 2.0f, 3.0f, 130.0f}, v4 = {1.0f, 2.0f, 3.0f, 130.0f}; GLM(vec4_subadd)(v1, v2, v4); ASSERT(test_eq(v3[0] + v1[0] - v2[0], v4[0])) ASSERT(test_eq(v3[1] + v1[1] - v2[1], v4[1])) ASSERT(test_eq(v3[2] + v1[2] - v2[2], v4[2])) ASSERT(test_eq(v3[3] + v1[3] - v2[3], v4[3])) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec4_muladd) { vec4 v1 = {2.0f, -3.0f, 4.0f, 4.0f}, v2 = {-3.0f, 4.0f, -5.0f, 20.0f}, v3 = {1.0f, 2.0f, 3.0f, 130.0f}, v4 = {1.0f, 2.0f, 3.0f, 130.0f}; GLM(vec4_muladd)(v1, v2, v4); ASSERT(test_eq(v3[0] + v1[0] * v2[0], v4[0])) ASSERT(test_eq(v3[1] + v1[1] * v2[1], v4[1])) ASSERT(test_eq(v3[2] + v1[2] * v2[2], v4[2])) ASSERT(test_eq(v3[3] + v1[3] * v2[3], v4[3])) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec4_muladds) { vec4 v1 = {2.0f, -3.0f, 4.0f, 4.0f}, v2 = {-3.0f, 4.0f, -5.0f, 20.0f}, v3 = {-3.0f, 4.0f, -5.0f, 20.0f}; float s = 9.0f; GLM(vec4_muladds)(v1, s, v3); ASSERT(test_eq(v2[0] + v1[0] * s, v3[0])) ASSERT(test_eq(v2[1] + v1[1] * s, v3[1])) ASSERT(test_eq(v2[2] + v1[2] * s, v3[2])) ASSERT(test_eq(v2[3] + v1[3] * s, v3[3])) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec4_maxadd) { vec4 v1 = {2.0f, -3.0f, 4.0f, 4.0f}, v2 = {-3.0f, 4.0f, -5.0f, 20.0f}, v3 = {1.0f, 2.0f, 3.0f, 130.0f}, v4 = {1.0f, 2.0f, 3.0f, 130.0f}; GLM(vec4_maxadd)(v1, v2, v4); ASSERT(test_eq(v3[0] + glm_max(v1[0], v2[0]), v4[0])) ASSERT(test_eq(v3[1] + glm_max(v1[1], v2[1]), v4[1])) ASSERT(test_eq(v3[2] + glm_max(v1[2], v2[2]), v4[2])) ASSERT(test_eq(v3[3] + glm_max(v1[3], v2[3]), v4[3])) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec4_minadd) { vec4 v1 = {2.0f, -3.0f, 4.0f, 4.0f}, v2 = {-3.0f, 4.0f, -5.0f, 20.0f}, v3 = {1.0f, 2.0f, 3.0f, 130.0f}, v4 = {1.0f, 2.0f, 3.0f, 130.0f}; GLM(vec4_minadd)(v1, v2, v4); ASSERT(test_eq(v3[0] + glm_min(v1[0], v2[0]), v4[0])) ASSERT(test_eq(v3[1] + glm_min(v1[1], v2[1]), v4[1])) ASSERT(test_eq(v3[2] + glm_min(v1[2], v2[2]), v4[2])) ASSERT(test_eq(v3[3] + glm_min(v1[3], v2[3]), v4[3])) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec4_subsub) { vec4 v1 = {2.0f, -3.0f, 4.0f, 4.0f}, v2 = {-3.0f, 4.0f, -5.0f, 20.0f}, v3 = {1.0f, 2.0f, 3.0f, 130.0f}, v4 = {1.0f, 2.0f, 3.0f, 130.0f}; GLM(vec4_subsub)(v1, v2, v4); ASSERT(test_eq(v3[0] - (v1[0] - v2[0]), v4[0])) ASSERT(test_eq(v3[1] - (v1[1] - v2[1]), v4[1])) ASSERT(test_eq(v3[2] - (v1[2] - v2[2]), v4[2])) ASSERT(test_eq(v3[3] - (v1[3] - v2[3]), v4[3])) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec4_addsub) { vec4 v1 = {2.0f, -3.0f, 4.0f, 4.0f}, v2 = {-3.0f, 4.0f, -5.0f, 20.0f}, v3 = {1.0f, 2.0f, 3.0f, 130.0f}, v4 = {1.0f, 2.0f, 3.0f, 130.0f}; GLM(vec4_addsub)(v1, v2, v4); ASSERT(test_eq(v3[0] - (v1[0] + v2[0]), v4[0])) ASSERT(test_eq(v3[1] - (v1[1] + v2[1]), v4[1])) ASSERT(test_eq(v3[2] - (v1[2] + v2[2]), v4[2])) ASSERT(test_eq(v3[3] - (v1[3] + v2[3]), v4[3])) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec4_mulsub) { vec4 v1 = {2.0f, -3.0f, 4.0f, 4.0f}, v2 = {-3.0f, 4.0f, -5.0f, 20.0f}, v3 = {1.0f, 2.0f, 3.0f, 130.0f}, v4 = {1.0f, 2.0f, 3.0f, 130.0f}; GLM(vec4_mulsub)(v1, v2, v4); ASSERT(test_eq(v3[0] - (v1[0] * v2[0]), v4[0])) ASSERT(test_eq(v3[1] - (v1[1] * v2[1]), v4[1])) ASSERT(test_eq(v3[2] - (v1[2] * v2[2]), v4[2])) ASSERT(test_eq(v3[3] - (v1[3] * v2[3]), v4[3])) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec4_mulsubs) { vec4 v1 = {2.0f, -3.0f, 4.0f, 4.0f}, v2 = {-3.0f, 4.0f, -5.0f, 20.0f}, v3 = {-3.0f, 4.0f, -5.0f, 20.0f}; float s = 9.0f; GLM(vec4_mulsubs)(v1, s, v3); ASSERT(test_eq(v2[0] - (v1[0] * s), v3[0])) ASSERT(test_eq(v2[1] - (v1[1] * s), v3[1])) ASSERT(test_eq(v2[2] - (v1[2] * s), v3[2])) ASSERT(test_eq(v2[3] - (v1[3] * s), v3[3])) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec4_maxsub) { vec4 v1 = {2.0f, -3.0f, 4.0f, 4.0f}, v2 = {-3.0f, 4.0f, -5.0f, 20.0f}, v3 = {1.0f, 2.0f, 3.0f, 130.0f}, v4 = {1.0f, 2.0f, 3.0f, 130.0f}; GLM(vec4_maxsub)(v1, v2, v4); ASSERT(test_eq(v3[0] - glm_max(v1[0], v2[0]), v4[0])) ASSERT(test_eq(v3[1] - glm_max(v1[1], v2[1]), v4[1])) ASSERT(test_eq(v3[2] - glm_max(v1[2], v2[2]), v4[2])) ASSERT(test_eq(v3[3] - glm_max(v1[3], v2[3]), v4[3])) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec4_minsub) { vec4 v1 = {2.0f, -3.0f, 4.0f, 4.0f}, v2 = {-3.0f, 4.0f, -5.0f, 20.0f}, v3 = {1.0f, 2.0f, 3.0f, 130.0f}, v4 = {1.0f, 2.0f, 3.0f, 130.0f}; GLM(vec4_minsub)(v1, v2, v4); ASSERT(test_eq(v3[0] - glm_min(v1[0], v2[0]), v4[0])) ASSERT(test_eq(v3[1] - glm_min(v1[1], v2[1]), v4[1])) ASSERT(test_eq(v3[2] - glm_min(v1[2], v2[2]), v4[2])) ASSERT(test_eq(v3[3] - glm_min(v1[3], v2[3]), v4[3])) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec4_negate_to) { vec4 v1 = {2.0f, -3.0f, 4.0f, 60.0f}, v2 = {-3.0f, 4.0f, -5.0f, 34.0f}, v3, v4; GLM(vec4_negate_to)(v1, v3); GLM(vec4_negate_to)(v2, v4); ASSERT(test_eq(-v1[0], v3[0])) ASSERT(test_eq(-v1[1], v3[1])) ASSERT(test_eq(-v1[2], v3[2])) ASSERT(test_eq(-v1[3], v3[3])) ASSERT(test_eq(-v2[0], v4[0])) ASSERT(test_eq(-v2[1], v4[1])) ASSERT(test_eq(-v2[2], v4[2])) ASSERT(test_eq(-v2[3], v4[3])) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec4_negate) { vec4 v1 = {2.0f, -3.0f, 4.0f, 60.0f}, v2 = {-3.0f, 4.0f, -5.0f, 34.0f}, v3 = {2.0f, -3.0f, 4.0f, 60.0f}, v4 = {-3.0f, 4.0f, -5.0f, 34.0f}; GLM(vec4_negate)(v1); GLM(vec4_negate)(v2); ASSERT(test_eq(-v1[0], v3[0])) ASSERT(test_eq(-v1[1], v3[1])) ASSERT(test_eq(-v1[2], v3[2])) ASSERT(test_eq(-v1[3], v3[3])) ASSERT(test_eq(-v2[0], v4[0])) ASSERT(test_eq(-v2[1], v4[1])) ASSERT(test_eq(-v2[2], v4[2])) ASSERT(test_eq(-v2[3], v4[3])) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec4_normalize) { vec4 v1 = {2.0f, -3.0f, 4.0f, 5.0f}, v2 = {2.0f, -3.0f, 4.0f, 5.0f}; float s = 1.0f; float norm; GLM(vec4_normalize)(v2); norm = sqrtf(v1[0] * v1[0] + v1[1] * v1[1] + v1[2] * v1[2] + v1[3] * v1[3]); if (norm < FLT_EPSILON) { ASSERT(test_eq(v1[0], 0.0f)) ASSERT(test_eq(v1[1], 0.0f)) ASSERT(test_eq(v1[2], 0.0f)) ASSERT(test_eq(v1[3], 0.0f)) TEST_SUCCESS } norm = s / norm; ASSERT(test_eq(v1[0] * norm, v2[0])) ASSERT(test_eq(v1[1] * norm, v2[1])) ASSERT(test_eq(v1[2] * norm, v2[2])) ASSERT(test_eq(v1[3] * norm, v2[3])) glm_vec4_zero(v1); GLM(vec4_normalize)(v1); ASSERTIFY(test_assert_vec4_eq(v1, GLM_VEC4_ZERO)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec4_normalize_to) { vec4 v1 = {2.0f, -3.0f, 4.0f, 5.0f}, v2; float s = 1.0f; float norm; GLM(vec4_normalize_to)(v1, v2); norm = sqrtf(v1[0] * v1[0] + v1[1] * v1[1] + v1[2] * v1[2] + v1[3] * v1[3]); if (norm < FLT_EPSILON) { ASSERT(test_eq(v1[0], 0.0f)) ASSERT(test_eq(v1[1], 0.0f)) ASSERT(test_eq(v1[2], 0.0f)) ASSERT(test_eq(v1[3], 0.0f)) TEST_SUCCESS } norm = s / norm; ASSERT(test_eq(v1[0] * norm, v2[0])) ASSERT(test_eq(v1[1] * norm, v2[1])) ASSERT(test_eq(v1[2] * norm, v2[2])) ASSERT(test_eq(v1[3] * norm, v2[3])) glm_vec4_zero(v1); GLM(vec4_normalize_to)(v1, v2); ASSERTIFY(test_assert_vec4_eq(v2, GLM_VEC4_ZERO)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec4_distance2) { vec4 v1 = {30.0f, 0.0f, 0.0f, 0.0f}, v2 = {0.0f, 0.0f, 0.0f, 0.0f}, v3 = {3.0f, 10.0f, 120.0f, 140.0f}, v4 = {0.46f, 4.0f, 14.0f, 10.0f}; float d; d = GLM(vec4_distance2)(v1, v2); ASSERT(test_eq(d, 30.0f * 30.0f)) d = GLM(vec4_distance2)(v3, v4); ASSERT(test_eq(powf(v3[0] - v4[0], 2.0f) + powf(v3[1] - v4[1], 2.0f) + powf(v3[2] - v4[2], 2.0f) + powf(v3[3] - v4[3], 2.0f), d)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec4_distance) { vec4 v1 = {30.0f, 0.0f, 0.0f, 0.0f}, v2 = {0.0f, 0.0f, 0.0f, 0.0f}, v3 = {3.0f, 10.0f, 120.0f, 140.0f}, v4 = {0.46f, 4.0f, 14.0f, 10.0f}; float d; d = GLM(vec4_distance)(v1, v2); ASSERT(test_eq(d, 30.0f)) d = GLM(vec4_distance)(v3, v4); ASSERT(test_eq(sqrtf(powf(v3[0] - v4[0], 2.0f) + powf(v3[1] - v4[1], 2.0f) + powf(v3[2] - v4[2], 2.0f) + powf(v3[3] - v4[3], 2.0f)), d)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec4_maxv) { vec4 v1, v2, v3; vec4 v5 = {-1.456f, -1.456f, 241.456f, 10.0f}; vec4 v6 = {11.0f, 11.0f, 11.0f, 90.0f}; vec4 v7 = {78.0f, -78.0f, 7.0f, 5.0f}; GLM(vec4_maxv)(v5, v6, v1); GLM(vec4_maxv)(v5, v7, v2); GLM(vec4_maxv)(v6, v7, v3); ASSERT(test_eq(v1[0], 11.0f)) ASSERT(test_eq(v1[1], 11.0f)) ASSERT(test_eq(v1[2], 241.456f)) ASSERT(test_eq(v1[3], 90.0f)) ASSERT(test_eq(v2[0], 78.0f)) ASSERT(test_eq(v2[1], -1.456f)) ASSERT(test_eq(v2[2], 241.456f)) ASSERT(test_eq(v2[3], 10.0f)) ASSERT(test_eq(v3[0], 78.0f)) ASSERT(test_eq(v3[1], 11.0f)) ASSERT(test_eq(v3[2], 11.0f)) ASSERT(test_eq(v3[3], 90.0f)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec4_minv) { vec4 v1, v2, v3; vec4 v5 = {-1.456f, -1.456f, 241.456f, 10.0f}; vec4 v6 = {11.0f, 11.0f, 11.0f, 90.0f}; vec4 v7 = {78.0f, -78.0f, 7.0f, 5.0f}; GLM(vec4_minv)(v5, v6, v1); GLM(vec4_minv)(v5, v7, v2); GLM(vec4_minv)(v6, v7, v3); ASSERT(test_eq(v1[0], -1.456f)) ASSERT(test_eq(v1[1], -1.456f)) ASSERT(test_eq(v1[2], 11.0f)) ASSERT(test_eq(v1[3], 10.0f)) ASSERT(test_eq(v2[0], -1.456f)) ASSERT(test_eq(v2[1], -78.0f)) ASSERT(test_eq(v2[2], 7.0f)) ASSERT(test_eq(v2[3], 5.0f)) ASSERT(test_eq(v3[0], 11.0f)) ASSERT(test_eq(v3[1], -78.0f)) ASSERT(test_eq(v3[2], 7.0f)) ASSERT(test_eq(v3[3], 5.0f)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec4_clamp) { vec4 v1 = {-1.456f, -11.456f, 31.456f, 67.04f}; vec4 v2 = {0.110f, 111.0f, 11.0f, 90.0f}; vec4 v3 = {78.0f, 32.0f, -78.0f, 3.0f}; GLM(vec4_clamp)(v1, -1.03f, 30.0f); GLM(vec4_clamp)(v2, 0.11f, 111.0f); GLM(vec4_clamp)(v3, -88.0f, 70.0f); ASSERT(test_eq(v1[0], -1.03f)) ASSERT(test_eq(v1[1], -1.03f)) ASSERT(test_eq(v1[2], 30.0f)) ASSERT(test_eq(v1[3], 30.0f)) ASSERT(test_eq(v2[0], 0.11f)) ASSERT(test_eq(v2[1], 111.0f)) ASSERT(test_eq(v2[2], 11.0f)) ASSERT(test_eq(v2[3], 90.0f)) ASSERT(test_eq(v3[0], 70.0f)) ASSERT(test_eq(v3[1], 32.0f)) ASSERT(test_eq(v3[2], -78.0f)) ASSERT(test_eq(v3[3], 3.0f)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec4_lerp) { vec4 v1 = {-100.0f, -200.0f, -10.0f, -10.0f}; vec4 v2 = {100.0f, 200.0f, 10.0f, 10.0f}; vec4 v3; GLM(vec4_lerp)(v1, v2, 0.5f, v3); ASSERT(test_eq(v3[0], 0.0f)) ASSERT(test_eq(v3[1], 0.0f)) ASSERT(test_eq(v3[2], 0.0f)) ASSERT(test_eq(v3[3], 0.0f)) GLM(vec4_lerp)(v1, v2, 0.75f, v3); ASSERT(test_eq(v3[0], 50.0f)) ASSERT(test_eq(v3[1], 100.0f)) ASSERT(test_eq(v3[2], 5.0f)) ASSERT(test_eq(v3[3], 5.0f)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec4_lerpc) { vec4 v1 = {-100.0f, -200.0f, -10.0f, -10.0f}; vec4 v2 = {100.0f, 200.0f, 10.0f, 10.0f}; vec4 v3; GLM(vec4_lerpc)(v1, v2, 0.5f, v3); ASSERT(test_eq(v3[0], 0.0f)) ASSERT(test_eq(v3[1], 0.0f)) ASSERT(test_eq(v3[2], 0.0f)) ASSERT(test_eq(v3[3], 0.0f)) GLM(vec4_lerpc)(v1, v2, 0.75f, v3); ASSERT(test_eq(v3[0], 50.0f)) ASSERT(test_eq(v3[1], 100.0f)) ASSERT(test_eq(v3[2], 5.0f)) ASSERT(test_eq(v3[3], 5.0f)) GLM(vec4_lerpc)(v1, v2, -1.75f, v3); ASSERT(test_eq(v3[0], -100.0f)) ASSERT(test_eq(v3[1], -200.0f)) ASSERT(test_eq(v3[2], -10.0f)) ASSERT(test_eq(v3[3], -10.0f)) GLM(vec4_lerpc)(v1, v2, 1.75f, v3); ASSERT(test_eq(v3[0], 100.0f)) ASSERT(test_eq(v3[1], 200.0f)) ASSERT(test_eq(v3[2], 10.0f)) ASSERT(test_eq(v3[3], 10.0f)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec4_mix) { vec4 v1 = {-100.0f, -200.0f, -10.0f, -10.0f}; vec4 v2 = {100.0f, 200.0f, 10.0f, 10.0f}; vec4 v3; GLM(vec4_mix)(v1, v2, 0.5f, v3); ASSERT(test_eq(v3[0], 0.0f)) ASSERT(test_eq(v3[1], 0.0f)) ASSERT(test_eq(v3[2], 0.0f)) ASSERT(test_eq(v3[3], 0.0f)) GLM(vec4_mix)(v1, v2, 0.75f, v3); ASSERT(test_eq(v3[0], 50.0f)) ASSERT(test_eq(v3[1], 100.0f)) ASSERT(test_eq(v3[2], 5.0f)) ASSERT(test_eq(v3[3], 5.0f)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec4_mixc) { vec4 v1 = {-100.0f, -200.0f, -10.0f, -10.0f}; vec4 v2 = {100.0f, 200.0f, 10.0f, 10.0f}; vec4 v3; GLM(vec4_mixc)(v1, v2, 0.5f, v3); ASSERT(test_eq(v3[0], 0.0f)) ASSERT(test_eq(v3[1], 0.0f)) ASSERT(test_eq(v3[2], 0.0f)) ASSERT(test_eq(v3[3], 0.0f)) GLM(vec4_mixc)(v1, v2, 0.75f, v3); ASSERT(test_eq(v3[0], 50.0f)) ASSERT(test_eq(v3[1], 100.0f)) ASSERT(test_eq(v3[2], 5.0f)) ASSERT(test_eq(v3[3], 5.0f)) GLM(vec4_mixc)(v1, v2, -1.75f, v3); ASSERT(test_eq(v3[0], -100.0f)) ASSERT(test_eq(v3[1], -200.0f)) ASSERT(test_eq(v3[2], -10.0f)) ASSERT(test_eq(v3[3], -10.0f)) GLM(vec4_mixc)(v1, v2, 1.75f, v3); ASSERT(test_eq(v3[0], 100.0f)) ASSERT(test_eq(v3[1], 200.0f)) ASSERT(test_eq(v3[2], 10.0f)) ASSERT(test_eq(v3[3], 10.0f)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec4_steps) { vec4 v1 = {-100.0f, -200.0f, -10.0f, -10.0f}; vec4 v2; GLM(vec4_steps)(-2.5f, v1, v2); ASSERT(test_eq(v2[0], 0.0f)) ASSERT(test_eq(v2[1], 0.0f)) ASSERT(test_eq(v2[2], 0.0f)) ASSERT(test_eq(v2[3], 0.0f)) GLM(vec4_steps)(-10.0f, v1, v2); ASSERT(test_eq(v2[0], 0.0f)) ASSERT(test_eq(v2[1], 0.0f)) ASSERT(test_eq(v2[2], 1.0f)) ASSERT(test_eq(v2[3], 1.0f)) GLM(vec4_steps)(-1000.0f, v1, v2); ASSERT(test_eq(v2[0], 1.0f)) ASSERT(test_eq(v2[1], 1.0f)) ASSERT(test_eq(v2[2], 1.0f)) ASSERT(test_eq(v2[3], 1.0f)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec4_stepr) { vec4 v1 = {-2.5f, -100.0f, -200.0f, -300.0f}; vec4 v2; GLM(vec4_stepr)(v1, -1000.0f, v2); ASSERT(test_eq(v2[0], 0.0f)) ASSERT(test_eq(v2[1], 0.0f)) ASSERT(test_eq(v2[2], 0.0f)) ASSERT(test_eq(v2[3], 0.0f)) GLM(vec4_stepr)(v1, -250.0f, v2); ASSERT(test_eq(v2[0], 0.0f)) ASSERT(test_eq(v2[1], 0.0f)) ASSERT(test_eq(v2[2], 0.0f)) ASSERT(test_eq(v2[3], 1.0f)) GLM(vec4_stepr)(v1, -150.0f, v2); ASSERT(test_eq(v2[0], 0.0f)) ASSERT(test_eq(v2[1], 0.0f)) ASSERT(test_eq(v2[2], 1.0f)) ASSERT(test_eq(v2[3], 1.0f)) GLM(vec4_stepr)(v1, -10.0f, v2); ASSERT(test_eq(v2[0], 0.0f)) ASSERT(test_eq(v2[1], 1.0f)) ASSERT(test_eq(v2[2], 1.0f)) ASSERT(test_eq(v2[3], 1.0f)) GLM(vec4_stepr)(v1, 0.0f, v2); ASSERT(test_eq(v2[0], 1.0f)) ASSERT(test_eq(v2[1], 1.0f)) ASSERT(test_eq(v2[2], 1.0f)) ASSERT(test_eq(v2[3], 1.0f)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec4_step) { vec4 v1 = {-100.0f, -200.0f, -10.0f, -10.0f}; vec4 s1 = {-100.0f, 0.0f, 10.0f, 10.0f}; vec4 s2 = {100.0f, -220.0f, -10.0f, -10.0f}; vec4 s3 = {100.0f, 200.0f, 10.0f, 10.0f}; vec4 v2; GLM(vec4_step)(s1, v1, v2); ASSERT(test_eq(v2[0], 1.0f)) ASSERT(test_eq(v2[1], 0.0f)) ASSERT(test_eq(v2[2], 0.0f)) ASSERT(test_eq(v2[3], 0.0f)) GLM(vec4_step)(s2, v1, v2); ASSERT(test_eq(v2[0], 0.0f)) ASSERT(test_eq(v2[1], 1.0f)) ASSERT(test_eq(v2[2], 1.0f)) ASSERT(test_eq(v2[3], 1.0f)) GLM(vec4_step)(s3, v1, v2); ASSERT(test_eq(v2[0], 0.0f)) ASSERT(test_eq(v2[1], 0.0f)) ASSERT(test_eq(v2[2], 0.0f)) ASSERT(test_eq(v2[3], 0.0f)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec4_smoothstep_uni) { vec4 v1 = {-100.0f, -200.0f, -10.0f, -10.0f}; vec4 v2; GLM(vec4_smoothstep_uni)(-200.0f, -100.0f, v1, v2); ASSERT(test_eq_th(v2[0], 1.0f, 1e-5f)) ASSERT(test_eq_th(v2[1], 0.0f, 1e-5f)) ASSERT(test_eq_th(v2[2], 1.0f, 1e-5f)) ASSERT(test_eq_th(v2[3], 1.0f, 1e-5f)) GLM(vec4_smoothstep_uni)(-250.0f, -200.0f, v1, v2); ASSERT(test_eq_th(v2[0], 1.0f, 1e-5f)) ASSERT(test_eq_th(v2[1], 1.0f, 1e-5f)) ASSERT(test_eq_th(v2[2], 1.0f, 1e-5f)) ASSERT(test_eq_th(v2[3], 1.0f, 1e-5f)) GLM(vec4_smoothstep_uni)(-200.0f, 200.0f, v1, v2); ASSERT(v2[0] > 0.0f && v2[0] < 0.25f) ASSERT(test_eq(v2[1], 0.0f)) ASSERT(v2[2] > 0.0f && v2[2] < 0.5f) ASSERT(v2[3] > 0.0f && v2[3] < 0.5f) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec4_smoothstep) { vec4 v1 = {-100.0f, -200.0f, -10.0f, -10.0f}; vec4 e1_0 = {-100.0f, 0.0f, -11.0f, -11.0f}; vec4 e1_1 = {50.0f, 10.0f, 20.0f, 20.0f}; vec4 e2_0 = {-180.0f, -300.0f, -93.0f, -93.0f}; vec4 e2_1 = {100.0f, 120.0f, -10.0f, -10.0f}; vec4 e3_0 = {-12.0f, 100.0f, 0.0f, 0.0f}; vec4 e3_1 = {100.0f, 200.0f, 10.0f, 10.0f}; vec4 v2; GLM(vec4_smoothstep)(e1_0, e1_1, v1, v2); ASSERT(test_eq_th(v2[0], 0.0f, 1e-5f)) ASSERT(test_eq_th(v2[1], 0.0f, 1e-5f)) ASSERT(v2[2] > 0.0f && v2[2] < 0.1f) ASSERT(v2[3] > 0.0f && v2[3] < 0.1f) GLM(vec4_smoothstep)(e2_0, e2_1, v1, v2); ASSERT(v2[0] > 0.0f && v2[0] < 0.25f) ASSERT(v2[1] > 0.0f && v2[1] < 0.15f) ASSERT(test_eq_th(v2[2], 1.0f, 1e-5f)) ASSERT(test_eq_th(v2[3], 1.0f, 1e-5f)) GLM(vec4_smoothstep)(e3_0, e3_1, v1, v2); ASSERT(test_eq_th(v2[0], 0.0f, 1e-5f)) ASSERT(test_eq_th(v2[1], 0.0f, 1e-5f)) ASSERT(test_eq_th(v2[2], 0.0f, 1e-5f)) ASSERT(test_eq_th(v2[3], 0.0f, 1e-5f)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec4_smoothinterp) { vec4 e1_0 = {-100.0f, 0.0f, -11.0f, -11.0f}; vec4 e1_1 = {50.0f, 10.0f, 20.0f, 20.0f}; vec4 e2_0 = {80.0f, -220.0f, -19.0f, -19.0f}; vec4 e2_1 = {100.0f, -200.0f, -10.0f, -10.0f}; vec4 e3_0 = {-12.0f, 100.0f, 0.0f, 0.0f}; vec4 e3_1 = {100.0f, 200.0f, 10.0f, 10.0f}; vec4 v2; GLM(vec4_smoothinterp)(e1_0, e1_1, 0.5f, v2); ASSERT(v2[0] >= e1_0[0] && v2[0] <= e1_1[0]) ASSERT(v2[1] >= e1_0[1] && v2[1] <= e1_1[1]) ASSERT(v2[2] >= e1_0[2] && v2[2] <= e1_1[2]) ASSERT(v2[3] >= e1_0[3] && v2[3] <= e1_1[3]) GLM(vec4_smoothinterp)(e2_0, e2_1, 0.5f, v2); ASSERT(v2[0] >= e2_0[0] && v2[0] <= e2_1[0]) ASSERT(v2[1] >= e2_0[1] && v2[1] <= e2_1[1]) ASSERT(v2[2] >= e2_0[2] && v2[2] <= e2_1[2]) ASSERT(v2[3] >= e2_0[3] && v2[3] <= e2_1[3]) GLM(vec4_smoothinterp)(e3_0, e3_1, 1.0f, v2); ASSERT(v2[0] >= e3_0[0] && v2[0] <= e3_1[0]) ASSERT(v2[1] >= e3_0[1] && v2[1] <= e3_1[1]) ASSERT(v2[2] >= e3_0[2] && v2[2] <= e3_1[2]) ASSERT(v2[3] >= e3_0[3] && v2[3] <= e3_1[3]) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec4_smoothinterpc) { vec4 e1_0 = {-100.0f, 0.0f, -11.0f, -11.0f}; vec4 e1_1 = {50.0f, 10.0f, 20.0f, 20.0f}; vec4 e2_0 = {80.0f, -220.0f, -19.0f, -19.0f}; vec4 e2_1 = {100.0f, -200.0f, -10.0f, -10.0f}; vec4 e3_0 = {-12.0f, 100.0f, 0.0f, 0.0f}; vec4 e3_1 = {100.0f, 200.0f, 10.0f, 10.0f}; vec4 v2; GLM(vec4_smoothinterpc)(e1_0, e1_1, -0.5f, v2); ASSERT(v2[0] >= e1_0[0] && v2[0] <= e1_1[0]) ASSERT(v2[1] >= e1_0[1] && v2[1] <= e1_1[1]) ASSERT(v2[2] >= e1_0[2] && v2[2] <= e1_1[2]) ASSERT(v2[3] >= e1_0[3] && v2[3] <= e1_1[3]) GLM(vec4_smoothinterpc)(e2_0, e2_1, 0.5f, v2); ASSERT(v2[0] >= e2_0[0] && v2[0] <= e2_1[0]) ASSERT(v2[1] >= e2_0[1] && v2[1] <= e2_1[1]) ASSERT(v2[2] >= e2_0[2] && v2[2] <= e2_1[2]) ASSERT(v2[3] >= e2_0[3] && v2[3] <= e2_1[3]) GLM(vec4_smoothinterpc)(e3_0, e3_1, 2.0f, v2); ASSERT(v2[0] >= e3_0[0] && v2[0] <= e3_1[0]) ASSERT(v2[1] >= e3_0[1] && v2[1] <= e3_1[1]) ASSERT(v2[2] >= e3_0[2] && v2[2] <= e3_1[2]) ASSERT(v2[3] >= e3_0[3] && v2[3] <= e3_1[3]) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec4_cubic) { vec4 v1 = {125.0f, 25.0f, 5.0f, 1.0f}; vec4 v2 = {216.0f, 36.0f, 6.0f, 1.0f}; vec4 v3, v4; ASSERT(test_eq(v1[0], v1[2] * v1[2] * v1[2])) ASSERT(test_eq(v1[1], v1[2] * v1[2])) ASSERT(test_eq(v1[3], 1.0f)) ASSERT(test_eq(v2[0], v2[2] * v2[2] * v2[2])) ASSERT(test_eq(v2[1], v2[2] * v2[2])) ASSERT(test_eq(v2[3], 1.0f)) GLM(vec4_cubic)(test_rand(), v3); ASSERT(test_eq(v3[0], v3[2] * v3[2] * v3[2])) ASSERT(test_eq(v3[1], v3[2] * v3[2])) ASSERT(test_eq(v3[3], 1.0f)) GLM(vec4_cubic)(test_rand(), v4); ASSERT(test_eq(v4[0], v4[2] * v4[2] * v4[2])) ASSERT(test_eq(v4[1], v4[2] * v4[2])) ASSERT(test_eq(v4[3], 1.0f)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec4_swizzle) { vec4 v; /* ZYX */ v[0] = 1; v[1] = 2; v[2] = 3; v[3] = 4; GLM(vec4_swizzle)(v, GLM_WZYX, v); ASSERTIFY(test_assert_vec4_eq(v, (vec4){4, 3, 2, 1})) GLM(vec4_swizzle)(v, GLM_XXXX, v); ASSERTIFY(test_assert_vec4_eq(v, (vec4){4, 4, 4, 4})) v[0] = 1; v[1] = 2; v[2] = 3; v[3] = 4; GLM(vec4_swizzle)(v, GLM_YYYY, v); ASSERTIFY(test_assert_vec4_eq(v, (vec4){2, 2, 2, 2})) v[0] = 1; v[1] = 2; v[2] = 3; v[3] = 4; GLM(vec4_swizzle)(v, GLM_ZZZZ, v); ASSERTIFY(test_assert_vec4_eq(v, (vec4){3, 3, 3, 3})) v[0] = 1; v[1] = 2; v[2] = 3; v[3] = 4; GLM(vec4_swizzle)(v, GLM_WWWW, v); ASSERTIFY(test_assert_vec4_eq(v, (vec4){4, 4, 4, 4})) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec4_broadcast) { vec4 v1, v2, v3; vec4 v5 = {-1.456f, -1.456f, -1.456f, -1.456f}; vec4 v6 = {11.0f, 11.0f, 11.0f, 11.0f}; vec4 v7 = {78.0f, 78.0f, 78.0f, 78.0f}; GLM(vec4_broadcast)(-1.456f, v1); GLM(vec4_broadcast)(11.0f, v2); GLM(vec4_broadcast)(78.0f, v3); ASSERTIFY(test_assert_vec4_eq(v1, v5)) ASSERTIFY(test_assert_vec4_eq(v2, v6)) ASSERTIFY(test_assert_vec4_eq(v3, v7)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec4_fill) { vec4 v1, v2, v3; vec4 v5 = {-1.456f, -1.456f, -1.456f, -1.456f}; vec4 v6 = {11.0f, 11.0f, 11.0f, 11.0f}; vec4 v7 = {78.0f, 78.0f, 78.0f, 78.0f}; GLM(vec4_fill)(v1, -1.456f); GLM(vec4_fill)(v2, 11.0f); GLM(vec4_fill)(v3, 78.0f); ASSERTIFY(test_assert_vec4_eq(v1, v5)) ASSERTIFY(test_assert_vec4_eq(v2, v6)) ASSERTIFY(test_assert_vec4_eq(v3, v7)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec4_eq) { vec4 v1, v2, v3; GLM(vec4_fill)(v1, -1.456f); GLM(vec4_fill)(v2, 11.0f); GLM(vec4_fill)(v3, 78.1f); ASSERT(GLM(vec4_eq)(v1, -1.456f)) ASSERT(GLM(vec4_eq)(v2, 11.0f)) ASSERT(!GLM(vec4_eq)(v3, 78.0f)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec4_eq_eps) { vec4 v1, v2, v3; GLM(vec4_fill)(v1, -1.456f); GLM(vec4_fill)(v2, 11.0f); GLM(vec4_fill)(v3, 78.1f); ASSERT(GLM(vec4_eq_eps)(v1, -1.456f)) ASSERT(GLM(vec4_eq_eps)(v2, 11.0f)) ASSERT(!GLM(vec4_eq_eps)(v3, 78.0f)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec4_eq_all) { vec4 v1, v2, v3; vec4 v4 = {2.104f, -3.012f, -4.10f, -4.10f}; vec4 v5 = {-12.35f, -31.140f, -43.502f, -43.502f}; GLM(vec4_fill)(v1, -1.456f); GLM(vec4_fill)(v2, 11.0f); GLM(vec4_fill)(v3, 78.0f); ASSERT(GLM(vec4_eq_all)(v1)) ASSERT(GLM(vec4_eq_all)(v2)) ASSERT(GLM(vec4_eq_all)(v3)) ASSERT(!GLM(vec4_eq_all)(v4)) ASSERT(!GLM(vec4_eq_all)(v5)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec4_eqv) { vec4 v1, v2, v3, v4, v5; vec4 v6 = {-1.456f, -1.456f, -1.456f, -1.456f}; vec4 v7 = {11.0f, 11.0f, 11.0f, 11.0f}; vec4 v8 = {78.0f, 78.0f, -43.502f, -43.502f}; GLM(vec4_fill)(v1, -1.456f); GLM(vec4_fill)(v2, 11.0f); GLM(vec4_fill)(v3, 78.0f); test_rand_vec4(v4); test_rand_vec4(v5); ASSERT(GLM(vec4_eqv)(v1, v6)) ASSERT(GLM(vec4_eqv)(v2, v7)) ASSERT(!GLM(vec4_eqv)(v3, v8)) ASSERT(!GLM(vec4_eqv)(v4, v5)) ASSERT(GLM(vec4_eqv)(v5, v5)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec4_eqv_eps) { vec4 v1, v2, v3, v4, v5; vec4 v6 = {-1.456f, -1.456f, -1.456f, -1.456f}; vec4 v7 = {11.0f, 11.0f, 11.0f, 11.0f}; vec4 v8 = {78.0f, 78.0f, -43.502f, -43.502f}; GLM(vec4_fill)(v1, -1.456f); GLM(vec4_fill)(v2, 11.0f); GLM(vec4_fill)(v3, 78.0f); test_rand_vec4(v4); test_rand_vec4(v5); ASSERT(GLM(vec4_eqv_eps)(v1, v6)) ASSERT(GLM(vec4_eqv_eps)(v2, v7)) ASSERT(!GLM(vec4_eqv_eps)(v3, v8)) ASSERT(!GLM(vec4_eqv_eps)(v4, v5)) ASSERT(GLM(vec4_eqv_eps)(v5, v5)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec4_max) { vec4 v1 = {2.104f, -3.012f, -4.10f, -4.10f}; vec4 v2 = {-12.35f, -31.140f, -43.502f, -43.502f}; #ifndef CGLM_FAST_MATH vec4 v3 = {INFINITY, 0.0f, 0.0f, 0.0f}; #endif // vec4 v4 = {NAN, INFINITY, 2.0f, 2.0f}; // vec4 v5 = {NAN, -1.0f, -1.0f, -1.0f}; vec4 v6 = {-1.0f, -11.0f, 11.0f, 11.0f}; ASSERT(test_eq(GLM(vec4_max)(v1), 2.104f)) ASSERT(test_eq(GLM(vec4_max)(v2), -12.35f)) #ifndef CGLM_FAST_MATH ASSERT(isinf(GLM(vec4_max)(v3))) #endif // ASSERT(isnan(GLM(vec4_max)(v4))) // ASSERT(isnan(GLM(vec4_max)(v5))) ASSERT(test_eq(GLM(vec4_max)(v6), 11.0f)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec4_min) { vec4 v1 = {2.104f, -3.012f, -4.10f, -4.10f}; vec4 v2 = {-12.35f, -31.140f, -43.502f, -43.502f}; #ifndef CGLM_FAST_MATH vec4 v3 = {INFINITY, 0.0f, 0.0f, 0.0f}; #endif // vec4 v4 = {NAN, INFINITY, 2.0f, 2.0f}; // vec4 v5 = {NAN, -1.0f, -1.0f, -1.0f}; vec4 v6 = {-1.0f, -11.0f, 11.0f, 11.0f}; ASSERT(test_eq(GLM(vec4_min)(v1), -4.10f)) ASSERT(test_eq(GLM(vec4_min)(v2), -43.502f)) #ifndef CGLM_FAST_MATH ASSERT(test_eq(GLM(vec4_min)(v3), 0.0f)) #endif // ASSERT(isnan(GLM(vec4_min)(v4))) // ASSERT(isnan(GLM(vec4_min)(v5))) ASSERT(test_eq(GLM(vec4_min)(v6), -11.0f)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec4_isnan) { #ifndef CGLM_FAST_MATH vec4 v1 = {2.104f, -3.012f, -4.10f, -4.10f}; vec4 v2 = {-12.35f, -31.140f, -43.502f, -43.502f}; vec4 v3 = {INFINITY, 0.0f, 0.0f, 0.0f}; vec4 v4 = {NAN, INFINITY, 2.0f, 2.0f}; vec4 v5 = {NAN, -1.0f, -1.0f, -1.0f}; vec4 v6 = {-1.0f, -1.0f, 11.0f, 11.0f}; ASSERT(!GLM(vec4_isnan)(v1)) ASSERT(!GLM(vec4_isnan)(v2)) ASSERT(!GLM(vec4_isnan)(v3)) ASSERT(GLM(vec4_isnan)(v4)) ASSERT(GLM(vec4_isnan)(v5)) ASSERT(!GLM(vec4_isnan)(v6)) #endif TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec4_isinf) { #ifndef CGLM_FAST_MATH vec4 v1 = {2.104f, -3.012f, -4.10f, -4.10f}; vec4 v2 = {-12.35f, -31.140f, -43.502f, -43.502f}; vec4 v3 = {INFINITY, 0.0f, 0.0f, 0.0f}; vec4 v4 = {NAN, INFINITY, 2.0f, 2.0f}; vec4 v5 = {NAN, -1.0f, -1.0f, -1.0f}; vec4 v6 = {-1.0f, -1.0f, 11.0f, 11.0f}; ASSERT(!GLM(vec4_isinf)(v1)) ASSERT(!GLM(vec4_isinf)(v2)) ASSERT(GLM(vec4_isinf)(v3)) ASSERT(GLM(vec4_isinf)(v4)) ASSERT(!GLM(vec4_isinf)(v5)) ASSERT(!GLM(vec4_isinf)(v6)) #endif TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec4_isvalid) { #ifndef CGLM_FAST_MATH vec4 v1 = {2.104f, -3.012f, -4.10f, -4.10f}; vec4 v2 = {-12.35f, -31.140f, -43.502f, -43.502f}; vec4 v3 = {INFINITY, 0.0f, 0.0f, 0.0f}; vec4 v4 = {NAN, INFINITY, 2.0f, 2.0f}; vec4 v5 = {NAN, -1.0f, -1.0f, -1.0f}; vec4 v6 = {-1.0f, -1.0f, 11.0f, 11.0f}; ASSERT(GLM(vec4_isvalid)(v1)) ASSERT(GLM(vec4_isvalid)(v2)) ASSERT(!GLM(vec4_isvalid)(v3)) ASSERT(!GLM(vec4_isvalid)(v4)) ASSERT(!GLM(vec4_isvalid)(v5)) ASSERT(GLM(vec4_isvalid)(v6)) #endif TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec4_sign) { vec4 v1 = {2.104f, -3.012f, -4.10f, -4.10f}; vec4 v2 = {-12.35f, -31.140f, -43.502f, -43.502f}; vec4 v3, v4; vec4 v5 = {1.0f, -1.0f, -1.0f, -1.0f}; vec4 v6 = {-1.0f, -1.0f, -1.0f, -1.0f}; GLM(vec4_sign)(v1, v3); GLM(vec4_sign)(v2, v4); ASSERTIFY(test_assert_vec4_eq(v3, v5)) ASSERTIFY(test_assert_vec4_eq(v4, v6)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec4_abs) { vec4 v1 = {2.104f, -3.012f, -4.10f, -4.10f}; vec4 v2 = {-12.35f, -31.140f, -43.502f, -43.502f}; vec4 v3, v4; vec4 v5 = {2.104f, 3.012f, 4.10f, 4.10f}; vec4 v6 = {12.35f, 31.140f, 43.502f, 43.502f}; GLM(vec4_abs)(v1, v3); GLM(vec4_abs)(v2, v4); ASSERTIFY(test_assert_vec4_eq(v3, v5)) ASSERTIFY(test_assert_vec4_eq(v4, v6)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec4_fract) { vec4 v1 = {2.104f, 3.012f, 4.10f, 4.10f}; vec4 v2 = {12.35f, 31.140f, 43.502f, 43.502f}; vec4 v3, v4; vec4 v5 = {0.104f, 0.012f, 0.10f, 0.10f}; vec4 v6 = {0.35f, 0.140f, 0.502f, 0.502f}; GLM(vec4_fract)(v1, v3); GLM(vec4_fract)(v2, v4); ASSERTIFY(test_assert_vec4_eq(v3, v5)) ASSERTIFY(test_assert_vec4_eq(v4, v6)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec4_floor) { vec4 v1 = {2.104f, 3.012f, 4.10f, 4.10f}; vec4 v2 = {12.35f, 31.140f, 43.502f, 43.502f}; vec4 v3, v4; vec4 v5 = {2.0f, 3.0f, 4.0f, 4.0f}; vec4 v6 = {12.0f, 31.0f, 43.0f, 43.0f}; GLM(vec4_floor)(v1, v3); GLM(vec4_floor)(v2, v4); ASSERTIFY(test_assert_vec4_eq(v3, v5)) ASSERTIFY(test_assert_vec4_eq(v4, v6)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec4_mods) { vec4 v1 = {2.104f, 3.012f, 4.10f, 5.78f}, v2 = {12.35f, 31.140f, 43.502f, 198.999f}; vec4 v3, v4; vec4 v5 = {0.104f, 0.012f, 0.10f, 0.78f}, v6 = {0.35f, 0.140f, 0.502f, 0.999f}; /* Mod 1 - leaves just the fractional part */ GLM(vec4_mods)(v1, 1.0f, v3); GLM(vec4_mods)(v2, 1.0f, v4); ASSERTIFY(test_assert_vec4_eq(v3, v5)) ASSERTIFY(test_assert_vec4_eq(v4, v6)) /* Mod 2 - parity + fractional part */ GLM(vec4_mods)(v1, 2.0f, v3); GLM(vec4_mods)(v2, 2.0f, v4); vec4 v7 = {0.104f, 1.012f, 0.10f, 1.78f}, v8 = {0.35f, 1.140f, 1.502f, 0.999f}; ASSERTIFY(test_assert_vec4_eq(v3, v7)) ASSERTIFY(test_assert_vec4_eq(v4, v8)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec4_hadd) { vec4 v1 = {2.0f, 3.0f, 4.0f, 4.0f}, v2 = {12.0f, 31.0f, 43.0f, 43.0f}; float r1, r2, r3, r4; r1 = GLM(vec4_hadd)(v1); r2 = GLM(vec4_hadd)(v2); r3 = v1[0] + v1[1] + v1[2] + v1[3]; r4 = v2[0] + v2[1] + v2[2] + v2[3]; ASSERT(test_eq(r1, r3)) ASSERT(test_eq(r2, r4)) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec4_sqrt) { vec4 v1 = {2.0f, 3.0f, 4.0f, 4.0f}, v2 = {12.0f, 31.0f, 43.0f, 43.0f}; vec4 v3, v4; GLM(vec4_sqrt)(v1, v3); GLM(vec4_sqrt)(v2, v4); ASSERT(test_eq(sqrtf(v1[0]), v3[0])) ASSERT(test_eq(sqrtf(v1[1]), v3[1])) ASSERT(test_eq(sqrtf(v1[2]), v3[2])) ASSERT(test_eq(sqrtf(v1[3]), v3[3])) ASSERT(test_eq(sqrtf(v2[0]), v4[0])) ASSERT(test_eq(sqrtf(v2[1]), v4[1])) ASSERT(test_eq(sqrtf(v2[2]), v4[2])) ASSERT(test_eq(sqrtf(v2[3]), v4[3])) TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec4_make) { float src[12] = { 7.2f, 1.0f, 5.8f, 0.0f, 2.5f, 6.1f, 9.9f, 1.0f, 17.7f, 4.3f, 3.2f, 1.0f }; vec4 dest[3]; float *srcp = src; unsigned int i, j; for (i = 0, j = 0; i < sizeof(src) / sizeof(float); i+=4,j++) { GLM(vec4_make)(srcp + i, dest[j]); ASSERT(test_eq(src[ i ], dest[j][0])); ASSERT(test_eq(src[i+1], dest[j][1])); ASSERT(test_eq(src[i+2], dest[j][2])); ASSERT(test_eq(src[i+3], dest[j][3])); } TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec4_reflect) { vec4 dest; /* Original test: Reflecting off a horizontal surface */ vec4 I1 = {1.0f, -1.0f, 0.0f, 0.0f}; /* Incoming vector */ vec4 N1 = {0.0f, 1.0f, 0.0f, 0.0f}; /* Normal vector */ GLM(vec4_reflect)(I1, N1, dest); ASSERT(fabsf(dest[0] - 1.0f) < 0.00001f && fabsf(dest[1] - 1.0f) < 0.00001f && fabsf(dest[2] - 0.0f) < 0.00001f && fabsf(dest[3] - 0.0f) < 0.00001f); /* Expect reflection */ /* Scenario 2: Reflecting off a vertical surface */ vec4 I2 = {1.0f, 0.0f, 0.0f, 0.0f}; /* Incoming vector */ vec4 N2 = {-1.0f, 0.0f, 0.0f, 0.0f}; /* Normal vector */ GLM(vec4_reflect)(I2, N2, dest); ASSERT(fabsf(dest[0] + 1.0f) < 0.00001f && fabsf(dest[1]) < 0.00001f && fabsf(dest[2]) < 0.00001f && fabsf(dest[3] - 0.0f) < 0.00001f); /* Expect reflection to the left */ /* Scenario 3: Reflecting at an angle */ vec4 I3 = {sqrtf(2)/2, -sqrtf(2)/2, 0.0f, 0.0f}; /* Incoming vector at 45 degrees */ vec4 N3 = {0.0f, 1.0f, 0.0f, 0.0f}; /* Upwards normal vector */ GLM(vec4_reflect)(I3, N3, dest); ASSERT(fabsf(dest[0] - sqrtf(2)/2) < 0.00001f && fabsf(dest[1] - sqrtf(2)/2) < 0.00001f && fabsf(dest[2]) < 0.00001f && fabsf(dest[3] - 0.0f) < 0.00001f); /* Expect reflection upwards */ TEST_SUCCESS } TEST_IMPL(GLM_PREFIX, vec4_refract) { vec4 v = {sqrtf(0.5f), -sqrtf(0.5f), 0.0f, 0.0f}; /* Incoming vector */ vec4 N = {0.0f, 1.0f, 0.0f, 0.0f}; /* Surface normal */ vec4 dest; float eta; float r; /* Water to Air (eta = 1.33/1.0) */ eta = 1.33f / 1.0f; r = GLM(vec4_refract)(v, N, eta, dest); if (!(dest[0] == 0.0f && dest[1] == 0.0f && dest[2] == 0.0f && dest[3] == 0.0f)) { ASSERT(dest[1] < -0.3f); ASSERT(r == true); } else { ASSERT(dest[0] == 0.0f && dest[1] == 0.0f && dest[2] == 0.0f && dest[3] == 0.0f); ASSERT(r == false); } /* Air to Glass (eta = 1.0 / 1.5) */ eta = 1.0f / 1.5f; r = GLM(vec4_refract)(v, N, eta, dest); ASSERT(r == true); ASSERT(dest[1] < -sqrtf(0.5f)); // Expect bending towards the normal /* Glass to Water (eta = 1.5 / 1.33) */ eta = 1.5f / 1.33f; r = GLM(vec4_refract)(v, N, eta, dest); ASSERT(r == true); ASSERT(dest[1] < -0.6f); // Expect bending towards the normal, less bending than air to glass /* Diamond to Air (eta = 2.42 / 1.0) */ eta = 2.42f / 1.0f; r = GLM(vec4_refract)(v, N, eta, dest); if (!(dest[0] == 0.0f && dest[1] == 0.0f && dest[2] == 0.0f && dest[3] == 0.0f)) { /* High potential for total internal reflection, but if it occurs, expect significant bending */ ASSERT(dest[1] < -sqrtf(0.5f)); ASSERT(r == true); } else { ASSERT(dest[0] == 0.0f && dest[1] == 0.0f && dest[2] == 0.0f && dest[3] == 0.0f); ASSERT(r == false); } TEST_SUCCESS } cglm-0.9.6/test/src/tests.c000066400000000000000000000042101475344456400155410ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ /* test inline */ /*---------------------------------------------------------------------------*/ #define GLM_PREFIX glm_ #define GLM(X) (glm_ ## X) #include "test_vec2.h" #include "test_vec3.h" #include "test_vec4.h" #include "test_ivec2.h" #include "test_ivec3.h" #include "test_ivec4.h" #include "test_mat2.h" #include "test_mat2x3.h" #include "test_mat2x4.h" #include "test_mat3.h" #include "test_mat3x2.h" #include "test_mat3x4.h" #include "test_mat4.h" #include "test_mat4x2.h" #include "test_mat4x3.h" #include "test_quat.h" #include "test_project.h" #include "test_plane.h" #include "test_noise.h" #include "test_affine.h" #include "test_affine2d.h" #include "test_affine_mat.h" #include "test_aabb2d.h" #include "test_ray.h" #include "test_cam.h" #include "test_cam_lh_no.h" #include "test_cam_lh_zo.h" #include "test_cam_rh_no.h" #include "test_cam_rh_zo.h" #include "test_euler_to_quat_rh.h" #include "test_euler_to_quat_lh.h" #undef GLM #undef GLM_PREFIX /* test pre-compiled */ /*---------------------------------------------------------------------------*/ #define GLM_PREFIX glmc_ #define GLM(X) (glmc_ ## X) #include "test_vec2.h" #include "test_vec3.h" #include "test_vec4.h" #include "test_ivec2.h" #include "test_ivec3.h" #include "test_ivec4.h" #include "test_mat2.h" #include "test_mat2x3.h" #include "test_mat2x4.h" #include "test_mat3.h" #include "test_mat3x2.h" #include "test_mat3x4.h" #include "test_mat4.h" #include "test_mat4x2.h" #include "test_mat4x3.h" #include "test_quat.h" #include "test_project.h" #include "test_plane.h" #include "test_noise.h" #include "test_affine.h" #include "test_affine2d.h" #include "test_affine_mat.h" #include "test_aabb2d.h" #include "test_ray.h" #include "test_cam.h" #include "test_cam_lh_no.h" #include "test_cam_lh_zo.h" #include "test_cam_rh_no.h" #include "test_cam_rh_zo.h" #include "test_euler_to_quat_rh.h" #include "test_euler_to_quat_lh.h" #undef GLM #undef GLM_PREFIX /*---------------------------------------------------------------------------*/ cglm-0.9.6/test/tests.h000066400000000000000000002106541475344456400147720ustar00rootroot00000000000000/* * Copyright (c), Recep Aslantas. * * MIT License (MIT), http://opensource.org/licenses/MIT * Full license can be found in the LICENSE file */ #ifndef tests_h #define tests_h #include "include/common.h" /* * To register a test: * 1. use TEST_DECLARE() to forward declare test * 2. use TEST_ENTRY() to add test to list */ /* affine mat */ TEST_DECLARE(glm_mul) TEST_DECLARE(glm_mul) TEST_DECLARE(glm_inv_tr) TEST_DECLARE(glmc_mul) TEST_DECLARE(glmc_mul_rot) TEST_DECLARE(glmc_inv_tr) /* affine */ TEST_DECLARE(glm_translate) TEST_DECLARE(glm_translate_to) TEST_DECLARE(glm_translate_x) TEST_DECLARE(glm_translate_y) TEST_DECLARE(glm_translate_z) TEST_DECLARE(glm_translate_make) TEST_DECLARE(glm_scale_to) TEST_DECLARE(glm_scale_make) TEST_DECLARE(glm_scale) TEST_DECLARE(glm_scale_uni) TEST_DECLARE(glm_rotate_x) TEST_DECLARE(glm_rotate_y) TEST_DECLARE(glm_rotate_z) TEST_DECLARE(glm_rotate_make) TEST_DECLARE(glm_rotate) TEST_DECLARE(glm_rotate_at) TEST_DECLARE(glm_rotate_atm) TEST_DECLARE(glm_decompose_scalev) TEST_DECLARE(glm_uniscaled) TEST_DECLARE(glm_decompose_rs) TEST_DECLARE(glm_decompose) TEST_DECLARE(glmc_translate) TEST_DECLARE(glmc_translate_to) TEST_DECLARE(glmc_translate_x) TEST_DECLARE(glmc_translate_y) TEST_DECLARE(glmc_translate_z) TEST_DECLARE(glmc_translate_make) TEST_DECLARE(glmc_scale_to) TEST_DECLARE(glmc_scale_make) TEST_DECLARE(glmc_scale) TEST_DECLARE(glmc_scale_uni) TEST_DECLARE(glmc_rotate_x) TEST_DECLARE(glmc_rotate_y) TEST_DECLARE(glmc_rotate_z) TEST_DECLARE(glmc_rotate_make) TEST_DECLARE(glmc_rotate) TEST_DECLARE(glmc_rotate_at) TEST_DECLARE(glmc_rotate_atm) TEST_DECLARE(glmc_decompose_scalev) TEST_DECLARE(glmc_uniscaled) TEST_DECLARE(glmc_decompose_rs) TEST_DECLARE(glmc_decompose) /* affine 2d */ TEST_DECLARE(glm_translate2d) TEST_DECLARE(glm_translate2d_to) TEST_DECLARE(glm_translate2d_x) TEST_DECLARE(glm_translate2d_y) TEST_DECLARE(glm_translate2d_make) TEST_DECLARE(glm_scale2d_to) TEST_DECLARE(glm_scale2d_make) TEST_DECLARE(glm_scale2d) TEST_DECLARE(glm_scale2d_uni) TEST_DECLARE(glm_rotate2d_make) TEST_DECLARE(glm_rotate2d) TEST_DECLARE(glm_rotate2d_to) TEST_DECLARE(glmc_translate2d) TEST_DECLARE(glmc_translate2d_to) TEST_DECLARE(glmc_translate2d_x) TEST_DECLARE(glmc_translate2d_y) TEST_DECLARE(glmc_translate2d_make) TEST_DECLARE(glmc_scale2d_to) TEST_DECLARE(glmc_scale2d_make) TEST_DECLARE(glmc_scale2d) TEST_DECLARE(glmc_scale2d_uni) TEST_DECLARE(glmc_rotate2d_make) TEST_DECLARE(glmc_rotate2d) TEST_DECLARE(glmc_rotate2d_to) /* aabb2d */ TEST_DECLARE(glm_aabb2d_sizev) /* mat4 */ TEST_DECLARE(glm_mat4_ucopy) TEST_DECLARE(glm_mat4_copy) TEST_DECLARE(glm_mat4_identity) TEST_DECLARE(glm_mat4_identity_array) TEST_DECLARE(glm_mat4_zero) TEST_DECLARE(glm_mat4_pick3) TEST_DECLARE(glm_mat4_pick3t) TEST_DECLARE(glm_mat4_ins3) TEST_DECLARE(glm_mat4_mul) TEST_DECLARE(glm_mat4_mulN) TEST_DECLARE(glm_mat4_mulv) TEST_DECLARE(glm_mat4_mulv3) TEST_DECLARE(glm_mat4_trace) TEST_DECLARE(glm_mat4_trace3) TEST_DECLARE(glm_mat4_quat) TEST_DECLARE(glm_mat4_transpose_to) TEST_DECLARE(glm_mat4_transpose) TEST_DECLARE(glm_mat4_scale_p) TEST_DECLARE(glm_mat4_scale) TEST_DECLARE(glm_mat4_det) TEST_DECLARE(glm_mat4_inv) TEST_DECLARE(glm_mat4_inv_fast) TEST_DECLARE(glm_mat4_inv_precise) TEST_DECLARE(glm_mat4_swap_col) TEST_DECLARE(glm_mat4_swap_row) TEST_DECLARE(glm_mat4_rmc) TEST_DECLARE(glm_mat4_make) TEST_DECLARE(glmc_mat4_ucopy) TEST_DECLARE(glmc_mat4_copy) TEST_DECLARE(glmc_mat4_identity) TEST_DECLARE(glmc_mat4_identity_array) TEST_DECLARE(glmc_mat4_zero) TEST_DECLARE(glmc_mat4_pick3) TEST_DECLARE(glmc_mat4_pick3t) TEST_DECLARE(glmc_mat4_ins3) TEST_DECLARE(glmc_mat4_mul) TEST_DECLARE(glmc_mat4_mulN) TEST_DECLARE(glmc_mat4_mulv) TEST_DECLARE(glmc_mat4_mulv3) TEST_DECLARE(glmc_mat4_trace) TEST_DECLARE(glmc_mat4_trace3) TEST_DECLARE(glmc_mat4_quat) TEST_DECLARE(glmc_mat4_transpose_to) TEST_DECLARE(glmc_mat4_transpose) TEST_DECLARE(glmc_mat4_scale_p) TEST_DECLARE(glmc_mat4_scale) TEST_DECLARE(glmc_mat4_det) TEST_DECLARE(glmc_mat4_inv) TEST_DECLARE(glmc_mat4_inv_fast) TEST_DECLARE(glmc_mat4_swap_col) TEST_DECLARE(glmc_mat4_swap_row) TEST_DECLARE(glmc_mat4_rmc) TEST_DECLARE(glmc_mat4_make) TEST_DECLARE(MACRO_GLM_MAT4X2_ZERO_INIT) TEST_DECLARE(MACRO_GLM_MAT4X2_ZERO) TEST_DECLARE(glm_mat4x2_copy) TEST_DECLARE(glm_mat4x2_zero) TEST_DECLARE(glm_mat4x2_make) TEST_DECLARE(glm_mat4x2_mul) TEST_DECLARE(glm_mat4x2_mulv) TEST_DECLARE(glm_mat4x2_transpose) TEST_DECLARE(glm_mat4x2_scale) TEST_DECLARE(glmc_mat4x2_copy) TEST_DECLARE(glmc_mat4x2_zero) TEST_DECLARE(glmc_mat4x2_make) TEST_DECLARE(glmc_mat4x2_mul) TEST_DECLARE(glmc_mat4x2_mulv) TEST_DECLARE(glmc_mat4x2_transpose) TEST_DECLARE(glmc_mat4x2_scale) TEST_DECLARE(MACRO_GLM_MAT4X3_ZERO_INIT) TEST_DECLARE(MACRO_GLM_MAT4X3_ZERO) TEST_DECLARE(glm_mat4x3_copy) TEST_DECLARE(glm_mat4x3_zero) TEST_DECLARE(glm_mat4x3_make) TEST_DECLARE(glm_mat4x3_mul) TEST_DECLARE(glm_mat4x3_mulv) TEST_DECLARE(glm_mat4x3_transpose) TEST_DECLARE(glm_mat4x3_scale) TEST_DECLARE(glmc_mat4x3_copy) TEST_DECLARE(glmc_mat4x3_zero) TEST_DECLARE(glmc_mat4x3_make) TEST_DECLARE(glmc_mat4x3_mul) TEST_DECLARE(glmc_mat4x3_mulv) TEST_DECLARE(glmc_mat4x3_transpose) TEST_DECLARE(glmc_mat4x3_scale) /* mat3 */ TEST_DECLARE(glm_mat3_copy) TEST_DECLARE(glm_mat3_identity) TEST_DECLARE(glm_mat3_identity_array) TEST_DECLARE(glm_mat3_zero) TEST_DECLARE(glm_mat3_mul) TEST_DECLARE(glm_mat3_mulv) TEST_DECLARE(glm_mat3_trace) TEST_DECLARE(glm_mat3_quat) TEST_DECLARE(glm_mat3_transpose_to) TEST_DECLARE(glm_mat3_transpose) TEST_DECLARE(glm_mat3_scale) TEST_DECLARE(glm_mat3_det) TEST_DECLARE(glm_mat3_inv) TEST_DECLARE(glm_mat3_swap_col) TEST_DECLARE(glm_mat3_swap_row) TEST_DECLARE(glm_mat3_rmc) TEST_DECLARE(glm_mat3_make) TEST_DECLARE(glmc_mat3_copy) TEST_DECLARE(glmc_mat3_identity) TEST_DECLARE(glmc_mat3_identity_array) TEST_DECLARE(glmc_mat3_zero) TEST_DECLARE(glmc_mat3_mul) TEST_DECLARE(glmc_mat3_mulv) TEST_DECLARE(glmc_mat3_trace) TEST_DECLARE(glmc_mat3_quat) TEST_DECLARE(glmc_mat3_transpose_to) TEST_DECLARE(glmc_mat3_transpose) TEST_DECLARE(glmc_mat3_scale) TEST_DECLARE(glmc_mat3_det) TEST_DECLARE(glmc_mat3_inv) TEST_DECLARE(glmc_mat3_swap_col) TEST_DECLARE(glmc_mat3_swap_row) TEST_DECLARE(glmc_mat3_rmc) TEST_DECLARE(glmc_mat3_make) TEST_DECLARE(MACRO_GLM_MAT3X2_ZERO_INIT) TEST_DECLARE(MACRO_GLM_MAT3X2_ZERO) TEST_DECLARE(glm_mat3x2_copy) TEST_DECLARE(glm_mat3x2_zero) TEST_DECLARE(glm_mat3x2_make) TEST_DECLARE(glm_mat3x2_mul) TEST_DECLARE(glm_mat3x2_mulv) TEST_DECLARE(glm_mat3x2_transpose) TEST_DECLARE(glm_mat3x2_scale) TEST_DECLARE(glmc_mat3x2_copy) TEST_DECLARE(glmc_mat3x2_zero) TEST_DECLARE(glmc_mat3x2_make) TEST_DECLARE(glmc_mat3x2_mul) TEST_DECLARE(glmc_mat3x2_mulv) TEST_DECLARE(glmc_mat3x2_transpose) TEST_DECLARE(glmc_mat3x2_scale) TEST_DECLARE(MACRO_GLM_MAT3X4_ZERO_INIT) TEST_DECLARE(MACRO_GLM_MAT3X4_ZERO) TEST_DECLARE(glm_mat3x4_make) TEST_DECLARE(glmc_mat3x4_make) TEST_DECLARE(MACRO_GLM_MAT2_IDENTITY_INIT) TEST_DECLARE(MACRO_GLM_MAT2_ZERO_INIT) TEST_DECLARE(MACRO_GLM_MAT2_IDENTITY) TEST_DECLARE(MACRO_GLM_MAT2_ZERO) TEST_DECLARE(glm_mat2_copy) TEST_DECLARE(glm_mat2_identity) TEST_DECLARE(glm_mat2_identity_array) TEST_DECLARE(glm_mat2_zero) TEST_DECLARE(glm_mat2_mul) TEST_DECLARE(glm_mat2_transpose_to) TEST_DECLARE(glm_mat2_transpose) TEST_DECLARE(glm_mat2_mulv) TEST_DECLARE(glm_mat2_trace) TEST_DECLARE(glm_mat2_scale) TEST_DECLARE(glm_mat2_det) TEST_DECLARE(glm_mat2_inv) TEST_DECLARE(glm_mat2_swap_col) TEST_DECLARE(glm_mat2_swap_row) TEST_DECLARE(glm_mat2_rmc) TEST_DECLARE(glm_mat2_make) TEST_DECLARE(glmc_mat2_copy) TEST_DECLARE(glmc_mat2_identity) TEST_DECLARE(glmc_mat2_identity_array) TEST_DECLARE(glmc_mat2_zero) TEST_DECLARE(glmc_mat2_mul) TEST_DECLARE(glmc_mat2_transpose_to) TEST_DECLARE(glmc_mat2_transpose) TEST_DECLARE(glmc_mat2_mulv) TEST_DECLARE(glmc_mat2_trace) TEST_DECLARE(glmc_mat2_scale) TEST_DECLARE(glmc_mat2_det) TEST_DECLARE(glmc_mat2_inv) TEST_DECLARE(glmc_mat2_swap_col) TEST_DECLARE(glmc_mat2_swap_row) TEST_DECLARE(glmc_mat2_rmc) TEST_DECLARE(glmc_mat2_make) TEST_DECLARE(MACRO_GLM_MAT2X3_ZERO_INIT) TEST_DECLARE(MACRO_GLM_MAT2X3_ZERO) TEST_DECLARE(glm_mat2x3_copy) TEST_DECLARE(glm_mat2x3_zero) TEST_DECLARE(glm_mat2x3_make) TEST_DECLARE(glm_mat2x3_mul) TEST_DECLARE(glm_mat2x3_mulv) TEST_DECLARE(glm_mat2x3_transpose) TEST_DECLARE(glm_mat2x3_scale) TEST_DECLARE(glmc_mat2x3_copy) TEST_DECLARE(glmc_mat2x3_zero) TEST_DECLARE(glmc_mat2x3_make) TEST_DECLARE(glmc_mat2x3_mul) TEST_DECLARE(glmc_mat2x3_mulv) TEST_DECLARE(glmc_mat2x3_transpose) TEST_DECLARE(glmc_mat2x3_scale) TEST_DECLARE(MACRO_GLM_MAT2X4_ZERO_INIT) TEST_DECLARE(MACRO_GLM_MAT2X4_ZERO) TEST_DECLARE(glm_mat2x4_copy) TEST_DECLARE(glm_mat2x4_zero) TEST_DECLARE(glm_mat2x4_make) TEST_DECLARE(glm_mat2x4_mul) TEST_DECLARE(glm_mat2x4_mulv) TEST_DECLARE(glm_mat2x4_transpose) TEST_DECLARE(glm_mat2x4_scale) TEST_DECLARE(glmc_mat2x4_copy) TEST_DECLARE(glmc_mat2x4_zero) TEST_DECLARE(glmc_mat2x4_make) TEST_DECLARE(glmc_mat2x4_mul) TEST_DECLARE(glmc_mat2x4_mulv) TEST_DECLARE(glmc_mat2x4_transpose) TEST_DECLARE(glmc_mat2x4_scale) /* camera (incl [LR]H cross [NZ]O) */ TEST_DECLARE(glm_perspective_lh_zo) TEST_DECLARE(glm_perspective_rh_zo) TEST_DECLARE(glm_perspective_lh_no) TEST_DECLARE(glm_perspective_rh_no) TEST_DECLARE(glm_camera_lookat) TEST_DECLARE(glm_camera_decomp) TEST_DECLARE(glmc_perspective_lh_zo) TEST_DECLARE(glmc_perspective_rh_zo) TEST_DECLARE(glmc_perspective_lh_no) TEST_DECLARE(glmc_perspective_rh_no) TEST_DECLARE(glmc_camera_lookat) TEST_DECLARE(glmc_camera_decomp) TEST_DECLARE(glm_frustum) TEST_DECLARE(glmc_frustum) /* project */ TEST_DECLARE(glm_unprojecti) TEST_DECLARE(glm_unproject) TEST_DECLARE(glm_project) TEST_DECLARE(glmc_unprojecti) TEST_DECLARE(glmc_unproject) TEST_DECLARE(glmc_project) /* plane */ TEST_DECLARE(glm_plane_normalize) TEST_DECLARE(glmc_plane_normalize) /* noise */ TEST_DECLARE(glm_perlin_vec4) TEST_DECLARE(glmc_perlin_vec4) TEST_DECLARE(glm_perlin_vec3) TEST_DECLARE(glmc_perlin_vec3) TEST_DECLARE(glm_perlin_vec2) TEST_DECLARE(glmc_perlin_vec2) /* utils */ TEST_DECLARE(clamp) /* euler */ TEST_DECLARE(glm_euler_xyz_quat_rh) TEST_DECLARE(glm_euler_xzy_quat_rh) TEST_DECLARE(glm_euler_yxz_quat_rh) TEST_DECLARE(glm_euler_yzx_quat_rh) TEST_DECLARE(glm_euler_zxy_quat_rh) TEST_DECLARE(glm_euler_zyx_quat_rh) TEST_DECLARE(glm_euler_xyz_quat_lh) TEST_DECLARE(glm_euler_xzy_quat_lh) TEST_DECLARE(glm_euler_yxz_quat_lh) TEST_DECLARE(glm_euler_yzx_quat_lh) TEST_DECLARE(glm_euler_zxy_quat_lh) TEST_DECLARE(glm_euler_zyx_quat_lh) TEST_DECLARE(glmc_euler_xyz_quat_rh) TEST_DECLARE(glmc_euler_xzy_quat_rh) TEST_DECLARE(glmc_euler_yxz_quat_rh) TEST_DECLARE(glmc_euler_yzx_quat_rh) TEST_DECLARE(glmc_euler_zxy_quat_rh) TEST_DECLARE(glmc_euler_zyx_quat_rh) TEST_DECLARE(glmc_euler_xyz_quat_lh) TEST_DECLARE(glmc_euler_xzy_quat_lh) TEST_DECLARE(glmc_euler_yxz_quat_lh) TEST_DECLARE(glmc_euler_yzx_quat_lh) TEST_DECLARE(glmc_euler_zxy_quat_lh) TEST_DECLARE(glmc_euler_zyx_quat_lh) TEST_DECLARE(euler) /* ray */ TEST_DECLARE(glm_ray_triangle) TEST_DECLARE(glm_ray_sphere) TEST_DECLARE(glm_ray_at) TEST_DECLARE(glmc_ray_triangle) TEST_DECLARE(glmc_ray_sphere) TEST_DECLARE(glmc_ray_at) /* quat */ TEST_DECLARE(MACRO_GLM_QUAT_IDENTITY_INIT) TEST_DECLARE(MACRO_GLM_QUAT_IDENTITY) TEST_DECLARE(glm_quat_identity) TEST_DECLARE(glm_quat_identity_array) TEST_DECLARE(glm_quat_init) TEST_DECLARE(glm_quatv) TEST_DECLARE(glm_quat) TEST_DECLARE(glm_quat_copy) TEST_DECLARE(glm_quat_norm) TEST_DECLARE(glm_quat_normalize_to) TEST_DECLARE(glm_quat_normalize) TEST_DECLARE(glm_quat_dot) TEST_DECLARE(glm_quat_conjugate) TEST_DECLARE(glm_quat_inv) TEST_DECLARE(glm_quat_add) TEST_DECLARE(glm_quat_sub) TEST_DECLARE(glm_quat_real) TEST_DECLARE(glm_quat_imag) TEST_DECLARE(glm_quat_imagn) TEST_DECLARE(glm_quat_imaglen) TEST_DECLARE(glm_quat_angle) TEST_DECLARE(glm_quat_axis) TEST_DECLARE(glm_quat_mul) TEST_DECLARE(glm_quat_mat4) TEST_DECLARE(glm_quat_mat4t) TEST_DECLARE(glm_quat_mat3) TEST_DECLARE(glm_quat_mat3t) TEST_DECLARE(glm_quat_lerp) TEST_DECLARE(glm_quat_lerpc) TEST_DECLARE(glm_quat_nlerp) TEST_DECLARE(glm_quat_slerp) TEST_DECLARE(glm_quat_look) TEST_DECLARE(glm_quat_for) TEST_DECLARE(glm_quat_forp) TEST_DECLARE(glm_quat_rotatev) TEST_DECLARE(glm_quat_rotate) TEST_DECLARE(glm_quat_rotate_at) TEST_DECLARE(glm_quat_rotate_atm) TEST_DECLARE(glm_quat_from_vecs) TEST_DECLARE(glm_quat_make) TEST_DECLARE(glmc_quat_identity) TEST_DECLARE(glmc_quat_identity_array) TEST_DECLARE(glmc_quat_init) TEST_DECLARE(glmc_quatv) TEST_DECLARE(glmc_quat) TEST_DECLARE(glmc_quat_copy) TEST_DECLARE(glmc_quat_norm) TEST_DECLARE(glmc_quat_normalize_to) TEST_DECLARE(glmc_quat_normalize) TEST_DECLARE(glmc_quat_dot) TEST_DECLARE(glmc_quat_conjugate) TEST_DECLARE(glmc_quat_inv) TEST_DECLARE(glmc_quat_add) TEST_DECLARE(glmc_quat_sub) TEST_DECLARE(glmc_quat_real) TEST_DECLARE(glmc_quat_imag) TEST_DECLARE(glmc_quat_imagn) TEST_DECLARE(glmc_quat_imaglen) TEST_DECLARE(glmc_quat_angle) TEST_DECLARE(glmc_quat_axis) TEST_DECLARE(glmc_quat_mul) TEST_DECLARE(glmc_quat_mat4) TEST_DECLARE(glmc_quat_mat4t) TEST_DECLARE(glmc_quat_mat3) TEST_DECLARE(glmc_quat_mat3t) TEST_DECLARE(glmc_quat_lerp) TEST_DECLARE(glmc_quat_lerpc) TEST_DECLARE(glmc_quat_nlerp) TEST_DECLARE(glmc_quat_slerp) TEST_DECLARE(glmc_quat_look) TEST_DECLARE(glmc_quat_for) TEST_DECLARE(glmc_quat_forp) TEST_DECLARE(glmc_quat_rotatev) TEST_DECLARE(glmc_quat_rotate) TEST_DECLARE(glmc_quat_rotate_at) TEST_DECLARE(glmc_quat_rotate_atm) TEST_DECLARE(glmc_quat_from_vecs) TEST_DECLARE(glmc_quat_make) /* bezier */ TEST_DECLARE(bezier) /* vec2 */ TEST_DECLARE(MACRO_GLM_VEC2_ONE_INIT) TEST_DECLARE(MACRO_GLM_VEC2_ZERO_INIT) TEST_DECLARE(MACRO_GLM_VEC2_ONE) TEST_DECLARE(MACRO_GLM_VEC2_ZERO) TEST_DECLARE(glm_vec2) TEST_DECLARE(glm_vec2_copy) TEST_DECLARE(glm_vec2_zero) TEST_DECLARE(glm_vec2_one) TEST_DECLARE(glm_vec2_dot) TEST_DECLARE(glm_vec2_cross) TEST_DECLARE(glm_vec2_norm2) TEST_DECLARE(glm_vec2_norm) TEST_DECLARE(glm_vec2_add) TEST_DECLARE(glm_vec2_adds) TEST_DECLARE(glm_vec2_sub) TEST_DECLARE(glm_vec2_subs) TEST_DECLARE(glm_vec2_mul) TEST_DECLARE(glm_vec2_scale) TEST_DECLARE(glm_vec2_scale_as) TEST_DECLARE(glm_vec2_div) TEST_DECLARE(glm_vec2_divs) TEST_DECLARE(glm_vec2_addadd) TEST_DECLARE(glm_vec2_subadd) TEST_DECLARE(glm_vec2_muladd) TEST_DECLARE(glm_vec2_muladds) TEST_DECLARE(glm_vec2_maxadd) TEST_DECLARE(glm_vec2_minadd) TEST_DECLARE(glm_vec2_subsub) TEST_DECLARE(glm_vec2_addsub) TEST_DECLARE(glm_vec2_mulsub) TEST_DECLARE(glm_vec2_mulsubs) TEST_DECLARE(glm_vec2_maxsub) TEST_DECLARE(glm_vec2_minsub) TEST_DECLARE(glm_vec2_negate_to) TEST_DECLARE(glm_vec2_negate) TEST_DECLARE(glm_vec2_normalize) TEST_DECLARE(glm_vec2_normalize_to) TEST_DECLARE(glm_vec2_rotate) TEST_DECLARE(glm_vec2_center) TEST_DECLARE(glm_vec2_distance2) TEST_DECLARE(glm_vec2_distance) TEST_DECLARE(glm_vec2_maxv) TEST_DECLARE(glm_vec2_minv) TEST_DECLARE(glm_vec2_clamp) TEST_DECLARE(glm_vec2_abs) TEST_DECLARE(glm_vec2_fract) TEST_DECLARE(glm_vec2_floor) TEST_DECLARE(glm_vec2_mods) TEST_DECLARE(glm_vec2_steps) TEST_DECLARE(glm_vec2_stepr) TEST_DECLARE(glm_vec2_lerp) TEST_DECLARE(glm_vec2_complex_mul) TEST_DECLARE(glm_vec2_complex_div) TEST_DECLARE(glm_vec2_make) TEST_DECLARE(glm_vec2_reflect) TEST_DECLARE(glm_vec2_refract) TEST_DECLARE(glmc_vec2) TEST_DECLARE(glmc_vec2_copy) TEST_DECLARE(glmc_vec2_zero) TEST_DECLARE(glmc_vec2_one) TEST_DECLARE(glmc_vec2_dot) TEST_DECLARE(glmc_vec2_cross) TEST_DECLARE(glmc_vec2_norm2) TEST_DECLARE(glmc_vec2_norm) TEST_DECLARE(glmc_vec2_add) TEST_DECLARE(glmc_vec2_adds) TEST_DECLARE(glmc_vec2_sub) TEST_DECLARE(glmc_vec2_subs) TEST_DECLARE(glmc_vec2_mul) TEST_DECLARE(glmc_vec2_scale) TEST_DECLARE(glmc_vec2_scale_as) TEST_DECLARE(glmc_vec2_div) TEST_DECLARE(glmc_vec2_divs) TEST_DECLARE(glmc_vec2_addadd) TEST_DECLARE(glmc_vec2_subadd) TEST_DECLARE(glmc_vec2_muladd) TEST_DECLARE(glmc_vec2_muladds) TEST_DECLARE(glmc_vec2_maxadd) TEST_DECLARE(glmc_vec2_minadd) TEST_DECLARE(glmc_vec2_subsub) TEST_DECLARE(glmc_vec2_addsub) TEST_DECLARE(glmc_vec2_mulsub) TEST_DECLARE(glmc_vec2_mulsubs) TEST_DECLARE(glmc_vec2_maxsub) TEST_DECLARE(glmc_vec2_minsub) TEST_DECLARE(glmc_vec2_negate_to) TEST_DECLARE(glmc_vec2_negate) TEST_DECLARE(glmc_vec2_normalize) TEST_DECLARE(glmc_vec2_normalize_to) TEST_DECLARE(glmc_vec2_rotate) TEST_DECLARE(glmc_vec2_center) TEST_DECLARE(glmc_vec2_distance2) TEST_DECLARE(glmc_vec2_distance) TEST_DECLARE(glmc_vec2_maxv) TEST_DECLARE(glmc_vec2_minv) TEST_DECLARE(glmc_vec2_clamp) TEST_DECLARE(glmc_vec2_abs) TEST_DECLARE(glmc_vec2_fract) TEST_DECLARE(glmc_vec2_floor) TEST_DECLARE(glmc_vec2_mods) TEST_DECLARE(glmc_vec2_steps) TEST_DECLARE(glmc_vec2_stepr) TEST_DECLARE(glmc_vec2_lerp) TEST_DECLARE(glmc_vec2_complex_mul) TEST_DECLARE(glmc_vec2_complex_div) TEST_DECLARE(glmc_vec2_make) TEST_DECLARE(glmc_vec2_reflect) TEST_DECLARE(glmc_vec2_refract) /* vec3 */ TEST_DECLARE(MACRO_GLM_VEC3_ONE_INIT) TEST_DECLARE(MACRO_GLM_VEC3_ZERO_INIT) TEST_DECLARE(MACRO_GLM_VEC3_ONE) TEST_DECLARE(MACRO_GLM_VEC3_ZERO) TEST_DECLARE(MACRO_GLM_YUP) TEST_DECLARE(MACRO_GLM_ZUP) TEST_DECLARE(MACRO_GLM_XUP) TEST_DECLARE(MACRO_GLM_FORWARD_RH) TEST_DECLARE(MACRO_GLM_SHUFFLE3) TEST_DECLARE(MACRO_GLM_XXX) TEST_DECLARE(MACRO_GLM_YYY) TEST_DECLARE(MACRO_GLM_ZZZ) TEST_DECLARE(MACRO_GLM_ZYX) TEST_DECLARE(MACRO_glm_vec3_dup) TEST_DECLARE(MACRO_glm_vec3_flipsign) TEST_DECLARE(MACRO_glm_vec3_flipsign_to) TEST_DECLARE(MACRO_glm_vec3_inv) TEST_DECLARE(MACRO_glm_vec3_inv_to) TEST_DECLARE(MACRO_glm_vec3_mulv) TEST_DECLARE(glm_vec3) TEST_DECLARE(glm_vec3_copy) TEST_DECLARE(glm_vec3_zero) TEST_DECLARE(glm_vec3_one) TEST_DECLARE(glm_vec3_dot) TEST_DECLARE(glm_dot) TEST_DECLARE(glm_vec3_norm2) TEST_DECLARE(glm_vec3_norm) TEST_DECLARE(glm_vec3_norm_one) TEST_DECLARE(glm_vec3_norm_inf) TEST_DECLARE(glm_vec3_add) TEST_DECLARE(glm_vec3_adds) TEST_DECLARE(glm_vec3_sub) TEST_DECLARE(glm_vec3_subs) TEST_DECLARE(glm_vec3_mul) TEST_DECLARE(glm_vec3_scale) TEST_DECLARE(glm_vec3_scale_as) TEST_DECLARE(glm_vec3_div) TEST_DECLARE(glm_vec3_divs) TEST_DECLARE(glm_vec3_addadd) TEST_DECLARE(glm_vec3_subadd) TEST_DECLARE(glm_vec3_muladd) TEST_DECLARE(glm_vec3_muladds) TEST_DECLARE(glm_vec3_maxadd) TEST_DECLARE(glm_vec3_minadd) TEST_DECLARE(glm_vec3_subsub) TEST_DECLARE(glm_vec3_addsub) TEST_DECLARE(glm_vec3_mulsub) TEST_DECLARE(glm_vec3_mulsubs) TEST_DECLARE(glm_vec3_maxsub) TEST_DECLARE(glm_vec3_minsub) TEST_DECLARE(glm_vec3_negate_to) TEST_DECLARE(glm_vec3_negate) TEST_DECLARE(glm_vec3_normalize) TEST_DECLARE(glm_vec3_normalize_to) TEST_DECLARE(glm_normalize) TEST_DECLARE(glm_normalize_to) TEST_DECLARE(glm_vec3_cross) TEST_DECLARE(glm_vec3_crossn) TEST_DECLARE(glm_cross) TEST_DECLARE(glm_vec3_angle) TEST_DECLARE(glm_vec3_rotate) TEST_DECLARE(glm_vec3_rotate_m4) TEST_DECLARE(glm_vec3_rotate_m3) TEST_DECLARE(glm_vec3_proj) TEST_DECLARE(glm_vec3_center) TEST_DECLARE(glm_vec3_distance2) TEST_DECLARE(glm_vec3_distance) TEST_DECLARE(glm_vec3_maxv) TEST_DECLARE(glm_vec3_minv) TEST_DECLARE(glm_vec3_ortho) TEST_DECLARE(glm_vec3_clamp) TEST_DECLARE(glm_vec3_mix) TEST_DECLARE(glm_vec3_mixc) TEST_DECLARE(glm_vec3_step) TEST_DECLARE(glm_vec3_smoothstep_uni) TEST_DECLARE(glm_vec3_smoothstep) TEST_DECLARE(glm_vec3_smoothinterp) TEST_DECLARE(glm_vec3_smoothinterpc) TEST_DECLARE(glm_vec3_swizzle) TEST_DECLARE(glm_vec3_broadcast) TEST_DECLARE(glm_vec3_fill) TEST_DECLARE(glm_vec3_eq) TEST_DECLARE(glm_vec3_eq_eps) TEST_DECLARE(glm_vec3_eq_all) TEST_DECLARE(glm_vec3_eqv) TEST_DECLARE(glm_vec3_eqv_eps) TEST_DECLARE(glm_vec3_max) TEST_DECLARE(glm_vec3_min) TEST_DECLARE(glm_vec3_isnan) TEST_DECLARE(glm_vec3_isinf) TEST_DECLARE(glm_vec3_isvalid) TEST_DECLARE(glm_vec3_sign) TEST_DECLARE(glm_vec3_abs) TEST_DECLARE(glm_vec3_fract) TEST_DECLARE(glm_vec3_floor) TEST_DECLARE(glm_vec3_mods) TEST_DECLARE(glm_vec3_steps) TEST_DECLARE(glm_vec3_stepr) TEST_DECLARE(glm_vec3_hadd) TEST_DECLARE(glm_vec3_sqrt) TEST_DECLARE(glm_vec3_make) TEST_DECLARE(glm_vec3_faceforward) TEST_DECLARE(glm_vec3_reflect) TEST_DECLARE(glm_vec3_refract) TEST_DECLARE(glmc_vec3) TEST_DECLARE(glmc_vec3_copy) TEST_DECLARE(glmc_vec3_zero) TEST_DECLARE(glmc_vec3_one) TEST_DECLARE(glmc_vec3_dot) TEST_DECLARE(glmc_vec3_norm2) TEST_DECLARE(glmc_vec3_norm) TEST_DECLARE(glmc_vec3_norm_one) TEST_DECLARE(glmc_vec3_norm_inf) TEST_DECLARE(glmc_vec3_add) TEST_DECLARE(glmc_vec3_adds) TEST_DECLARE(glmc_vec3_sub) TEST_DECLARE(glmc_vec3_subs) TEST_DECLARE(glmc_vec3_mul) TEST_DECLARE(glmc_vec3_scale) TEST_DECLARE(glmc_vec3_scale_as) TEST_DECLARE(glmc_vec3_div) TEST_DECLARE(glmc_vec3_divs) TEST_DECLARE(glmc_vec3_addadd) TEST_DECLARE(glmc_vec3_subadd) TEST_DECLARE(glmc_vec3_muladd) TEST_DECLARE(glmc_vec3_muladds) TEST_DECLARE(glmc_vec3_maxadd) TEST_DECLARE(glmc_vec3_minadd) TEST_DECLARE(glmc_vec3_subsub) TEST_DECLARE(glmc_vec3_addsub) TEST_DECLARE(glmc_vec3_mulsub) TEST_DECLARE(glmc_vec3_mulsubs) TEST_DECLARE(glmc_vec3_maxsub) TEST_DECLARE(glmc_vec3_minsub) TEST_DECLARE(glmc_vec3_negate_to) TEST_DECLARE(glmc_vec3_negate) TEST_DECLARE(glmc_vec3_normalize) TEST_DECLARE(glmc_vec3_normalize_to) TEST_DECLARE(glmc_vec3_cross) TEST_DECLARE(glmc_vec3_crossn) TEST_DECLARE(glmc_vec3_angle) TEST_DECLARE(glmc_vec3_rotate) TEST_DECLARE(glmc_vec3_rotate_m4) TEST_DECLARE(glmc_vec3_rotate_m3) TEST_DECLARE(glmc_vec3_proj) TEST_DECLARE(glmc_vec3_center) TEST_DECLARE(glmc_vec3_distance2) TEST_DECLARE(glmc_vec3_distance) TEST_DECLARE(glmc_vec3_maxv) TEST_DECLARE(glmc_vec3_minv) TEST_DECLARE(glmc_vec3_ortho) TEST_DECLARE(glmc_vec3_clamp) TEST_DECLARE(glmc_vec3_mix) TEST_DECLARE(glmc_vec3_mixc) TEST_DECLARE(glmc_vec3_step) TEST_DECLARE(glmc_vec3_smoothstep_uni) TEST_DECLARE(glmc_vec3_smoothstep) TEST_DECLARE(glmc_vec3_smoothinterp) TEST_DECLARE(glmc_vec3_smoothinterpc) TEST_DECLARE(glmc_vec3_swizzle) TEST_DECLARE(glmc_vec3_broadcast) TEST_DECLARE(glmc_vec3_fill) TEST_DECLARE(glmc_vec3_eq) TEST_DECLARE(glmc_vec3_eq_eps) TEST_DECLARE(glmc_vec3_eq_all) TEST_DECLARE(glmc_vec3_eqv) TEST_DECLARE(glmc_vec3_eqv_eps) TEST_DECLARE(glmc_vec3_max) TEST_DECLARE(glmc_vec3_min) TEST_DECLARE(glmc_vec3_isnan) TEST_DECLARE(glmc_vec3_isinf) TEST_DECLARE(glmc_vec3_isvalid) TEST_DECLARE(glmc_vec3_sign) TEST_DECLARE(glmc_vec3_abs) TEST_DECLARE(glmc_vec3_fract) TEST_DECLARE(glmc_vec3_floor) TEST_DECLARE(glmc_vec3_mods) TEST_DECLARE(glmc_vec3_steps) TEST_DECLARE(glmc_vec3_stepr) TEST_DECLARE(glmc_vec3_hadd) TEST_DECLARE(glmc_vec3_sqrt) TEST_DECLARE(glmc_vec3_make) TEST_DECLARE(glmc_vec3_faceforward) TEST_DECLARE(glmc_vec3_reflect) TEST_DECLARE(glmc_vec3_refract) /* vec4 */ TEST_DECLARE(MACRO_GLM_VEC4_ONE_INIT) TEST_DECLARE(MACRO_GLM_VEC4_ZERO_INIT) TEST_DECLARE(MACRO_GLM_VEC4_ONE) TEST_DECLARE(MACRO_GLM_VEC4_ZERO) TEST_DECLARE(MACRO_GLM_XXXX) TEST_DECLARE(MACRO_GLM_YYYY) TEST_DECLARE(MACRO_GLM_ZZZZ) TEST_DECLARE(MACRO_GLM_WZYX) TEST_DECLARE(MACRO_glm_vec4_dup) TEST_DECLARE(MACRO_glm_vec4_flipsign) TEST_DECLARE(MACRO_glm_vec4_flipsign_to) TEST_DECLARE(MACRO_glm_vec4_inv) TEST_DECLARE(MACRO_glm_vec4_inv_to) TEST_DECLARE(MACRO_glm_vec4_mulv) TEST_DECLARE(glm_vec4) TEST_DECLARE(glm_vec4_copy3) TEST_DECLARE(glm_vec4_copy) TEST_DECLARE(glm_vec4_ucopy) TEST_DECLARE(glm_vec4_zero) TEST_DECLARE(glm_vec4_one) TEST_DECLARE(glm_vec4_dot) TEST_DECLARE(glm_vec4_norm2) TEST_DECLARE(glm_vec4_norm) TEST_DECLARE(glm_vec4_norm_one) TEST_DECLARE(glm_vec4_norm_inf) TEST_DECLARE(glm_vec4_add) TEST_DECLARE(glm_vec4_adds) TEST_DECLARE(glm_vec4_sub) TEST_DECLARE(glm_vec4_subs) TEST_DECLARE(glm_vec4_mul) TEST_DECLARE(glm_vec4_scale) TEST_DECLARE(glm_vec4_scale_as) TEST_DECLARE(glm_vec4_div) TEST_DECLARE(glm_vec4_divs) TEST_DECLARE(glm_vec4_addadd) TEST_DECLARE(glm_vec4_subadd) TEST_DECLARE(glm_vec4_muladd) TEST_DECLARE(glm_vec4_muladds) TEST_DECLARE(glm_vec4_maxadd) TEST_DECLARE(glm_vec4_minadd) TEST_DECLARE(glm_vec4_subsub) TEST_DECLARE(glm_vec4_addsub) TEST_DECLARE(glm_vec4_mulsub) TEST_DECLARE(glm_vec4_mulsubs) TEST_DECLARE(glm_vec4_maxsub) TEST_DECLARE(glm_vec4_minsub) TEST_DECLARE(glm_vec4_negate_to) TEST_DECLARE(glm_vec4_negate) TEST_DECLARE(glm_vec4_normalize) TEST_DECLARE(glm_vec4_normalize_to) TEST_DECLARE(glm_vec4_distance2) TEST_DECLARE(glm_vec4_distance) TEST_DECLARE(glm_vec4_maxv) TEST_DECLARE(glm_vec4_minv) TEST_DECLARE(glm_vec4_clamp) TEST_DECLARE(glm_vec4_lerp) TEST_DECLARE(glm_vec4_lerpc) TEST_DECLARE(glm_vec4_mix) TEST_DECLARE(glm_vec4_mixc) TEST_DECLARE(glm_vec4_step) TEST_DECLARE(glm_vec4_smoothstep_uni) TEST_DECLARE(glm_vec4_smoothstep) TEST_DECLARE(glm_vec4_smoothinterp) TEST_DECLARE(glm_vec4_smoothinterpc) TEST_DECLARE(glm_vec4_cubic) TEST_DECLARE(glm_vec4_swizzle) TEST_DECLARE(glm_vec4_broadcast) TEST_DECLARE(glm_vec4_fill) TEST_DECLARE(glm_vec4_eq) TEST_DECLARE(glm_vec4_eq_eps) TEST_DECLARE(glm_vec4_eq_all) TEST_DECLARE(glm_vec4_eqv) TEST_DECLARE(glm_vec4_eqv_eps) TEST_DECLARE(glm_vec4_max) TEST_DECLARE(glm_vec4_min) TEST_DECLARE(glm_vec4_isnan) TEST_DECLARE(glm_vec4_isinf) TEST_DECLARE(glm_vec4_isvalid) TEST_DECLARE(glm_vec4_sign) TEST_DECLARE(glm_vec4_abs) TEST_DECLARE(glm_vec4_fract) TEST_DECLARE(glm_vec4_floor) TEST_DECLARE(glm_vec4_mods) TEST_DECLARE(glm_vec4_steps) TEST_DECLARE(glm_vec4_stepr) TEST_DECLARE(glm_vec4_hadd) TEST_DECLARE(glm_vec4_sqrt) TEST_DECLARE(glm_vec4_make) TEST_DECLARE(glm_vec4_reflect) TEST_DECLARE(glm_vec4_refract) TEST_DECLARE(glmc_vec4) TEST_DECLARE(glmc_vec4_copy3) TEST_DECLARE(glmc_vec4_copy) TEST_DECLARE(glmc_vec4_ucopy) TEST_DECLARE(glmc_vec4_zero) TEST_DECLARE(glmc_vec4_one) TEST_DECLARE(glmc_vec4_dot) TEST_DECLARE(glmc_vec4_norm2) TEST_DECLARE(glmc_vec4_norm) TEST_DECLARE(glmc_vec4_norm_one) TEST_DECLARE(glmc_vec4_norm_inf) TEST_DECLARE(glmc_vec4_add) TEST_DECLARE(glmc_vec4_adds) TEST_DECLARE(glmc_vec4_sub) TEST_DECLARE(glmc_vec4_subs) TEST_DECLARE(glmc_vec4_mul) TEST_DECLARE(glmc_vec4_scale) TEST_DECLARE(glmc_vec4_scale_as) TEST_DECLARE(glmc_vec4_div) TEST_DECLARE(glmc_vec4_divs) TEST_DECLARE(glmc_vec4_addadd) TEST_DECLARE(glmc_vec4_subadd) TEST_DECLARE(glmc_vec4_muladd) TEST_DECLARE(glmc_vec4_muladds) TEST_DECLARE(glmc_vec4_maxadd) TEST_DECLARE(glmc_vec4_minadd) TEST_DECLARE(glmc_vec4_subsub) TEST_DECLARE(glmc_vec4_addsub) TEST_DECLARE(glmc_vec4_mulsub) TEST_DECLARE(glmc_vec4_mulsubs) TEST_DECLARE(glmc_vec4_maxsub) TEST_DECLARE(glmc_vec4_minsub) TEST_DECLARE(glmc_vec4_negate_to) TEST_DECLARE(glmc_vec4_negate) TEST_DECLARE(glmc_vec4_normalize) TEST_DECLARE(glmc_vec4_normalize_to) TEST_DECLARE(glmc_vec4_distance2) TEST_DECLARE(glmc_vec4_distance) TEST_DECLARE(glmc_vec4_maxv) TEST_DECLARE(glmc_vec4_minv) TEST_DECLARE(glmc_vec4_clamp) TEST_DECLARE(glmc_vec4_lerp) TEST_DECLARE(glmc_vec4_lerpc) TEST_DECLARE(glmc_vec4_mix) TEST_DECLARE(glmc_vec4_mixc) TEST_DECLARE(glmc_vec4_step) TEST_DECLARE(glmc_vec4_smoothstep_uni) TEST_DECLARE(glmc_vec4_smoothstep) TEST_DECLARE(glmc_vec4_smoothinterp) TEST_DECLARE(glmc_vec4_smoothinterpc) TEST_DECLARE(glmc_vec4_cubic) TEST_DECLARE(glmc_vec4_swizzle) TEST_DECLARE(glmc_vec4_broadcast) TEST_DECLARE(glmc_vec4_fill) TEST_DECLARE(glmc_vec4_eq) TEST_DECLARE(glmc_vec4_eq_eps) TEST_DECLARE(glmc_vec4_eq_all) TEST_DECLARE(glmc_vec4_eqv) TEST_DECLARE(glmc_vec4_eqv_eps) TEST_DECLARE(glmc_vec4_max) TEST_DECLARE(glmc_vec4_min) TEST_DECLARE(glmc_vec4_isnan) TEST_DECLARE(glmc_vec4_isinf) TEST_DECLARE(glmc_vec4_isvalid) TEST_DECLARE(glmc_vec4_sign) TEST_DECLARE(glmc_vec4_abs) TEST_DECLARE(glmc_vec4_fract) TEST_DECLARE(glmc_vec4_floor) TEST_DECLARE(glmc_vec4_mods) TEST_DECLARE(glmc_vec4_steps) TEST_DECLARE(glmc_vec4_stepr) TEST_DECLARE(glmc_vec4_hadd) TEST_DECLARE(glmc_vec4_sqrt) TEST_DECLARE(glmc_vec4_make) TEST_DECLARE(glmc_vec4_reflect) TEST_DECLARE(glmc_vec4_refract) /* ivec2 */ TEST_DECLARE(glm_ivec2) TEST_DECLARE(glm_ivec2_copy) TEST_DECLARE(glm_ivec2_zero) TEST_DECLARE(glm_ivec2_one) TEST_DECLARE(glm_ivec2_dot) TEST_DECLARE(glm_ivec2_cross) TEST_DECLARE(glm_ivec2_add) TEST_DECLARE(glm_ivec2_adds) TEST_DECLARE(glm_ivec2_sub) TEST_DECLARE(glm_ivec2_subs) TEST_DECLARE(glm_ivec2_mul) TEST_DECLARE(glm_ivec2_scale) TEST_DECLARE(glm_ivec2_div) TEST_DECLARE(glm_ivec2_divs) TEST_DECLARE(glm_ivec2_mod) TEST_DECLARE(glm_ivec2_addadd) TEST_DECLARE(glm_ivec2_addadds) TEST_DECLARE(glm_ivec2_subadd) TEST_DECLARE(glm_ivec2_subadds) TEST_DECLARE(glm_ivec2_muladd) TEST_DECLARE(glm_ivec2_muladds) TEST_DECLARE(glm_ivec2_maxadd) TEST_DECLARE(glm_ivec2_minadd) TEST_DECLARE(glm_ivec2_subsub) TEST_DECLARE(glm_ivec2_subsubs) TEST_DECLARE(glm_ivec2_addsub) TEST_DECLARE(glm_ivec2_addsubs) TEST_DECLARE(glm_ivec2_mulsub) TEST_DECLARE(glm_ivec2_mulsubs) TEST_DECLARE(glm_ivec2_maxsub) TEST_DECLARE(glm_ivec2_minsub) TEST_DECLARE(glm_ivec2_distance2) TEST_DECLARE(glm_ivec2_distance) TEST_DECLARE(glm_ivec2_fill) TEST_DECLARE(glm_ivec2_eq) TEST_DECLARE(glm_ivec2_eqv) TEST_DECLARE(glm_ivec2_maxv) TEST_DECLARE(glm_ivec2_minv) TEST_DECLARE(glm_ivec2_clamp) TEST_DECLARE(glm_ivec2_abs) TEST_DECLARE(glmc_ivec2) TEST_DECLARE(glmc_ivec2_copy) TEST_DECLARE(glmc_ivec2_zero) TEST_DECLARE(glmc_ivec2_one) TEST_DECLARE(glmc_ivec2_dot) TEST_DECLARE(glmc_ivec2_cross) TEST_DECLARE(glmc_ivec2_add) TEST_DECLARE(glmc_ivec2_adds) TEST_DECLARE(glmc_ivec2_sub) TEST_DECLARE(glmc_ivec2_subs) TEST_DECLARE(glmc_ivec2_mul) TEST_DECLARE(glmc_ivec2_scale) TEST_DECLARE(glmc_ivec2_div) TEST_DECLARE(glmc_ivec2_divs) TEST_DECLARE(glmc_ivec2_mod) TEST_DECLARE(glmc_ivec2_addadd) TEST_DECLARE(glmc_ivec2_addadds) TEST_DECLARE(glmc_ivec2_subadd) TEST_DECLARE(glmc_ivec2_subadds) TEST_DECLARE(glmc_ivec2_muladd) TEST_DECLARE(glmc_ivec2_muladds) TEST_DECLARE(glmc_ivec2_maxadd) TEST_DECLARE(glmc_ivec2_minadd) TEST_DECLARE(glmc_ivec2_subsub) TEST_DECLARE(glmc_ivec2_subsubs) TEST_DECLARE(glmc_ivec2_addsub) TEST_DECLARE(glmc_ivec2_addsubs) TEST_DECLARE(glmc_ivec2_mulsub) TEST_DECLARE(glmc_ivec2_mulsubs) TEST_DECLARE(glmc_ivec2_maxsub) TEST_DECLARE(glmc_ivec2_minsub) TEST_DECLARE(glmc_ivec2_distance2) TEST_DECLARE(glmc_ivec2_distance) TEST_DECLARE(glmc_ivec2_fill) TEST_DECLARE(glmc_ivec2_eq) TEST_DECLARE(glmc_ivec2_eqv) TEST_DECLARE(glmc_ivec2_maxv) TEST_DECLARE(glmc_ivec2_minv) TEST_DECLARE(glmc_ivec2_clamp) TEST_DECLARE(glmc_ivec2_abs) /* ivec3 */ TEST_DECLARE(glm_ivec3) TEST_DECLARE(glm_ivec3_copy) TEST_DECLARE(glm_ivec3_zero) TEST_DECLARE(glm_ivec3_one) TEST_DECLARE(glm_ivec3_dot) TEST_DECLARE(glm_ivec3_norm2) TEST_DECLARE(glm_ivec3_norm) TEST_DECLARE(glm_ivec3_add) TEST_DECLARE(glm_ivec3_adds) TEST_DECLARE(glm_ivec3_sub) TEST_DECLARE(glm_ivec3_subs) TEST_DECLARE(glm_ivec3_mul) TEST_DECLARE(glm_ivec3_scale) TEST_DECLARE(glm_ivec3_div) TEST_DECLARE(glm_ivec3_divs) TEST_DECLARE(glm_ivec3_mod) TEST_DECLARE(glm_ivec3_addadd) TEST_DECLARE(glm_ivec3_addadds) TEST_DECLARE(glm_ivec3_subadd) TEST_DECLARE(glm_ivec3_subadds) TEST_DECLARE(glm_ivec3_muladd) TEST_DECLARE(glm_ivec3_muladds) TEST_DECLARE(glm_ivec3_maxadd) TEST_DECLARE(glm_ivec3_minadd) TEST_DECLARE(glm_ivec3_subsub) TEST_DECLARE(glm_ivec3_subsubs) TEST_DECLARE(glm_ivec3_addsub) TEST_DECLARE(glm_ivec3_addsubs) TEST_DECLARE(glm_ivec3_mulsub) TEST_DECLARE(glm_ivec3_mulsubs) TEST_DECLARE(glm_ivec3_maxsub) TEST_DECLARE(glm_ivec3_minsub) TEST_DECLARE(glm_ivec3_distance2) TEST_DECLARE(glm_ivec3_distance) TEST_DECLARE(glm_ivec3_fill) TEST_DECLARE(glm_ivec3_eq) TEST_DECLARE(glm_ivec3_eqv) TEST_DECLARE(glm_ivec3_maxv) TEST_DECLARE(glm_ivec3_minv) TEST_DECLARE(glm_ivec3_clamp) TEST_DECLARE(glmc_ivec3) TEST_DECLARE(glmc_ivec3_copy) TEST_DECLARE(glmc_ivec3_zero) TEST_DECLARE(glmc_ivec3_one) TEST_DECLARE(glmc_ivec3_dot) TEST_DECLARE(glmc_ivec3_norm2) TEST_DECLARE(glmc_ivec3_norm) TEST_DECLARE(glmc_ivec3_add) TEST_DECLARE(glmc_ivec3_adds) TEST_DECLARE(glmc_ivec3_sub) TEST_DECLARE(glmc_ivec3_subs) TEST_DECLARE(glmc_ivec3_mul) TEST_DECLARE(glmc_ivec3_scale) TEST_DECLARE(glmc_ivec3_div) TEST_DECLARE(glmc_ivec3_divs) TEST_DECLARE(glmc_ivec3_mod) TEST_DECLARE(glmc_ivec3_addadd) TEST_DECLARE(glmc_ivec3_addadds) TEST_DECLARE(glmc_ivec3_subadd) TEST_DECLARE(glmc_ivec3_subadds) TEST_DECLARE(glmc_ivec3_muladd) TEST_DECLARE(glmc_ivec3_muladds) TEST_DECLARE(glmc_ivec3_maxadd) TEST_DECLARE(glmc_ivec3_minadd) TEST_DECLARE(glmc_ivec3_subsub) TEST_DECLARE(glmc_ivec3_subsubs) TEST_DECLARE(glmc_ivec3_addsub) TEST_DECLARE(glmc_ivec3_addsubs) TEST_DECLARE(glmc_ivec3_mulsub) TEST_DECLARE(glmc_ivec3_mulsubs) TEST_DECLARE(glmc_ivec3_maxsub) TEST_DECLARE(glmc_ivec3_minsub) TEST_DECLARE(glmc_ivec3_distance2) TEST_DECLARE(glmc_ivec3_distance) TEST_DECLARE(glmc_ivec3_fill) TEST_DECLARE(glmc_ivec3_eq) TEST_DECLARE(glmc_ivec3_eqv) TEST_DECLARE(glmc_ivec3_maxv) TEST_DECLARE(glmc_ivec3_minv) TEST_DECLARE(glmc_ivec3_clamp) /* ivec4 */ TEST_DECLARE(glm_ivec4) TEST_DECLARE(glm_ivec4_copy) TEST_DECLARE(glm_ivec4_zero) TEST_DECLARE(glm_ivec4_one) TEST_DECLARE(glm_ivec4_add) TEST_DECLARE(glm_ivec4_adds) TEST_DECLARE(glm_ivec4_sub) TEST_DECLARE(glm_ivec4_subs) TEST_DECLARE(glm_ivec4_mul) TEST_DECLARE(glm_ivec4_scale) TEST_DECLARE(glm_ivec4_addadd) TEST_DECLARE(glm_ivec4_addadds) TEST_DECLARE(glm_ivec4_subadd) TEST_DECLARE(glm_ivec4_subadds) TEST_DECLARE(glm_ivec4_muladd) TEST_DECLARE(glm_ivec4_muladds) TEST_DECLARE(glm_ivec4_maxadd) TEST_DECLARE(glm_ivec4_minadd) TEST_DECLARE(glm_ivec4_subsub) TEST_DECLARE(glm_ivec4_subsubs) TEST_DECLARE(glm_ivec4_addsub) TEST_DECLARE(glm_ivec4_addsubs) TEST_DECLARE(glm_ivec4_mulsub) TEST_DECLARE(glm_ivec4_mulsubs) TEST_DECLARE(glm_ivec4_maxsub) TEST_DECLARE(glm_ivec4_minsub) TEST_DECLARE(glm_ivec4_distance2) TEST_DECLARE(glm_ivec4_distance) TEST_DECLARE(glm_ivec4_maxv) TEST_DECLARE(glm_ivec4_minv) TEST_DECLARE(glm_ivec4_clamp) TEST_DECLARE(glm_ivec4_abs) TEST_DECLARE(glmc_ivec4) TEST_DECLARE(glmc_ivec4_copy) TEST_DECLARE(glmc_ivec4_zero) TEST_DECLARE(glmc_ivec4_one) TEST_DECLARE(glmc_ivec4_add) TEST_DECLARE(glmc_ivec4_adds) TEST_DECLARE(glmc_ivec4_sub) TEST_DECLARE(glmc_ivec4_subs) TEST_DECLARE(glmc_ivec4_mul) TEST_DECLARE(glmc_ivec4_scale) TEST_DECLARE(glmc_ivec4_addadd) TEST_DECLARE(glmc_ivec4_addadds) TEST_DECLARE(glmc_ivec4_subadd) TEST_DECLARE(glmc_ivec4_subadds) TEST_DECLARE(glmc_ivec4_muladd) TEST_DECLARE(glmc_ivec4_muladds) TEST_DECLARE(glmc_ivec4_maxadd) TEST_DECLARE(glmc_ivec4_minadd) TEST_DECLARE(glmc_ivec4_subsub) TEST_DECLARE(glmc_ivec4_subsubs) TEST_DECLARE(glmc_ivec4_addsub) TEST_DECLARE(glmc_ivec4_addsubs) TEST_DECLARE(glmc_ivec4_mulsub) TEST_DECLARE(glmc_ivec4_mulsubs) TEST_DECLARE(glmc_ivec4_maxsub) TEST_DECLARE(glmc_ivec4_minsub) TEST_DECLARE(glmc_ivec4_distance2) TEST_DECLARE(glmc_ivec4_distance) TEST_DECLARE(glmc_ivec4_maxv) TEST_DECLARE(glmc_ivec4_minv) TEST_DECLARE(glmc_ivec4_clamp) TEST_DECLARE(glmc_ivec4_abs) /* structs */ TEST_DECLARE(mat2x3s_zero_init) TEST_DECLARE(mat2x3s_zero) TEST_DECLARE(mat2x4s_zero_init) TEST_DECLARE(mat2x4s_zero) TEST_DECLARE(mat3s_identity_init) TEST_DECLARE(mat3s_zero_init) TEST_DECLARE(mat3x2s_zero_init) TEST_DECLARE(mat3x2s_zero) TEST_DECLARE(mat3x4s_zero_init) TEST_DECLARE(mat3x4s_zero) TEST_DECLARE(mat4s_identity_init) TEST_DECLARE(mat4s_zero_init) TEST_DECLARE(mat4x2s_zero_init) TEST_DECLARE(mat4x2s_zero) TEST_DECLARE(mat4x3s_zero_init) TEST_DECLARE(mat4x3s_zero) TEST_DECLARE(quats_zero_init) TEST_DECLARE(vec3s_one_init) TEST_DECLARE(vec3s_zero_init) TEST_DECLARE(vec4s_black_init) TEST_DECLARE(vec4s_one_init) TEST_DECLARE(vec4s_zero_init) /*****************************************************************************/ TEST_LIST { /* affine mat */ TEST_ENTRY(glm_mul) TEST_ENTRY(glm_mul) TEST_ENTRY(glm_inv_tr) TEST_ENTRY(glmc_mul) TEST_ENTRY(glmc_mul_rot) TEST_ENTRY(glmc_inv_tr) /* affine */ TEST_ENTRY(glm_translate) TEST_ENTRY(glm_translate_to) TEST_ENTRY(glm_translate_x) TEST_ENTRY(glm_translate_y) TEST_ENTRY(glm_translate_z) TEST_ENTRY(glm_translate_make) TEST_ENTRY(glm_scale_to) TEST_ENTRY(glm_scale_make) TEST_ENTRY(glm_scale) TEST_ENTRY(glm_scale_uni) TEST_ENTRY(glm_rotate_x) TEST_ENTRY(glm_rotate_y) TEST_ENTRY(glm_rotate_z) TEST_ENTRY(glm_rotate_make) TEST_ENTRY(glm_rotate) TEST_ENTRY(glm_rotate_at) TEST_ENTRY(glm_rotate_atm) TEST_ENTRY(glm_decompose_scalev) TEST_ENTRY(glm_uniscaled) TEST_ENTRY(glm_decompose_rs) TEST_ENTRY(glm_decompose) TEST_ENTRY(glmc_translate) TEST_ENTRY(glmc_translate_to) TEST_ENTRY(glmc_translate_x) TEST_ENTRY(glmc_translate_y) TEST_ENTRY(glmc_translate_z) TEST_ENTRY(glmc_translate_make) TEST_ENTRY(glmc_scale_to) TEST_ENTRY(glmc_scale_make) TEST_ENTRY(glmc_scale) TEST_ENTRY(glmc_scale_uni) TEST_ENTRY(glmc_rotate_x) TEST_ENTRY(glmc_rotate_y) TEST_ENTRY(glmc_rotate_z) TEST_ENTRY(glmc_rotate_make) TEST_ENTRY(glmc_rotate) TEST_ENTRY(glmc_rotate_at) TEST_ENTRY(glmc_rotate_atm) TEST_ENTRY(glmc_decompose_scalev) TEST_ENTRY(glmc_uniscaled) TEST_ENTRY(glmc_decompose_rs) TEST_ENTRY(glmc_decompose) /* affine 2d */ TEST_ENTRY(glm_translate2d) TEST_ENTRY(glm_translate2d_to) TEST_ENTRY(glm_translate2d_x) TEST_ENTRY(glm_translate2d_y) TEST_ENTRY(glm_translate2d_make) TEST_ENTRY(glm_scale2d_to) TEST_ENTRY(glm_scale2d_make) TEST_ENTRY(glm_scale2d) TEST_ENTRY(glm_scale2d_uni) TEST_ENTRY(glm_rotate2d_make) TEST_ENTRY(glm_rotate2d) TEST_ENTRY(glm_rotate2d_to) TEST_ENTRY(glmc_translate2d) TEST_ENTRY(glmc_translate2d_to) TEST_ENTRY(glmc_translate2d_x) TEST_ENTRY(glmc_translate2d_y) TEST_ENTRY(glmc_translate2d_make) TEST_ENTRY(glmc_scale2d_to) TEST_ENTRY(glmc_scale2d_make) TEST_ENTRY(glmc_scale2d) TEST_ENTRY(glmc_scale2d_uni) TEST_ENTRY(glmc_rotate2d_make) TEST_ENTRY(glmc_rotate2d) TEST_ENTRY(glmc_rotate2d_to) /* aabb2d */ TEST_ENTRY(glm_aabb2d_sizev) /* mat4 */ TEST_ENTRY(glm_mat4_ucopy) TEST_ENTRY(glm_mat4_copy) TEST_ENTRY(glm_mat4_identity) TEST_ENTRY(glm_mat4_identity_array) TEST_ENTRY(glm_mat4_zero) TEST_ENTRY(glm_mat4_pick3) TEST_ENTRY(glm_mat4_pick3t) TEST_ENTRY(glm_mat4_ins3) TEST_ENTRY(glm_mat4_mul) TEST_ENTRY(glm_mat4_mulN) TEST_ENTRY(glm_mat4_mulv) TEST_ENTRY(glm_mat4_mulv3) TEST_ENTRY(glm_mat4_trace) TEST_ENTRY(glm_mat4_trace3) TEST_ENTRY(glm_mat4_quat) TEST_ENTRY(glm_mat4_transpose_to) TEST_ENTRY(glm_mat4_transpose) TEST_ENTRY(glm_mat4_scale_p) TEST_ENTRY(glm_mat4_scale) TEST_ENTRY(glm_mat4_det) TEST_ENTRY(glm_mat4_inv) TEST_ENTRY(glm_mat4_inv_fast) TEST_ENTRY(glm_mat4_inv_precise) TEST_ENTRY(glm_mat4_swap_col) TEST_ENTRY(glm_mat4_swap_row) TEST_ENTRY(glm_mat4_rmc) TEST_ENTRY(glm_mat4_make) TEST_ENTRY(glmc_mat4_ucopy) TEST_ENTRY(glmc_mat4_copy) TEST_ENTRY(glmc_mat4_identity) TEST_ENTRY(glmc_mat4_identity_array) TEST_ENTRY(glmc_mat4_zero) TEST_ENTRY(glmc_mat4_pick3) TEST_ENTRY(glmc_mat4_pick3t) TEST_ENTRY(glmc_mat4_ins3) TEST_ENTRY(glmc_mat4_mul) TEST_ENTRY(glmc_mat4_mulN) TEST_ENTRY(glmc_mat4_mulv) TEST_ENTRY(glmc_mat4_mulv3) TEST_ENTRY(glmc_mat4_trace) TEST_ENTRY(glmc_mat4_trace3) TEST_ENTRY(glmc_mat4_quat) TEST_ENTRY(glmc_mat4_transpose_to) TEST_ENTRY(glmc_mat4_transpose) TEST_ENTRY(glmc_mat4_scale_p) TEST_ENTRY(glmc_mat4_scale) TEST_ENTRY(glmc_mat4_det) TEST_ENTRY(glmc_mat4_inv) TEST_ENTRY(glmc_mat4_inv_fast) TEST_ENTRY(glmc_mat4_swap_col) TEST_ENTRY(glmc_mat4_swap_row) TEST_ENTRY(glmc_mat4_rmc) TEST_ENTRY(glmc_mat4_make) TEST_ENTRY(MACRO_GLM_MAT4X2_ZERO_INIT) TEST_ENTRY(MACRO_GLM_MAT4X2_ZERO) TEST_ENTRY(glm_mat4x2_copy) TEST_ENTRY(glm_mat4x2_zero) TEST_ENTRY(glm_mat4x2_make) TEST_ENTRY(glm_mat4x2_mul) TEST_ENTRY(glm_mat4x2_mulv) TEST_ENTRY(glm_mat4x2_transpose) TEST_ENTRY(glm_mat4x2_scale) TEST_ENTRY(glmc_mat4x2_copy) TEST_ENTRY(glmc_mat4x2_zero) TEST_ENTRY(glmc_mat4x2_make) TEST_ENTRY(glmc_mat4x2_mul) TEST_ENTRY(glmc_mat4x2_mulv) TEST_ENTRY(glmc_mat4x2_transpose) TEST_ENTRY(glmc_mat4x2_scale) TEST_ENTRY(MACRO_GLM_MAT4X3_ZERO_INIT) TEST_ENTRY(MACRO_GLM_MAT4X3_ZERO) TEST_ENTRY(glm_mat4x3_copy) TEST_ENTRY(glm_mat4x3_zero) TEST_ENTRY(glm_mat4x3_make) TEST_ENTRY(glm_mat4x3_mul) TEST_ENTRY(glm_mat4x3_mulv) TEST_ENTRY(glm_mat4x3_transpose) TEST_ENTRY(glm_mat4x3_scale) TEST_ENTRY(glmc_mat4x3_copy) TEST_ENTRY(glmc_mat4x3_zero) TEST_ENTRY(glmc_mat4x3_make) TEST_ENTRY(glmc_mat4x3_mul) TEST_ENTRY(glmc_mat4x3_mulv) TEST_ENTRY(glmc_mat4x3_transpose) TEST_ENTRY(glmc_mat4x3_scale) /* mat3 */ TEST_ENTRY(glm_mat3_copy) TEST_ENTRY(glm_mat3_identity) TEST_ENTRY(glm_mat3_identity_array) TEST_ENTRY(glm_mat3_zero) TEST_ENTRY(glm_mat3_mul) TEST_ENTRY(glm_mat3_mulv) TEST_ENTRY(glm_mat3_trace) TEST_ENTRY(glm_mat3_quat) TEST_ENTRY(glm_mat3_transpose_to) TEST_ENTRY(glm_mat3_transpose) TEST_ENTRY(glm_mat3_scale) TEST_ENTRY(glm_mat3_det) TEST_ENTRY(glm_mat3_inv) TEST_ENTRY(glm_mat3_swap_col) TEST_ENTRY(glm_mat3_swap_row) TEST_ENTRY(glm_mat3_rmc) TEST_ENTRY(glm_mat3_make) TEST_ENTRY(glmc_mat3_copy) TEST_ENTRY(glmc_mat3_identity) TEST_ENTRY(glmc_mat3_identity_array) TEST_ENTRY(glmc_mat3_zero) TEST_ENTRY(glmc_mat3_mul) TEST_ENTRY(glmc_mat3_mulv) TEST_ENTRY(glmc_mat3_trace) TEST_ENTRY(glmc_mat3_quat) TEST_ENTRY(glmc_mat3_transpose_to) TEST_ENTRY(glmc_mat3_transpose) TEST_ENTRY(glmc_mat3_scale) TEST_ENTRY(glmc_mat3_det) TEST_ENTRY(glmc_mat3_inv) TEST_ENTRY(glmc_mat3_swap_col) TEST_ENTRY(glmc_mat3_swap_row) TEST_ENTRY(glmc_mat3_rmc) TEST_ENTRY(glmc_mat3_make) TEST_ENTRY(MACRO_GLM_MAT3X2_ZERO_INIT) TEST_ENTRY(MACRO_GLM_MAT3X2_ZERO) TEST_ENTRY(glm_mat3x2_copy) TEST_ENTRY(glm_mat3x2_zero) TEST_ENTRY(glm_mat3x2_make) TEST_ENTRY(glm_mat3x2_mul) TEST_ENTRY(glm_mat3x2_mulv) TEST_ENTRY(glm_mat3x2_transpose) TEST_ENTRY(glm_mat3x2_scale) TEST_ENTRY(glmc_mat3x2_copy) TEST_ENTRY(glmc_mat3x2_zero) TEST_ENTRY(glmc_mat3x2_make) TEST_ENTRY(glmc_mat3x2_mul) TEST_ENTRY(glmc_mat3x2_mulv) TEST_ENTRY(glmc_mat3x2_transpose) TEST_ENTRY(glmc_mat3x2_scale) TEST_ENTRY(MACRO_GLM_MAT3X4_ZERO_INIT) TEST_ENTRY(MACRO_GLM_MAT3X4_ZERO) TEST_ENTRY(glm_mat3x4_make) TEST_ENTRY(glmc_mat3x4_make) TEST_ENTRY(MACRO_GLM_MAT2_IDENTITY_INIT) TEST_ENTRY(MACRO_GLM_MAT2_ZERO_INIT) TEST_ENTRY(MACRO_GLM_MAT2_IDENTITY) TEST_ENTRY(MACRO_GLM_MAT2_ZERO) TEST_ENTRY(glm_mat2_copy) TEST_ENTRY(glm_mat2_identity) TEST_ENTRY(glm_mat2_identity_array) TEST_ENTRY(glm_mat2_zero) TEST_ENTRY(glm_mat2_mul) TEST_ENTRY(glm_mat2_transpose_to) TEST_ENTRY(glm_mat2_transpose) TEST_ENTRY(glm_mat2_mulv) TEST_ENTRY(glm_mat2_trace) TEST_ENTRY(glm_mat2_scale) TEST_ENTRY(glm_mat2_det) TEST_ENTRY(glm_mat2_inv) TEST_ENTRY(glm_mat2_swap_col) TEST_ENTRY(glm_mat2_swap_row) TEST_ENTRY(glm_mat2_rmc) TEST_ENTRY(glm_mat2_make) TEST_ENTRY(glmc_mat2_copy) TEST_ENTRY(glmc_mat2_identity) TEST_ENTRY(glmc_mat2_identity_array) TEST_ENTRY(glmc_mat2_zero) TEST_ENTRY(glmc_mat2_mul) TEST_ENTRY(glmc_mat2_transpose_to) TEST_ENTRY(glmc_mat2_transpose) TEST_ENTRY(glmc_mat2_mulv) TEST_ENTRY(glmc_mat2_trace) TEST_ENTRY(glmc_mat2_scale) TEST_ENTRY(glmc_mat2_det) TEST_ENTRY(glmc_mat2_inv) TEST_ENTRY(glmc_mat2_swap_col) TEST_ENTRY(glmc_mat2_swap_row) TEST_ENTRY(glmc_mat2_rmc) TEST_ENTRY(glmc_mat2_make) TEST_ENTRY(MACRO_GLM_MAT2X3_ZERO_INIT) TEST_ENTRY(MACRO_GLM_MAT2X3_ZERO) TEST_ENTRY(glm_mat2x3_copy) TEST_ENTRY(glm_mat2x3_zero) TEST_ENTRY(glm_mat2x3_make) TEST_ENTRY(glm_mat2x3_mul) TEST_ENTRY(glm_mat2x3_mulv) TEST_ENTRY(glm_mat2x3_transpose) TEST_ENTRY(glm_mat2x3_scale) TEST_ENTRY(glmc_mat2x3_copy) TEST_ENTRY(glmc_mat2x3_zero) TEST_ENTRY(glmc_mat2x3_make) TEST_ENTRY(glmc_mat2x3_mul) TEST_ENTRY(glmc_mat2x3_mulv) TEST_ENTRY(glmc_mat2x3_transpose) TEST_ENTRY(glmc_mat2x3_scale) TEST_ENTRY(MACRO_GLM_MAT2X4_ZERO_INIT) TEST_ENTRY(MACRO_GLM_MAT2X4_ZERO) TEST_ENTRY(glm_mat2x4_copy) TEST_ENTRY(glm_mat2x4_zero) TEST_ENTRY(glm_mat2x4_make) TEST_ENTRY(glm_mat2x4_mul) TEST_ENTRY(glm_mat2x4_mulv) TEST_ENTRY(glm_mat2x4_transpose) TEST_ENTRY(glm_mat2x4_scale) TEST_ENTRY(glmc_mat2x4_copy) TEST_ENTRY(glmc_mat2x4_zero) TEST_ENTRY(glmc_mat2x4_make) TEST_ENTRY(glmc_mat2x4_mul) TEST_ENTRY(glmc_mat2x4_mulv) TEST_ENTRY(glmc_mat2x4_transpose) TEST_ENTRY(glmc_mat2x4_scale) /* camera (incl [LR]H cross [NZ]O) */ TEST_ENTRY(glm_perspective_lh_zo) TEST_ENTRY(glm_perspective_rh_zo) TEST_ENTRY(glm_perspective_lh_no) TEST_ENTRY(glm_perspective_rh_no) TEST_ENTRY(glm_camera_lookat) TEST_ENTRY(glm_camera_decomp) TEST_ENTRY(glmc_perspective_lh_zo) TEST_ENTRY(glmc_perspective_rh_zo) TEST_ENTRY(glmc_perspective_lh_no) TEST_ENTRY(glmc_perspective_rh_no) TEST_ENTRY(glmc_camera_lookat) TEST_ENTRY(glmc_camera_decomp) TEST_ENTRY(glm_frustum) TEST_ENTRY(glmc_frustum) /* project */ TEST_ENTRY(glm_unprojecti) TEST_ENTRY(glm_unproject) TEST_ENTRY(glm_project) TEST_ENTRY(glmc_unprojecti) TEST_ENTRY(glmc_unproject) TEST_ENTRY(glmc_project) /* plane */ TEST_ENTRY(glm_plane_normalize) TEST_ENTRY(glmc_plane_normalize) /* noise */ TEST_ENTRY(glm_perlin_vec4) TEST_ENTRY(glmc_perlin_vec4) TEST_ENTRY(glm_perlin_vec3) TEST_ENTRY(glmc_perlin_vec3) TEST_ENTRY(glm_perlin_vec2) TEST_ENTRY(glmc_perlin_vec2) /* utils */ TEST_ENTRY(clamp) /* euler */ TEST_ENTRY(glm_euler_xyz_quat_rh) TEST_ENTRY(glm_euler_xzy_quat_rh) TEST_ENTRY(glm_euler_yxz_quat_rh) TEST_ENTRY(glm_euler_yzx_quat_rh) TEST_ENTRY(glm_euler_zxy_quat_rh) TEST_ENTRY(glm_euler_zyx_quat_rh) TEST_ENTRY(glm_euler_xyz_quat_lh) TEST_ENTRY(glm_euler_xzy_quat_lh) TEST_ENTRY(glm_euler_yxz_quat_lh) TEST_ENTRY(glm_euler_yzx_quat_lh) TEST_ENTRY(glm_euler_zxy_quat_lh) TEST_ENTRY(glm_euler_zyx_quat_lh) TEST_ENTRY(glmc_euler_xyz_quat_rh) TEST_ENTRY(glmc_euler_xzy_quat_rh) TEST_ENTRY(glmc_euler_yxz_quat_rh) TEST_ENTRY(glmc_euler_yzx_quat_rh) TEST_ENTRY(glmc_euler_zxy_quat_rh) TEST_ENTRY(glmc_euler_zyx_quat_rh) TEST_ENTRY(glmc_euler_xyz_quat_lh) TEST_ENTRY(glmc_euler_xzy_quat_lh) TEST_ENTRY(glmc_euler_yxz_quat_lh) TEST_ENTRY(glmc_euler_yzx_quat_lh) TEST_ENTRY(glmc_euler_zxy_quat_lh) TEST_ENTRY(glmc_euler_zyx_quat_lh) TEST_ENTRY(euler) /* ray */ TEST_ENTRY(glm_ray_triangle) TEST_ENTRY(glm_ray_sphere) TEST_ENTRY(glm_ray_at) TEST_ENTRY(glmc_ray_triangle) TEST_ENTRY(glmc_ray_sphere) TEST_ENTRY(glmc_ray_at) /* quat */ TEST_ENTRY(MACRO_GLM_QUAT_IDENTITY_INIT) TEST_ENTRY(MACRO_GLM_QUAT_IDENTITY) TEST_ENTRY(glm_quat_identity) TEST_ENTRY(glm_quat_identity_array) TEST_ENTRY(glm_quat_init) TEST_ENTRY(glm_quatv) TEST_ENTRY(glm_quat) TEST_ENTRY(glm_quat_copy) TEST_ENTRY(glm_quat_norm) TEST_ENTRY(glm_quat_normalize_to) TEST_ENTRY(glm_quat_normalize) TEST_ENTRY(glm_quat_dot) TEST_ENTRY(glm_quat_conjugate) TEST_ENTRY(glm_quat_inv) TEST_ENTRY(glm_quat_add) TEST_ENTRY(glm_quat_sub) TEST_ENTRY(glm_quat_real) TEST_ENTRY(glm_quat_imag) TEST_ENTRY(glm_quat_imagn) TEST_ENTRY(glm_quat_imaglen) TEST_ENTRY(glm_quat_angle) TEST_ENTRY(glm_quat_axis) TEST_ENTRY(glm_quat_mul) TEST_ENTRY(glm_quat_mat4) TEST_ENTRY(glm_quat_mat4t) TEST_ENTRY(glm_quat_mat3) TEST_ENTRY(glm_quat_mat3t) TEST_ENTRY(glm_quat_lerp) TEST_ENTRY(glm_quat_lerpc) TEST_ENTRY(glm_quat_nlerp) TEST_ENTRY(glm_quat_slerp) TEST_ENTRY(glm_quat_look) TEST_ENTRY(glm_quat_for) TEST_ENTRY(glm_quat_forp) TEST_ENTRY(glm_quat_rotatev) TEST_ENTRY(glm_quat_rotate) TEST_ENTRY(glm_quat_rotate_at) TEST_ENTRY(glm_quat_rotate_atm) TEST_ENTRY(glm_quat_from_vecs) TEST_ENTRY(glm_quat_make) TEST_ENTRY(glmc_quat_identity) TEST_ENTRY(glmc_quat_identity_array) TEST_ENTRY(glmc_quat_init) TEST_ENTRY(glmc_quatv) TEST_ENTRY(glmc_quat) TEST_ENTRY(glmc_quat_copy) TEST_ENTRY(glmc_quat_norm) TEST_ENTRY(glmc_quat_normalize_to) TEST_ENTRY(glmc_quat_normalize) TEST_ENTRY(glmc_quat_dot) TEST_ENTRY(glmc_quat_conjugate) TEST_ENTRY(glmc_quat_inv) TEST_ENTRY(glmc_quat_add) TEST_ENTRY(glmc_quat_sub) TEST_ENTRY(glmc_quat_real) TEST_ENTRY(glmc_quat_imag) TEST_ENTRY(glmc_quat_imagn) TEST_ENTRY(glmc_quat_imaglen) TEST_ENTRY(glmc_quat_angle) TEST_ENTRY(glmc_quat_axis) TEST_ENTRY(glmc_quat_mul) TEST_ENTRY(glmc_quat_mat4) TEST_ENTRY(glmc_quat_mat4t) TEST_ENTRY(glmc_quat_mat3) TEST_ENTRY(glmc_quat_mat3t) TEST_ENTRY(glmc_quat_lerp) TEST_ENTRY(glmc_quat_lerpc) TEST_ENTRY(glmc_quat_nlerp) TEST_ENTRY(glmc_quat_slerp) TEST_ENTRY(glmc_quat_look) TEST_ENTRY(glmc_quat_for) TEST_ENTRY(glmc_quat_forp) TEST_ENTRY(glmc_quat_rotatev) TEST_ENTRY(glmc_quat_rotate) TEST_ENTRY(glmc_quat_rotate_at) TEST_ENTRY(glmc_quat_rotate_atm) TEST_ENTRY(glmc_quat_from_vecs) TEST_ENTRY(glmc_quat_make) /* bezier */ TEST_ENTRY(bezier) /* vec2 */ TEST_ENTRY(MACRO_GLM_VEC2_ONE_INIT) TEST_ENTRY(MACRO_GLM_VEC2_ZERO_INIT) TEST_ENTRY(MACRO_GLM_VEC2_ONE) TEST_ENTRY(MACRO_GLM_VEC2_ZERO) TEST_ENTRY(glm_vec2) TEST_ENTRY(glm_vec2_copy) TEST_ENTRY(glm_vec2_zero) TEST_ENTRY(glm_vec2_one) TEST_ENTRY(glm_vec2_dot) TEST_ENTRY(glm_vec2_cross) TEST_ENTRY(glm_vec2_norm2) TEST_ENTRY(glm_vec2_norm) TEST_ENTRY(glm_vec2_add) TEST_ENTRY(glm_vec2_adds) TEST_ENTRY(glm_vec2_sub) TEST_ENTRY(glm_vec2_subs) TEST_ENTRY(glm_vec2_mul) TEST_ENTRY(glm_vec2_scale) TEST_ENTRY(glm_vec2_scale_as) TEST_ENTRY(glm_vec2_div) TEST_ENTRY(glm_vec2_divs) TEST_ENTRY(glm_vec2_addadd) TEST_ENTRY(glm_vec2_subadd) TEST_ENTRY(glm_vec2_muladd) TEST_ENTRY(glm_vec2_muladds) TEST_ENTRY(glm_vec2_maxadd) TEST_ENTRY(glm_vec2_minadd) TEST_ENTRY(glm_vec2_subsub) TEST_ENTRY(glm_vec2_addsub) TEST_ENTRY(glm_vec2_mulsub) TEST_ENTRY(glm_vec2_mulsubs) TEST_ENTRY(glm_vec2_maxsub) TEST_ENTRY(glm_vec2_minsub) TEST_ENTRY(glm_vec2_negate_to) TEST_ENTRY(glm_vec2_negate) TEST_ENTRY(glm_vec2_normalize) TEST_ENTRY(glm_vec2_normalize_to) TEST_ENTRY(glm_vec2_rotate) TEST_ENTRY(glm_vec2_center) TEST_ENTRY(glm_vec2_distance2) TEST_ENTRY(glm_vec2_distance) TEST_ENTRY(glm_vec2_maxv) TEST_ENTRY(glm_vec2_minv) TEST_ENTRY(glm_vec2_clamp) TEST_ENTRY(glm_vec2_abs) TEST_ENTRY(glm_vec2_fract) TEST_ENTRY(glm_vec2_floor) TEST_ENTRY(glm_vec2_mods) TEST_ENTRY(glm_vec2_steps) TEST_ENTRY(glm_vec2_stepr) TEST_ENTRY(glm_vec2_lerp) TEST_ENTRY(glm_vec2_complex_mul) TEST_ENTRY(glm_vec2_complex_div) TEST_ENTRY(glm_vec2_make) TEST_ENTRY(glm_vec2_reflect) TEST_ENTRY(glm_vec2_refract) TEST_ENTRY(glmc_vec2) TEST_ENTRY(glmc_vec2_copy) TEST_ENTRY(glmc_vec2_zero) TEST_ENTRY(glmc_vec2_one) TEST_ENTRY(glmc_vec2_dot) TEST_ENTRY(glmc_vec2_cross) TEST_ENTRY(glmc_vec2_norm2) TEST_ENTRY(glmc_vec2_norm) TEST_ENTRY(glmc_vec2_add) TEST_ENTRY(glmc_vec2_adds) TEST_ENTRY(glmc_vec2_sub) TEST_ENTRY(glmc_vec2_subs) TEST_ENTRY(glmc_vec2_mul) TEST_ENTRY(glmc_vec2_scale) TEST_ENTRY(glmc_vec2_scale_as) TEST_ENTRY(glmc_vec2_div) TEST_ENTRY(glmc_vec2_divs) TEST_ENTRY(glmc_vec2_addadd) TEST_ENTRY(glmc_vec2_subadd) TEST_ENTRY(glmc_vec2_muladd) TEST_ENTRY(glmc_vec2_muladds) TEST_ENTRY(glmc_vec2_maxadd) TEST_ENTRY(glmc_vec2_minadd) TEST_ENTRY(glmc_vec2_subsub) TEST_ENTRY(glmc_vec2_addsub) TEST_ENTRY(glmc_vec2_mulsub) TEST_ENTRY(glmc_vec2_mulsubs) TEST_ENTRY(glmc_vec2_maxsub) TEST_ENTRY(glmc_vec2_minsub) TEST_ENTRY(glmc_vec2_negate_to) TEST_ENTRY(glmc_vec2_negate) TEST_ENTRY(glmc_vec2_normalize) TEST_ENTRY(glmc_vec2_normalize_to) TEST_ENTRY(glmc_vec2_rotate) TEST_ENTRY(glmc_vec2_center) TEST_ENTRY(glmc_vec2_distance2) TEST_ENTRY(glmc_vec2_distance) TEST_ENTRY(glmc_vec2_maxv) TEST_ENTRY(glmc_vec2_minv) TEST_ENTRY(glmc_vec2_clamp) TEST_ENTRY(glmc_vec2_abs) TEST_ENTRY(glmc_vec2_fract) TEST_ENTRY(glmc_vec2_floor) TEST_ENTRY(glmc_vec2_mods) TEST_ENTRY(glmc_vec2_steps) TEST_ENTRY(glmc_vec2_stepr) TEST_ENTRY(glmc_vec2_lerp) TEST_ENTRY(glmc_vec2_complex_mul) TEST_ENTRY(glmc_vec2_complex_div) TEST_ENTRY(glmc_vec2_make) TEST_ENTRY(glmc_vec2_reflect) TEST_ENTRY(glmc_vec2_refract) /* vec3 */ TEST_ENTRY(MACRO_GLM_VEC3_ONE_INIT) TEST_ENTRY(MACRO_GLM_VEC3_ZERO_INIT) TEST_ENTRY(MACRO_GLM_VEC3_ONE) TEST_ENTRY(MACRO_GLM_VEC3_ZERO) TEST_ENTRY(MACRO_GLM_YUP) TEST_ENTRY(MACRO_GLM_ZUP) TEST_ENTRY(MACRO_GLM_XUP) TEST_ENTRY(MACRO_GLM_FORWARD_RH) TEST_ENTRY(MACRO_GLM_SHUFFLE3) TEST_ENTRY(MACRO_GLM_XXX) TEST_ENTRY(MACRO_GLM_YYY) TEST_ENTRY(MACRO_GLM_ZZZ) TEST_ENTRY(MACRO_GLM_ZYX) TEST_ENTRY(MACRO_glm_vec3_dup) TEST_ENTRY(MACRO_glm_vec3_flipsign) TEST_ENTRY(MACRO_glm_vec3_flipsign_to) TEST_ENTRY(MACRO_glm_vec3_inv) TEST_ENTRY(MACRO_glm_vec3_inv_to) TEST_ENTRY(MACRO_glm_vec3_mulv) TEST_ENTRY(glm_vec3) TEST_ENTRY(glm_vec3_copy) TEST_ENTRY(glm_vec3_zero) TEST_ENTRY(glm_vec3_one) TEST_ENTRY(glm_vec3_dot) TEST_ENTRY(glm_dot) TEST_ENTRY(glm_vec3_norm2) TEST_ENTRY(glm_vec3_norm) TEST_ENTRY(glm_vec3_norm_one) TEST_ENTRY(glm_vec3_norm_inf) TEST_ENTRY(glm_vec3_add) TEST_ENTRY(glm_vec3_adds) TEST_ENTRY(glm_vec3_sub) TEST_ENTRY(glm_vec3_subs) TEST_ENTRY(glm_vec3_mul) TEST_ENTRY(glm_vec3_scale) TEST_ENTRY(glm_vec3_scale_as) TEST_ENTRY(glm_vec3_div) TEST_ENTRY(glm_vec3_divs) TEST_ENTRY(glm_vec3_addadd) TEST_ENTRY(glm_vec3_subadd) TEST_ENTRY(glm_vec3_muladd) TEST_ENTRY(glm_vec3_muladds) TEST_ENTRY(glm_vec3_maxadd) TEST_ENTRY(glm_vec3_minadd) TEST_ENTRY(glm_vec3_subsub) TEST_ENTRY(glm_vec3_addsub) TEST_ENTRY(glm_vec3_mulsub) TEST_ENTRY(glm_vec3_mulsubs) TEST_ENTRY(glm_vec3_maxsub) TEST_ENTRY(glm_vec3_minsub) TEST_ENTRY(glm_vec3_negate_to) TEST_ENTRY(glm_vec3_negate) TEST_ENTRY(glm_vec3_normalize) TEST_ENTRY(glm_vec3_normalize_to) TEST_ENTRY(glm_normalize) TEST_ENTRY(glm_normalize_to) TEST_ENTRY(glm_vec3_cross) TEST_ENTRY(glm_vec3_crossn) TEST_ENTRY(glm_cross) TEST_ENTRY(glm_vec3_angle) TEST_ENTRY(glm_vec3_rotate) TEST_ENTRY(glm_vec3_rotate_m4) TEST_ENTRY(glm_vec3_rotate_m3) TEST_ENTRY(glm_vec3_proj) TEST_ENTRY(glm_vec3_center) TEST_ENTRY(glmc_vec3_distance2) TEST_ENTRY(glmc_vec3_distance) TEST_ENTRY(glm_vec3_maxv) TEST_ENTRY(glm_vec3_minv) TEST_ENTRY(glm_vec3_ortho) TEST_ENTRY(glm_vec3_clamp) TEST_ENTRY(glm_vec3_mix) TEST_ENTRY(glm_vec3_mixc) TEST_ENTRY(glm_vec3_step) TEST_ENTRY(glm_vec3_smoothstep_uni) TEST_ENTRY(glm_vec3_smoothstep) TEST_ENTRY(glm_vec3_smoothinterp) TEST_ENTRY(glm_vec3_smoothinterpc) TEST_ENTRY(glm_vec3_swizzle) TEST_ENTRY(glm_vec3_broadcast) TEST_ENTRY(glm_vec3_fill) TEST_ENTRY(glm_vec3_eq) TEST_ENTRY(glm_vec3_eq_eps) TEST_ENTRY(glm_vec3_eq_all) TEST_ENTRY(glm_vec3_eqv) TEST_ENTRY(glm_vec3_eqv_eps) TEST_ENTRY(glm_vec3_max) TEST_ENTRY(glm_vec3_min) TEST_ENTRY(glm_vec3_isnan) TEST_ENTRY(glm_vec3_isinf) TEST_ENTRY(glm_vec3_isvalid) TEST_ENTRY(glm_vec3_sign) TEST_ENTRY(glm_vec3_abs) TEST_ENTRY(glm_vec3_fract) TEST_ENTRY(glm_vec3_floor) TEST_ENTRY(glm_vec3_mods) TEST_ENTRY(glm_vec3_steps) TEST_ENTRY(glm_vec3_stepr) TEST_ENTRY(glm_vec3_hadd) TEST_ENTRY(glm_vec3_sqrt) TEST_ENTRY(glm_vec3_make) TEST_ENTRY(glm_vec3_faceforward) TEST_ENTRY(glm_vec3_reflect) TEST_ENTRY(glm_vec3_refract) TEST_ENTRY(glmc_vec3) TEST_ENTRY(glmc_vec3_copy) TEST_ENTRY(glmc_vec3_zero) TEST_ENTRY(glmc_vec3_one) TEST_ENTRY(glmc_vec3_dot) TEST_ENTRY(glmc_vec3_norm2) TEST_ENTRY(glmc_vec3_norm) TEST_ENTRY(glmc_vec3_norm_one) TEST_ENTRY(glmc_vec3_norm_inf) TEST_ENTRY(glmc_vec3_add) TEST_ENTRY(glmc_vec3_adds) TEST_ENTRY(glmc_vec3_sub) TEST_ENTRY(glmc_vec3_subs) TEST_ENTRY(glmc_vec3_mul) TEST_ENTRY(glmc_vec3_scale) TEST_ENTRY(glmc_vec3_scale_as) TEST_ENTRY(glmc_vec3_div) TEST_ENTRY(glmc_vec3_divs) TEST_ENTRY(glmc_vec3_addadd) TEST_ENTRY(glmc_vec3_subadd) TEST_ENTRY(glmc_vec3_muladd) TEST_ENTRY(glmc_vec3_muladds) TEST_ENTRY(glmc_vec3_maxadd) TEST_ENTRY(glmc_vec3_minadd) TEST_ENTRY(glmc_vec3_subsub) TEST_ENTRY(glmc_vec3_addsub) TEST_ENTRY(glmc_vec3_mulsub) TEST_ENTRY(glmc_vec3_mulsubs) TEST_ENTRY(glmc_vec3_maxsub) TEST_ENTRY(glmc_vec3_minsub) TEST_ENTRY(glmc_vec3_negate_to) TEST_ENTRY(glmc_vec3_negate) TEST_ENTRY(glmc_vec3_normalize) TEST_ENTRY(glmc_vec3_normalize_to) TEST_ENTRY(glmc_vec3_cross) TEST_ENTRY(glmc_vec3_crossn) TEST_ENTRY(glmc_vec3_angle) TEST_ENTRY(glmc_vec3_rotate) TEST_ENTRY(glmc_vec3_rotate_m4) TEST_ENTRY(glmc_vec3_rotate_m3) TEST_ENTRY(glmc_vec3_proj) TEST_ENTRY(glmc_vec3_center) TEST_ENTRY(glmc_vec3_distance2) TEST_ENTRY(glmc_vec3_distance) TEST_ENTRY(glmc_vec3_maxv) TEST_ENTRY(glmc_vec3_minv) TEST_ENTRY(glmc_vec3_ortho) TEST_ENTRY(glmc_vec3_clamp) TEST_ENTRY(glmc_vec3_mix) TEST_ENTRY(glmc_vec3_mixc) TEST_ENTRY(glmc_vec3_step) TEST_ENTRY(glmc_vec3_smoothstep_uni) TEST_ENTRY(glmc_vec3_smoothstep) TEST_ENTRY(glmc_vec3_smoothinterp) TEST_ENTRY(glmc_vec3_smoothinterpc) TEST_ENTRY(glmc_vec3_swizzle) TEST_ENTRY(glmc_vec3_broadcast) TEST_ENTRY(glmc_vec3_fill) TEST_ENTRY(glmc_vec3_eq) TEST_ENTRY(glmc_vec3_eq_eps) TEST_ENTRY(glmc_vec3_eq_all) TEST_ENTRY(glmc_vec3_eqv) TEST_ENTRY(glmc_vec3_eqv_eps) TEST_ENTRY(glmc_vec3_max) TEST_ENTRY(glmc_vec3_min) TEST_ENTRY(glmc_vec3_isnan) TEST_ENTRY(glmc_vec3_isinf) TEST_ENTRY(glmc_vec3_isvalid) TEST_ENTRY(glmc_vec3_sign) TEST_ENTRY(glmc_vec3_abs) TEST_ENTRY(glmc_vec3_fract) TEST_ENTRY(glmc_vec3_floor) TEST_ENTRY(glmc_vec3_mods) TEST_ENTRY(glmc_vec3_steps) TEST_ENTRY(glmc_vec3_stepr) TEST_ENTRY(glmc_vec3_hadd) TEST_ENTRY(glmc_vec3_sqrt) TEST_ENTRY(glmc_vec3_make) TEST_ENTRY(glmc_vec3_faceforward) TEST_ENTRY(glmc_vec3_reflect) TEST_ENTRY(glmc_vec3_refract) /* vec4 */ TEST_ENTRY(MACRO_GLM_VEC4_ONE_INIT) TEST_ENTRY(MACRO_GLM_VEC4_ZERO_INIT) TEST_ENTRY(MACRO_GLM_VEC4_ONE) TEST_ENTRY(MACRO_GLM_VEC4_ZERO) TEST_ENTRY(MACRO_GLM_XXXX) TEST_ENTRY(MACRO_GLM_YYYY) TEST_ENTRY(MACRO_GLM_ZZZZ) TEST_ENTRY(MACRO_GLM_WZYX) TEST_ENTRY(MACRO_glm_vec4_dup) TEST_ENTRY(MACRO_glm_vec4_flipsign) TEST_ENTRY(MACRO_glm_vec4_flipsign_to) TEST_ENTRY(MACRO_glm_vec4_inv) TEST_ENTRY(MACRO_glm_vec4_inv_to) TEST_ENTRY(MACRO_glm_vec4_mulv) TEST_ENTRY(glm_vec4) TEST_ENTRY(glm_vec4_copy3) TEST_ENTRY(glm_vec4_copy) TEST_ENTRY(glm_vec4_ucopy) TEST_ENTRY(glm_vec4_zero) TEST_ENTRY(glm_vec4_one) TEST_ENTRY(glm_vec4_dot) TEST_ENTRY(glm_vec4_norm2) TEST_ENTRY(glm_vec4_norm) TEST_ENTRY(glm_vec4_norm_one) TEST_ENTRY(glm_vec4_norm_inf) TEST_ENTRY(glm_vec4_add) TEST_ENTRY(glm_vec4_adds) TEST_ENTRY(glm_vec4_sub) TEST_ENTRY(glm_vec4_subs) TEST_ENTRY(glm_vec4_mul) TEST_ENTRY(glm_vec4_scale) TEST_ENTRY(glm_vec4_scale_as) TEST_ENTRY(glm_vec4_div) TEST_ENTRY(glm_vec4_divs) TEST_ENTRY(glm_vec4_addadd) TEST_ENTRY(glm_vec4_subadd) TEST_ENTRY(glm_vec4_muladd) TEST_ENTRY(glm_vec4_muladds) TEST_ENTRY(glm_vec4_maxadd) TEST_ENTRY(glm_vec4_minadd) TEST_ENTRY(glm_vec4_subsub) TEST_ENTRY(glm_vec4_addsub) TEST_ENTRY(glm_vec4_mulsub) TEST_ENTRY(glm_vec4_mulsubs) TEST_ENTRY(glm_vec4_maxsub) TEST_ENTRY(glm_vec4_minsub) TEST_ENTRY(glm_vec4_negate_to) TEST_ENTRY(glm_vec4_negate) TEST_ENTRY(glm_vec4_normalize) TEST_ENTRY(glm_vec4_normalize_to) TEST_ENTRY(glm_vec4_distance2) TEST_ENTRY(glm_vec4_distance) TEST_ENTRY(glm_vec4_maxv) TEST_ENTRY(glm_vec4_minv) TEST_ENTRY(glm_vec4_clamp) TEST_ENTRY(glm_vec4_lerp) TEST_ENTRY(glm_vec4_lerpc) TEST_ENTRY(glm_vec4_mix) TEST_ENTRY(glm_vec4_mixc) TEST_ENTRY(glm_vec4_step) TEST_ENTRY(glm_vec4_smoothstep_uni) TEST_ENTRY(glm_vec4_smoothstep) TEST_ENTRY(glm_vec4_smoothinterp) TEST_ENTRY(glm_vec4_smoothinterpc) TEST_ENTRY(glm_vec4_cubic) TEST_ENTRY(glm_vec4_swizzle) TEST_ENTRY(glm_vec4_broadcast) TEST_ENTRY(glm_vec4_fill) TEST_ENTRY(glm_vec4_eq) TEST_ENTRY(glm_vec4_eq_eps) TEST_ENTRY(glm_vec4_eq_all) TEST_ENTRY(glm_vec4_eqv) TEST_ENTRY(glm_vec4_eqv_eps) TEST_ENTRY(glm_vec4_max) TEST_ENTRY(glm_vec4_min) TEST_ENTRY(glm_vec4_isnan) TEST_ENTRY(glm_vec4_isinf) TEST_ENTRY(glm_vec4_isvalid) TEST_ENTRY(glm_vec4_sign) TEST_ENTRY(glm_vec4_abs) TEST_ENTRY(glm_vec4_fract) TEST_ENTRY(glm_vec4_floor) TEST_ENTRY(glm_vec4_mods) TEST_ENTRY(glm_vec4_steps) TEST_ENTRY(glm_vec4_stepr) TEST_ENTRY(glm_vec4_hadd) TEST_ENTRY(glm_vec4_sqrt) TEST_ENTRY(glm_vec4_make) TEST_ENTRY(glm_vec4_reflect) TEST_ENTRY(glm_vec4_refract) TEST_ENTRY(glmc_vec4) TEST_ENTRY(glmc_vec4_copy3) TEST_ENTRY(glmc_vec4_copy) TEST_ENTRY(glmc_vec4_ucopy) TEST_ENTRY(glmc_vec4_zero) TEST_ENTRY(glmc_vec4_one) TEST_ENTRY(glmc_vec4_dot) TEST_ENTRY(glmc_vec4_norm2) TEST_ENTRY(glmc_vec4_norm) TEST_ENTRY(glmc_vec4_norm_one) TEST_ENTRY(glmc_vec4_norm_inf) TEST_ENTRY(glmc_vec4_add) TEST_ENTRY(glmc_vec4_adds) TEST_ENTRY(glmc_vec4_sub) TEST_ENTRY(glmc_vec4_subs) TEST_ENTRY(glmc_vec4_mul) TEST_ENTRY(glmc_vec4_scale) TEST_ENTRY(glmc_vec4_scale_as) TEST_ENTRY(glmc_vec4_div) TEST_ENTRY(glmc_vec4_divs) TEST_ENTRY(glmc_vec4_addadd) TEST_ENTRY(glmc_vec4_subadd) TEST_ENTRY(glmc_vec4_muladd) TEST_ENTRY(glmc_vec4_muladds) TEST_ENTRY(glmc_vec4_maxadd) TEST_ENTRY(glmc_vec4_minadd) TEST_ENTRY(glmc_vec4_subsub) TEST_ENTRY(glmc_vec4_addsub) TEST_ENTRY(glmc_vec4_mulsub) TEST_ENTRY(glmc_vec4_mulsubs) TEST_ENTRY(glmc_vec4_maxsub) TEST_ENTRY(glmc_vec4_minsub) TEST_ENTRY(glmc_vec4_negate_to) TEST_ENTRY(glmc_vec4_negate) TEST_ENTRY(glmc_vec4_normalize) TEST_ENTRY(glmc_vec4_normalize_to) TEST_ENTRY(glmc_vec4_distance2) TEST_ENTRY(glmc_vec4_distance) TEST_ENTRY(glmc_vec4_maxv) TEST_ENTRY(glmc_vec4_minv) TEST_ENTRY(glmc_vec4_clamp) TEST_ENTRY(glmc_vec4_lerp) TEST_ENTRY(glmc_vec4_lerpc) TEST_ENTRY(glmc_vec4_mix) TEST_ENTRY(glmc_vec4_mixc) TEST_ENTRY(glmc_vec4_step) TEST_ENTRY(glmc_vec4_smoothstep_uni) TEST_ENTRY(glmc_vec4_smoothstep) TEST_ENTRY(glmc_vec4_smoothinterp) TEST_ENTRY(glmc_vec4_smoothinterpc) TEST_ENTRY(glmc_vec4_cubic) TEST_ENTRY(glmc_vec4_swizzle) TEST_ENTRY(glmc_vec4_broadcast) TEST_ENTRY(glmc_vec4_fill) TEST_ENTRY(glmc_vec4_eq) TEST_ENTRY(glmc_vec4_eq_eps) TEST_ENTRY(glmc_vec4_eq_all) TEST_ENTRY(glmc_vec4_eqv) TEST_ENTRY(glmc_vec4_eqv_eps) TEST_ENTRY(glmc_vec4_max) TEST_ENTRY(glmc_vec4_min) TEST_ENTRY(glmc_vec4_isnan) TEST_ENTRY(glmc_vec4_isinf) TEST_ENTRY(glmc_vec4_isvalid) TEST_ENTRY(glmc_vec4_sign) TEST_ENTRY(glmc_vec4_abs) TEST_ENTRY(glmc_vec4_fract) TEST_ENTRY(glmc_vec4_floor) TEST_ENTRY(glmc_vec4_mods) TEST_ENTRY(glmc_vec4_steps) TEST_ENTRY(glmc_vec4_stepr) TEST_ENTRY(glmc_vec4_hadd) TEST_ENTRY(glmc_vec4_sqrt) TEST_ENTRY(glmc_vec4_make) TEST_ENTRY(glmc_vec4_reflect) TEST_ENTRY(glmc_vec4_refract) /* ivec2 */ TEST_ENTRY(glm_ivec2) TEST_ENTRY(glm_ivec2_copy) TEST_ENTRY(glm_ivec2_zero) TEST_ENTRY(glm_ivec2_one) TEST_ENTRY(glm_ivec2_dot) TEST_ENTRY(glm_ivec2_cross) TEST_ENTRY(glm_ivec2_add) TEST_ENTRY(glm_ivec2_adds) TEST_ENTRY(glm_ivec2_sub) TEST_ENTRY(glm_ivec2_subs) TEST_ENTRY(glm_ivec2_mul) TEST_ENTRY(glm_ivec2_scale) TEST_ENTRY(glm_ivec2_div) TEST_ENTRY(glm_ivec2_divs) TEST_ENTRY(glm_ivec2_mod) TEST_ENTRY(glm_ivec2_addadd) TEST_ENTRY(glm_ivec2_addadds) TEST_ENTRY(glm_ivec2_subadd) TEST_ENTRY(glm_ivec2_subadds) TEST_ENTRY(glm_ivec2_muladd) TEST_ENTRY(glm_ivec2_muladds) TEST_ENTRY(glm_ivec2_maxadd) TEST_ENTRY(glm_ivec2_minadd) TEST_ENTRY(glm_ivec2_subsub) TEST_ENTRY(glm_ivec2_subsubs) TEST_ENTRY(glm_ivec2_addsub) TEST_ENTRY(glm_ivec2_addsubs) TEST_ENTRY(glm_ivec2_mulsub) TEST_ENTRY(glm_ivec2_mulsubs) TEST_ENTRY(glm_ivec2_maxsub) TEST_ENTRY(glm_ivec2_minsub) TEST_ENTRY(glm_ivec2_distance2) TEST_ENTRY(glm_ivec2_distance) TEST_ENTRY(glm_ivec2_fill) TEST_ENTRY(glm_ivec2_eq) TEST_ENTRY(glm_ivec2_eqv) TEST_ENTRY(glm_ivec2_maxv) TEST_ENTRY(glm_ivec2_minv) TEST_ENTRY(glm_ivec2_clamp) TEST_ENTRY(glm_ivec2_abs) TEST_ENTRY(glmc_ivec2) TEST_ENTRY(glmc_ivec2_copy) TEST_ENTRY(glmc_ivec2_zero) TEST_ENTRY(glmc_ivec2_one) TEST_ENTRY(glmc_ivec2_dot) TEST_ENTRY(glmc_ivec2_cross) TEST_ENTRY(glmc_ivec2_add) TEST_ENTRY(glmc_ivec2_adds) TEST_ENTRY(glmc_ivec2_sub) TEST_ENTRY(glmc_ivec2_subs) TEST_ENTRY(glmc_ivec2_mul) TEST_ENTRY(glmc_ivec2_scale) TEST_ENTRY(glmc_ivec2_div) TEST_ENTRY(glmc_ivec2_divs) TEST_ENTRY(glmc_ivec2_mod) TEST_ENTRY(glmc_ivec2_addadd) TEST_ENTRY(glmc_ivec2_addadds) TEST_ENTRY(glmc_ivec2_subadd) TEST_ENTRY(glmc_ivec2_subadds) TEST_ENTRY(glmc_ivec2_muladd) TEST_ENTRY(glmc_ivec2_muladds) TEST_ENTRY(glmc_ivec2_maxadd) TEST_ENTRY(glmc_ivec2_minadd) TEST_ENTRY(glmc_ivec2_subsub) TEST_ENTRY(glmc_ivec2_subsubs) TEST_ENTRY(glmc_ivec2_addsub) TEST_ENTRY(glmc_ivec2_addsubs) TEST_ENTRY(glmc_ivec2_mulsub) TEST_ENTRY(glmc_ivec2_mulsubs) TEST_ENTRY(glmc_ivec2_maxsub) TEST_ENTRY(glmc_ivec2_minsub) TEST_ENTRY(glmc_ivec2_distance2) TEST_ENTRY(glmc_ivec2_distance) TEST_ENTRY(glmc_ivec2_fill) TEST_ENTRY(glmc_ivec2_eq) TEST_ENTRY(glmc_ivec2_eqv) TEST_ENTRY(glmc_ivec2_maxv) TEST_ENTRY(glmc_ivec2_minv) TEST_ENTRY(glmc_ivec2_clamp) TEST_ENTRY(glmc_ivec2_abs) /* ivec3 */ TEST_ENTRY(glm_ivec3) TEST_ENTRY(glm_ivec3_copy) TEST_ENTRY(glm_ivec3_zero) TEST_ENTRY(glm_ivec3_one) TEST_ENTRY(glm_ivec3_dot) TEST_ENTRY(glm_ivec3_norm2) TEST_ENTRY(glm_ivec3_norm) TEST_ENTRY(glm_ivec3_add) TEST_ENTRY(glm_ivec3_adds) TEST_ENTRY(glm_ivec3_sub) TEST_ENTRY(glm_ivec3_subs) TEST_ENTRY(glm_ivec3_mul) TEST_ENTRY(glm_ivec3_scale) TEST_ENTRY(glm_ivec3_div) TEST_ENTRY(glm_ivec3_divs) TEST_ENTRY(glm_ivec3_mod) TEST_ENTRY(glm_ivec3_addadd) TEST_ENTRY(glm_ivec3_addadds) TEST_ENTRY(glm_ivec3_subadd) TEST_ENTRY(glm_ivec3_subadds) TEST_ENTRY(glm_ivec3_muladd) TEST_ENTRY(glm_ivec3_muladds) TEST_ENTRY(glm_ivec3_maxadd) TEST_ENTRY(glm_ivec3_minadd) TEST_ENTRY(glm_ivec3_subsub) TEST_ENTRY(glm_ivec3_subsubs) TEST_ENTRY(glm_ivec3_addsub) TEST_ENTRY(glm_ivec3_addsubs) TEST_ENTRY(glm_ivec3_mulsub) TEST_ENTRY(glm_ivec3_mulsubs) TEST_ENTRY(glm_ivec3_maxsub) TEST_ENTRY(glm_ivec3_minsub) TEST_ENTRY(glm_ivec3_distance2) TEST_ENTRY(glm_ivec3_distance) TEST_ENTRY(glm_ivec3_fill) TEST_ENTRY(glm_ivec3_eq) TEST_ENTRY(glm_ivec3_eqv) TEST_ENTRY(glm_ivec3_maxv) TEST_ENTRY(glm_ivec3_minv) TEST_ENTRY(glm_ivec3_clamp) TEST_ENTRY(glmc_ivec3) TEST_ENTRY(glmc_ivec3_copy) TEST_ENTRY(glmc_ivec3_zero) TEST_ENTRY(glmc_ivec3_one) TEST_ENTRY(glmc_ivec3_dot) TEST_ENTRY(glmc_ivec3_norm2) TEST_ENTRY(glmc_ivec3_norm) TEST_ENTRY(glmc_ivec3_add) TEST_ENTRY(glmc_ivec3_adds) TEST_ENTRY(glmc_ivec3_sub) TEST_ENTRY(glmc_ivec3_subs) TEST_ENTRY(glmc_ivec3_mul) TEST_ENTRY(glmc_ivec3_scale) TEST_ENTRY(glmc_ivec3_div) TEST_ENTRY(glmc_ivec3_divs) TEST_ENTRY(glmc_ivec3_mod) TEST_ENTRY(glmc_ivec3_addadd) TEST_ENTRY(glmc_ivec3_addadds) TEST_ENTRY(glmc_ivec3_subadd) TEST_ENTRY(glmc_ivec3_subadds) TEST_ENTRY(glmc_ivec3_muladd) TEST_ENTRY(glmc_ivec3_muladds) TEST_ENTRY(glmc_ivec3_maxadd) TEST_ENTRY(glmc_ivec3_minadd) TEST_ENTRY(glmc_ivec3_subsub) TEST_ENTRY(glmc_ivec3_subsubs) TEST_ENTRY(glmc_ivec3_addsub) TEST_ENTRY(glmc_ivec3_addsubs) TEST_ENTRY(glmc_ivec3_mulsub) TEST_ENTRY(glmc_ivec3_mulsubs) TEST_ENTRY(glmc_ivec3_maxsub) TEST_ENTRY(glmc_ivec3_minsub) TEST_ENTRY(glmc_ivec3_distance2) TEST_ENTRY(glmc_ivec3_distance) TEST_ENTRY(glmc_ivec3_fill) TEST_ENTRY(glmc_ivec3_eq) TEST_ENTRY(glmc_ivec3_eqv) TEST_ENTRY(glmc_ivec3_maxv) TEST_ENTRY(glmc_ivec3_minv) TEST_ENTRY(glmc_ivec3_clamp) /* ivec4 */ TEST_ENTRY(glm_ivec4) TEST_ENTRY(glm_ivec4_copy) TEST_ENTRY(glm_ivec4_zero) TEST_ENTRY(glm_ivec4_one) TEST_ENTRY(glm_ivec4_add) TEST_ENTRY(glm_ivec4_adds) TEST_ENTRY(glm_ivec4_sub) TEST_ENTRY(glm_ivec4_subs) TEST_ENTRY(glm_ivec4_mul) TEST_ENTRY(glm_ivec4_scale) TEST_ENTRY(glm_ivec4_addadd) TEST_ENTRY(glm_ivec4_addadds) TEST_ENTRY(glm_ivec4_subadd) TEST_ENTRY(glm_ivec4_subadds) TEST_ENTRY(glm_ivec4_muladd) TEST_ENTRY(glm_ivec4_muladds) TEST_ENTRY(glm_ivec4_maxadd) TEST_ENTRY(glm_ivec4_minadd) TEST_ENTRY(glm_ivec4_subsub) TEST_ENTRY(glm_ivec4_subsubs) TEST_ENTRY(glm_ivec4_addsub) TEST_ENTRY(glm_ivec4_addsubs) TEST_ENTRY(glm_ivec4_mulsub) TEST_ENTRY(glm_ivec4_mulsubs) TEST_ENTRY(glm_ivec4_maxsub) TEST_ENTRY(glm_ivec4_minsub) TEST_ENTRY(glm_ivec4_distance2) TEST_ENTRY(glm_ivec4_distance) TEST_ENTRY(glm_ivec4_maxv) TEST_ENTRY(glm_ivec4_minv) TEST_ENTRY(glm_ivec4_clamp) TEST_ENTRY(glmc_ivec4) TEST_ENTRY(glmc_ivec4_copy) TEST_ENTRY(glmc_ivec4_zero) TEST_ENTRY(glmc_ivec4_one) TEST_ENTRY(glmc_ivec4_add) TEST_ENTRY(glmc_ivec4_adds) TEST_ENTRY(glmc_ivec4_sub) TEST_ENTRY(glmc_ivec4_subs) TEST_ENTRY(glmc_ivec4_mul) TEST_ENTRY(glmc_ivec4_scale) TEST_ENTRY(glmc_ivec4_addadd) TEST_ENTRY(glmc_ivec4_addadds) TEST_ENTRY(glmc_ivec4_subadd) TEST_ENTRY(glmc_ivec4_subadds) TEST_ENTRY(glmc_ivec4_muladd) TEST_ENTRY(glmc_ivec4_muladds) TEST_ENTRY(glmc_ivec4_maxadd) TEST_ENTRY(glmc_ivec4_minadd) TEST_ENTRY(glmc_ivec4_subsub) TEST_ENTRY(glmc_ivec4_subsubs) TEST_ENTRY(glmc_ivec4_addsub) TEST_ENTRY(glmc_ivec4_addsubs) TEST_ENTRY(glmc_ivec4_mulsub) TEST_ENTRY(glmc_ivec4_mulsubs) TEST_ENTRY(glmc_ivec4_maxsub) TEST_ENTRY(glmc_ivec4_minsub) TEST_ENTRY(glmc_ivec4_distance2) TEST_ENTRY(glmc_ivec4_distance) TEST_ENTRY(glmc_ivec4_maxv) TEST_ENTRY(glmc_ivec4_minv) TEST_ENTRY(glmc_ivec4_clamp) TEST_ENTRY(glmc_ivec4_abs) /* structs */ TEST_ENTRY(mat2x3s_zero_init) TEST_ENTRY(mat2x3s_zero) TEST_ENTRY(mat2x4s_zero_init) TEST_ENTRY(mat2x4s_zero) TEST_ENTRY(mat3s_identity_init) TEST_ENTRY(mat3s_zero_init) TEST_ENTRY(mat3x2s_zero_init) TEST_ENTRY(mat3x2s_zero) TEST_ENTRY(mat3x4s_zero_init) TEST_ENTRY(mat3x4s_zero) TEST_ENTRY(mat4s_identity_init) TEST_ENTRY(mat4s_zero_init) TEST_ENTRY(mat4x2s_zero_init) TEST_ENTRY(mat4x2s_zero) TEST_ENTRY(mat4x3s_zero_init) TEST_ENTRY(mat4x3s_zero) TEST_ENTRY(quats_zero_init) TEST_ENTRY(vec3s_one_init) TEST_ENTRY(vec3s_zero_init) TEST_ENTRY(vec4s_black_init) TEST_ENTRY(vec4s_one_init) TEST_ENTRY(vec4s_zero_init) }; #endif /* tests_h */ cglm-0.9.6/win/000077500000000000000000000000001475344456400132655ustar00rootroot00000000000000cglm-0.9.6/win/.gitignore000066400000000000000000000001601475344456400152520ustar00rootroot00000000000000!cglm.sln !cglm.vcxproj !cglm.vcxproj.filters !cglm-test.vcxproj !cglm-test.vcxproj.filters !packages.config cglm-0.9.6/win/build.bat000077500000000000000000000000561475344456400150600ustar00rootroot00000000000000msbuild cglm.vcxproj /p:Configuration=Release cglm-0.9.6/win/cglm-test.vcxproj000066400000000000000000000531341475344456400166070ustar00rootroot00000000000000 Debug ARM Debug ARM64 Debug ARM64EC Debug Win32 Release ARM Release ARM64 Release ARM64EC Release Win32 Debug x64 Release x64 {ca8bcaf9-cd25-4133-8f62-3d1449b5d2fc} 16.0 {200E0DF1-7532-44E6-8273-84FB92C5557E} Win32Proj cglmtest 10.0 Application true v142 Unicode Application false v142 true Unicode Application true v142 Unicode Application true v142 Unicode Application true v142 Unicode Application true v142 Unicode Application false v142 true Unicode Application false v142 true Unicode Application false v142 true Unicode Application false v142 true Unicode false false false false true true true true true false Level3 MaxSpeed true true true NDEBUG;_CONSOLE;%(PreprocessorDefinitions) true ../include;%(AdditionalIncludeDirectories) Console true true true %(AdditionalDependencies) Level3 MaxSpeed true true true NDEBUG;_CONSOLE;%(PreprocessorDefinitions) true ../include;%(AdditionalIncludeDirectories) Console true true true %(AdditionalDependencies) Level3 MaxSpeed true true true NDEBUG;_CONSOLE;%(PreprocessorDefinitions) true ../include;%(AdditionalIncludeDirectories) Console true true true %(AdditionalDependencies) Level3 MaxSpeed true true true NDEBUG;_CONSOLE;%(PreprocessorDefinitions) true ../include;%(AdditionalIncludeDirectories) Console true true true %(AdditionalDependencies) Level3 Disabled true WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) true ../include;%(AdditionalIncludeDirectories) Default Console true %(AdditionalDependencies) Level3 Disabled true _DEBUG;_CONSOLE;%(PreprocessorDefinitions) true ../include;%(AdditionalIncludeDirectories) Default Console true %(AdditionalDependencies) Level3 Disabled true _DEBUG;_CONSOLE;%(PreprocessorDefinitions) true ../include;%(AdditionalIncludeDirectories) Default Console true %(AdditionalDependencies) Level3 Disabled true _DEBUG;_CONSOLE;%(PreprocessorDefinitions) true ../include;%(AdditionalIncludeDirectories) Default Console true %(AdditionalDependencies) Level3 Disabled true _DEBUG;_CONSOLE;%(PreprocessorDefinitions) true ../include;%(AdditionalIncludeDirectories) Default Console true %(AdditionalDependencies) Level3 MaxSpeed true true true WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) true ../include;%(AdditionalIncludeDirectories) Console true true true %(AdditionalDependencies) cglm-0.9.6/win/cglm-test.vcxproj.filters000066400000000000000000000111171475344456400202510ustar00rootroot00000000000000 {4FC737F1-C7A5-4376-A066-2A32D752A2FF} cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx {93995380-89BD-4b04-88EB-625FBE52EBFB} h;hh;hpp;hxx;hm;inl;inc;ipp;xsd src src src src src src src include include include src src src src src src src src src src src src src src src src src src src src src src src src src src src src src src src cglm-0.9.6/win/cglm.sln000066400000000000000000000102411475344456400147230ustar00rootroot00000000000000 Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 16 VisualStudioVersion = 16.0.29123.88 MinimumVisualStudioVersion = 10.0.40219.1 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cglm", "cglm.vcxproj", "{CA8BCAF9-CD25-4133-8F62-3D1449B5D2FC}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cglm-test", "cglm-test.vcxproj", "{200E0DF1-7532-44E6-8273-84FB92C5557E}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|ARM = Debug|ARM Debug|ARM64 = Debug|ARM64 Debug|ARM64EC = Debug|ARM64EC Debug|x64 = Debug|x64 Debug|x86 = Debug|x86 Release|ARM = Release|ARM Release|ARM64 = Release|ARM64 Release|ARM64EC = Release|ARM64EC Release|x64 = Release|x64 Release|x86 = Release|x86 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {CA8BCAF9-CD25-4133-8F62-3D1449B5D2FC}.Debug|ARM.ActiveCfg = Debug|ARM {CA8BCAF9-CD25-4133-8F62-3D1449B5D2FC}.Debug|ARM.Build.0 = Debug|ARM {CA8BCAF9-CD25-4133-8F62-3D1449B5D2FC}.Debug|ARM64.ActiveCfg = Debug|ARM64 {CA8BCAF9-CD25-4133-8F62-3D1449B5D2FC}.Debug|ARM64.Build.0 = Debug|ARM64 {CA8BCAF9-CD25-4133-8F62-3D1449B5D2FC}.Debug|ARM64EC.ActiveCfg = Debug|ARM64EC {CA8BCAF9-CD25-4133-8F62-3D1449B5D2FC}.Debug|ARM64EC.Build.0 = Debug|ARM64EC {CA8BCAF9-CD25-4133-8F62-3D1449B5D2FC}.Debug|x64.ActiveCfg = Debug|x64 {CA8BCAF9-CD25-4133-8F62-3D1449B5D2FC}.Debug|x64.Build.0 = Debug|x64 {CA8BCAF9-CD25-4133-8F62-3D1449B5D2FC}.Debug|x86.ActiveCfg = Debug|Win32 {CA8BCAF9-CD25-4133-8F62-3D1449B5D2FC}.Debug|x86.Build.0 = Debug|Win32 {CA8BCAF9-CD25-4133-8F62-3D1449B5D2FC}.Release|ARM.ActiveCfg = Release|ARM {CA8BCAF9-CD25-4133-8F62-3D1449B5D2FC}.Release|ARM.Build.0 = Release|ARM {CA8BCAF9-CD25-4133-8F62-3D1449B5D2FC}.Release|ARM64.ActiveCfg = Release|ARM64 {CA8BCAF9-CD25-4133-8F62-3D1449B5D2FC}.Release|ARM64.Build.0 = Release|ARM64 {CA8BCAF9-CD25-4133-8F62-3D1449B5D2FC}.Release|ARM64EC.ActiveCfg = Release|ARM64EC {CA8BCAF9-CD25-4133-8F62-3D1449B5D2FC}.Release|ARM64EC.Build.0 = Release|ARM64EC {CA8BCAF9-CD25-4133-8F62-3D1449B5D2FC}.Release|x64.ActiveCfg = Release|x64 {CA8BCAF9-CD25-4133-8F62-3D1449B5D2FC}.Release|x64.Build.0 = Release|x64 {CA8BCAF9-CD25-4133-8F62-3D1449B5D2FC}.Release|x86.ActiveCfg = Release|Win32 {CA8BCAF9-CD25-4133-8F62-3D1449B5D2FC}.Release|x86.Build.0 = Release|Win32 {200E0DF1-7532-44E6-8273-84FB92C5557E}.Debug|ARM.ActiveCfg = Debug|ARM {200E0DF1-7532-44E6-8273-84FB92C5557E}.Debug|ARM.Build.0 = Debug|ARM {200E0DF1-7532-44E6-8273-84FB92C5557E}.Debug|ARM64.ActiveCfg = Debug|ARM64 {200E0DF1-7532-44E6-8273-84FB92C5557E}.Debug|ARM64.Build.0 = Debug|ARM64 {200E0DF1-7532-44E6-8273-84FB92C5557E}.Debug|ARM64EC.ActiveCfg = Debug|ARM64EC {200E0DF1-7532-44E6-8273-84FB92C5557E}.Debug|ARM64EC.Build.0 = Debug|ARM64EC {200E0DF1-7532-44E6-8273-84FB92C5557E}.Debug|x64.ActiveCfg = Debug|x64 {200E0DF1-7532-44E6-8273-84FB92C5557E}.Debug|x64.Build.0 = Debug|x64 {200E0DF1-7532-44E6-8273-84FB92C5557E}.Debug|x86.ActiveCfg = Debug|Win32 {200E0DF1-7532-44E6-8273-84FB92C5557E}.Debug|x86.Build.0 = Debug|Win32 {200E0DF1-7532-44E6-8273-84FB92C5557E}.Release|ARM.ActiveCfg = Release|ARM {200E0DF1-7532-44E6-8273-84FB92C5557E}.Release|ARM.Build.0 = Release|ARM {200E0DF1-7532-44E6-8273-84FB92C5557E}.Release|ARM64.ActiveCfg = Release|ARM64 {200E0DF1-7532-44E6-8273-84FB92C5557E}.Release|ARM64.Build.0 = Release|ARM64 {200E0DF1-7532-44E6-8273-84FB92C5557E}.Release|ARM64EC.ActiveCfg = Release|ARM64EC {200E0DF1-7532-44E6-8273-84FB92C5557E}.Release|ARM64EC.Build.0 = Release|ARM64EC {200E0DF1-7532-44E6-8273-84FB92C5557E}.Release|x64.ActiveCfg = Release|x64 {200E0DF1-7532-44E6-8273-84FB92C5557E}.Release|x64.Build.0 = Release|x64 {200E0DF1-7532-44E6-8273-84FB92C5557E}.Release|x86.ActiveCfg = Release|Win32 {200E0DF1-7532-44E6-8273-84FB92C5557E}.Release|x86.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {2AEF23C9-433B-428B-BEBC-068BF3AC9A65} EndGlobalSection EndGlobal cglm-0.9.6/win/cglm.vcxproj000066400000000000000000001024201475344456400156230ustar00rootroot00000000000000 Debug ARM Debug ARM64 Debug ARM64EC Debug Win32 Release ARM Release ARM64 Release ARM64EC Release Win32 Debug x64 Release x64 15.0 {CA8BCAF9-CD25-4133-8F62-3D1449B5D2FC} Win32Proj cglm 10.0 DynamicLibrary true v141 Unicode DynamicLibrary false v141 true Unicode DynamicLibrary true v141 Unicode DynamicLibrary true v141 Unicode DynamicLibrary true v141 Unicode DynamicLibrary true v141 Unicode DynamicLibrary false v141 true Unicode DynamicLibrary false v141 true Unicode DynamicLibrary false v141 true Unicode DynamicLibrary false v141 true Unicode true NativeRecommendedRules.ruleset true NativeRecommendedRules.ruleset true NativeRecommendedRules.ruleset true NativeRecommendedRules.ruleset true NativeRecommendedRules.ruleset true false NativeRecommendedRules.ruleset true false NativeRecommendedRules.ruleset true false NativeRecommendedRules.ruleset true false NativeRecommendedRules.ruleset true false NativeRecommendedRules.ruleset true NotUsing Level3 MaxSpeed WIN32;_DEBUG;_WINDOWS;_USRDLL;CGLM_EXPORTS;%(PreprocessorDefinitions) None Default CompileAsC true true Windows Level3 MaxSpeed _DEBUG;_WINDOWS;_USRDLL;CGLM_EXPORTS;%(PreprocessorDefinitions) AnySuitable true true CompileAsC None Default true Windows Level3 MaxSpeed _DEBUG;_WINDOWS;_USRDLL;CGLM_EXPORTS;%(PreprocessorDefinitions) AnySuitable true true CompileAsC None Default true Windows Level3 MaxSpeed _DEBUG;_WINDOWS;_USRDLL;CGLM_EXPORTS;%(PreprocessorDefinitions) AnySuitable true true CompileAsC None Default true Windows Level3 MaxSpeed _DEBUG;_WINDOWS;_USRDLL;CGLM_EXPORTS;%(PreprocessorDefinitions) AnySuitable true true CompileAsC None Default true Windows Level3 NotUsing MaxSpeed true true WIN32;NDEBUG;_WINDOWS;_USRDLL;CGLM_EXPORTS;%(PreprocessorDefinitions) None CompileAsC true Default Windows true true Level3 NotUsing MaxSpeed true true NDEBUG;_WINDOWS;_USRDLL;CGLM_EXPORTS;%(PreprocessorDefinitions) None CompileAsC true Default Windows true true Level3 NotUsing MaxSpeed true true NDEBUG;_WINDOWS;_USRDLL;CGLM_EXPORTS;%(PreprocessorDefinitions) None CompileAsC true Default Windows true true Level3 NotUsing MaxSpeed true true NDEBUG;_WINDOWS;_USRDLL;CGLM_EXPORTS;%(PreprocessorDefinitions) None CompileAsC true Default Windows true true Level3 NotUsing MaxSpeed true true NDEBUG;_WINDOWS;_USRDLL;CGLM_EXPORTS;%(PreprocessorDefinitions) None CompileAsC true Default Windows true true cglm-0.9.6/win/cglm.vcxproj.filters000066400000000000000000000710521475344456400173000ustar00rootroot00000000000000 {4FC737F1-C7A5-4376-A066-2A32D752A2FF} cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx {f46634e5-c098-41a0-afb3-45afb6a53593} {b982cbd3-03d9-4557-bed8-8224e4d95945} {6a2a4ebb-ac68-4ed6-a4a1-f6d2243814e9} {4bcb64d3-e522-48f7-85ef-3ddfacf50874} {ccf6244c-614c-4016-a5d9-8a78ffc7765a} {8607b04c-6eb6-49af-8ac2-e534ba78bf76} {fb97f276-fe14-47ba-8a9f-01032f065a19} {0b5febe7-a88d-4330-94ae-305897a5e957} {8044a657-123d-4a0e-8de1-f348fad7dadb} {842a48fc-5c7e-4951-9623-64af96dfb95a} {86101de1-0722-4c88-92a0-e6d71158354e} {98a166bb-ba2d-4649-a20f-ba6bf4ce6383} {24571788-2e78-4969-b66f-065aea5489be} {e6a410e7-83db-41a5-b9fc-34bbfcf46ae5} src src src src src src src src src src src src src src src src src src src src src src src src src src src src\clipspace src\clipspace src\clipspace src\clipspace src\clipspace src\clipspace src\clipspace src\clipspace src\clipspace src\clipspace src\clipspace src\clipspace src\clipspace src\clipspace src src src src src src include\cglm\call include\cglm\call include\cglm\call include\cglm\call include\cglm\call include\cglm\call include\cglm\call include\cglm\call include\cglm\call include\cglm\call include\cglm\call include\cglm\call include\cglm\call include\cglm\call include\cglm\simd\avx include\cglm\simd\avx include\cglm\simd\neon include\cglm\simd\sse2 include\cglm\simd\sse2 include\cglm\simd\sse2 include\cglm\simd\sse2 include\cglm\simd include\cglm include\cglm include\cglm include\cglm include\cglm include\cglm include\cglm include\cglm include\cglm include\cglm include\cglm include\cglm include\cglm include\cglm include\cglm include\cglm include\cglm include\cglm include\cglm include\cglm include\cglm include\cglm include\cglm\call include\cglm\call include\cglm include\cglm include\cglm\call include\cglm include\cglm include\cglm include\cglm\call include\cglm\call include\cglm include\cglm\call include\cglm include\cglm include\cglm\simd include\cglm\simd include\cglm\call include\cglm include\cglm include\cglm\call include\cglm include\cglm\struct include\cglm\struct include\cglm\struct include\cglm\struct include\cglm\struct include\cglm\struct include\cglm\struct include\cglm\struct include\cglm\struct include\cglm\struct include\cglm\struct include\cglm\struct include\cglm\struct include\cglm\struct include\cglm\struct include\cglm\struct include\cglm\struct include\cglm\struct include\cglm\struct include\cglm\struct include\cglm\struct include\cglm\struct include\cglm include\cglm include\cglm\call include\cglm\call include\cglm\call include\cglm\call include\cglm\struct include\cglm\struct include\cglm\struct include\cglm include\cglm include\cglm include\cglm include\cglm include\cglm\struct include\cglm\struct include\cglm\simd\sse2 include\cglm\call include\cglm include\cglm\struct include\cglm\simd\neon include\cglm\simd\neon include\cglm\simd\neon include\cglm\clipspace include\cglm\clipspace include\cglm\clipspace include\cglm\clipspace include\cglm\clipspace include\cglm\clipspace include\cglm\clipspace include\cglm\clipspace include\cglm\clipspace include\cglm\clipspace include\cglm\clipspace include\cglm\clipspace include\cglm\clipspace include\cglm\clipspace include\cglm\clipspace include\cglm\call\clipspace include\cglm\call\clipspace include\cglm\call\clipspace include\cglm\call\clipspace include\cglm\call\clipspace include\cglm\call\clipspace include\cglm\call\clipspace include\cglm\call\clipspace include\cglm\call\clipspace include\cglm\call\clipspace include\cglm\call\clipspace include\cglm\call\clipspace include\cglm\struct\clipspace include\cglm\struct\clipspace include\cglm\struct\clipspace include\cglm\struct\clipspace include\cglm\struct\clipspace include\cglm\struct\clipspace include\cglm\struct\clipspace include\cglm\struct\clipspace include\cglm\struct\clipspace include\cglm\struct\clipspace include\cglm\struct\clipspace include\cglm\struct\clipspace include\cglm\clipspace include\cglm\clipspace include\cglm\call\clipspace include\cglm\call\clipspace include\cglm\call include\cglm\call include\cglm\call include\cglm\struct\clipspace include\cglm\struct\clipspace include\cglm include\cglm include\cglm include\cglm include\cglm include\cglm\struct include\cglm\struct include\cglm\struct include\cglm include\cglm\call include\cglm\simd\wasm include\cglm\simd\wasm include\cglm\simd\wasm include\cglm\simd\wasm include\cglm\simd\wasm include\cglm\simd include\cglm\struct include\cglm\struct\handed include\cglm\struct\handed include\cglm\struct include\cglm\struct include\cglm\struct include\cglm\struct include\cglm include\cglm\call include\cglm\struct