├── .drone.jsonnet ├── .drone ├── drone.bat └── drone.sh ├── .gitattributes ├── .github └── workflows │ ├── ci.yml │ └── gh-pages.yml ├── .gitignore ├── .vscode ├── c_cpp_properties.json └── tasks.json ├── CMakeLists.txt ├── LICENSE_1_0.txt ├── README.md ├── build.jam ├── doc ├── .gitignore ├── Jamfile ├── docinfo.html ├── qvm-theme.yml ├── qvm.adoc ├── rouge-github.css ├── skin.png ├── zajo-dark.css └── zajo-light.css ├── gen ├── Jamfile.v2 ├── gen.cpp └── generate_single_header.py ├── include └── boost │ ├── qvm.hpp │ ├── qvm │ ├── all.hpp │ ├── assert.hpp │ ├── config.hpp │ ├── deduce_mat.hpp │ ├── deduce_quat.hpp │ ├── deduce_scalar.hpp │ ├── deduce_vec.hpp │ ├── detail │ │ ├── cofactor_impl.hpp │ │ ├── determinant_impl.hpp │ │ ├── mat_assign.hpp │ │ ├── quat_assign.hpp │ │ ├── remove_const.hpp │ │ ├── swizzle_traits.hpp │ │ ├── transp_impl.hpp │ │ ├── vec_assign.hpp │ │ └── vec_register_impl.hpp │ ├── enable_if.hpp │ ├── error.hpp │ ├── gen │ │ ├── mat_assign2.hpp │ │ ├── mat_assign3.hpp │ │ ├── mat_assign4.hpp │ │ ├── mat_operations2.hpp │ │ ├── mat_operations3.hpp │ │ ├── mat_operations4.hpp │ │ ├── swizzle2.hpp │ │ ├── swizzle3.hpp │ │ ├── swizzle4.hpp │ │ ├── vec_assign2.hpp │ │ ├── vec_assign3.hpp │ │ ├── vec_assign4.hpp │ │ ├── vec_mat_operations2.hpp │ │ ├── vec_mat_operations3.hpp │ │ ├── vec_mat_operations4.hpp │ │ ├── vec_operations2.hpp │ │ ├── vec_operations3.hpp │ │ └── vec_operations4.hpp │ ├── is_scalar.hpp │ ├── lite.hpp │ ├── map.hpp │ ├── map_mat_mat.hpp │ ├── map_mat_vec.hpp │ ├── map_vec_mat.hpp │ ├── mat.hpp │ ├── mat_access.hpp │ ├── mat_operations.hpp │ ├── mat_operations2.hpp │ ├── mat_operations3.hpp │ ├── mat_operations4.hpp │ ├── mat_traits.hpp │ ├── mat_traits_array.hpp │ ├── mat_traits_defaults.hpp │ ├── math.hpp │ ├── operations.hpp │ ├── quat.hpp │ ├── quat_access.hpp │ ├── quat_operations.hpp │ ├── quat_traits.hpp │ ├── quat_traits_array.hpp │ ├── quat_traits_defaults.hpp │ ├── quat_vec_operations.hpp │ ├── scalar_traits.hpp │ ├── static_assert.hpp │ ├── swizzle.hpp │ ├── swizzle2.hpp │ ├── swizzle3.hpp │ ├── swizzle4.hpp │ ├── throw_exception.hpp │ ├── to_string.hpp │ ├── vec.hpp │ ├── vec_access.hpp │ ├── vec_mat_operations.hpp │ ├── vec_mat_operations2.hpp │ ├── vec_mat_operations3.hpp │ ├── vec_mat_operations4.hpp │ ├── vec_operations.hpp │ ├── vec_operations2.hpp │ ├── vec_operations3.hpp │ ├── vec_operations4.hpp │ ├── vec_register.hpp │ ├── vec_register2.hpp │ ├── vec_register3.hpp │ ├── vec_register4.hpp │ ├── vec_traits.hpp │ ├── vec_traits_array.hpp │ ├── vec_traits_defaults.hpp │ └── vec_traits_gnuc.hpp │ └── qvm_lite.hpp ├── index.html ├── meson.build ├── meson_options.txt ├── meta └── libraries.json └── test ├── Jamfile.v2 ├── access_m_fail1.cpp ├── access_m_fail2.cpp ├── access_m_test.cpp ├── access_q_fail.cpp ├── access_q_test.cpp ├── access_v_fail1.cpp ├── access_v_fail2.cpp ├── access_v_test.cpp ├── assign_test.cpp ├── cmp_mm_test.cpp ├── cmp_qq_test.cpp ├── cmp_vv_test.cpp ├── col_mat_test.cpp ├── col_test.cpp ├── conjugate_test.cpp ├── convert_to_test.cpp ├── cross_test.cpp ├── deduce_mat_test.cpp ├── deduce_quat_test.cpp ├── deduce_scalar_fail.cpp ├── deduce_scalar_mq_test.cpp ├── deduce_scalar_mv_test.cpp ├── deduce_scalar_test.cpp ├── deduce_vec_test.cpp ├── del_col_test.cpp ├── del_row_col_test.cpp ├── del_row_test.cpp ├── determinant_test.cpp ├── diag_mat_test.cpp ├── diag_test.cpp ├── div_eq_ms_test.cpp ├── div_eq_qs_test.cpp ├── div_eq_vs_test.cpp ├── div_ms_test.cpp ├── div_qs_test.cpp ├── div_vs_test.cpp ├── dot_qq_test.cpp ├── dot_vv_test.cpp ├── eq_mm_test.cpp ├── eq_qq_test.cpp ├── eq_vv_test.cpp ├── gold.hpp ├── header-test.cpp ├── identity_mat_test.cpp ├── identity_quat_test.cpp ├── interop_test.cpp ├── inverse_m_test.cpp ├── inverse_q_test.cpp ├── mag_q_test.cpp ├── mag_sqr_q_test.cpp ├── mag_sqr_v_test.cpp ├── mag_v_test.cpp ├── mat_index_test.cpp ├── mat_traits_array_test.cpp ├── mat_traits_std_array_test.cpp ├── math_test.cpp ├── minus_eq_mm_test.cpp ├── minus_eq_qq_test.cpp ├── minus_eq_vv_test.cpp ├── minus_m_test.cpp ├── minus_mm_test.cpp ├── minus_q_test.cpp ├── minus_qq_test.cpp ├── minus_v_test.cpp ├── minus_vv_test.cpp ├── mul_eq_mm_test.cpp ├── mul_eq_ms_test.cpp ├── mul_eq_qq_test.cpp ├── mul_eq_qs_test.cpp ├── mul_eq_vs_test.cpp ├── mul_mm_test.cpp ├── mul_ms_test.cpp ├── mul_mv_test.cpp ├── mul_qq_test.cpp ├── mul_qs_test.cpp ├── mul_qv_test.cpp ├── mul_sm_test.cpp ├── mul_sv_test.cpp ├── mul_vm_test.cpp ├── mul_vs_test.cpp ├── neg_col_test.cpp ├── neg_row_test.cpp ├── normalize_q_test.cpp ├── normalize_v_test.cpp ├── plus_eq_mm_test.cpp ├── plus_eq_qq_test.cpp ├── plus_eq_vv_test.cpp ├── plus_mm_test.cpp ├── plus_qq_test.cpp ├── plus_vv_test.cpp ├── projection_test.cpp ├── quat_traits_array_test.cpp ├── quat_traits_std_array_test.cpp ├── rot_mat_test.cpp ├── rot_quat_test.cpp ├── rotx_mat_test.cpp ├── rotx_quat_test.cpp ├── roty_mat_test.cpp ├── roty_quat_test.cpp ├── rotz_mat_test.cpp ├── rotz_quat_test.cpp ├── row_mat_test.cpp ├── row_test.cpp ├── scalar_cast_m_test.cpp ├── scalar_cast_q_test.cpp ├── scalar_cast_v_test.cpp ├── scalar_traits_test.cpp ├── slerp_test.cpp ├── swap_cols_test.cpp ├── swap_rows_test.cpp ├── swizzle2_test.cpp ├── swizzle2_test2.cpp ├── swizzle2_test3.cpp ├── swizzle2_test4.cpp ├── swizzle3_test.cpp ├── swizzle3_test2.cpp ├── swizzle3_test3.cpp ├── swizzle3_test4.cpp ├── swizzle4_test.cpp ├── swizzle4_test2.cpp ├── swizzle4_test3.cpp ├── swizzle4_test4.cpp ├── swizzle_const_fail.cpp ├── test_qvm.hpp ├── test_qvm_matrix.hpp ├── test_qvm_quaternion.hpp ├── test_qvm_vector.hpp ├── to_string_test.cpp ├── transform_test.cpp ├── translation_mat_test.cpp ├── translation_test.cpp ├── transpose_test.cpp ├── vec_index_test.cpp ├── vec_register_test.cpp ├── vec_traits_array_test.cpp ├── vec_traits_gnuc_test.cpp ├── vec_traits_std_array_test.cpp ├── zero_mat_test.cpp ├── zero_quat_test.cpp └── zero_vec_test.cpp /.drone/drone.bat: -------------------------------------------------------------------------------- 1 | @REM Copyright 2022 Peter Dimov 2 | @REM Distributed under the Boost Software License, Version 1.0. 3 | @REM https://www.boost.org/LICENSE_1_0.txt 4 | 5 | @ECHO ON 6 | 7 | set LIBRARY=%1 8 | set DRONE_BUILD_DIR=%CD% 9 | 10 | set BOOST_BRANCH=develop 11 | if "%DRONE_BRANCH%" == "master" set BOOST_BRANCH=master 12 | cd .. 13 | git clone -b %BOOST_BRANCH% --depth 1 https://github.com/boostorg/boost.git boost-root 14 | cd boost-root 15 | git submodule update --init tools/boostdep 16 | xcopy /s /e /q %DRONE_BUILD_DIR% libs\%LIBRARY%\ 17 | python tools/boostdep/depinst/depinst.py %LIBRARY% 18 | cmd /c bootstrap 19 | b2 -d0 headers 20 | 21 | if not "%CXXSTD%" == "" set CXXSTD=cxxstd=%CXXSTD% 22 | if not "%ADDRMD%" == "" set ADDRMD=address-model=%ADDRMD% 23 | b2 -j3 libs/%LIBRARY%/test toolset=%TOOLSET% %CXXSTD% %ADDRMD% variant=debug,release embed-manifest-via=linker 24 | -------------------------------------------------------------------------------- /.drone/drone.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Copyright 2022 Peter Dimov 4 | # Distributed under the Boost Software License, Version 1.0. 5 | # https://www.boost.org/LICENSE_1_0.txt 6 | 7 | set -ex 8 | 9 | DRONE_BUILD_DIR=$(pwd) 10 | 11 | BOOST_BRANCH=develop 12 | if [ "$DRONE_BRANCH" = "master" ]; then BOOST_BRANCH=master; fi 13 | 14 | cd .. 15 | git clone -b $BOOST_BRANCH --depth 1 https://github.com/boostorg/boost.git boost-root 16 | cd boost-root 17 | git submodule update --init tools/boostdep 18 | cp -r $DRONE_BUILD_DIR/* libs/$LIBRARY 19 | python tools/boostdep/depinst/depinst.py $LIBRARY 20 | ./bootstrap.sh 21 | ./b2 -d0 headers 22 | 23 | echo "using $TOOLSET : : $COMPILER ;" > ~/user-config.jam 24 | ./b2 -j3 libs/$LIBRARY/test toolset=$TOOLSET cxxstd=$CXXSTD variant=debug,release ${ADDRMD:+address-model=$ADDRMD} ${UBSAN:+undefined-sanitizer=norecover debug-symbols=on} ${ASAN:+address-sanitizer=norecover debug-symbols=on} ${LINKFLAGS:+linkflags=$LINKFLAGS} 25 | -------------------------------------------------------------------------------- /.github/workflows/gh-pages.yml: -------------------------------------------------------------------------------- 1 | name: documentation 2 | 3 | on: 4 | push: 5 | branches: 6 | - master 7 | - feature/gha_fixes 8 | 9 | jobs: 10 | publish: 11 | runs-on: ubuntu-latest 12 | steps: 13 | - uses: actions/checkout@v4 14 | 15 | - name: Install packages 16 | run: | 17 | sudo gem install asciidoctor asciidoctor-pdf rouge 18 | 19 | - name: Setup Boost 20 | run: | 21 | REF=${GITHUB_BASE_REF:-$GITHUB_REF} 22 | BOOST_BRANCH=develop && [ "$REF" == "master" ] && BOOST_BRANCH=master || true 23 | cd .. 24 | git clone -b $BOOST_BRANCH --depth 1 https://github.com/boostorg/boost.git boost-root 25 | cd boost-root 26 | cp -r $GITHUB_WORKSPACE/* libs/qvm 27 | git submodule update --init tools/build 28 | git submodule update --init tools/boost_install 29 | git submodule update --init libs/config 30 | ./bootstrap.sh 31 | 32 | - name: Create user-config.jam 33 | run: | 34 | echo "using asciidoctor ;" > ~/user-config.jam 35 | 36 | - name: Build documentation 37 | run: | 38 | cd ../boost-root/libs/qvm/doc 39 | ../../../b2 40 | 41 | - name: Generate single header 42 | run: | 43 | REF=$(git show-ref $GITHUB_REF --hash) 44 | cd ../boost-root/libs/qvm 45 | python gen/generate_single_header.py -i include/boost/qvm.hpp -p include -o doc/html/qvm.hpp boost/qvm --hash "$REF" 46 | python gen/generate_single_header.py -i include/boost/qvm_lite.hpp -p include -o doc/html/qvm_lite.hpp boost/qvm --hash "$REF" 47 | 48 | - name: Deploy to GitHub Pages 49 | uses: JamesIves/github-pages-deploy-action@4.0.0 50 | with: 51 | token: ${{ secrets.GITHUB_TOKEN }} 52 | branch: gh-pages 53 | folder: ../boost-root/libs/qvm/doc/html 54 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | .Trashes 3 | *.suo 4 | *.user 5 | *.log 6 | *.sdf 7 | *.db 8 | vcxproj.bat 9 | vcxproj.exe 10 | *.opensdf 11 | /doc/html/** 12 | /.vscode/c_cpp_properties.json 13 | /bld/* 14 | /test/qvm.hpp 15 | /test/qvm_lite.hpp 16 | -------------------------------------------------------------------------------- /.vscode/c_cpp_properties.json: -------------------------------------------------------------------------------- 1 | { 2 | "configurations": [ 3 | { 4 | "name": "Mac", 5 | "includePath": [ 6 | "${workspaceFolder}/**" 7 | ], 8 | "defines": [], 9 | "macFrameworkPath": [], 10 | "compilerPath": "/usr/local/bin/gcc-9", 11 | "cStandard": "gnu17", 12 | "compileCommands": "${workspaceFolder}/bld/debug/compile_commands.json" 13 | } 14 | ], 15 | "version": 4 16 | } -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Generated by `boostdep --cmake qvm` 2 | # Copyright 2020 Peter Dimov 3 | # Distributed under the Boost Software License, Version 1.0. 4 | # https://www.boost.org/LICENSE_1_0.txt 5 | 6 | cmake_minimum_required(VERSION 3.5...3.16) 7 | 8 | project(boost_qvm VERSION "${BOOST_SUPERPROJECT_VERSION}" LANGUAGES CXX) 9 | 10 | add_library(boost_qvm INTERFACE) 11 | add_library(Boost::qvm ALIAS boost_qvm) 12 | 13 | target_include_directories(boost_qvm INTERFACE include) 14 | 15 | if(BUILD_TESTING AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/test/CMakeLists.txt") 16 | 17 | add_subdirectory(test) 18 | 19 | endif() 20 | 21 | -------------------------------------------------------------------------------- /LICENSE_1_0.txt: -------------------------------------------------------------------------------- 1 | Boost Software License - Version 1.0 - August 17th, 2003 2 | 3 | Permission is hereby granted, free of charge, to any person or organization 4 | obtaining a copy of the software and accompanying documentation covered by 5 | this license (the "Software") to use, reproduce, display, distribute, 6 | execute, and transmit the Software, and to prepare derivative works of the 7 | Software, and to permit third-parties to whom the Software is furnished to 8 | do so, all subject to the following: 9 | 10 | The copyright notices in the Software and this entire statement, including 11 | the above license grant, this restriction and the following disclaimer, 12 | must be included in all copies of the Software, in whole or in part, and 13 | all derivative works of the Software, unless such copies or derivative 14 | works are solely in the form of machine-executable object code generated by 15 | a source language processor. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT 20 | SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE 21 | FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, 22 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 23 | DEALINGS IN THE SOFTWARE. 24 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # QVM 2 | 3 | > A generic C++ library for working with `Q`uaternions, `V`ectors and `M`atrices. 4 | 5 | ## Documentation 6 | 7 | https://boostorg.github.io/qvm/ 8 | 9 | ## Features 10 | 11 | * Emphasis on 2, 3 and 4-dimensional operations needed in graphics, video games and simulation applications. 12 | * Free function templates operate on any compatible user-defined Quaternion, Vector or Matrix type. 13 | * Enables Quaternion, Vector and Matrix types from different libraries to be safely mixed in the same expression. 14 | * Type-safe mapping between compatible lvalue types with no temporary objects; f.ex. transpose remaps the access to the elements, rather than transforming the matrix. 15 | * Requires only {CPP}03. 16 | * Zero dependencies. 17 | 18 | ## Support 19 | 20 | * [cpplang on Slack](https://Cpplang.slack.com) (use the `#boost` channel) 21 | * [Boost Users Mailing List](https://lists.boost.org/mailman/listinfo.cgi/boost-users) 22 | * [Boost Developers Mailing List](https://lists.boost.org/mailman/listinfo.cgi/boost) 23 | 24 | ## Distribution 25 | 26 | Besides GitHub, there are two other distribution channels: 27 | 28 | * QVM is included in official [Boost](https://www.boost.org/) releases. 29 | * For maximum portability, the library is also available in single-header format, in two variants (direct download links): 30 | * [qvm.hpp](https://boostorg.github.io/qvm/qvm.hpp): single header containing the complete QVM source, including the complete set of swizzling overloads. 31 | * [qvm_lite.hpp](https://boostorg.github.io/qvm/qvm_lite.hpp): single header containing everything except for the swizzling overloads. 32 | 33 | Copyright 2008-2023 Emil Dotchevski and Reverge Studios, Inc. Distributed under the [Boost Software License, Version 1.0](http://www.boost.org/LICENSE_1_0.txt). 34 | -------------------------------------------------------------------------------- /build.jam: -------------------------------------------------------------------------------- 1 | # Copyright René Ferdinand Rivera Morell 2023-2024 2 | # Distributed under the Boost Software License, Version 1.0. 3 | # (See accompanying file LICENSE_1_0.txt or copy at 4 | # http://www.boost.org/LICENSE_1_0.txt) 5 | 6 | require-b2 5.2 ; 7 | 8 | project /boost/qvm 9 | ; 10 | 11 | explicit 12 | [ alias boost_qvm : : : 13 | : include $(boost_dependencies) ] 14 | [ alias all : boost_qvm test ] 15 | ; 16 | 17 | call-if : boost-library qvm 18 | ; 19 | 20 | -------------------------------------------------------------------------------- /doc/.gitignore: -------------------------------------------------------------------------------- 1 | /out/ 2 | -------------------------------------------------------------------------------- /doc/Jamfile: -------------------------------------------------------------------------------- 1 | # Copyright 2017 Peter Dimov 2 | # Copyright 2018-2020 Emil Dotchevski 3 | # 4 | # Distributed under the Boost Software License, Version 1.0. 5 | # (See accompanying file LICENSE_1_0.txt or copy at 6 | # http://www.boost.org/LICENSE_1_0.txt) 7 | 8 | project doc/qvm ; 9 | using asciidoctor ; 10 | 11 | html index.html : qvm.adoc : stylesheet=zajo-dark.css linkcss ; 12 | install html_ : index.html skin.png zajo-dark.css zajo-light.css rouge-github.css : html ; 13 | 14 | pdf qvm.pdf : qvm.adoc : book pdf-themesdir=. pdf-theme=qvm ; 15 | install pdf_ : qvm.pdf : html ; 16 | 17 | alias boostdoc ; 18 | explicit boostdoc ; 19 | alias boostrelease : html_ ; 20 | explicit boostrelease ; 21 | -------------------------------------------------------------------------------- /doc/docinfo.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 13 | -------------------------------------------------------------------------------- /doc/qvm-theme.yml: -------------------------------------------------------------------------------- 1 | extends: default 2 | base: 3 | font: 4 | color: #404040 5 | literal: 6 | font: 7 | family: Courier 8 | color: #000000 9 | admonition: 10 | icon: 11 | note: 12 | stroke-color: #000000 13 | tip: 14 | stroke-color: #000000 15 | warning: 16 | stroke-color: #FF5100 17 | important: 18 | stroke-color: #FF5100 19 | caution: 20 | stroke-color: #FF5100 21 | conum: 22 | font: 23 | glyphs: circled 24 | color: #000000 25 | link: 26 | text-decoration: underline 27 | text-decoration-width: 0.5 28 | font-color: #000000 29 | -------------------------------------------------------------------------------- /doc/skin.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/boostorg/qvm/98bb6f3ae69003ca56ebb672df0089662f464b6a/doc/skin.png -------------------------------------------------------------------------------- /gen/Jamfile.v2: -------------------------------------------------------------------------------- 1 | # Copyright 2008-2022 Emil Dotchevski and Reverge Studios, Inc. 2 | 3 | # Distributed under the Boost Software License, Version 1.0. (See accompanying 4 | # file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 5 | 6 | import testing ; 7 | 8 | run gen.cpp : -od ../include/boost/qvm/gen ; 9 | -------------------------------------------------------------------------------- /include/boost/qvm.hpp: -------------------------------------------------------------------------------- 1 | #ifndef BOOST_QVM_HPP_INCLUDED 2 | #define BOOST_QVM_HPP_INCLUDED 3 | 4 | // Copyright 2008-2024 Emil Dotchevski and Reverge Studios, Inc. 5 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 6 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 7 | 8 | #include 9 | 10 | #endif 11 | -------------------------------------------------------------------------------- /include/boost/qvm/all.hpp: -------------------------------------------------------------------------------- 1 | // Copyright 2008-2024 Emil Dotchevski and Reverge Studios, Inc. 2 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 3 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | #include 6 | #include 7 | -------------------------------------------------------------------------------- /include/boost/qvm/assert.hpp: -------------------------------------------------------------------------------- 1 | // Copyright 2008-2024 Emil Dotchevski and Reverge Studios, Inc. 2 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 3 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | #ifndef BOOST_QVM_ASSERT 6 | # ifdef BOOST_ASSERT 7 | # define BOOST_QVM_ASSERT BOOST_ASSERT 8 | # else 9 | # include 10 | # define BOOST_QVM_ASSERT assert 11 | # endif 12 | #endif 13 | -------------------------------------------------------------------------------- /include/boost/qvm/config.hpp: -------------------------------------------------------------------------------- 1 | #ifndef BOOST_QVM_CONFIG_HPP_INCLUDED 2 | #define BOOST_QVM_CONFIG_HPP_INCLUDED 3 | 4 | // Copyright 2008-2024 Emil Dotchevski and Reverge Studios, Inc. 5 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 6 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 7 | 8 | #if defined( BOOST_STRICT_CONFIG ) || defined( BOOST_QVM_NO_WORKAROUNDS ) 9 | # define BOOST_QVM_WORKAROUND( symbol, test ) 0 10 | #else 11 | # define BOOST_QVM_WORKAROUND( symbol, test ) ((symbol) != 0 && ((symbol) test)) 12 | #endif 13 | 14 | #define BOOST_QVM_CLANG 0 15 | #if defined(__clang__) 16 | # undef BOOST_QVM_CLANG 17 | # define BOOST_QVM_CLANG (__clang_major__ * 100 + __clang_minor__) 18 | #endif 19 | 20 | #if BOOST_QVM_WORKAROUND( BOOST_QVM_CLANG, < 304 ) 21 | # define BOOST_QVM_DEPRECATED(msg) 22 | #elif defined(__GNUC__) || defined(__clang__) 23 | # define BOOST_QVM_DEPRECATED(msg) __attribute__((deprecated(msg))) 24 | #elif defined(_MSC_VER) && _MSC_VER >= 1900 25 | # define BOOST_QVM_DEPRECATED(msg) [[deprecated(msg)]] 26 | #else 27 | # define BOOST_QVM_DEPRECATED(msg) 28 | #endif 29 | 30 | #ifndef BOOST_QVM_FORCEINLINE 31 | # if defined(_MSC_VER) 32 | # define BOOST_QVM_FORCEINLINE __forceinline 33 | # elif defined(__GNUC__) && __GNUC__>3 34 | # define BOOST_QVM_FORCEINLINE inline __attribute__ ((always_inline)) 35 | # else 36 | # define BOOST_QVM_FORCEINLINE inline 37 | # endif 38 | #endif 39 | 40 | #ifndef BOOST_QVM_INLINE 41 | # define BOOST_QVM_INLINE inline 42 | #endif 43 | 44 | #ifndef BOOST_QVM_INLINE_TRIVIAL 45 | # define BOOST_QVM_INLINE_TRIVIAL BOOST_QVM_FORCEINLINE 46 | #endif 47 | 48 | #ifndef BOOST_QVM_INLINE_CRITICAL 49 | # define BOOST_QVM_INLINE_CRITICAL BOOST_QVM_FORCEINLINE 50 | #endif 51 | 52 | #ifndef BOOST_QVM_INLINE_OPERATIONS 53 | # define BOOST_QVM_INLINE_OPERATIONS BOOST_QVM_INLINE 54 | #endif 55 | 56 | #ifndef BOOST_QVM_INLINE_RECURSION 57 | # define BOOST_QVM_INLINE_RECURSION BOOST_QVM_INLINE_OPERATIONS 58 | #endif 59 | 60 | #ifndef BOOST_QVM_CONSTEXPR 61 | # if __cplusplus >= 201703L 62 | # define BOOST_QVM_CONSTEXPR constexpr 63 | # else 64 | # define BOOST_QVM_CONSTEXPR 65 | # endif 66 | #endif 67 | 68 | #endif 69 | -------------------------------------------------------------------------------- /include/boost/qvm/detail/cofactor_impl.hpp: -------------------------------------------------------------------------------- 1 | #ifndef BOOST_QVM_DETAIL_COFACTOR_IMPL_HPP_INCLUDED 2 | #define BOOST_QVM_DETAIL_COFACTOR_IMPL_HPP_INCLUDED 3 | 4 | // Copyright 2008-2024 Emil Dotchevski and Reverge Studios, Inc. 5 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 6 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 7 | 8 | #include 9 | #include 10 | #include 11 | 12 | namespace boost { namespace qvm { 13 | 14 | namespace 15 | qvm_detail 16 | { 17 | template 18 | BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_OPERATIONS 19 | typename deduce_mat::type 20 | cofactor_impl( A const & a ) 21 | { 22 | BOOST_QVM_STATIC_ASSERT(mat_traits::rows==mat_traits::cols); 23 | int const N=mat_traits::rows; 24 | typedef typename mat_traits::scalar_type T; 25 | T c[N-1][N-1]; 26 | typedef typename deduce_mat::type R; 27 | R b; 28 | for( int j=0; j!=N; ++j ) 29 | { 30 | for( int i=0; i!=N; ++i ) 31 | { 32 | int i1=0; 33 | for( int ii=0; ii!=N; ++ii ) 34 | { 35 | if( ii==i ) 36 | continue; 37 | int j1=0; 38 | for( int jj=0; jj!=N; ++jj ) 39 | { 40 | if( jj==j ) 41 | continue; 42 | c[i1][j1] = mat_traits::read_element_idx(ii,jj,a); 43 | ++j1; 44 | } 45 | ++i1; 46 | } 47 | T det = determinant_impl(c); 48 | if( (i+j)&1 ) 49 | det=-det; 50 | write_mat_element_idx(i,j,b,det); 51 | } 52 | } 53 | return b; 54 | } 55 | } 56 | 57 | } } 58 | 59 | #endif 60 | -------------------------------------------------------------------------------- /include/boost/qvm/detail/quat_assign.hpp: -------------------------------------------------------------------------------- 1 | #ifndef BOOST_QVM_DETAIL_QUAT_ASSIGN_HPP_INCLUDED 2 | #define BOOST_QVM_DETAIL_QUAT_ASSIGN_HPP_INCLUDED 3 | 4 | // Copyright 2008-2024 Emil Dotchevski and Reverge Studios, Inc. 5 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 6 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 7 | 8 | #include 9 | #include 10 | #include 11 | 12 | namespace boost { namespace qvm { 13 | 14 | template 15 | BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_OPERATIONS 16 | typename enable_if_c< 17 | is_quat::value && is_quat::value, 18 | A &>::type 19 | assign( A & a, B const & b ) 20 | { 21 | write_quat_element<0>(a,quat_traits::template read_element<0>(b)); 22 | write_quat_element<1>(a,quat_traits::template read_element<1>(b)); 23 | write_quat_element<2>(a,quat_traits::template read_element<2>(b)); 24 | write_quat_element<3>(a,quat_traits::template read_element<3>(b)); 25 | return a; 26 | } 27 | 28 | } } 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /include/boost/qvm/detail/remove_const.hpp: -------------------------------------------------------------------------------- 1 | #ifndef BOOST_QVM_DETAIL_REMOVE_CONST_HPP_INCLUDED 2 | #define BOOST_QVM_DETAIL_REMOVE_CONST_HPP_INCLUDED 3 | 4 | // Copyright 2008-2024 Emil Dotchevski and Reverge Studios, Inc. 5 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 6 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 7 | 8 | namespace boost { namespace qvm { 9 | 10 | namespace 11 | qvm_detail 12 | { 13 | template 14 | struct 15 | remove_const 16 | { 17 | typedef T type; 18 | }; 19 | 20 | template 21 | struct 22 | remove_const 23 | { 24 | typedef T type; 25 | }; 26 | } 27 | 28 | } } 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /include/boost/qvm/detail/vec_assign.hpp: -------------------------------------------------------------------------------- 1 | #ifndef BOOST_QVM_DETAIL_VEC_ASSIGN_HPP_INCLUDED 2 | #define BOOST_QVM_DETAIL_VEC_ASSIGN_HPP_INCLUDED 3 | 4 | // Copyright 2008-2024 Emil Dotchevski and Reverge Studios, Inc. 5 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 6 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 7 | 8 | #include 9 | #include 10 | #include 11 | 12 | namespace boost { namespace qvm { 13 | 14 | namespace 15 | qvm_detail 16 | { 17 | template 18 | struct 19 | assign_vv_defined 20 | { 21 | static bool const value=false; 22 | }; 23 | 24 | template 25 | struct 26 | copy_vector_elements 27 | { 28 | template 29 | static 30 | BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_CRITICAL 31 | typename enable_if_c< 32 | vec_write_element_ref::value, 33 | void>::type 34 | f( A & a, B const & b ) 35 | { 36 | vec_traits::template write_element(a) = vec_traits::template read_element(b); 37 | copy_vector_elements::f(a,b); 38 | } 39 | 40 | template 41 | static 42 | BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_CRITICAL 43 | typename enable_if_c< 44 | !vec_write_element_ref::value, 45 | void>::type 46 | f( A & a, B const & b ) 47 | { 48 | vec_traits::template write_element(a, vec_traits::template read_element(b)); 49 | copy_vector_elements::f(a,b); 50 | } 51 | }; 52 | 53 | template 54 | struct 55 | copy_vector_elements 56 | { 57 | template 58 | static 59 | void 60 | f( A &, B const & ) 61 | { 62 | } 63 | }; 64 | } 65 | 66 | template 67 | inline 68 | typename enable_if_c< 69 | is_vec::value && is_vec::value && 70 | vec_traits::dim==vec_traits::dim && 71 | !qvm_detail::assign_vv_defined::dim>::value, 72 | A &>::type 73 | assign( A & a, B const & b ) 74 | { 75 | qvm_detail::copy_vector_elements<0,vec_traits::dim>::f(a,b); 76 | return a; 77 | } 78 | 79 | } } 80 | 81 | #endif 82 | -------------------------------------------------------------------------------- /include/boost/qvm/error.hpp: -------------------------------------------------------------------------------- 1 | #ifndef BOOST_QVM_ERROR_HPP_INCLUDED 2 | #define BOOST_QVM_ERROR_HPP_INCLUDED 3 | 4 | // Copyright 2008-2024 Emil Dotchevski and Reverge Studios, Inc. 5 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 6 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 7 | 8 | #include 9 | 10 | namespace boost { namespace qvm { 11 | 12 | struct 13 | error: 14 | std::exception 15 | { 16 | char const * 17 | what() const throw() 18 | { 19 | return "Boost QVM error"; 20 | } 21 | 22 | ~error() throw() 23 | { 24 | } 25 | }; 26 | 27 | struct zero_determinant_error: error { }; 28 | struct zero_magnitude_error: error { }; 29 | 30 | } } 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /include/boost/qvm/gen/vec_assign2.hpp: -------------------------------------------------------------------------------- 1 | #ifndef BOOST_QVM_GEN_VEC_ASSIGN2_HPP_INCLUDED 2 | #define BOOST_QVM_GEN_VEC_ASSIGN2_HPP_INCLUDED 3 | 4 | // Copyright 2008-2024 Emil Dotchevski and Reverge Studios, Inc. 5 | // This file was generated by a program. Do not edit manually. 6 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 7 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 8 | 9 | #include 10 | #include 11 | #include 12 | 13 | namespace boost { namespace qvm { 14 | 15 | template 16 | BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_OPERATIONS 17 | typename enable_if_c< 18 | vec_traits::dim==2 && vec_traits::dim==2, 19 | A &>::type 20 | assign( A & a, B const & b ) 21 | { 22 | write_vec_element<0>(a,vec_traits::template read_element<0>(b)); 23 | write_vec_element<1>(a,vec_traits::template read_element<1>(b)); 24 | return a; 25 | } 26 | 27 | namespace 28 | sfinae 29 | { 30 | using ::boost::qvm::assign; 31 | } 32 | 33 | namespace 34 | qvm_detail 35 | { 36 | template 37 | struct assign_vv_defined; 38 | 39 | template <> 40 | struct 41 | assign_vv_defined<2> 42 | { 43 | static bool const value=true; 44 | }; 45 | } 46 | 47 | } } 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /include/boost/qvm/gen/vec_assign3.hpp: -------------------------------------------------------------------------------- 1 | #ifndef BOOST_QVM_GEN_VEC_ASSIGN3_HPP_INCLUDED 2 | #define BOOST_QVM_GEN_VEC_ASSIGN3_HPP_INCLUDED 3 | 4 | // Copyright 2008-2024 Emil Dotchevski and Reverge Studios, Inc. 5 | // This file was generated by a program. Do not edit manually. 6 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 7 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 8 | 9 | #include 10 | #include 11 | #include 12 | 13 | namespace boost { namespace qvm { 14 | 15 | template 16 | BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_OPERATIONS 17 | typename enable_if_c< 18 | vec_traits::dim==3 && vec_traits::dim==3, 19 | A &>::type 20 | assign( A & a, B const & b ) 21 | { 22 | write_vec_element<0>(a,vec_traits::template read_element<0>(b)); 23 | write_vec_element<1>(a,vec_traits::template read_element<1>(b)); 24 | write_vec_element<2>(a,vec_traits::template read_element<2>(b)); 25 | return a; 26 | } 27 | 28 | namespace 29 | sfinae 30 | { 31 | using ::boost::qvm::assign; 32 | } 33 | 34 | namespace 35 | qvm_detail 36 | { 37 | template 38 | struct assign_vv_defined; 39 | 40 | template <> 41 | struct 42 | assign_vv_defined<3> 43 | { 44 | static bool const value=true; 45 | }; 46 | } 47 | 48 | } } 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /include/boost/qvm/gen/vec_assign4.hpp: -------------------------------------------------------------------------------- 1 | #ifndef BOOST_QVM_GEN_VEC_ASSIGN4_HPP_INCLUDED 2 | #define BOOST_QVM_GEN_VEC_ASSIGN4_HPP_INCLUDED 3 | 4 | // Copyright 2008-2024 Emil Dotchevski and Reverge Studios, Inc. 5 | // This file was generated by a program. Do not edit manually. 6 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 7 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 8 | 9 | #include 10 | #include 11 | #include 12 | 13 | namespace boost { namespace qvm { 14 | 15 | template 16 | BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_OPERATIONS 17 | typename enable_if_c< 18 | vec_traits::dim==4 && vec_traits::dim==4, 19 | A &>::type 20 | assign( A & a, B const & b ) 21 | { 22 | write_vec_element<0>(a,vec_traits::template read_element<0>(b)); 23 | write_vec_element<1>(a,vec_traits::template read_element<1>(b)); 24 | write_vec_element<2>(a,vec_traits::template read_element<2>(b)); 25 | write_vec_element<3>(a,vec_traits::template read_element<3>(b)); 26 | return a; 27 | } 28 | 29 | namespace 30 | sfinae 31 | { 32 | using ::boost::qvm::assign; 33 | } 34 | 35 | namespace 36 | qvm_detail 37 | { 38 | template 39 | struct assign_vv_defined; 40 | 41 | template <> 42 | struct 43 | assign_vv_defined<4> 44 | { 45 | static bool const value=true; 46 | }; 47 | } 48 | 49 | } } 50 | 51 | #endif 52 | -------------------------------------------------------------------------------- /include/boost/qvm/is_scalar.hpp: -------------------------------------------------------------------------------- 1 | #ifndef BOOST_QVM_IS_SCALAR_HPP_INCLUDED 2 | #define BOOST_QVM_IS_SCALAR_HPP_INCLUDED 3 | 4 | // Copyright 2008-2024 Emil Dotchevski and Reverge Studios, Inc. 5 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 6 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 7 | 8 | namespace boost { namespace qvm { 9 | 10 | template 11 | struct 12 | is_scalar 13 | { 14 | static bool const value=false; 15 | }; 16 | template 17 | struct 18 | is_scalar: 19 | is_scalar 20 | { 21 | }; 22 | template <> struct is_scalar { static bool const value=true; }; 23 | template <> struct is_scalar { static bool const value=true; }; 24 | template <> struct is_scalar { static bool const value=true; }; 25 | template <> struct is_scalar { static bool const value=true; }; 26 | template <> struct is_scalar { static bool const value=true; }; 27 | template <> struct is_scalar { static bool const value=true; }; 28 | template <> struct is_scalar { static bool const value=true; }; 29 | template <> struct is_scalar { static bool const value=true; }; 30 | template <> struct is_scalar { static bool const value=true; }; 31 | template <> struct is_scalar { static bool const value=true; }; 32 | template <> struct is_scalar { static bool const value=true; }; 33 | template <> struct is_scalar { static bool const value=true; }; 34 | template <> struct is_scalar { static bool const value=true; }; 35 | } } 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /include/boost/qvm/lite.hpp: -------------------------------------------------------------------------------- 1 | // Copyright 2008-2024 Emil Dotchevski and Reverge Studios, Inc. 2 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 3 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | -------------------------------------------------------------------------------- /include/boost/qvm/map.hpp: -------------------------------------------------------------------------------- 1 | #ifndef BOOST_QVM_MAP_HPP_INCLUDED 2 | #define BOOST_QVM_MAP_HPP_INCLUDED 3 | 4 | // Copyright 2008-2024 Emil Dotchevski and Reverge Studios, Inc. 5 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 6 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 7 | 8 | #include 9 | #include 10 | #include 11 | 12 | #endif 13 | -------------------------------------------------------------------------------- /include/boost/qvm/mat_operations2.hpp: -------------------------------------------------------------------------------- 1 | // Copyright 2008-2024 Emil Dotchevski and Reverge Studios, Inc. 2 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 3 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | #include 6 | -------------------------------------------------------------------------------- /include/boost/qvm/mat_operations3.hpp: -------------------------------------------------------------------------------- 1 | // Copyright 2008-2024 Emil Dotchevski and Reverge Studios, Inc. 2 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 3 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | #include 6 | -------------------------------------------------------------------------------- /include/boost/qvm/mat_operations4.hpp: -------------------------------------------------------------------------------- 1 | // Copyright 2008-2024 Emil Dotchevski and Reverge Studios, Inc. 2 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 3 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | #include 6 | -------------------------------------------------------------------------------- /include/boost/qvm/operations.hpp: -------------------------------------------------------------------------------- 1 | #ifndef BOOST_QVM_OPERATIONS_HPP_INCLUDED 2 | #define BOOST_QVM_OPERATIONS_HPP_INCLUDED 3 | 4 | // Copyright 2008-2024 Emil Dotchevski and Reverge Studios, Inc. 5 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 6 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | #endif 15 | -------------------------------------------------------------------------------- /include/boost/qvm/quat.hpp: -------------------------------------------------------------------------------- 1 | #ifndef BOOST_QVM_QUAT_HPP_INCLUDED 2 | #define BOOST_QVM_QUAT_HPP_INCLUDED 3 | 4 | // Copyright 2008-2024 Emil Dotchevski and Reverge Studios, Inc. 5 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 6 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 7 | 8 | #include 9 | #include 10 | #include 11 | 12 | namespace boost { namespace qvm { 13 | 14 | template 15 | struct 16 | quat 17 | { 18 | T a[4]; 19 | template = 201103L 21 | , class = typename enable_if >::type 22 | #endif 23 | > 24 | operator R() const 25 | { 26 | R r; 27 | assign(r,*this); 28 | return r; 29 | } 30 | }; 31 | 32 | template 33 | struct quat_traits; 34 | 35 | template 36 | struct 37 | quat_traits< quat > 38 | { 39 | typedef quat this_quaternion; 40 | typedef T scalar_type; 41 | 42 | template 43 | static 44 | BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_CRITICAL 45 | scalar_type 46 | read_element( this_quaternion const & x ) 47 | { 48 | BOOST_QVM_STATIC_ASSERT(I>=0); 49 | BOOST_QVM_STATIC_ASSERT(I<4); 50 | return x.a[I]; 51 | } 52 | 53 | template 54 | static 55 | BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_CRITICAL 56 | scalar_type & 57 | write_element( this_quaternion & x ) 58 | { 59 | BOOST_QVM_STATIC_ASSERT(I>=0); 60 | BOOST_QVM_STATIC_ASSERT(I<4); 61 | return x.a[I]; 62 | } 63 | }; 64 | 65 | } } 66 | 67 | #endif 68 | -------------------------------------------------------------------------------- /include/boost/qvm/quat_traits_defaults.hpp: -------------------------------------------------------------------------------- 1 | #ifndef BOOST_QVM_QUAT_TRAITS_DEFAULTS_HPP_INCLUDED 2 | #define BOOST_QVM_QUAT_TRAITS_DEFAULTS_HPP_INCLUDED 3 | 4 | // Copyright 2008-2024 Emil Dotchevski and Reverge Studios, Inc. 5 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 6 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 7 | 8 | #include 9 | #include 10 | 11 | namespace boost { namespace qvm { 12 | 13 | template 14 | struct quat_traits; 15 | 16 | template 17 | struct 18 | quat_traits_defaults 19 | { 20 | typedef QuatType quat_type; 21 | typedef ScalarType scalar_type; 22 | 23 | template 24 | static 25 | BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_CRITICAL 26 | scalar_type 27 | read_element( quat_type const & x ) 28 | { 29 | return quat_traits::template write_element(const_cast(x)); 30 | } 31 | }; 32 | 33 | } } 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /include/boost/qvm/quat_vec_operations.hpp: -------------------------------------------------------------------------------- 1 | #ifndef BOOST_QVM_QUAT_VEC_OPERATIONS_HPP_INCLUDED 2 | #define BOOST_QVM_QUAT_VEC_OPERATIONS_HPP_INCLUDED 3 | 4 | // Copyright 2008-2024 Emil Dotchevski and Reverge Studios, Inc. 5 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 6 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | namespace boost { namespace qvm { 14 | 15 | template 16 | BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_OPERATIONS 17 | typename lazy_enable_if_c< 18 | is_quat::value && 19 | is_vec::value && vec_traits::dim==3, 20 | deduce_vec2 >::type 21 | operator*( A const & a, B const & b ) 22 | { 23 | typedef typename deduce_vec2::type R; 24 | typedef typename quat_traits::scalar_type TA; 25 | typedef typename vec_traits::scalar_type TB; 26 | TA const aa = quat_traits::template read_element<0>(a); 27 | TA const ab = quat_traits::template read_element<1>(a); 28 | TA const ac = quat_traits::template read_element<2>(a); 29 | TA const ad = quat_traits::template read_element<3>(a); 30 | TA const t2 = aa*ab; 31 | TA const t3 = aa*ac; 32 | TA const t4 = aa*ad; 33 | TA const t5 = -ab*ab; 34 | TA const t6 = ab*ac; 35 | TA const t7 = ab*ad; 36 | TA const t8 = -ac*ac; 37 | TA const t9 = ac*ad; 38 | TA const t10 = -ad*ad; 39 | TB const bx = vec_traits::template read_element<0>(b); 40 | TB const by = vec_traits::template read_element<1>(b); 41 | TB const bz = vec_traits::template read_element<2>(b); 42 | R r; 43 | write_vec_element<0>(r, 2*((t8+t10)*bx + (t6-t4)*by + (t3+t7)*bz) + bx); 44 | write_vec_element<1>(r, 2*((t4+t6)*bx + (t5+t10)*by + (t9-t2)*bz) + by); 45 | write_vec_element<2>(r, 2*((t7-t3)*bx + (t2+t9)*by + (t5+t8)*bz) + bz); 46 | return r; 47 | } 48 | 49 | namespace 50 | sfinae 51 | { 52 | using ::boost::qvm::operator*; 53 | } 54 | 55 | } } 56 | 57 | #endif 58 | -------------------------------------------------------------------------------- /include/boost/qvm/scalar_traits.hpp: -------------------------------------------------------------------------------- 1 | #ifndef BOOST_QVM_SCALAR_TRAITS_HPP_INCLUDED 2 | #define BOOST_QVM_SCALAR_TRAITS_HPP_INCLUDED 3 | 4 | // Copyright 2008-2024 Emil Dotchevski and Reverge Studios, Inc. 5 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 6 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | namespace boost { namespace qvm { 14 | 15 | template 16 | struct 17 | scalar_traits 18 | { 19 | static 20 | BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_CRITICAL 21 | Scalar 22 | value( int v ) 23 | { 24 | return Scalar(v); 25 | } 26 | }; 27 | 28 | namespace 29 | qvm_detail 30 | { 31 | template ::value, 33 | bool IsV=is_vec::value, 34 | bool IsM=is_mat::value, 35 | bool IsS=is_scalar::value> 36 | struct 37 | scalar_impl 38 | { 39 | typedef void type; 40 | }; 41 | 42 | template 43 | struct 44 | scalar_impl 45 | { 46 | typedef A type; 47 | }; 48 | 49 | template 50 | struct 51 | scalar_impl 52 | { 53 | typedef typename mat_traits::scalar_type type; 54 | }; 55 | 56 | template 57 | struct 58 | scalar_impl 59 | { 60 | typedef typename vec_traits::scalar_type type; 61 | }; 62 | 63 | template 64 | struct 65 | scalar_impl 66 | { 67 | typedef typename quat_traits::scalar_type type; 68 | }; 69 | } 70 | 71 | template 72 | struct 73 | scalar 74 | { 75 | typedef typename qvm_detail::scalar_impl::type type; 76 | }; 77 | 78 | } } 79 | 80 | #endif 81 | -------------------------------------------------------------------------------- /include/boost/qvm/static_assert.hpp: -------------------------------------------------------------------------------- 1 | // Copyright 2008-2024 Emil Dotchevski and Reverge Studios, Inc. 2 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 3 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | #ifndef BOOST_QVM_STATIC_ASSERT 6 | 7 | # if __cplusplus >= 201103L 8 | 9 | # include 10 | # define BOOST_QVM_STATIC_ASSERT(condition) static_assert(condition, "Boost QVM static assertion failure") 11 | 12 | # else 13 | 14 | # ifdef __GNUC__ 15 | # define BOOST_QVM_ATTRIBUTE_UNUSED __attribute__((unused)) 16 | # else 17 | # define BOOST_QVM_ATTRIBUTE_UNUSED 18 | # endif 19 | 20 | # define BOOST_QVM_TOKEN_PASTE(x, y) x ## y 21 | # define BOOST_QVM_TOKEN_PASTE2(x, y) BOOST_QVM_TOKEN_PASTE(x, y) 22 | # define BOOST_QVM_STATIC_ASSERT(condition) typedef char BOOST_QVM_TOKEN_PASTE2(boost_qvm_static_assert_failure_,__LINE__)[(condition)?1:-1] BOOST_QVM_ATTRIBUTE_UNUSED 23 | 24 | # endif 25 | 26 | #endif 27 | -------------------------------------------------------------------------------- /include/boost/qvm/swizzle.hpp: -------------------------------------------------------------------------------- 1 | #ifndef BOOST_QVM_SWIZZLE_HPP_INCLUDED 2 | #define BOOST_QVM_SWIZZLE_HPP_INCLUDED 3 | 4 | // Copyright 2008-2024 Emil Dotchevski and Reverge Studios, Inc. 5 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 6 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 7 | 8 | #include 9 | #include 10 | #include 11 | 12 | #endif 13 | -------------------------------------------------------------------------------- /include/boost/qvm/swizzle2.hpp: -------------------------------------------------------------------------------- 1 | // Copyright 2008-2024 Emil Dotchevski and Reverge Studios, Inc. 2 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 3 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | #include 6 | -------------------------------------------------------------------------------- /include/boost/qvm/swizzle3.hpp: -------------------------------------------------------------------------------- 1 | // Copyright 2008-2024 Emil Dotchevski and Reverge Studios, Inc. 2 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 3 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | #include 6 | -------------------------------------------------------------------------------- /include/boost/qvm/swizzle4.hpp: -------------------------------------------------------------------------------- 1 | // Copyright 2008-2024 Emil Dotchevski and Reverge Studios, Inc. 2 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 3 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | #include 6 | -------------------------------------------------------------------------------- /include/boost/qvm/to_string.hpp: -------------------------------------------------------------------------------- 1 | #ifndef BOOST_QVM_TO_STRING_HPP_INCLUDED 2 | #define BOOST_QVM_TO_STRING_HPP_INCLUDED 3 | 4 | // Copyright 2008-2024 Emil Dotchevski and Reverge Studios, Inc. 5 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 6 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 7 | 8 | #include 9 | 10 | #if __cplusplus >= 201103L 11 | 12 | namespace boost { namespace qvm { 13 | 14 | namespace 15 | qvm_to_string_detail 16 | { 17 | using std::to_string; 18 | } 19 | 20 | } } 21 | 22 | #else 23 | 24 | #include 25 | 26 | namespace boost { namespace qvm { 27 | 28 | namespace 29 | qvm_to_string_detail 30 | { 31 | template 32 | std::string 33 | to_string( T const & x ) 34 | { 35 | std::stringstream s; 36 | s << x; 37 | return s.str(); 38 | } 39 | } 40 | 41 | } } 42 | 43 | #endif 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /include/boost/qvm/vec.hpp: -------------------------------------------------------------------------------- 1 | #ifndef BOOST_QVM_VEC_HPP_INCLUDED 2 | #define BOOST_QVM_VEC_HPP_INCLUDED 3 | 4 | // Copyright 2008-2024 Emil Dotchevski and Reverge Studios, Inc. 5 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 6 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 7 | 8 | #include 9 | #include 10 | #include 11 | 12 | namespace boost { namespace qvm { 13 | 14 | template 15 | struct 16 | vec 17 | { 18 | T a[D]; 19 | template = 201103L 21 | , class = typename enable_if >::type 22 | #endif 23 | > 24 | operator R() const 25 | { 26 | R r; 27 | assign(r,*this); 28 | return r; 29 | } 30 | }; 31 | 32 | template 33 | struct vec_traits; 34 | 35 | template 36 | struct 37 | vec_traits< vec > 38 | { 39 | typedef vec this_vector; 40 | typedef T scalar_type; 41 | static int const dim=Dim; 42 | 43 | template 44 | static 45 | BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_CRITICAL 46 | scalar_type 47 | read_element( this_vector const & x ) 48 | { 49 | BOOST_QVM_STATIC_ASSERT(I>=0); 50 | BOOST_QVM_STATIC_ASSERT(I 55 | static 56 | BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_CRITICAL 57 | scalar_type & 58 | write_element( this_vector & x ) 59 | { 60 | BOOST_QVM_STATIC_ASSERT(I>=0); 61 | BOOST_QVM_STATIC_ASSERT(I=0); 71 | BOOST_QVM_ASSERT(i=0); 81 | BOOST_QVM_ASSERT(i 6 | -------------------------------------------------------------------------------- /include/boost/qvm/vec_mat_operations3.hpp: -------------------------------------------------------------------------------- 1 | // Copyright 2008-2024 Emil Dotchevski and Reverge Studios, Inc. 2 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 3 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | #include 6 | -------------------------------------------------------------------------------- /include/boost/qvm/vec_mat_operations4.hpp: -------------------------------------------------------------------------------- 1 | // Copyright 2008-2024 Emil Dotchevski and Reverge Studios, Inc. 2 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 3 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | #include 6 | -------------------------------------------------------------------------------- /include/boost/qvm/vec_operations2.hpp: -------------------------------------------------------------------------------- 1 | // Copyright 2008-2024 Emil Dotchevski and Reverge Studios, Inc. 2 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 3 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | #include 6 | -------------------------------------------------------------------------------- /include/boost/qvm/vec_operations3.hpp: -------------------------------------------------------------------------------- 1 | // Copyright 2008-2024 Emil Dotchevski and Reverge Studios, Inc. 2 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 3 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | #include 6 | -------------------------------------------------------------------------------- /include/boost/qvm/vec_operations4.hpp: -------------------------------------------------------------------------------- 1 | // Copyright 2008-2024 Emil Dotchevski and Reverge Studios, Inc. 2 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 3 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | #include 6 | -------------------------------------------------------------------------------- /include/boost/qvm/vec_register.hpp: -------------------------------------------------------------------------------- 1 | #ifndef BOOST_QVM_VEC_REGISTER_HPP_INCLUDED 2 | #define BOOST_QVM_VEC_REGISTER_HPP_INCLUDED 3 | 4 | // Copyright 2008-2024 Emil Dotchevski and Reverge Studios, Inc. 5 | // Copyright 2018 agate-pris 6 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 7 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 8 | 9 | #include 10 | #include 11 | #include 12 | 13 | #endif 14 | -------------------------------------------------------------------------------- /include/boost/qvm/vec_register2.hpp: -------------------------------------------------------------------------------- 1 | #ifndef BOOST_QVM_VEC_REGISTER2_HPP 2 | #define BOOST_QVM_VEC_REGISTER2_HPP 3 | 4 | // Copyright 2008-2024 Emil Dotchevski and Reverge Studios, Inc. 5 | // Copyright 2018 agate-pris 6 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 7 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 8 | 9 | #include 10 | 11 | #define BOOST_QVM_REGISTER_VEC_2_READ(VecType, ScalarType, Read0, Read1) \ 12 | BOOST_QVM_DETAIL_REGISTER_VEC_SPECIALIZE_VEC_TRAITS_READ(VecType, ScalarType, 2) \ 13 | BOOST_QVM_DETAIL_SPECIALIZE_QVM_DETAIL_VEC_REGISTER_READ(VecType, ScalarType, 2, 0, Read0) \ 14 | BOOST_QVM_DETAIL_SPECIALIZE_QVM_DETAIL_VEC_REGISTER_READ(VecType, ScalarType, 2, 1, Read1) 15 | 16 | #define BOOST_QVM_REGISTER_VEC_2_READ_WRITE(VecType, ScalarType, Read0, Read1, Write0, Write1) \ 17 | BOOST_QVM_DETAIL_REGISTER_VEC_SPECIALIZE_VEC_TRAITS_READ_WRITE(VecType, ScalarType, 2) \ 18 | BOOST_QVM_DETAIL_SPECIALIZE_QVM_DETAIL_VEC_REGISTER_READ_WRITE(VecType, ScalarType, 2, 0, Read0, Write0)\ 19 | BOOST_QVM_DETAIL_SPECIALIZE_QVM_DETAIL_VEC_REGISTER_READ_WRITE(VecType, ScalarType, 2, 1, Read1, Write1) 20 | 21 | #define BOOST_QVM_REGISTER_VEC_2(VecType, ScalarType, Element0, Element1) \ 22 | BOOST_QVM_REGISTER_VEC_2_READ_WRITE(VecType, ScalarType, Element0, Element1, Element0, Element1) 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /include/boost/qvm/vec_register3.hpp: -------------------------------------------------------------------------------- 1 | #ifndef BOOST_QVM_VEC_REGISTER3_HPP 2 | #define BOOST_QVM_VEC_REGISTER3_HPP 3 | 4 | // Copyright 2008-2024 Emil Dotchevski and Reverge Studios, Inc. 5 | // Copyright 2018 agate-pris 6 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 7 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 8 | 9 | #include 10 | 11 | #define BOOST_QVM_REGISTER_VEC_3_READ(VecType, ScalarType, Read0, Read1, Read2) \ 12 | BOOST_QVM_DETAIL_REGISTER_VEC_SPECIALIZE_VEC_TRAITS_READ(VecType, ScalarType, 3) \ 13 | BOOST_QVM_DETAIL_SPECIALIZE_QVM_DETAIL_VEC_REGISTER_READ(VecType, ScalarType, 3, 0, Read0) \ 14 | BOOST_QVM_DETAIL_SPECIALIZE_QVM_DETAIL_VEC_REGISTER_READ(VecType, ScalarType, 3, 1, Read1) \ 15 | BOOST_QVM_DETAIL_SPECIALIZE_QVM_DETAIL_VEC_REGISTER_READ(VecType, ScalarType, 3, 2, Read2) 16 | 17 | #define BOOST_QVM_REGISTER_VEC_3_READ_WRITE(VecType, ScalarType, Read0, Read1, Read2, Write0, Write1, Write2) \ 18 | BOOST_QVM_DETAIL_REGISTER_VEC_SPECIALIZE_VEC_TRAITS_READ_WRITE(VecType, ScalarType, 3) \ 19 | BOOST_QVM_DETAIL_SPECIALIZE_QVM_DETAIL_VEC_REGISTER_READ_WRITE(VecType, ScalarType, 3, 0, Read0, Write0) \ 20 | BOOST_QVM_DETAIL_SPECIALIZE_QVM_DETAIL_VEC_REGISTER_READ_WRITE(VecType, ScalarType, 3, 1, Read1, Write1) \ 21 | BOOST_QVM_DETAIL_SPECIALIZE_QVM_DETAIL_VEC_REGISTER_READ_WRITE(VecType, ScalarType, 3, 2, Read2, Write2) 22 | 23 | #define BOOST_QVM_REGISTER_VEC_3(VecType, ScalarType, Element0, Element1, Element2) \ 24 | BOOST_QVM_REGISTER_VEC_3_READ_WRITE(VecType, ScalarType, Element0, Element1, Element2, Element0, Element1, Element2) 25 | 26 | #endif 27 | -------------------------------------------------------------------------------- /include/boost/qvm/vec_register4.hpp: -------------------------------------------------------------------------------- 1 | #ifndef BOOST_QVM_VEC_REGISTER4_HPP 2 | #define BOOST_QVM_VEC_REGISTER4_HPP 3 | 4 | // Copyright 2008-2024 Emil Dotchevski and Reverge Studios, Inc. 5 | // Copyright 2018 agate-pris 6 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 7 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 8 | 9 | #include 10 | 11 | #define BOOST_QVM_REGISTER_VEC_4_READ(VecType, ScalarType, Read0, Read1, Read2, Read3) \ 12 | BOOST_QVM_DETAIL_REGISTER_VEC_SPECIALIZE_VEC_TRAITS_READ(VecType, ScalarType, 4) \ 13 | BOOST_QVM_DETAIL_SPECIALIZE_QVM_DETAIL_VEC_REGISTER_READ(VecType, ScalarType, 4, 0, Read0) \ 14 | BOOST_QVM_DETAIL_SPECIALIZE_QVM_DETAIL_VEC_REGISTER_READ(VecType, ScalarType, 4, 1, Read1) \ 15 | BOOST_QVM_DETAIL_SPECIALIZE_QVM_DETAIL_VEC_REGISTER_READ(VecType, ScalarType, 4, 2, Read2) \ 16 | BOOST_QVM_DETAIL_SPECIALIZE_QVM_DETAIL_VEC_REGISTER_READ(VecType, ScalarType, 4, 3, Read3) 17 | 18 | #define BOOST_QVM_REGISTER_VEC_4_READ_WRITE(VecType, ScalarType, Read0, Read1, Read2, Read3, Write0, Write1, Write2, Write3)\ 19 | BOOST_QVM_DETAIL_REGISTER_VEC_SPECIALIZE_VEC_TRAITS_READ_WRITE(VecType, ScalarType, 4) \ 20 | BOOST_QVM_DETAIL_SPECIALIZE_QVM_DETAIL_VEC_REGISTER_READ_WRITE(VecType, ScalarType, 4, 0, Read0, Write0) \ 21 | BOOST_QVM_DETAIL_SPECIALIZE_QVM_DETAIL_VEC_REGISTER_READ_WRITE(VecType, ScalarType, 4, 1, Read1, Write1) \ 22 | BOOST_QVM_DETAIL_SPECIALIZE_QVM_DETAIL_VEC_REGISTER_READ_WRITE(VecType, ScalarType, 4, 2, Read2, Write2) \ 23 | BOOST_QVM_DETAIL_SPECIALIZE_QVM_DETAIL_VEC_REGISTER_READ_WRITE(VecType, ScalarType, 4, 3, Read3, Write3) 24 | 25 | #define BOOST_QVM_REGISTER_VEC_4(VecType, ScalarType, Element0, Element1, Element2, Element3) \ 26 | BOOST_QVM_REGISTER_VEC_4_READ_WRITE(VecType, ScalarType, Element0, Element1, Element2, Element3, Element0, Element1, Element2, Element3) 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /include/boost/qvm_lite.hpp: -------------------------------------------------------------------------------- 1 | #ifndef BOOST_QVM_LITE_HPP_INCLUDED 2 | #define BOOST_QVM_LITE_HPP_INCLUDED 3 | 4 | // Copyright 2008-2024 Emil Dotchevski and Reverge Studios, Inc. 5 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 6 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 7 | 8 | #include 9 | 10 | #endif 11 | -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Automatic redirection 6 | 7 | 8 | Automatic redirection failed, please go to 9 | QVM
10 | 11 | 12 | -------------------------------------------------------------------------------- /meson_options.txt: -------------------------------------------------------------------------------- 1 | option('qvm_header_mode',type:'string',value:'multi',description:'Unit test header inclusion option: multi, single, single_lite') 2 | option('qvm_enable_unit_tests',type:'boolean',value:true,description:'Enable the building of unit test programs') 3 | -------------------------------------------------------------------------------- /meta/libraries.json: -------------------------------------------------------------------------------- 1 | { 2 | "key": "qvm", 3 | "name": "QVM", 4 | "authors": [ 5 | "Emil Dotchevski" 6 | ], 7 | "description": "Generic C++ library for working with Quaternions Vectors and Matrices.", 8 | "documentation": "index.html", 9 | "category": [ 10 | "Generic", 11 | "Math", 12 | "Algorithms" 13 | ], 14 | "maintainers": [ 15 | "Emil Dotchevski " 16 | ], 17 | "cxxstd": "03" 18 | } 19 | -------------------------------------------------------------------------------- /test/access_m_fail1.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2008-2024 Emil Dotchevski and Reverge Studios, Inc. 2 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 3 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | #include 6 | 7 | template struct my_mat { }; 8 | 9 | namespace 10 | boost 11 | { 12 | namespace 13 | qvm 14 | { 15 | template 16 | struct 17 | mat_traits< my_mat > 18 | { 19 | typedef int scalar_type; 20 | static int const rows=R; 21 | static int const cols=C; 22 | template static int read_element( my_mat const & ); 23 | template static int & write_element( my_mat & ); 24 | }; 25 | } 26 | } 27 | 28 | int 29 | main() 30 | { 31 | using namespace boost::qvm; 32 | my_mat<1,1> const m=my_mat<1,1>(); 33 | A11(m); 34 | return 1; 35 | } 36 | -------------------------------------------------------------------------------- /test/access_m_fail2.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2008-2024 Emil Dotchevski and Reverge Studios, Inc. 2 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 3 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | #include 6 | 7 | template struct my_mat { }; 8 | 9 | namespace 10 | boost 11 | { 12 | namespace 13 | qvm 14 | { 15 | template 16 | struct 17 | mat_traits< my_mat > 18 | { 19 | typedef int scalar_type; 20 | static int const rows=R; 21 | static int const cols=C; 22 | template static int read_element( my_mat const & ); 23 | template static int & write_element( my_mat & ); 24 | }; 25 | } 26 | } 27 | 28 | int 29 | main() 30 | { 31 | using namespace boost::qvm; 32 | my_mat<1,1> m; 33 | A11(m); 34 | return 1; 35 | } 36 | -------------------------------------------------------------------------------- /test/access_q_fail.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2008-2024 Emil Dotchevski and Reverge Studios, Inc. 2 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 3 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | #include 6 | #include 7 | 8 | struct my_quat { }; 9 | 10 | namespace 11 | boost 12 | { 13 | namespace 14 | qvm 15 | { 16 | template <> 17 | struct 18 | quat_traits 19 | { 20 | typedef int scalar_type; 21 | template static int read_element( my_quat const & ); 22 | template static int & write_element( my_quat & ); 23 | }; 24 | } 25 | } 26 | 27 | int 28 | main() 29 | { 30 | using namespace boost::qvm; 31 | my_quat const q=my_quat(); 32 | A<3>(V(q)); 33 | return 1; 34 | } 35 | -------------------------------------------------------------------------------- /test/access_q_test.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2008-2024 Emil Dotchevski and Reverge Studios, Inc. 2 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 3 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | #ifdef BOOST_QVM_TEST_SINGLE_HEADER 6 | # include BOOST_QVM_TEST_SINGLE_HEADER 7 | #else 8 | # include 9 | # include 10 | #endif 11 | 12 | #include "test_qvm_quaternion.hpp" 13 | 14 | int 15 | main() 16 | { 17 | using namespace boost::qvm; 18 | 19 | test_qvm::quaternion q; 20 | q.a[0]=42.0f; 21 | q.a[1]=43.0f; 22 | q.a[2]=44.0f; 23 | q.a[3]=45.0f; 24 | test_qvm::quaternion const & qq=q; 25 | 26 | BOOST_TEST_EQ(X(V(qq)),q.a[1]); 27 | BOOST_TEST_EQ(Y(V(qq)),q.a[2]); 28 | BOOST_TEST_EQ(Z(V(qq)),q.a[3]); 29 | BOOST_TEST(X(V(q))==q.a[1]); 30 | BOOST_TEST(Y(V(q))==q.a[2]); 31 | BOOST_TEST(Z(V(q))==q.a[3]); 32 | 33 | BOOST_TEST_EQ(S(qq),q.a[0]); 34 | BOOST_TEST_EQ(X(qq),q.a[1]); 35 | BOOST_TEST_EQ(Y(qq),q.a[2]); 36 | BOOST_TEST_EQ(Z(qq),q.a[3]); 37 | #ifdef BOOST_QVM_TEST_REF_WRITE_ELEMENT 38 | BOOST_TEST(&S(q)==&q.a[0]); 39 | BOOST_TEST(&X(q)==&q.a[1]); 40 | BOOST_TEST(&Y(q)==&q.a[2]); 41 | BOOST_TEST(&Z(q)==&q.a[3]); 42 | #else 43 | S(q)=45.0f; 44 | X(q)=44.0f; 45 | Y(q)=43.0f; 46 | Z(q)=42.0f; 47 | BOOST_TEST_EQ(q.a[0],45.0f); 48 | BOOST_TEST_EQ(q.a[1],44.0f); 49 | BOOST_TEST_EQ(q.a[2],43.0f); 50 | BOOST_TEST_EQ(q.a[3],42.0f); 51 | #endif 52 | 53 | return boost::report_errors(); 54 | } 55 | -------------------------------------------------------------------------------- /test/access_v_fail1.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2008-2024 Emil Dotchevski and Reverge Studios, Inc. 2 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 3 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | #include 6 | 7 | template struct my_vec { }; 8 | 9 | namespace 10 | boost 11 | { 12 | namespace 13 | qvm 14 | { 15 | template 16 | struct 17 | vec_traits< my_vec > 18 | { 19 | typedef int scalar_type; 20 | static int const dim=D; 21 | template static int read_element( my_vec const & ); 22 | template static int & write_element( my_vec & ); 23 | }; 24 | } 25 | } 26 | 27 | int 28 | main() 29 | { 30 | using namespace boost::qvm; 31 | my_vec<1> const v=my_vec<1>(); 32 | A1(v); 33 | return 1; 34 | } 35 | -------------------------------------------------------------------------------- /test/access_v_fail2.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2008-2024 Emil Dotchevski and Reverge Studios, Inc. 2 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 3 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | #include 6 | 7 | template struct my_vec { }; 8 | 9 | namespace 10 | boost 11 | { 12 | namespace 13 | qvm 14 | { 15 | template 16 | struct 17 | vec_traits< my_vec > 18 | { 19 | typedef int scalar_type; 20 | static int const dim=D; 21 | template static int read_element( my_vec const & ); 22 | template static int & write_element( my_vec & ); 23 | }; 24 | } 25 | } 26 | 27 | int 28 | main() 29 | { 30 | using namespace boost::qvm; 31 | my_vec<1> v; 32 | A1(v); 33 | return 1; 34 | } 35 | -------------------------------------------------------------------------------- /test/assign_test.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2008-2024 Emil Dotchevski and Reverge Studios, Inc. 2 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 3 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | #ifdef BOOST_QVM_TEST_SINGLE_HEADER 6 | # include BOOST_QVM_TEST_SINGLE_HEADER 7 | #else 8 | # include 9 | # include 10 | # include 11 | #endif 12 | 13 | #include "test_qvm_matrix.hpp" 14 | #include "test_qvm_quaternion.hpp" 15 | #include "test_qvm_vector.hpp" 16 | #include "gold.hpp" 17 | 18 | namespace 19 | { 20 | template 21 | void 22 | test_matrix() 23 | { 24 | using namespace boost::qvm::sfinae; 25 | test_qvm::matrix const x(42,1); 26 | test_qvm::matrix y(43,1); 27 | assign(y,x); 28 | BOOST_QVM_TEST_EQ(x.a,y.a); 29 | } 30 | 31 | template 32 | void 33 | test_vector() 34 | { 35 | using namespace boost::qvm::sfinae; 36 | test_qvm::vector const x(42,1); 37 | test_qvm::vector y(43,1); 38 | assign(y,x); 39 | BOOST_QVM_TEST_EQ(x.a,y.a); 40 | } 41 | 42 | void 43 | test_quaternion() 44 | { 45 | using namespace boost::qvm::sfinae; 46 | test_qvm::quaternion const x(42,1); 47 | test_qvm::quaternion y(43,1); 48 | assign(y,x); 49 | BOOST_QVM_TEST_EQ(x.a,y.a); 50 | } 51 | } 52 | 53 | int 54 | main() 55 | { 56 | test_matrix<1,2>(); 57 | test_matrix<2,1>(); 58 | test_matrix<2,2>(); 59 | test_matrix<1,3>(); 60 | test_matrix<3,1>(); 61 | test_matrix<3,3>(); 62 | test_matrix<1,4>(); 63 | test_matrix<4,1>(); 64 | test_matrix<4,4>(); 65 | test_matrix<1,5>(); 66 | test_matrix<5,1>(); 67 | test_matrix<5,5>(); 68 | test_vector<2>(); 69 | test_vector<3>(); 70 | test_vector<4>(); 71 | test_vector<5>(); 72 | test_quaternion(); 73 | return boost::report_errors(); 74 | } 75 | -------------------------------------------------------------------------------- /test/cmp_qq_test.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2008-2024 Emil Dotchevski and Reverge Studios, Inc. 2 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 3 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | #ifdef BOOST_QVM_TEST_SINGLE_HEADER 6 | # include BOOST_QVM_TEST_SINGLE_HEADER 7 | #else 8 | # include 9 | #endif 10 | 11 | #include "test_qvm_quaternion.hpp" 12 | #include "gold.hpp" 13 | #include 14 | 15 | namespace 16 | { 17 | void 18 | test() 19 | { 20 | using namespace boost::qvm::sfinae; 21 | test_qvm::quaternion const x(42,1); 22 | for( int i=0; i!=4; ++i ) 23 | { 24 | { 25 | test_qvm::quaternion y(x); 26 | BOOST_TEST(cmp(x,y,std::equal_to())); 27 | y.a[i]=0; 28 | BOOST_TEST(!cmp(x,y,std::equal_to())); 29 | } 30 | } 31 | } 32 | } 33 | 34 | int 35 | main() 36 | { 37 | test(); 38 | return boost::report_errors(); 39 | } 40 | -------------------------------------------------------------------------------- /test/col_mat_test.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2008-2024 Emil Dotchevski and Reverge Studios, Inc. 2 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 3 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | #ifdef BOOST_QVM_TEST_SINGLE_HEADER 6 | # include BOOST_QVM_TEST_SINGLE_HEADER 7 | #else 8 | # include 9 | # include 10 | # include 11 | # include 12 | #endif 13 | 14 | #include 15 | #include "test_qvm_vector.hpp" 16 | #include "gold.hpp" 17 | 18 | namespace 19 | { 20 | template 21 | void 22 | test() 23 | { 24 | using namespace boost::qvm; 25 | test_qvm::vector x(42,1); 26 | float y[1][Dim]; assign(y,transposed(col_mat(x))); 27 | BOOST_QVM_TEST_EQ(x.a,y[0]); 28 | test_qvm::scalar_multiply_v(x.b,x.a,2.0f); 29 | col<0>(col_mat(x)) *= 2; 30 | BOOST_QVM_TEST_EQ(x.a,x.b); 31 | col_mat(x)+col_mat(x); 32 | -col_mat(x); 33 | } 34 | } 35 | 36 | int 37 | main() 38 | { 39 | test<2>(); 40 | test<3>(); 41 | test<4>(); 42 | test<5>(); 43 | return boost::report_errors(); 44 | } 45 | -------------------------------------------------------------------------------- /test/conjugate_test.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2008-2024 Emil Dotchevski and Reverge Studios, Inc. 2 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 3 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | #ifdef BOOST_QVM_TEST_SINGLE_HEADER 6 | # include BOOST_QVM_TEST_SINGLE_HEADER 7 | #else 8 | # include 9 | # include 10 | #endif 11 | 12 | #include "test_qvm_quaternion.hpp" 13 | #include "gold.hpp" 14 | 15 | namespace 16 | { 17 | template struct same_type_tester; 18 | template struct same_type_tester { }; 19 | template void test_same_type( T, U ) { same_type_tester(); } 20 | 21 | void 22 | test() 23 | { 24 | using namespace boost::qvm::sfinae; 25 | test_qvm::quaternion const x(42,1); 26 | test_qvm::scalar_multiply_v(x.b,x.a,-1.0f); 27 | x.b[0]=-x.b[0]; 28 | test_same_type(x,conjugate(x)); 29 | { 30 | test_qvm::quaternion y=conjugate(x); 31 | BOOST_QVM_TEST_EQ(x.b,y.a); 32 | } 33 | { 34 | test_qvm::quaternion y=conjugate(qref(x)); 35 | BOOST_QVM_TEST_EQ(x.b,y.a); 36 | } 37 | } 38 | } 39 | 40 | int 41 | main() 42 | { 43 | test(); 44 | return boost::report_errors(); 45 | } 46 | -------------------------------------------------------------------------------- /test/cross_test.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2008-2024 Emil Dotchevski and Reverge Studios, Inc. 2 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 3 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | #ifdef BOOST_QVM_TEST_SINGLE_HEADER 6 | # include BOOST_QVM_TEST_SINGLE_HEADER 7 | #else 8 | # include 9 | # include 10 | # include 11 | # include 12 | # include 13 | #endif 14 | 15 | #include "test_qvm_vector.hpp" 16 | #include "test_qvm_matrix.hpp" 17 | #include "gold.hpp" 18 | 19 | namespace 20 | { 21 | template struct same_type_tester; 22 | template struct same_type_tester { }; 23 | template void test_same_type( T, U ) { same_type_tester(); } 24 | } 25 | 26 | int 27 | main() 28 | { 29 | using namespace boost::qvm; 30 | 31 | { 32 | test_qvm::vector x(42,1); 33 | test_qvm::vector y=x*2; 34 | test_qvm::matrix m; 35 | A00(m) = 0; 36 | A01(m) = -A2(x); 37 | A02(m) = A1(x); 38 | A10(m) = A2(x); 39 | A11(m) = 0; 40 | A12(m) = -A0(x); 41 | A20(m) = -A1(x); 42 | A21(m) = A0(x); 43 | A22(m) = 0; 44 | { 45 | test_same_type(x,cross(x,y)); 46 | test_qvm::vector c=cross(x,y); 47 | test_qvm::multiply_mv(c.b,m.a,y.a); 48 | BOOST_QVM_TEST_EQ(c.a,c.b); 49 | } 50 | { 51 | test_qvm::vector c=cross(vref(x),y); 52 | test_qvm::multiply_mv(c.b,m.a,y.a); 53 | BOOST_QVM_TEST_EQ(c.a,c.b); 54 | } 55 | { 56 | test_qvm::vector c=cross(x,vref(y)); 57 | test_qvm::multiply_mv(c.b,m.a,y.a); 58 | BOOST_QVM_TEST_EQ(c.a,c.b); 59 | } 60 | } 61 | 62 | { 63 | test_qvm::vector x(42,1); 64 | test_qvm::vector y(43,1); 65 | float r = cross(x,y); 66 | BOOST_QVM_TEST_EQ(r, x.a[0]*y.a[1] - x.a[1]*y.a[0]); 67 | } 68 | 69 | return boost::report_errors(); 70 | } 71 | -------------------------------------------------------------------------------- /test/deduce_quat_test.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2008-2024 Emil Dotchevski and Reverge Studios, Inc. 2 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 3 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | #ifdef BOOST_QVM_TEST_SINGLE_HEADER 6 | # include BOOST_QVM_TEST_SINGLE_HEADER 7 | #else 8 | # include 9 | #endif 10 | 11 | template 12 | struct same_type; 13 | 14 | template 15 | struct 16 | same_type 17 | { 18 | }; 19 | 20 | template 21 | struct 22 | check 23 | { 24 | same_type::type,Result> a; 25 | same_type::type,Result> b; 26 | }; 27 | 28 | template struct q1; 29 | template struct q2; 30 | 31 | namespace 32 | boost 33 | { 34 | namespace 35 | qvm 36 | { 37 | template 38 | struct 39 | quat_traits< q1 > 40 | { 41 | typedef T scalar_type; 42 | }; 43 | 44 | template 45 | struct 46 | quat_traits< q2 > 47 | { 48 | typedef T scalar_type; 49 | }; 50 | 51 | template 52 | struct 53 | deduce_quat,S> 54 | { 55 | typedef q2 type; 56 | }; 57 | 58 | template 59 | struct 60 | deduce_quat2,q2,S> 61 | { 62 | typedef q2 type; 63 | }; 64 | } 65 | } 66 | 67 | int 68 | main() 69 | { 70 | same_type< boost::qvm::deduce_quat< q1 >::type, q1 >(); 71 | check< q1, q1, q1 >(); 72 | 73 | same_type< boost::qvm::deduce_quat< q2 >::type, q2 >(); 74 | same_type< boost::qvm::deduce_quat< q2 >::type, q2 >(); 75 | check< q2, q2, q2 >(); 76 | check< q2, q2, q2 >(); 77 | } 78 | -------------------------------------------------------------------------------- /test/deduce_scalar_fail.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2008-2024 Emil Dotchevski and Reverge Studios, Inc. 2 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 3 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | #include 6 | 7 | template struct tester { }; 8 | template <> struct tester; 9 | 10 | int char_scalars_not_supported_use_signed_char_instead = sizeof(tester::type>); 11 | -------------------------------------------------------------------------------- /test/deduce_scalar_mq_test.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2008-2024 Emil Dotchevski and Reverge Studios, Inc. 2 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 3 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | #ifdef BOOST_QVM_TEST_SINGLE_HEADER 6 | # include BOOST_QVM_TEST_SINGLE_HEADER 7 | #else 8 | # include 9 | # include 10 | # include 11 | # include 12 | # include 13 | #endif 14 | 15 | #include 16 | 17 | template 18 | struct 19 | wrap 20 | { 21 | T t; 22 | wrap() { } 23 | wrap(T t):t(t) { } 24 | }; 25 | 26 | template 27 | wrap 28 | operator*(S s, wrap w) 29 | { 30 | return wrap(s * w.t); 31 | } 32 | 33 | template 34 | wrap operator+(wrap a, wrap b) 35 | { 36 | return wrap(a.t + b.t); 37 | } 38 | 39 | namespace 40 | boost 41 | { 42 | namespace 43 | qvm 44 | { 45 | template 46 | struct 47 | is_scalar > 48 | { 49 | static bool const value=true; 50 | }; 51 | template 52 | struct 53 | deduce_scalar > 54 | { 55 | typedef wrap::type> type; 56 | }; 57 | } 58 | } 59 | 60 | int 61 | main() 62 | { 63 | using namespace boost::qvm; 64 | quat q = rotz_quat(3.14159); 65 | vec, 3> v; 66 | v.a[0] = wrap(1.0); 67 | v.a[1] = wrap(0); 68 | v.a[2] = wrap(0); 69 | vec, 3> r = q * v; 70 | BOOST_TEST_LT(fabs(r.a[0].t+1), 0.0001); 71 | BOOST_TEST_LT(fabs(r.a[1].t), 0.0001); 72 | BOOST_TEST_LT(fabs(r.a[2].t), 0.0001); 73 | return boost::report_errors(); 74 | } 75 | -------------------------------------------------------------------------------- /test/deduce_scalar_mv_test.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2008-2024 Emil Dotchevski and Reverge Studios, Inc. 2 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 3 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | #ifdef BOOST_QVM_TEST_SINGLE_HEADER 6 | # include BOOST_QVM_TEST_SINGLE_HEADER 7 | #else 8 | # include 9 | # include 10 | # include 11 | # include 12 | # include 13 | #endif 14 | 15 | #include 16 | 17 | template 18 | struct 19 | wrap 20 | { 21 | T t; 22 | wrap() { } 23 | explicit wrap(T t):t(t) { } 24 | }; 25 | 26 | template 27 | wrap 28 | operator*(S s, wrap w) 29 | { 30 | return wrap(s * w.t); 31 | } 32 | 33 | template 34 | wrap operator+(wrap a, wrap b) 35 | { 36 | return wrap(a.t + b.t); 37 | } 38 | 39 | namespace 40 | boost 41 | { 42 | namespace 43 | qvm 44 | { 45 | template 46 | struct 47 | is_scalar > 48 | { 49 | static bool const value=true; 50 | }; 51 | template 52 | struct 53 | deduce_scalar > 54 | { 55 | typedef wrap::type> type; 56 | }; 57 | } 58 | } 59 | 60 | int 61 | main() 62 | { 63 | using namespace boost::qvm; 64 | mat m = rotz_mat<3>(3.14159); 65 | vec, 3> v; 66 | v.a[0] = wrap(1.0); 67 | v.a[1] = wrap(0); 68 | v.a[2] = wrap(0); 69 | vec, 3> r = m * v; 70 | BOOST_TEST_LT(fabs(r.a[0].t+1), 0.0001); 71 | BOOST_TEST_LT(fabs(r.a[1].t), 0.0001); 72 | BOOST_TEST_LT(fabs(r.a[2].t), 0.0001); 73 | return boost::report_errors(); 74 | } 75 | -------------------------------------------------------------------------------- /test/deduce_vec_test.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2008-2024 Emil Dotchevski and Reverge Studios, Inc. 2 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 3 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | #ifdef BOOST_QVM_TEST_SINGLE_HEADER 6 | # include BOOST_QVM_TEST_SINGLE_HEADER 7 | #else 8 | # include 9 | #endif 10 | 11 | template 12 | struct same_type; 13 | 14 | template 15 | struct 16 | same_type 17 | { 18 | }; 19 | 20 | template 21 | struct 22 | check 23 | { 24 | same_type::type,Result> a; 25 | same_type::type,Result> b; 26 | }; 27 | 28 | template struct v1; 29 | template struct v2; 30 | 31 | namespace 32 | boost 33 | { 34 | namespace 35 | qvm 36 | { 37 | template 38 | struct 39 | vec_traits< v1 > 40 | { 41 | typedef T scalar_type; 42 | static int const dim=D; 43 | }; 44 | 45 | template 46 | struct 47 | vec_traits< v2 > 48 | { 49 | typedef T scalar_type; 50 | static int const dim=D; 51 | }; 52 | 53 | template 54 | struct 55 | deduce_vec,D,S> 56 | { 57 | typedef v2 type; 58 | }; 59 | 60 | template 61 | struct 62 | deduce_vec2,v2,D,S> 63 | { 64 | typedef v2 type; 65 | }; 66 | } 67 | } 68 | 69 | int 70 | main() 71 | { 72 | same_type< boost::qvm::deduce_vec< v1 >::type, v1 >(); 73 | same_type< boost::qvm::deduce_vec< v1, 4 >::type, boost::qvm::vec >(); 74 | check< v1, v1, 3, v1 >(); 75 | check< v1, v1, 4, boost::qvm::vec >(); 76 | 77 | same_type< boost::qvm::deduce_vec< v2 >::type, v2 >(); 78 | same_type< boost::qvm::deduce_vec< v2, 4 >::type, v2 >(); 79 | check< v2, v2, 3, v2 >(); 80 | check< v2, v2, 4, v2 >(); 81 | } 82 | -------------------------------------------------------------------------------- /test/del_col_test.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2008-2024 Emil Dotchevski and Reverge Studios, Inc. 2 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 3 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | #ifdef BOOST_QVM_TEST_SINGLE_HEADER 6 | # include BOOST_QVM_TEST_SINGLE_HEADER 7 | #else 8 | # include 9 | # include 10 | # include 11 | #endif 12 | 13 | #include 14 | #include "test_qvm.hpp" 15 | #include "test_qvm_matrix.hpp" 16 | #include "gold.hpp" 17 | 18 | namespace 19 | { 20 | template 21 | void 22 | test() 23 | { 24 | using namespace boost::qvm; 25 | test_qvm::matrix x(42,1); 26 | float r1[Rows][Cols-1]; 27 | for( int i=0; i!=Rows; ++i ) 28 | for( int j=0; j!=Cols-1; ++j ) 29 | r1[i][j]=x.a[i][j+(j>=Col)]; 30 | float r2[Rows][Cols-1]; 31 | assign(r2,del_col(x)); 32 | BOOST_QVM_TEST_EQ(r1,r2); 33 | del_col(x) *= 2; 34 | for( int i=0; i!=Rows; ++i ) 35 | for( int j=0; j!=Cols-1; ++j ) 36 | r1[i][j]=x.a[i][j+(j>=Col)]; 37 | assign(r2,del_col(x)); 38 | BOOST_QVM_TEST_EQ(r1,r2); 39 | del_col(x) + del_col(x); 40 | -del_col(x); 41 | } 42 | } 43 | 44 | int 45 | main() 46 | { 47 | test<2,2,0>(); 48 | test<2,2,1>(); 49 | 50 | test<3,3,0>(); 51 | test<3,3,1>(); 52 | test<3,3,2>(); 53 | 54 | test<4,4,0>(); 55 | test<4,4,1>(); 56 | test<4,4,2>(); 57 | test<4,4,3>(); 58 | 59 | test<5,5,0>(); 60 | test<5,5,1>(); 61 | test<5,5,2>(); 62 | test<5,5,3>(); 63 | test<5,5,4>(); 64 | return boost::report_errors(); 65 | } 66 | -------------------------------------------------------------------------------- /test/del_row_test.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2008-2024 Emil Dotchevski and Reverge Studios, Inc. 2 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 3 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | #ifdef BOOST_QVM_TEST_SINGLE_HEADER 6 | # include BOOST_QVM_TEST_SINGLE_HEADER 7 | #else 8 | # include 9 | # include 10 | # include 11 | #endif 12 | 13 | #include 14 | #include "test_qvm.hpp" 15 | #include "test_qvm_matrix.hpp" 16 | #include "gold.hpp" 17 | 18 | namespace 19 | { 20 | template 21 | void 22 | test() 23 | { 24 | using namespace boost::qvm; 25 | test_qvm::matrix x(42,1); 26 | float r1[Rows-1][Cols]; 27 | for( int i=0; i!=Rows-1; ++i ) 28 | for( int j=0; j!=Cols; ++j ) 29 | r1[i][j]=x.a[i+(i>=Row)][j]; 30 | float r2[Rows-1][Cols]; 31 | assign(r2,del_row(x)); 32 | BOOST_QVM_TEST_EQ(r1,r2); 33 | del_row(x) *= 2; 34 | for( int i=0; i!=Rows-1; ++i ) 35 | for( int j=0; j!=Cols; ++j ) 36 | r1[i][j]=x.a[i+(i>=Row)][j]; 37 | assign(r2,del_row(x)); 38 | BOOST_QVM_TEST_EQ(r1,r2); 39 | del_row(x)+del_row(x); 40 | -del_row(x); 41 | } 42 | } 43 | 44 | int 45 | main() 46 | { 47 | test<2,2,0>(); 48 | test<2,2,1>(); 49 | 50 | test<3,3,0>(); 51 | test<3,3,1>(); 52 | test<3,3,2>(); 53 | 54 | test<4,4,0>(); 55 | test<4,4,1>(); 56 | test<4,4,2>(); 57 | test<4,4,3>(); 58 | 59 | test<5,5,0>(); 60 | test<5,5,1>(); 61 | test<5,5,2>(); 62 | test<5,5,3>(); 63 | test<5,5,4>(); 64 | return boost::report_errors(); 65 | } 66 | -------------------------------------------------------------------------------- /test/determinant_test.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2008-2024 Emil Dotchevski and Reverge Studios, Inc. 2 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 3 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | #ifdef BOOST_QVM_TEST_SINGLE_HEADER 6 | # include BOOST_QVM_TEST_SINGLE_HEADER 7 | #else 8 | # include 9 | #endif 10 | 11 | #include "test_qvm_matrix.hpp" 12 | #include "gold.hpp" 13 | 14 | namespace 15 | { 16 | template 17 | void 18 | test() 19 | { 20 | using namespace boost::qvm::sfinae; 21 | test_qvm::matrix const x(42,1); 22 | float gd=test_qvm::determinant(x.b); 23 | float d=determinant(x); 24 | BOOST_QVM_TEST_EQ(gd,d); 25 | } 26 | } 27 | 28 | int 29 | main() 30 | { 31 | test<2>(); 32 | test<3>(); 33 | test<4>(); 34 | test<5>(); 35 | return boost::report_errors(); 36 | } 37 | -------------------------------------------------------------------------------- /test/diag_mat_test.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2008-2024 Emil Dotchevski and Reverge Studios, Inc. 2 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 3 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | #ifdef BOOST_QVM_TEST_SINGLE_HEADER 6 | # include BOOST_QVM_TEST_SINGLE_HEADER 7 | #else 8 | # include 9 | # include 10 | # include 11 | # include 12 | #endif 13 | 14 | #include 15 | #include "test_qvm_vector.hpp" 16 | #include "gold.hpp" 17 | 18 | namespace 19 | { 20 | template 21 | void 22 | test() 23 | { 24 | using namespace boost::qvm; 25 | test_qvm::vector x(42,1); 26 | float y[Dim][Dim]; assign(y,diag_mat(x)); 27 | for( int i=0; i!=Dim; ++i ) 28 | x.b[i]=y[i][i]; 29 | BOOST_QVM_TEST_EQ(x.a,x.b); 30 | test_qvm::scalar_multiply_v(x.b,x.a,2.0f); 31 | diag(diag_mat(x)) *= 2; 32 | BOOST_QVM_TEST_EQ(x.a,x.b); 33 | diag_mat(x) + diag_mat(x); 34 | -diag_mat(x); 35 | } 36 | } 37 | 38 | int 39 | main() 40 | { 41 | test<2>(); 42 | test<3>(); 43 | test<4>(); 44 | test<5>(); 45 | return boost::report_errors(); 46 | } 47 | -------------------------------------------------------------------------------- /test/diag_test.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2008-2024 Emil Dotchevski and Reverge Studios, Inc. 2 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 3 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | #ifdef BOOST_QVM_TEST_SINGLE_HEADER 6 | # include BOOST_QVM_TEST_SINGLE_HEADER 7 | #else 8 | # include 9 | # include 10 | # include 11 | #endif 12 | 13 | #include "test_qvm_matrix.hpp" 14 | #include "test_qvm_vector.hpp" 15 | #include "gold.hpp" 16 | 17 | namespace 18 | { 19 | template 20 | struct 21 | get_min 22 | { 23 | static int const value=B; 24 | }; 25 | 26 | template 27 | struct 28 | get_min 29 | { 30 | static int const value=A; 31 | }; 32 | 33 | template 34 | void 35 | test() 36 | { 37 | using namespace boost::qvm; 38 | int const D=get_min::value; 39 | test_qvm::matrix x(42,1); 40 | test_qvm::vector y=diag(x); 41 | for( int i=0; i!=D; ++i ) 42 | y.b[i]=x.a[i][i]; 43 | BOOST_QVM_TEST_EQ(y.a,y.b); 44 | diag(x) *= 2; 45 | for( int i=0; i!=D; ++i ) 46 | x.b[i][i] *= 2; 47 | BOOST_QVM_TEST_EQ(x.a,x.b); 48 | diag(x) + diag(x); 49 | -diag(x); 50 | } 51 | } 52 | 53 | int 54 | main() 55 | { 56 | test<1,2>(); 57 | test<1,3>(); 58 | test<1,4>(); 59 | test<1,5>(); 60 | test<2,1>(); 61 | test<3,1>(); 62 | test<4,1>(); 63 | test<5,1>(); 64 | test<2,2>(); 65 | test<3,3>(); 66 | test<4,4>(); 67 | test<5,5>(); 68 | return boost::report_errors(); 69 | } 70 | -------------------------------------------------------------------------------- /test/div_eq_ms_test.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2008-2024 Emil Dotchevski and Reverge Studios, Inc. 2 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 3 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | #ifdef BOOST_QVM_TEST_SINGLE_HEADER 6 | # include BOOST_QVM_TEST_SINGLE_HEADER 7 | #else 8 | # include 9 | #endif 10 | 11 | #include "test_qvm_matrix.hpp" 12 | #include "gold.hpp" 13 | 14 | namespace 15 | { 16 | template 17 | void 18 | test() 19 | { 20 | using namespace boost::qvm::sfinae; 21 | test_qvm::matrix x(42,1); 22 | test_qvm::scalar_multiply_m(x.b,x.a,0.5f); 23 | x/=2; 24 | BOOST_QVM_TEST_EQ(x.a,x.b); 25 | } 26 | } 27 | 28 | int 29 | main() 30 | { 31 | test<1,2>(); 32 | test<2,1>(); 33 | test<2,2>(); 34 | test<1,3>(); 35 | test<3,1>(); 36 | test<3,3>(); 37 | test<1,4>(); 38 | test<4,1>(); 39 | test<4,4>(); 40 | test<1,5>(); 41 | test<5,1>(); 42 | test<5,5>(); 43 | return boost::report_errors(); 44 | } 45 | -------------------------------------------------------------------------------- /test/div_eq_qs_test.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2008-2024 Emil Dotchevski and Reverge Studios, Inc. 2 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 3 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | #ifdef BOOST_QVM_TEST_SINGLE_HEADER 6 | # include BOOST_QVM_TEST_SINGLE_HEADER 7 | #else 8 | # include 9 | #endif 10 | 11 | #include "test_qvm_quaternion.hpp" 12 | #include "gold.hpp" 13 | 14 | namespace 15 | { 16 | void 17 | test() 18 | { 19 | using namespace boost::qvm::sfinae; 20 | test_qvm::quaternion x(42,1); 21 | test_qvm::scalar_multiply_v(x.b,x.a,0.5f); 22 | x/=2; 23 | BOOST_QVM_TEST_EQ(x.a,x.b); 24 | } 25 | } 26 | 27 | int 28 | main() 29 | { 30 | test(); 31 | return boost::report_errors(); 32 | } 33 | -------------------------------------------------------------------------------- /test/div_eq_vs_test.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2008-2024 Emil Dotchevski and Reverge Studios, Inc. 2 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 3 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | #ifdef BOOST_QVM_TEST_SINGLE_HEADER 6 | # include BOOST_QVM_TEST_SINGLE_HEADER 7 | #else 8 | # include 9 | #endif 10 | 11 | #include "test_qvm_vector.hpp" 12 | #include "gold.hpp" 13 | 14 | namespace 15 | { 16 | template 17 | void 18 | test() 19 | { 20 | using namespace boost::qvm::sfinae; 21 | test_qvm::vector x(42,1); 22 | test_qvm::scalar_multiply_v(x.b,x.a,0.5f); 23 | x/=2; 24 | BOOST_QVM_TEST_EQ(x.a,x.b); 25 | } 26 | } 27 | 28 | int 29 | main() 30 | { 31 | test<1>(); 32 | test<2>(); 33 | test<3>(); 34 | test<4>(); 35 | test<5>(); 36 | return boost::report_errors(); 37 | } 38 | -------------------------------------------------------------------------------- /test/div_ms_test.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2008-2024 Emil Dotchevski and Reverge Studios, Inc. 2 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 3 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | #ifdef BOOST_QVM_TEST_SINGLE_HEADER 6 | # include BOOST_QVM_TEST_SINGLE_HEADER 7 | #else 8 | # include 9 | # include 10 | #endif 11 | 12 | #include "test_qvm_matrix.hpp" 13 | #include "gold.hpp" 14 | 15 | namespace 16 | { 17 | template struct same_type_tester; 18 | template struct same_type_tester { }; 19 | template void test_same_type( T, U ) { same_type_tester(); } 20 | 21 | template 22 | void 23 | test() 24 | { 25 | using namespace boost::qvm::sfinae; 26 | test_qvm::matrix const x(42,1); 27 | test_qvm::scalar_multiply_m(x.b,x.a,0.5f); 28 | test_same_type(x,x/2); 29 | { 30 | test_qvm::matrix y=x/2; 31 | BOOST_QVM_TEST_EQ(x.b,y.a); 32 | } 33 | { 34 | test_qvm::matrix y=mref(x)/2; 35 | BOOST_QVM_TEST_EQ(x.b,y.a); 36 | } 37 | } 38 | } 39 | 40 | int 41 | main() 42 | { 43 | test<1,2>(); 44 | test<2,1>(); 45 | test<2,2>(); 46 | test<1,3>(); 47 | test<3,1>(); 48 | test<3,3>(); 49 | test<1,4>(); 50 | test<4,1>(); 51 | test<4,4>(); 52 | test<1,5>(); 53 | test<5,1>(); 54 | test<5,5>(); 55 | return boost::report_errors(); 56 | } 57 | -------------------------------------------------------------------------------- /test/div_qs_test.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2008-2024 Emil Dotchevski and Reverge Studios, Inc. 2 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 3 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | #ifdef BOOST_QVM_TEST_SINGLE_HEADER 6 | # include BOOST_QVM_TEST_SINGLE_HEADER 7 | #else 8 | # include 9 | # include 10 | #endif 11 | 12 | #include "test_qvm_quaternion.hpp" 13 | #include "gold.hpp" 14 | 15 | namespace 16 | { 17 | template struct same_type_tester; 18 | template struct same_type_tester { }; 19 | template void test_same_type( T, U ) { same_type_tester(); } 20 | 21 | void 22 | test() 23 | { 24 | using namespace boost::qvm::sfinae; 25 | test_qvm::quaternion const x(42,1); 26 | test_qvm::scalar_multiply_v(x.b,x.a,0.5f); 27 | test_same_type(x,x/2); 28 | { 29 | test_qvm::quaternion y=x/2; 30 | BOOST_QVM_TEST_EQ(x.b,y.a); 31 | } 32 | { 33 | test_qvm::quaternion y=qref(x)/2; 34 | BOOST_QVM_TEST_EQ(x.b,y.a); 35 | } 36 | } 37 | } 38 | 39 | int 40 | main() 41 | { 42 | test(); 43 | return boost::report_errors(); 44 | } 45 | -------------------------------------------------------------------------------- /test/div_vs_test.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2008-2024 Emil Dotchevski and Reverge Studios, Inc. 2 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 3 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | #ifdef BOOST_QVM_TEST_SINGLE_HEADER 6 | # include BOOST_QVM_TEST_SINGLE_HEADER 7 | #else 8 | # include 9 | # include 10 | #endif 11 | 12 | #include "test_qvm_vector.hpp" 13 | #include "gold.hpp" 14 | 15 | namespace 16 | { 17 | template struct same_type_tester; 18 | template struct same_type_tester { }; 19 | template void test_same_type( T, U ) { same_type_tester(); } 20 | 21 | template 22 | void 23 | test() 24 | { 25 | using namespace boost::qvm::sfinae; 26 | test_qvm::vector const x(42,1); 27 | test_qvm::scalar_multiply_v(x.b,x.a,0.5f); 28 | test_same_type(x,x/2); 29 | { 30 | test_qvm::vector y=x/2; 31 | BOOST_QVM_TEST_EQ(x.b,y.a); 32 | } 33 | { 34 | test_qvm::vector y=vref(x)/2; 35 | BOOST_QVM_TEST_EQ(x.b,y.a); 36 | } 37 | } 38 | } 39 | 40 | int 41 | main() 42 | { 43 | test<1>(); 44 | test<2>(); 45 | test<3>(); 46 | test<4>(); 47 | test<5>(); 48 | return boost::report_errors(); 49 | } 50 | -------------------------------------------------------------------------------- /test/dot_qq_test.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2008-2024 Emil Dotchevski and Reverge Studios, Inc. 2 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 3 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | #ifdef BOOST_QVM_TEST_SINGLE_HEADER 6 | # include BOOST_QVM_TEST_SINGLE_HEADER 7 | #else 8 | # include 9 | #endif 10 | 11 | #include "test_qvm_quaternion.hpp" 12 | #include "gold.hpp" 13 | 14 | namespace 15 | { 16 | template struct same_type_tester; 17 | template struct same_type_tester { }; 18 | template void test_same_type( T, U ) { same_type_tester(); } 19 | 20 | void 21 | test() 22 | { 23 | using namespace boost::qvm::sfinae; 24 | 25 | test_qvm::quaternion const x(42,1); 26 | { 27 | test_qvm::quaternion const y(43,1); 28 | test_same_type(float(),dot(x,y)); 29 | float d1=dot(x,y); 30 | float d2=test_qvm::dot(x.a,y.a); 31 | BOOST_QVM_TEST_CLOSE(d1,d2,0.000001f); 32 | } 33 | { 34 | test_qvm::quaternion const y(43,1); 35 | test_same_type(double(),dot(x,y)); 36 | double d1=dot(x,y); 37 | double d2=test_qvm::dot(x.a,y.a); 38 | BOOST_QVM_TEST_CLOSE(d1,d2,0.000001); 39 | } 40 | } 41 | } 42 | 43 | int 44 | main() 45 | { 46 | test(); 47 | return boost::report_errors(); 48 | } 49 | -------------------------------------------------------------------------------- /test/dot_vv_test.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2008-2024 Emil Dotchevski and Reverge Studios, Inc. 2 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 3 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | #ifdef BOOST_QVM_TEST_SINGLE_HEADER 6 | # include BOOST_QVM_TEST_SINGLE_HEADER 7 | #else 8 | # include 9 | #endif 10 | 11 | #include "test_qvm_vector.hpp" 12 | #include "gold.hpp" 13 | 14 | namespace 15 | { 16 | template struct same_type_tester; 17 | template struct same_type_tester { }; 18 | template void test_same_type( T, U ) { same_type_tester(); } 19 | 20 | template 21 | void 22 | test() 23 | { 24 | using namespace boost::qvm::sfinae; 25 | 26 | test_qvm::vector const x(42,1); 27 | { 28 | test_qvm::vector const y(43,1); 29 | test_same_type(float(),dot(x,y)); 30 | float d1=dot(x,y); 31 | float d2=test_qvm::dot(x.a,y.a); 32 | BOOST_QVM_TEST_CLOSE(d1,d2,0.000001f); 33 | } 34 | { 35 | test_qvm::vector const y(43,1); 36 | test_same_type(double(),dot(x,y)); 37 | double d1=dot(x,y); 38 | double d2=test_qvm::dot(x.a,y.a); 39 | BOOST_QVM_TEST_CLOSE(d1,d2,0.000001); 40 | } 41 | } 42 | } 43 | 44 | int 45 | main() 46 | { 47 | test<2>(); 48 | test<3>(); 49 | test<4>(); 50 | test<5>(); 51 | return boost::report_errors(); 52 | } 53 | -------------------------------------------------------------------------------- /test/eq_mm_test.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2008-2024 Emil Dotchevski and Reverge Studios, Inc. 2 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 3 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | #ifdef BOOST_QVM_TEST_SINGLE_HEADER 6 | # include BOOST_QVM_TEST_SINGLE_HEADER 7 | #else 8 | # include 9 | #endif 10 | 11 | #include "test_qvm_matrix.hpp" 12 | #include "gold.hpp" 13 | 14 | namespace 15 | { 16 | template 17 | void 18 | test() 19 | { 20 | using namespace boost::qvm::sfinae; 21 | test_qvm::matrix const x(42,1); 22 | for( int i=0; i!=Rows; ++i ) 23 | for( int j=0; j!=Cols; ++j ) 24 | { 25 | { 26 | test_qvm::matrix y(x); 27 | BOOST_QVM_TEST_EQ(x,y); 28 | y.a[i][j]=0; 29 | BOOST_QVM_TEST_NEQ(x,y); 30 | } 31 | { 32 | test_qvm::matrix y; assign(y,x); 33 | BOOST_QVM_TEST_EQ(x,y); 34 | y.a[i][j]=0; 35 | BOOST_QVM_TEST_NEQ(x,y); 36 | } 37 | } 38 | } 39 | } 40 | 41 | int 42 | main() 43 | { 44 | test<1,2>(); 45 | test<2,1>(); 46 | test<2,2>(); 47 | test<1,3>(); 48 | test<3,1>(); 49 | test<3,3>(); 50 | test<1,4>(); 51 | test<4,1>(); 52 | test<4,4>(); 53 | test<1,5>(); 54 | test<5,1>(); 55 | test<5,5>(); 56 | return boost::report_errors(); 57 | } 58 | -------------------------------------------------------------------------------- /test/eq_qq_test.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2008-2024 Emil Dotchevski and Reverge Studios, Inc. 2 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 3 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | #ifdef BOOST_QVM_TEST_SINGLE_HEADER 6 | # include BOOST_QVM_TEST_SINGLE_HEADER 7 | #else 8 | # include 9 | #endif 10 | 11 | #include "test_qvm_quaternion.hpp" 12 | #include "gold.hpp" 13 | 14 | namespace 15 | { 16 | void 17 | test() 18 | { 19 | using namespace boost::qvm::sfinae; 20 | test_qvm::quaternion const x(42,1); 21 | for( int i=0; i!=4; ++i ) 22 | { 23 | { 24 | test_qvm::quaternion y(x); 25 | BOOST_QVM_TEST_EQ(x,y); 26 | y.a[i]=0; 27 | BOOST_QVM_TEST_NEQ(x,y); 28 | } 29 | { 30 | test_qvm::quaternion y; assign(y,x); 31 | BOOST_QVM_TEST_EQ(x,y); 32 | y.a[i]=0; 33 | BOOST_QVM_TEST_NEQ(x,y); 34 | } 35 | } 36 | } 37 | } 38 | 39 | int 40 | main() 41 | { 42 | test(); 43 | return boost::report_errors(); 44 | } 45 | -------------------------------------------------------------------------------- /test/eq_vv_test.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2008-2024 Emil Dotchevski and Reverge Studios, Inc. 2 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 3 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | #ifdef BOOST_QVM_TEST_SINGLE_HEADER 6 | # include BOOST_QVM_TEST_SINGLE_HEADER 7 | #else 8 | # include 9 | #endif 10 | 11 | #include "test_qvm_vector.hpp" 12 | #include "gold.hpp" 13 | 14 | namespace 15 | { 16 | template 17 | void 18 | test() 19 | { 20 | using namespace boost::qvm::sfinae; 21 | test_qvm::vector const x(42,1); 22 | for( int i=0; i!=Dim; ++i ) 23 | { 24 | { 25 | test_qvm::vector y(x); 26 | BOOST_QVM_TEST_EQ(x,y); 27 | y.a[i]=0; 28 | BOOST_QVM_TEST_NEQ(x,y); 29 | } 30 | { 31 | test_qvm::vector y; assign(y,x); 32 | BOOST_QVM_TEST_EQ(x,y); 33 | y.a[i]=0; 34 | BOOST_QVM_TEST_NEQ(x,y); 35 | } 36 | } 37 | } 38 | } 39 | 40 | int 41 | main() 42 | { 43 | test<2>(); 44 | test<3>(); 45 | test<4>(); 46 | test<5>(); 47 | return boost::report_errors(); 48 | } 49 | -------------------------------------------------------------------------------- /test/header-test.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2008-2024 Emil Dotchevski and Reverge Studios, Inc. 2 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 3 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | #include REVERGE_HEADER 6 | #include REVERGE_HEADER 7 | -------------------------------------------------------------------------------- /test/identity_mat_test.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2008-2024 Emil Dotchevski and Reverge Studios, Inc. 2 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 3 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | #ifdef BOOST_QVM_TEST_SINGLE_HEADER 6 | # include BOOST_QVM_TEST_SINGLE_HEADER 7 | #else 8 | # include 9 | #endif 10 | 11 | #include "test_qvm_matrix.hpp" 12 | 13 | namespace 14 | { 15 | template 16 | void 17 | test() 18 | { 19 | using namespace boost::qvm; 20 | test_qvm::matrix m=identity_mat(); 21 | for( int i=0; i!=Dim; ++i ) 22 | for( int j=0; j!=Dim; ++j ) 23 | BOOST_TEST(m.a[i][j]==float(i==j)); 24 | test_qvm::matrix n(42,1); 25 | set_identity(n); 26 | for( int i=0; i!=Dim; ++i ) 27 | for( int j=0; j!=Dim; ++j ) 28 | BOOST_TEST(n.a[i][j]==float(i==j)); 29 | } 30 | } 31 | 32 | int 33 | main() 34 | { 35 | test<2>(); 36 | test<3>(); 37 | test<4>(); 38 | test<5>(); 39 | return boost::report_errors(); 40 | } 41 | -------------------------------------------------------------------------------- /test/identity_quat_test.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2008-2024 Emil Dotchevski and Reverge Studios, Inc. 2 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 3 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | #ifdef BOOST_QVM_TEST_SINGLE_HEADER 6 | # include BOOST_QVM_TEST_SINGLE_HEADER 7 | #else 8 | # include 9 | #endif 10 | 11 | #include "test_qvm_quaternion.hpp" 12 | 13 | namespace 14 | { 15 | void 16 | test() 17 | { 18 | using namespace boost::qvm; 19 | test_qvm::quaternion q=identity_quat(); 20 | BOOST_TEST(q.a[0]==1); 21 | BOOST_TEST(q.a[1]==0); 22 | BOOST_TEST(q.a[2]==0); 23 | BOOST_TEST(q.a[3]==0); 24 | test_qvm::quaternion p(42,1); 25 | set_identity(p); 26 | BOOST_TEST(p.a[0]==1); 27 | BOOST_TEST(p.a[1]==0); 28 | BOOST_TEST(p.a[2]==0); 29 | BOOST_TEST(p.a[3]==0); 30 | } 31 | } 32 | 33 | int 34 | main() 35 | { 36 | test(); 37 | return boost::report_errors(); 38 | } 39 | -------------------------------------------------------------------------------- /test/inverse_m_test.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2008-2024 Emil Dotchevski and Reverge Studios, Inc. 2 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 3 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | #ifdef BOOST_QVM_TEST_SINGLE_HEADER 6 | # include BOOST_QVM_TEST_SINGLE_HEADER 7 | #else 8 | # include 9 | # include 10 | #endif 11 | 12 | #include 13 | #include "test_qvm_matrix.hpp" 14 | #include "gold.hpp" 15 | 16 | namespace 17 | { 18 | template struct same_type_tester; 19 | template struct same_type_tester { }; 20 | template void test_same_type( T, U ) { same_type_tester(); } 21 | 22 | template 23 | void 24 | test() 25 | { 26 | using namespace boost::qvm::sfinae; 27 | test_qvm::matrix x; 28 | test_qvm::rotation_z(x.a,42.0f); 29 | test_qvm::inverse(x.b,x.a); 30 | test_same_type(x,inverse(x)); 31 | { 32 | test_qvm::matrix y=inverse(x); 33 | BOOST_QVM_TEST_CLOSE(x.b,y.a,0.000001f); 34 | } 35 | { 36 | test_qvm::matrix y=inverse(mref(x)); 37 | BOOST_QVM_TEST_CLOSE(x.b,y.a,0.000001f); 38 | } 39 | } 40 | } 41 | 42 | int 43 | main() 44 | { 45 | try 46 | { 47 | test<2>(); 48 | test<3>(); 49 | test<4>(); 50 | test<5>(); 51 | return boost::report_errors(); 52 | } 53 | catch( 54 | ... ) 55 | { 56 | std::cerr << "Uncaught exception:\n" << boost::current_exception_diagnostic_information(); 57 | return 1; 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /test/inverse_q_test.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2008-2024 Emil Dotchevski and Reverge Studios, Inc. 2 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 3 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | #ifdef BOOST_QVM_TEST_SINGLE_HEADER 6 | # include BOOST_QVM_TEST_SINGLE_HEADER 7 | #else 8 | # include 9 | # include 10 | #endif 11 | 12 | #include 13 | #include "test_qvm_quaternion.hpp" 14 | #include "test_qvm.hpp" 15 | 16 | namespace 17 | { 18 | template struct same_type_tester; 19 | template struct same_type_tester { }; 20 | template void test_same_type( T, U ) { same_type_tester(); } 21 | 22 | void 23 | test() 24 | { 25 | using namespace boost::qvm; 26 | test_qvm::quaternion x=rotx_quat(4.2f); 27 | test_same_type(x,inverse(x)); 28 | test_qvm::quaternion y=rotx_quat(-4.2f); 29 | { 30 | test_qvm::quaternion z=inverse(x); 31 | BOOST_QVM_TEST_CLOSE_QUAT(z.a,y.a,0.00001f); 32 | } 33 | { 34 | test_qvm::quaternion z=inverse(qref(x)); 35 | BOOST_QVM_TEST_CLOSE_QUAT(z.a,y.a,0.00001f); 36 | } 37 | } 38 | } 39 | 40 | int 41 | main() 42 | { 43 | test(); 44 | return boost::report_errors(); 45 | } 46 | -------------------------------------------------------------------------------- /test/mag_q_test.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2008-2024 Emil Dotchevski and Reverge Studios, Inc. 2 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 3 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | #ifdef BOOST_QVM_TEST_SINGLE_HEADER 6 | # include BOOST_QVM_TEST_SINGLE_HEADER 7 | #else 8 | # include 9 | #endif 10 | 11 | #include "test_qvm_quaternion.hpp" 12 | #include "gold.hpp" 13 | 14 | namespace 15 | { 16 | void 17 | test() 18 | { 19 | using namespace boost::qvm::sfinae; 20 | 21 | test_qvm::quaternion const x(42,1); 22 | float m1=mag(x); 23 | float m2=mag(qref(x)); 24 | float m3=sqrtf(test_qvm::dot(x.a,x.a)); 25 | BOOST_QVM_TEST_CLOSE(m1,m3,0.000001f); 26 | BOOST_QVM_TEST_CLOSE(m2,m3,0.000001f); 27 | } 28 | } 29 | 30 | int 31 | main() 32 | { 33 | test(); 34 | return boost::report_errors(); 35 | } 36 | -------------------------------------------------------------------------------- /test/mag_sqr_q_test.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2008-2024 Emil Dotchevski and Reverge Studios, Inc. 2 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 3 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | #ifdef BOOST_QVM_TEST_SINGLE_HEADER 6 | # include BOOST_QVM_TEST_SINGLE_HEADER 7 | #else 8 | # include 9 | #endif 10 | 11 | #include "test_qvm_quaternion.hpp" 12 | #include "gold.hpp" 13 | 14 | namespace 15 | { 16 | void 17 | test() 18 | { 19 | using namespace boost::qvm::sfinae; 20 | test_qvm::quaternion const x(42,1); 21 | float m1=mag_sqr(x); 22 | float m2=mag_sqr(qref(x)); 23 | float m3=test_qvm::dot(x.a,x.a); 24 | BOOST_QVM_TEST_CLOSE(m1,m3,0.000001f); 25 | BOOST_QVM_TEST_CLOSE(m2,m3,0.000001f); 26 | } 27 | } 28 | 29 | int 30 | main() 31 | { 32 | test(); 33 | return boost::report_errors(); 34 | } 35 | -------------------------------------------------------------------------------- /test/mag_sqr_v_test.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2008-2024 Emil Dotchevski and Reverge Studios, Inc. 2 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 3 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | #ifdef BOOST_QVM_TEST_SINGLE_HEADER 6 | # include BOOST_QVM_TEST_SINGLE_HEADER 7 | #else 8 | # include 9 | #endif 10 | 11 | #include "test_qvm_vector.hpp" 12 | #include "gold.hpp" 13 | 14 | namespace 15 | { 16 | template 17 | void 18 | test() 19 | { 20 | using namespace boost::qvm::sfinae; 21 | 22 | test_qvm::vector const x(42,1); 23 | float m1=mag_sqr(x); 24 | float m2=mag_sqr(vref(x)); 25 | float m3=test_qvm::dot(x.a,x.a); 26 | BOOST_QVM_TEST_CLOSE(m1,m3,0.000001f); 27 | BOOST_QVM_TEST_CLOSE(m2,m3,0.000001f); 28 | } 29 | } 30 | 31 | int 32 | main() 33 | { 34 | test<2>(); 35 | test<3>(); 36 | test<4>(); 37 | test<5>(); 38 | return boost::report_errors(); 39 | } 40 | -------------------------------------------------------------------------------- /test/mag_v_test.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2008-2024 Emil Dotchevski and Reverge Studios, Inc. 2 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 3 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | #ifdef BOOST_QVM_TEST_SINGLE_HEADER 6 | # include BOOST_QVM_TEST_SINGLE_HEADER 7 | #else 8 | # include 9 | #endif 10 | 11 | #include "test_qvm_vector.hpp" 12 | #include "gold.hpp" 13 | 14 | namespace 15 | { 16 | template 17 | void 18 | test() 19 | { 20 | using namespace boost::qvm::sfinae; 21 | 22 | test_qvm::vector const x(42,1); 23 | float m1=mag(x); 24 | float m2=mag(vref(x)); 25 | float m3=sqrtf(test_qvm::dot(x.a,x.a)); 26 | BOOST_QVM_TEST_CLOSE(m1,m3,0.000001f); 27 | BOOST_QVM_TEST_CLOSE(m2,m3,0.000001f); 28 | } 29 | } 30 | 31 | int 32 | main() 33 | { 34 | test<2>(); 35 | test<3>(); 36 | test<4>(); 37 | test<5>(); 38 | return boost::report_errors(); 39 | } 40 | -------------------------------------------------------------------------------- /test/mat_index_test.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2008-2024 Emil Dotchevski and Reverge Studios, Inc. 2 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 3 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | #include "test_qvm_matrix.hpp" 6 | 7 | using namespace boost::qvm; 8 | 9 | template ::value> 10 | struct 11 | test_write_element_idx 12 | { 13 | static 14 | void 15 | test() 16 | { 17 | for( int r1=0; r1!=mat_traits::rows; ++r1 ) 18 | for( int c1=0; c1!=mat_traits::cols; ++c1 ) 19 | { 20 | M m(0,1); 21 | mat_traits::write_element_idx(r1,c1,m,42); 22 | int i = 0; 23 | for( int r2=0; r2!=mat_traits::rows; ++r2 ) 24 | for( int c2=0; c2!=mat_traits::cols; ++c2,++i ) 25 | BOOST_TEST_EQ( 26 | (mat_traits::read_element_idx(r2,c2,m)), 27 | (r1==r2 && c1==c2 ? 42 : i) ); 28 | } 29 | } 30 | }; 31 | 32 | template 33 | struct 34 | test_write_element_idx 35 | { 36 | static 37 | void 38 | test() 39 | { 40 | M m; 41 | for( int r=0; r!=mat_traits::rows; ++r ) 42 | for( int c=0; c!=mat_traits::cols; ++c ) 43 | BOOST_TEST_EQ(&mat_traits::write_element_idx(r,c,m), &m.a[r][c]); 44 | } 45 | }; 46 | 47 | template 48 | void 49 | mat_index_test() 50 | { 51 | M m(0, 1); 52 | int i = 0; 53 | for( int r=0; r!=mat_traits::rows; ++r ) 54 | for( int c=0; c!=mat_traits::cols; ++c,++i ) 55 | BOOST_TEST_EQ(mat_traits::read_element_idx(r,c,m), i); 56 | test_write_element_idx::test(); 57 | } 58 | 59 | int 60 | main() 61 | { 62 | using namespace boost::qvm; 63 | mat_index_test >(); 64 | mat_index_test >(); 65 | return boost::report_errors(); 66 | } 67 | -------------------------------------------------------------------------------- /test/minus_eq_mm_test.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2008-2024 Emil Dotchevski and Reverge Studios, Inc. 2 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 3 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | #ifdef BOOST_QVM_TEST_SINGLE_HEADER 6 | # include BOOST_QVM_TEST_SINGLE_HEADER 7 | #else 8 | # include 9 | #endif 10 | 11 | #include "test_qvm_matrix.hpp" 12 | #include "gold.hpp" 13 | 14 | namespace 15 | { 16 | template 17 | void 18 | test() 19 | { 20 | using namespace boost::qvm::sfinae; 21 | test_qvm::matrix x(42,2); 22 | { 23 | test_qvm::matrix const y(42,1); 24 | test_qvm::subtract_m(x.b,x.a,y.a); 25 | x-=y; 26 | BOOST_QVM_TEST_EQ(x.a,x.b); 27 | } 28 | { 29 | test_qvm::matrix const y(42,1); 30 | test_qvm::subtract_m(x.b,x.a,y.a); 31 | x-=y; 32 | BOOST_QVM_TEST_EQ(x.a,x.b); 33 | } 34 | } 35 | } 36 | 37 | int 38 | main() 39 | { 40 | test<1,2>(); 41 | test<2,1>(); 42 | test<2,2>(); 43 | test<1,3>(); 44 | test<3,1>(); 45 | test<3,3>(); 46 | test<1,4>(); 47 | test<4,1>(); 48 | test<4,4>(); 49 | test<1,5>(); 50 | test<5,1>(); 51 | test<5,5>(); 52 | return boost::report_errors(); 53 | } 54 | -------------------------------------------------------------------------------- /test/minus_eq_qq_test.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2008-2024 Emil Dotchevski and Reverge Studios, Inc. 2 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 3 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | #ifdef BOOST_QVM_TEST_SINGLE_HEADER 6 | # include BOOST_QVM_TEST_SINGLE_HEADER 7 | #else 8 | # include 9 | #endif 10 | 11 | #include "test_qvm_quaternion.hpp" 12 | #include "gold.hpp" 13 | 14 | namespace 15 | { 16 | void 17 | test() 18 | { 19 | using namespace boost::qvm::sfinae; 20 | test_qvm::quaternion x(42,2); 21 | { 22 | test_qvm::quaternion const y(42,1); 23 | test_qvm::subtract_v(x.b,x.a,y.a); 24 | x-=y; 25 | BOOST_QVM_TEST_EQ(x.a,x.b); 26 | } 27 | { 28 | test_qvm::quaternion const y(42,1); 29 | test_qvm::subtract_v(x.b,x.a,y.a); 30 | x-=y; 31 | BOOST_QVM_TEST_EQ(x.a,x.b); 32 | } 33 | } 34 | } 35 | 36 | int 37 | main() 38 | { 39 | test(); 40 | return boost::report_errors(); 41 | } 42 | -------------------------------------------------------------------------------- /test/minus_eq_vv_test.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2008-2024 Emil Dotchevski and Reverge Studios, Inc. 2 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 3 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | #ifdef BOOST_QVM_TEST_SINGLE_HEADER 6 | # include BOOST_QVM_TEST_SINGLE_HEADER 7 | #else 8 | # include 9 | #endif 10 | 11 | #include "test_qvm_vector.hpp" 12 | #include "gold.hpp" 13 | 14 | namespace 15 | { 16 | template 17 | void 18 | test() 19 | { 20 | using namespace boost::qvm::sfinae; 21 | test_qvm::vector x(42,2); 22 | { 23 | test_qvm::vector const y(42,1); 24 | test_qvm::subtract_v(x.b,x.a,y.a); 25 | x-=y; 26 | BOOST_QVM_TEST_EQ(x.a,x.b); 27 | } 28 | { 29 | test_qvm::vector const y(42,1); 30 | test_qvm::subtract_v(x.b,x.a,y.a); 31 | x-=y; 32 | BOOST_QVM_TEST_EQ(x.a,x.b); 33 | } 34 | } 35 | } 36 | 37 | int 38 | main() 39 | { 40 | test<2>(); 41 | test<3>(); 42 | test<4>(); 43 | test<5>(); 44 | return boost::report_errors(); 45 | } 46 | -------------------------------------------------------------------------------- /test/minus_m_test.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2008-2024 Emil Dotchevski and Reverge Studios, Inc. 2 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 3 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | #ifdef BOOST_QVM_TEST_SINGLE_HEADER 6 | # include BOOST_QVM_TEST_SINGLE_HEADER 7 | #else 8 | # include 9 | # include 10 | #endif 11 | 12 | #include "test_qvm_matrix.hpp" 13 | #include "gold.hpp" 14 | 15 | namespace 16 | { 17 | template struct same_type_tester; 18 | template struct same_type_tester { }; 19 | template void test_same_type( T, U ) { same_type_tester(); } 20 | 21 | template 22 | void 23 | test() 24 | { 25 | using namespace boost::qvm::sfinae; 26 | test_qvm::matrix const x(42,1); 27 | test_qvm::scalar_multiply_m(x.b,x.a,-1.0f); 28 | test_same_type(x,-x); 29 | { 30 | test_qvm::matrix y=-x; 31 | BOOST_QVM_TEST_EQ(x.b,y.a); 32 | } 33 | { 34 | test_qvm::matrix y=-mref(x); 35 | BOOST_QVM_TEST_EQ(x.b,y.a); 36 | } 37 | } 38 | } 39 | 40 | int 41 | main() 42 | { 43 | test<1,2>(); 44 | test<2,1>(); 45 | test<2,2>(); 46 | test<1,3>(); 47 | test<3,1>(); 48 | test<3,3>(); 49 | test<1,4>(); 50 | test<4,1>(); 51 | test<4,4>(); 52 | test<1,5>(); 53 | test<5,1>(); 54 | test<5,5>(); 55 | return boost::report_errors(); 56 | } 57 | -------------------------------------------------------------------------------- /test/minus_mm_test.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2008-2024 Emil Dotchevski and Reverge Studios, Inc. 2 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 3 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | #ifdef BOOST_QVM_TEST_SINGLE_HEADER 6 | # include BOOST_QVM_TEST_SINGLE_HEADER 7 | #else 8 | # include 9 | # include 10 | #endif 11 | 12 | #include "test_qvm_matrix.hpp" 13 | #include "gold.hpp" 14 | 15 | namespace 16 | { 17 | template struct same_type_tester; 18 | template struct same_type_tester { }; 19 | template void test_same_type( T, U ) { same_type_tester(); } 20 | 21 | template 22 | void 23 | test() 24 | { 25 | using namespace boost::qvm::sfinae; 26 | test_qvm::matrix const x(42,2); 27 | { 28 | test_qvm::matrix const y(42,1); 29 | test_same_type(x,x-y); 30 | test_qvm::matrix r=x-y; 31 | test_qvm::subtract_m(r.b,x.b,y.b); 32 | BOOST_QVM_TEST_EQ(r.a,r.b); 33 | } 34 | { 35 | test_qvm::matrix const y(42,1); 36 | test_qvm::matrix r=mref(x)-y; 37 | test_qvm::subtract_m(r.b,x.b,y.b); 38 | BOOST_QVM_TEST_EQ(r.a,r.b); 39 | } 40 | { 41 | test_qvm::matrix const y(42,1); 42 | test_qvm::matrix r=x-mref(y); 43 | test_qvm::subtract_m(r.b,x.b,y.b); 44 | BOOST_QVM_TEST_EQ(r.a,r.b); 45 | } 46 | } 47 | } 48 | 49 | int 50 | main() 51 | { 52 | test<1,2>(); 53 | test<2,1>(); 54 | test<2,2>(); 55 | test<1,3>(); 56 | test<3,1>(); 57 | test<3,3>(); 58 | test<1,4>(); 59 | test<4,1>(); 60 | test<4,4>(); 61 | test<1,5>(); 62 | test<5,1>(); 63 | test<5,5>(); 64 | return boost::report_errors(); 65 | } 66 | -------------------------------------------------------------------------------- /test/minus_q_test.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2008-2024 Emil Dotchevski and Reverge Studios, Inc. 2 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 3 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | #ifdef BOOST_QVM_TEST_SINGLE_HEADER 6 | # include BOOST_QVM_TEST_SINGLE_HEADER 7 | #else 8 | # include 9 | # include 10 | #endif 11 | 12 | #include "test_qvm_quaternion.hpp" 13 | #include "gold.hpp" 14 | 15 | namespace 16 | { 17 | template struct same_type_tester; 18 | template struct same_type_tester { }; 19 | template void test_same_type( T, U ) { same_type_tester(); } 20 | 21 | void 22 | test() 23 | { 24 | using namespace boost::qvm::sfinae; 25 | test_qvm::quaternion const x(42,1); 26 | test_qvm::scalar_multiply_v(x.b,x.a,-1.0f); 27 | test_same_type(x,-x); 28 | { 29 | test_qvm::quaternion y=-x; 30 | BOOST_QVM_TEST_EQ(x.b,y.a); 31 | } 32 | { 33 | test_qvm::quaternion y=-qref(x); 34 | BOOST_QVM_TEST_EQ(x.b,y.a); 35 | } 36 | } 37 | } 38 | 39 | int 40 | main() 41 | { 42 | test(); 43 | return boost::report_errors(); 44 | } 45 | -------------------------------------------------------------------------------- /test/minus_qq_test.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2008-2024 Emil Dotchevski and Reverge Studios, Inc. 2 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 3 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | #ifdef BOOST_QVM_TEST_SINGLE_HEADER 6 | # include BOOST_QVM_TEST_SINGLE_HEADER 7 | #else 8 | # include 9 | # include 10 | #endif 11 | 12 | #include "test_qvm_quaternion.hpp" 13 | #include "gold.hpp" 14 | 15 | namespace 16 | { 17 | template struct same_type_tester; 18 | template struct same_type_tester { }; 19 | template void test_same_type( T, U ) { same_type_tester(); } 20 | 21 | void 22 | test() 23 | { 24 | using namespace boost::qvm::sfinae; 25 | test_qvm::quaternion const x(42,2); 26 | { 27 | test_qvm::quaternion const y(42,1); 28 | test_same_type(x,x-y); 29 | test_qvm::quaternion r=x-y; 30 | test_qvm::subtract_v(r.b,x.b,y.b); 31 | BOOST_QVM_TEST_EQ(r.a,r.b); 32 | } 33 | { 34 | test_qvm::quaternion const y(42,1); 35 | test_qvm::quaternion r=qref(x)-y; 36 | test_qvm::subtract_v(r.b,x.b,y.b); 37 | BOOST_QVM_TEST_EQ(r.a,r.b); 38 | } 39 | { 40 | test_qvm::quaternion const y(42,1); 41 | test_qvm::quaternion r=x-qref(y); 42 | test_qvm::subtract_v(r.b,x.b,y.b); 43 | BOOST_QVM_TEST_EQ(r.a,r.b); 44 | } 45 | } 46 | } 47 | 48 | int 49 | main() 50 | { 51 | test(); 52 | return boost::report_errors(); 53 | } 54 | -------------------------------------------------------------------------------- /test/minus_v_test.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2008-2024 Emil Dotchevski and Reverge Studios, Inc. 2 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 3 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | #ifdef BOOST_QVM_TEST_SINGLE_HEADER 6 | # include BOOST_QVM_TEST_SINGLE_HEADER 7 | #else 8 | # include 9 | # include 10 | #endif 11 | 12 | #include "test_qvm_vector.hpp" 13 | #include "gold.hpp" 14 | 15 | namespace 16 | { 17 | template struct same_type_tester; 18 | template struct same_type_tester { }; 19 | template void test_same_type( T, U ) { same_type_tester(); } 20 | 21 | template 22 | void 23 | test() 24 | { 25 | using namespace boost::qvm::sfinae; 26 | test_qvm::vector const x(42,1); 27 | test_qvm::scalar_multiply_v(x.b,x.a,-1.0f); 28 | test_same_type(x,-x); 29 | { 30 | test_qvm::vector y=-x; 31 | BOOST_QVM_TEST_EQ(x.b,y.a); 32 | } 33 | { 34 | test_qvm::vector y=-vref(x); 35 | BOOST_QVM_TEST_EQ(x.b,y.a); 36 | } 37 | } 38 | } 39 | 40 | int 41 | main() 42 | { 43 | test<2>(); 44 | test<3>(); 45 | test<4>(); 46 | test<5>(); 47 | return boost::report_errors(); 48 | } 49 | -------------------------------------------------------------------------------- /test/minus_vv_test.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2008-2024 Emil Dotchevski and Reverge Studios, Inc. 2 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 3 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | #ifdef BOOST_QVM_TEST_SINGLE_HEADER 6 | # include BOOST_QVM_TEST_SINGLE_HEADER 7 | #else 8 | # include 9 | # include 10 | #endif 11 | 12 | #include "test_qvm_vector.hpp" 13 | #include "gold.hpp" 14 | 15 | namespace 16 | { 17 | template struct same_type_tester; 18 | template struct same_type_tester { }; 19 | template void test_same_type( T, U ) { same_type_tester(); } 20 | 21 | template 22 | void 23 | test() 24 | { 25 | using namespace boost::qvm::sfinae; 26 | test_qvm::vector const x(42,2); 27 | { 28 | test_qvm::vector const y(42,1); 29 | test_same_type(x,x-y); 30 | test_qvm::vector r=x-y; 31 | test_qvm::subtract_v(r.b,x.b,y.b); 32 | BOOST_QVM_TEST_EQ(r.a,r.b); 33 | } 34 | { 35 | test_qvm::vector const y(42,1); 36 | test_qvm::vector r=vref(x)-y; 37 | test_qvm::subtract_v(r.b,x.b,y.b); 38 | BOOST_QVM_TEST_EQ(r.a,r.b); 39 | } 40 | { 41 | test_qvm::vector const y(42,1); 42 | test_qvm::vector r=x-vref(y); 43 | test_qvm::subtract_v(r.b,x.b,y.b); 44 | BOOST_QVM_TEST_EQ(r.a,r.b); 45 | } 46 | } 47 | } 48 | 49 | int 50 | main() 51 | { 52 | test<2>(); 53 | test<3>(); 54 | test<4>(); 55 | test<5>(); 56 | return boost::report_errors(); 57 | } 58 | -------------------------------------------------------------------------------- /test/mul_eq_mm_test.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2008-2024 Emil Dotchevski and Reverge Studios, Inc. 2 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 3 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | #ifdef BOOST_QVM_TEST_SINGLE_HEADER 6 | # include BOOST_QVM_TEST_SINGLE_HEADER 7 | #else 8 | # include 9 | #endif 10 | 11 | #include "test_qvm_matrix.hpp" 12 | #include "gold.hpp" 13 | 14 | namespace 15 | { 16 | template 17 | void 18 | test() 19 | { 20 | using namespace boost::qvm::sfinae; 21 | { 22 | test_qvm::matrix x(42,1); 23 | test_qvm::matrix const y(42,2); 24 | test_qvm::multiply_m(x.b,x.a,y.a); 25 | x *= y; 26 | BOOST_QVM_TEST_EQ(x.a,x.b); 27 | } 28 | { 29 | test_qvm::matrix x(42,1); 30 | test_qvm::matrix const y(42,2); 31 | test_qvm::multiply_m(x.b,x.a,y.a); 32 | x *= y; 33 | BOOST_QVM_TEST_EQ(x.a,x.b); 34 | } 35 | } 36 | } 37 | 38 | int 39 | main() 40 | { 41 | test<2>(); 42 | test<3>(); 43 | test<4>(); 44 | test<5>(); 45 | return boost::report_errors(); 46 | } 47 | -------------------------------------------------------------------------------- /test/mul_eq_ms_test.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2008-2024 Emil Dotchevski and Reverge Studios, Inc. 2 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 3 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | #ifdef BOOST_QVM_TEST_SINGLE_HEADER 6 | # include BOOST_QVM_TEST_SINGLE_HEADER 7 | #else 8 | # include 9 | #endif 10 | 11 | #include "test_qvm_matrix.hpp" 12 | #include "gold.hpp" 13 | 14 | namespace 15 | { 16 | template 17 | void 18 | test() 19 | { 20 | using namespace boost::qvm::sfinae; 21 | test_qvm::matrix x(42,1); 22 | test_qvm::scalar_multiply_m(x.b,x.a,2.0f); 23 | x*=2; 24 | BOOST_QVM_TEST_EQ(x.a,x.b); 25 | } 26 | } 27 | 28 | int 29 | main() 30 | { 31 | test<1,2>(); 32 | test<2,1>(); 33 | test<2,2>(); 34 | test<1,3>(); 35 | test<3,1>(); 36 | test<3,3>(); 37 | test<1,4>(); 38 | test<4,1>(); 39 | test<4,4>(); 40 | test<1,5>(); 41 | test<5,1>(); 42 | test<5,5>(); 43 | return boost::report_errors(); 44 | } 45 | -------------------------------------------------------------------------------- /test/mul_eq_qq_test.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2008-2024 Emil Dotchevski and Reverge Studios, Inc. 2 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 3 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | #ifdef BOOST_QVM_TEST_SINGLE_HEADER 6 | # include BOOST_QVM_TEST_SINGLE_HEADER 7 | #else 8 | # include 9 | # include 10 | #endif 11 | 12 | #include "test_qvm_quaternion.hpp" 13 | #include "test_qvm_matrix.hpp" 14 | #include "gold.hpp" 15 | 16 | namespace 17 | { 18 | template struct same_type_tester; 19 | template struct same_type_tester { }; 20 | template void test_same_type( T, U ) { same_type_tester(); } 21 | 22 | void 23 | test() 24 | { 25 | using namespace boost::qvm; 26 | for( float a=0; a<6.28f; a+=0.2f ) 27 | { 28 | test_qvm::quaternion const qx=rotx_quat(a); 29 | test_qvm::quaternion const qy=roty_quat(a); 30 | test_qvm::quaternion const qz=rotz_quat(a); 31 | test_qvm::quaternion q1=identity_quat(); 32 | q1 *= qx; 33 | q1 *= qy; 34 | q1 *= qref(qz); 35 | test_qvm::matrix const mx=rotx_mat<3>(a); 36 | test_qvm::matrix const my=roty_mat<3>(a); 37 | test_qvm::matrix const mz=rotz_mat<3>(a); 38 | test_qvm::matrix const m=mx*my*mz; 39 | test_qvm::quaternion const q2=convert_to< test_qvm::quaternion >(m); 40 | BOOST_QVM_TEST_CLOSE_QUAT(q1.a,q2.a,0.00001f); 41 | } 42 | } 43 | } 44 | 45 | int 46 | main() 47 | { 48 | test(); 49 | return boost::report_errors(); 50 | } 51 | -------------------------------------------------------------------------------- /test/mul_eq_qs_test.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2008-2024 Emil Dotchevski and Reverge Studios, Inc. 2 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 3 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | #ifdef BOOST_QVM_TEST_SINGLE_HEADER 6 | # include BOOST_QVM_TEST_SINGLE_HEADER 7 | #else 8 | # include 9 | #endif 10 | 11 | #include "test_qvm_quaternion.hpp" 12 | #include "gold.hpp" 13 | 14 | namespace 15 | { 16 | void 17 | test() 18 | { 19 | using namespace boost::qvm::sfinae; 20 | test_qvm::quaternion x(42,1); 21 | test_qvm::scalar_multiply_v(x.b,x.a,2); 22 | x*=2; 23 | BOOST_QVM_TEST_EQ(x.a,x.b); 24 | } 25 | } 26 | 27 | int 28 | main() 29 | { 30 | test(); 31 | return boost::report_errors(); 32 | } 33 | -------------------------------------------------------------------------------- /test/mul_eq_vs_test.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2008-2024 Emil Dotchevski and Reverge Studios, Inc. 2 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 3 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | #ifdef BOOST_QVM_TEST_SINGLE_HEADER 6 | # include BOOST_QVM_TEST_SINGLE_HEADER 7 | #else 8 | # include 9 | #endif 10 | 11 | #include "test_qvm_vector.hpp" 12 | #include "gold.hpp" 13 | 14 | namespace 15 | { 16 | template 17 | void 18 | test() 19 | { 20 | using namespace boost::qvm::sfinae; 21 | test_qvm::vector x(42,1); 22 | test_qvm::scalar_multiply_v(x.b,x.a,2.0f); 23 | x*=2; 24 | BOOST_QVM_TEST_EQ(x.a,x.b); 25 | } 26 | } 27 | 28 | int 29 | main() 30 | { 31 | test<1>(); 32 | test<2>(); 33 | test<3>(); 34 | test<4>(); 35 | test<5>(); 36 | return boost::report_errors(); 37 | } 38 | -------------------------------------------------------------------------------- /test/mul_mm_test.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2008-2024 Emil Dotchevski and Reverge Studios, Inc. 2 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 3 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | #ifdef BOOST_QVM_TEST_SINGLE_HEADER 6 | # include BOOST_QVM_TEST_SINGLE_HEADER 7 | #else 8 | # include 9 | # include 10 | #endif 11 | 12 | #include "test_qvm_matrix.hpp" 13 | #include "gold.hpp" 14 | 15 | namespace 16 | { 17 | template 18 | void 19 | test() 20 | { 21 | using namespace boost::qvm::sfinae; 22 | test_qvm::matrix const x(42,1); 23 | test_qvm::matrix const y(42,1); 24 | { 25 | test_qvm::matrix r=x*y; 26 | test_qvm::multiply_m(r.b,x.b,y.b); 27 | BOOST_QVM_TEST_CLOSE(r.a,r.b,0.0000001f); 28 | } 29 | { 30 | test_qvm::matrix r=mref(x)*y; 31 | test_qvm::multiply_m(r.b,x.b,y.b); 32 | BOOST_QVM_TEST_CLOSE(r.a,r.b,0.0000001f); 33 | } 34 | { 35 | test_qvm::matrix r=x*mref(y); 36 | test_qvm::multiply_m(r.b,x.b,y.b); 37 | BOOST_QVM_TEST_CLOSE(r.a,r.b,0.0000001f); 38 | } 39 | } 40 | } 41 | 42 | int 43 | main() 44 | { 45 | test<1,2,2>(); 46 | test<2,2,1>(); 47 | test<2,2,2>(); 48 | test<1,3,3>(); 49 | test<3,3,1>(); 50 | test<3,3,3>(); 51 | test<1,4,4>(); 52 | test<4,4,1>(); 53 | test<4,4,4>(); 54 | test<1,5,5>(); 55 | test<5,5,1>(); 56 | test<5,5,5>(); 57 | test<2,3,4>(); 58 | return boost::report_errors(); 59 | } 60 | -------------------------------------------------------------------------------- /test/mul_ms_test.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2008-2024 Emil Dotchevski and Reverge Studios, Inc. 2 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 3 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | #ifdef BOOST_QVM_TEST_SINGLE_HEADER 6 | # include BOOST_QVM_TEST_SINGLE_HEADER 7 | #else 8 | # include 9 | # include 10 | #endif 11 | 12 | #include "test_qvm_matrix.hpp" 13 | #include "gold.hpp" 14 | 15 | namespace 16 | { 17 | template struct same_type_tester; 18 | template struct same_type_tester { }; 19 | template void test_same_type( T, U ) { same_type_tester(); } 20 | 21 | template 22 | void 23 | test() 24 | { 25 | using namespace boost::qvm::sfinae; 26 | test_qvm::matrix const x(42,1); 27 | test_qvm::scalar_multiply_m(x.b,x.a,2.0f); 28 | test_same_type(x,x*2); 29 | { 30 | test_qvm::matrix y=x*2; 31 | BOOST_QVM_TEST_EQ(x.b,y.a); 32 | } 33 | { 34 | test_qvm::matrix y=mref(x)*2; 35 | BOOST_QVM_TEST_EQ(x.b,y.a); 36 | } 37 | } 38 | } 39 | 40 | int 41 | main() 42 | { 43 | test<1,2>(); 44 | test<2,1>(); 45 | test<2,2>(); 46 | test<1,3>(); 47 | test<3,1>(); 48 | test<3,3>(); 49 | test<1,4>(); 50 | test<4,1>(); 51 | test<4,4>(); 52 | test<1,5>(); 53 | test<5,1>(); 54 | test<5,5>(); 55 | return boost::report_errors(); 56 | } 57 | -------------------------------------------------------------------------------- /test/mul_mv_test.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2008-2024 Emil Dotchevski and Reverge Studios, Inc. 2 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 3 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | #ifdef BOOST_QVM_TEST_SINGLE_HEADER 6 | # include BOOST_QVM_TEST_SINGLE_HEADER 7 | #else 8 | # include 9 | # include 10 | # include 11 | # include 12 | # include 13 | #endif 14 | 15 | #include "test_qvm_matrix.hpp" 16 | #include "test_qvm_vector.hpp" 17 | #include "gold.hpp" 18 | 19 | namespace 20 | { 21 | template 22 | struct same_type; 23 | 24 | template 25 | struct 26 | same_type 27 | { 28 | }; 29 | 30 | template 31 | void 32 | check_same_type( T const &, U const & ) 33 | { 34 | same_type(); 35 | } 36 | 37 | template 38 | void 39 | test() 40 | { 41 | using namespace boost::qvm::sfinae; 42 | test_qvm::matrix const x(42,1); 43 | test_qvm::vector const y(42,1); 44 | { 45 | test_qvm::vector r=x*y; 46 | test_qvm::multiply_mv(r.b,x.b,y.b); 47 | BOOST_QVM_TEST_CLOSE(r.a,r.b,0.0000001f); 48 | } 49 | { 50 | test_qvm::vector r=mref(x)*y; 51 | test_qvm::multiply_mv(r.b,x.b,y.b); 52 | BOOST_QVM_TEST_CLOSE(r.a,r.b,0.0000001f); 53 | } 54 | { 55 | test_qvm::vector r=x*vref(y); 56 | test_qvm::multiply_mv(r.b,x.b,y.b); 57 | BOOST_QVM_TEST_CLOSE(r.a,r.b,0.0000001f); 58 | } 59 | check_same_type(x*y,boost::qvm::vec()); 60 | } 61 | } 62 | 63 | int 64 | main() 65 | { 66 | test<1,2>(); 67 | test<2,1>(); 68 | test<2,2>(); 69 | test<1,3>(); 70 | test<3,1>(); 71 | test<3,3>(); 72 | test<1,4>(); 73 | test<4,1>(); 74 | test<4,4>(); 75 | test<1,5>(); 76 | test<5,1>(); 77 | test<5,5>(); 78 | return boost::report_errors(); 79 | } 80 | -------------------------------------------------------------------------------- /test/mul_qq_test.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2008-2024 Emil Dotchevski and Reverge Studios, Inc. 2 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 3 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | #ifdef BOOST_QVM_TEST_SINGLE_HEADER 6 | # include BOOST_QVM_TEST_SINGLE_HEADER 7 | #else 8 | # include 9 | # include 10 | # include 11 | #endif 12 | 13 | #include "test_qvm_quaternion.hpp" 14 | #include "test_qvm_matrix.hpp" 15 | #include "gold.hpp" 16 | 17 | namespace 18 | { 19 | template struct same_type_tester; 20 | template struct same_type_tester { }; 21 | template void test_same_type( T, U ) { same_type_tester(); } 22 | 23 | void 24 | test() 25 | { 26 | using namespace boost::qvm; 27 | for( float a=0; a<6.28f; a+=0.2f ) 28 | { 29 | test_qvm::quaternion const qx=rotx_quat(a); 30 | test_qvm::quaternion const qy=roty_quat(a); 31 | test_qvm::quaternion const qz=rotz_quat(a); 32 | test_qvm::quaternion const q1=qx*qy*qref(qz); 33 | test_qvm::matrix const mx=rotx_mat<3>(a); 34 | test_qvm::matrix const my=roty_mat<3>(a); 35 | test_qvm::matrix const mz=rotz_mat<3>(a); 36 | test_qvm::matrix const m=mx*my*mz; 37 | test_qvm::quaternion const q2=convert_to< test_qvm::quaternion >(m); 38 | test_same_type(qx,qx*qy); 39 | BOOST_QVM_TEST_CLOSE_QUAT(q1.a,q2.a,0.00001f); 40 | } 41 | } 42 | } 43 | 44 | int 45 | main() 46 | { 47 | test(); 48 | return boost::report_errors(); 49 | } 50 | -------------------------------------------------------------------------------- /test/mul_qs_test.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2008-2024 Emil Dotchevski and Reverge Studios, Inc. 2 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 3 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | #ifdef BOOST_QVM_TEST_SINGLE_HEADER 6 | # include BOOST_QVM_TEST_SINGLE_HEADER 7 | #else 8 | # include 9 | # include 10 | #endif 11 | 12 | #include "test_qvm_quaternion.hpp" 13 | #include "gold.hpp" 14 | 15 | namespace 16 | { 17 | template struct same_type_tester; 18 | template struct same_type_tester { }; 19 | template void test_same_type( T, U ) { same_type_tester(); } 20 | 21 | void 22 | test() 23 | { 24 | using namespace boost::qvm::sfinae; 25 | test_qvm::quaternion const x(42,1); 26 | test_qvm::scalar_multiply_v(x.b,x.a,2); 27 | test_same_type(x,x*2); 28 | { 29 | test_qvm::quaternion y=x*2; 30 | BOOST_QVM_TEST_EQ(x.b,y.a); 31 | } 32 | { 33 | test_qvm::quaternion y=qref(x)*2; 34 | BOOST_QVM_TEST_EQ(x.b,y.a); 35 | } 36 | } 37 | } 38 | 39 | int 40 | main() 41 | { 42 | test(); 43 | return boost::report_errors(); 44 | } 45 | -------------------------------------------------------------------------------- /test/mul_qv_test.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2008-2024 Emil Dotchevski and Reverge Studios, Inc. 2 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 3 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | #ifdef BOOST_QVM_TEST_SINGLE_HEADER 6 | # include BOOST_QVM_TEST_SINGLE_HEADER 7 | #else 8 | # include 9 | # include 10 | #endif 11 | 12 | #include "test_qvm_quaternion.hpp" 13 | #include "test_qvm_matrix.hpp" 14 | #include "test_qvm_vector.hpp" 15 | #include "gold.hpp" 16 | 17 | namespace 18 | { 19 | template struct same_type_tester; 20 | template struct same_type_tester { }; 21 | template void test_same_type( T, U ) { same_type_tester(); } 22 | 23 | void 24 | test() 25 | { 26 | using namespace boost::qvm; 27 | for( float a=0; a<6.28f; a+=0.2f ) 28 | { 29 | test_qvm::quaternion const qx=rotx_quat(a); 30 | test_qvm::quaternion const qy=roty_quat(a); 31 | test_qvm::quaternion const qz=rotz_quat(a); 32 | test_qvm::matrix const mx=rotx_mat<3>(a); 33 | test_qvm::matrix const my=roty_mat<3>(a); 34 | test_qvm::matrix const mz=rotz_mat<3>(a); 35 | test_qvm::vector const v(42,1); 36 | test_same_type(vec(),qx*v); 37 | test_qvm::vector const q_vx=qx*v; 38 | test_qvm::vector const m_vx=mx*v; 39 | test_qvm::vector const q_vy=qy*v; 40 | test_qvm::vector const m_vy=my*v; 41 | test_qvm::vector const q_vz=qz*v; 42 | test_qvm::vector const m_vz=mz*v; 43 | BOOST_QVM_TEST_CLOSE(q_vx.a,m_vx.a,0.001f); 44 | BOOST_QVM_TEST_CLOSE(q_vy.a,m_vy.a,0.001f); 45 | BOOST_QVM_TEST_CLOSE(q_vz.a,m_vz.a,0.001f); 46 | } 47 | } 48 | } 49 | 50 | int 51 | main() 52 | { 53 | test(); 54 | return boost::report_errors(); 55 | } 56 | -------------------------------------------------------------------------------- /test/mul_sm_test.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2008-2024 Emil Dotchevski and Reverge Studios, Inc. 2 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 3 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | #ifdef BOOST_QVM_TEST_SINGLE_HEADER 6 | # include BOOST_QVM_TEST_SINGLE_HEADER 7 | #else 8 | # include 9 | # include 10 | #endif 11 | 12 | #include "test_qvm_matrix.hpp" 13 | #include "gold.hpp" 14 | 15 | namespace 16 | { 17 | template struct same_type_tester; 18 | template struct same_type_tester { }; 19 | template void test_same_type( T, U ) { same_type_tester(); } 20 | 21 | template 22 | void 23 | test() 24 | { 25 | using namespace boost::qvm::sfinae; 26 | test_qvm::matrix const x(42,1); 27 | test_qvm::scalar_multiply_m(x.b,x.a,2.0f); 28 | test_same_type(x,2*x); 29 | { 30 | test_qvm::matrix y=2*x; 31 | BOOST_QVM_TEST_EQ(x.b,y.a); 32 | } 33 | { 34 | test_qvm::matrix y=2*mref(x); 35 | BOOST_QVM_TEST_EQ(x.b,y.a); 36 | } 37 | } 38 | } 39 | 40 | int 41 | main() 42 | { 43 | test<1,2>(); 44 | test<2,1>(); 45 | test<2,2>(); 46 | test<1,3>(); 47 | test<3,1>(); 48 | test<3,3>(); 49 | test<1,4>(); 50 | test<4,1>(); 51 | test<4,4>(); 52 | test<1,5>(); 53 | test<5,1>(); 54 | test<5,5>(); 55 | return boost::report_errors(); 56 | } 57 | -------------------------------------------------------------------------------- /test/mul_sv_test.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2008-2024 Emil Dotchevski and Reverge Studios, Inc. 2 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 3 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | #ifdef BOOST_QVM_TEST_SINGLE_HEADER 6 | # include BOOST_QVM_TEST_SINGLE_HEADER 7 | #else 8 | # include 9 | # include 10 | #endif 11 | 12 | #include "test_qvm_vector.hpp" 13 | #include "gold.hpp" 14 | 15 | namespace 16 | { 17 | template struct same_type_tester; 18 | template struct same_type_tester { }; 19 | template void test_same_type( T, U ) { same_type_tester(); } 20 | 21 | template 22 | void 23 | test() 24 | { 25 | using namespace boost::qvm::sfinae; 26 | test_qvm::vector const x(42,1); 27 | test_qvm::scalar_multiply_v(x.b,x.a,2.0f); 28 | test_same_type(x,2*x); 29 | { 30 | test_qvm::vector y=2*x; 31 | BOOST_QVM_TEST_EQ(x.b,y.a); 32 | } 33 | { 34 | test_qvm::vector y=2*vref(x); 35 | BOOST_QVM_TEST_EQ(x.b,y.a); 36 | } 37 | } 38 | } 39 | 40 | int 41 | main() 42 | { 43 | test<1>(); 44 | test<2>(); 45 | test<3>(); 46 | test<4>(); 47 | test<5>(); 48 | return boost::report_errors(); 49 | } 50 | -------------------------------------------------------------------------------- /test/mul_vm_test.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2008-2024 Emil Dotchevski and Reverge Studios, Inc. 2 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 3 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | #ifdef BOOST_QVM_TEST_SINGLE_HEADER 6 | # include BOOST_QVM_TEST_SINGLE_HEADER 7 | #else 8 | # include 9 | # include 10 | # include 11 | # include 12 | #endif 13 | 14 | #include "test_qvm_matrix.hpp" 15 | #include "test_qvm_vector.hpp" 16 | #include "gold.hpp" 17 | 18 | namespace 19 | { 20 | template 21 | struct same_type; 22 | 23 | template 24 | struct 25 | same_type 26 | { 27 | }; 28 | 29 | template 30 | void 31 | check_same_type( T const &, U const & ) 32 | { 33 | same_type(); 34 | } 35 | 36 | template 37 | void 38 | test() 39 | { 40 | using namespace boost::qvm::sfinae; 41 | using namespace boost::qvm; 42 | test_qvm::vector const x(42,1); 43 | test_qvm::matrix const y(42,1); 44 | { 45 | test_qvm::vector r=x*y; 46 | test_qvm::multiply_vm(r.b,x.b,y.b); 47 | BOOST_QVM_TEST_CLOSE(r.a,r.b,0.0000001f); 48 | } 49 | { 50 | test_qvm::vector r=vref(x)*y; 51 | test_qvm::multiply_vm(r.b,x.b,y.b); 52 | BOOST_QVM_TEST_CLOSE(r.a,r.b,0.0000001f); 53 | } 54 | { 55 | test_qvm::vector r=x*mref(y); 56 | test_qvm::multiply_vm(r.b,x.b,y.b); 57 | BOOST_QVM_TEST_CLOSE(r.a,r.b,0.0000001f); 58 | } 59 | check_same_type(x*y,boost::qvm::vec()); 60 | } 61 | } 62 | 63 | int 64 | main() 65 | { 66 | test<1,2>(); 67 | test<2,1>(); 68 | test<2,2>(); 69 | test<1,3>(); 70 | test<3,1>(); 71 | test<3,3>(); 72 | test<1,4>(); 73 | test<4,1>(); 74 | test<4,4>(); 75 | test<1,5>(); 76 | test<5,1>(); 77 | test<5,5>(); 78 | return boost::report_errors(); 79 | } 80 | -------------------------------------------------------------------------------- /test/mul_vs_test.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2008-2024 Emil Dotchevski and Reverge Studios, Inc. 2 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 3 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | #ifdef BOOST_QVM_TEST_SINGLE_HEADER 6 | # include BOOST_QVM_TEST_SINGLE_HEADER 7 | #else 8 | # include 9 | # include 10 | #endif 11 | 12 | #include "test_qvm_vector.hpp" 13 | #include "gold.hpp" 14 | 15 | namespace 16 | { 17 | template struct same_type_tester; 18 | template struct same_type_tester { }; 19 | template void test_same_type( T, U ) { same_type_tester(); } 20 | 21 | template 22 | void 23 | test() 24 | { 25 | using namespace boost::qvm::sfinae; 26 | test_qvm::vector const x(42,1); 27 | test_qvm::scalar_multiply_v(x.b,x.a,2.0f); 28 | test_same_type(x,x*2); 29 | { 30 | test_qvm::vector y=x*2; 31 | BOOST_QVM_TEST_EQ(x.b,y.a); 32 | } 33 | { 34 | test_qvm::vector y=vref(x)*2; 35 | BOOST_QVM_TEST_EQ(x.b,y.a); 36 | } 37 | } 38 | } 39 | 40 | int 41 | main() 42 | { 43 | test<1>(); 44 | test<2>(); 45 | test<3>(); 46 | test<4>(); 47 | test<5>(); 48 | return boost::report_errors(); 49 | } 50 | -------------------------------------------------------------------------------- /test/neg_col_test.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2008-2024 Emil Dotchevski and Reverge Studios, Inc. 2 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 3 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | #ifdef BOOST_QVM_TEST_SINGLE_HEADER 6 | # include BOOST_QVM_TEST_SINGLE_HEADER 7 | #else 8 | # include 9 | # include 10 | # include 11 | #endif 12 | 13 | #include 14 | #include "test_qvm.hpp" 15 | #include "test_qvm_matrix.hpp" 16 | #include "gold.hpp" 17 | 18 | namespace 19 | { 20 | template 21 | void 22 | test() 23 | { 24 | using namespace boost::qvm; 25 | test_qvm::matrix x(42,1); 26 | float r1[Rows][Cols]; 27 | for( int i=0; i!=Rows; ++i ) 28 | for( int j=0; j!=Cols; ++j ) 29 | r1[i][j]=(j==Col?-x.a[i][j]:x.a[i][j]); 30 | float r2[Rows][Cols]; 31 | assign(r2,neg_col(x)); 32 | BOOST_QVM_TEST_EQ(r1,r2); 33 | neg_col(x) + neg_col(x); 34 | -neg_col(x); 35 | } 36 | } 37 | 38 | int 39 | main() 40 | { 41 | test<2,2,0>(); 42 | test<2,2,1>(); 43 | 44 | test<3,3,0>(); 45 | test<3,3,1>(); 46 | test<3,3,2>(); 47 | 48 | test<4,4,0>(); 49 | test<4,4,1>(); 50 | test<4,4,2>(); 51 | test<4,4,3>(); 52 | 53 | test<5,5,0>(); 54 | test<5,5,1>(); 55 | test<5,5,2>(); 56 | test<5,5,3>(); 57 | test<5,5,4>(); 58 | return boost::report_errors(); 59 | } 60 | -------------------------------------------------------------------------------- /test/neg_row_test.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2008-2024 Emil Dotchevski and Reverge Studios, Inc. 2 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 3 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | #ifdef BOOST_QVM_TEST_SINGLE_HEADER 6 | # include BOOST_QVM_TEST_SINGLE_HEADER 7 | #else 8 | # include 9 | # include 10 | # include 11 | #endif 12 | 13 | #include 14 | #include "test_qvm.hpp" 15 | #include "test_qvm_matrix.hpp" 16 | #include "gold.hpp" 17 | 18 | namespace 19 | { 20 | template 21 | void 22 | test() 23 | { 24 | using namespace boost::qvm; 25 | test_qvm::matrix x(42,1); 26 | float r1[Rows][Cols]; 27 | for( int i=0; i!=Rows; ++i ) 28 | for( int j=0; j!=Cols; ++j ) 29 | r1[i][j]=(i==Row?-x.a[i][j]:x.a[i][j]); 30 | float r2[Rows][Cols]; 31 | assign(r2,neg_row(x)); 32 | BOOST_QVM_TEST_EQ(r1,r2); 33 | neg_row(x) + neg_row(x); 34 | -neg_row(x); 35 | } 36 | } 37 | 38 | int 39 | main() 40 | { 41 | test<2,2,0>(); 42 | test<2,2,1>(); 43 | 44 | test<3,3,0>(); 45 | test<3,3,1>(); 46 | test<3,3,2>(); 47 | 48 | test<4,4,0>(); 49 | test<4,4,1>(); 50 | test<4,4,2>(); 51 | test<4,4,3>(); 52 | 53 | test<5,5,0>(); 54 | test<5,5,1>(); 55 | test<5,5,2>(); 56 | test<5,5,3>(); 57 | test<5,5,4>(); 58 | return boost::report_errors(); 59 | } 60 | -------------------------------------------------------------------------------- /test/normalize_q_test.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2008-2024 Emil Dotchevski and Reverge Studios, Inc. 2 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 3 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | #ifdef BOOST_QVM_TEST_SINGLE_HEADER 6 | # include BOOST_QVM_TEST_SINGLE_HEADER 7 | #else 8 | # include 9 | # include 10 | #endif 11 | 12 | #include "test_qvm_quaternion.hpp" 13 | #include "gold.hpp" 14 | 15 | namespace 16 | { 17 | template struct same_type_tester; 18 | template struct same_type_tester { }; 19 | template void test_same_type( T, U ) { same_type_tester(); } 20 | 21 | void 22 | test() 23 | { 24 | using namespace boost::qvm::sfinae; 25 | { 26 | test_qvm::quaternion const x(42,1); 27 | test_same_type(x,normalized(x)); 28 | test_qvm::quaternion y=normalized(x); 29 | float m=sqrtf(test_qvm::dot(x.a,x.a)); 30 | test_qvm::scalar_multiply_v(y.b,x.a,1/m); 31 | BOOST_QVM_TEST_CLOSE(y.a,y.b,0.000001f); 32 | } 33 | { 34 | test_qvm::quaternion const x(42,1); 35 | test_qvm::quaternion y=normalized(qref(x)); 36 | float m=sqrtf(test_qvm::dot(x.a,x.a)); 37 | test_qvm::scalar_multiply_v(y.b,x.a,1/m); 38 | BOOST_QVM_TEST_CLOSE(y.a,y.b,0.000001f); 39 | } 40 | { 41 | test_qvm::quaternion x(42,1); 42 | float m=sqrtf(test_qvm::dot(x.a,x.a)); 43 | test_qvm::scalar_multiply_v(x.b,x.a,1/m); 44 | normalize(x); 45 | BOOST_QVM_TEST_CLOSE(x.a,x.b,0.000001f); 46 | } 47 | } 48 | } 49 | 50 | int 51 | main() 52 | { 53 | test(); 54 | return boost::report_errors(); 55 | } 56 | -------------------------------------------------------------------------------- /test/normalize_v_test.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2008-2024 Emil Dotchevski and Reverge Studios, Inc. 2 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 3 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | #ifdef BOOST_QVM_TEST_SINGLE_HEADER 6 | # include BOOST_QVM_TEST_SINGLE_HEADER 7 | #else 8 | # include 9 | #endif 10 | 11 | #include "test_qvm_vector.hpp" 12 | #include "gold.hpp" 13 | 14 | namespace 15 | { 16 | template struct same_type_tester; 17 | template struct same_type_tester { }; 18 | template void test_same_type( T, U ) { same_type_tester(); } 19 | 20 | template 21 | void 22 | test() 23 | { 24 | using namespace boost::qvm::sfinae; 25 | { 26 | test_qvm::vector const x(42,1); 27 | test_same_type(x,normalized(x)); 28 | test_qvm::vector y=normalized(x); 29 | float m=sqrtf(test_qvm::dot(x.a,x.a)); 30 | test_qvm::scalar_multiply_v(y.b,x.a,1/m); 31 | BOOST_QVM_TEST_CLOSE(y.a,y.b,0.000001f); 32 | } 33 | { 34 | test_qvm::vector x(42,1); 35 | float m=sqrtf(test_qvm::dot(x.a,x.a)); 36 | test_qvm::scalar_multiply_v(x.b,x.a,1/m); 37 | normalize(x); 38 | BOOST_QVM_TEST_CLOSE(x.a,x.b,0.000001f); 39 | } 40 | } 41 | } 42 | 43 | int 44 | main() 45 | { 46 | test<2>(); 47 | test<3>(); 48 | test<4>(); 49 | test<5>(); 50 | return boost::report_errors(); 51 | } 52 | -------------------------------------------------------------------------------- /test/plus_eq_mm_test.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2008-2024 Emil Dotchevski and Reverge Studios, Inc. 2 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 3 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | #ifdef BOOST_QVM_TEST_SINGLE_HEADER 6 | # include BOOST_QVM_TEST_SINGLE_HEADER 7 | #else 8 | # include 9 | #endif 10 | 11 | #include "test_qvm_matrix.hpp" 12 | #include "gold.hpp" 13 | 14 | namespace 15 | { 16 | template 17 | void 18 | test() 19 | { 20 | using namespace boost::qvm::sfinae; 21 | test_qvm::matrix x(42,2); 22 | { 23 | test_qvm::matrix const y(42,1); 24 | test_qvm::add_m(x.b,x.a,y.a); 25 | x+=y; 26 | BOOST_QVM_TEST_EQ(x.a,x.b); 27 | } 28 | { 29 | test_qvm::matrix const y(42,1); 30 | test_qvm::add_m(x.b,x.a,y.a); 31 | x+=y; 32 | BOOST_QVM_TEST_EQ(x.a,x.b); 33 | } 34 | } 35 | } 36 | 37 | int 38 | main() 39 | { 40 | test<1,2>(); 41 | test<2,1>(); 42 | test<2,2>(); 43 | test<1,3>(); 44 | test<3,1>(); 45 | test<3,3>(); 46 | test<1,4>(); 47 | test<4,1>(); 48 | test<4,4>(); 49 | test<1,5>(); 50 | test<5,1>(); 51 | test<5,5>(); 52 | return boost::report_errors(); 53 | } 54 | -------------------------------------------------------------------------------- /test/plus_eq_qq_test.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2008-2024 Emil Dotchevski and Reverge Studios, Inc. 2 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 3 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | #ifdef BOOST_QVM_TEST_SINGLE_HEADER 6 | # include BOOST_QVM_TEST_SINGLE_HEADER 7 | #else 8 | # include 9 | #endif 10 | 11 | #include "test_qvm_quaternion.hpp" 12 | #include "gold.hpp" 13 | 14 | namespace 15 | { 16 | void 17 | test() 18 | { 19 | using namespace boost::qvm::sfinae; 20 | test_qvm::quaternion x(42,2); 21 | { 22 | test_qvm::quaternion const y(42,1); 23 | test_qvm::add_v(x.b,x.a,y.a); 24 | x+=y; 25 | BOOST_QVM_TEST_EQ(x.a,x.b); 26 | } 27 | { 28 | test_qvm::quaternion const y(42,1); 29 | test_qvm::add_v(x.b,x.a,y.a); 30 | x+=y; 31 | BOOST_QVM_TEST_EQ(x.a,x.b); 32 | } 33 | } 34 | } 35 | 36 | int 37 | main() 38 | { 39 | test(); 40 | return boost::report_errors(); 41 | } 42 | -------------------------------------------------------------------------------- /test/plus_eq_vv_test.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2008-2024 Emil Dotchevski and Reverge Studios, Inc. 2 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 3 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | #ifdef BOOST_QVM_TEST_SINGLE_HEADER 6 | # include BOOST_QVM_TEST_SINGLE_HEADER 7 | #else 8 | # include 9 | #endif 10 | 11 | #include "test_qvm_vector.hpp" 12 | #include "gold.hpp" 13 | 14 | namespace 15 | { 16 | template 17 | void 18 | test() 19 | { 20 | using namespace boost::qvm::sfinae; 21 | test_qvm::vector x(42,2); 22 | { 23 | test_qvm::vector const y(42,1); 24 | test_qvm::add_v(x.b,x.a,y.a); 25 | x+=y; 26 | BOOST_QVM_TEST_EQ(x.a,x.b); 27 | } 28 | { 29 | test_qvm::vector const y(42,1); 30 | test_qvm::add_v(x.b,x.a,y.a); 31 | x+=y; 32 | BOOST_QVM_TEST_EQ(x.a,x.b); 33 | } 34 | } 35 | } 36 | 37 | int 38 | main() 39 | { 40 | test<2>(); 41 | test<3>(); 42 | test<4>(); 43 | test<5>(); 44 | return boost::report_errors(); 45 | } 46 | -------------------------------------------------------------------------------- /test/plus_mm_test.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2008-2024 Emil Dotchevski and Reverge Studios, Inc. 2 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 3 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | #ifdef BOOST_QVM_TEST_SINGLE_HEADER 6 | # include BOOST_QVM_TEST_SINGLE_HEADER 7 | #else 8 | # include 9 | # include 10 | #endif 11 | 12 | #include "test_qvm_matrix.hpp" 13 | #include "gold.hpp" 14 | 15 | namespace 16 | { 17 | template struct same_type_tester; 18 | template struct same_type_tester { }; 19 | template void test_same_type( T, U ) { same_type_tester(); } 20 | 21 | template 22 | void 23 | test() 24 | { 25 | using namespace boost::qvm::sfinae; 26 | test_qvm::matrix const x(42,2); 27 | { 28 | test_qvm::matrix const y(42,1); 29 | test_same_type(x,x+y); 30 | test_qvm::matrix r=x+y; 31 | test_qvm::add_m(r.b,x.b,y.b); 32 | BOOST_QVM_TEST_EQ(r.a,r.b); 33 | } 34 | { 35 | test_qvm::matrix const y(42,1); 36 | test_qvm::matrix r=mref(x)+y; 37 | test_qvm::add_m(r.b,x.b,y.b); 38 | BOOST_QVM_TEST_EQ(r.a,r.b); 39 | } 40 | { 41 | test_qvm::matrix const y(42,1); 42 | test_qvm::matrix r=x+mref(y); 43 | test_qvm::add_m(r.b,x.b,y.b); 44 | BOOST_QVM_TEST_EQ(r.a,r.b); 45 | } 46 | } 47 | } 48 | 49 | int 50 | main() 51 | { 52 | test<1,2>(); 53 | test<2,1>(); 54 | test<2,2>(); 55 | test<1,3>(); 56 | test<3,1>(); 57 | test<3,3>(); 58 | test<1,4>(); 59 | test<4,1>(); 60 | test<4,4>(); 61 | test<1,5>(); 62 | test<5,1>(); 63 | test<5,5>(); 64 | return boost::report_errors(); 65 | } 66 | -------------------------------------------------------------------------------- /test/plus_qq_test.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2008-2024 Emil Dotchevski and Reverge Studios, Inc. 2 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 3 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | #ifdef BOOST_QVM_TEST_SINGLE_HEADER 6 | # include BOOST_QVM_TEST_SINGLE_HEADER 7 | #else 8 | # include 9 | # include 10 | #endif 11 | 12 | #include "test_qvm_quaternion.hpp" 13 | #include "gold.hpp" 14 | 15 | namespace 16 | { 17 | template struct same_type_tester; 18 | template struct same_type_tester { }; 19 | template void test_same_type( T, U ) { same_type_tester(); } 20 | 21 | void 22 | test() 23 | { 24 | using namespace boost::qvm::sfinae; 25 | test_qvm::quaternion const x(42,2); 26 | { 27 | test_qvm::quaternion const y(42,1); 28 | test_same_type(x,x+y); 29 | test_qvm::quaternion r=x+y; 30 | test_qvm::add_v(r.b,x.b,y.b); 31 | BOOST_QVM_TEST_EQ(r.a,r.b); 32 | } 33 | { 34 | test_qvm::quaternion const y(42,1); 35 | test_qvm::quaternion r=qref(x)+y; 36 | test_qvm::add_v(r.b,x.b,y.b); 37 | BOOST_QVM_TEST_EQ(r.a,r.b); 38 | } 39 | { 40 | test_qvm::quaternion const y(42,1); 41 | test_qvm::quaternion r=x+qref(y); 42 | test_qvm::add_v(r.b,x.b,y.b); 43 | BOOST_QVM_TEST_EQ(r.a,r.b); 44 | } 45 | } 46 | } 47 | 48 | int 49 | main() 50 | { 51 | test(); 52 | return boost::report_errors(); 53 | } 54 | -------------------------------------------------------------------------------- /test/plus_vv_test.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2008-2024 Emil Dotchevski and Reverge Studios, Inc. 2 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 3 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | #ifdef BOOST_QVM_TEST_SINGLE_HEADER 6 | # include BOOST_QVM_TEST_SINGLE_HEADER 7 | #else 8 | # include 9 | # include 10 | #endif 11 | 12 | #include "test_qvm_vector.hpp" 13 | #include "gold.hpp" 14 | 15 | namespace 16 | { 17 | template struct same_type_tester; 18 | template struct same_type_tester { }; 19 | template void test_same_type( T, U ) { same_type_tester(); } 20 | 21 | template 22 | void 23 | test() 24 | { 25 | using namespace boost::qvm::sfinae; 26 | test_qvm::vector const x(42,2); 27 | { 28 | test_qvm::vector const y(42,1); 29 | test_same_type(x,x+y); 30 | test_qvm::vector r=x+y; 31 | test_qvm::add_v(r.b,x.b,y.b); 32 | BOOST_QVM_TEST_EQ(r.a,r.b); 33 | } 34 | { 35 | test_qvm::vector const y(42,1); 36 | test_qvm::vector r=vref(x)+y; 37 | test_qvm::add_v(r.b,x.b,y.b); 38 | BOOST_QVM_TEST_EQ(r.a,r.b); 39 | } 40 | { 41 | test_qvm::vector const y(42,1); 42 | test_qvm::vector r=x+vref(y); 43 | test_qvm::add_v(r.b,x.b,y.b); 44 | BOOST_QVM_TEST_EQ(r.a,r.b); 45 | } 46 | } 47 | } 48 | 49 | int 50 | main() 51 | { 52 | test<2>(); 53 | test<3>(); 54 | test<4>(); 55 | test<5>(); 56 | return boost::report_errors(); 57 | } 58 | -------------------------------------------------------------------------------- /test/projection_test.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2008-2024 Emil Dotchevski and Reverge Studios, Inc. 2 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 3 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | #ifdef BOOST_QVM_TEST_SINGLE_HEADER 6 | # include BOOST_QVM_TEST_SINGLE_HEADER 7 | #else 8 | # include 9 | #endif 10 | 11 | #include "test_qvm_matrix.hpp" 12 | #include "gold.hpp" 13 | 14 | namespace 15 | { 16 | template 17 | void 18 | test_perspective_lh( T fov_y, T aspect_ratio, T z_near, T z_far ) 19 | { 20 | using namespace boost::qvm; 21 | test_qvm::matrix const m=perspective_lh(fov_y,aspect_ratio,z_near,z_far); 22 | test_qvm::matrix_perspective_lh(m.b,fov_y,aspect_ratio,z_near,z_far); 23 | BOOST_QVM_TEST_CLOSE(m.a,m.b,0.000001f); 24 | } 25 | 26 | template 27 | void 28 | test_perspective_rh( T fov_y, T aspect_ratio, T z_near, T z_far ) 29 | { 30 | using namespace boost::qvm; 31 | test_qvm::matrix const m=perspective_rh(fov_y,aspect_ratio,z_near,z_far); 32 | test_qvm::matrix_perspective_rh(m.b,fov_y,aspect_ratio,z_near,z_far); 33 | BOOST_QVM_TEST_CLOSE(m.a,m.b,0.000001f); 34 | } 35 | } 36 | 37 | int 38 | main() 39 | { 40 | test_perspective_lh(0.5f,1.3f,0.1f,2000.0f); 41 | test_perspective_rh(0.5f,1.3f,0.1f,2000.0f); 42 | return boost::report_errors(); 43 | } 44 | -------------------------------------------------------------------------------- /test/rotx_mat_test.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2008-2024 Emil Dotchevski and Reverge Studios, Inc. 2 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 3 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | #ifdef BOOST_QVM_TEST_SINGLE_HEADER 6 | # include BOOST_QVM_TEST_SINGLE_HEADER 7 | #else 8 | # include 9 | # include 10 | #endif 11 | 12 | #include "test_qvm_matrix.hpp" 13 | #include "gold.hpp" 14 | 15 | namespace 16 | { 17 | template 18 | void 19 | test() 20 | { 21 | using namespace boost::qvm; 22 | for( float r=0; r<6.28f; r+=0.5f ) 23 | { 24 | test_qvm::matrix const m1=rotx_mat(r); 25 | test_qvm::rotation_x(m1.b,r); 26 | BOOST_QVM_TEST_CLOSE(m1.a,m1.b,0.001f); 27 | test_qvm::matrix m2(42,1); 28 | set_rotx(m2,r); 29 | test_qvm::rotation_x(m2.b,r); 30 | BOOST_QVM_TEST_CLOSE(m2.a,m2.b,0.001f); 31 | test_qvm::matrix m3(42,1); 32 | test_qvm::matrix r1=m3*m1; 33 | rotate_x(m3,r); 34 | BOOST_QVM_TEST_CLOSE(m3.a,r1.a,0.001f); 35 | } 36 | rotx_mat(0.0f)+rotx_mat(0.0f); 37 | -rotx_mat(0.0f); 38 | } 39 | } 40 | 41 | int 42 | main() 43 | { 44 | test<3>(); 45 | test<4>(); 46 | test<5>(); 47 | return boost::report_errors(); 48 | } 49 | -------------------------------------------------------------------------------- /test/rotx_quat_test.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2008-2024 Emil Dotchevski and Reverge Studios, Inc. 2 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 3 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | #ifdef BOOST_QVM_TEST_SINGLE_HEADER 6 | # include BOOST_QVM_TEST_SINGLE_HEADER 7 | #else 8 | # include 9 | # include 10 | # include 11 | #endif 12 | 13 | #include "test_qvm_quaternion.hpp" 14 | #include "test_qvm_matrix.hpp" 15 | #include "gold.hpp" 16 | 17 | namespace 18 | { 19 | void 20 | test() 21 | { 22 | using namespace boost::qvm; 23 | for( float r=0; r<6.28f; r+=0.5f ) 24 | { 25 | test_qvm::quaternion q1=rotx_quat(r); 26 | test_qvm::matrix m1=convert_to< test_qvm::matrix >(q1); 27 | test_qvm::rotation_x(m1.b,r); 28 | BOOST_QVM_TEST_CLOSE(m1.a,m1.b,0.000001f); 29 | test_qvm::quaternion q2(42,1); 30 | set_rotx(q2,r); 31 | test_qvm::matrix m2=convert_to< test_qvm::matrix >(q2); 32 | test_qvm::rotation_x(m2.b,r); 33 | BOOST_QVM_TEST_CLOSE(m2.a,m2.b,0.000001f); 34 | test_qvm::quaternion q3(42,1); 35 | test_qvm::quaternion r1=q3*q1; 36 | rotate_x(q3,r); 37 | BOOST_QVM_TEST_CLOSE(q3.a,r1.a,0.000001f); 38 | } 39 | rotx_quat(0.0f)+rotx_quat(0.0f); 40 | -rotx_quat(0.0f); 41 | } 42 | } 43 | 44 | int 45 | main() 46 | { 47 | test(); 48 | return boost::report_errors(); 49 | } 50 | -------------------------------------------------------------------------------- /test/roty_mat_test.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2008-2024 Emil Dotchevski and Reverge Studios, Inc. 2 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 3 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | #ifdef BOOST_QVM_TEST_SINGLE_HEADER 6 | # include BOOST_QVM_TEST_SINGLE_HEADER 7 | #else 8 | # include 9 | # include 10 | #endif 11 | 12 | #include "test_qvm_matrix.hpp" 13 | #include "gold.hpp" 14 | 15 | namespace 16 | { 17 | template 18 | void 19 | test() 20 | { 21 | using namespace boost::qvm; 22 | for( float r=0; r<6.28f; r+=0.5f ) 23 | { 24 | test_qvm::matrix const m1=roty_mat(r); 25 | test_qvm::rotation_y(m1.b,r); 26 | BOOST_QVM_TEST_CLOSE(m1.a,m1.b,0.001f); 27 | test_qvm::matrix m2(42,1); 28 | set_roty(m2,r); 29 | test_qvm::rotation_y(m2.b,r); 30 | BOOST_QVM_TEST_CLOSE(m2.a,m2.b,0.001f); 31 | test_qvm::matrix m3(42,1); 32 | test_qvm::matrix r1=m3*m1; 33 | rotate_y(m3,r); 34 | BOOST_QVM_TEST_CLOSE(m3.a,r1.a,0.001f); 35 | } 36 | roty_mat(0.0f)+roty_mat(0.0f); 37 | -roty_mat(0.0f); 38 | } 39 | } 40 | 41 | int 42 | main() 43 | { 44 | test<3>(); 45 | test<4>(); 46 | test<5>(); 47 | return boost::report_errors(); 48 | } 49 | -------------------------------------------------------------------------------- /test/roty_quat_test.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2008-2024 Emil Dotchevski and Reverge Studios, Inc. 2 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 3 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | #ifdef BOOST_QVM_TEST_SINGLE_HEADER 6 | # include BOOST_QVM_TEST_SINGLE_HEADER 7 | #else 8 | # include 9 | # include 10 | # include 11 | #endif 12 | 13 | #include "test_qvm_quaternion.hpp" 14 | #include "test_qvm_matrix.hpp" 15 | #include "gold.hpp" 16 | 17 | namespace 18 | { 19 | void 20 | test() 21 | { 22 | using namespace boost::qvm; 23 | for( float r=0; r<6.28f; r+=0.5f ) 24 | { 25 | test_qvm::quaternion q1=roty_quat(r); 26 | test_qvm::matrix m1=convert_to< test_qvm::matrix >(q1); 27 | test_qvm::rotation_y(m1.b,r); 28 | BOOST_QVM_TEST_CLOSE(m1.a,m1.b,0.000001f); 29 | test_qvm::quaternion q2(42,1); 30 | set_roty(q2,r); 31 | test_qvm::matrix m2=convert_to< test_qvm::matrix >(q2); 32 | test_qvm::rotation_y(m2.b,r); 33 | BOOST_QVM_TEST_CLOSE(m2.a,m2.b,0.000001f); 34 | test_qvm::quaternion q3(42,1); 35 | test_qvm::quaternion r1=q3*q1; 36 | rotate_y(q3,r); 37 | BOOST_QVM_TEST_CLOSE(q3.a,r1.a,0.00001f); 38 | } 39 | roty_quat(0.0f)+roty_quat(0.0f); 40 | -roty_quat(0.0f); 41 | } 42 | } 43 | 44 | int 45 | main() 46 | { 47 | test(); 48 | return boost::report_errors(); 49 | } 50 | -------------------------------------------------------------------------------- /test/rotz_mat_test.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2008-2024 Emil Dotchevski and Reverge Studios, Inc. 2 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 3 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | #ifdef BOOST_QVM_TEST_SINGLE_HEADER 6 | # include BOOST_QVM_TEST_SINGLE_HEADER 7 | #else 8 | # include 9 | # include 10 | #endif 11 | 12 | #include "test_qvm_matrix.hpp" 13 | #include "gold.hpp" 14 | 15 | namespace 16 | { 17 | template 18 | void 19 | test() 20 | { 21 | using namespace boost::qvm; 22 | for( float r=0; r<6.28f; r+=0.5f ) 23 | { 24 | test_qvm::matrix const m1=rotz_mat(r); 25 | test_qvm::rotation_z(m1.b,r); 26 | BOOST_QVM_TEST_CLOSE(m1.a,m1.b,0.001f); 27 | test_qvm::matrix m2(42,1); 28 | set_rotz(m2,r); 29 | test_qvm::rotation_z(m2.b,r); 30 | BOOST_QVM_TEST_CLOSE(m2.a,m2.b,0.001f); 31 | test_qvm::matrix m3(42,1); 32 | test_qvm::matrix r1=m3*m1; 33 | rotate_z(m3,r); 34 | BOOST_QVM_TEST_CLOSE(m3.a,r1.a,0.001f); 35 | } 36 | rotz_mat(0.0f)+rotz_mat(0.0f); 37 | -rotz_mat(0.0f); 38 | } 39 | } 40 | 41 | int 42 | main() 43 | { 44 | test<2>(); 45 | test<3>(); 46 | test<4>(); 47 | test<5>(); 48 | return boost::report_errors(); 49 | } 50 | -------------------------------------------------------------------------------- /test/rotz_quat_test.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2008-2024 Emil Dotchevski and Reverge Studios, Inc. 2 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 3 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | #ifdef BOOST_QVM_TEST_SINGLE_HEADER 6 | # include BOOST_QVM_TEST_SINGLE_HEADER 7 | #else 8 | # include 9 | # include 10 | # include 11 | #endif 12 | 13 | #include "test_qvm_quaternion.hpp" 14 | #include "test_qvm_matrix.hpp" 15 | #include "gold.hpp" 16 | 17 | namespace 18 | { 19 | void 20 | test() 21 | { 22 | using namespace boost::qvm; 23 | for( float r=0; r<6.28f; r+=0.5f ) 24 | { 25 | test_qvm::quaternion q1=rotz_quat(r); 26 | test_qvm::matrix m1=convert_to< test_qvm::matrix >(q1); 27 | test_qvm::rotation_z(m1.b,r); 28 | BOOST_QVM_TEST_CLOSE(m1.a,m1.b,0.000001f); 29 | test_qvm::quaternion q2(42,1); 30 | set_rotz(q2,r); 31 | test_qvm::matrix m2=convert_to< test_qvm::matrix >(q2); 32 | test_qvm::rotation_z(m2.b,r); 33 | BOOST_QVM_TEST_CLOSE(m2.a,m2.b,0.000001f); 34 | test_qvm::quaternion q3(42,1); 35 | test_qvm::quaternion r1=q3*q1; 36 | rotate_z(q3,r); 37 | BOOST_QVM_TEST_CLOSE(q3.a,r1.a,0.000001f); 38 | } 39 | rotz_quat(0.0f)+rotz_quat(0.0f); 40 | -rotz_quat(0.0f); 41 | } 42 | } 43 | 44 | int 45 | main() 46 | { 47 | test(); 48 | return boost::report_errors(); 49 | } 50 | -------------------------------------------------------------------------------- /test/row_mat_test.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2008-2024 Emil Dotchevski and Reverge Studios, Inc. 2 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 3 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | #ifdef BOOST_QVM_TEST_SINGLE_HEADER 6 | # include BOOST_QVM_TEST_SINGLE_HEADER 7 | #else 8 | # include 9 | # include 10 | # include 11 | # include 12 | #endif 13 | 14 | #include 15 | #include "test_qvm_vector.hpp" 16 | #include "gold.hpp" 17 | 18 | namespace 19 | { 20 | template 21 | void 22 | test() 23 | { 24 | using namespace boost::qvm; 25 | test_qvm::vector x(42,1); 26 | float y[1][Dim]; assign(y,row_mat(x)); 27 | BOOST_QVM_TEST_EQ(x.a,y[0]); 28 | test_qvm::scalar_multiply_v(x.b,x.a,2.0f); 29 | row<0>(row_mat(x)) *= 2; 30 | BOOST_QVM_TEST_EQ(x.a,x.b); 31 | row_mat(x) + row_mat(x); 32 | -row_mat(x); 33 | } 34 | } 35 | 36 | int 37 | main() 38 | { 39 | test<2>(); 40 | test<3>(); 41 | test<4>(); 42 | test<5>(); 43 | return boost::report_errors(); 44 | } 45 | -------------------------------------------------------------------------------- /test/scalar_cast_m_test.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2008-2024 Emil Dotchevski and Reverge Studios, Inc. 2 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 3 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | #ifdef BOOST_QVM_TEST_SINGLE_HEADER 6 | # include BOOST_QVM_TEST_SINGLE_HEADER 7 | #else 8 | # include 9 | #endif 10 | 11 | #include "test_qvm_matrix.hpp" 12 | #include "gold.hpp" 13 | 14 | namespace 15 | { 16 | template 17 | void 18 | test() 19 | { 20 | using namespace boost::qvm::sfinae; 21 | test_qvm::matrix x(42,1); 22 | test_qvm::matrix y; 23 | assign(y,scalar_cast(x)); 24 | for( int i=0; i!=Rows; ++i ) 25 | for( int j=0; j!=Cols; ++j ) 26 | y.b[i][j]=static_cast(x.a[i][j]); 27 | BOOST_QVM_TEST_EQ(y.a,y.b); 28 | } 29 | } 30 | 31 | int 32 | main() 33 | { 34 | test<1,2>(); 35 | test<2,1>(); 36 | test<2,2>(); 37 | return boost::report_errors(); 38 | } 39 | -------------------------------------------------------------------------------- /test/scalar_cast_q_test.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2008-2024 Emil Dotchevski and Reverge Studios, Inc. 2 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 3 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | #ifdef BOOST_QVM_TEST_SINGLE_HEADER 6 | # include BOOST_QVM_TEST_SINGLE_HEADER 7 | #else 8 | # include 9 | #endif 10 | 11 | #include "test_qvm_quaternion.hpp" 12 | #include "gold.hpp" 13 | 14 | namespace 15 | { 16 | void 17 | test() 18 | { 19 | using namespace boost::qvm::sfinae; 20 | test_qvm::quaternion x(42,1); 21 | test_qvm::quaternion y; 22 | assign(y,scalar_cast(x)); 23 | for( int i=0; i!=4; ++i ) 24 | y.b[i]=static_cast(x.a[i]); 25 | BOOST_QVM_TEST_EQ(y.a,y.b); 26 | } 27 | } 28 | 29 | int 30 | main() 31 | { 32 | test(); 33 | return boost::report_errors(); 34 | } 35 | -------------------------------------------------------------------------------- /test/scalar_cast_v_test.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2008-2024 Emil Dotchevski and Reverge Studios, Inc. 2 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 3 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | #ifdef BOOST_QVM_TEST_SINGLE_HEADER 6 | # include BOOST_QVM_TEST_SINGLE_HEADER 7 | #else 8 | # include 9 | #endif 10 | 11 | #include "test_qvm_vector.hpp" 12 | #include "gold.hpp" 13 | 14 | namespace 15 | { 16 | template 17 | void 18 | test() 19 | { 20 | using namespace boost::qvm::sfinae; 21 | test_qvm::vector x(42,1); 22 | test_qvm::vector y; 23 | assign(y,scalar_cast(x)); 24 | for( int i=0; i!=Dim; ++i ) 25 | y.b[i]=static_cast(x.a[i]); 26 | BOOST_QVM_TEST_EQ(y.a,y.b); 27 | } 28 | } 29 | 30 | int 31 | main() 32 | { 33 | test<2>(); 34 | return boost::report_errors(); 35 | } 36 | -------------------------------------------------------------------------------- /test/scalar_traits_test.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2008-2024 Emil Dotchevski and Reverge Studios, Inc. 2 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 3 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | #ifdef BOOST_QVM_TEST_SINGLE_HEADER 6 | # include BOOST_QVM_TEST_SINGLE_HEADER 7 | #else 8 | # include 9 | #endif 10 | 11 | #include 12 | #include 13 | #include 14 | 15 | template 16 | struct tester; 17 | 18 | template <> 19 | struct 20 | tester 21 | { 22 | }; 23 | 24 | using namespace boost::qvm; 25 | tester::value> t1; 26 | tester::value> t2; 27 | tester::value> t3; 28 | tester::value> t4; 29 | tester::value> t5; 30 | tester::value> t6; 31 | tester::value> t7; 32 | tester::value> t8; 33 | tester::value> t9; 34 | tester::value> t10; 35 | tester::value> t11; 36 | tester::value> t13; 37 | tester >::value> t14; 38 | tester >::value> t15; 39 | tester >::value> t16; 40 | tester::value> t17; 41 | tester::value> t18; 42 | 43 | int 44 | main() 45 | { 46 | return 0; 47 | } 48 | -------------------------------------------------------------------------------- /test/swizzle2_test2.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2008-2024 Emil Dotchevski and Reverge Studios, Inc. 2 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 3 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | #ifdef BOOST_QVM_TEST_SINGLE_HEADER 6 | # include BOOST_QVM_TEST_SINGLE_HEADER 7 | # ifdef BOOST_QVM_TEST_SINGLE_HEADER_SWIZZLE 8 | # include BOOST_QVM_TEST_SINGLE_HEADER_SWIZZLE 9 | # endif 10 | #else 11 | # include 12 | # include 13 | #endif 14 | 15 | #include 16 | 17 | template struct my_vec { }; 18 | int called=0; 19 | 20 | namespace 21 | boost 22 | { 23 | namespace 24 | qvm 25 | { 26 | void 27 | XX(...) 28 | { 29 | BOOST_TEST(0); 30 | } 31 | void 32 | XY(...) 33 | { 34 | ++called; 35 | } 36 | template 37 | struct 38 | vec_traits< my_vec > 39 | { 40 | typedef int scalar_type; 41 | static int const dim=D; 42 | template static int read_element( my_vec const & ); 43 | template static int & write_element( my_vec & ); 44 | }; 45 | } 46 | } 47 | 48 | int 49 | main() 50 | { 51 | using namespace boost::qvm; 52 | XX(my_vec<1>()); 53 | XY(my_vec<1>()); 54 | BOOST_TEST(called==1); 55 | return boost::report_errors(); 56 | } 57 | -------------------------------------------------------------------------------- /test/swizzle2_test3.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2008-2024 Emil Dotchevski and Reverge Studios, Inc. 2 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 3 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | #ifdef BOOST_QVM_TEST_SINGLE_HEADER 6 | # include BOOST_QVM_TEST_SINGLE_HEADER 7 | # ifdef BOOST_QVM_TEST_SINGLE_HEADER_SWIZZLE 8 | # include BOOST_QVM_TEST_SINGLE_HEADER_SWIZZLE 9 | # endif 10 | #else 11 | # include 12 | # include 13 | #endif 14 | 15 | #include 16 | 17 | template struct my_vec { }; 18 | int called=0; 19 | 20 | namespace 21 | boost 22 | { 23 | namespace 24 | qvm 25 | { 26 | void 27 | YY(...) 28 | { 29 | BOOST_TEST(0); 30 | } 31 | void 32 | XZ(...) 33 | { 34 | ++called; 35 | } 36 | template 37 | struct 38 | vec_traits< my_vec > 39 | { 40 | typedef int scalar_type; 41 | static int const dim=D; 42 | template static int read_element( my_vec const & ); 43 | template static int & write_element( my_vec & ); 44 | }; 45 | } 46 | } 47 | 48 | int 49 | main() 50 | { 51 | using namespace boost::qvm; 52 | YY(my_vec<2>()); 53 | XZ(my_vec<2>()); 54 | BOOST_TEST(called==1); 55 | return boost::report_errors(); 56 | } 57 | -------------------------------------------------------------------------------- /test/swizzle2_test4.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2008-2024 Emil Dotchevski and Reverge Studios, Inc. 2 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 3 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | #ifdef BOOST_QVM_TEST_SINGLE_HEADER 6 | # include BOOST_QVM_TEST_SINGLE_HEADER 7 | # ifdef BOOST_QVM_TEST_SINGLE_HEADER_SWIZZLE 8 | # include BOOST_QVM_TEST_SINGLE_HEADER_SWIZZLE 9 | # endif 10 | #else 11 | # include 12 | # include 13 | #endif 14 | 15 | #include 16 | 17 | template struct my_vec { }; 18 | int called=0; 19 | 20 | namespace 21 | boost 22 | { 23 | namespace 24 | qvm 25 | { 26 | void 27 | ZZ(...) 28 | { 29 | BOOST_TEST(0); 30 | } 31 | void 32 | XW(...) 33 | { 34 | ++called; 35 | } 36 | template 37 | struct 38 | vec_traits< my_vec > 39 | { 40 | typedef int scalar_type; 41 | static int const dim=D; 42 | template static int read_element( my_vec const & ); 43 | template static int & write_element( my_vec & ); 44 | }; 45 | } 46 | } 47 | 48 | int 49 | main() 50 | { 51 | using namespace boost::qvm; 52 | ZZ(my_vec<3>()); 53 | XW(my_vec<3>()); 54 | BOOST_TEST(called==1); 55 | return boost::report_errors(); 56 | } 57 | -------------------------------------------------------------------------------- /test/swizzle3_test2.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2008-2024 Emil Dotchevski and Reverge Studios, Inc. 2 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 3 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | #ifdef BOOST_QVM_TEST_SINGLE_HEADER 6 | # include BOOST_QVM_TEST_SINGLE_HEADER 7 | # ifdef BOOST_QVM_TEST_SINGLE_HEADER_SWIZZLE 8 | # include BOOST_QVM_TEST_SINGLE_HEADER_SWIZZLE 9 | # endif 10 | #else 11 | # include 12 | # include 13 | #endif 14 | 15 | #include 16 | 17 | template struct my_vec { }; 18 | int called=0; 19 | 20 | namespace 21 | boost 22 | { 23 | namespace 24 | qvm 25 | { 26 | void 27 | XXX(...) 28 | { 29 | BOOST_TEST(0); 30 | } 31 | void 32 | XXY(...) 33 | { 34 | ++called; 35 | } 36 | template 37 | struct 38 | vec_traits< my_vec > 39 | { 40 | typedef int scalar_type; 41 | static int const dim=D; 42 | template static int read_element( my_vec const & ); 43 | template static int & write_element( my_vec & ); 44 | }; 45 | } 46 | } 47 | 48 | int 49 | main() 50 | { 51 | using namespace boost::qvm; 52 | XXX(my_vec<1>()); 53 | XXY(my_vec<1>()); 54 | BOOST_TEST(called==1); 55 | return boost::report_errors(); 56 | } 57 | -------------------------------------------------------------------------------- /test/swizzle3_test3.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2008-2024 Emil Dotchevski and Reverge Studios, Inc. 2 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 3 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | #ifdef BOOST_QVM_TEST_SINGLE_HEADER 6 | # include BOOST_QVM_TEST_SINGLE_HEADER 7 | # ifdef BOOST_QVM_TEST_SINGLE_HEADER_SWIZZLE 8 | # include BOOST_QVM_TEST_SINGLE_HEADER_SWIZZLE 9 | # endif 10 | #else 11 | # include 12 | # include 13 | #endif 14 | 15 | #include 16 | 17 | template struct my_vec { }; 18 | int called=0; 19 | 20 | namespace 21 | boost 22 | { 23 | namespace 24 | qvm 25 | { 26 | void 27 | YYY(...) 28 | { 29 | BOOST_TEST(0); 30 | } 31 | void 32 | XXZ(...) 33 | { 34 | ++called; 35 | } 36 | template 37 | struct 38 | vec_traits< my_vec > 39 | { 40 | typedef int scalar_type; 41 | static int const dim=D; 42 | template static int read_element( my_vec const & ); 43 | template static int & write_element( my_vec & ); 44 | }; 45 | } 46 | } 47 | 48 | int 49 | main() 50 | { 51 | using namespace boost::qvm; 52 | YYY(my_vec<2>()); 53 | XXZ(my_vec<2>()); 54 | BOOST_TEST(called==1); 55 | return boost::report_errors(); 56 | } 57 | -------------------------------------------------------------------------------- /test/swizzle3_test4.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2008-2024 Emil Dotchevski and Reverge Studios, Inc. 2 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 3 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | #ifdef BOOST_QVM_TEST_SINGLE_HEADER 6 | # include BOOST_QVM_TEST_SINGLE_HEADER 7 | # ifdef BOOST_QVM_TEST_SINGLE_HEADER_SWIZZLE 8 | # include BOOST_QVM_TEST_SINGLE_HEADER_SWIZZLE 9 | # endif 10 | #else 11 | # include 12 | # include 13 | #endif 14 | 15 | #include 16 | 17 | template struct my_vec { }; 18 | int called=0; 19 | 20 | namespace 21 | boost 22 | { 23 | namespace 24 | qvm 25 | { 26 | void 27 | ZZZ(...) 28 | { 29 | BOOST_TEST(0); 30 | } 31 | void 32 | XXW(...) 33 | { 34 | ++called; 35 | } 36 | template 37 | struct 38 | vec_traits< my_vec > 39 | { 40 | typedef int scalar_type; 41 | static int const dim=D; 42 | template static int read_element( my_vec const & ); 43 | template static int & write_element( my_vec & ); 44 | }; 45 | } 46 | } 47 | 48 | int 49 | main() 50 | { 51 | using namespace boost::qvm; 52 | ZZZ(my_vec<3>()); 53 | XXW(my_vec<3>()); 54 | BOOST_TEST(called==1); 55 | return boost::report_errors(); 56 | } 57 | -------------------------------------------------------------------------------- /test/swizzle4_test2.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2008-2024 Emil Dotchevski and Reverge Studios, Inc. 2 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 3 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | #ifdef BOOST_QVM_TEST_SINGLE_HEADER 6 | # include BOOST_QVM_TEST_SINGLE_HEADER 7 | # ifdef BOOST_QVM_TEST_SINGLE_HEADER_SWIZZLE 8 | # include BOOST_QVM_TEST_SINGLE_HEADER_SWIZZLE 9 | # endif 10 | #else 11 | # include 12 | # include 13 | #endif 14 | 15 | #include 16 | 17 | template struct my_vec { }; 18 | int called=0; 19 | 20 | namespace 21 | boost 22 | { 23 | namespace 24 | qvm 25 | { 26 | void 27 | XXXX(...) 28 | { 29 | BOOST_TEST(0); 30 | } 31 | void 32 | XXXY(...) 33 | { 34 | ++called; 35 | } 36 | template 37 | struct 38 | vec_traits< my_vec > 39 | { 40 | typedef int scalar_type; 41 | static int const dim=D; 42 | template static int read_element( my_vec const & ); 43 | template static int & write_element( my_vec & ); 44 | }; 45 | } 46 | } 47 | 48 | int 49 | main() 50 | { 51 | using namespace boost::qvm; 52 | XXXX(my_vec<1>()); 53 | XXXY(my_vec<1>()); 54 | BOOST_TEST(called==1); 55 | return boost::report_errors(); 56 | } 57 | -------------------------------------------------------------------------------- /test/swizzle4_test3.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2008-2024 Emil Dotchevski and Reverge Studios, Inc. 2 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 3 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | #ifdef BOOST_QVM_TEST_SINGLE_HEADER 6 | # include BOOST_QVM_TEST_SINGLE_HEADER 7 | # ifdef BOOST_QVM_TEST_SINGLE_HEADER_SWIZZLE 8 | # include BOOST_QVM_TEST_SINGLE_HEADER_SWIZZLE 9 | # endif 10 | #else 11 | # include 12 | # include 13 | #endif 14 | 15 | #include 16 | 17 | template struct my_vec { }; 18 | int called=0; 19 | 20 | namespace 21 | boost 22 | { 23 | namespace 24 | qvm 25 | { 26 | void 27 | YYYY(...) 28 | { 29 | BOOST_TEST(0); 30 | } 31 | void 32 | XXXZ(...) 33 | { 34 | ++called; 35 | } 36 | template 37 | struct 38 | vec_traits< my_vec > 39 | { 40 | typedef int scalar_type; 41 | static int const dim=D; 42 | template static int read_element( my_vec const & ); 43 | template static int & write_element( my_vec & ); 44 | }; 45 | } 46 | } 47 | 48 | int 49 | main() 50 | { 51 | using namespace boost::qvm; 52 | YYYY(my_vec<2>()); 53 | XXXZ(my_vec<2>()); 54 | BOOST_TEST(called==1); 55 | return boost::report_errors(); 56 | } 57 | -------------------------------------------------------------------------------- /test/swizzle4_test4.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2008-2024 Emil Dotchevski and Reverge Studios, Inc. 2 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 3 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | #ifdef BOOST_QVM_TEST_SINGLE_HEADER 6 | # include BOOST_QVM_TEST_SINGLE_HEADER 7 | # ifdef BOOST_QVM_TEST_SINGLE_HEADER_SWIZZLE 8 | # include BOOST_QVM_TEST_SINGLE_HEADER_SWIZZLE 9 | # endif 10 | #else 11 | # include 12 | # include 13 | #endif 14 | 15 | #include 16 | 17 | template struct my_vec { }; 18 | int called=0; 19 | 20 | namespace 21 | boost 22 | { 23 | namespace 24 | qvm 25 | { 26 | void 27 | ZZZZ(...) 28 | { 29 | BOOST_TEST(0); 30 | } 31 | void 32 | XXXW(...) 33 | { 34 | ++called; 35 | } 36 | template 37 | struct 38 | vec_traits< my_vec > 39 | { 40 | typedef int scalar_type; 41 | static int const dim=D; 42 | template static int read_element( my_vec const & ); 43 | template static int & write_element( my_vec & ); 44 | }; 45 | } 46 | } 47 | 48 | int 49 | main() 50 | { 51 | using namespace boost::qvm; 52 | ZZZZ(my_vec<3>()); 53 | XXXW(my_vec<3>()); 54 | BOOST_TEST(called==1); 55 | return boost::report_errors(); 56 | } 57 | -------------------------------------------------------------------------------- /test/swizzle_const_fail.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2008-2024 Emil Dotchevski and Reverge Studios, Inc. 2 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 3 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | #include 6 | #include 7 | #include 8 | 9 | int 10 | main() 11 | { 12 | using namespace boost::qvm; 13 | vec v; 14 | vec const & cv=v; 15 | XY(cv)*=2; 16 | return 1; 17 | } 18 | -------------------------------------------------------------------------------- /test/transform_test.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2008-2024 Emil Dotchevski and Reverge Studios, Inc. 2 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 3 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | #ifdef BOOST_QVM_TEST_SINGLE_HEADER 6 | # include BOOST_QVM_TEST_SINGLE_HEADER 7 | # ifdef BOOST_QVM_TEST_SINGLE_HEADER_SWIZZLE 8 | # include BOOST_QVM_TEST_SINGLE_HEADER_SWIZZLE 9 | # endif 10 | #else 11 | # include 12 | # include 13 | # include 14 | # include 15 | # include 16 | # include 17 | # include 18 | # include 19 | #endif 20 | 21 | #include "test_qvm_matrix.hpp" 22 | #include "test_qvm_vector.hpp" 23 | #include "test_qvm.hpp" 24 | 25 | namespace 26 | { 27 | void 28 | test() 29 | { 30 | using namespace boost::qvm; 31 | test_qvm::matrix m=rot_mat<4>(test_qvm::vector(1,0),1.0f); 32 | X(col<3>(m)) = 42; 33 | Y(col<3>(m)) = 42; 34 | Z(col<3>(m)) = 42; 35 | test_qvm::vector v(42,1); 36 | test_qvm::vector mv=transform_vector(m,v); 37 | test_qvm::vector mp=transform_point(m,v); 38 | test_qvm::vector v3=del_row_col<3,3>(m) * v; 39 | test_qvm::vector v4=XYZ(m*XYZ1(v)); 40 | BOOST_QVM_TEST_EQ(mv.a,v3.a); 41 | BOOST_QVM_TEST_EQ(mp.a,v4.a); 42 | } 43 | } 44 | 45 | int 46 | main() 47 | { 48 | test(); 49 | return boost::report_errors(); 50 | } 51 | -------------------------------------------------------------------------------- /test/translation_mat_test.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2008-2024 Emil Dotchevski and Reverge Studios, Inc. 2 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 3 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | #ifdef BOOST_QVM_TEST_SINGLE_HEADER 6 | # include BOOST_QVM_TEST_SINGLE_HEADER 7 | #else 8 | # include 9 | # include 10 | # include 11 | # include 12 | #endif 13 | 14 | #include 15 | #include "test_qvm_vector.hpp" 16 | #include "gold.hpp" 17 | 18 | namespace 19 | { 20 | template 21 | void 22 | test() 23 | { 24 | using namespace boost::qvm; 25 | test_qvm::vector x(42,1); 26 | float r1[Dim][Dim]; 27 | test_qvm::translation(r1,x.a); 28 | float r2[Dim][Dim]; 29 | assign(r2,translation_mat(x)); 30 | BOOST_QVM_TEST_EQ(r1,r2); 31 | test_qvm::scalar_multiply_v(x.b,x.a,2.0f); 32 | col(del_row(translation_mat(x))) *= 2; 33 | BOOST_QVM_TEST_EQ(x.a,x.b); 34 | translation_mat(x) + translation_mat(x); 35 | -translation_mat(x); 36 | } 37 | } 38 | 39 | int 40 | main() 41 | { 42 | test<3>(); 43 | test<4>(); 44 | test<5>(); 45 | return boost::report_errors(); 46 | } 47 | -------------------------------------------------------------------------------- /test/translation_test.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2008-2024 Emil Dotchevski and Reverge Studios, Inc. 2 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 3 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | #ifdef BOOST_QVM_TEST_SINGLE_HEADER 6 | # include BOOST_QVM_TEST_SINGLE_HEADER 7 | #else 8 | # include 9 | # include 10 | # include 11 | #endif 12 | 13 | #include "test_qvm_matrix.hpp" 14 | #include "test_qvm_vector.hpp" 15 | #include "gold.hpp" 16 | 17 | namespace 18 | { 19 | template 20 | void 21 | test() 22 | { 23 | using namespace boost::qvm; 24 | test_qvm::matrix x(42,1); 25 | test_qvm::vector y=translation(x); 26 | for( int i=0; i!=C-1; ++i ) 27 | y.b[i]=x.a[i][C-1]; 28 | BOOST_QVM_TEST_EQ(y.a,y.b); 29 | translation(x) *= 2; 30 | for( int i=0; i!=C-1; ++i ) 31 | x.b[i][C-1] *= 2; 32 | BOOST_QVM_TEST_EQ(x.a,x.b); 33 | translation(x) + translation(x); 34 | -translation(x); 35 | } 36 | } 37 | 38 | int 39 | main() 40 | { 41 | test<3,3>(); 42 | test<2,3>(); 43 | test<4,4>(); 44 | test<3,4>(); 45 | test<5,5>(); 46 | test<4,5>(); 47 | return boost::report_errors(); 48 | } 49 | -------------------------------------------------------------------------------- /test/transpose_test.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2008-2024 Emil Dotchevski and Reverge Studios, Inc. 2 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 3 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | #ifdef BOOST_QVM_TEST_SINGLE_HEADER 6 | # include BOOST_QVM_TEST_SINGLE_HEADER 7 | #else 8 | # include 9 | # include 10 | # include 11 | #endif 12 | 13 | #include 14 | #include "test_qvm_matrix.hpp" 15 | #include "gold.hpp" 16 | 17 | namespace 18 | { 19 | template 20 | void 21 | test() 22 | { 23 | using namespace boost::qvm; 24 | test_qvm::matrix x(42,1); 25 | float r1[Cols][Rows]; 26 | for( int i=0; i!=Rows; ++i ) 27 | for( int j=0; j!=Cols; ++j ) 28 | r1[j][i]=x.a[i][j]; 29 | float r2[Cols][Rows]; 30 | assign(r2,transposed(x)); 31 | BOOST_QVM_TEST_EQ(r1,r2); 32 | test_qvm::scalar_multiply_m(x.b,x.a,2.0f); 33 | transposed(x) *= 2; 34 | BOOST_QVM_TEST_EQ(x.a,x.b); 35 | transposed(x) + transposed(x); 36 | -transposed(x); 37 | } 38 | } 39 | 40 | int 41 | main() 42 | { 43 | test<1,2>(); 44 | test<2,1>(); 45 | test<2,2>(); 46 | test<1,3>(); 47 | test<3,1>(); 48 | test<3,3>(); 49 | test<1,4>(); 50 | test<4,1>(); 51 | test<4,4>(); 52 | test<1,5>(); 53 | test<5,1>(); 54 | test<5,5>(); 55 | return boost::report_errors(); 56 | } 57 | -------------------------------------------------------------------------------- /test/vec_index_test.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2008-2024 Emil Dotchevski and Reverge Studios, Inc. 2 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 3 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | #include "test_qvm_vector.hpp" 6 | 7 | using namespace boost::qvm; 8 | 9 | template ::value> 10 | struct 11 | test_write_element_idx 12 | { 13 | static 14 | void 15 | test() 16 | { 17 | for( int i=0; i!=vec_traits::dim; ++i ) 18 | { 19 | V v(0,1); 20 | vec_traits::write_element_idx(i,v,42); 21 | for( int j=0; j!=vec_traits::dim; ++j ) 22 | BOOST_TEST_EQ( 23 | (vec_traits::read_element_idx(j,v)), 24 | (i==j ? 42 : j) ); 25 | } 26 | } 27 | }; 28 | 29 | template 30 | struct 31 | test_write_element_idx 32 | { 33 | static 34 | void 35 | test() 36 | { 37 | V v; 38 | for( int i=0; i!=vec_traits::dim; ++v ) 39 | BOOST_TEST_EQ(&vec_traits::write_element_idx(i,v), &v.a[i]); 40 | } 41 | }; 42 | 43 | template 44 | void 45 | vec_index_test() 46 | { 47 | V v(0, 1); 48 | for( int i=0; i!=vec_traits::dim; ++i ) 49 | BOOST_TEST_EQ(vec_traits::read_element_idx(i,v), i); 50 | test_write_element_idx::test(); 51 | } 52 | 53 | int 54 | main() 55 | { 56 | using namespace boost::qvm; 57 | vec_index_test >(); 58 | vec_index_test >(); 59 | return boost::report_errors(); 60 | } 61 | -------------------------------------------------------------------------------- /test/zero_mat_test.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2008-2024 Emil Dotchevski and Reverge Studios, Inc. 2 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 3 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | #ifdef BOOST_QVM_TEST_SINGLE_HEADER 6 | # include BOOST_QVM_TEST_SINGLE_HEADER 7 | #else 8 | # include 9 | # include 10 | #endif 11 | 12 | #include "test_qvm_matrix.hpp" 13 | 14 | namespace 15 | { 16 | template 17 | struct same_type; 18 | 19 | template 20 | struct 21 | same_type 22 | { 23 | }; 24 | 25 | template 26 | void 27 | check_deduction( T const &, U const & ) 28 | { 29 | same_type::type>(); 30 | } 31 | 32 | template 33 | void 34 | test() 35 | { 36 | using namespace boost::qvm; 37 | test_qvm::matrix m1=zero_mat(); 38 | for( int i=0; i!=Rows; ++i ) 39 | for( int j=0; j!=Cols; ++j ) 40 | BOOST_TEST(!m1.a[i][j]); 41 | test_qvm::matrix m2(42,1); 42 | set_zero(m2); 43 | for( int i=0; i!=Rows; ++i ) 44 | for( int j=0; j!=Cols; ++j ) 45 | BOOST_TEST(!m2.a[i][j]); 46 | check_deduction(mat(),zero_mat()); 47 | check_deduction(mat(),zero_mat()); 48 | } 49 | 50 | template 51 | void 52 | test() 53 | { 54 | using namespace boost::qvm; 55 | test_qvm::matrix m1=zero_mat(); 56 | for( int i=0; i!=Dim; ++i ) 57 | for( int j=0; j!=Dim; ++j ) 58 | BOOST_TEST(!m1.a[i][j]); 59 | } 60 | } 61 | 62 | int 63 | main() 64 | { 65 | test<1,2>(); 66 | test<2,1>(); 67 | test<2,2>(); 68 | test<1,3>(); 69 | test<3,1>(); 70 | test<3,3>(); 71 | test<1,4>(); 72 | test<4,1>(); 73 | test<4,4>(); 74 | test<1,5>(); 75 | test<5,1>(); 76 | test<5,5>(); 77 | test<2>(); 78 | test<3>(); 79 | test<4>(); 80 | test<5>(); 81 | return boost::report_errors(); 82 | } 83 | -------------------------------------------------------------------------------- /test/zero_quat_test.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2008-2024 Emil Dotchevski and Reverge Studios, Inc. 2 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 3 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | #ifdef BOOST_QVM_TEST_SINGLE_HEADER 6 | # include BOOST_QVM_TEST_SINGLE_HEADER 7 | #else 8 | # include 9 | #endif 10 | 11 | #include "test_qvm_quaternion.hpp" 12 | 13 | namespace 14 | { 15 | void 16 | test() 17 | { 18 | using namespace boost::qvm; 19 | test_qvm::quaternion v1=zero_quat(); 20 | for( int i=0; i!=4; ++i ) 21 | BOOST_TEST(!v1.a[i]); 22 | test_qvm::quaternion v2(42,1); 23 | set_zero(v2); 24 | for( int i=0; i!=4; ++i ) 25 | BOOST_TEST(!v2.a[i]); 26 | } 27 | } 28 | 29 | int 30 | main() 31 | { 32 | test(); 33 | return boost::report_errors(); 34 | } 35 | -------------------------------------------------------------------------------- /test/zero_vec_test.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2008-2024 Emil Dotchevski and Reverge Studios, Inc. 2 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 3 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | #ifdef BOOST_QVM_TEST_SINGLE_HEADER 6 | # include BOOST_QVM_TEST_SINGLE_HEADER 7 | #else 8 | # include 9 | # include 10 | #endif 11 | 12 | #include "test_qvm_vector.hpp" 13 | 14 | namespace 15 | { 16 | template 17 | struct same_type; 18 | 19 | template 20 | struct 21 | same_type 22 | { 23 | }; 24 | 25 | template 26 | void 27 | check_deduction( T const &, U const & ) 28 | { 29 | same_type::type>(); 30 | } 31 | 32 | template 33 | void 34 | test() 35 | { 36 | using namespace boost::qvm; 37 | test_qvm::vector v1=zero_vec(); 38 | for( int i=0; i!=Dim; ++i ) 39 | BOOST_TEST(!v1.a[i]); 40 | test_qvm::vector v2(42,1); 41 | set_zero(v2); 42 | for( int i=0; i!=Dim; ++i ) 43 | BOOST_TEST(!v2.a[i]); 44 | check_deduction(vec(),zero_vec()); 45 | check_deduction(vec(),zero_vec()); 46 | } 47 | } 48 | 49 | int 50 | main() 51 | { 52 | test<2>(); 53 | test<3>(); 54 | test<4>(); 55 | test<5>(); 56 | return boost::report_errors(); 57 | } 58 | --------------------------------------------------------------------------------