From 622f1976ac886c165e01e1fc6c8d062b86189107 Mon Sep 17 00:00:00 2001 From: Ian Pike Date: Fri, 30 Jun 2023 19:02:41 -0400 Subject: [PATCH 01/14] Update CI to use better versions of clang --- .github/workflows/build.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4e0e81f..504d3fc 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -12,12 +12,14 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - name: init + - name: install g++11 and ninja run: sudo apt install -yqq ninja-build g++-11 + - name: update to clang 16 + run: sudo wget https://apt.llvm.org/llvm.sh && sudo chmod +x llvm.sh && sudo ./llvm.sh 16 - name: configure gcc run: cmake -S . --preset=default -B build -DCMAKE_CXX_COMPILER=g++-11 - name: configure clang - run: cmake -S . --preset=ninja-clang -B clang + run: cmake -S . --preset=ninja-clang -B clang -DCMAKE_CXX_COMPILER=clang++-16 - name: build gcc run: cmake --build build --config=Release - name: build clang @@ -44,6 +46,8 @@ jobs: run: /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" - name: install ninja and gcc run: brew install ninja gcc@11 + - name: update AppleClang to 14.0.3 + run: sudo xcode-select -s /Applications/Xcode_14.3.app/Contents/Developer - name: configure gcc run: cmake -S . --preset=default -B build -DCMAKE_CXX_COMPILER=g++-11 - name: configure clang From 6d42e30a599f8cf4153390906030730e57804a82 Mon Sep 17 00:00:00 2001 From: Rinzii Date: Thu, 13 Jul 2023 16:38:52 -0400 Subject: [PATCH 02/14] Apply rename and build out mat --- include/mim/detail/compute/compute_vector.hpp | 180 ++++---- include/mim/detail/func/func_quaternion.inl | 18 +- include/mim/detail/func/func_vector1.inl | 16 +- include/mim/detail/func/func_vector2.inl | 36 +- include/mim/detail/func/func_vector3.inl | 40 +- include/mim/detail/func/func_vector4.inl | 16 +- include/mim/detail/qualifier.hpp | 6 +- include/mim/detail/type/type_matrix2x2.hpp | 30 +- include/mim/detail/type/type_matrix2x3.hpp | 30 +- include/mim/detail/type/type_matrix2x4.hpp | 30 +- include/mim/detail/type/type_matrix3x2.hpp | 30 +- include/mim/detail/type/type_matrix3x3.hpp | 30 +- include/mim/detail/type/type_matrix3x4.hpp | 1 + include/mim/detail/type/type_matrix4x2.hpp | 30 +- include/mim/detail/type/type_matrix4x3.hpp | 12 +- include/mim/detail/type/type_matrix4x4.hpp | 12 +- include/mim/detail/type/type_quaternion.hpp | 82 ++-- include/mim/detail/type/type_quaternion.inl | 98 ++-- include/mim/detail/type/type_vector1.hpp | 186 ++++---- include/mim/detail/type/type_vector1.inl | 260 +++++------ include/mim/detail/type/type_vector2.hpp | 240 +++++----- include/mim/detail/type/type_vector2.inl | 332 +++++++------- include/mim/detail/type/type_vector3.hpp | 252 +++++----- include/mim/detail/type/type_vector3.inl | 344 +++++++------- include/mim/detail/type/type_vector4.hpp | 288 ++++++------ include/mim/detail/type/type_vector4.inl | 434 +++++++++--------- include/mim/quat.hpp | 6 +- include/mim/vec.hpp | 12 - include/mim/vec1.hpp | 62 +-- include/mim/vec2.hpp | 62 +-- include/mim/vec3.hpp | 56 +-- include/mim/vec4.hpp | 56 +-- 32 files changed, 1721 insertions(+), 1566 deletions(-) diff --git a/include/mim/detail/compute/compute_vector.hpp b/include/mim/detail/compute/compute_vector.hpp index 64afcac..88a86fe 100644 --- a/include/mim/detail/compute/compute_vector.hpp +++ b/include/mim/detail/compute/compute_vector.hpp @@ -19,41 +19,41 @@ namespace mim::detail struct Equal { static constexpr bool compute(T a, T b) { return a == b; } - static constexpr bool compute(VectorT<1, T, Q> const& a, VectorT<1, T, Q> const& b) { return a.x == b.x; } + static constexpr bool compute(vec<1, T, Q> const& a, vec<1, T, Q> const& b) { return a.x == b.x; } - static constexpr bool compute(VectorT<2, T, Q> const& a, VectorT<2, T, Q> const& b) { return a.x == b.x && a.y == b.y; } + static constexpr bool compute(vec<2, T, Q> const& a, vec<2, T, Q> const& b) { return a.x == b.x && a.y == b.y; } - static constexpr bool compute(VectorT<3, T, Q> const& a, VectorT<3, T, Q> const& b) { return a.x == b.x && a.y == b.y && a.z == b.z; } + static constexpr bool compute(vec<3, T, Q> const& a, vec<3, T, Q> const& b) { return a.x == b.x && a.y == b.y && a.z == b.z; } - static constexpr bool compute(VectorT<4, T, Q> const& a, VectorT<4, T, Q> const& b) { return a.x == b.x && a.y == b.y && a.z == b.z && a.w == b.w; } + static constexpr bool compute(vec<4, T, Q> const& a, vec<4, T, Q> const& b) { return a.x == b.x && a.y == b.y && a.z == b.z && a.w == b.w; } }; template struct NotEqual { static constexpr bool compute(T a, T b) { return a != b; } - static constexpr bool compute(VectorT<1, T, Q> const& a, VectorT<1, T, Q> const& b) { return a.x != b.x; } + static constexpr bool compute(vec<1, T, Q> const& a, vec<1, T, Q> const& b) { return a.x != b.x; } - static constexpr bool compute(VectorT<2, T, Q> const& a, VectorT<2, T, Q> const& b) { return a.x != b.x || a.y != b.y; } + static constexpr bool compute(vec<2, T, Q> const& a, vec<2, T, Q> const& b) { return a.x != b.x || a.y != b.y; } - static constexpr bool compute(VectorT<3, T, Q> const& a, VectorT<3, T, Q> const& b) { return a.x != b.x || a.y != b.y || a.z != b.z; } + static constexpr bool compute(vec<3, T, Q> const& a, vec<3, T, Q> const& b) { return a.x != b.x || a.y != b.y || a.z != b.z; } - static constexpr bool compute(VectorT<4, T, Q> const& a, VectorT<4, T, Q> const& b) { return a.x != b.x || a.y != b.y || a.z != b.z || a.w != b.w; } + static constexpr bool compute(vec<4, T, Q> const& a, vec<4, T, Q> const& b) { return a.x != b.x || a.y != b.y || a.z != b.z || a.w != b.w; } }; template struct Add { static constexpr bool compute(T a, T b) { return a + b; } - static constexpr bool compute(VectorT<1, T, Q> const& a, VectorT<1, T, Q> const& b) { return VectorT<1, T, Q>(a.x + b.x); } + static constexpr bool compute(vec<1, T, Q> const& a, vec<1, T, Q> const& b) { return vec<1, T, Q>(a.x + b.x); } - static constexpr bool compute(VectorT<2, T, Q> const& a, VectorT<2, T, Q> const& b) { return VectorT<2, T, Q>(a.x + b.x, a.y + b.y); } + static constexpr bool compute(vec<2, T, Q> const& a, vec<2, T, Q> const& b) { return vec<2, T, Q>(a.x + b.x, a.y + b.y); } - static constexpr bool compute(VectorT<3, T, Q> const& a, VectorT<3, T, Q> const& b) { return VectorT<3, T, Q>(a.x + b.x, a.y + b.y, a.z + b.z); } + static constexpr bool compute(vec<3, T, Q> const& a, vec<3, T, Q> const& b) { return vec<3, T, Q>(a.x + b.x, a.y + b.y, a.z + b.z); } - constexpr static VectorT<4, T, Q> compute(VectorT<4, T, Q> const& a, VectorT<4, T, Q> const& b) + constexpr static vec<4, T, Q> compute(vec<4, T, Q> const& a, vec<4, T, Q> const& b) { - return VectorT<4, T, Q>(a.x + b.x, a.y + b.y, a.z + b.z, a.w + b.w); + return vec<4, T, Q>(a.x + b.x, a.y + b.y, a.z + b.z, a.w + b.w); } }; @@ -61,15 +61,15 @@ namespace mim::detail struct Sub { static constexpr bool compute(T a, T b) { return a - b; } - static constexpr bool compute(VectorT<1, T, Q> const& a, VectorT<1, T, Q> const& b) { return VectorT<1, T, Q>(a.x - b.x); } + static constexpr bool compute(vec<1, T, Q> const& a, vec<1, T, Q> const& b) { return vec<1, T, Q>(a.x - b.x); } - static constexpr bool compute(VectorT<2, T, Q> const& a, VectorT<2, T, Q> const& b) { return VectorT<2, T, Q>(a.x - b.x, a.y - b.y); } + static constexpr bool compute(vec<2, T, Q> const& a, vec<2, T, Q> const& b) { return vec<2, T, Q>(a.x - b.x, a.y - b.y); } - static constexpr bool compute(VectorT<3, T, Q> const& a, VectorT<3, T, Q> const& b) { return VectorT<3, T, Q>(a.x - b.x, a.y - b.y, a.z - b.z); } + static constexpr bool compute(vec<3, T, Q> const& a, vec<3, T, Q> const& b) { return vec<3, T, Q>(a.x - b.x, a.y - b.y, a.z - b.z); } - constexpr static VectorT<4, T, Q> compute(VectorT<4, T, Q> const& a, VectorT<4, T, Q> const& b) + constexpr static vec<4, T, Q> compute(vec<4, T, Q> const& a, vec<4, T, Q> const& b) { - return VectorT<4, T, Q>(a.x - b.x, a.y - b.y, a.z - b.z, a.w - b.w); + return vec<4, T, Q>(a.x - b.x, a.y - b.y, a.z - b.z, a.w - b.w); } }; @@ -77,15 +77,15 @@ namespace mim::detail struct Mul { static constexpr bool compute(T a, T b) { return a * b; } - static constexpr bool compute(VectorT<1, T, Q> const& a, VectorT<1, T, Q> const& b) { return VectorT<1, T, Q>(a.x * b.x); } + static constexpr bool compute(vec<1, T, Q> const& a, vec<1, T, Q> const& b) { return vec<1, T, Q>(a.x * b.x); } - static constexpr bool compute(VectorT<2, T, Q> const& a, VectorT<2, T, Q> const& b) { return VectorT<2, T, Q>(a.x * b.x, a.y * b.y); } + static constexpr bool compute(vec<2, T, Q> const& a, vec<2, T, Q> const& b) { return vec<2, T, Q>(a.x * b.x, a.y * b.y); } - static constexpr bool compute(VectorT<3, T, Q> const& a, VectorT<3, T, Q> const& b) { return VectorT<3, T, Q>(a.x * b.x, a.y * b.y, a.z * b.z); } + static constexpr bool compute(vec<3, T, Q> const& a, vec<3, T, Q> const& b) { return vec<3, T, Q>(a.x * b.x, a.y * b.y, a.z * b.z); } - constexpr static VectorT<4, T, Q> compute(VectorT<4, T, Q> const& a, VectorT<4, T, Q> const& b) + constexpr static vec<4, T, Q> compute(vec<4, T, Q> const& a, vec<4, T, Q> const& b) { - return VectorT<4, T, Q>(a.x * b.x, a.y * b.y, a.z * b.z, a.w * b.w); + return vec<4, T, Q>(a.x * b.x, a.y * b.y, a.z * b.z, a.w * b.w); } }; @@ -93,15 +93,15 @@ namespace mim::detail struct Div { static constexpr bool compute(T a, T b) { return a / b; } - static constexpr bool compute(VectorT<1, T, Q> const& a, VectorT<1, T, Q> const& b) { return VectorT<1, T, Q>(a.x / b.x); } + static constexpr bool compute(vec<1, T, Q> const& a, vec<1, T, Q> const& b) { return vec<1, T, Q>(a.x / b.x); } - static constexpr bool compute(VectorT<2, T, Q> const& a, VectorT<2, T, Q> const& b) { return VectorT<2, T, Q>(a.x / b.x, a.y / b.y); } + static constexpr bool compute(vec<2, T, Q> const& a, vec<2, T, Q> const& b) { return vec<2, T, Q>(a.x / b.x, a.y / b.y); } - static constexpr bool compute(VectorT<3, T, Q> const& a, VectorT<3, T, Q> const& b) { return VectorT<3, T, Q>(a.x / b.x, a.y / b.y, a.z / b.z); } + static constexpr bool compute(vec<3, T, Q> const& a, vec<3, T, Q> const& b) { return vec<3, T, Q>(a.x / b.x, a.y / b.y, a.z / b.z); } - constexpr static VectorT<4, T, Q> compute(VectorT<4, T, Q> const& a, VectorT<4, T, Q> const& b) + constexpr static vec<4, T, Q> compute(vec<4, T, Q> const& a, vec<4, T, Q> const& b) { - return VectorT<4, T, Q>(a.x / b.x, a.y / b.y, a.z / b.z, a.w / b.w); + return vec<4, T, Q>(a.x / b.x, a.y / b.y, a.z / b.z, a.w / b.w); } }; @@ -109,15 +109,15 @@ namespace mim::detail struct Mod { static constexpr bool compute(T a, T b) { return a % b; } - static constexpr bool compute(VectorT<1, T, Q> const& a, VectorT<1, T, Q> const& b) { return VectorT<1, T, Q>(a.x % b.x); } + static constexpr bool compute(vec<1, T, Q> const& a, vec<1, T, Q> const& b) { return vec<1, T, Q>(a.x % b.x); } - static constexpr bool compute(VectorT<2, T, Q> const& a, VectorT<2, T, Q> const& b) { return VectorT<2, T, Q>(a.x % b.x, a.y % b.y); } + static constexpr bool compute(vec<2, T, Q> const& a, vec<2, T, Q> const& b) { return vec<2, T, Q>(a.x % b.x, a.y % b.y); } - static constexpr bool compute(VectorT<3, T, Q> const& a, VectorT<3, T, Q> const& b) { return VectorT<3, T, Q>(a.x % b.x, a.y % b.y, a.z % b.z); } + static constexpr bool compute(vec<3, T, Q> const& a, vec<3, T, Q> const& b) { return vec<3, T, Q>(a.x % b.x, a.y % b.y, a.z % b.z); } - constexpr static VectorT<4, T, Q> compute(VectorT<4, T, Q> const& a, VectorT<4, T, Q> const& b) + constexpr static vec<4, T, Q> compute(vec<4, T, Q> const& a, vec<4, T, Q> const& b) { - return VectorT<4, T, Q>(a.x % b.x, a.y % b.y, a.z % b.z, a.w % b.w); + return vec<4, T, Q>(a.x % b.x, a.y % b.y, a.z % b.z, a.w % b.w); } }; @@ -125,15 +125,15 @@ namespace mim::detail struct BitwiseAnd { static constexpr bool compute(T a, T b) { return a & b; } - static constexpr bool compute(VectorT<1, T, Q> const& a, VectorT<1, T, Q> const& b) { return VectorT<1, T, Q>(a.x & b.x); } + static constexpr bool compute(vec<1, T, Q> const& a, vec<1, T, Q> const& b) { return vec<1, T, Q>(a.x & b.x); } - static constexpr bool compute(VectorT<2, T, Q> const& a, VectorT<2, T, Q> const& b) { return VectorT<2, T, Q>(a.x & b.x, a.y & b.y); } + static constexpr bool compute(vec<2, T, Q> const& a, vec<2, T, Q> const& b) { return vec<2, T, Q>(a.x & b.x, a.y & b.y); } - static constexpr bool compute(VectorT<3, T, Q> const& a, VectorT<3, T, Q> const& b) { return VectorT<3, T, Q>(a.x & b.x, a.y & b.y, a.z & b.z); } + static constexpr bool compute(vec<3, T, Q> const& a, vec<3, T, Q> const& b) { return vec<3, T, Q>(a.x & b.x, a.y & b.y, a.z & b.z); } - constexpr static VectorT<4, T, Q> compute(VectorT<4, T, Q> const& a, VectorT<4, T, Q> const& b) + constexpr static vec<4, T, Q> compute(vec<4, T, Q> const& a, vec<4, T, Q> const& b) { - return VectorT<4, T, Q>(a.x & b.x, a.y & b.y, a.z & b.z, a.w & b.w); + return vec<4, T, Q>(a.x & b.x, a.y & b.y, a.z & b.z, a.w & b.w); } }; @@ -141,15 +141,15 @@ namespace mim::detail struct BitwiseOr { static constexpr bool compute(T a, T b) { return a | b; } - static constexpr bool compute(VectorT<1, T, Q> const& a, VectorT<1, T, Q> const& b) { return VectorT<1, T, Q>(a.x | b.x); } + static constexpr bool compute(vec<1, T, Q> const& a, vec<1, T, Q> const& b) { return vec<1, T, Q>(a.x | b.x); } - static constexpr bool compute(VectorT<2, T, Q> const& a, VectorT<2, T, Q> const& b) { return VectorT<2, T, Q>(a.x | b.x, a.y | b.y); } + static constexpr bool compute(vec<2, T, Q> const& a, vec<2, T, Q> const& b) { return vec<2, T, Q>(a.x | b.x, a.y | b.y); } - static constexpr bool compute(VectorT<3, T, Q> const& a, VectorT<3, T, Q> const& b) { return VectorT<3, T, Q>(a.x | b.x, a.y | b.y, a.z | b.z); } + static constexpr bool compute(vec<3, T, Q> const& a, vec<3, T, Q> const& b) { return vec<3, T, Q>(a.x | b.x, a.y | b.y, a.z | b.z); } - constexpr static VectorT<4, T, Q> compute(VectorT<4, T, Q> const& a, VectorT<4, T, Q> const& b) + constexpr static vec<4, T, Q> compute(vec<4, T, Q> const& a, vec<4, T, Q> const& b) { - return VectorT<4, T, Q>(a.x | b.x, a.y | b.y, a.z | b.z, a.w | b.w); + return vec<4, T, Q>(a.x | b.x, a.y | b.y, a.z | b.z, a.w | b.w); } }; @@ -157,15 +157,15 @@ namespace mim::detail struct Xor { static constexpr bool compute(T a, T b) { return a ^ b; } - static constexpr bool compute(VectorT<1, T, Q> const& a, VectorT<1, T, Q> const& b) { return VectorT<1, T, Q>(a.x ^ b.x); } + static constexpr bool compute(vec<1, T, Q> const& a, vec<1, T, Q> const& b) { return vec<1, T, Q>(a.x ^ b.x); } - static constexpr bool compute(VectorT<2, T, Q> const& a, VectorT<2, T, Q> const& b) { return VectorT<2, T, Q>(a.x ^ b.x, a.y ^ b.y); } + static constexpr bool compute(vec<2, T, Q> const& a, vec<2, T, Q> const& b) { return vec<2, T, Q>(a.x ^ b.x, a.y ^ b.y); } - static constexpr bool compute(VectorT<3, T, Q> const& a, VectorT<3, T, Q> const& b) { return VectorT<3, T, Q>(a.x ^ b.x, a.y ^ b.y, a.z ^ b.z); } + static constexpr bool compute(vec<3, T, Q> const& a, vec<3, T, Q> const& b) { return vec<3, T, Q>(a.x ^ b.x, a.y ^ b.y, a.z ^ b.z); } - constexpr static VectorT<4, T, Q> compute(VectorT<4, T, Q> const& a, VectorT<4, T, Q> const& b) + constexpr static vec<4, T, Q> compute(vec<4, T, Q> const& a, vec<4, T, Q> const& b) { - return VectorT<4, T, Q>(a.x ^ b.x, a.y ^ b.y, a.z ^ b.z, a.w ^ b.w); + return vec<4, T, Q>(a.x ^ b.x, a.y ^ b.y, a.z ^ b.z, a.w ^ b.w); } }; @@ -173,15 +173,15 @@ namespace mim::detail struct ShiftLeft { static constexpr bool compute(T a, T b) { return a << b; } - static constexpr bool compute(VectorT<1, T, Q> const& a, VectorT<1, T, Q> const& b) { return VectorT<1, T, Q>(a.x << b.x); } + static constexpr bool compute(vec<1, T, Q> const& a, vec<1, T, Q> const& b) { return vec<1, T, Q>(a.x << b.x); } - static constexpr bool compute(VectorT<2, T, Q> const& a, VectorT<2, T, Q> const& b) { return VectorT<2, T, Q>(a.x << b.x, a.y << b.y); } + static constexpr bool compute(vec<2, T, Q> const& a, vec<2, T, Q> const& b) { return vec<2, T, Q>(a.x << b.x, a.y << b.y); } - static constexpr bool compute(VectorT<3, T, Q> const& a, VectorT<3, T, Q> const& b) { return VectorT<3, T, Q>(a.x << b.x, a.y << b.y, a.z << b.z); } + static constexpr bool compute(vec<3, T, Q> const& a, vec<3, T, Q> const& b) { return vec<3, T, Q>(a.x << b.x, a.y << b.y, a.z << b.z); } - constexpr static VectorT<4, T, Q> compute(VectorT<4, T, Q> const& v, int shift) + constexpr static vec<4, T, Q> compute(vec<4, T, Q> const& v, int shift) { - return VectorT<4, T, Q>(v.x << shift, v.y << shift, v.z << shift, v.w << shift); + return vec<4, T, Q>(v.x << shift, v.y << shift, v.z << shift, v.w << shift); } }; @@ -189,15 +189,15 @@ namespace mim::detail struct ShiftRight { static constexpr bool compute(T a, T b) { return a >> b; } - static constexpr bool compute(VectorT<1, T, Q> const& a, VectorT<1, T, Q> const& b) { return VectorT<1, T, Q>(a.x >> b.x); } + static constexpr bool compute(vec<1, T, Q> const& a, vec<1, T, Q> const& b) { return vec<1, T, Q>(a.x >> b.x); } - static constexpr bool compute(VectorT<2, T, Q> const& a, VectorT<2, T, Q> const& b) { return VectorT<2, T, Q>(a.x >> b.x, a.y >> b.y); } + static constexpr bool compute(vec<2, T, Q> const& a, vec<2, T, Q> const& b) { return vec<2, T, Q>(a.x >> b.x, a.y >> b.y); } - static constexpr bool compute(VectorT<3, T, Q> const& a, VectorT<3, T, Q> const& b) { return VectorT<3, T, Q>(a.x >> b.x, a.y >> b.y, a.z >> b.z); } + static constexpr bool compute(vec<3, T, Q> const& a, vec<3, T, Q> const& b) { return vec<3, T, Q>(a.x >> b.x, a.y >> b.y, a.z >> b.z); } - constexpr static VectorT<4, T, Q> compute(VectorT<4, T, Q> const& v, int shift) + constexpr static vec<4, T, Q> compute(vec<4, T, Q> const& v, int shift) { - return VectorT<4, T, Q>(v.x >> shift, v.y >> shift, v.z >> shift, v.w >> shift); + return vec<4, T, Q>(v.x >> shift, v.y >> shift, v.z >> shift, v.w >> shift); } }; @@ -205,31 +205,31 @@ namespace mim::detail struct BitwiseNot { static constexpr bool compute(T a) { return ~a; } - static constexpr bool compute(VectorT<1, T, Q> const& v) { return VectorT<1, T, Q>(~v.x); } + static constexpr bool compute(vec<1, T, Q> const& v) { return vec<1, T, Q>(~v.x); } - static constexpr bool compute(VectorT<2, T, Q> const& v) { return VectorT<2, T, Q>(~v.x, ~v.y); } + static constexpr bool compute(vec<2, T, Q> const& v) { return vec<2, T, Q>(~v.x, ~v.y); } - static constexpr bool compute(VectorT<3, T, Q> const& v) { return VectorT<3, T, Q>(~v.x, ~v.y, ~v.z); } + static constexpr bool compute(vec<3, T, Q> const& v) { return vec<3, T, Q>(~v.x, ~v.y, ~v.z); } - constexpr static VectorT<4, T, Q> compute(VectorT<4, T, Q> const& v) { return VectorT<4, T, Q>(~v.x, ~v.y, ~v.z, ~v.w); } + constexpr static vec<4, T, Q> compute(vec<4, T, Q> const& v) { return vec<4, T, Q>(~v.x, ~v.y, ~v.z, ~v.w); } }; template struct Min { static constexpr bool compute(T a, T b) { return min(a, b); } - static constexpr bool compute(VectorT<1, T, Q> const& a, VectorT<1, T, Q> const& b) { return VectorT<1, T, Q>(min(a.x, b.x)); } + static constexpr bool compute(vec<1, T, Q> const& a, vec<1, T, Q> const& b) { return vec<1, T, Q>(min(a.x, b.x)); } - static constexpr bool compute(VectorT<2, T, Q> const& a, VectorT<2, T, Q> const& b) { return VectorT<2, T, Q>(min(a.x, b.x), min(a.y, b.y)); } + static constexpr bool compute(vec<2, T, Q> const& a, vec<2, T, Q> const& b) { return vec<2, T, Q>(min(a.x, b.x), min(a.y, b.y)); } - static constexpr bool compute(VectorT<3, T, Q> const& a, VectorT<3, T, Q> const& b) + static constexpr bool compute(vec<3, T, Q> const& a, vec<3, T, Q> const& b) { - return VectorT<3, T, Q>(min(a.x, b.x), min(a.y, b.y), min(a.z, b.z)); + return vec<3, T, Q>(min(a.x, b.x), min(a.y, b.y), min(a.z, b.z)); } - constexpr static VectorT<4, T, Q> compute(VectorT<4, T, Q> const& a, VectorT<4, T, Q> const& b) + constexpr static vec<4, T, Q> compute(vec<4, T, Q> const& a, vec<4, T, Q> const& b) { - return VectorT<4, T, Q>(min(a.x, b.x), min(a.y, b.y), min(a.z, b.z), min(a.w, b.w)); + return vec<4, T, Q>(min(a.x, b.x), min(a.y, b.y), min(a.z, b.z), min(a.w, b.w)); } }; @@ -237,18 +237,18 @@ namespace mim::detail struct Max { static constexpr bool compute(T a, T b) { return max(a, b); } - static constexpr bool compute(VectorT<1, T, Q> const& a, VectorT<1, T, Q> const& b) { return VectorT<1, T, Q>(max(a.x, b.x)); } + static constexpr bool compute(vec<1, T, Q> const& a, vec<1, T, Q> const& b) { return vec<1, T, Q>(max(a.x, b.x)); } - static constexpr bool compute(VectorT<2, T, Q> const& a, VectorT<2, T, Q> const& b) { return VectorT<2, T, Q>(max(a.x, b.x), max(a.y, b.y)); } + static constexpr bool compute(vec<2, T, Q> const& a, vec<2, T, Q> const& b) { return vec<2, T, Q>(max(a.x, b.x), max(a.y, b.y)); } - static constexpr bool compute(VectorT<3, T, Q> const& a, VectorT<3, T, Q> const& b) + static constexpr bool compute(vec<3, T, Q> const& a, vec<3, T, Q> const& b) { - return VectorT<3, T, Q>(max(a.x, b.x), max(a.y, b.y), max(a.z, b.z)); + return vec<3, T, Q>(max(a.x, b.x), max(a.y, b.y), max(a.z, b.z)); } - constexpr static VectorT<4, T, Q> compute(VectorT<4, T, Q> const& a, VectorT<4, T, Q> const& b) + constexpr static vec<4, T, Q> compute(vec<4, T, Q> const& a, vec<4, T, Q> const& b) { - return VectorT<4, T, Q>(max(a.x, b.x), max(a.y, b.y), max(a.z, b.z), max(a.w, b.w)); + return vec<4, T, Q>(max(a.x, b.x), max(a.y, b.y), max(a.z, b.z), max(a.w, b.w)); } }; @@ -256,52 +256,52 @@ namespace mim::detail struct Abs { static constexpr bool compute(T a) { return abs(a); } - static constexpr bool compute(VectorT<1, T, Q> const& v) { return VectorT<1, T, Q>(abs(v.x)); } + static constexpr bool compute(vec<1, T, Q> const& v) { return vec<1, T, Q>(abs(v.x)); } - static constexpr bool compute(VectorT<2, T, Q> const& v) { return VectorT<2, T, Q>(abs(v.x), abs(v.y)); } + static constexpr bool compute(vec<2, T, Q> const& v) { return vec<2, T, Q>(abs(v.x), abs(v.y)); } - static constexpr bool compute(VectorT<3, T, Q> const& v) { return VectorT<3, T, Q>(abs(v.x), abs(v.y), abs(v.z)); } + static constexpr bool compute(vec<3, T, Q> const& v) { return vec<3, T, Q>(abs(v.x), abs(v.y), abs(v.z)); } - constexpr static VectorT<4, T, Q> compute(VectorT<4, T, Q> const& v) { return VectorT<4, T, Q>(abs(v.x), abs(v.y), abs(v.z), abs(v.w)); } + constexpr static vec<4, T, Q> compute(vec<4, T, Q> const& v) { return vec<4, T, Q>(abs(v.x), abs(v.y), abs(v.z), abs(v.w)); } }; template struct Sign { static constexpr bool compute(T a) { return sign(a); } - static constexpr bool compute(VectorT<1, T, Q> const& v) { return VectorT<1, T, Q>(sign(v.x)); } + static constexpr bool compute(vec<1, T, Q> const& v) { return vec<1, T, Q>(sign(v.x)); } - static constexpr bool compute(VectorT<2, T, Q> const& v) { return VectorT<2, T, Q>(sign(v.x), sign(v.y)); } + static constexpr bool compute(vec<2, T, Q> const& v) { return vec<2, T, Q>(sign(v.x), sign(v.y)); } - static constexpr bool compute(VectorT<3, T, Q> const& v) { return VectorT<3, T, Q>(sign(v.x), sign(v.y), sign(v.z)); } + static constexpr bool compute(vec<3, T, Q> const& v) { return vec<3, T, Q>(sign(v.x), sign(v.y), sign(v.z)); } - constexpr static VectorT<4, T, Q> compute(VectorT<4, T, Q> const& v) { return VectorT<4, T, Q>(sign(v.x), sign(v.y), sign(v.z), sign(v.w)); } + constexpr static vec<4, T, Q> compute(vec<4, T, Q> const& v) { return vec<4, T, Q>(sign(v.x), sign(v.y), sign(v.z), sign(v.w)); } }; template struct Floor { static constexpr bool compute(T a) { return floor(a); } - static constexpr bool compute(VectorT<1, T, Q> const& v) { return VectorT<1, T, Q>(floor(v.x)); } + static constexpr bool compute(vec<1, T, Q> const& v) { return vec<1, T, Q>(floor(v.x)); } - static constexpr bool compute(VectorT<2, T, Q> const& v) { return VectorT<2, T, Q>(floor(v.x), floor(v.y)); } + static constexpr bool compute(vec<2, T, Q> const& v) { return vec<2, T, Q>(floor(v.x), floor(v.y)); } - static constexpr bool compute(VectorT<3, T, Q> const& v) { return VectorT<3, T, Q>(floor(v.x), floor(v.y), floor(v.z)); } + static constexpr bool compute(vec<3, T, Q> const& v) { return vec<3, T, Q>(floor(v.x), floor(v.y), floor(v.z)); } - constexpr static VectorT<4, T, Q> compute(VectorT<4, T, Q> const& v) { return VectorT<4, T, Q>(floor(v.x), floor(v.y), floor(v.z), floor(v.w)); } + constexpr static vec<4, T, Q> compute(vec<4, T, Q> const& v) { return vec<4, T, Q>(floor(v.x), floor(v.y), floor(v.z), floor(v.w)); } }; template struct Ceil { static constexpr bool compute(T a) { return ceil(a); } - static constexpr bool compute(VectorT<1, T, Q> const& v) { return VectorT<1, T, Q>(ceil(v.x)); } + static constexpr bool compute(vec<1, T, Q> const& v) { return vec<1, T, Q>(ceil(v.x)); } - static constexpr bool compute(VectorT<2, T, Q> const& v) { return VectorT<2, T, Q>(ceil(v.x), ceil(v.y)); } + static constexpr bool compute(vec<2, T, Q> const& v) { return vec<2, T, Q>(ceil(v.x), ceil(v.y)); } - static constexpr bool compute(VectorT<3, T, Q> const& v) { return VectorT<3, T, Q>(ceil(v.x), ceil(v.y), ceil(v.z)); } + static constexpr bool compute(vec<3, T, Q> const& v) { return vec<3, T, Q>(ceil(v.x), ceil(v.y), ceil(v.z)); } - constexpr static VectorT<4, T, Q> compute(VectorT<4, T, Q> const& v) { return VectorT<4, T, Q>(ceil(v.x), ceil(v.y), ceil(v.z), ceil(v.w)); } + constexpr static vec<4, T, Q> compute(vec<4, T, Q> const& v) { return vec<4, T, Q>(ceil(v.x), ceil(v.y), ceil(v.z), ceil(v.w)); } }; } // namespace mim::detail diff --git a/include/mim/detail/func/func_quaternion.inl b/include/mim/detail/func/func_quaternion.inl index 9bec6c5..0c8847d 100644 --- a/include/mim/detail/func/func_quaternion.inl +++ b/include/mim/detail/func/func_quaternion.inl @@ -9,13 +9,13 @@ namespace mim { template - constexpr T Quaternion::length() const + constexpr T quat::length() const { return math::sqrt(w * w + x * x + y * y + z * z); } template - constexpr void Quaternion::normalize() + constexpr void quat::normalize() { T len = length(); if (len > 0) @@ -29,32 +29,32 @@ namespace mim } template - constexpr Quaternion Quaternion::normalized() const + constexpr quat quat::normalized() const { T len = length(); if (len > 0) { T invLen = 1 / len; - return Quaternion(w * invLen, x * invLen, y * invLen, z * invLen); + return quat(w * invLen, x * invLen, y * invLen, z * invLen); } - return Quaternion(0, 0, 0, 0); + return quat(0, 0, 0, 0); } template - constexpr bool Quaternion::is_normalized() const + constexpr bool quat::is_normalized() const { return mim::math::abs(length() - 1) < MIM_UNIT_EPSILON; } template - constexpr Quaternion Quaternion::inverse() const + constexpr quat quat::inverse() const { T len = length(); if (len > 0) { T invLen = 1 / len; - return Quaternion(w * invLen, -x * invLen, -y * invLen, -z * invLen); + return quat(w * invLen, -x * invLen, -y * invLen, -z * invLen); } - return Quaternion(0, 0, 0, 0); + return quat(0, 0, 0, 0); } } diff --git a/include/mim/detail/func/func_vector1.inl b/include/mim/detail/func/func_vector1.inl index 32d4702..99bde14 100644 --- a/include/mim/detail/func/func_vector1.inl +++ b/include/mim/detail/func/func_vector1.inl @@ -10,19 +10,19 @@ namespace mim { template - constexpr T VectorT<1, T, Q>::length() const + constexpr T vec<1, T, Q>::length() const { return sqrt(x * x); } template - constexpr T VectorT<1, T, Q>::length_squared() const + constexpr T vec<1, T, Q>::length_squared() const { return x * x; } template - constexpr void VectorT<1, T, Q>::normalize() + constexpr void vec<1, T, Q>::normalize() { static_assert(std::is_floating_point::value, "Cannot normalize a non-floating-point vector."); @@ -35,17 +35,17 @@ namespace mim } template - constexpr VectorT<1, T, Q> VectorT<1, T, Q>::normalized() const + constexpr vec<1, T, Q> vec<1, T, Q>::normalized() const { static_assert(std::is_floating_point::value, "Cannot normalize a non-floating-point vector."); - VectorT<1, T, Q> v = *this; + vec<1, T, Q> v = *this; v.normalize(); return v; } template - constexpr bool VectorT<1, T, Q>::is_normalized() const + constexpr bool vec<1, T, Q>::is_normalized() const { static_assert(std::is_floating_point::value, "Cannot normalize a non-floating-point vector."); @@ -53,13 +53,13 @@ namespace mim } template - constexpr T VectorT<1, T, Q>::distance(const VectorT<1, T, Q>& v) const + constexpr T vec<1, T, Q>::distance(const vec<1, T, Q>& v) const { return mim::math::sqrt(x - v.x); } template - constexpr T VectorT<1, T, Q>::distance_squared(const VectorT<1, T, Q>& v) const + constexpr T vec<1, T, Q>::distance_squared(const vec<1, T, Q>& v) const { return (x - v.x) * (x - v.x); } diff --git a/include/mim/detail/func/func_vector2.inl b/include/mim/detail/func/func_vector2.inl index d707793..ead9826 100644 --- a/include/mim/detail/func/func_vector2.inl +++ b/include/mim/detail/func/func_vector2.inl @@ -10,19 +10,19 @@ namespace mim { template - constexpr T VectorT<2, T, Q>::length() const + constexpr T vec<2, T, Q>::length() const { return sqrt(x * x + y * y); } template - constexpr T VectorT<2, T, Q>::length_squared() const + constexpr T vec<2, T, Q>::length_squared() const { return x * x + y * y; } template - constexpr void VectorT<2, T, Q>::normalize() + constexpr void vec<2, T, Q>::normalize() { static_assert(std::is_floating_point::value, "Cannot normalize a non-floating-point vector."); @@ -36,17 +36,17 @@ namespace mim } template - constexpr VectorT<2, T, Q> VectorT<2, T, Q>::normalized() const + constexpr vec<2, T, Q> vec<2, T, Q>::normalized() const { static_assert(std::is_floating_point::value, "Cannot normalize a non-floating-point vector."); - VectorT<2, T, Q> v = *this; + vec<2, T, Q> v = *this; v.normalize(); return v; } template - constexpr bool VectorT<2, T, Q>::is_normalized() const + constexpr bool vec<2, T, Q>::is_normalized() const { static_assert(std::is_floating_point::value, "Cannot normalize a non-floating-point vector."); @@ -55,13 +55,13 @@ namespace mim } template - constexpr T VectorT<2, T, Q>::distance(const VectorT<2, T, Q>& v) const + constexpr T vec<2, T, Q>::distance(const vec<2, T, Q>& v) const { return mim::math::sqrt((x - v.x) * (x - v.x) + (y - v.y) * (y - v.y)); } template - constexpr T VectorT<2, T, Q>::distance_squared(const VectorT<2, T, Q>& v) const + constexpr T vec<2, T, Q>::distance_squared(const vec<2, T, Q>& v) const { return (x - v.x) * (x - v.x) + (y - v.y) * (y - v.y); } @@ -70,25 +70,25 @@ namespace mim /// Functions template - constexpr T VectorT<2, T, Q>::dot(const VectorT<2, T, Q>& v) const + constexpr T vec<2, T, Q>::dot(const vec<2, T, Q>& v) const { return x * v.x + y * v.y; } template - constexpr T VectorT<2, T, Q>::cross(const VectorT<2, T, Q>& v) const + constexpr T vec<2, T, Q>::cross(const vec<2, T, Q>& v) const { return x * v.y - y * v.x; } // TODO: Make this constexpr once sine and cosine are constexpr. template - VectorT<2, T, Q> VectorT<2, T, Q>::rotated(T angle) const + vec<2, T, Q> vec<2, T, Q>::rotated(T angle) const { T sine = std::sin(angle); T cosi = std::cos(angle); - return VectorT<2, T, Q>( + return vec<2, T, Q>( x * cosi - y * sine, x * sine + y * cosi ); @@ -96,32 +96,32 @@ namespace mim } template - constexpr VectorT<2, T, Q> VectorT<2, T, Q>::clamp(const VectorT<2, T, Q>& min, const VectorT<2, T, Q>& max) const + constexpr vec<2, T, Q> vec<2, T, Q>::clamp(const vec<2, T, Q>& min, const vec<2, T, Q>& max) const { - return VectorT<2, T, Q>( + return vec<2, T, Q>( mim::math::clamp(x, min.x, max.x), mim::math::clamp(y, min.y, max.y) ); } template - constexpr VectorT<2, T, Q> VectorT<2, T, Q>::reflect(const VectorT<2, T, Q>& normal) const + constexpr vec<2, T, Q> vec<2, T, Q>::reflect(const vec<2, T, Q>& normal) const { return T{ 2 } * normal * this->dot(normal) - *this; } template - constexpr VectorT<2, T, Q> VectorT<2, T, Q>::refract(const VectorT<2, T, Q>& normal, T eta) const + constexpr vec<2, T, Q> vec<2, T, Q>::refract(const vec<2, T, Q>& normal, T eta) const { auto K = T{ 1 } - eta * eta * (T{ 1 } - normal.dot(*this) * normal.dot(*this)); if (K < T{ 0 }) - return VectorT<2, T, Q>{ 0 }; + return vec<2, T, Q>{ 0 }; else return eta * *this - (eta * normal.dot(*this) + mim::math::sqrt(K)) * normal; } template - constexpr VectorT<2, T, Q> VectorT<2, T, Q>::project(const VectorT<2, T, Q>& to) const + constexpr vec<2, T, Q> vec<2, T, Q>::project(const vec<2, T, Q>& to) const { return to * (this->dot(to) / to.length_squared()); } diff --git a/include/mim/detail/func/func_vector3.inl b/include/mim/detail/func/func_vector3.inl index 353352e..8bd33ed 100644 --- a/include/mim/detail/func/func_vector3.inl +++ b/include/mim/detail/func/func_vector3.inl @@ -11,19 +11,19 @@ namespace mim { template - constexpr T VectorT<3, T, Q>::length() const + constexpr T vec<3, T, Q>::length() const { return mim::math::sqrt(x * x + y * y + z * z); } template - constexpr T VectorT<3, T, Q>::length_squared() const + constexpr T vec<3, T, Q>::length_squared() const { return x * x + y * y + z * z; } template - constexpr void VectorT<3, T, Q>::normalize() + constexpr void vec<3, T, Q>::normalize() { static_assert(std::is_floating_point::value, "Cannot normalize a non-floating-point vector."); @@ -38,17 +38,17 @@ namespace mim } template - constexpr VectorT<3, T, Q> VectorT<3, T, Q>::normalized() const + constexpr vec<3, T, Q> vec<3, T, Q>::normalized() const { static_assert(std::is_floating_point::value, "Cannot normalize a non-floating-point vector."); - VectorT<3, T, Q> v = *this; + vec<3, T, Q> v = *this; v.normalize(); return v; } template - constexpr bool VectorT<3, T, Q>::is_normalized() const + constexpr bool vec<3, T, Q>::is_normalized() const { static_assert(std::is_floating_point::value, "Cannot normalize a non-floating-point vector."); @@ -57,13 +57,13 @@ namespace mim } template - constexpr T VectorT<3, T, Q>::distance(const VectorT<3, T, Q>& v) const + constexpr T vec<3, T, Q>::distance(const vec<3, T, Q>& v) const { return mim::math::sqrt((x - v.x) * (x - v.x) + (y - v.y) * (y - v.y) + (z - v.z) * (z - v.z)); } template - constexpr T VectorT<3, T, Q>::distance_squared(const VectorT<3, T, Q>& v) const + constexpr T vec<3, T, Q>::distance_squared(const vec<3, T, Q>& v) const { return (x - v.x) * (x - v.x) + (y - v.y) * (y - v.y) + (z - v.z) * (z - v.z); } @@ -72,37 +72,37 @@ namespace mim /// Functions template - constexpr T VectorT<3, T, Q>::dot(const VectorT<3, T, Q>& v) const + constexpr T vec<3, T, Q>::dot(const vec<3, T, Q>& v) const { return x * v.x + y * v.y + z * v.z; } template - constexpr T VectorT<3, T, Q>::cross(const VectorT<3, T, Q>& v) const + constexpr T vec<3, T, Q>::cross(const vec<3, T, Q>& v) const { return x * v.y - y * v.x - z * v.z; } template - constexpr void VectorT<3, T, Q>::rotate(T angle) + constexpr void vec<3, T, Q>::rotate(T angle) { // TODO: Implement rotation of a vec3 using Euler angles. } template - constexpr VectorT<3, T, Q> VectorT<3, T, Q>::rotated(T angle) const + constexpr vec<3, T, Q> vec<3, T, Q>::rotated(T angle) const { - VectorT<3, T, Q> v = *this; + vec<3, T, Q> v = *this; v.rotate(angle); return v; } template - constexpr VectorT<3, T, Q> VectorT<3, T, Q>::clamp(const VectorT<3, T, Q>& min, const VectorT<3, T, Q>& max) const + constexpr vec<3, T, Q> vec<3, T, Q>::clamp(const vec<3, T, Q>& min, const vec<3, T, Q>& max) const { - return VectorT<3, T, Q>( + return vec<3, T, Q>( mim::math::clamp(x, min.x, max.x), mim::math::clamp(y, min.y, max.y), mim::math::clamp(z, min.z, max.z) @@ -110,11 +110,11 @@ namespace mim } template - constexpr VectorT<3, T, Q> VectorT<3, T, Q>::reflect(const VectorT<3, T, Q>& normal) const + constexpr vec<3, T, Q> vec<3, T, Q>::reflect(const vec<3, T, Q>& normal) const { T factor = T{ -2 } * normal.dot(*this); - return VectorT<3, T, Q>( + return vec<3, T, Q>( factor * normal.x + x, factor * normal.y + y, factor * normal.z + z @@ -122,7 +122,7 @@ namespace mim } template - constexpr VectorT<3, T, Q> VectorT<3, T, Q>::refract(const VectorT<3, T, Q>& normal, T eta) const + constexpr vec<3, T, Q> vec<3, T, Q>::refract(const vec<3, T, Q>& normal, T eta) const { // TODO: Validate this function. @@ -131,7 +131,7 @@ namespace mim if (k < T{ 0 }) { - return VectorT<3, T, Q>{}; + return vec<3, T, Q>{}; } else { @@ -140,7 +140,7 @@ namespace mim } template - constexpr VectorT<3, T, Q> VectorT<3, T, Q>::project(const VectorT<3, T, Q>& to) const + constexpr vec<3, T, Q> vec<3, T, Q>::project(const vec<3, T, Q>& to) const { // TODO: Validate this function. return to * (this->dot(to) / to.length_squared()); diff --git a/include/mim/detail/func/func_vector4.inl b/include/mim/detail/func/func_vector4.inl index f2de11b..6947daf 100644 --- a/include/mim/detail/func/func_vector4.inl +++ b/include/mim/detail/func/func_vector4.inl @@ -7,19 +7,19 @@ namespace mim { template - constexpr T VectorT<4, T, Q>::length() const + constexpr T vec<4, T, Q>::length() const { return mim::math::sqrt(x * x + y * y + z * z + w * w); } template - constexpr T VectorT<4, T, Q>::length_squared() const + constexpr T vec<4, T, Q>::length_squared() const { return x * x + y * y + z * z + w * w; } template - constexpr void VectorT<4, T, Q>::normalize() + constexpr void vec<4, T, Q>::normalize() { static_assert(std::is_floating_point::value, "Cannot normalize a non-floating-point vector."); @@ -35,17 +35,17 @@ namespace mim } template - constexpr VectorT<4, T, Q> VectorT<4, T, Q>::normalized() const + constexpr vec<4, T, Q> vec<4, T, Q>::normalized() const { static_assert(std::is_floating_point::value, "Cannot normalize a non-floating-point vector."); - VectorT<4, T, Q> v = *this; + vec<4, T, Q> v = *this; v.normalize(); return v; } template - constexpr bool VectorT<4, T, Q>::is_normalized() const + constexpr bool vec<4, T, Q>::is_normalized() const { static_assert(std::is_floating_point::value, "Cannot normalize a non-floating-point vector."); @@ -54,13 +54,13 @@ namespace mim } template - constexpr T VectorT<4, T, Q>::distance(const VectorT<4, T, Q>& v) const + constexpr T vec<4, T, Q>::distance(const vec<4, T, Q>& v) const { return mim::math::sqrt((x - v.x) * (x - v.x) + (y - v.y) * (y - v.y) + (z - v.z) * (z - v.z) + (w - v.w) * (w - v.w)); } template - constexpr T VectorT<4, T, Q>::distance_squared(const VectorT<4, T, Q>& v) const + constexpr T vec<4, T, Q>::distance_squared(const vec<4, T, Q>& v) const { return (x - v.x) * (x - v.x) + (y - v.y) * (y - v.y) + (z - v.z) * (z - v.z) + (w - v.w) * (w - v.w); } diff --git a/include/mim/detail/qualifier.hpp b/include/mim/detail/qualifier.hpp index 9bb0cb2..d11f15e 100644 --- a/include/mim/detail/qualifier.hpp +++ b/include/mim/detail/qualifier.hpp @@ -37,11 +37,11 @@ namespace mim using precision = qualifier; template - struct VectorT; + struct vec; template - struct MatrixT; + struct mat; template - struct Quaternion; + struct quat; // TODO: Decide what to do with this // Currently I'm planning to move away from this more complex implementation diff --git a/include/mim/detail/type/type_matrix2x2.hpp b/include/mim/detail/type/type_matrix2x2.hpp index 8fa198f..ccfcd85 100644 --- a/include/mim/detail/type/type_matrix2x2.hpp +++ b/include/mim/detail/type/type_matrix2x2.hpp @@ -2,8 +2,36 @@ #pragma once +#include #include "mim/detail/qualifier.hpp" namespace mim { -} + template + struct mat<2, 2, T, Q> { + using type = mat<2, 2, T, Q>; + using row_type = vec<2, T, Q>; + using column_type = vec<2, T, Q>; + using transpose_type = mat<2, 2, T, Q>; + using value_type = T; + using size_type = std::size_t; + static constexpr std::size_t column_size_v = 2; + static constexpr std::size_t row_size_v = 2; + static constexpr T size_v = vec<2, std::size_t, Q>(column_size_v, row_size_v); + + private: + using data = std::array; + + public: + static constexpr size_type size() { return size_v; } + static constexpr size_type row_size() { return row_size_v; } + static constexpr size_type column_size() { return column_size_v; } + + constexpr column_type& operator[](size_type i) noexcept; + constexpr column_type const& operator[](size_type i) const noexcept; + + constexpr row_type row(size_type i) const noexcept; + constexpr column_type column(size_type i) const noexcept; + // constexpr column_type at(size_type i, size_type j) const noexcept; + }; +} // namespace mim diff --git a/include/mim/detail/type/type_matrix2x3.hpp b/include/mim/detail/type/type_matrix2x3.hpp index 8fa198f..3d5445c 100644 --- a/include/mim/detail/type/type_matrix2x3.hpp +++ b/include/mim/detail/type/type_matrix2x3.hpp @@ -2,8 +2,36 @@ #pragma once +#include #include "mim/detail/qualifier.hpp" namespace mim { -} + template + struct mat<2, 3, T, Q> { + using type = mat<2, 3, T, Q>; + using row_type = vec<2, T, Q>; + using column_type = vec<3, T, Q>; + using transpose_type = mat<2, 3, T, Q>; + using value_type = T; + using size_type = std::size_t; + static constexpr std::size_t column_size_v = 2; + static constexpr std::size_t row_size_v = 3; + static constexpr T size_v = vec<2, std::size_t, Q>(column_size_v, row_size_v); + + private: + using data = std::array; + + public: + static constexpr size_type size() { return size_v; } + static constexpr size_type row_size() { return row_size_v; } + static constexpr size_type column_size() { return column_size_v; } + + constexpr column_type& operator[](size_type i) noexcept; + constexpr column_type const& operator[](size_type i) const noexcept; + + constexpr row_type row(size_type i) const noexcept; + constexpr column_type column(size_type i) const noexcept; + // constexpr column_type at(size_type i, size_type j) const noexcept; + }; +} // namespace mim diff --git a/include/mim/detail/type/type_matrix2x4.hpp b/include/mim/detail/type/type_matrix2x4.hpp index 8fa198f..ee35b9a 100644 --- a/include/mim/detail/type/type_matrix2x4.hpp +++ b/include/mim/detail/type/type_matrix2x4.hpp @@ -2,8 +2,36 @@ #pragma once +#include #include "mim/detail/qualifier.hpp" namespace mim { -} + template + struct mat<2, 4, T, Q> { + using type = mat<2, 4, T, Q>; + using row_type = vec<2, T, Q>; + using column_type = vec<4, T, Q>; + using transpose_type = mat<2, 4, T, Q>; + using value_type = T; + using size_type = std::size_t; + static constexpr std::size_t column_size_v = 2; + static constexpr std::size_t row_size_v = 4; + static constexpr T size_v = vec<2, std::size_t, Q>(column_size_v, row_size_v); + + private: + using data = std::array; + + public: + static constexpr size_type size() { return size_v; } + static constexpr size_type row_size() { return row_size_v; } + static constexpr size_type column_size() { return column_size_v; } + + constexpr column_type& operator[](size_type i) noexcept; + constexpr column_type const& operator[](size_type i) const noexcept; + + constexpr row_type row(size_type i) const noexcept; + constexpr column_type column(size_type i) const noexcept; + // constexpr column_type at(size_type i, size_type j) const noexcept; + }; +} // namespace mim diff --git a/include/mim/detail/type/type_matrix3x2.hpp b/include/mim/detail/type/type_matrix3x2.hpp index 8fa198f..5f9aa2e 100644 --- a/include/mim/detail/type/type_matrix3x2.hpp +++ b/include/mim/detail/type/type_matrix3x2.hpp @@ -2,8 +2,36 @@ #pragma once +#include #include "mim/detail/qualifier.hpp" namespace mim { -} + template + struct mat<3, 2, T, Q> { + using type = mat<3, 2, T, Q>; + using row_type = vec<3, T, Q>; + using column_type = vec<2, T, Q>; + using transpose_type = mat<3, 2, T, Q>; + using value_type = T; + using size_type = std::size_t; + static constexpr std::size_t column_size_v = 3; + static constexpr std::size_t row_size_v = 2; + static constexpr T size_v = vec<2, std::size_t, Q>(column_size_v, row_size_v); + + private: + using data = std::array; + + public: + static constexpr size_type size() { return size_v; } + static constexpr size_type row_size() { return row_size_v; } + static constexpr size_type column_size() { return column_size_v; } + + constexpr column_type& operator[](size_type i) noexcept; + constexpr column_type const& operator[](size_type i) const noexcept; + + constexpr row_type row(size_type i) const noexcept; + constexpr column_type column(size_type i) const noexcept; + // constexpr column_type at(size_type i, size_type j) const noexcept; + }; +} // namespace mim diff --git a/include/mim/detail/type/type_matrix3x3.hpp b/include/mim/detail/type/type_matrix3x3.hpp index 8fa198f..c8b406a 100644 --- a/include/mim/detail/type/type_matrix3x3.hpp +++ b/include/mim/detail/type/type_matrix3x3.hpp @@ -2,8 +2,36 @@ #pragma once +#include #include "mim/detail/qualifier.hpp" namespace mim { -} + template + struct mat<3, 3, T, Q> { + using type = mat<3, 3, T, Q>; + using row_type = vec<3, T, Q>; + using column_type = vec<3, T, Q>; + using transpose_type = mat<3, 3, T, Q>; + using value_type = T; + using size_type = std::size_t; + static constexpr std::size_t column_size_v = 3; + static constexpr std::size_t row_size_v = 3; + static constexpr T size_v = vec<2, std::size_t, Q>(column_size_v, row_size_v); + + private: + using data = std::array; + + public: + static constexpr size_type size() { return size_v; } + static constexpr size_type row_size() { return row_size_v; } + static constexpr size_type column_size() { return column_size_v; } + + constexpr column_type& operator[](size_type i) noexcept; + constexpr column_type const& operator[](size_type i) const noexcept; + + constexpr row_type row(size_type i) const noexcept; + constexpr column_type column(size_type i) const noexcept; + // constexpr column_type at(size_type i, size_type j) const noexcept; + }; +} // namespace mim diff --git a/include/mim/detail/type/type_matrix3x4.hpp b/include/mim/detail/type/type_matrix3x4.hpp index 8fa198f..e0c54c3 100644 --- a/include/mim/detail/type/type_matrix3x4.hpp +++ b/include/mim/detail/type/type_matrix3x4.hpp @@ -6,4 +6,5 @@ namespace mim { + } diff --git a/include/mim/detail/type/type_matrix4x2.hpp b/include/mim/detail/type/type_matrix4x2.hpp index 8fa198f..2481cf1 100644 --- a/include/mim/detail/type/type_matrix4x2.hpp +++ b/include/mim/detail/type/type_matrix4x2.hpp @@ -2,8 +2,36 @@ #pragma once +#include #include "mim/detail/qualifier.hpp" namespace mim { -} + template + struct mat<4, 2, T, Q> { + using type = mat<4, 2, T, Q>; + using row_type = vec<4, T, Q>; + using column_type = vec<2, T, Q>; + using transpose_type = mat<4, 2, T, Q>; + using value_type = T; + using size_type = std::size_t; + static constexpr std::size_t column_size_v = 4; + static constexpr std::size_t row_size_v = 2; + static constexpr T size_v = vec<2, std::size_t, Q>(column_size_v, row_size_v); + + private: + using data = std::array; + + public: + static constexpr size_type size() { return size_v; } + static constexpr size_type row_size() { return row_size_v; } + static constexpr size_type column_size() { return column_size_v; } + + constexpr column_type& operator[](size_type i) noexcept; + constexpr column_type const& operator[](size_type i) const noexcept; + + constexpr row_type row(size_type i) const noexcept; + constexpr column_type column(size_type i) const noexcept; + // constexpr column_type at(size_type i, size_type j) const noexcept; + }; +} // namespace mim diff --git a/include/mim/detail/type/type_matrix4x3.hpp b/include/mim/detail/type/type_matrix4x3.hpp index 779423d..8971d9b 100644 --- a/include/mim/detail/type/type_matrix4x3.hpp +++ b/include/mim/detail/type/type_matrix4x3.hpp @@ -8,16 +8,16 @@ namespace mim { template - struct MatrixT<4, 3, T, Q> { - using type = MatrixT<4, 3, T, Q>; - using row_type = VectorT<4, T, Q>; - using column_type = VectorT<3, T, Q>; - using transpose_type = MatrixT<4, 3, T, Q>; + struct mat<4, 3, T, Q> { + using type = mat<4, 3, T, Q>; + using row_type = vec<4, T, Q>; + using column_type = vec<3, T, Q>; + using transpose_type = mat<4, 3, T, Q>; using value_type = T; using size_type = std::size_t; static constexpr std::size_t column_size_v = 4; static constexpr std::size_t row_size_v = 3; - static constexpr T size_v = VectorT<2, std::size_t, Q>(column_size_v, row_size_v); + static constexpr T size_v = vec<2, std::size_t, Q>(column_size_v, row_size_v); private: using data = std::array; diff --git a/include/mim/detail/type/type_matrix4x4.hpp b/include/mim/detail/type/type_matrix4x4.hpp index 85628c5..3080ab9 100644 --- a/include/mim/detail/type/type_matrix4x4.hpp +++ b/include/mim/detail/type/type_matrix4x4.hpp @@ -8,16 +8,16 @@ namespace mim { template - struct MatrixT<4, 4, T, Q> { - using Type = MatrixT<4, 4, T, Q>; - using RowType = VectorT<4, T, Q>; - using ColumnType = VectorT<4, T, Q>; - using TransposeType = MatrixT<4, 4, T, Q>; + struct mat<4, 4, T, Q> { + using Type = mat<4, 4, T, Q>; + using RowType = vec<4, T, Q>; + using ColumnType = vec<4, T, Q>; + using TransposeType = mat<4, 4, T, Q>; using ValueType = T; using SizeType = std::size_t; static constexpr std::size_t RowSizeV = T{4}; static constexpr std::size_t ColumnSizeV = T{4}; - static constexpr T SizeV = VectorT<2, std::size_t, Q>(4); + static constexpr T SizeV = vec<2, std::size_t, Q>(4); private: using Data = std::array; diff --git a/include/mim/detail/type/type_quaternion.hpp b/include/mim/detail/type/type_quaternion.hpp index 1ad7856..210ec10 100644 --- a/include/mim/detail/type/type_quaternion.hpp +++ b/include/mim/detail/type/type_quaternion.hpp @@ -8,9 +8,9 @@ namespace mim { template - struct Quaternion { + struct quat { using value_type = T; - using type = Quaternion; + using type = quat; using size_type = size_t; static constexpr auto sizeV = 4; @@ -21,121 +21,121 @@ namespace mim constexpr T& operator[](size_type i) { - static_assert(i < size(), "Out of range: Quaternion::operator[]"); + static_assert(i < size(), "Out of range: quat::operator[]"); return (&w)[i]; } constexpr T const& operator[](size_type i) const { - static_assert(i < size(), "Out of range: Quaternion::operator[]"); + static_assert(i < size(), "Out of range: quat::operator[]"); return (&w)[i]; } constexpr T const& at(size_type i) const { - static_assert(i < size(), "Out of range: Quaternion::at"); + static_assert(i < size(), "Out of range: quat::at"); return (&w)[i]; } - constexpr Quaternion(); - constexpr Quaternion(Quaternion const&); + constexpr quat(); + constexpr quat(quat const&); template - constexpr explicit Quaternion(Quaternion const& q); + constexpr explicit quat(quat const& q); - constexpr Quaternion(T const& s, VectorT<3, T, Q> const& v); + constexpr quat(T const& s, vec<3, T, Q> const& v); - constexpr Quaternion(T const& w, T const& x, T const& y, T const& z); + constexpr quat(T const& w, T const& x, T const& y, T const& z); template - constexpr explicit Quaternion(Quaternion const& q); + constexpr explicit quat(quat const& q); - explicit operator MatrixT<3, 3, T, Q>() const; - explicit operator MatrixT<4, 4, T, Q>() const; + explicit operator mat<3, 3, T, Q>() const; + explicit operator mat<4, 4, T, Q>() const; - Quaternion(VectorT<3, T, Q> const& a1, VectorT<3, T, Q> const& a2); + quat(vec<3, T, Q> const& a1, vec<3, T, Q> const& a2); - constexpr explicit Quaternion(VectorT<3, T, Q> const& euler); + constexpr explicit quat(vec<3, T, Q> const& euler); /* TODO: Once matrix is implemented bring this back in. - constexpr explicit Quaternion(MatrixT<3, 3, T, Q> const& m); - constexpr explicit Quaternion(MatrixT<4, 4, T, Q> const& m); + constexpr explicit quat(mat<3, 3, T, Q> const& m); + constexpr explicit quat(mat<4, 4, T, Q> const& m); */ - constexpr Quaternion& operator=(Quaternion const& q) = default; + constexpr quat& operator=(quat const& q) = default; template - constexpr Quaternion& operator=(Quaternion const& q); + constexpr quat& operator=(quat const& q); template - constexpr Quaternion& operator+=(Quaternion const& q); + constexpr quat& operator+=(quat const& q); template - constexpr Quaternion& operator-=(Quaternion const& q); + constexpr quat& operator-=(quat const& q); template - constexpr Quaternion& operator*=(Quaternion const& r); + constexpr quat& operator*=(quat const& r); template - constexpr Quaternion& operator*=(U const& scalar); + constexpr quat& operator*=(U const& scalar); template - constexpr Quaternion& operator/=(U const& scalar); + constexpr quat& operator/=(U const& scalar); constexpr T length() const; constexpr void normalize(); - constexpr Quaternion normalized() const; + constexpr quat normalized() const; MIM_NODISCARD constexpr bool is_normalized() const; - constexpr Quaternion inverse() const; + constexpr quat inverse() const; - //VectorT<3, T, Q> get_euler() const; + //vec<3, T, Q> get_euler() const; }; template - constexpr Quaternion operator+(Quaternion const& q); + constexpr quat operator+(quat const& q); template - constexpr Quaternion operator-(Quaternion const& q); + constexpr quat operator-(quat const& q); template - constexpr Quaternion operator+(Quaternion const& q1, Quaternion const& p); + constexpr quat operator+(quat const& q1, quat const& p); template - constexpr Quaternion operator-(Quaternion const& q1, Quaternion const& p); + constexpr quat operator-(quat const& q1, quat const& p); template - constexpr Quaternion operator*(Quaternion const& q1, Quaternion const& p); + constexpr quat operator*(quat const& q1, quat const& p); template - constexpr Quaternion operator*(Quaternion const& q, VectorT<3, T, Q> const& v); + constexpr quat operator*(quat const& q, vec<3, T, Q> const& v); template - constexpr Quaternion operator*(VectorT<3, T, Q> const& v, Quaternion const& q); + constexpr quat operator*(vec<3, T, Q> const& v, quat const& q); template - constexpr Quaternion operator*(Quaternion const& q, VectorT<4, T, Q> const& v); + constexpr quat operator*(quat const& q, vec<4, T, Q> const& v); template - constexpr Quaternion operator*(VectorT<4, T, Q> const& v, Quaternion const& q); + constexpr quat operator*(vec<4, T, Q> const& v, quat const& q); template - constexpr Quaternion operator*(Quaternion const& q, T const& scalar); + constexpr quat operator*(quat const& q, T const& scalar); template - constexpr Quaternion operator*(T const& scalar, Quaternion const& q); + constexpr quat operator*(T const& scalar, quat const& q); template - constexpr Quaternion operator/(Quaternion const& q, T const& scalar); + constexpr quat operator/(quat const& q, T const& scalar); template - constexpr bool operator==(Quaternion const& q1, Quaternion const& p); + constexpr bool operator==(quat const& q1, quat const& p); template - constexpr bool operator!=(Quaternion const& q1, Quaternion const& p); + constexpr bool operator!=(quat const& q1, quat const& p); } // namespace mim diff --git a/include/mim/detail/type/type_quaternion.inl b/include/mim/detail/type/type_quaternion.inl index 9e0eb5b..1b3950e 100644 --- a/include/mim/detail/type/type_quaternion.inl +++ b/include/mim/detail/type/type_quaternion.inl @@ -9,7 +9,7 @@ namespace mim { template - constexpr Quaternion::Quaternion() + constexpr quat::quat() { #if MIM_FORCE_QUATERNION_XYZW x = static_cast(0); @@ -25,7 +25,7 @@ namespace mim } template - constexpr Quaternion::Quaternion(Quaternion const& q) + constexpr quat::quat(quat const& q) { #if MIM_FORCE_QUATERNION_XYZW x = q.x; @@ -42,7 +42,7 @@ namespace mim template template - constexpr Quaternion::Quaternion(Quaternion const& q) + constexpr quat::quat(quat const& q) #if MIM_FORCE_QUATERNION_XYZW : x(q.x), y(q.y), z(q.z), w(q.w) #else @@ -52,7 +52,7 @@ namespace mim } template - constexpr Quaternion::Quaternion(const T& s, const VectorT<3, T, Q>& v) + constexpr quat::quat(const T& s, const vec<3, T, Q>& v) #if MIM_FORCE_QUATERNION_XYZW : x(v.x), y(v.y), z(v.z), w(s) #else @@ -63,16 +63,16 @@ namespace mim template #if MIM_FORCE_QUATERNION_XYZW - constexpr Quaternion::Quaternion(const T& x_, const T& y_, const T& z_, const T& w_) : x(x_), y(y_), z(z_), w(w_) + constexpr quat::quat(const T& x_, const T& y_, const T& z_, const T& w_) : x(x_), y(y_), z(z_), w(w_) #else - constexpr Quaternion::Quaternion(const T& w_, const T& x_, const T& y_, const T& z_) : w(w_), x(x_), y(y_), z(z_) + constexpr quat::quat(const T& w_, const T& x_, const T& y_, const T& z_) : w(w_), x(x_), y(y_), z(z_) #endif { } template template - constexpr Quaternion::Quaternion(Quaternion const& q) + constexpr quat::quat(quat const& q) #if MIM_FORCE_QUATERNION_XYZW : x(static_cast(q.x)), y(static_cast(q.y)), z(static_cast(q.z)), w(static_cast(q.w)) #else @@ -82,41 +82,41 @@ namespace mim } template - Quaternion::operator MatrixT<3, 3, T, Q>() const + quat::operator mat<3, 3, T, Q>() const { - return MatrixT<3, 3, T, Q>(); + return mat<3, 3, T, Q>(); } template - Quaternion::operator MatrixT<4, 4, T, Q>() const + quat::operator mat<4, 4, T, Q>() const { - return MatrixT<4, 4, T, Q>(); + return mat<4, 4, T, Q>(); } template - Quaternion::Quaternion(const VectorT<3, T, Q>& a1, const VectorT<3, T, Q>& a2) + quat::quat(const vec<3, T, Q>& a1, const vec<3, T, Q>& a2) { T normalizeAxis = sqrt(dot(a1, a1) * dot(a2, a2)); T real = normalizeAxis + dot(a1, a2); - VectorT<3, T, Q> tmp; + vec<3, T, Q> tmp; if (real < static_cast(1.e-6f) * normalizeAxis) { // If a1 and a2 are exactly opposite, rotate 180 degrees real = static_cast(0); - tmp = abs(a1.x) > abs(a1.z) ? VectorT<3, T, Q>(-a1.y, a1.x, static_cast(0)) : VectorT<3, T, Q>(static_cast(0), -a1.z, a1.y); + tmp = abs(a1.x) > abs(a1.z) ? vec<3, T, Q>(-a1.y, a1.x, static_cast(0)) : vec<3, T, Q>(static_cast(0), -a1.z, a1.y); } else { // Else, build normal quaternion tmp = cross(a1, a2); } - *this = normalize(Quaternion(real, tmp)); + *this = normalize(quat(real, tmp)); } template - constexpr Quaternion::Quaternion(const VectorT<3, T, Q>& euler) + constexpr quat::quat(const vec<3, T, Q>& euler) { - VectorT<3, T, Q> c = cos(euler * static_cast(0.5)); - VectorT<3, T, Q> s = sin(euler * static_cast(0.5)); + vec<3, T, Q> c = cos(euler * static_cast(0.5)); + vec<3, T, Q> s = sin(euler * static_cast(0.5)); w = c.x * c.y * c.z + s.x * s.y * s.z; x = s.x * c.y * c.z - c.x * s.y * s.z; @@ -126,19 +126,19 @@ namespace mim /* TODO: Once matrix is implemented bring this back in. template - constexpr Quaternion::Quaternion(const MatrixT<3, 3, T, Q>& m) { + constexpr quat::quat(const mat<3, 3, T, Q>& m) { } template - constexpr Quaternion::Quaternion(const MatrixT<4, 4, T, Q>& m) { + constexpr quat::quat(const mat<4, 4, T, Q>& m) { } */ template template - constexpr Quaternion& Quaternion::operator=(const Quaternion& q) + constexpr quat& quat::operator=(const quat& q) { this->x = static_cast(q.w); this->y = static_cast(q.x); @@ -149,7 +149,7 @@ namespace mim template template - constexpr Quaternion& Quaternion::operator+=(const Quaternion& q) + constexpr quat& quat::operator+=(const quat& q) { this->w += static_cast(q.w); this->x += static_cast(q.x); @@ -160,7 +160,7 @@ namespace mim template template - constexpr Quaternion& Quaternion::operator-=(const Quaternion& q) + constexpr quat& quat::operator-=(const quat& q) { this->w -= static_cast(q.w); this->x -= static_cast(q.x); @@ -171,10 +171,10 @@ namespace mim template template - constexpr Quaternion& Quaternion::operator*=(const Quaternion& r) + constexpr quat& quat::operator*=(const quat& r) { - Quaternion p(*this); - Quaternion q(r); + quat p(*this); + quat q(r); this->w = p.w * q.w - p.x * q.x - p.y * q.y - p.z * q.z; this->x = p.w * q.x + p.x * q.w + p.y * q.z - p.z * q.y; @@ -185,14 +185,14 @@ namespace mim template template - constexpr Quaternion& Quaternion::operator/=(const U& scalar) + constexpr quat& quat::operator/=(const U& scalar) { return *this *= static_cast(1) / scalar; } template template - constexpr Quaternion& Quaternion::operator*=(const U& scalar) + constexpr quat& quat::operator*=(const U& scalar) { this->x *= scalar; this->y *= scalar; @@ -202,77 +202,77 @@ namespace mim } template - constexpr Quaternion operator+(const Quaternion& q) + constexpr quat operator+(const quat& q) { return q; } template - constexpr Quaternion operator-(Quaternion const& q) + constexpr quat operator-(quat const& q) { - return Quaternion(-q.w, -q.x, -q.y, -q.z); + return quat(-q.w, -q.x, -q.y, -q.z); } template - constexpr Quaternion operator+(Quaternion const& q, Quaternion const& p) + constexpr quat operator+(quat const& q, quat const& p) { - return Quaternion(q) += p; + return quat(q) += p; } template - constexpr Quaternion operator-(Quaternion const& q, Quaternion const& p) + constexpr quat operator-(quat const& q, quat const& p) { - return Quaternion(q) -= p; + return quat(q) -= p; } template - constexpr Quaternion operator*(Quaternion const& q, Quaternion const& p) + constexpr quat operator*(quat const& q, quat const& p) { - return Quaternion(q) *= p; + return quat(q) *= p; } template - constexpr Quaternion operator*(Quaternion const& q, VectorT<3, T, Q> const& v) + constexpr quat operator*(quat const& q, vec<3, T, Q> const& v) { - VectorT<3, T, Q> const QuatVector(q.x, q.y, q.z); - VectorT<3, T, Q> const uv(cross(QuatVector, v)); - VectorT<3, T, Q> const uuv(cross(QuatVector, uv)); + vec<3, T, Q> const QuatVector(q.x, q.y, q.z); + vec<3, T, Q> const uv(cross(QuatVector, v)); + vec<3, T, Q> const uuv(cross(QuatVector, uv)); return v + ((uv * q.w) + uuv) * static_cast(2); } template - constexpr Quaternion operator*(VectorT<3, T, Q> const& v, Quaternion const& q) + constexpr quat operator*(vec<3, T, Q> const& v, quat const& q) { inverse(q) * v; } template - constexpr Quaternion operator*(Quaternion const& q, T const& scalar) + constexpr quat operator*(quat const& q, T const& scalar) { - return Quaternion(q.w * scalar, q.x * scalar, q.y * scalar, q.z * scalar); + return quat(q.w * scalar, q.x * scalar, q.y * scalar, q.z * scalar); } template - constexpr Quaternion operator*(T const& scalar, Quaternion const& q) + constexpr quat operator*(T const& scalar, quat const& q) { return q * scalar; } template - constexpr Quaternion operator/(Quaternion const& q, T const& scalar) + constexpr quat operator/(quat const& q, T const& scalar) { - return Quaternion(q.w / scalar, q.x / scalar, q.y / scalar, q.z / scalar); + return quat(q.w / scalar, q.x / scalar, q.y / scalar, q.z / scalar); } template - constexpr bool operator==(Quaternion const& q, Quaternion const& p) + constexpr bool operator==(quat const& q, quat const& p) { return q.w == p.w && q.x == p.x && q.y == p.y && q.z == p.z; } template - constexpr bool operator!=(Quaternion const& q, Quaternion const& p) + constexpr bool operator!=(quat const& q, quat const& p) { return !(q == p); } diff --git a/include/mim/detail/type/type_vector1.hpp b/include/mim/detail/type/type_vector1.hpp index 2c20db2..9952f50 100644 --- a/include/mim/detail/type/type_vector1.hpp +++ b/include/mim/detail/type/type_vector1.hpp @@ -13,11 +13,11 @@ namespace mim { template - struct VectorT<1, T, Q> { + struct vec<1, T, Q> { /// Aliases using value_type = T; - using type = VectorT<1, T, Q>; + using type = vec<1, T, Q>; using size_type = size_t; static constexpr auto size_v = 1; @@ -40,157 +40,157 @@ namespace mim /// Constructors - constexpr VectorT(); + constexpr vec(); - constexpr VectorT(VectorT<1, T, Q> const& v); + constexpr vec(vec<1, T, Q> const& v); - constexpr explicit VectorT(T scalar); + constexpr explicit vec(T scalar); /// Template Constructors template - constexpr explicit VectorT(VectorT<1, T, P> const& v); + constexpr explicit vec(vec<1, T, P> const& v); template - constexpr explicit VectorT(U scalar); + constexpr explicit vec(U scalar); template - constexpr explicit VectorT(VectorT<1, U, P> const& v); + constexpr explicit vec(vec<1, U, P> const& v); template - constexpr explicit VectorT(VectorT<2, U, P> const& v); + constexpr explicit vec(vec<2, U, P> const& v); template - constexpr explicit VectorT(VectorT<3, U, P> const& v); + constexpr explicit vec(vec<3, U, P> const& v); template - constexpr explicit VectorT(VectorT<4, U, P> const& v); + constexpr explicit vec(vec<4, U, P> const& v); /// Assignment Operators - constexpr VectorT<1, T, Q>& operator=(T scalar); + constexpr vec<1, T, Q>& operator=(T scalar); - constexpr VectorT<1, T, Q>& operator=(VectorT<1, T, Q> const& v); + constexpr vec<1, T, Q>& operator=(vec<1, T, Q> const& v); template - constexpr VectorT<1, T, Q>& operator=(VectorT<1, U, Q> const& v); + constexpr vec<1, T, Q>& operator=(vec<1, U, Q> const& v); template - constexpr VectorT<1, T, Q>& operator=(VectorT<2, U, Q> const& v); + constexpr vec<1, T, Q>& operator=(vec<2, U, Q> const& v); template - constexpr VectorT<1, T, Q>& operator=(VectorT<3, U, Q> const& v); + constexpr vec<1, T, Q>& operator=(vec<3, U, Q> const& v); template - constexpr VectorT<1, T, Q>& operator=(VectorT<4, U, Q> const& v); + constexpr vec<1, T, Q>& operator=(vec<4, U, Q> const& v); template - constexpr VectorT<1, T, Q>& operator+=(U scalar); + constexpr vec<1, T, Q>& operator+=(U scalar); template - constexpr VectorT<1, T, Q>& operator+=(VectorT<1, U, Q> const& v); + constexpr vec<1, T, Q>& operator+=(vec<1, U, Q> const& v); template - constexpr VectorT<1, T, Q>& operator+=(VectorT<2, U, Q> const& v); + constexpr vec<1, T, Q>& operator+=(vec<2, U, Q> const& v); template - constexpr VectorT<1, T, Q>& operator+=(VectorT<3, U, Q> const& v); + constexpr vec<1, T, Q>& operator+=(vec<3, U, Q> const& v); template - constexpr VectorT<1, T, Q>& operator+=(VectorT<4, U, Q> const& v); + constexpr vec<1, T, Q>& operator+=(vec<4, U, Q> const& v); template - constexpr VectorT<1, T, Q>& operator-=(U scalar); + constexpr vec<1, T, Q>& operator-=(U scalar); template - constexpr VectorT<1, T, Q>& operator-=(VectorT<1, U, Q> const& v); + constexpr vec<1, T, Q>& operator-=(vec<1, U, Q> const& v); template - constexpr VectorT<1, T, Q>& operator-=(VectorT<2, U, Q> const& v); + constexpr vec<1, T, Q>& operator-=(vec<2, U, Q> const& v); template - constexpr VectorT<1, T, Q>& operator-=(VectorT<3, U, Q> const& v); + constexpr vec<1, T, Q>& operator-=(vec<3, U, Q> const& v); template - constexpr VectorT<1, T, Q>& operator-=(VectorT<4, U, Q> const& v); + constexpr vec<1, T, Q>& operator-=(vec<4, U, Q> const& v); template - constexpr VectorT<1, T, Q>& operator*=(U scalar); + constexpr vec<1, T, Q>& operator*=(U scalar); template - constexpr VectorT<1, T, Q>& operator*=(VectorT<1, U, Q> const& v); + constexpr vec<1, T, Q>& operator*=(vec<1, U, Q> const& v); template - constexpr VectorT<1, T, Q>& operator*=(VectorT<2, U, Q> const& v); + constexpr vec<1, T, Q>& operator*=(vec<2, U, Q> const& v); template - constexpr VectorT<1, T, Q>& operator*=(VectorT<3, U, Q> const& v); + constexpr vec<1, T, Q>& operator*=(vec<3, U, Q> const& v); template - constexpr VectorT<1, T, Q>& operator*=(VectorT<4, U, Q> const& v); + constexpr vec<1, T, Q>& operator*=(vec<4, U, Q> const& v); template - constexpr VectorT<1, T, Q>& operator/=(U scalar); + constexpr vec<1, T, Q>& operator/=(U scalar); template - constexpr VectorT<1, T, Q>& operator/=(VectorT<1, U, Q> const& v); + constexpr vec<1, T, Q>& operator/=(vec<1, U, Q> const& v); template - constexpr VectorT<1, T, Q>& operator/=(VectorT<2, U, Q> const& v); + constexpr vec<1, T, Q>& operator/=(vec<2, U, Q> const& v); template - constexpr VectorT<1, T, Q>& operator/=(VectorT<3, U, Q> const& v); + constexpr vec<1, T, Q>& operator/=(vec<3, U, Q> const& v); template - constexpr VectorT<1, T, Q>& operator/=(VectorT<4, U, Q> const& v); + constexpr vec<1, T, Q>& operator/=(vec<4, U, Q> const& v); template - constexpr VectorT<1, T, Q>& operator%=(U scalar); + constexpr vec<1, T, Q>& operator%=(U scalar); template - constexpr VectorT<1, T, Q>& operator%=(VectorT<1, U, Q> const& v); + constexpr vec<1, T, Q>& operator%=(vec<1, U, Q> const& v); /// Increment and Decrement Operators - constexpr VectorT<1, T, Q>& operator++(); + constexpr vec<1, T, Q>& operator++(); - constexpr VectorT<1, T, Q>& operator--(); + constexpr vec<1, T, Q>& operator--(); - constexpr const VectorT<1, T, Q> operator++(int); + constexpr const vec<1, T, Q> operator++(int); - constexpr const VectorT<1, T, Q> operator--(int); + constexpr const vec<1, T, Q> operator--(int); /// Bitwise Assignment Operators template - constexpr VectorT<1, T, Q>& operator&=(U scalar); + constexpr vec<1, T, Q>& operator&=(U scalar); template - constexpr VectorT<1, T, Q>& operator&=(VectorT<1, U, Q> const& v); + constexpr vec<1, T, Q>& operator&=(vec<1, U, Q> const& v); template - constexpr VectorT<1, T, Q>& operator|=(U scalar); + constexpr vec<1, T, Q>& operator|=(U scalar); template - constexpr VectorT<1, T, Q>& operator|=(VectorT<1, U, Q> const& v); + constexpr vec<1, T, Q>& operator|=(vec<1, U, Q> const& v); template - constexpr VectorT<1, T, Q>& operator^=(U scalar); + constexpr vec<1, T, Q>& operator^=(U scalar); template - constexpr VectorT<1, T, Q>& operator^=(VectorT<1, U, Q> const& v); + constexpr vec<1, T, Q>& operator^=(vec<1, U, Q> const& v); template - constexpr VectorT<1, T, Q>& operator<<=(U scalar); + constexpr vec<1, T, Q>& operator<<=(U scalar); template - constexpr VectorT<1, T, Q>& operator<<=(VectorT<1, U, Q> const& v); + constexpr vec<1, T, Q>& operator<<=(vec<1, U, Q> const& v); template - constexpr VectorT<1, T, Q>& operator>>=(U scalar); + constexpr vec<1, T, Q>& operator>>=(U scalar); template - constexpr VectorT<1, T, Q>& operator>>=(VectorT<1, U, Q> const& v); + constexpr vec<1, T, Q>& operator>>=(vec<1, U, Q> const& v); /// Function Declarations @@ -201,13 +201,13 @@ namespace mim constexpr void normalize(); - constexpr VectorT<1, T, Q> normalized() const; + constexpr vec<1, T, Q> normalized() const; MIM_NODISCARD constexpr bool is_normalized() const; - constexpr T distance(const VectorT<1, T, Q>& v) const; + constexpr T distance(const vec<1, T, Q>& v) const; - constexpr T distance_squared(const VectorT<1, T, Q>& v) const; + constexpr T distance_squared(const vec<1, T, Q>& v) const; @@ -216,121 +216,121 @@ namespace mim /// Unary Operators template - constexpr VectorT<1, T, Q> operator+(VectorT<1, T, Q> const& v); + constexpr vec<1, T, Q> operator+(vec<1, T, Q> const& v); template - constexpr VectorT<1, T, Q> operator-(VectorT<1, T, Q> const& v); + constexpr vec<1, T, Q> operator-(vec<1, T, Q> const& v); /// Binary Operators template - constexpr VectorT<1, T, Q> operator+(VectorT<1, T, Q> const& v, T scalar); + constexpr vec<1, T, Q> operator+(vec<1, T, Q> const& v, T scalar); template - constexpr VectorT<1, T, Q> operator+(T scalar, VectorT<1, T, Q> const& v); + constexpr vec<1, T, Q> operator+(T scalar, vec<1, T, Q> const& v); template - constexpr VectorT<1, T, Q> operator+(VectorT<1, T, Q> const& v1, VectorT<1, T, Q> const& v2); + constexpr vec<1, T, Q> operator+(vec<1, T, Q> const& v1, vec<1, T, Q> const& v2); template - constexpr VectorT<1, T, Q> operator-(VectorT<1, T, Q> const& v, T scalar); + constexpr vec<1, T, Q> operator-(vec<1, T, Q> const& v, T scalar); template - constexpr VectorT<1, T, Q> operator-(T scalar, VectorT<1, T, Q> const& v); + constexpr vec<1, T, Q> operator-(T scalar, vec<1, T, Q> const& v); template - constexpr VectorT<1, T, Q> operator-(VectorT<1, T, Q> const& v1, VectorT<1, T, Q> const& v2); + constexpr vec<1, T, Q> operator-(vec<1, T, Q> const& v1, vec<1, T, Q> const& v2); template - constexpr VectorT<1, T, Q> operator*(VectorT<1, T, Q> const& v, T scalar); + constexpr vec<1, T, Q> operator*(vec<1, T, Q> const& v, T scalar); template - constexpr VectorT<1, T, Q> operator*(T scalar, VectorT<1, T, Q> const& v); + constexpr vec<1, T, Q> operator*(T scalar, vec<1, T, Q> const& v); template - constexpr VectorT<1, T, Q> operator*(VectorT<1, T, Q> const& v1, VectorT<1, T, Q> const& v2); + constexpr vec<1, T, Q> operator*(vec<1, T, Q> const& v1, vec<1, T, Q> const& v2); template - constexpr VectorT<1, T, Q> operator/(VectorT<1, T, Q> const& v, T scalar); + constexpr vec<1, T, Q> operator/(vec<1, T, Q> const& v, T scalar); template - constexpr VectorT<1, T, Q> operator/(T scalar, VectorT<1, T, Q> const& v); + constexpr vec<1, T, Q> operator/(T scalar, vec<1, T, Q> const& v); template - constexpr VectorT<1, T, Q> operator/(VectorT<1, T, Q> const& v1, VectorT<1, T, Q> const& v2); + constexpr vec<1, T, Q> operator/(vec<1, T, Q> const& v1, vec<1, T, Q> const& v2); template - constexpr VectorT<1, T, Q> operator%(VectorT<1, T, Q> const& v, T scalar); + constexpr vec<1, T, Q> operator%(vec<1, T, Q> const& v, T scalar); template - constexpr VectorT<1, T, Q> operator%(T scalar, VectorT<1, T, Q> const& v); + constexpr vec<1, T, Q> operator%(T scalar, vec<1, T, Q> const& v); template - constexpr VectorT<1, T, Q> operator%(VectorT<1, T, Q> const& v1, VectorT<1, T, Q> const& v2); + constexpr vec<1, T, Q> operator%(vec<1, T, Q> const& v1, vec<1, T, Q> const& v2); /// Bitwise Binary Operators template - constexpr VectorT<1, T, Q> operator&(VectorT<1, T, Q> const& v, T scalar); + constexpr vec<1, T, Q> operator&(vec<1, T, Q> const& v, T scalar); template - constexpr VectorT<1, T, Q> operator&(T scalar, VectorT<1, T, Q> const& v); + constexpr vec<1, T, Q> operator&(T scalar, vec<1, T, Q> const& v); template - constexpr VectorT<1, T, Q> operator&(VectorT<1, T, Q> const& v1, VectorT<1, T, Q> const& v2); + constexpr vec<1, T, Q> operator&(vec<1, T, Q> const& v1, vec<1, T, Q> const& v2); template - constexpr VectorT<1, T, Q> operator|(VectorT<1, T, Q> const& v, T scalar); + constexpr vec<1, T, Q> operator|(vec<1, T, Q> const& v, T scalar); template - constexpr VectorT<1, T, Q> operator|(T scalar, VectorT<1, T, Q> const& v); + constexpr vec<1, T, Q> operator|(T scalar, vec<1, T, Q> const& v); template - constexpr VectorT<1, T, Q> operator|(VectorT<1, T, Q> const& v1, VectorT<1, T, Q> const& v2); + constexpr vec<1, T, Q> operator|(vec<1, T, Q> const& v1, vec<1, T, Q> const& v2); template - constexpr VectorT<1, T, Q> operator^(VectorT<1, T, Q> const& v, T scalar); + constexpr vec<1, T, Q> operator^(vec<1, T, Q> const& v, T scalar); template - constexpr VectorT<1, T, Q> operator^(T scalar, VectorT<1, T, Q> const& v); + constexpr vec<1, T, Q> operator^(T scalar, vec<1, T, Q> const& v); template - constexpr VectorT<1, T, Q> operator^(VectorT<1, T, Q> const& v1, VectorT<1, T, Q> const& v2); + constexpr vec<1, T, Q> operator^(vec<1, T, Q> const& v1, vec<1, T, Q> const& v2); template - constexpr VectorT<1, T, Q> operator<<(VectorT<1, T, Q> const& v, T scalar); + constexpr vec<1, T, Q> operator<<(vec<1, T, Q> const& v, T scalar); template - constexpr VectorT<1, T, Q> operator<<(T scalar, VectorT<1, T, Q> const& v); + constexpr vec<1, T, Q> operator<<(T scalar, vec<1, T, Q> const& v); template - constexpr VectorT<1, T, Q> operator<<(VectorT<1, T, Q> const& v1, VectorT<1, T, Q> const& v2); + constexpr vec<1, T, Q> operator<<(vec<1, T, Q> const& v1, vec<1, T, Q> const& v2); template - constexpr VectorT<1, T, Q> operator>>(VectorT<1, T, Q> const& v, T scalar); + constexpr vec<1, T, Q> operator>>(vec<1, T, Q> const& v, T scalar); template - constexpr VectorT<1, T, Q> operator>>(T scalar, VectorT<1, T, Q> const& v); + constexpr vec<1, T, Q> operator>>(T scalar, vec<1, T, Q> const& v); template - constexpr VectorT<1, T, Q> operator>>(VectorT<1, T, Q> const& v1, VectorT<1, T, Q> const& v2); + constexpr vec<1, T, Q> operator>>(vec<1, T, Q> const& v1, vec<1, T, Q> const& v2); template - constexpr VectorT<1, T, Q> operator~(VectorT<1, T, Q> const& v); + constexpr vec<1, T, Q> operator~(vec<1, T, Q> const& v); /// Comparison Operators template - constexpr bool operator==(VectorT<1, T, Q> const& v1, VectorT<1, T, Q> const& v2); + constexpr bool operator==(vec<1, T, Q> const& v1, vec<1, T, Q> const& v2); template - constexpr bool operator!=(VectorT<1, T, Q> const& v1, VectorT<1, T, Q> const& v2); + constexpr bool operator!=(vec<1, T, Q> const& v1, vec<1, T, Q> const& v2); template - constexpr bool operator&&(VectorT<1, bool, Q> const& v1, VectorT<1, bool, Q> const& v2); + constexpr bool operator&&(vec<1, bool, Q> const& v1, vec<1, bool, Q> const& v2); template - constexpr bool operator||(VectorT<1, bool, Q> const& v1, VectorT<1, bool, Q> const& v2); + constexpr bool operator||(vec<1, bool, Q> const& v1, vec<1, bool, Q> const& v2); } // namespace mim diff --git a/include/mim/detail/type/type_vector1.inl b/include/mim/detail/type/type_vector1.inl index f7561bc..4fb0114 100644 --- a/include/mim/detail/type/type_vector1.inl +++ b/include/mim/detail/type/type_vector1.inl @@ -9,29 +9,29 @@ namespace mim // Element Accessors template - constexpr T& VectorT<1, T, Q>::operator[](typename VectorT<1, T, Q>::size_type) + constexpr T& vec<1, T, Q>::operator[](typename vec<1, T, Q>::size_type) { return x; } template - constexpr const T& VectorT<1, T, Q>::operator[](typename VectorT<1, T, Q>::size_type) const + constexpr const T& vec<1, T, Q>::operator[](typename vec<1, T, Q>::size_type) const { return x; } template - T& VectorT<1, T, Q>::at(typename VectorT<1, T, Q>::size_type i) + T& vec<1, T, Q>::at(typename vec<1, T, Q>::size_type i) { - static_assert(i < size(), "VectorT<1, T, Q>::at() : Index out of range."); + static_assert(i < size(), "vec<1, T, Q>::at() : Index out of range."); return x; } template - const T& VectorT<1, T, Q>::at(typename VectorT<1, T, Q>::size_type i) const + const T& vec<1, T, Q>::at(typename vec<1, T, Q>::size_type i) const { - static_assert(i < size(), "VectorT<1, T, Q>::at() : Index out of range."); + static_assert(i < size(), "vec<1, T, Q>::at() : Index out of range."); return x; } @@ -39,17 +39,17 @@ namespace mim /// Constructors template - constexpr VectorT<1, T, Q>::VectorT() : x(0) + constexpr vec<1, T, Q>::vec() : x(0) { } template - constexpr VectorT<1, T, Q>::VectorT(VectorT<1, T, Q> const& v) : x(v.x) + constexpr vec<1, T, Q>::vec(vec<1, T, Q> const& v) : x(v.x) { } template - constexpr VectorT<1, T, Q>::VectorT(T scalar) : x(scalar) + constexpr vec<1, T, Q>::vec(T scalar) : x(scalar) { } @@ -57,7 +57,7 @@ namespace mim template template - constexpr VectorT<1, T, Q>::VectorT(VectorT<1, T, P> const& v) : x(v.x) + constexpr vec<1, T, Q>::vec(vec<1, T, P> const& v) : x(v.x) { } @@ -65,45 +65,45 @@ namespace mim template template - constexpr VectorT<1, T, Q>::VectorT(U scalar) : x(static_cast(scalar)) + constexpr vec<1, T, Q>::vec(U scalar) : x(static_cast(scalar)) { } template template - constexpr VectorT<1, T, Q>::VectorT(VectorT<1, U, P> const& v) : x(static_cast(v.x)) + constexpr vec<1, T, Q>::vec(vec<1, U, P> const& v) : x(static_cast(v.x)) { } template template - constexpr VectorT<1, T, Q>::VectorT(VectorT<2, U, P> const& v) : x(static_cast(v.x)) + constexpr vec<1, T, Q>::vec(vec<2, U, P> const& v) : x(static_cast(v.x)) { } template template - constexpr VectorT<1, T, Q>::VectorT(VectorT<3, U, P> const& v) : x(static_cast(v.x)) + constexpr vec<1, T, Q>::vec(vec<3, U, P> const& v) : x(static_cast(v.x)) { } template template - constexpr VectorT<1, T, Q>::VectorT(VectorT<4, U, P> const& v) : x(static_cast(v.x)) + constexpr vec<1, T, Q>::vec(vec<4, U, P> const& v) : x(static_cast(v.x)) { } // Assignment Operators template - constexpr VectorT<1, T, Q>& VectorT<1, T, Q>::operator=(T scalar) + constexpr vec<1, T, Q>& vec<1, T, Q>::operator=(T scalar) { this->x = scalar; return *this; } template - constexpr VectorT<1, T, Q>& VectorT<1, T, Q>::operator=(VectorT const& v) + constexpr vec<1, T, Q>& vec<1, T, Q>::operator=(vec const& v) { this->x = v.x; return *this; @@ -111,7 +111,7 @@ namespace mim template template - constexpr VectorT<1, T, Q>& VectorT<1, T, Q>::operator=(VectorT<1, U, Q> const& v) + constexpr vec<1, T, Q>& vec<1, T, Q>::operator=(vec<1, U, Q> const& v) { this->x = static_cast(v.x); return *this; @@ -119,7 +119,7 @@ namespace mim template template - constexpr VectorT<1, T, Q>& VectorT<1, T, Q>::operator=(VectorT<2, U, Q> const& v) + constexpr vec<1, T, Q>& vec<1, T, Q>::operator=(vec<2, U, Q> const& v) { this->x = static_cast(v.x); return *this; @@ -127,7 +127,7 @@ namespace mim template template - constexpr VectorT<1, T, Q>& VectorT<1, T, Q>::operator=(VectorT<3, U, Q> const& v) + constexpr vec<1, T, Q>& vec<1, T, Q>::operator=(vec<3, U, Q> const& v) { this->x = static_cast(v.x); return *this; @@ -135,7 +135,7 @@ namespace mim template template - constexpr VectorT<1, T, Q>& VectorT<1, T, Q>::operator=(VectorT<4, U, Q> const& v) + constexpr vec<1, T, Q>& vec<1, T, Q>::operator=(vec<4, U, Q> const& v) { this->x = static_cast(v.x); return *this; @@ -143,7 +143,7 @@ namespace mim template template - constexpr VectorT<1, T, Q>& VectorT<1, T, Q>::operator+=(U scalar) + constexpr vec<1, T, Q>& vec<1, T, Q>::operator+=(U scalar) { this->x += static_cast(scalar); return *this; @@ -151,7 +151,7 @@ namespace mim template template - constexpr VectorT<1, T, Q>& VectorT<1, T, Q>::operator+=(VectorT<1, U, Q> const& v) + constexpr vec<1, T, Q>& vec<1, T, Q>::operator+=(vec<1, U, Q> const& v) { this->x += static_cast(v.x); return *this; @@ -159,7 +159,7 @@ namespace mim template template - constexpr VectorT<1, T, Q>& VectorT<1, T, Q>::operator+=(VectorT<2, U, Q> const& v) + constexpr vec<1, T, Q>& vec<1, T, Q>::operator+=(vec<2, U, Q> const& v) { this->x += static_cast(v.x); return *this; @@ -167,7 +167,7 @@ namespace mim template template - constexpr VectorT<1, T, Q>& VectorT<1, T, Q>::operator+=(VectorT<3, U, Q> const& v) + constexpr vec<1, T, Q>& vec<1, T, Q>::operator+=(vec<3, U, Q> const& v) { this->x += static_cast(v.x); return *this; @@ -175,7 +175,7 @@ namespace mim template template - constexpr VectorT<1, T, Q>& VectorT<1, T, Q>::operator+=(VectorT<4, U, Q> const& v) + constexpr vec<1, T, Q>& vec<1, T, Q>::operator+=(vec<4, U, Q> const& v) { this->x += static_cast(v.x); return *this; @@ -183,7 +183,7 @@ namespace mim template template - constexpr VectorT<1, T, Q>& VectorT<1, T, Q>::operator-=(U scalar) + constexpr vec<1, T, Q>& vec<1, T, Q>::operator-=(U scalar) { this->x -= static_cast(scalar); return *this; @@ -191,7 +191,7 @@ namespace mim template template - constexpr VectorT<1, T, Q>& VectorT<1, T, Q>::operator-=(VectorT<1, U, Q> const& v) + constexpr vec<1, T, Q>& vec<1, T, Q>::operator-=(vec<1, U, Q> const& v) { this->x -= static_cast(v.x); return *this; @@ -199,7 +199,7 @@ namespace mim template template - constexpr VectorT<1, T, Q>& VectorT<1, T, Q>::operator-=(VectorT<2, U, Q> const& v) + constexpr vec<1, T, Q>& vec<1, T, Q>::operator-=(vec<2, U, Q> const& v) { this->x -= static_cast(v.x); return *this; @@ -207,7 +207,7 @@ namespace mim template template - constexpr VectorT<1, T, Q>& VectorT<1, T, Q>::operator-=(VectorT<3, U, Q> const& v) + constexpr vec<1, T, Q>& vec<1, T, Q>::operator-=(vec<3, U, Q> const& v) { this->x -= static_cast(v.x); return *this; @@ -215,7 +215,7 @@ namespace mim template template - constexpr VectorT<1, T, Q>& VectorT<1, T, Q>::operator-=(VectorT<4, U, Q> const& v) + constexpr vec<1, T, Q>& vec<1, T, Q>::operator-=(vec<4, U, Q> const& v) { this->x -= static_cast(v.x); return *this; @@ -223,7 +223,7 @@ namespace mim template template - constexpr VectorT<1, T, Q>& VectorT<1, T, Q>::operator*=(U scalar) + constexpr vec<1, T, Q>& vec<1, T, Q>::operator*=(U scalar) { this->x *= static_cast(scalar); return *this; @@ -231,7 +231,7 @@ namespace mim template template - constexpr VectorT<1, T, Q>& VectorT<1, T, Q>::operator*=(VectorT<1, U, Q> const& v) + constexpr vec<1, T, Q>& vec<1, T, Q>::operator*=(vec<1, U, Q> const& v) { this->x *= static_cast(v.x); return *this; @@ -239,7 +239,7 @@ namespace mim template template - constexpr VectorT<1, T, Q>& VectorT<1, T, Q>::operator*=(VectorT<2, U, Q> const& v) + constexpr vec<1, T, Q>& vec<1, T, Q>::operator*=(vec<2, U, Q> const& v) { this->x *= static_cast(v.x); return *this; @@ -247,7 +247,7 @@ namespace mim template template - constexpr VectorT<1, T, Q>& VectorT<1, T, Q>::operator*=(VectorT<3, U, Q> const& v) + constexpr vec<1, T, Q>& vec<1, T, Q>::operator*=(vec<3, U, Q> const& v) { this->x *= static_cast(v.x); return *this; @@ -255,7 +255,7 @@ namespace mim template template - constexpr VectorT<1, T, Q>& VectorT<1, T, Q>::operator*=(VectorT<4, U, Q> const& v) + constexpr vec<1, T, Q>& vec<1, T, Q>::operator*=(vec<4, U, Q> const& v) { this->x *= static_cast(v.x); return *this; @@ -263,7 +263,7 @@ namespace mim template template - constexpr VectorT<1, T, Q>& VectorT<1, T, Q>::operator/=(U scalar) + constexpr vec<1, T, Q>& vec<1, T, Q>::operator/=(U scalar) { this->x /= static_cast(scalar); return *this; @@ -271,7 +271,7 @@ namespace mim template template - constexpr VectorT<1, T, Q>& VectorT<1, T, Q>::operator/=(VectorT<1, U, Q> const& v) + constexpr vec<1, T, Q>& vec<1, T, Q>::operator/=(vec<1, U, Q> const& v) { this->x /= static_cast(v.x); return *this; @@ -279,7 +279,7 @@ namespace mim template template - constexpr VectorT<1, T, Q>& VectorT<1, T, Q>::operator/=(VectorT<2, U, Q> const& v) + constexpr vec<1, T, Q>& vec<1, T, Q>::operator/=(vec<2, U, Q> const& v) { this->x /= static_cast(v.x); return *this; @@ -287,7 +287,7 @@ namespace mim template template - constexpr VectorT<1, T, Q>& VectorT<1, T, Q>::operator/=(VectorT<3, U, Q> const& v) + constexpr vec<1, T, Q>& vec<1, T, Q>::operator/=(vec<3, U, Q> const& v) { this->x /= static_cast(v.x); return *this; @@ -295,7 +295,7 @@ namespace mim template template - constexpr VectorT<1, T, Q>& VectorT<1, T, Q>::operator/=(VectorT<4, U, Q> const& v) + constexpr vec<1, T, Q>& vec<1, T, Q>::operator/=(vec<4, U, Q> const& v) { this->x /= static_cast(v.x); @@ -304,7 +304,7 @@ namespace mim template template - constexpr VectorT<1, T, Q>& VectorT<1, T, Q>::operator%=(U scalar) + constexpr vec<1, T, Q>& vec<1, T, Q>::operator%=(U scalar) { static_assert(std::is_integral::value, "Cannot perform modulo operation on non-integral type."); this->x %= static_cast(scalar); @@ -313,7 +313,7 @@ namespace mim template template - constexpr VectorT<1, T, Q>& VectorT<1, T, Q>::operator%=(VectorT<1, U, Q> const& v) + constexpr vec<1, T, Q>& vec<1, T, Q>::operator%=(vec<1, U, Q> const& v) { static_assert(std::is_integral::value, "Cannot perform modulo operation on non-integral type."); this->x %= static_cast(v.x); @@ -323,31 +323,31 @@ namespace mim /// Increment and Decrement Operators template - constexpr VectorT<1, T, Q>& VectorT<1, T, Q>::operator++() + constexpr vec<1, T, Q>& vec<1, T, Q>::operator++() { ++this->x; return *this; } template - constexpr VectorT<1, T, Q>& VectorT<1, T, Q>::operator--() + constexpr vec<1, T, Q>& vec<1, T, Q>::operator--() { --this->x; return *this; } template - constexpr const VectorT<1, T, Q> VectorT<1, T, Q>::operator++(int) + constexpr const vec<1, T, Q> vec<1, T, Q>::operator++(int) { - VectorT<1, T, Q> result(*this); + vec<1, T, Q> result(*this); ++*this; return result; } template - constexpr const VectorT<1, T, Q> VectorT<1, T, Q>::operator--(int) + constexpr const vec<1, T, Q> vec<1, T, Q>::operator--(int) { - VectorT<1, T, Q> result(*this); + vec<1, T, Q> result(*this); --*this; return result; } @@ -356,7 +356,7 @@ namespace mim template template - constexpr VectorT<1, T, Q>& VectorT<1, T, Q>::operator&=(U scalar) + constexpr vec<1, T, Q>& vec<1, T, Q>::operator&=(U scalar) { this->x &= static_cast(scalar); @@ -365,7 +365,7 @@ namespace mim template template - constexpr VectorT<1, T, Q>& VectorT<1, T, Q>::operator&=(VectorT<1, U, Q> const& v) + constexpr vec<1, T, Q>& vec<1, T, Q>::operator&=(vec<1, U, Q> const& v) { this->x &= static_cast(v.x); return *this; @@ -373,7 +373,7 @@ namespace mim template template - constexpr VectorT<1, T, Q>& VectorT<1, T, Q>::operator|=(U scalar) + constexpr vec<1, T, Q>& vec<1, T, Q>::operator|=(U scalar) { this->x |= static_cast(scalar); return *this; @@ -381,7 +381,7 @@ namespace mim template template - constexpr VectorT<1, T, Q>& VectorT<1, T, Q>::operator|=(VectorT<1, U, Q> const& v) + constexpr vec<1, T, Q>& vec<1, T, Q>::operator|=(vec<1, U, Q> const& v) { this->x |= static_cast(v.x); return *this; @@ -389,7 +389,7 @@ namespace mim template template - constexpr VectorT<1, T, Q>& VectorT<1, T, Q>::operator^=(U scalar) + constexpr vec<1, T, Q>& vec<1, T, Q>::operator^=(U scalar) { this->x ^= static_cast(scalar); return *this; @@ -397,7 +397,7 @@ namespace mim template template - constexpr VectorT<1, T, Q>& VectorT<1, T, Q>::operator^=(VectorT<1, U, Q> const& v) + constexpr vec<1, T, Q>& vec<1, T, Q>::operator^=(vec<1, U, Q> const& v) { this->x ^= static_cast(v.x); return *this; @@ -405,7 +405,7 @@ namespace mim template template - constexpr VectorT<1, T, Q>& VectorT<1, T, Q>::operator<<=(U scalar) + constexpr vec<1, T, Q>& vec<1, T, Q>::operator<<=(U scalar) { this->x <<= static_cast(scalar); return *this; @@ -413,7 +413,7 @@ namespace mim template template - constexpr VectorT<1, T, Q>& VectorT<1, T, Q>::operator<<=(VectorT<1, U, Q> const& v) + constexpr vec<1, T, Q>& vec<1, T, Q>::operator<<=(vec<1, U, Q> const& v) { this->x <<= static_cast(v.x); return *this; @@ -421,7 +421,7 @@ namespace mim template template - constexpr VectorT<1, T, Q>& VectorT<1, T, Q>::operator>>=(U scalar) + constexpr vec<1, T, Q>& vec<1, T, Q>::operator>>=(U scalar) { this->x >>= static_cast(scalar); return *this; @@ -429,7 +429,7 @@ namespace mim template template - constexpr VectorT<1, T, Q>& VectorT<1, T, Q>::operator>>=(VectorT<1, U, Q> const& v) + constexpr vec<1, T, Q>& vec<1, T, Q>::operator>>=(vec<1, U, Q> const& v) { this->x >>= static_cast(v.x); return *this; @@ -438,233 +438,233 @@ namespace mim // Unary Operators template - constexpr VectorT<1, T, Q> operator+(VectorT<1, T, Q> const& v) + constexpr vec<1, T, Q> operator+(vec<1, T, Q> const& v) { return v; } template - constexpr VectorT<1, T, Q> operator-(VectorT<1, T, Q> const& v) + constexpr vec<1, T, Q> operator-(vec<1, T, Q> const& v) { - return VectorT<1, T, Q>(-v.x); + return vec<1, T, Q>(-v.x); } template - constexpr VectorT<1, T, Q> operator+(VectorT<1, T, Q> const& v, T scalar) + constexpr vec<1, T, Q> operator+(vec<1, T, Q> const& v, T scalar) { - return VectorT<1, T, Q>(v.x + scalar); + return vec<1, T, Q>(v.x + scalar); } template - constexpr VectorT<1, T, Q> operator+(T scalar, VectorT<1, T, Q> const& v) + constexpr vec<1, T, Q> operator+(T scalar, vec<1, T, Q> const& v) { - return VectorT<1, T, Q>(scalar + v.x); + return vec<1, T, Q>(scalar + v.x); } template - constexpr VectorT<1, T, Q> operator+(VectorT<1, T, Q> const& v1, VectorT<1, T, Q> const& v2) + constexpr vec<1, T, Q> operator+(vec<1, T, Q> const& v1, vec<1, T, Q> const& v2) { - return VectorT<1, T, Q>(v1.x + v2.x); + return vec<1, T, Q>(v1.x + v2.x); } template - constexpr VectorT<1, T, Q> operator-(VectorT<1, T, Q> const& v, T scalar) + constexpr vec<1, T, Q> operator-(vec<1, T, Q> const& v, T scalar) { - return VectorT<1, T, Q>(v.x - scalar); + return vec<1, T, Q>(v.x - scalar); } template - constexpr VectorT<1, T, Q> operator-(T scalar, VectorT<1, T, Q> const& v) + constexpr vec<1, T, Q> operator-(T scalar, vec<1, T, Q> const& v) { - return VectorT<1, T, Q>(scalar - v.x); + return vec<1, T, Q>(scalar - v.x); } template - constexpr VectorT<1, T, Q> operator-(VectorT<1, T, Q> const& v1, VectorT<1, T, Q> const& v2) + constexpr vec<1, T, Q> operator-(vec<1, T, Q> const& v1, vec<1, T, Q> const& v2) { - return VectorT<1, T, Q>(v1.x - v2.x); + return vec<1, T, Q>(v1.x - v2.x); } template - constexpr VectorT<1, T, Q> operator*(VectorT<1, T, Q> const& v, T scalar) + constexpr vec<1, T, Q> operator*(vec<1, T, Q> const& v, T scalar) { - return VectorT<1, T, Q>(v.x * scalar); + return vec<1, T, Q>(v.x * scalar); } template - constexpr VectorT<1, T, Q> operator*(T scalar, VectorT<1, T, Q> const& v) + constexpr vec<1, T, Q> operator*(T scalar, vec<1, T, Q> const& v) { - return VectorT<1, T, Q>(scalar * v.x); + return vec<1, T, Q>(scalar * v.x); } template - constexpr VectorT<1, T, Q> operator*(VectorT<1, T, Q> const& v1, VectorT<1, T, Q> const& v2) + constexpr vec<1, T, Q> operator*(vec<1, T, Q> const& v1, vec<1, T, Q> const& v2) { - return VectorT<1, T, Q>(v1.x * v2.x); + return vec<1, T, Q>(v1.x * v2.x); } template - constexpr VectorT<1, bool, Q> operator*(VectorT<1, bool, Q> const& v1, VectorT<1, bool, Q> const& v2) + constexpr vec<1, bool, Q> operator*(vec<1, bool, Q> const& v1, vec<1, bool, Q> const& v2) { - return VectorT<1, bool, Q>(v1.x && v2.x); + return vec<1, bool, Q>(v1.x && v2.x); } template - constexpr VectorT<1, T, Q> operator/(VectorT<1, T, Q> const& v, T scalar) + constexpr vec<1, T, Q> operator/(vec<1, T, Q> const& v, T scalar) { - return VectorT<1, T, Q>(v.x / scalar); + return vec<1, T, Q>(v.x / scalar); } template - constexpr VectorT<1, T, Q> operator/(T scalar, VectorT<1, T, Q> const& v) + constexpr vec<1, T, Q> operator/(T scalar, vec<1, T, Q> const& v) { - return VectorT<1, T, Q>(scalar / v.x); + return vec<1, T, Q>(scalar / v.x); } template - constexpr VectorT<1, T, Q> operator/(VectorT<1, T, Q> const& v1, VectorT<1, T, Q> const& v2) + constexpr vec<1, T, Q> operator/(vec<1, T, Q> const& v1, vec<1, T, Q> const& v2) { - return VectorT<1, T, Q>(v1.x / v2.x); + return vec<1, T, Q>(v1.x / v2.x); } template - constexpr VectorT<1, T, Q> operator%(VectorT<1, T, Q> const& v, T scalar) + constexpr vec<1, T, Q> operator%(vec<1, T, Q> const& v, T scalar) { - return VectorT<1, T, Q>(v.x % scalar); + return vec<1, T, Q>(v.x % scalar); } template - constexpr VectorT<1, T, Q> operator%(T scalar, VectorT<1, T, Q> const& v) + constexpr vec<1, T, Q> operator%(T scalar, vec<1, T, Q> const& v) { - return VectorT<1, T, Q>(scalar % v.x); + return vec<1, T, Q>(scalar % v.x); } template - constexpr VectorT<1, T, Q> operator%(VectorT<1, T, Q> const& v1, VectorT<1, T, Q> const& v2) + constexpr vec<1, T, Q> operator%(vec<1, T, Q> const& v1, vec<1, T, Q> const& v2) { - return VectorT<1, T, Q>(v1.x % v2.x); + return vec<1, T, Q>(v1.x % v2.x); } /// Bitwise Binary Operators template - constexpr VectorT<1, T, Q> operator&(VectorT<1, T, Q> const& v, T scalar) + constexpr vec<1, T, Q> operator&(vec<1, T, Q> const& v, T scalar) { - return VectorT<1, T, Q>(v.x & scalar); + return vec<1, T, Q>(v.x & scalar); } template - constexpr VectorT<1, T, Q> operator&(T scalar, VectorT<1, T, Q> const& v) + constexpr vec<1, T, Q> operator&(T scalar, vec<1, T, Q> const& v) { - return VectorT<1, T, Q>(scalar & v.x); + return vec<1, T, Q>(scalar & v.x); } template - constexpr VectorT<1, T, Q> operator&(VectorT<1, T, Q> const& v1, VectorT<1, T, Q> const& v2) + constexpr vec<1, T, Q> operator&(vec<1, T, Q> const& v1, vec<1, T, Q> const& v2) { - return VectorT<1, T, Q>(v1.x & v2.x); + return vec<1, T, Q>(v1.x & v2.x); } template - constexpr VectorT<1, T, Q> operator|(VectorT<1, T, Q> const& v, T scalar) + constexpr vec<1, T, Q> operator|(vec<1, T, Q> const& v, T scalar) { - return VectorT<1, T, Q>(v.x | scalar); + return vec<1, T, Q>(v.x | scalar); } template - constexpr VectorT<1, T, Q> operator|(T scalar, VectorT<1, T, Q> const& v) + constexpr vec<1, T, Q> operator|(T scalar, vec<1, T, Q> const& v) { - return VectorT<1, T, Q>(scalar | v.x); + return vec<1, T, Q>(scalar | v.x); } template - constexpr VectorT<1, T, Q> operator|(VectorT<1, T, Q> const& v1, VectorT<1, T, Q> const& v2) + constexpr vec<1, T, Q> operator|(vec<1, T, Q> const& v1, vec<1, T, Q> const& v2) { - return VectorT<1, T, Q>(v1.x | v2.x); + return vec<1, T, Q>(v1.x | v2.x); } template - constexpr VectorT<1, T, Q> operator^(VectorT<1, T, Q> const& v, T scalar) + constexpr vec<1, T, Q> operator^(vec<1, T, Q> const& v, T scalar) { - return VectorT<1, T, Q>(v.x ^ scalar); + return vec<1, T, Q>(v.x ^ scalar); } template - constexpr VectorT<1, T, Q> operator^(T scalar, VectorT<1, T, Q> const& v) + constexpr vec<1, T, Q> operator^(T scalar, vec<1, T, Q> const& v) { - return VectorT<1, T, Q>(scalar ^ v.x); + return vec<1, T, Q>(scalar ^ v.x); } template - constexpr VectorT<1, T, Q> operator^(VectorT<1, T, Q> const& v1, VectorT<1, T, Q> const& v2) + constexpr vec<1, T, Q> operator^(vec<1, T, Q> const& v1, vec<1, T, Q> const& v2) { - return VectorT<1, T, Q>(v1.x ^ v2.x); + return vec<1, T, Q>(v1.x ^ v2.x); } template - constexpr VectorT<1, T, Q> operator<<(VectorT<1, T, Q> const& v, T scalar) + constexpr vec<1, T, Q> operator<<(vec<1, T, Q> const& v, T scalar) { - return VectorT<1, T, Q>(v.x << scalar); + return vec<1, T, Q>(v.x << scalar); } template - constexpr VectorT<1, T, Q> operator<<(T scalar, VectorT<1, T, Q> const& v) + constexpr vec<1, T, Q> operator<<(T scalar, vec<1, T, Q> const& v) { - return VectorT<1, T, Q>(scalar << v.x); + return vec<1, T, Q>(scalar << v.x); } template - constexpr VectorT<1, T, Q> operator<<(VectorT<1, T, Q> const& v1, VectorT<1, T, Q> const& v2) + constexpr vec<1, T, Q> operator<<(vec<1, T, Q> const& v1, vec<1, T, Q> const& v2) { - return VectorT<1, T, Q>(v1.x << v2.x); + return vec<1, T, Q>(v1.x << v2.x); } template - constexpr VectorT<1, T, Q> operator>>(VectorT<1, T, Q> const& v, T scalar) + constexpr vec<1, T, Q> operator>>(vec<1, T, Q> const& v, T scalar) { - return VectorT<1, T, Q>(v.x >> scalar); + return vec<1, T, Q>(v.x >> scalar); } template - constexpr VectorT<1, T, Q> operator>>(T scalar, VectorT<1, T, Q> const& v) + constexpr vec<1, T, Q> operator>>(T scalar, vec<1, T, Q> const& v) { - return VectorT<1, T, Q>(scalar >> v.x); + return vec<1, T, Q>(scalar >> v.x); } template - constexpr VectorT<1, T, Q> operator>>(VectorT<1, T, Q> const& v1, VectorT<1, T, Q> const& v2) + constexpr vec<1, T, Q> operator>>(vec<1, T, Q> const& v1, vec<1, T, Q> const& v2) { - return VectorT<1, T, Q>(v1.x >> v2.x); + return vec<1, T, Q>(v1.x >> v2.x); } template - constexpr VectorT<1, T, Q> operator~(VectorT<1, T, Q> const& v) + constexpr vec<1, T, Q> operator~(vec<1, T, Q> const& v) { - return VectorT<1, T, Q>(~v.x); + return vec<1, T, Q>(~v.x); } /// Comparison Operators template - constexpr bool operator==(VectorT<1, T, Q> const& v1, VectorT<1, T, Q> const& v2) + constexpr bool operator==(vec<1, T, Q> const& v1, vec<1, T, Q> const& v2) { return detail::Equal::is_iec559, sizeof(T) * 2, detail::IsAligned::value>::compute(v1, v2); } template - constexpr bool operator!=(VectorT<1, T, Q> const& v1, VectorT<1, T, Q> const& v2) + constexpr bool operator!=(vec<1, T, Q> const& v1, vec<1, T, Q> const& v2) { return !(v1 == v2); } template - constexpr bool operator&&(VectorT<1, bool, Q> const& v1, VectorT<1, bool, Q> const& v2) + constexpr bool operator&&(vec<1, bool, Q> const& v1, vec<1, bool, Q> const& v2) { return (v1.x && v2.x); } template - constexpr bool operator||(VectorT<1, bool, Q> const& v1, VectorT<1, bool, Q> const& v2) + constexpr bool operator||(vec<1, bool, Q> const& v1, vec<1, bool, Q> const& v2) { return (v1.x || v2.x); } diff --git a/include/mim/detail/type/type_vector2.hpp b/include/mim/detail/type/type_vector2.hpp index ea3928c..6e84301 100644 --- a/include/mim/detail/type/type_vector2.hpp +++ b/include/mim/detail/type/type_vector2.hpp @@ -7,11 +7,11 @@ namespace mim { template - struct VectorT<2, T, Q> { + struct vec<2, T, Q> { // Aliases using value_type = T; - using type = VectorT<2, T, Q>; + using type = vec<2, T, Q>; using size_type = size_t; static constexpr auto size_v = 2; @@ -34,160 +34,160 @@ namespace mim /// Constructors - constexpr VectorT(); + constexpr vec(); - constexpr VectorT(T _x, T _y); + constexpr vec(T _x, T _y); - constexpr VectorT(VectorT const& v); + constexpr vec(vec const& v); - constexpr explicit VectorT(T scalar); + constexpr explicit vec(T scalar); /// Template Constructors template - constexpr explicit VectorT(VectorT<2, T, P> const& v); + constexpr explicit vec(vec<2, T, P> const& v); // U Template Constructors template - constexpr explicit VectorT(VectorT<1, U, P> const& scalar); + constexpr explicit vec(vec<1, U, P> const& scalar); template - constexpr explicit VectorT(VectorT<2, U, P> const& v); + constexpr explicit vec(vec<2, U, P> const& v); template - constexpr explicit VectorT(VectorT<3, U, P> const& v); + constexpr explicit vec(vec<3, U, P> const& v); template - constexpr explicit VectorT(VectorT<4, U, P> const& v); + constexpr explicit vec(vec<4, U, P> const& v); // AB Template Constructors template - constexpr explicit VectorT(A _x, B _y); + constexpr explicit vec(A _x, B _y); template - constexpr VectorT(VectorT<1, A, Q> const& _x, B _y); + constexpr vec(vec<1, A, Q> const& _x, B _y); template - constexpr VectorT(A _x, VectorT<1, B, Q> const& _y); + constexpr vec(A _x, vec<1, B, Q> const& _y); template - constexpr VectorT(VectorT<1, A, Q> const& _x, VectorT<1, B, Q> const& _y); + constexpr vec(vec<1, A, Q> const& _x, vec<1, B, Q> const& _y); /// Assignment Operators - constexpr VectorT<2, T, Q>& operator=(T scalar); + constexpr vec<2, T, Q>& operator=(T scalar); - constexpr VectorT<2, T, Q>& operator=(VectorT<2, T, Q> const& v); + constexpr vec<2, T, Q>& operator=(vec<2, T, Q> const& v); template - constexpr VectorT<2, T, Q>& operator=(VectorT<1, U, Q> const& scalar); + constexpr vec<2, T, Q>& operator=(vec<1, U, Q> const& scalar); template - constexpr VectorT<2, T, Q>& operator=(VectorT<2, U, Q> const& v); + constexpr vec<2, T, Q>& operator=(vec<2, U, Q> const& v); template - constexpr VectorT<2, T, Q>& operator+=(U scalar); + constexpr vec<2, T, Q>& operator+=(U scalar); template - constexpr VectorT<2, T, Q>& operator+=(VectorT<1, U, Q> const& scalar); + constexpr vec<2, T, Q>& operator+=(vec<1, U, Q> const& scalar); template - constexpr VectorT<2, T, Q>& operator+=(VectorT<2, U, Q> const& v); + constexpr vec<2, T, Q>& operator+=(vec<2, U, Q> const& v); template - constexpr VectorT<2, T, Q>& operator-=(U scalar); + constexpr vec<2, T, Q>& operator-=(U scalar); template - constexpr VectorT<2, T, Q>& operator-=(VectorT<1, U, Q> const& scalar); + constexpr vec<2, T, Q>& operator-=(vec<1, U, Q> const& scalar); template - constexpr VectorT<2, T, Q>& operator-=(VectorT<2, U, Q> const& v); + constexpr vec<2, T, Q>& operator-=(vec<2, U, Q> const& v); template - constexpr VectorT<2, T, Q>& operator*=(U scalar); + constexpr vec<2, T, Q>& operator*=(U scalar); template - constexpr VectorT<2, T, Q>& operator*=(VectorT<1, U, Q> const& scalar); + constexpr vec<2, T, Q>& operator*=(vec<1, U, Q> const& scalar); template - constexpr VectorT<2, T, Q>& operator*=(VectorT<2, U, Q> const& v); + constexpr vec<2, T, Q>& operator*=(vec<2, U, Q> const& v); template - constexpr VectorT<2, T, Q>& operator/=(U scalar); + constexpr vec<2, T, Q>& operator/=(U scalar); template - constexpr VectorT<2, T, Q>& operator/=(VectorT<1, U, Q> const& scalar); + constexpr vec<2, T, Q>& operator/=(vec<1, U, Q> const& scalar); template - constexpr VectorT<2, T, Q>& operator/=(VectorT<2, U, Q> const& v); + constexpr vec<2, T, Q>& operator/=(vec<2, U, Q> const& v); template - constexpr VectorT<2, T, Q>& operator%=(U scalar); + constexpr vec<2, T, Q>& operator%=(U scalar); template - constexpr VectorT<2, T, Q>& operator%=(VectorT<1, U, Q> const& scalar); + constexpr vec<2, T, Q>& operator%=(vec<1, U, Q> const& scalar); template - constexpr VectorT<2, T, Q>& operator%=(VectorT<2, U, Q> const& v); + constexpr vec<2, T, Q>& operator%=(vec<2, U, Q> const& v); /// Increment and Decrement Operators - constexpr VectorT<2, T, Q>& operator++(); + constexpr vec<2, T, Q>& operator++(); - constexpr VectorT<2, T, Q>& operator--(); + constexpr vec<2, T, Q>& operator--(); - constexpr const VectorT<2, T, Q> operator++(int); + constexpr const vec<2, T, Q> operator++(int); - constexpr const VectorT<2, T, Q> operator--(int); + constexpr const vec<2, T, Q> operator--(int); /// Bitwise Assignment Operators template - constexpr VectorT<2, T, Q>& operator&=(U scalar); + constexpr vec<2, T, Q>& operator&=(U scalar); template - constexpr VectorT<2, T, Q>& operator&=(VectorT<1, U, Q> const& scalar); + constexpr vec<2, T, Q>& operator&=(vec<1, U, Q> const& scalar); template - constexpr VectorT<2, T, Q>& operator&=(VectorT<2, U, Q> const& v); + constexpr vec<2, T, Q>& operator&=(vec<2, U, Q> const& v); template - constexpr VectorT<2, T, Q>& operator|=(U scalar); + constexpr vec<2, T, Q>& operator|=(U scalar); template - constexpr VectorT<2, T, Q>& operator|=(VectorT<1, U, Q> const& scalar); + constexpr vec<2, T, Q>& operator|=(vec<1, U, Q> const& scalar); template - constexpr VectorT<2, T, Q>& operator|=(VectorT<2, U, Q> const& v); + constexpr vec<2, T, Q>& operator|=(vec<2, U, Q> const& v); template - constexpr VectorT<2, T, Q>& operator^=(U scalar); + constexpr vec<2, T, Q>& operator^=(U scalar); template - constexpr VectorT<2, T, Q>& operator^=(VectorT<1, U, Q> const& scalar); + constexpr vec<2, T, Q>& operator^=(vec<1, U, Q> const& scalar); template - constexpr VectorT<2, T, Q>& operator^=(VectorT<2, U, Q> const& v); + constexpr vec<2, T, Q>& operator^=(vec<2, U, Q> const& v); template - constexpr VectorT<2, T, Q>& operator<<=(U scalar); + constexpr vec<2, T, Q>& operator<<=(U scalar); template - constexpr VectorT<2, T, Q>& operator<<=(VectorT<1, U, Q> const& scalar); + constexpr vec<2, T, Q>& operator<<=(vec<1, U, Q> const& scalar); template - constexpr VectorT<2, T, Q>& operator<<=(VectorT<2, U, Q> const& v); + constexpr vec<2, T, Q>& operator<<=(vec<2, U, Q> const& v); template - constexpr VectorT<2, T, Q>& operator>>=(U scalar); + constexpr vec<2, T, Q>& operator>>=(U scalar); template - constexpr VectorT<2, T, Q>& operator>>=(VectorT<1, U, Q> const& scalar); + constexpr vec<2, T, Q>& operator>>=(vec<1, U, Q> const& scalar); template - constexpr VectorT<2, T, Q>& operator>>=(VectorT<2, U, Q> const& v); + constexpr vec<2, T, Q>& operator>>=(vec<2, U, Q> const& v); /// Generic Function Declarations @@ -198,212 +198,212 @@ namespace mim constexpr void normalize(); - constexpr VectorT<2, T, Q> normalized() const; + constexpr vec<2, T, Q> normalized() const; MIM_NODISCARD constexpr bool is_normalized() const; - constexpr T distance(const VectorT<2, T, Q>& v) const; + constexpr T distance(const vec<2, T, Q>& v) const; - constexpr T distance_squared(const VectorT<2, T, Q>& v) const; + constexpr T distance_squared(const vec<2, T, Q>& v) const; /// Function Declarations - constexpr T dot(const VectorT<2, T, Q>& v) const; + constexpr T dot(const vec<2, T, Q>& v) const; - constexpr T cross(const VectorT<2, T, Q>& v) const; + constexpr T cross(const vec<2, T, Q>& v) const; - VectorT<2, T, Q> rotated(T angle) const; + vec<2, T, Q> rotated(T angle) const; - constexpr VectorT<2, T, Q> clamp(const VectorT<2, T, Q>& min, const VectorT<2, T, Q>& max) const; + constexpr vec<2, T, Q> clamp(const vec<2, T, Q>& min, const vec<2, T, Q>& max) const; - constexpr VectorT<2, T, Q> reflect(const VectorT<2, T, Q>& normal) const; + constexpr vec<2, T, Q> reflect(const vec<2, T, Q>& normal) const; - constexpr VectorT<2, T, Q> refract(const VectorT<2, T, Q>& normal, T eta) const; + constexpr vec<2, T, Q> refract(const vec<2, T, Q>& normal, T eta) const; - constexpr VectorT<2, T, Q> project(const VectorT<2, T, Q>& to) const; + constexpr vec<2, T, Q> project(const vec<2, T, Q>& to) const; }; /// Unary Operators template - constexpr VectorT<2, T, Q> operator+(VectorT<2, T, Q> const& v); + constexpr vec<2, T, Q> operator+(vec<2, T, Q> const& v); template - constexpr VectorT<2, T, Q> operator-(VectorT<2, T, Q> const& v); + constexpr vec<2, T, Q> operator-(vec<2, T, Q> const& v); /// Binary Operators // TODO: Decide if we should allow scalar operations on vec2 using vec3-4 template - constexpr VectorT<2, T, Q> operator+(VectorT<2, T, Q> const& v, T scalar); + constexpr vec<2, T, Q> operator+(vec<2, T, Q> const& v, T scalar); template - constexpr VectorT<2, T, Q> operator+(T scalar, VectorT<2, T, Q> const& v); + constexpr vec<2, T, Q> operator+(T scalar, vec<2, T, Q> const& v); template - constexpr VectorT<2, T, Q> operator+(VectorT<2, T, Q> const& v1, VectorT<2, T, Q> const& v2); + constexpr vec<2, T, Q> operator+(vec<2, T, Q> const& v1, vec<2, T, Q> const& v2); template - constexpr VectorT<2, T, Q> operator+(VectorT<1, T, Q> const& v1, VectorT<2, T, Q> const& v2); + constexpr vec<2, T, Q> operator+(vec<1, T, Q> const& v1, vec<2, T, Q> const& v2); template - constexpr VectorT<2, T, Q> operator+(VectorT<2, T, Q> const& v1, VectorT<1, T, Q> const& v); + constexpr vec<2, T, Q> operator+(vec<2, T, Q> const& v1, vec<1, T, Q> const& v); template - constexpr VectorT<2, T, Q> operator-(VectorT<2, T, Q> const& v, T scalar); + constexpr vec<2, T, Q> operator-(vec<2, T, Q> const& v, T scalar); template - constexpr VectorT<2, T, Q> operator-(T scalar, VectorT<2, T, Q> const& v); + constexpr vec<2, T, Q> operator-(T scalar, vec<2, T, Q> const& v); template - constexpr VectorT<2, T, Q> operator-(VectorT<2, T, Q> const& v1, VectorT<2, T, Q> const& v2); + constexpr vec<2, T, Q> operator-(vec<2, T, Q> const& v1, vec<2, T, Q> const& v2); template - constexpr VectorT<2, T, Q> operator-(VectorT<1, T, Q> const& v1, VectorT<2, T, Q> const& v2); + constexpr vec<2, T, Q> operator-(vec<1, T, Q> const& v1, vec<2, T, Q> const& v2); template - constexpr VectorT<2, T, Q> operator-(VectorT<2, T, Q> const& v1, VectorT<1, T, Q> const& v2); + constexpr vec<2, T, Q> operator-(vec<2, T, Q> const& v1, vec<1, T, Q> const& v2); template - constexpr VectorT<2, T, Q> operator*(VectorT<2, T, Q> const& v, T scalar); + constexpr vec<2, T, Q> operator*(vec<2, T, Q> const& v, T scalar); template - constexpr VectorT<2, T, Q> operator*(T scalar, VectorT<2, T, Q> const& v); + constexpr vec<2, T, Q> operator*(T scalar, vec<2, T, Q> const& v); template - constexpr VectorT<2, T, Q> operator*(VectorT<2, T, Q> const& v1, VectorT<2, T, Q> const& v2); + constexpr vec<2, T, Q> operator*(vec<2, T, Q> const& v1, vec<2, T, Q> const& v2); template - constexpr VectorT<2, T, Q> operator*(VectorT<1, T, Q> const& v1, VectorT<2, T, Q> const& v2); + constexpr vec<2, T, Q> operator*(vec<1, T, Q> const& v1, vec<2, T, Q> const& v2); template - constexpr VectorT<2, T, Q> operator*(VectorT<2, T, Q> const& v1, VectorT<1, T, Q> const& v); + constexpr vec<2, T, Q> operator*(vec<2, T, Q> const& v1, vec<1, T, Q> const& v); template - constexpr VectorT<2, T, Q> operator/(VectorT<2, T, Q> const& v, T scalar); + constexpr vec<2, T, Q> operator/(vec<2, T, Q> const& v, T scalar); template - constexpr VectorT<2, T, Q> operator/(T scalar, VectorT<2, T, Q> const& v); + constexpr vec<2, T, Q> operator/(T scalar, vec<2, T, Q> const& v); template - constexpr VectorT<2, T, Q> operator/(VectorT<2, T, Q> const& v1, VectorT<2, T, Q> const& v2); + constexpr vec<2, T, Q> operator/(vec<2, T, Q> const& v1, vec<2, T, Q> const& v2); template - constexpr VectorT<2, T, Q> operator/(VectorT<1, T, Q> const& v1, VectorT<2, T, Q> const& v2); + constexpr vec<2, T, Q> operator/(vec<1, T, Q> const& v1, vec<2, T, Q> const& v2); template - constexpr VectorT<2, T, Q> operator/(VectorT<2, T, Q> const& v1, VectorT<1, T, Q> const& v2); + constexpr vec<2, T, Q> operator/(vec<2, T, Q> const& v1, vec<1, T, Q> const& v2); template - constexpr VectorT<2, T, Q> operator%(VectorT<2, T, Q> const& v, T scalar); + constexpr vec<2, T, Q> operator%(vec<2, T, Q> const& v, T scalar); template - constexpr VectorT<2, T, Q> operator%(T scalar, VectorT<2, T, Q> const& v); + constexpr vec<2, T, Q> operator%(T scalar, vec<2, T, Q> const& v); template - constexpr VectorT<2, T, Q> operator%(VectorT<2, T, Q> const& v1, VectorT<2, T, Q> const& v2); + constexpr vec<2, T, Q> operator%(vec<2, T, Q> const& v1, vec<2, T, Q> const& v2); template - constexpr VectorT<2, T, Q> operator%(VectorT<1, T, Q> const& v, VectorT<2, T, Q> const& v2); + constexpr vec<2, T, Q> operator%(vec<1, T, Q> const& v, vec<2, T, Q> const& v2); template - constexpr VectorT<2, T, Q> operator%(VectorT<2, T, Q> const& v1, VectorT<1, T, Q> const& v); + constexpr vec<2, T, Q> operator%(vec<2, T, Q> const& v1, vec<1, T, Q> const& v); /// Bitwise Binary Operators // TODO: Decide if we should allow bitwise operations on vec2 using vec3-4 template - constexpr VectorT<2, T, Q> operator&(VectorT<2, T, Q> const& v, T scalar); + constexpr vec<2, T, Q> operator&(vec<2, T, Q> const& v, T scalar); template - constexpr VectorT<2, T, Q> operator&(T scalar, VectorT<2, T, Q> const& v); + constexpr vec<2, T, Q> operator&(T scalar, vec<2, T, Q> const& v); template - constexpr VectorT<2, T, Q> operator&(VectorT<2, T, Q> const& v1, VectorT<2, T, Q> const& v2); + constexpr vec<2, T, Q> operator&(vec<2, T, Q> const& v1, vec<2, T, Q> const& v2); template - constexpr VectorT<2, T, Q> operator&(VectorT<1, T, Q> const& v1, VectorT<2, T, Q> const& v2); + constexpr vec<2, T, Q> operator&(vec<1, T, Q> const& v1, vec<2, T, Q> const& v2); template - constexpr VectorT<2, T, Q> operator&(VectorT<2, T, Q> const& v1, VectorT<1, T, Q> const& v2); + constexpr vec<2, T, Q> operator&(vec<2, T, Q> const& v1, vec<1, T, Q> const& v2); template - constexpr VectorT<2, T, Q> operator|(VectorT<2, T, Q> const& v1, T scalar); + constexpr vec<2, T, Q> operator|(vec<2, T, Q> const& v1, T scalar); template - constexpr VectorT<2, T, Q> operator|(T scalar, VectorT<2, T, Q> const& v); + constexpr vec<2, T, Q> operator|(T scalar, vec<2, T, Q> const& v); template - constexpr VectorT<2, T, Q> operator|(VectorT<2, T, Q> const& v1, VectorT<2, T, Q> const& v2); + constexpr vec<2, T, Q> operator|(vec<2, T, Q> const& v1, vec<2, T, Q> const& v2); template - constexpr VectorT<2, T, Q> operator|(VectorT<1, T, Q> const& v1, VectorT<2, T, Q> const& v2); + constexpr vec<2, T, Q> operator|(vec<1, T, Q> const& v1, vec<2, T, Q> const& v2); template - constexpr VectorT<2, T, Q> operator|(VectorT<2, T, Q> const& v1, VectorT<1, T, Q> const& v2); + constexpr vec<2, T, Q> operator|(vec<2, T, Q> const& v1, vec<1, T, Q> const& v2); template - constexpr VectorT<2, T, Q> operator^(VectorT<2, T, Q> const& v1, T scalar); + constexpr vec<2, T, Q> operator^(vec<2, T, Q> const& v1, T scalar); template - constexpr VectorT<2, T, Q> operator^(T scalar, VectorT<2, T, Q> const& v); + constexpr vec<2, T, Q> operator^(T scalar, vec<2, T, Q> const& v); template - constexpr VectorT<2, T, Q> operator^(VectorT<2, T, Q> const& v1, VectorT<2, T, Q> const& v2); + constexpr vec<2, T, Q> operator^(vec<2, T, Q> const& v1, vec<2, T, Q> const& v2); template - constexpr VectorT<2, T, Q> operator^(VectorT<1, T, Q> const& v1, VectorT<2, T, Q> const& v2); + constexpr vec<2, T, Q> operator^(vec<1, T, Q> const& v1, vec<2, T, Q> const& v2); template - constexpr VectorT<2, T, Q> operator^(VectorT<2, T, Q> const& v1, VectorT<1, T, Q> const& v2); + constexpr vec<2, T, Q> operator^(vec<2, T, Q> const& v1, vec<1, T, Q> const& v2); template - constexpr VectorT<2, T, Q> operator<<(VectorT<2, T, Q> const& v, T scalar); + constexpr vec<2, T, Q> operator<<(vec<2, T, Q> const& v, T scalar); template - constexpr VectorT<2, T, Q> operator<<(T scalar, VectorT<2, T, Q> const& v); + constexpr vec<2, T, Q> operator<<(T scalar, vec<2, T, Q> const& v); template - constexpr VectorT<2, T, Q> operator<<(VectorT<2, T, Q> const& v1, VectorT<2, T, Q> const& v2); + constexpr vec<2, T, Q> operator<<(vec<2, T, Q> const& v1, vec<2, T, Q> const& v2); template - constexpr VectorT<2, T, Q> operator<<(VectorT<1, T, Q> const& v1, VectorT<2, T, Q> const& v2); + constexpr vec<2, T, Q> operator<<(vec<1, T, Q> const& v1, vec<2, T, Q> const& v2); template - constexpr VectorT<2, T, Q> operator<<(VectorT<2, T, Q> const& v1, VectorT<1, T, Q> const& v2); + constexpr vec<2, T, Q> operator<<(vec<2, T, Q> const& v1, vec<1, T, Q> const& v2); template - constexpr VectorT<2, T, Q> operator>>(VectorT<2, T, Q> const& v, T scalar); + constexpr vec<2, T, Q> operator>>(vec<2, T, Q> const& v, T scalar); template - constexpr VectorT<2, T, Q> operator>>(T scalar, VectorT<2, T, Q> const& v); + constexpr vec<2, T, Q> operator>>(T scalar, vec<2, T, Q> const& v); template - constexpr VectorT<2, T, Q> operator>>(VectorT<2, T, Q> const& v1, VectorT<2, T, Q> const& v2); + constexpr vec<2, T, Q> operator>>(vec<2, T, Q> const& v1, vec<2, T, Q> const& v2); template - constexpr VectorT<2, T, Q> operator>>(VectorT<1, T, Q> const& v1, VectorT<2, T, Q> const& v2); + constexpr vec<2, T, Q> operator>>(vec<1, T, Q> const& v1, vec<2, T, Q> const& v2); template - constexpr VectorT<2, T, Q> operator>>(VectorT<2, T, Q> const& v1, VectorT<1, T, Q> const& v2); + constexpr vec<2, T, Q> operator>>(vec<2, T, Q> const& v1, vec<1, T, Q> const& v2); template - constexpr VectorT<2, T, Q> operator~(VectorT<2, T, Q> const& v); + constexpr vec<2, T, Q> operator~(vec<2, T, Q> const& v); /// Conditional operators template - constexpr bool operator==(VectorT<2, T, Q> const& v1, VectorT<2, T, Q> const& v2); + constexpr bool operator==(vec<2, T, Q> const& v1, vec<2, T, Q> const& v2); template - constexpr bool operator!=(VectorT<2, T, Q> const& v1, VectorT<2, T, Q> const& v2); + constexpr bool operator!=(vec<2, T, Q> const& v1, vec<2, T, Q> const& v2); template - constexpr bool operator&&(VectorT<2, bool, Q> const& v1, VectorT<2, bool, Q> const& v2); + constexpr bool operator&&(vec<2, bool, Q> const& v1, vec<2, bool, Q> const& v2); template - constexpr bool operator||(VectorT<2, bool, Q> const& v1, VectorT<2, bool, Q> const& v2); + constexpr bool operator||(vec<2, bool, Q> const& v1, vec<2, bool, Q> const& v2); } // namespace mim diff --git a/include/mim/detail/type/type_vector2.inl b/include/mim/detail/type/type_vector2.inl index 63cac41..8db6755 100644 --- a/include/mim/detail/type/type_vector2.inl +++ b/include/mim/detail/type/type_vector2.inl @@ -8,7 +8,7 @@ namespace mim // Element Accessors template - constexpr T& VectorT<2, T, Q>::operator[](size_type i) + constexpr T& vec<2, T, Q>::operator[](size_type i) { switch (i) { default: @@ -18,7 +18,7 @@ namespace mim } template - constexpr T const& VectorT<2, T, Q>::operator[](size_type i) const + constexpr T const& vec<2, T, Q>::operator[](size_type i) const { switch (i) { @@ -29,7 +29,7 @@ namespace mim } template - T& VectorT<2, T, Q>::at(std::size_t i) + T& vec<2, T, Q>::at(std::size_t i) { switch (i) { @@ -40,7 +40,7 @@ namespace mim } template - const T& VectorT<2, T, Q>::at(std::size_t i) const + const T& vec<2, T, Q>::at(std::size_t i) const { switch (i) { @@ -53,22 +53,22 @@ namespace mim /// Constructors template - constexpr VectorT<2, T, Q>::VectorT() : x(0), y(0) + constexpr vec<2, T, Q>::vec() : x(0), y(0) { } template - constexpr VectorT<2, T, Q>::VectorT(T _x, T _y) : x(_x), y(_y) + constexpr vec<2, T, Q>::vec(T _x, T _y) : x(_x), y(_y) { } template - constexpr VectorT<2, T, Q>::VectorT(VectorT<2, T, Q> const& v) : x(v.x), y(v.y) + constexpr vec<2, T, Q>::vec(vec<2, T, Q> const& v) : x(v.x), y(v.y) { } template - constexpr VectorT<2, T, Q>::VectorT(T scalar) : x(scalar), y(scalar) + constexpr vec<2, T, Q>::vec(T scalar) : x(scalar), y(scalar) { } @@ -76,7 +76,7 @@ namespace mim template template - constexpr VectorT<2, T, Q>::VectorT(VectorT<2, T, P> const& v) : x(v.x), y(v.y) + constexpr vec<2, T, Q>::vec(vec<2, T, P> const& v) : x(v.x), y(v.y) { } @@ -84,25 +84,25 @@ namespace mim template template - constexpr VectorT<2, T, Q>::VectorT(VectorT<1, U, P> const& scalar) : x(static_cast(scalar.x)), y(static_cast(scalar.x)) + constexpr vec<2, T, Q>::vec(vec<1, U, P> const& scalar) : x(static_cast(scalar.x)), y(static_cast(scalar.x)) { } template template - constexpr VectorT<2, T, Q>::VectorT(VectorT<2, U, P> const& v) : x(static_cast(v.x)), y(static_cast(v.y)) + constexpr vec<2, T, Q>::vec(vec<2, U, P> const& v) : x(static_cast(v.x)), y(static_cast(v.y)) { } template template - constexpr VectorT<2, T, Q>::VectorT(VectorT<3, U, P> const& v) : x(static_cast(v.x)), y(static_cast(v.y)) + constexpr vec<2, T, Q>::vec(vec<3, U, P> const& v) : x(static_cast(v.x)), y(static_cast(v.y)) { } template template - constexpr VectorT<2, T, Q>::VectorT(VectorT<4, U, P> const& v) : x(static_cast(v.x)), y(static_cast(v.y)) + constexpr vec<2, T, Q>::vec(vec<4, U, P> const& v) : x(static_cast(v.x)), y(static_cast(v.y)) { } @@ -110,32 +110,32 @@ namespace mim template template - constexpr VectorT<2, T, Q>::VectorT(A _x, B _y) : x(static_cast(_x)), y(static_cast(_y)) + constexpr vec<2, T, Q>::vec(A _x, B _y) : x(static_cast(_x)), y(static_cast(_y)) { } template template - constexpr VectorT<2, T, Q>::VectorT(VectorT<1, A, Q> const& _x, B _y) : x(static_cast(_x.x)), y(static_cast(_y)) + constexpr vec<2, T, Q>::vec(vec<1, A, Q> const& _x, B _y) : x(static_cast(_x.x)), y(static_cast(_y)) { } template template - constexpr VectorT<2, T, Q>::VectorT(A _x, VectorT<1, B, Q> const& _y) : x(static_cast(_x)), y(static_cast(_y.x)) + constexpr vec<2, T, Q>::vec(A _x, vec<1, B, Q> const& _y) : x(static_cast(_x)), y(static_cast(_y.x)) { } template template - constexpr VectorT<2, T, Q>::VectorT(VectorT<1, A, Q> const& _x, VectorT<1, B, Q> const& _y) : x(static_cast(_x.x)), y(static_cast(_y.x)) + constexpr vec<2, T, Q>::vec(vec<1, A, Q> const& _x, vec<1, B, Q> const& _y) : x(static_cast(_x.x)), y(static_cast(_y.x)) { } /// Assignment Operators template - constexpr VectorT<2, T, Q>& VectorT<2, T, Q>::operator=(T scalar) + constexpr vec<2, T, Q>& vec<2, T, Q>::operator=(T scalar) { this->x = scalar; this->y = scalar; @@ -143,7 +143,7 @@ namespace mim } template - constexpr VectorT<2, T, Q>& VectorT<2, T, Q>::operator=(VectorT const& v) + constexpr vec<2, T, Q>& vec<2, T, Q>::operator=(vec const& v) { this->x = v.x; this->y = v.y; @@ -155,7 +155,7 @@ namespace mim */ template template - constexpr VectorT<2, T, Q>& VectorT<2, T, Q>::operator=(VectorT<1, U, Q> const& scalar) + constexpr vec<2, T, Q>& vec<2, T, Q>::operator=(vec<1, U, Q> const& scalar) { this->x = static_cast(scalar.x); this->y = static_cast(scalar.x); @@ -164,7 +164,7 @@ namespace mim template template - constexpr VectorT<2, T, Q>& VectorT<2, T, Q>::operator=(VectorT<2, U, Q> const& v) + constexpr vec<2, T, Q>& vec<2, T, Q>::operator=(vec<2, U, Q> const& v) { this->x = static_cast(v.x); this->y = static_cast(v.y); @@ -173,7 +173,7 @@ namespace mim template template - constexpr VectorT<2, T, Q>& VectorT<2, T, Q>::operator+=(U scalar) + constexpr vec<2, T, Q>& vec<2, T, Q>::operator+=(U scalar) { this->x += static_cast(scalar); this->y += static_cast(scalar); @@ -185,7 +185,7 @@ namespace mim */ template template - constexpr VectorT<2, T, Q>& VectorT<2, T, Q>::operator+=(VectorT<1, U, Q> const& scalar) + constexpr vec<2, T, Q>& vec<2, T, Q>::operator+=(vec<1, U, Q> const& scalar) { this->x += static_cast(scalar.x); this->y += static_cast(scalar.x); @@ -194,7 +194,7 @@ namespace mim template template - constexpr VectorT<2, T, Q>& VectorT<2, T, Q>::operator+=(VectorT<2, U, Q> const& v) + constexpr vec<2, T, Q>& vec<2, T, Q>::operator+=(vec<2, U, Q> const& v) { this->x += static_cast(v.x); this->y += static_cast(v.y); @@ -203,7 +203,7 @@ namespace mim template template - constexpr VectorT<2, T, Q>& VectorT<2, T, Q>::operator-=(U scalar) + constexpr vec<2, T, Q>& vec<2, T, Q>::operator-=(U scalar) { this->x -= static_cast(scalar); this->y -= static_cast(scalar); @@ -215,7 +215,7 @@ namespace mim */ template template - constexpr VectorT<2, T, Q>& VectorT<2, T, Q>::operator-=(VectorT<1, U, Q> const& scalar) + constexpr vec<2, T, Q>& vec<2, T, Q>::operator-=(vec<1, U, Q> const& scalar) { this->x -= static_cast(scalar.x); this->y -= static_cast(scalar.x); @@ -224,7 +224,7 @@ namespace mim template template - constexpr VectorT<2, T, Q>& VectorT<2, T, Q>::operator-=(VectorT<2, U, Q> const& v) + constexpr vec<2, T, Q>& vec<2, T, Q>::operator-=(vec<2, U, Q> const& v) { this->x -= static_cast(v.x); this->y -= static_cast(v.y); @@ -233,7 +233,7 @@ namespace mim template template - constexpr VectorT<2, T, Q>& VectorT<2, T, Q>::operator*=(U scalar) + constexpr vec<2, T, Q>& vec<2, T, Q>::operator*=(U scalar) { this->x *= static_cast(scalar); this->y *= static_cast(scalar); @@ -245,7 +245,7 @@ namespace mim */ template template - constexpr VectorT<2, T, Q>& VectorT<2, T, Q>::operator*=(VectorT<1, U, Q> const& scalar) + constexpr vec<2, T, Q>& vec<2, T, Q>::operator*=(vec<1, U, Q> const& scalar) { this->x *= static_cast(scalar.x); this->y *= static_cast(scalar.x); @@ -254,7 +254,7 @@ namespace mim template template - constexpr VectorT<2, T, Q>& VectorT<2, T, Q>::operator*=(VectorT<2, U, Q> const& v) + constexpr vec<2, T, Q>& vec<2, T, Q>::operator*=(vec<2, U, Q> const& v) { this->x *= static_cast(v.x); this->y *= static_cast(v.y); @@ -263,7 +263,7 @@ namespace mim template template - constexpr VectorT<2, T, Q>& VectorT<2, T, Q>::operator/=(U scalar) + constexpr vec<2, T, Q>& vec<2, T, Q>::operator/=(U scalar) { this->x /= static_cast(scalar); this->y /= static_cast(scalar); @@ -275,7 +275,7 @@ namespace mim */ template template - constexpr VectorT<2, T, Q>& VectorT<2, T, Q>::operator/=(VectorT<1, U, Q> const& scalar) + constexpr vec<2, T, Q>& vec<2, T, Q>::operator/=(vec<1, U, Q> const& scalar) { this->x /= static_cast(scalar.x); this->y /= static_cast(scalar.x); @@ -284,7 +284,7 @@ namespace mim template template - constexpr VectorT<2, T, Q>& VectorT<2, T, Q>::operator/=(VectorT<2, U, Q> const& v) + constexpr vec<2, T, Q>& vec<2, T, Q>::operator/=(vec<2, U, Q> const& v) { this->x /= static_cast(v.x); this->y /= static_cast(v.y); @@ -293,7 +293,7 @@ namespace mim template template - constexpr VectorT<2, T, Q>& VectorT<2, T, Q>::operator%=(U scalar) + constexpr vec<2, T, Q>& vec<2, T, Q>::operator%=(U scalar) { this->x %= static_cast(scalar); this->y %= static_cast(scalar); @@ -305,7 +305,7 @@ namespace mim */ template template - constexpr VectorT<2, T, Q>& VectorT<2, T, Q>::operator%=(VectorT<1, U, Q> const& scalar) + constexpr vec<2, T, Q>& vec<2, T, Q>::operator%=(vec<1, U, Q> const& scalar) { this->x %= static_cast(scalar.x); this->y %= static_cast(scalar.x); @@ -314,7 +314,7 @@ namespace mim template template - constexpr VectorT<2, T, Q>& VectorT<2, T, Q>::operator%=(VectorT<2, U, Q> const& v) + constexpr vec<2, T, Q>& vec<2, T, Q>::operator%=(vec<2, U, Q> const& v) { this->x %= static_cast(v.x); this->y %= static_cast(v.y); @@ -324,7 +324,7 @@ namespace mim /// Increment and Decrement Operators template - constexpr VectorT<2, T, Q>& VectorT<2, T, Q>::operator++() + constexpr vec<2, T, Q>& vec<2, T, Q>::operator++() { ++this->x; ++this->y; @@ -332,7 +332,7 @@ namespace mim } template - constexpr VectorT<2, T, Q>& VectorT<2, T, Q>::operator--() + constexpr vec<2, T, Q>& vec<2, T, Q>::operator--() { --this->x; --this->y; @@ -340,18 +340,18 @@ namespace mim } template - constexpr const VectorT<2, T, Q> VectorT<2, T, Q>::operator++(int) + constexpr const vec<2, T, Q> vec<2, T, Q>::operator++(int) { - VectorT<2, T, Q> v(*this); + vec<2, T, Q> v(*this); ++this->x; ++this->y; return v; } template - constexpr const VectorT<2, T, Q> VectorT<2, T, Q>::operator--(int) + constexpr const vec<2, T, Q> vec<2, T, Q>::operator--(int) { - VectorT<2, T, Q> v(*this); + vec<2, T, Q> v(*this); --this->x; --this->y; return v; @@ -363,7 +363,7 @@ namespace mim template template - constexpr VectorT<2, T, Q>& VectorT<2, T, Q>::operator&=(U scalar) + constexpr vec<2, T, Q>& vec<2, T, Q>::operator&=(U scalar) { this->x &= static_cast(scalar); this->y &= static_cast(scalar); @@ -375,7 +375,7 @@ namespace mim */ template template - constexpr VectorT<2, T, Q>& VectorT<2, T, Q>::operator&=(VectorT<1, U, Q> const& scalar) + constexpr vec<2, T, Q>& vec<2, T, Q>::operator&=(vec<1, U, Q> const& scalar) { this->x &= static_cast(scalar.x); this->y &= static_cast(scalar.x); @@ -384,7 +384,7 @@ namespace mim template template - constexpr VectorT<2, T, Q>& VectorT<2, T, Q>::operator&=(VectorT<2, U, Q> const& v) + constexpr vec<2, T, Q>& vec<2, T, Q>::operator&=(vec<2, U, Q> const& v) { this->x &= static_cast(v.x); this->y &= static_cast(v.y); @@ -393,7 +393,7 @@ namespace mim template template - constexpr VectorT<2, T, Q>& VectorT<2, T, Q>::operator|=(U scalar) + constexpr vec<2, T, Q>& vec<2, T, Q>::operator|=(U scalar) { this->x |= static_cast(scalar); this->y |= static_cast(scalar); @@ -405,7 +405,7 @@ namespace mim */ template template - constexpr VectorT<2, T, Q>& VectorT<2, T, Q>::operator|=(VectorT<1, U, Q> const& scalar) + constexpr vec<2, T, Q>& vec<2, T, Q>::operator|=(vec<1, U, Q> const& scalar) { this->x |= static_cast(scalar.x); this->y |= static_cast(scalar.x); @@ -414,7 +414,7 @@ namespace mim template template - constexpr VectorT<2, T, Q>& VectorT<2, T, Q>::operator|=(VectorT<2, U, Q> const& v) + constexpr vec<2, T, Q>& vec<2, T, Q>::operator|=(vec<2, U, Q> const& v) { this->x |= static_cast(v.x); this->y |= static_cast(v.y); @@ -423,7 +423,7 @@ namespace mim template template - constexpr VectorT<2, T, Q>& VectorT<2, T, Q>::operator^=(U scalar) + constexpr vec<2, T, Q>& vec<2, T, Q>::operator^=(U scalar) { this->x ^= static_cast(scalar); this->y ^= static_cast(scalar); @@ -435,7 +435,7 @@ namespace mim */ template template - constexpr VectorT<2, T, Q>& VectorT<2, T, Q>::operator^=(VectorT<1, U, Q> const& scalar) + constexpr vec<2, T, Q>& vec<2, T, Q>::operator^=(vec<1, U, Q> const& scalar) { this->x ^= static_cast(scalar.x); this->y ^= static_cast(scalar.x); @@ -444,7 +444,7 @@ namespace mim template template - constexpr VectorT<2, T, Q>& VectorT<2, T, Q>::operator^=(VectorT<2, U, Q> const& v) + constexpr vec<2, T, Q>& vec<2, T, Q>::operator^=(vec<2, U, Q> const& v) { this->x ^= static_cast(v.x); this->y ^= static_cast(v.y); @@ -453,7 +453,7 @@ namespace mim template template - constexpr VectorT<2, T, Q>& VectorT<2, T, Q>::operator<<=(U scalar) + constexpr vec<2, T, Q>& vec<2, T, Q>::operator<<=(U scalar) { this->x <<= static_cast(scalar); this->y <<= static_cast(scalar); @@ -465,7 +465,7 @@ namespace mim */ template template - constexpr VectorT<2, T, Q>& VectorT<2, T, Q>::operator<<=(VectorT<1, U, Q> const& scalar) + constexpr vec<2, T, Q>& vec<2, T, Q>::operator<<=(vec<1, U, Q> const& scalar) { this->x <<= static_cast(scalar.x); this->y <<= static_cast(scalar.x); @@ -474,7 +474,7 @@ namespace mim template template - constexpr VectorT<2, T, Q>& VectorT<2, T, Q>::operator<<=(VectorT<2, U, Q> const& v) + constexpr vec<2, T, Q>& vec<2, T, Q>::operator<<=(vec<2, U, Q> const& v) { this->x <<= static_cast(v.x); this->y <<= static_cast(v.y); @@ -483,7 +483,7 @@ namespace mim template template - constexpr VectorT<2, T, Q>& VectorT<2, T, Q>::operator>>=(U scalar) + constexpr vec<2, T, Q>& vec<2, T, Q>::operator>>=(U scalar) { this->x >>= static_cast(scalar); this->y >>= static_cast(scalar); @@ -495,7 +495,7 @@ namespace mim */ template template - constexpr VectorT<2, T, Q>& VectorT<2, T, Q>::operator>>=(VectorT<1, U, Q> const& scalar) + constexpr vec<2, T, Q>& vec<2, T, Q>::operator>>=(vec<1, U, Q> const& scalar) { this->x >>= static_cast(scalar.x); this->y >>= static_cast(scalar.x); @@ -504,7 +504,7 @@ namespace mim template template - constexpr VectorT<2, T, Q>& VectorT<2, T, Q>::operator>>=(VectorT<2, U, Q> const& v) + constexpr vec<2, T, Q>& vec<2, T, Q>::operator>>=(vec<2, U, Q> const& v) { this->x >>= static_cast(v.x); this->y >>= static_cast(v.y); @@ -517,409 +517,409 @@ namespace mim /// Unary operators template - constexpr VectorT<2, T, Q> operator+(VectorT<2, T, Q> const& v) + constexpr vec<2, T, Q> operator+(vec<2, T, Q> const& v) { return v; } template - constexpr VectorT<2, T, Q> operator-(VectorT<2, T, Q> const& v) + constexpr vec<2, T, Q> operator-(vec<2, T, Q> const& v) { - return VectorT<2, T, Q>(-v.x, -v.y); + return vec<2, T, Q>(-v.x, -v.y); } /// Binary Operators template - constexpr VectorT<2, T, Q> operator+(VectorT<2, T, Q> const& v, T scalar) + constexpr vec<2, T, Q> operator+(vec<2, T, Q> const& v, T scalar) { - return VectorT<2, T, Q>(v.x + scalar, v.y + scalar); + return vec<2, T, Q>(v.x + scalar, v.y + scalar); } template - constexpr VectorT<2, T, Q> operator+(T scalar, VectorT<2, T, Q> const& v) + constexpr vec<2, T, Q> operator+(T scalar, vec<2, T, Q> const& v) { - return VectorT<2, T, Q>(scalar + v.x, scalar + v.y); + return vec<2, T, Q>(scalar + v.x, scalar + v.y); } /* * \note Vec1 is deliberately treated like a scalar to mimic shader languages. */ template - constexpr VectorT<2, T, Q> operator+(VectorT<2, T, Q> const& v1, VectorT<1, T, Q> const& v2) + constexpr vec<2, T, Q> operator+(vec<2, T, Q> const& v1, vec<1, T, Q> const& v2) { - return VectorT<2, T, Q>(v1.x + v2.x, v1.y + v2.x); + return vec<2, T, Q>(v1.x + v2.x, v1.y + v2.x); } /* * \note Vec1 is deliberately treated like a scalar to mimic shader languages. */ template - constexpr VectorT<2, T, Q> operator+(VectorT<1, T, Q> const& v1, VectorT<2, T, Q> const& v2) + constexpr vec<2, T, Q> operator+(vec<1, T, Q> const& v1, vec<2, T, Q> const& v2) { - return VectorT<2, T, Q>(v1.x + v2.x, v1.x + v2.y); + return vec<2, T, Q>(v1.x + v2.x, v1.x + v2.y); } template - constexpr VectorT<2, T, Q> operator+(VectorT<2, T, Q> const& v1, VectorT<2, T, Q> const& v2) + constexpr vec<2, T, Q> operator+(vec<2, T, Q> const& v1, vec<2, T, Q> const& v2) { - return VectorT<2, T, Q>(v1.x + v2.x, v1.y + v2.y); + return vec<2, T, Q>(v1.x + v2.x, v1.y + v2.y); } template - constexpr VectorT<2, T, Q> operator-(VectorT<2, T, Q> const& v, T scalar) + constexpr vec<2, T, Q> operator-(vec<2, T, Q> const& v, T scalar) { - return VectorT<2, T, Q>(v.x - scalar, v.y - scalar); + return vec<2, T, Q>(v.x - scalar, v.y - scalar); } template - constexpr VectorT<2, T, Q> operator-(T scalar, VectorT<2, T, Q> const& v) + constexpr vec<2, T, Q> operator-(T scalar, vec<2, T, Q> const& v) { - return VectorT<2, T, Q>(scalar - v.x, scalar - v.y); + return vec<2, T, Q>(scalar - v.x, scalar - v.y); } /* * \note Vec1 is deliberately treated like a scalar to mimic shader languages. */ template - constexpr VectorT<2, T, Q> operator-(VectorT<2, T, Q> const& v1, VectorT<1, T, Q> const& v2) + constexpr vec<2, T, Q> operator-(vec<2, T, Q> const& v1, vec<1, T, Q> const& v2) { - return VectorT<2, T, Q>(v1.x - v2.x, v1.y - v2.x); + return vec<2, T, Q>(v1.x - v2.x, v1.y - v2.x); } /* * \note Vec1 is deliberately treated like a scalar to mimic shader languages. */ template - constexpr VectorT<2, T, Q> operator-(VectorT<1, T, Q> const& v1, VectorT<2, T, Q> const& v2) + constexpr vec<2, T, Q> operator-(vec<1, T, Q> const& v1, vec<2, T, Q> const& v2) { - return VectorT<2, T, Q>(v1.x - v2.x, v1.x - v2.y); + return vec<2, T, Q>(v1.x - v2.x, v1.x - v2.y); } template - constexpr VectorT<2, T, Q> operator-(VectorT<2, T, Q> const& v1, VectorT<2, T, Q> const& v2) + constexpr vec<2, T, Q> operator-(vec<2, T, Q> const& v1, vec<2, T, Q> const& v2) { - return VectorT<2, T, Q>(v1.x - v2.x, v1.y - v2.y); + return vec<2, T, Q>(v1.x - v2.x, v1.y - v2.y); } template - constexpr VectorT<2, T, Q> operator*(VectorT<2, T, Q> const& v, T scalar) + constexpr vec<2, T, Q> operator*(vec<2, T, Q> const& v, T scalar) { - return VectorT<2, T, Q>(v.x * scalar, v.y * scalar); + return vec<2, T, Q>(v.x * scalar, v.y * scalar); } template - constexpr VectorT<2, T, Q> operator*(T scalar, VectorT<2, T, Q> const& v) + constexpr vec<2, T, Q> operator*(T scalar, vec<2, T, Q> const& v) { - return VectorT<2, T, Q>(scalar * v.x, scalar * v.y); + return vec<2, T, Q>(scalar * v.x, scalar * v.y); } /* * \note Vec1 is deliberately treated like a scalar to mimic shader languages. */ template - constexpr VectorT<2, T, Q> operator*(VectorT<2, T, Q> const& v1, VectorT<1, T, Q> const& v2) + constexpr vec<2, T, Q> operator*(vec<2, T, Q> const& v1, vec<1, T, Q> const& v2) { - return VectorT<2, T, Q>(v1.x * v2.x, v1.y * v2.x); + return vec<2, T, Q>(v1.x * v2.x, v1.y * v2.x); } /* * \note Vec1 is deliberately treated like a scalar to mimic shader languages. */ template - constexpr VectorT<2, T, Q> operator*(VectorT<1, T, Q> const& v1, VectorT<2, T, Q> const& v2) + constexpr vec<2, T, Q> operator*(vec<1, T, Q> const& v1, vec<2, T, Q> const& v2) { - return VectorT<2, T, Q>(v1.x * v2.x, v1.x * v2.y); + return vec<2, T, Q>(v1.x * v2.x, v1.x * v2.y); } template - constexpr VectorT<2, T, Q> operator*(VectorT<2, T, Q> const& v1, VectorT<2, T, Q> const& v2) + constexpr vec<2, T, Q> operator*(vec<2, T, Q> const& v1, vec<2, T, Q> const& v2) { - return VectorT<2, T, Q>(v1.x * v2.x, v1.y * v2.y); + return vec<2, T, Q>(v1.x * v2.x, v1.y * v2.y); } template - constexpr VectorT<2, T, Q> operator/(VectorT<2, T, Q> const& v, T scalar) + constexpr vec<2, T, Q> operator/(vec<2, T, Q> const& v, T scalar) { - return VectorT<2, T, Q>(v.x / scalar, v.y / scalar); + return vec<2, T, Q>(v.x / scalar, v.y / scalar); } template - constexpr VectorT<2, T, Q> operator/(T scalar, VectorT<2, T, Q> const& v) + constexpr vec<2, T, Q> operator/(T scalar, vec<2, T, Q> const& v) { - return VectorT<2, T, Q>(scalar / v.x, scalar / v.y); + return vec<2, T, Q>(scalar / v.x, scalar / v.y); } /* * \note Vec1 is deliberately treated like a scalar to mimic shader languages. */ template - constexpr VectorT<2, T, Q> operator/(VectorT<2, T, Q> const& v1, VectorT<1, T, Q> const& v2) + constexpr vec<2, T, Q> operator/(vec<2, T, Q> const& v1, vec<1, T, Q> const& v2) { - return VectorT<2, T, Q>(v1.x / v2.x, v1.y / v2.x); + return vec<2, T, Q>(v1.x / v2.x, v1.y / v2.x); } /* * \note Vec1 is deliberately treated like a scalar to mimic shader languages. */ template - constexpr VectorT<2, T, Q> operator/(VectorT<1, T, Q> const& v1, VectorT<2, T, Q> const& v2) + constexpr vec<2, T, Q> operator/(vec<1, T, Q> const& v1, vec<2, T, Q> const& v2) { - return VectorT<2, T, Q>(v1.x / v2.x, v1.x / v2.y); + return vec<2, T, Q>(v1.x / v2.x, v1.x / v2.y); } template - constexpr VectorT<2, T, Q> operator/(VectorT<2, T, Q> const& v1, VectorT<2, T, Q> const& v2) + constexpr vec<2, T, Q> operator/(vec<2, T, Q> const& v1, vec<2, T, Q> const& v2) { - return VectorT<2, T, Q>(v1.x / v2.x, v1.y / v2.y); + return vec<2, T, Q>(v1.x / v2.x, v1.y / v2.y); } template - constexpr VectorT<2, T, Q> operator%(VectorT<2, T, Q> const& v, T scalar) + constexpr vec<2, T, Q> operator%(vec<2, T, Q> const& v, T scalar) { - return VectorT<2, T, Q>(v.x % scalar, v.y % scalar); + return vec<2, T, Q>(v.x % scalar, v.y % scalar); } template - constexpr VectorT<2, T, Q> operator%(T scalar, VectorT<2, T, Q> const& v) + constexpr vec<2, T, Q> operator%(T scalar, vec<2, T, Q> const& v) { - return VectorT<2, T, Q>(scalar % v.x, scalar % v.y); + return vec<2, T, Q>(scalar % v.x, scalar % v.y); } /* * \note Vec1 is deliberately treated like a scalar to mimic shader languages. */ template - constexpr VectorT<2, T, Q> operator%(VectorT<2, T, Q> const& v1, VectorT<1, T, Q> const& v2) + constexpr vec<2, T, Q> operator%(vec<2, T, Q> const& v1, vec<1, T, Q> const& v2) { - return VectorT<2, T, Q>(v1.x % v2.x, v1.y % v2.x); + return vec<2, T, Q>(v1.x % v2.x, v1.y % v2.x); } /* * \note Vec1 is deliberately treated like a scalar to mimic shader languages. */ template - constexpr VectorT<2, T, Q> operator%(VectorT<1, T, Q> const& v1, VectorT<2, T, Q> const& v2) + constexpr vec<2, T, Q> operator%(vec<1, T, Q> const& v1, vec<2, T, Q> const& v2) { - return VectorT<2, T, Q>(v1.x % v2.x, v1.x % v2.y); + return vec<2, T, Q>(v1.x % v2.x, v1.x % v2.y); } template - constexpr VectorT<2, T, Q> operator%(VectorT<2, T, Q> const& v1, VectorT<2, T, Q> const& v2) + constexpr vec<2, T, Q> operator%(vec<2, T, Q> const& v1, vec<2, T, Q> const& v2) { - return VectorT<2, T, Q>(v1.x % v2.x, v1.y % v2.y); + return vec<2, T, Q>(v1.x % v2.x, v1.y % v2.y); } /// Bitwise Binary Operators template - constexpr VectorT<2, T, Q> operator&(VectorT<2, T, Q> const& v, T scalar) + constexpr vec<2, T, Q> operator&(vec<2, T, Q> const& v, T scalar) { - return VectorT<2, T, Q>(v.x & scalar, v.y & scalar); + return vec<2, T, Q>(v.x & scalar, v.y & scalar); } template - constexpr VectorT<2, T, Q> operator&(T scalar, VectorT<2, T, Q> const& v) + constexpr vec<2, T, Q> operator&(T scalar, vec<2, T, Q> const& v) { - return VectorT<2, T, Q>(scalar & v.x, scalar & v.y); + return vec<2, T, Q>(scalar & v.x, scalar & v.y); } /* * \note Vec1 is deliberately treated like a scalar to mimic shader languages. */ template - constexpr VectorT<2, T, Q> operator&(VectorT<2, T, Q> const& v1, VectorT<1, T, Q> const& v2) + constexpr vec<2, T, Q> operator&(vec<2, T, Q> const& v1, vec<1, T, Q> const& v2) { - return VectorT<2, T, Q>(v1.x & v2.x, v1.y & v2.x); + return vec<2, T, Q>(v1.x & v2.x, v1.y & v2.x); } /* * \note Vec1 is deliberately treated like a scalar to mimic shader languages. */ template - constexpr VectorT<2, T, Q> operator&(VectorT<1, T, Q> const& v1, VectorT<2, T, Q> const& v2) + constexpr vec<2, T, Q> operator&(vec<1, T, Q> const& v1, vec<2, T, Q> const& v2) { - return VectorT<2, T, Q>(v1.x & v2.x, v1.x & v2.y); + return vec<2, T, Q>(v1.x & v2.x, v1.x & v2.y); } template - constexpr VectorT<2, T, Q> operator&(VectorT<2, T, Q> const& v1, VectorT<2, T, Q> const& v2) + constexpr vec<2, T, Q> operator&(vec<2, T, Q> const& v1, vec<2, T, Q> const& v2) { - return VectorT<2, T, Q>(v1.x & v2.x, v1.y & v2.y); + return vec<2, T, Q>(v1.x & v2.x, v1.y & v2.y); } template - constexpr VectorT<2, T, Q> operator|(VectorT<2, T, Q> const& v, T scalar) + constexpr vec<2, T, Q> operator|(vec<2, T, Q> const& v, T scalar) { - return VectorT<2, T, Q>(v.x | scalar, v.y | scalar); + return vec<2, T, Q>(v.x | scalar, v.y | scalar); } template - constexpr VectorT<2, T, Q> operator|(T scalar, VectorT<2, T, Q> const& v) + constexpr vec<2, T, Q> operator|(T scalar, vec<2, T, Q> const& v) { - return VectorT<2, T, Q>(scalar | v.x, scalar | v.y); + return vec<2, T, Q>(scalar | v.x, scalar | v.y); } /* * \note Vec1 is deliberately treated like a scalar to mimic shader languages. */ template - constexpr VectorT<2, T, Q> operator|(VectorT<2, T, Q> const& v1, VectorT<1, T, Q> const& v2) + constexpr vec<2, T, Q> operator|(vec<2, T, Q> const& v1, vec<1, T, Q> const& v2) { - return VectorT<2, T, Q>(v1.x | v2.x, v1.y | v2.x); + return vec<2, T, Q>(v1.x | v2.x, v1.y | v2.x); } /* * \note Vec1 is deliberately treated like a scalar to mimic shader languages. */ template - constexpr VectorT<2, T, Q> operator|(VectorT<1, T, Q> const& v1, VectorT<2, T, Q> const& v2) + constexpr vec<2, T, Q> operator|(vec<1, T, Q> const& v1, vec<2, T, Q> const& v2) { - return VectorT<2, T, Q>(v1.x | v2.x, v1.x | v2.y); + return vec<2, T, Q>(v1.x | v2.x, v1.x | v2.y); } template - constexpr VectorT<2, T, Q> operator|(VectorT<2, T, Q> const& v1, VectorT<2, T, Q> const& v2) + constexpr vec<2, T, Q> operator|(vec<2, T, Q> const& v1, vec<2, T, Q> const& v2) { - return VectorT<2, T, Q>(v1.x | v2.x, v1.y | v2.y); + return vec<2, T, Q>(v1.x | v2.x, v1.y | v2.y); } template - constexpr VectorT<2, T, Q> operator^(VectorT<2, T, Q> const& v, T scalar) + constexpr vec<2, T, Q> operator^(vec<2, T, Q> const& v, T scalar) { - return VectorT<2, T, Q>(v.x ^ scalar, v.y ^ scalar); + return vec<2, T, Q>(v.x ^ scalar, v.y ^ scalar); } template - constexpr VectorT<2, T, Q> operator^(T scalar, VectorT<2, T, Q> const& v) + constexpr vec<2, T, Q> operator^(T scalar, vec<2, T, Q> const& v) { - return VectorT<2, T, Q>(scalar ^ v.x, scalar ^ v.y); + return vec<2, T, Q>(scalar ^ v.x, scalar ^ v.y); } /* * \note Vec1 is deliberately treated like a scalar to mimic shader languages. */ template - constexpr VectorT<2, T, Q> operator^(VectorT<2, T, Q> const& v1, VectorT<1, T, Q> const& v2) + constexpr vec<2, T, Q> operator^(vec<2, T, Q> const& v1, vec<1, T, Q> const& v2) { - return VectorT<2, T, Q>(v1.x ^ v2.x, v1.y ^ v2.x); + return vec<2, T, Q>(v1.x ^ v2.x, v1.y ^ v2.x); } /* * \note Vec1 is deliberately treated like a scalar to mimic shader languages. */ template - constexpr VectorT<2, T, Q> operator^(VectorT<1, T, Q> const& v1, VectorT<2, T, Q> const& v2) + constexpr vec<2, T, Q> operator^(vec<1, T, Q> const& v1, vec<2, T, Q> const& v2) { - return VectorT<2, T, Q>(v1.x ^ v2.x, v1.x ^ v2.y); + return vec<2, T, Q>(v1.x ^ v2.x, v1.x ^ v2.y); } template - constexpr VectorT<2, T, Q> operator^(VectorT<2, T, Q> const& v1, VectorT<2, T, Q> const& v2) + constexpr vec<2, T, Q> operator^(vec<2, T, Q> const& v1, vec<2, T, Q> const& v2) { - return VectorT<2, T, Q>(v1.x ^ v2.x, v1.y ^ v2.y); + return vec<2, T, Q>(v1.x ^ v2.x, v1.y ^ v2.y); } template - constexpr VectorT<2, T, Q> operator<<(VectorT<2, T, Q> const& v, T scalar) + constexpr vec<2, T, Q> operator<<(vec<2, T, Q> const& v, T scalar) { - return VectorT<2, T, Q>(v.x << scalar, v.y << scalar); + return vec<2, T, Q>(v.x << scalar, v.y << scalar); } template - constexpr VectorT<2, T, Q> operator<<(T scalar, VectorT<2, T, Q> const& v) + constexpr vec<2, T, Q> operator<<(T scalar, vec<2, T, Q> const& v) { - return VectorT<2, T, Q>(scalar << v.x, scalar << v.y); + return vec<2, T, Q>(scalar << v.x, scalar << v.y); } /* * \note Vec1 is deliberately treated like a scalar to mimic shader languages. */ template - constexpr VectorT<2, T, Q> operator<<(VectorT<2, T, Q> const& v1, VectorT<1, T, Q> const& v2) + constexpr vec<2, T, Q> operator<<(vec<2, T, Q> const& v1, vec<1, T, Q> const& v2) { - return VectorT<2, T, Q>(v1.x << v2.x, v1.y << v2.x); + return vec<2, T, Q>(v1.x << v2.x, v1.y << v2.x); } /* * \note Vec1 is deliberately treated like a scalar to mimic shader languages. */ template - constexpr VectorT<2, T, Q> operator<<(VectorT<1, T, Q> const& v1, VectorT<2, T, Q> const& v2) + constexpr vec<2, T, Q> operator<<(vec<1, T, Q> const& v1, vec<2, T, Q> const& v2) { - return VectorT<2, T, Q>(v1.x << v2.x, v1.x << v2.y); + return vec<2, T, Q>(v1.x << v2.x, v1.x << v2.y); } template - constexpr VectorT<2, T, Q> operator<<(VectorT<2, T, Q> const& v1, VectorT<2, T, Q> const& v2) + constexpr vec<2, T, Q> operator<<(vec<2, T, Q> const& v1, vec<2, T, Q> const& v2) { - return VectorT<2, T, Q>(v1.x << v2.x, v1.y << v2.y); + return vec<2, T, Q>(v1.x << v2.x, v1.y << v2.y); } template - constexpr VectorT<2, T, Q> operator>>(VectorT<2, T, Q> const& v, T scalar) + constexpr vec<2, T, Q> operator>>(vec<2, T, Q> const& v, T scalar) { - return VectorT<2, T, Q>(v.x >> scalar, v.y >> scalar); + return vec<2, T, Q>(v.x >> scalar, v.y >> scalar); } template - constexpr VectorT<2, T, Q> operator>>(T scalar, VectorT<2, T, Q> const& v) + constexpr vec<2, T, Q> operator>>(T scalar, vec<2, T, Q> const& v) { - return VectorT<2, T, Q>(scalar >> v.x, scalar >> v.y); + return vec<2, T, Q>(scalar >> v.x, scalar >> v.y); } /* * \note Vec1 is deliberately treated like a scalar to mimic shader languages. */ template - constexpr VectorT<2, T, Q> operator>>(VectorT<2, T, Q> const& v1, VectorT<1, T, Q> const& v2) + constexpr vec<2, T, Q> operator>>(vec<2, T, Q> const& v1, vec<1, T, Q> const& v2) { - return VectorT<2, T, Q>(v1.x >> v2.x, v1.y >> v2.x); + return vec<2, T, Q>(v1.x >> v2.x, v1.y >> v2.x); } /* * \note Vec1 is deliberately treated like a scalar to mimic shader languages. */ template - constexpr VectorT<2, T, Q> operator>>(VectorT<1, T, Q> const& v1, VectorT<2, T, Q> const& v2) + constexpr vec<2, T, Q> operator>>(vec<1, T, Q> const& v1, vec<2, T, Q> const& v2) { - return VectorT<2, T, Q>(v1.x >> v2.x, v1.x >> v2.y); + return vec<2, T, Q>(v1.x >> v2.x, v1.x >> v2.y); } template - constexpr VectorT<2, T, Q> operator>>(VectorT<2, T, Q> const& v1, VectorT<2, T, Q> const& v2) + constexpr vec<2, T, Q> operator>>(vec<2, T, Q> const& v1, vec<2, T, Q> const& v2) { - return VectorT<2, T, Q>(v1.x >> v2.x, v1.y >> v2.y); + return vec<2, T, Q>(v1.x >> v2.x, v1.y >> v2.y); } template - constexpr VectorT<2, T, Q> operator~(VectorT<2, T, Q> const& v) + constexpr vec<2, T, Q> operator~(vec<2, T, Q> const& v) { - return VectorT<2, T, Q>(~v.x, ~v.y); + return vec<2, T, Q>(~v.x, ~v.y); } /// Conditional Operators template - constexpr bool operator==(VectorT<2, T, Q> const& v1, VectorT<2, T, Q> const& v2) + constexpr bool operator==(vec<2, T, Q> const& v1, vec<2, T, Q> const& v2) { return detail::Equal::is_iec559, sizeof(T) * 4, detail::IsAligned::value>::compute(v1, v2); } template - constexpr bool operator!=(VectorT<2, T, Q> const& v1, VectorT<2, T, Q> const& v2) + constexpr bool operator!=(vec<2, T, Q> const& v1, vec<2, T, Q> const& v2) { return !(v1 == v2); } template - constexpr bool operator&&(VectorT<2, T, Q> const& v1, VectorT<2, T, Q> const& v2) + constexpr bool operator&&(vec<2, T, Q> const& v1, vec<2, T, Q> const& v2) { return (v1.x && v2.x, v1.y && v2.y); } template - constexpr bool operator||(VectorT<2, T, Q> const& v1, VectorT<2, T, Q> const& v2) + constexpr bool operator||(vec<2, T, Q> const& v1, vec<2, T, Q> const& v2) { return (v1.x || v2.x, v1.y || v2.y); } diff --git a/include/mim/detail/type/type_vector3.hpp b/include/mim/detail/type/type_vector3.hpp index e329133..1ce6ff7 100644 --- a/include/mim/detail/type/type_vector3.hpp +++ b/include/mim/detail/type/type_vector3.hpp @@ -8,9 +8,9 @@ namespace mim { template - struct VectorT<3, T, Q> { + struct vec<3, T, Q> { using value_type = T; - using type = VectorT<3, T, Q>; + using type = vec<3, T, Q>; using size_type = size_t; static constexpr auto size_v = 3; @@ -26,180 +26,180 @@ namespace mim /// Constructors - constexpr VectorT(); + constexpr vec(); - constexpr VectorT(T _x, T _y, T _z); + constexpr vec(T _x, T _y, T _z); - constexpr VectorT(VectorT<3, T, Q> const& v); + constexpr vec(vec<3, T, Q> const& v); - constexpr explicit VectorT(T scalar); + constexpr explicit vec(T scalar); /// Template Constructors template - constexpr explicit VectorT(VectorT<3, T, P> const& v); + constexpr explicit vec(vec<3, T, P> const& v); // U Template Constructors template - constexpr explicit VectorT(VectorT<1, U, P> const& scalar); + constexpr explicit vec(vec<1, U, P> const& scalar); template - constexpr explicit VectorT(VectorT<3, U, P> const& v); + constexpr explicit vec(vec<3, U, P> const& v); // XYZ Template Constructors template - constexpr VectorT(X _x, Y _y, Z _z); + constexpr vec(X _x, Y _y, Z _z); template - constexpr VectorT(VectorT<1, X, Q> const& _x, Y _y, Z _z); + constexpr vec(vec<1, X, Q> const& _x, Y _y, Z _z); template - constexpr VectorT(X _x, VectorT<1, Y, Q> const& _y, Z _z); + constexpr vec(X _x, vec<1, Y, Q> const& _y, Z _z); template - constexpr VectorT(X _x, Y _y, VectorT<1, Z, Q> const& _z); + constexpr vec(X _x, Y _y, vec<1, Z, Q> const& _z); template - constexpr VectorT(VectorT<1, X, Q> const& _x, VectorT<1, Y, Q> const& _y, Z _z); + constexpr vec(vec<1, X, Q> const& _x, vec<1, Y, Q> const& _y, Z _z); template - constexpr VectorT(VectorT<1, X, Q> const& _x, Y _y, VectorT<1, Z, Q> const& _z); + constexpr vec(vec<1, X, Q> const& _x, Y _y, vec<1, Z, Q> const& _z); template - constexpr VectorT(X _x, VectorT<1, Y, Q> const& _y, VectorT<1, Z, Q> const& _z); + constexpr vec(X _x, vec<1, Y, Q> const& _y, vec<1, Z, Q> const& _z); template - constexpr VectorT(VectorT<1, X, Q> const& _x, VectorT<1, Y, Q> const& _y, VectorT<1, Z, Q> const& _z); + constexpr vec(vec<1, X, Q> const& _x, vec<1, Y, Q> const& _y, vec<1, Z, Q> const& _z); // AB Template Constructors template - constexpr VectorT(VectorT<2, A, P> const& _xy, B _z); + constexpr vec(vec<2, A, P> const& _xy, B _z); template - constexpr VectorT(A _x, VectorT<2, B, P> const& _yz); + constexpr vec(A _x, vec<2, B, P> const& _yz); template - constexpr VectorT(VectorT<2, A, P> const& _xy, VectorT<1, B, P> const& _z); + constexpr vec(vec<2, A, P> const& _xy, vec<1, B, P> const& _z); template - constexpr VectorT(VectorT<1, A, P> const& _x, VectorT<2, B, P> const& _yz); + constexpr vec(vec<1, A, P> const& _x, vec<2, B, P> const& _yz); /// Assignment Operators - constexpr VectorT<3, T, Q>& operator=(T scalar); + constexpr vec<3, T, Q>& operator=(T scalar); - constexpr VectorT<3, T, Q>& operator=(VectorT<3, T, Q> const& v); + constexpr vec<3, T, Q>& operator=(vec<3, T, Q> const& v); template - constexpr VectorT<3, T, Q>& operator=(VectorT<1, U, Q> const& scalar); + constexpr vec<3, T, Q>& operator=(vec<1, U, Q> const& scalar); template - constexpr VectorT<3, T, Q>& operator=(VectorT<3, U, Q> const& v); + constexpr vec<3, T, Q>& operator=(vec<3, U, Q> const& v); template - constexpr VectorT<3, T, Q>& operator+=(U scalar); + constexpr vec<3, T, Q>& operator+=(U scalar); template - constexpr VectorT<3, T, Q>& operator+=(VectorT<1, U, Q> const& v); + constexpr vec<3, T, Q>& operator+=(vec<1, U, Q> const& v); template - constexpr VectorT<3, T, Q>& operator+=(VectorT<3, U, Q> const& v); + constexpr vec<3, T, Q>& operator+=(vec<3, U, Q> const& v); template - constexpr VectorT<3, T, Q>& operator-=(U scalar); + constexpr vec<3, T, Q>& operator-=(U scalar); template - constexpr VectorT<3, T, Q>& operator-=(VectorT<1, U, Q> const& scalar); + constexpr vec<3, T, Q>& operator-=(vec<1, U, Q> const& scalar); template - constexpr VectorT<3, T, Q>& operator-=(VectorT<3, U, Q> const& v); + constexpr vec<3, T, Q>& operator-=(vec<3, U, Q> const& v); template - constexpr VectorT<3, T, Q>& operator*=(U scalar); + constexpr vec<3, T, Q>& operator*=(U scalar); template - constexpr VectorT<3, T, Q>& operator*=(VectorT<1, U, Q> const& v); + constexpr vec<3, T, Q>& operator*=(vec<1, U, Q> const& v); template - constexpr VectorT<3, T, Q>& operator*=(VectorT<3, U, Q> const& v); + constexpr vec<3, T, Q>& operator*=(vec<3, U, Q> const& v); template - constexpr VectorT<3, T, Q>& operator/=(U scalar); + constexpr vec<3, T, Q>& operator/=(U scalar); template - constexpr VectorT<3, T, Q>& operator/=(VectorT<1, U, Q> const& v); + constexpr vec<3, T, Q>& operator/=(vec<1, U, Q> const& v); template - constexpr VectorT<3, T, Q>& operator/=(VectorT<3, U, Q> const& v); + constexpr vec<3, T, Q>& operator/=(vec<3, U, Q> const& v); template - constexpr VectorT<3, T, Q>& operator%=(U scalar); + constexpr vec<3, T, Q>& operator%=(U scalar); template - constexpr VectorT<3, T, Q>& operator%=(VectorT<1, U, Q> const& v); + constexpr vec<3, T, Q>& operator%=(vec<1, U, Q> const& v); template - constexpr VectorT<3, T, Q>& operator%=(VectorT<3, U, Q> const& v); + constexpr vec<3, T, Q>& operator%=(vec<3, U, Q> const& v); /// Increment and Decrement Operators - constexpr VectorT<3, T, Q>& operator++(); + constexpr vec<3, T, Q>& operator++(); - constexpr VectorT<3, T, Q>& operator--(); + constexpr vec<3, T, Q>& operator--(); - constexpr const VectorT<3, T, Q> operator++(int); + constexpr const vec<3, T, Q> operator++(int); - constexpr const VectorT<3, T, Q> operator--(int); + constexpr const vec<3, T, Q> operator--(int); /// Bitwise Assignment Operators template - constexpr VectorT<3, T, Q>& operator&=(U scalar); + constexpr vec<3, T, Q>& operator&=(U scalar); template - constexpr VectorT<3, T, Q>& operator&=(VectorT<1, U, Q> const& v); + constexpr vec<3, T, Q>& operator&=(vec<1, U, Q> const& v); template - constexpr VectorT<3, T, Q>& operator&=(VectorT<3, U, Q> const& v); + constexpr vec<3, T, Q>& operator&=(vec<3, U, Q> const& v); template - constexpr VectorT<3, T, Q>& operator|=(U scalar); + constexpr vec<3, T, Q>& operator|=(U scalar); template - constexpr VectorT<3, T, Q>& operator|=(VectorT<1, U, Q> const& v); + constexpr vec<3, T, Q>& operator|=(vec<1, U, Q> const& v); template - constexpr VectorT<3, T, Q>& operator|=(VectorT<3, U, Q> const& v); + constexpr vec<3, T, Q>& operator|=(vec<3, U, Q> const& v); template - constexpr VectorT<3, T, Q>& operator^=(U scalar); + constexpr vec<3, T, Q>& operator^=(U scalar); template - constexpr VectorT<3, T, Q>& operator^=(VectorT<1, U, Q> const& v); + constexpr vec<3, T, Q>& operator^=(vec<1, U, Q> const& v); template - constexpr VectorT<3, T, Q>& operator^=(VectorT<3, U, Q> const& v); + constexpr vec<3, T, Q>& operator^=(vec<3, U, Q> const& v); template - constexpr VectorT<3, T, Q>& operator<<=(U scalar); + constexpr vec<3, T, Q>& operator<<=(U scalar); template - constexpr VectorT<3, T, Q>& operator<<=(VectorT<1, U, Q> const& v); + constexpr vec<3, T, Q>& operator<<=(vec<1, U, Q> const& v); template - constexpr VectorT<3, T, Q>& operator<<=(VectorT<3, U, Q> const& v); + constexpr vec<3, T, Q>& operator<<=(vec<3, U, Q> const& v); template - constexpr VectorT<3, T, Q>& operator>>=(U scalar); + constexpr vec<3, T, Q>& operator>>=(U scalar); template - constexpr VectorT<3, T, Q>& operator>>=(VectorT<1, U, Q> const& v); + constexpr vec<3, T, Q>& operator>>=(vec<1, U, Q> const& v); template - constexpr VectorT<3, T, Q>& operator>>=(VectorT<3, U, Q> const& v); + constexpr vec<3, T, Q>& operator>>=(vec<3, U, Q> const& v); /// Generic Function Declarations @@ -210,206 +210,206 @@ namespace mim constexpr void normalize(); - constexpr VectorT<3, T, Q> normalized() const; + constexpr vec<3, T, Q> normalized() const; MIM_NODISCARD constexpr bool is_normalized() const; - constexpr T distance(const VectorT<3, T, Q>& v) const; + constexpr T distance(const vec<3, T, Q>& v) const; - constexpr T distance_squared(const VectorT<3, T, Q>& v) const; + constexpr T distance_squared(const vec<3, T, Q>& v) const; /// Function Declarations - constexpr T dot(const VectorT<3, T, Q>& v) const; - constexpr T cross(const VectorT<3, T, Q>& v) const; + constexpr T dot(const vec<3, T, Q>& v) const; + constexpr T cross(const vec<3, T, Q>& v) const; constexpr void rotate(T angle); - constexpr VectorT<3, T, Q> rotated(T angle) const; - constexpr VectorT<3, T, Q> clamp(const VectorT<3, T, Q>& min, const VectorT<3, T, Q>& max) const; - constexpr VectorT<3, T, Q> reflect(const VectorT<3, T, Q>& normal) const; - constexpr VectorT<3, T, Q> refract(const VectorT<3, T, Q>& normal, T eta) const; - constexpr VectorT<3, T, Q> project(const VectorT<3, T, Q>& normal) const; + constexpr vec<3, T, Q> rotated(T angle) const; + constexpr vec<3, T, Q> clamp(const vec<3, T, Q>& min, const vec<3, T, Q>& max) const; + constexpr vec<3, T, Q> reflect(const vec<3, T, Q>& normal) const; + constexpr vec<3, T, Q> refract(const vec<3, T, Q>& normal, T eta) const; + constexpr vec<3, T, Q> project(const vec<3, T, Q>& normal) const; }; /// Unary Operators template - constexpr VectorT<3, T, Q> operator+(VectorT<3, T, Q> const& v); + constexpr vec<3, T, Q> operator+(vec<3, T, Q> const& v); template - constexpr VectorT<3, T, Q> operator-(VectorT<3, T, Q> const& v); + constexpr vec<3, T, Q> operator-(vec<3, T, Q> const& v); /// Binary Operators template - constexpr VectorT<3, T, Q> operator+(VectorT<3, T, Q> const& v, T scalar); + constexpr vec<3, T, Q> operator+(vec<3, T, Q> const& v, T scalar); template - constexpr VectorT<3, T, Q> operator+(VectorT<3, T, Q> const& v1, VectorT<1, T, Q> const& sv); + constexpr vec<3, T, Q> operator+(vec<3, T, Q> const& v1, vec<1, T, Q> const& sv); template - constexpr VectorT<3, T, Q> operator+(T scalar, VectorT<3, T, Q> const& v); + constexpr vec<3, T, Q> operator+(T scalar, vec<3, T, Q> const& v); template - constexpr VectorT<3, T, Q> operator+(VectorT<1, T, Q> const& sv, VectorT<3, T, Q> const& v2); + constexpr vec<3, T, Q> operator+(vec<1, T, Q> const& sv, vec<3, T, Q> const& v2); template - constexpr VectorT<3, T, Q> operator+(VectorT<3, T, Q> const& v1, VectorT<3, T, Q> const& v2); + constexpr vec<3, T, Q> operator+(vec<3, T, Q> const& v1, vec<3, T, Q> const& v2); template - constexpr VectorT<3, T, Q> operator-(VectorT<3, T, Q> const& v, T scalar); + constexpr vec<3, T, Q> operator-(vec<3, T, Q> const& v, T scalar); template - constexpr VectorT<3, T, Q> operator-(VectorT<3, T, Q> const& v1, VectorT<1, T, Q> const& sv); + constexpr vec<3, T, Q> operator-(vec<3, T, Q> const& v1, vec<1, T, Q> const& sv); template - constexpr VectorT<3, T, Q> operator-(T scalar, VectorT<3, T, Q> const& v); + constexpr vec<3, T, Q> operator-(T scalar, vec<3, T, Q> const& v); template - constexpr VectorT<3, T, Q> operator-(VectorT<1, T, Q> const& sv, VectorT<3, T, Q> const& v2); + constexpr vec<3, T, Q> operator-(vec<1, T, Q> const& sv, vec<3, T, Q> const& v2); template - constexpr VectorT<3, T, Q> operator-(VectorT<3, T, Q> const& v1, VectorT<3, T, Q> const& v2); + constexpr vec<3, T, Q> operator-(vec<3, T, Q> const& v1, vec<3, T, Q> const& v2); template - constexpr VectorT<3, T, Q> operator*(VectorT<3, T, Q> const& v, T scalar); + constexpr vec<3, T, Q> operator*(vec<3, T, Q> const& v, T scalar); template - constexpr VectorT<3, T, Q> operator*(VectorT<3, T, Q> const& v1, VectorT<1, T, Q> const& sv); + constexpr vec<3, T, Q> operator*(vec<3, T, Q> const& v1, vec<1, T, Q> const& sv); template - constexpr VectorT<3, T, Q> operator*(T scalar, VectorT<3, T, Q> const& v); + constexpr vec<3, T, Q> operator*(T scalar, vec<3, T, Q> const& v); template - constexpr VectorT<3, T, Q> operator*(VectorT<1, T, Q> const& sv, VectorT<3, T, Q> const& v2); + constexpr vec<3, T, Q> operator*(vec<1, T, Q> const& sv, vec<3, T, Q> const& v2); template - constexpr VectorT<3, T, Q> operator*(VectorT<3, T, Q> const& v1, VectorT<3, T, Q> const& v2); + constexpr vec<3, T, Q> operator*(vec<3, T, Q> const& v1, vec<3, T, Q> const& v2); template - constexpr VectorT<3, T, Q> operator/(VectorT<3, T, Q> const& v, T scalar); + constexpr vec<3, T, Q> operator/(vec<3, T, Q> const& v, T scalar); template - constexpr VectorT<3, T, Q> operator/(VectorT<3, T, Q> const& v1, VectorT<1, T, Q> const& sv); + constexpr vec<3, T, Q> operator/(vec<3, T, Q> const& v1, vec<1, T, Q> const& sv); template - constexpr VectorT<3, T, Q> operator/(T scalar, VectorT<3, T, Q> const& v); + constexpr vec<3, T, Q> operator/(T scalar, vec<3, T, Q> const& v); template - constexpr VectorT<3, T, Q> operator/(VectorT<1, T, Q> const& sv, VectorT<3, T, Q> const& v2); + constexpr vec<3, T, Q> operator/(vec<1, T, Q> const& sv, vec<3, T, Q> const& v2); template - constexpr VectorT<3, T, Q> operator/(VectorT<3, T, Q> const& v1, VectorT<3, T, Q> const& v2); + constexpr vec<3, T, Q> operator/(vec<3, T, Q> const& v1, vec<3, T, Q> const& v2); template - constexpr VectorT<3, T, Q> operator%(VectorT<3, T, Q> const& v, T scalar); + constexpr vec<3, T, Q> operator%(vec<3, T, Q> const& v, T scalar); template - constexpr VectorT<3, T, Q> operator%(VectorT<3, T, Q> const& v1, VectorT<1, T, Q> const& sv); + constexpr vec<3, T, Q> operator%(vec<3, T, Q> const& v1, vec<1, T, Q> const& sv); template - constexpr VectorT<3, T, Q> operator%(T scalar, VectorT<3, T, Q> const& v); + constexpr vec<3, T, Q> operator%(T scalar, vec<3, T, Q> const& v); template - constexpr VectorT<3, T, Q> operator%(VectorT<1, T, Q> const& sv, VectorT<3, T, Q> const& v2); + constexpr vec<3, T, Q> operator%(vec<1, T, Q> const& sv, vec<3, T, Q> const& v2); template - constexpr VectorT<3, T, Q> operator%(VectorT<3, T, Q> const& v1, VectorT<3, T, Q> const& v2); + constexpr vec<3, T, Q> operator%(vec<3, T, Q> const& v1, vec<3, T, Q> const& v2); /// Bitwise Binary Operators template - constexpr VectorT<3, T, Q> operator&(VectorT<3, T, Q> const& v, T scalar); + constexpr vec<3, T, Q> operator&(vec<3, T, Q> const& v, T scalar); template - constexpr VectorT<3, T, Q> operator&(VectorT<3, T, Q> const& v1, VectorT<1, T, Q> const& sv); + constexpr vec<3, T, Q> operator&(vec<3, T, Q> const& v1, vec<1, T, Q> const& sv); template - constexpr VectorT<3, T, Q> operator&(T scalar, VectorT<3, T, Q> const& v); + constexpr vec<3, T, Q> operator&(T scalar, vec<3, T, Q> const& v); template - constexpr VectorT<3, T, Q> operator&(VectorT<1, T, Q> const& sv, VectorT<3, T, Q> const& v2); + constexpr vec<3, T, Q> operator&(vec<1, T, Q> const& sv, vec<3, T, Q> const& v2); template - constexpr VectorT<3, T, Q> operator&(VectorT<3, T, Q> const& v1, VectorT<3, T, Q> const& v2); + constexpr vec<3, T, Q> operator&(vec<3, T, Q> const& v1, vec<3, T, Q> const& v2); template - constexpr VectorT<3, T, Q> operator|(VectorT<3, T, Q> const& v, T scalar); + constexpr vec<3, T, Q> operator|(vec<3, T, Q> const& v, T scalar); template - constexpr VectorT<3, T, Q> operator|(VectorT<3, T, Q> const& v1, VectorT<1, T, Q> const& sv); + constexpr vec<3, T, Q> operator|(vec<3, T, Q> const& v1, vec<1, T, Q> const& sv); template - constexpr VectorT<3, T, Q> operator|(T scalar, VectorT<3, T, Q> const& v); + constexpr vec<3, T, Q> operator|(T scalar, vec<3, T, Q> const& v); template - constexpr VectorT<3, T, Q> operator|(VectorT<1, T, Q> const& sv, VectorT<3, T, Q> const& v2); + constexpr vec<3, T, Q> operator|(vec<1, T, Q> const& sv, vec<3, T, Q> const& v2); template - constexpr VectorT<3, T, Q> operator|(VectorT<3, T, Q> const& v1, VectorT<3, T, Q> const& v2); + constexpr vec<3, T, Q> operator|(vec<3, T, Q> const& v1, vec<3, T, Q> const& v2); template - constexpr VectorT<3, T, Q> operator^(VectorT<3, T, Q> const& v, T scalar); + constexpr vec<3, T, Q> operator^(vec<3, T, Q> const& v, T scalar); template - constexpr VectorT<3, T, Q> operator^(VectorT<3, T, Q> const& v1, VectorT<1, T, Q> const& sv); + constexpr vec<3, T, Q> operator^(vec<3, T, Q> const& v1, vec<1, T, Q> const& sv); template - constexpr VectorT<3, T, Q> operator^(T scalar, VectorT<3, T, Q> const& v); + constexpr vec<3, T, Q> operator^(T scalar, vec<3, T, Q> const& v); template - constexpr VectorT<3, T, Q> operator^(VectorT<1, T, Q> const& sv, VectorT<3, T, Q> const& v2); + constexpr vec<3, T, Q> operator^(vec<1, T, Q> const& sv, vec<3, T, Q> const& v2); template - constexpr VectorT<3, T, Q> operator^(VectorT<3, T, Q> const& v1, VectorT<3, T, Q> const& v2); + constexpr vec<3, T, Q> operator^(vec<3, T, Q> const& v1, vec<3, T, Q> const& v2); template - constexpr VectorT<3, T, Q> operator<<(VectorT<3, T, Q> const& v, T scalar); + constexpr vec<3, T, Q> operator<<(vec<3, T, Q> const& v, T scalar); template - constexpr VectorT<3, T, Q> operator<<(VectorT<3, T, Q> const& v1, VectorT<1, T, Q> const& sv); + constexpr vec<3, T, Q> operator<<(vec<3, T, Q> const& v1, vec<1, T, Q> const& sv); template - constexpr VectorT<3, T, Q> operator<<(T scalar, VectorT<3, T, Q> const& v); + constexpr vec<3, T, Q> operator<<(T scalar, vec<3, T, Q> const& v); template - constexpr VectorT<3, T, Q> operator<<(VectorT<1, T, Q> const& sv, VectorT<3, T, Q> const& v2); + constexpr vec<3, T, Q> operator<<(vec<1, T, Q> const& sv, vec<3, T, Q> const& v2); template - constexpr VectorT<3, T, Q> operator<<(VectorT<3, T, Q> const& v1, VectorT<3, T, Q> const& v2); + constexpr vec<3, T, Q> operator<<(vec<3, T, Q> const& v1, vec<3, T, Q> const& v2); template - constexpr VectorT<3, T, Q> operator>>(VectorT<3, T, Q> const& v, T scalar); + constexpr vec<3, T, Q> operator>>(vec<3, T, Q> const& v, T scalar); template - constexpr VectorT<3, T, Q> operator>>(VectorT<3, T, Q> const& v1, VectorT<1, T, Q> const& sv); + constexpr vec<3, T, Q> operator>>(vec<3, T, Q> const& v1, vec<1, T, Q> const& sv); template - constexpr VectorT<3, T, Q> operator>>(T scalar, VectorT<3, T, Q> const& v); + constexpr vec<3, T, Q> operator>>(T scalar, vec<3, T, Q> const& v); template - constexpr VectorT<3, T, Q> operator>>(VectorT<1, T, Q> const& sv, VectorT<3, T, Q> const& v2); + constexpr vec<3, T, Q> operator>>(vec<1, T, Q> const& sv, vec<3, T, Q> const& v2); template - constexpr VectorT<3, T, Q> operator>>(VectorT<3, T, Q> const& v1, VectorT<3, T, Q> const& v2); + constexpr vec<3, T, Q> operator>>(vec<3, T, Q> const& v1, vec<3, T, Q> const& v2); template - constexpr VectorT<3, T, Q> operator~(VectorT<3, T, Q> const& v); + constexpr vec<3, T, Q> operator~(vec<3, T, Q> const& v); /// Conditional Operators template - constexpr bool operator==(VectorT<3, T, Q> const& v1, VectorT<3, T, Q> const& v2); + constexpr bool operator==(vec<3, T, Q> const& v1, vec<3, T, Q> const& v2); template - constexpr bool operator!=(VectorT<3, T, Q> const& v1, VectorT<3, T, Q> const& v2); + constexpr bool operator!=(vec<3, T, Q> const& v1, vec<3, T, Q> const& v2); template - constexpr bool operator&&(VectorT<3, T, Q> const& v1, VectorT<3, T, Q> const& v2); + constexpr bool operator&&(vec<3, T, Q> const& v1, vec<3, T, Q> const& v2); template - constexpr bool operator||(VectorT<3, T, Q> const& v1, VectorT<3, T, Q> const& v2); + constexpr bool operator||(vec<3, T, Q> const& v1, vec<3, T, Q> const& v2); } // namespace mim diff --git a/include/mim/detail/type/type_vector3.inl b/include/mim/detail/type/type_vector3.inl index 7bed2fe..cd6cf44 100644 --- a/include/mim/detail/type/type_vector3.inl +++ b/include/mim/detail/type/type_vector3.inl @@ -6,9 +6,9 @@ namespace mim { template - constexpr T& VectorT<3, T, Q>::operator[](size_type i) + constexpr T& vec<3, T, Q>::operator[](size_type i) { - static_assert(i < this->length(), "Out of range: VectorT<3, T, Q>::operator[]"); + static_assert(i < this->length(), "Out of range: vec<3, T, Q>::operator[]"); switch (i) { default: @@ -19,9 +19,9 @@ namespace mim } template - constexpr T const& VectorT<3, T, Q>::operator[](size_type i) const + constexpr T const& vec<3, T, Q>::operator[](size_type i) const { - static_assert(i < this->length(), "Out of range: VectorT<3, T, Q>::operator[]"); + static_assert(i < this->length(), "Out of range: vec<3, T, Q>::operator[]"); switch (i) { default: @@ -34,22 +34,22 @@ namespace mim /// Constructors template - constexpr VectorT<3, T, Q>::VectorT() : x(0), y(0), z(0) + constexpr vec<3, T, Q>::vec() : x(0), y(0), z(0) { } template - constexpr VectorT<3, T, Q>::VectorT(T _x, T _y, T _z) : x(_x), y(_y), z(_z) + constexpr vec<3, T, Q>::vec(T _x, T _y, T _z) : x(_x), y(_y), z(_z) { } template - constexpr VectorT<3, T, Q>::VectorT(VectorT<3, T, Q> const& v) : x(v.x), y(v.y), z(v.z) + constexpr vec<3, T, Q>::vec(vec<3, T, Q> const& v) : x(v.x), y(v.y), z(v.z) { } template - constexpr VectorT<3, T, Q>::VectorT(T scalar) : x(scalar), y(scalar), z(scalar) + constexpr vec<3, T, Q>::vec(T scalar) : x(scalar), y(scalar), z(scalar) { } @@ -57,7 +57,7 @@ namespace mim template template - constexpr VectorT<3, T, Q>::VectorT(VectorT<3, T, P> const& v) : x(v.x), y(v.y), z(v.z) + constexpr vec<3, T, Q>::vec(vec<3, T, P> const& v) : x(v.x), y(v.y), z(v.z) { } @@ -67,13 +67,13 @@ namespace mim template template - constexpr VectorT<3, T, Q>::VectorT(VectorT<1, U, P> const& scalar) : x(static_cast(scalar.x)), y(static_cast(scalar.x)), z(static_cast(scalar.x)) + constexpr vec<3, T, Q>::vec(vec<1, U, P> const& scalar) : x(static_cast(scalar.x)), y(static_cast(scalar.x)), z(static_cast(scalar.x)) { } template template - constexpr VectorT<3, T, Q>::VectorT(VectorT<3, U, P> const& v) : x(static_cast(v.x)), y(static_cast(v.y)), z(static_cast(v.z)) + constexpr vec<3, T, Q>::vec(vec<3, U, P> const& v) : x(static_cast(v.x)), y(static_cast(v.y)), z(static_cast(v.z)) { } @@ -81,52 +81,52 @@ namespace mim template template - constexpr VectorT<3, T, Q>::VectorT(X _x, Y _y, Z _z) : x(static_cast(_x)), y(static_cast(_y)), z(static_cast(_z)) + constexpr vec<3, T, Q>::vec(X _x, Y _y, Z _z) : x(static_cast(_x)), y(static_cast(_y)), z(static_cast(_z)) { } template template - constexpr VectorT<3, T, Q>::VectorT(VectorT<1, X, Q> const& _x, Y _y, Z _z) : x(static_cast(_x.x)), y(static_cast(_y)), z(static_cast(_z)) + constexpr vec<3, T, Q>::vec(vec<1, X, Q> const& _x, Y _y, Z _z) : x(static_cast(_x.x)), y(static_cast(_y)), z(static_cast(_z)) { } template template - constexpr VectorT<3, T, Q>::VectorT(X _x, VectorT<1, Y, Q> const& _y, Z _z) : x(static_cast(_x)), y(static_cast(_y.y)), z(static_cast(_z)) + constexpr vec<3, T, Q>::vec(X _x, vec<1, Y, Q> const& _y, Z _z) : x(static_cast(_x)), y(static_cast(_y.y)), z(static_cast(_z)) { } template template - constexpr VectorT<3, T, Q>::VectorT(X _x, Y _y, VectorT<1, Z, Q> const& _z) : x(static_cast(_x)), y(static_cast(_y)), z(static_cast(_z.z)) + constexpr vec<3, T, Q>::vec(X _x, Y _y, vec<1, Z, Q> const& _z) : x(static_cast(_x)), y(static_cast(_y)), z(static_cast(_z.z)) { } template template - constexpr VectorT<3, T, Q>::VectorT(VectorT<1, X, Q> const& _x, VectorT<1, Y, Q> const& _y, Z _z) + constexpr vec<3, T, Q>::vec(vec<1, X, Q> const& _x, vec<1, Y, Q> const& _y, Z _z) : x(static_cast(_x.x)), y(static_cast(_y.y)), z(static_cast(_z)) { } template template - constexpr VectorT<3, T, Q>::VectorT(VectorT<1, X, Q> const& _x, Y _y, VectorT<1, Z, Q> const& _z) + constexpr vec<3, T, Q>::vec(vec<1, X, Q> const& _x, Y _y, vec<1, Z, Q> const& _z) : x(static_cast(_x.x)), y(static_cast(_y)), z(static_cast(_z.z)) { } template template - constexpr VectorT<3, T, Q>::VectorT(X _x, VectorT<1, Y, Q> const& _y, VectorT<1, Z, Q> const& _z) + constexpr vec<3, T, Q>::vec(X _x, vec<1, Y, Q> const& _y, vec<1, Z, Q> const& _z) : x(static_cast(_x)), y(static_cast(_y.y)), z(static_cast(_z.z)) { } template template - constexpr VectorT<3, T, Q>::VectorT(VectorT<1, X, Q> const& _x, VectorT<1, Y, Q> const& _y, VectorT<1, Z, Q> const& _z) + constexpr vec<3, T, Q>::vec(vec<1, X, Q> const& _x, vec<1, Y, Q> const& _y, vec<1, Z, Q> const& _z) : x(static_cast(_x.x)), y(static_cast(_y.y)), z(static_cast(_z.z)) { } @@ -135,26 +135,26 @@ namespace mim template template - constexpr VectorT<3, T, Q>::VectorT(VectorT<2, A, P> const& _xy, B _z) : x(static_cast(_xy.x)), y(static_cast(_xy.y)), z(static_cast(_z)) + constexpr vec<3, T, Q>::vec(vec<2, A, P> const& _xy, B _z) : x(static_cast(_xy.x)), y(static_cast(_xy.y)), z(static_cast(_z)) { } template template - constexpr VectorT<3, T, Q>::VectorT(VectorT<2, A, P> const& _xy, VectorT<1, B, P> const& _z) + constexpr vec<3, T, Q>::vec(vec<2, A, P> const& _xy, vec<1, B, P> const& _z) : x(static_cast(_xy.x)), y(static_cast(_xy.y)), z(static_cast(_z.z)) { } template template - constexpr VectorT<3, T, Q>::VectorT(A _x, VectorT<2, B, P> const& _yz) : x(static_cast(_x)), y(static_cast(_yz.y)), z(static_cast(_yz.z)) + constexpr vec<3, T, Q>::vec(A _x, vec<2, B, P> const& _yz) : x(static_cast(_x)), y(static_cast(_yz.y)), z(static_cast(_yz.z)) { } template template - constexpr VectorT<3, T, Q>::VectorT(VectorT<1, A, P> const& _x, VectorT<2, B, P> const& _yz) + constexpr vec<3, T, Q>::vec(vec<1, A, P> const& _x, vec<2, B, P> const& _yz) : x(static_cast(_x.x)), y(static_cast(_yz.y)), z(static_cast(_yz.z)) { } @@ -162,7 +162,7 @@ namespace mim /// Assignment Operators template - constexpr VectorT<3, T, Q>& VectorT<3, T, Q>::operator=(T scalar) + constexpr vec<3, T, Q>& vec<3, T, Q>::operator=(T scalar) { x = scalar; y = scalar; @@ -171,7 +171,7 @@ namespace mim } template - constexpr VectorT<3, T, Q>& VectorT<3, T, Q>::operator=(VectorT<3, T, Q> const& v) + constexpr vec<3, T, Q>& vec<3, T, Q>::operator=(vec<3, T, Q> const& v) { x = v.x; y = v.y; @@ -184,7 +184,7 @@ namespace mim */ template template - constexpr VectorT<3, T, Q>& VectorT<3, T, Q>::operator=(VectorT<1, U, Q> const& scalar) + constexpr vec<3, T, Q>& vec<3, T, Q>::operator=(vec<1, U, Q> const& scalar) { x = static_cast(scalar.x); y = static_cast(scalar.x); @@ -194,7 +194,7 @@ namespace mim template template - constexpr VectorT<3, T, Q>& VectorT<3, T, Q>::operator=(VectorT<3, U, Q> const& v) + constexpr vec<3, T, Q>& vec<3, T, Q>::operator=(vec<3, U, Q> const& v) { x = static_cast(v.x); y = static_cast(v.y); @@ -204,7 +204,7 @@ namespace mim template template - constexpr VectorT<3, T, Q>& VectorT<3, T, Q>::operator+=(U scalar) + constexpr vec<3, T, Q>& vec<3, T, Q>::operator+=(U scalar) { x += static_cast(scalar); y += static_cast(scalar); @@ -217,7 +217,7 @@ namespace mim */ template template - constexpr VectorT<3, T, Q>& VectorT<3, T, Q>::operator+=(VectorT<1, U, Q> const& v) + constexpr vec<3, T, Q>& vec<3, T, Q>::operator+=(vec<1, U, Q> const& v) { x += static_cast(v.x); y += static_cast(v.x); @@ -227,7 +227,7 @@ namespace mim template template - constexpr VectorT<3, T, Q>& VectorT<3, T, Q>::operator+=(VectorT<3, U, Q> const& v) + constexpr vec<3, T, Q>& vec<3, T, Q>::operator+=(vec<3, U, Q> const& v) { x += static_cast(v.x); y += static_cast(v.y); @@ -237,7 +237,7 @@ namespace mim template template - constexpr VectorT<3, T, Q>& VectorT<3, T, Q>::operator-=(U scalar) + constexpr vec<3, T, Q>& vec<3, T, Q>::operator-=(U scalar) { x -= static_cast(scalar); y -= static_cast(scalar); @@ -250,7 +250,7 @@ namespace mim */ template template - constexpr VectorT<3, T, Q>& VectorT<3, T, Q>::operator-=(VectorT<1, U, Q> const& scalar) + constexpr vec<3, T, Q>& vec<3, T, Q>::operator-=(vec<1, U, Q> const& scalar) { x -= static_cast(scalar.x); y -= static_cast(scalar.x); @@ -260,7 +260,7 @@ namespace mim template template - constexpr VectorT<3, T, Q>& VectorT<3, T, Q>::operator-=(VectorT<3, U, Q> const& v) + constexpr vec<3, T, Q>& vec<3, T, Q>::operator-=(vec<3, U, Q> const& v) { x -= static_cast(v.x); y -= static_cast(v.y); @@ -270,7 +270,7 @@ namespace mim template template - constexpr VectorT<3, T, Q>& VectorT<3, T, Q>::operator*=(U scalar) + constexpr vec<3, T, Q>& vec<3, T, Q>::operator*=(U scalar) { x *= static_cast(scalar); y *= static_cast(scalar); @@ -283,7 +283,7 @@ namespace mim */ template template - constexpr VectorT<3, T, Q>& VectorT<3, T, Q>::operator*=(VectorT<1, U, Q> const& v) + constexpr vec<3, T, Q>& vec<3, T, Q>::operator*=(vec<1, U, Q> const& v) { x *= static_cast(v.x); y *= static_cast(v.x); @@ -293,7 +293,7 @@ namespace mim template template - constexpr VectorT<3, T, Q>& VectorT<3, T, Q>::operator*=(VectorT<3, U, Q> const& v) + constexpr vec<3, T, Q>& vec<3, T, Q>::operator*=(vec<3, U, Q> const& v) { x *= static_cast(v.x); y *= static_cast(v.y); @@ -303,7 +303,7 @@ namespace mim template template - constexpr VectorT<3, T, Q>& VectorT<3, T, Q>::operator/=(U scalar) + constexpr vec<3, T, Q>& vec<3, T, Q>::operator/=(U scalar) { x /= static_cast(scalar); y /= static_cast(scalar); @@ -316,7 +316,7 @@ namespace mim */ template template - constexpr VectorT<3, T, Q>& VectorT<3, T, Q>::operator/=(VectorT<1, U, Q> const& v) + constexpr vec<3, T, Q>& vec<3, T, Q>::operator/=(vec<1, U, Q> const& v) { x /= static_cast(v.x); y /= static_cast(v.x); @@ -326,7 +326,7 @@ namespace mim template template - constexpr VectorT<3, T, Q>& VectorT<3, T, Q>::operator/=(VectorT<3, U, Q> const& v) + constexpr vec<3, T, Q>& vec<3, T, Q>::operator/=(vec<3, U, Q> const& v) { x /= static_cast(v.x); y /= static_cast(v.y); @@ -337,7 +337,7 @@ namespace mim /// Increment and decrement operators template - constexpr VectorT<3, T, Q>& VectorT<3, T, Q>::operator++() + constexpr vec<3, T, Q>& vec<3, T, Q>::operator++() { ++this->x; ++this->y; @@ -346,7 +346,7 @@ namespace mim } template - constexpr VectorT<3, T, Q>& VectorT<3, T, Q>::operator--() + constexpr vec<3, T, Q>& vec<3, T, Q>::operator--() { --this->x; --this->y; @@ -355,17 +355,17 @@ namespace mim } template - constexpr const VectorT<3, T, Q> VectorT<3, T, Q>::operator++(int) + constexpr const vec<3, T, Q> vec<3, T, Q>::operator++(int) { - VectorT<3, T, Q> result(*this); + vec<3, T, Q> result(*this); ++*this; return result; } template - constexpr const VectorT<3, T, Q> VectorT<3, T, Q>::operator--(int) + constexpr const vec<3, T, Q> vec<3, T, Q>::operator--(int) { - VectorT<3, T, Q> result(*this); + vec<3, T, Q> result(*this); --*this; return result; } @@ -374,7 +374,7 @@ namespace mim template template - constexpr VectorT<3, T, Q>& VectorT<3, T, Q>::operator%=(U scalar) + constexpr vec<3, T, Q>& vec<3, T, Q>::operator%=(U scalar) { x %= static_cast(scalar); y %= static_cast(scalar); @@ -387,7 +387,7 @@ namespace mim */ template template - constexpr VectorT<3, T, Q>& VectorT<3, T, Q>::operator%=(VectorT<1, U, Q> const& v) + constexpr vec<3, T, Q>& vec<3, T, Q>::operator%=(vec<1, U, Q> const& v) { x %= static_cast(v.x); y %= static_cast(v.x); @@ -397,7 +397,7 @@ namespace mim template template - constexpr VectorT<3, T, Q>& VectorT<3, T, Q>::operator%=(VectorT<3, U, Q> const& v) + constexpr vec<3, T, Q>& vec<3, T, Q>::operator%=(vec<3, U, Q> const& v) { x %= static_cast(v.x); y %= static_cast(v.y); @@ -407,7 +407,7 @@ namespace mim template template - constexpr VectorT<3, T, Q>& VectorT<3, T, Q>::operator&=(U scalar) + constexpr vec<3, T, Q>& vec<3, T, Q>::operator&=(U scalar) { x &= static_cast(scalar); y &= static_cast(scalar); @@ -420,7 +420,7 @@ namespace mim */ template template - constexpr VectorT<3, T, Q>& VectorT<3, T, Q>::operator&=(VectorT<1, U, Q> const& v) + constexpr vec<3, T, Q>& vec<3, T, Q>::operator&=(vec<1, U, Q> const& v) { x &= static_cast(v.x); y &= static_cast(v.x); @@ -430,7 +430,7 @@ namespace mim template template - constexpr VectorT<3, T, Q>& VectorT<3, T, Q>::operator&=(VectorT<3, U, Q> const& v) + constexpr vec<3, T, Q>& vec<3, T, Q>::operator&=(vec<3, U, Q> const& v) { x &= static_cast(v.x); y &= static_cast(v.y); @@ -440,7 +440,7 @@ namespace mim template template - constexpr VectorT<3, T, Q>& VectorT<3, T, Q>::operator|=(U scalar) + constexpr vec<3, T, Q>& vec<3, T, Q>::operator|=(U scalar) { x |= static_cast(scalar); y |= static_cast(scalar); @@ -453,7 +453,7 @@ namespace mim */ template template - constexpr VectorT<3, T, Q>& VectorT<3, T, Q>::operator|=(VectorT<1, U, Q> const& v) + constexpr vec<3, T, Q>& vec<3, T, Q>::operator|=(vec<1, U, Q> const& v) { x |= static_cast(v.x); y |= static_cast(v.x); @@ -463,7 +463,7 @@ namespace mim template template - constexpr VectorT<3, T, Q>& VectorT<3, T, Q>::operator|=(VectorT<3, U, Q> const& v) + constexpr vec<3, T, Q>& vec<3, T, Q>::operator|=(vec<3, U, Q> const& v) { x |= static_cast(v.x); y |= static_cast(v.y); @@ -473,7 +473,7 @@ namespace mim template template - constexpr VectorT<3, T, Q>& VectorT<3, T, Q>::operator^=(U scalar) + constexpr vec<3, T, Q>& vec<3, T, Q>::operator^=(U scalar) { x ^= static_cast(scalar); y ^= static_cast(scalar); @@ -486,7 +486,7 @@ namespace mim */ template template - constexpr VectorT<3, T, Q>& VectorT<3, T, Q>::operator^=(VectorT<1, U, Q> const& v) + constexpr vec<3, T, Q>& vec<3, T, Q>::operator^=(vec<1, U, Q> const& v) { x ^= static_cast(v.x); y ^= static_cast(v.x); @@ -496,7 +496,7 @@ namespace mim template template - constexpr VectorT<3, T, Q>& VectorT<3, T, Q>::operator^=(VectorT<3, U, Q> const& v) + constexpr vec<3, T, Q>& vec<3, T, Q>::operator^=(vec<3, U, Q> const& v) { x ^= static_cast(v.x); y ^= static_cast(v.y); @@ -506,7 +506,7 @@ namespace mim template template - constexpr VectorT<3, T, Q>& VectorT<3, T, Q>::operator<<=(U scalar) + constexpr vec<3, T, Q>& vec<3, T, Q>::operator<<=(U scalar) { x <<= static_cast(scalar); y <<= static_cast(scalar); @@ -519,7 +519,7 @@ namespace mim */ template template - constexpr VectorT<3, T, Q>& VectorT<3, T, Q>::operator<<=(VectorT<1, U, Q> const& v) + constexpr vec<3, T, Q>& vec<3, T, Q>::operator<<=(vec<1, U, Q> const& v) { x <<= static_cast(v.x); y <<= static_cast(v.x); @@ -529,7 +529,7 @@ namespace mim template template - constexpr VectorT<3, T, Q>& VectorT<3, T, Q>::operator<<=(VectorT<3, U, Q> const& v) + constexpr vec<3, T, Q>& vec<3, T, Q>::operator<<=(vec<3, U, Q> const& v) { x <<= static_cast(v.x); y <<= static_cast(v.y); @@ -539,7 +539,7 @@ namespace mim template template - constexpr VectorT<3, T, Q>& VectorT<3, T, Q>::operator>>=(U scalar) + constexpr vec<3, T, Q>& vec<3, T, Q>::operator>>=(U scalar) { x >>= static_cast(scalar); y >>= static_cast(scalar); @@ -552,7 +552,7 @@ namespace mim */ template template - constexpr VectorT<3, T, Q>& VectorT<3, T, Q>::operator>>=(VectorT<1, U, Q> const& v) + constexpr vec<3, T, Q>& vec<3, T, Q>::operator>>=(vec<1, U, Q> const& v) { x >>= static_cast(v.x); y >>= static_cast(v.x); @@ -562,7 +562,7 @@ namespace mim template template - constexpr VectorT<3, T, Q>& VectorT<3, T, Q>::operator>>=(VectorT<3, U, Q> const& v) + constexpr vec<3, T, Q>& vec<3, T, Q>::operator>>=(vec<3, U, Q> const& v) { x >>= static_cast(v.x); y >>= static_cast(v.y); @@ -571,403 +571,403 @@ namespace mim } template - constexpr VectorT<3, T, Q> operator+(VectorT<3, T, Q> const& v) + constexpr vec<3, T, Q> operator+(vec<3, T, Q> const& v) { return v; } template - constexpr VectorT<3, T, Q> operator-(VectorT<3, T, Q> const& v) + constexpr vec<3, T, Q> operator-(vec<3, T, Q> const& v) { - return VectorT<3, T, Q>(-v.x, -v.y, -v.z); + return vec<3, T, Q>(-v.x, -v.y, -v.z); } template - constexpr VectorT<3, T, Q> operator+(VectorT<3, T, Q> const& v, T scalar) + constexpr vec<3, T, Q> operator+(vec<3, T, Q> const& v, T scalar) { - return VectorT<3, T, Q>(v.x + scalar, v.y + scalar, v.z + scalar); + return vec<3, T, Q>(v.x + scalar, v.y + scalar, v.z + scalar); } template - constexpr VectorT<3, T, Q> operator+(T scalar, VectorT<3, T, Q> const& v) + constexpr vec<3, T, Q> operator+(T scalar, vec<3, T, Q> const& v) { - return VectorT<3, T, Q>(scalar + v.x, scalar + v.y, scalar + v.z); + return vec<3, T, Q>(scalar + v.x, scalar + v.y, scalar + v.z); } /* * \note Vec1 is deliberately treated like a scalar to mimic shader languages. */ template - constexpr VectorT<3, T, Q> operator+(VectorT<3, T, Q> const& v, VectorT<1, T, Q> const& sv) + constexpr vec<3, T, Q> operator+(vec<3, T, Q> const& v, vec<1, T, Q> const& sv) { - return VectorT<3, T, Q>(v.x + sv.x, v.y + sv.x, v.z + sv.x); + return vec<3, T, Q>(v.x + sv.x, v.y + sv.x, v.z + sv.x); } /* * \note Vec1 is deliberately treated like a scalar to mimic shader languages. */ template - constexpr VectorT<3, T, Q> operator+(VectorT<1, T, Q> const& sv, VectorT<3, T, Q> const& v) + constexpr vec<3, T, Q> operator+(vec<1, T, Q> const& sv, vec<3, T, Q> const& v) { - return VectorT<3, T, Q>(sv.x + v.x, sv.x + v.y, sv.x + v.z); + return vec<3, T, Q>(sv.x + v.x, sv.x + v.y, sv.x + v.z); } template - constexpr VectorT<3, T, Q> operator+(VectorT<3, T, Q> const& v1, VectorT<3, T, Q> const& v2) + constexpr vec<3, T, Q> operator+(vec<3, T, Q> const& v1, vec<3, T, Q> const& v2) { - return VectorT<3, T, Q>(v1.x + v2.x, v1.y + v2.y, v1.z + v2.z); + return vec<3, T, Q>(v1.x + v2.x, v1.y + v2.y, v1.z + v2.z); } template - constexpr VectorT<3, T, Q> operator-(VectorT<3, T, Q> const& v, T scalar) + constexpr vec<3, T, Q> operator-(vec<3, T, Q> const& v, T scalar) { - return VectorT<3, T, Q>(v.x - scalar, v.y - scalar, v.z - scalar); + return vec<3, T, Q>(v.x - scalar, v.y - scalar, v.z - scalar); } template - constexpr VectorT<3, T, Q> operator-(T scalar, VectorT<3, T, Q> const& v) + constexpr vec<3, T, Q> operator-(T scalar, vec<3, T, Q> const& v) { - return VectorT<3, T, Q>(scalar - v.x, scalar - v.y, scalar - v.z); + return vec<3, T, Q>(scalar - v.x, scalar - v.y, scalar - v.z); } /* * \note Vec1 is deliberately treated like a scalar to mimic shader languages. */ template - constexpr VectorT<3, T, Q> operator-(VectorT<3, T, Q> const& v, VectorT<1, T, Q> const& sv) + constexpr vec<3, T, Q> operator-(vec<3, T, Q> const& v, vec<1, T, Q> const& sv) { - return VectorT<3, T, Q>(v.x - sv.x, v.y - sv.x, v.z - sv.x); + return vec<3, T, Q>(v.x - sv.x, v.y - sv.x, v.z - sv.x); } /* * \note Vec1 is deliberately treated like a scalar to mimic shader languages. */ template - constexpr VectorT<3, T, Q> operator-(VectorT<1, T, Q> const& sv, VectorT<3, T, Q> const& v) + constexpr vec<3, T, Q> operator-(vec<1, T, Q> const& sv, vec<3, T, Q> const& v) { - return VectorT<3, T, Q>(sv.x - v.x, sv.x - v.y, sv.x - v.z); + return vec<3, T, Q>(sv.x - v.x, sv.x - v.y, sv.x - v.z); } template - constexpr VectorT<3, T, Q> operator-(VectorT<3, T, Q> const& v1, VectorT<3, T, Q> const& v2) + constexpr vec<3, T, Q> operator-(vec<3, T, Q> const& v1, vec<3, T, Q> const& v2) { - return VectorT<3, T, Q>(v1.x - v2.x, v1.y - v2.y, v1.z - v2.z); + return vec<3, T, Q>(v1.x - v2.x, v1.y - v2.y, v1.z - v2.z); } template - constexpr VectorT<3, T, Q> operator*(VectorT<3, T, Q> const& v, T scalar) + constexpr vec<3, T, Q> operator*(vec<3, T, Q> const& v, T scalar) { - return VectorT<3, T, Q>(v.x * scalar, v.y * scalar, v.z * scalar); + return vec<3, T, Q>(v.x * scalar, v.y * scalar, v.z * scalar); } template - constexpr VectorT<3, T, Q> operator*(T scalar, VectorT<3, T, Q> const& v) + constexpr vec<3, T, Q> operator*(T scalar, vec<3, T, Q> const& v) { - return VectorT<3, T, Q>(scalar * v.x, scalar * v.y, scalar * v.z); + return vec<3, T, Q>(scalar * v.x, scalar * v.y, scalar * v.z); } /* * \note Vec1 is deliberately treated like a scalar to mimic shader languages. */ template - constexpr VectorT<3, T, Q> operator*(VectorT<3, T, Q> const& v, VectorT<1, T, Q> const& sv) + constexpr vec<3, T, Q> operator*(vec<3, T, Q> const& v, vec<1, T, Q> const& sv) { - return VectorT<3, T, Q>(v.x * sv.x, v.y * sv.x, v.z * sv.x); + return vec<3, T, Q>(v.x * sv.x, v.y * sv.x, v.z * sv.x); } /* * \note Vec1 is deliberately treated like a scalar to mimic shader languages. */ template - constexpr VectorT<3, T, Q> operator*(VectorT<1, T, Q> const& sv, VectorT<3, T, Q> const& v) + constexpr vec<3, T, Q> operator*(vec<1, T, Q> const& sv, vec<3, T, Q> const& v) { - return VectorT<3, T, Q>(sv.x * v.x, sv.x * v.y, sv.x * v.z); + return vec<3, T, Q>(sv.x * v.x, sv.x * v.y, sv.x * v.z); } template - constexpr VectorT<3, T, Q> operator*(VectorT<3, T, Q> const& v1, VectorT<3, T, Q> const& v2) + constexpr vec<3, T, Q> operator*(vec<3, T, Q> const& v1, vec<3, T, Q> const& v2) { - return VectorT<3, T, Q>(v1.x * v2.x, v1.y * v2.y, v1.z * v2.z); + return vec<3, T, Q>(v1.x * v2.x, v1.y * v2.y, v1.z * v2.z); } template - constexpr VectorT<3, T, Q> operator/(VectorT<3, T, Q> const& v, T scalar) + constexpr vec<3, T, Q> operator/(vec<3, T, Q> const& v, T scalar) { - return VectorT<3, T, Q>(v.x / scalar, v.y / scalar, v.z / scalar); + return vec<3, T, Q>(v.x / scalar, v.y / scalar, v.z / scalar); } template - constexpr VectorT<3, T, Q> operator/(T scalar, VectorT<3, T, Q> const& v) + constexpr vec<3, T, Q> operator/(T scalar, vec<3, T, Q> const& v) { - return VectorT<3, T, Q>(scalar / v.x, scalar / v.y, scalar / v.z); + return vec<3, T, Q>(scalar / v.x, scalar / v.y, scalar / v.z); } /* * \note Vec1 is deliberately treated like a scalar to mimic shader languages. */ template - constexpr VectorT<3, T, Q> operator/(VectorT<3, T, Q> const& v, VectorT<1, T, Q> const& sv) + constexpr vec<3, T, Q> operator/(vec<3, T, Q> const& v, vec<1, T, Q> const& sv) { - return VectorT<3, T, Q>(v.x / sv.x, v.y / sv.x, v.z / sv.x); + return vec<3, T, Q>(v.x / sv.x, v.y / sv.x, v.z / sv.x); } /* * \note Vec1 is deliberately treated like a scalar to mimic shader languages. */ template - constexpr VectorT<3, T, Q> operator/(VectorT<1, T, Q> const& sv, VectorT<3, T, Q> const& v) + constexpr vec<3, T, Q> operator/(vec<1, T, Q> const& sv, vec<3, T, Q> const& v) { - return VectorT<3, T, Q>(sv.x / v.x, sv.x / v.y, sv.x / v.z); + return vec<3, T, Q>(sv.x / v.x, sv.x / v.y, sv.x / v.z); } template - constexpr VectorT<3, T, Q> operator/(VectorT<3, T, Q> const& v1, VectorT<3, T, Q> const& v2) + constexpr vec<3, T, Q> operator/(vec<3, T, Q> const& v1, vec<3, T, Q> const& v2) { - return VectorT<3, T, Q>(v1.x / v2.x, v1.y / v2.y, v1.z / v2.z); + return vec<3, T, Q>(v1.x / v2.x, v1.y / v2.y, v1.z / v2.z); } template - constexpr VectorT<3, T, Q> operator%(VectorT<3, T, Q> const& v, T scalar) + constexpr vec<3, T, Q> operator%(vec<3, T, Q> const& v, T scalar) { - return VectorT<3, T, Q>(v.x % scalar, v.y % scalar, v.z % scalar); + return vec<3, T, Q>(v.x % scalar, v.y % scalar, v.z % scalar); } template - constexpr VectorT<3, T, Q> operator%(T scalar, VectorT<3, T, Q> const& v) + constexpr vec<3, T, Q> operator%(T scalar, vec<3, T, Q> const& v) { - return VectorT<3, T, Q>(scalar % v.x, scalar % v.y, scalar % v.z); + return vec<3, T, Q>(scalar % v.x, scalar % v.y, scalar % v.z); } /* * \note Vec1 is deliberately treated like a scalar to mimic shader languages. */ template - constexpr VectorT<3, T, Q> operator%(VectorT<3, T, Q> const& v, VectorT<1, T, Q> const& sv) + constexpr vec<3, T, Q> operator%(vec<3, T, Q> const& v, vec<1, T, Q> const& sv) { - return VectorT<3, T, Q>(v.x % sv.x, v.y % sv.x, v.z % sv.x); + return vec<3, T, Q>(v.x % sv.x, v.y % sv.x, v.z % sv.x); } /* * \note Vec1 is deliberately treated like a scalar to mimic shader languages. */ template - constexpr VectorT<3, T, Q> operator%(VectorT<1, T, Q> const& sv, VectorT<3, T, Q> const& v) + constexpr vec<3, T, Q> operator%(vec<1, T, Q> const& sv, vec<3, T, Q> const& v) { - return VectorT<3, T, Q>(sv.x % v.x, sv.x % v.y, sv.x % v.z); + return vec<3, T, Q>(sv.x % v.x, sv.x % v.y, sv.x % v.z); } template - constexpr VectorT<3, T, Q> operator%(VectorT<3, T, Q> const& v1, VectorT<3, T, Q> const& v2) + constexpr vec<3, T, Q> operator%(vec<3, T, Q> const& v1, vec<3, T, Q> const& v2) { - return VectorT<3, T, Q>(v1.x % v2.x, v1.y % v2.y, v1.z % v2.z); + return vec<3, T, Q>(v1.x % v2.x, v1.y % v2.y, v1.z % v2.z); } template - constexpr VectorT<3, T, Q> operator&(VectorT<3, T, Q> const& v, T scalar) + constexpr vec<3, T, Q> operator&(vec<3, T, Q> const& v, T scalar) { - return VectorT<3, T, Q>(v.x & scalar, v.y & scalar, v.z & scalar); + return vec<3, T, Q>(v.x & scalar, v.y & scalar, v.z & scalar); } template - constexpr VectorT<3, T, Q> operator&(T scalar, VectorT<3, T, Q> const& v) + constexpr vec<3, T, Q> operator&(T scalar, vec<3, T, Q> const& v) { - return VectorT<3, T, Q>(scalar & v.x, scalar & v.y, scalar & v.z); + return vec<3, T, Q>(scalar & v.x, scalar & v.y, scalar & v.z); } /* * \note Vec1 is deliberately treated like a scalar to mimic shader languages. */ template - constexpr VectorT<3, T, Q> operator&(VectorT<3, T, Q> const& v, VectorT<1, T, Q> const& sv) + constexpr vec<3, T, Q> operator&(vec<3, T, Q> const& v, vec<1, T, Q> const& sv) { - return VectorT<3, T, Q>(v.x & sv.x, v.y & sv.x, v.z & sv.x); + return vec<3, T, Q>(v.x & sv.x, v.y & sv.x, v.z & sv.x); } /* * \note Vec1 is deliberately treated like a scalar to mimic shader languages. */ template - constexpr VectorT<3, T, Q> operator&(VectorT<1, T, Q> const& sv, VectorT<3, T, Q> const& v) + constexpr vec<3, T, Q> operator&(vec<1, T, Q> const& sv, vec<3, T, Q> const& v) { - return VectorT<3, T, Q>(sv.x & v.x, sv.x & v.y, sv.x & v.z); + return vec<3, T, Q>(sv.x & v.x, sv.x & v.y, sv.x & v.z); } template - constexpr VectorT<3, T, Q> operator&(VectorT<3, T, Q> const& v1, VectorT<3, T, Q> const& v2) + constexpr vec<3, T, Q> operator&(vec<3, T, Q> const& v1, vec<3, T, Q> const& v2) { - return VectorT<3, T, Q>(v1.x & v2.x, v1.y & v2.y, v1.z & v2.z); + return vec<3, T, Q>(v1.x & v2.x, v1.y & v2.y, v1.z & v2.z); } template - constexpr VectorT<3, T, Q> operator|(VectorT<3, T, Q> const& v, T scalar) + constexpr vec<3, T, Q> operator|(vec<3, T, Q> const& v, T scalar) { - return VectorT<3, T, Q>(v.x | scalar, v.y | scalar, v.z | scalar); + return vec<3, T, Q>(v.x | scalar, v.y | scalar, v.z | scalar); } template - constexpr VectorT<3, T, Q> operator|(T scalar, VectorT<3, T, Q> const& v) + constexpr vec<3, T, Q> operator|(T scalar, vec<3, T, Q> const& v) { - return VectorT<3, T, Q>(scalar | v.x, scalar | v.y, scalar | v.z); + return vec<3, T, Q>(scalar | v.x, scalar | v.y, scalar | v.z); } /* * \note Vec1 is deliberately treated like a scalar to mimic shader languages. */ template - constexpr VectorT<3, T, Q> operator|(VectorT<3, T, Q> const& v, VectorT<1, T, Q> const& sv) + constexpr vec<3, T, Q> operator|(vec<3, T, Q> const& v, vec<1, T, Q> const& sv) { - return VectorT<3, T, Q>(v.x | sv.x, v.y | sv.x, v.z | sv.x); + return vec<3, T, Q>(v.x | sv.x, v.y | sv.x, v.z | sv.x); } /* * \note Vec1 is deliberately treated like a scalar to mimic shader languages. */ template - constexpr VectorT<3, T, Q> operator|(VectorT<1, T, Q> const& sv, VectorT<3, T, Q> const& v) + constexpr vec<3, T, Q> operator|(vec<1, T, Q> const& sv, vec<3, T, Q> const& v) { - return VectorT<3, T, Q>(sv.x | v.x, sv.x | v.y, sv.x | v.z); + return vec<3, T, Q>(sv.x | v.x, sv.x | v.y, sv.x | v.z); } template - constexpr VectorT<3, T, Q> operator|(VectorT<3, T, Q> const& v1, VectorT<3, T, Q> const& v2) + constexpr vec<3, T, Q> operator|(vec<3, T, Q> const& v1, vec<3, T, Q> const& v2) { - return VectorT<3, T, Q>(v1.x | v2.x, v1.y | v2.y, v1.z | v2.z); + return vec<3, T, Q>(v1.x | v2.x, v1.y | v2.y, v1.z | v2.z); } template - constexpr VectorT<3, T, Q> operator^(VectorT<3, T, Q> const& v, T scalar) + constexpr vec<3, T, Q> operator^(vec<3, T, Q> const& v, T scalar) { - return VectorT<3, T, Q>(v.x ^ scalar, v.y ^ scalar, v.z ^ scalar); + return vec<3, T, Q>(v.x ^ scalar, v.y ^ scalar, v.z ^ scalar); } template - constexpr VectorT<3, T, Q> operator^(T scalar, VectorT<3, T, Q> const& v) + constexpr vec<3, T, Q> operator^(T scalar, vec<3, T, Q> const& v) { - return VectorT<3, T, Q>(scalar ^ v.x, scalar ^ v.y, scalar ^ v.z); + return vec<3, T, Q>(scalar ^ v.x, scalar ^ v.y, scalar ^ v.z); } /* * \note Vec1 is deliberately treated like a scalar to mimic shader languages. */ template - constexpr VectorT<3, T, Q> operator^(VectorT<3, T, Q> const& v, VectorT<1, T, Q> const& sv) + constexpr vec<3, T, Q> operator^(vec<3, T, Q> const& v, vec<1, T, Q> const& sv) { - return VectorT<3, T, Q>(v.x ^ sv.x, v.y ^ sv.x, v.z ^ sv.x); + return vec<3, T, Q>(v.x ^ sv.x, v.y ^ sv.x, v.z ^ sv.x); } /* * \note Vec1 is deliberately treated like a scalar to mimic shader languages. */ template - constexpr VectorT<3, T, Q> operator^(VectorT<1, T, Q> const& sv, VectorT<3, T, Q> const& v) + constexpr vec<3, T, Q> operator^(vec<1, T, Q> const& sv, vec<3, T, Q> const& v) { - return VectorT<3, T, Q>(sv.x ^ v.x, sv.x ^ v.y, sv.x ^ v.z); + return vec<3, T, Q>(sv.x ^ v.x, sv.x ^ v.y, sv.x ^ v.z); } template - constexpr VectorT<3, T, Q> operator^(VectorT<3, T, Q> const& v1, VectorT<3, T, Q> const& v2) + constexpr vec<3, T, Q> operator^(vec<3, T, Q> const& v1, vec<3, T, Q> const& v2) { - return VectorT<3, T, Q>(v1.x ^ v2.x, v1.y ^ v2.y, v1.z ^ v2.z); + return vec<3, T, Q>(v1.x ^ v2.x, v1.y ^ v2.y, v1.z ^ v2.z); } template - constexpr VectorT<3, T, Q> operator<<(VectorT<3, T, Q> const& v, T scalar) + constexpr vec<3, T, Q> operator<<(vec<3, T, Q> const& v, T scalar) { - return VectorT<3, T, Q>(v.x << scalar, v.y << scalar, v.z << scalar); + return vec<3, T, Q>(v.x << scalar, v.y << scalar, v.z << scalar); } template - constexpr VectorT<3, T, Q> operator<<(T scalar, VectorT<3, T, Q> const& v) + constexpr vec<3, T, Q> operator<<(T scalar, vec<3, T, Q> const& v) { - return VectorT<3, T, Q>(scalar << v.x, scalar << v.y, scalar << v.z); + return vec<3, T, Q>(scalar << v.x, scalar << v.y, scalar << v.z); } /* * \note Vec1 is deliberately treated like a scalar to mimic shader languages. */ template - constexpr VectorT<3, T, Q> operator<<(VectorT<3, T, Q> const& v, VectorT<1, T, Q> const& sv) + constexpr vec<3, T, Q> operator<<(vec<3, T, Q> const& v, vec<1, T, Q> const& sv) { - return VectorT<3, T, Q>(v.x << sv.x, v.y << sv.x, v.z << sv.x); + return vec<3, T, Q>(v.x << sv.x, v.y << sv.x, v.z << sv.x); } /* * \note Vec1 is deliberately treated like a scalar to mimic shader languages. */ template - constexpr VectorT<3, T, Q> operator<<(VectorT<1, T, Q> const& sv, VectorT<3, T, Q> const& v) + constexpr vec<3, T, Q> operator<<(vec<1, T, Q> const& sv, vec<3, T, Q> const& v) { - return VectorT<3, T, Q>(sv.x << v.x, sv.x << v.y, sv.x << v.z); + return vec<3, T, Q>(sv.x << v.x, sv.x << v.y, sv.x << v.z); } template - constexpr VectorT<3, T, Q> operator<<(VectorT<3, T, Q> const& v1, VectorT<3, T, Q> const& v2) + constexpr vec<3, T, Q> operator<<(vec<3, T, Q> const& v1, vec<3, T, Q> const& v2) { - return VectorT<3, T, Q>(v1.x << v2.x, v1.y << v2.y, v1.z << v2.z); + return vec<3, T, Q>(v1.x << v2.x, v1.y << v2.y, v1.z << v2.z); } template - constexpr VectorT<3, T, Q> operator>>(VectorT<3, T, Q> const& v, T scalar) + constexpr vec<3, T, Q> operator>>(vec<3, T, Q> const& v, T scalar) { - return VectorT<3, T, Q>(v.x >> scalar, v.y >> scalar, v.z >> scalar); + return vec<3, T, Q>(v.x >> scalar, v.y >> scalar, v.z >> scalar); } template - constexpr VectorT<3, T, Q> operator>>(T scalar, VectorT<3, T, Q> const& v) + constexpr vec<3, T, Q> operator>>(T scalar, vec<3, T, Q> const& v) { - return VectorT<3, T, Q>(scalar >> v.x, scalar >> v.y, scalar >> v.z); + return vec<3, T, Q>(scalar >> v.x, scalar >> v.y, scalar >> v.z); } /* * \note Vec1 is deliberately treated like a scalar to mimic shader languages. */ template - constexpr VectorT<3, T, Q> operator>>(VectorT<3, T, Q> const& v, VectorT<1, T, Q> const& sv) + constexpr vec<3, T, Q> operator>>(vec<3, T, Q> const& v, vec<1, T, Q> const& sv) { - return VectorT<3, T, Q>(v.x >> sv.x, v.y >> sv.x, v.z >> sv.x); + return vec<3, T, Q>(v.x >> sv.x, v.y >> sv.x, v.z >> sv.x); } /* * \note Vec1 is deliberately treated like a scalar to mimic shader languages. */ template - constexpr VectorT<3, T, Q> operator>>(VectorT<1, T, Q> const& sv, VectorT<3, T, Q> const& v) + constexpr vec<3, T, Q> operator>>(vec<1, T, Q> const& sv, vec<3, T, Q> const& v) { - return VectorT<3, T, Q>(sv.x >> v.x, sv.x >> v.y, sv.x >> v.z); + return vec<3, T, Q>(sv.x >> v.x, sv.x >> v.y, sv.x >> v.z); } template - constexpr VectorT<3, T, Q> operator>>(VectorT<3, T, Q> const& v1, VectorT<3, T, Q> const& v2) + constexpr vec<3, T, Q> operator>>(vec<3, T, Q> const& v1, vec<3, T, Q> const& v2) { - return VectorT<3, T, Q>(v1.x >> v2.x, v1.y >> v2.y, v1.z >> v2.z); + return vec<3, T, Q>(v1.x >> v2.x, v1.y >> v2.y, v1.z >> v2.z); } template - constexpr VectorT<3, T, Q> operator~(VectorT<3, T, Q> const& v) + constexpr vec<3, T, Q> operator~(vec<3, T, Q> const& v) { - return VectorT<3, T, Q>(~v.x, ~v.y, ~v.z); + return vec<3, T, Q>(~v.x, ~v.y, ~v.z); } template - constexpr bool operator==(VectorT<3, T, Q> const& v1, VectorT<3, T, Q> const& v2) + constexpr bool operator==(vec<3, T, Q> const& v1, vec<3, T, Q> const& v2) { return detail::Equal::is_iec559, sizeof(T) * 6, detail::IsAligned::value>::compute(v1, v2); } template - constexpr bool operator!=(VectorT<3, T, Q> const& v1, VectorT<3, T, Q> const& v2) + constexpr bool operator!=(vec<3, T, Q> const& v1, vec<3, T, Q> const& v2) { return !(v1 == v2); } template - constexpr VectorT<3, bool, Q> operator&&(VectorT<3, T, Q> const& v1, VectorT<3, T, Q> const& v2) + constexpr vec<3, bool, Q> operator&&(vec<3, T, Q> const& v1, vec<3, T, Q> const& v2) { return (v1.x && v2.x, v1.y && v2.y, v1.z && v2.z); } template - constexpr VectorT<3, bool, Q> operator||(VectorT<3, T, Q> const& v1, VectorT<3, T, Q> const& v2) + constexpr vec<3, bool, Q> operator||(vec<3, T, Q> const& v1, vec<3, T, Q> const& v2) { return (v1.x || v2.x, v1.y || v2.y, v1.z || v2.z); } diff --git a/include/mim/detail/type/type_vector4.hpp b/include/mim/detail/type/type_vector4.hpp index 403503f..a048516 100644 --- a/include/mim/detail/type/type_vector4.hpp +++ b/include/mim/detail/type/type_vector4.hpp @@ -7,9 +7,9 @@ namespace mim { template - struct VectorT<4, T, Q> { + struct vec<4, T, Q> { using value_type = T; - using type = VectorT<4, T, Q>; + using type = vec<4, T, Q>; using size_type = size_t; static constexpr auto size_v = 4; @@ -25,237 +25,237 @@ namespace mim /// Constructors - constexpr VectorT(); + constexpr vec(); - constexpr VectorT(T x, T y, T z, T w); + constexpr vec(T x, T y, T z, T w); - constexpr VectorT(VectorT<4, T, Q> const& v); + constexpr vec(vec<4, T, Q> const& v); - constexpr explicit VectorT(T scalar); + constexpr explicit vec(T scalar); /// Template Constructors template - constexpr explicit VectorT(VectorT<4, T, P> const& v); + constexpr explicit vec(vec<4, T, P> const& v); // U Template Constructors template - constexpr explicit VectorT(VectorT<1, U, P> const& v); + constexpr explicit vec(vec<1, U, P> const& v); template - constexpr explicit VectorT(VectorT<4, U, P> const& v); + constexpr explicit vec(vec<4, U, P> const& v); // XYZW Template Constructors template - constexpr VectorT(X _x, Y _y, Z _z, W _w); + constexpr vec(X _x, Y _y, Z _z, W _w); template - constexpr VectorT(VectorT<1, X, Q> const& _x, Y _y, Z _z, W _w); + constexpr vec(vec<1, X, Q> const& _x, Y _y, Z _z, W _w); template - constexpr VectorT(X _x, VectorT<1, Y, Q> const& _y, Z _z, W _w); + constexpr vec(X _x, vec<1, Y, Q> const& _y, Z _z, W _w); template - constexpr VectorT(VectorT<1, X, Q> const& _x, VectorT<1, Y, Q> const& _y, Z _z, W _w); + constexpr vec(vec<1, X, Q> const& _x, vec<1, Y, Q> const& _y, Z _z, W _w); template - constexpr VectorT(X _x, Y _y, VectorT<1, Z, Q> const& _z, W _w); + constexpr vec(X _x, Y _y, vec<1, Z, Q> const& _z, W _w); template - constexpr VectorT(VectorT<1, X, Q> const& _x, Y _y, VectorT<1, Z, Q> const& _z, W _w); + constexpr vec(vec<1, X, Q> const& _x, Y _y, vec<1, Z, Q> const& _z, W _w); template - constexpr VectorT(X _x, VectorT<1, Y, Q> const& _y, VectorT<1, Z, Q> const& _z, W _w); + constexpr vec(X _x, vec<1, Y, Q> const& _y, vec<1, Z, Q> const& _z, W _w); template - constexpr VectorT(VectorT<1, X, Q> const& _x, VectorT<1, Y, Q> const& _y, VectorT<1, Z, Q> const& _z, W _w); + constexpr vec(vec<1, X, Q> const& _x, vec<1, Y, Q> const& _y, vec<1, Z, Q> const& _z, W _w); template - constexpr VectorT(VectorT<1, X, Q> const& _x, Y _y, Z _z, VectorT<1, W, Q> const& _w); + constexpr vec(vec<1, X, Q> const& _x, Y _y, Z _z, vec<1, W, Q> const& _w); template - constexpr VectorT(X _x, VectorT<1, Y, Q> const& _y, Z _z, VectorT<1, W, Q> const& _w); + constexpr vec(X _x, vec<1, Y, Q> const& _y, Z _z, vec<1, W, Q> const& _w); template - constexpr VectorT(VectorT<1, X, Q> const& _x, VectorT<1, Y, Q> const& _y, Z _z, VectorT<1, W, Q> const& _w); + constexpr vec(vec<1, X, Q> const& _x, vec<1, Y, Q> const& _y, Z _z, vec<1, W, Q> const& _w); template - constexpr VectorT(X _x, Y _y, VectorT<1, Z, Q> const& _z, VectorT<1, W, Q> const& _w); + constexpr vec(X _x, Y _y, vec<1, Z, Q> const& _z, vec<1, W, Q> const& _w); template - constexpr VectorT(VectorT<1, X, Q> const& _x, Y _y, VectorT<1, Z, Q> const& _z, VectorT<1, W, Q> const& _w); + constexpr vec(vec<1, X, Q> const& _x, Y _y, vec<1, Z, Q> const& _z, vec<1, W, Q> const& _w); template - constexpr VectorT(X _x, VectorT<1, Y, Q> const& _y, VectorT<1, Z, Q> const& _z, VectorT<1, W, Q> const& _w); + constexpr vec(X _x, vec<1, Y, Q> const& _y, vec<1, Z, Q> const& _z, vec<1, W, Q> const& _w); template - constexpr VectorT(VectorT<1, X, Q> const& _x, VectorT<1, Y, Q> const& _y, VectorT<1, Z, Q> const& _z, VectorT<1, W, Q> const& _w); + constexpr vec(vec<1, X, Q> const& _x, vec<1, Y, Q> const& _y, vec<1, Z, Q> const& _z, vec<1, W, Q> const& _w); // ABC Template Constructors template - constexpr VectorT(VectorT<2, A, P> const& _xy, B _z, C _w); + constexpr vec(vec<2, A, P> const& _xy, B _z, C _w); template - constexpr VectorT(VectorT<2, A, P> const& _xy, VectorT<1, B, P> const& _z, C _w); + constexpr vec(vec<2, A, P> const& _xy, vec<1, B, P> const& _z, C _w); template - constexpr VectorT(VectorT<2, A, P> const& _xy, B _z, VectorT<1, C, P> const& _w); + constexpr vec(vec<2, A, P> const& _xy, B _z, vec<1, C, P> const& _w); template - constexpr VectorT(VectorT<2, A, P> const& _xy, VectorT<1, B, P> const& _z, VectorT<1, C, P> const& _w); + constexpr vec(vec<2, A, P> const& _xy, vec<1, B, P> const& _z, vec<1, C, P> const& _w); template - constexpr VectorT(A _x, VectorT<2, B, P> const& _yz, C _w); + constexpr vec(A _x, vec<2, B, P> const& _yz, C _w); template - constexpr VectorT(VectorT<1, A, P> const& _x, VectorT<2, B, P> const& _yz, C _w); + constexpr vec(vec<1, A, P> const& _x, vec<2, B, P> const& _yz, C _w); template - constexpr VectorT(A _x, VectorT<2, B, P> const& _yz, VectorT<1, C, P> const& _w); + constexpr vec(A _x, vec<2, B, P> const& _yz, vec<1, C, P> const& _w); template - constexpr VectorT(VectorT<1, A, P> const& _x, VectorT<2, B, P> const& _yz, VectorT<1, C, P> const& _w); + constexpr vec(vec<1, A, P> const& _x, vec<2, B, P> const& _yz, vec<1, C, P> const& _w); template - constexpr VectorT(A _x, B _y, VectorT<2, C, P> const& _zw); + constexpr vec(A _x, B _y, vec<2, C, P> const& _zw); template - constexpr VectorT(VectorT<1, A, P> const& _x, B _y, VectorT<2, C, P> const& _zw); + constexpr vec(vec<1, A, P> const& _x, B _y, vec<2, C, P> const& _zw); template - constexpr VectorT(A _x, VectorT<1, B, P> const& _y, VectorT<2, C, P> const& _zw); + constexpr vec(A _x, vec<1, B, P> const& _y, vec<2, C, P> const& _zw); template - constexpr VectorT(VectorT<1, A, P> const& _x, VectorT<1, B, P> const& _y, VectorT<2, C, P> const& _zw); + constexpr vec(vec<1, A, P> const& _x, vec<1, B, P> const& _y, vec<2, C, P> const& _zw); // AB Template Constructors template - constexpr VectorT(VectorT<3, A, P> const& _xyz, B _w); + constexpr vec(vec<3, A, P> const& _xyz, B _w); template - constexpr VectorT(VectorT<3, A, P> const& _xyz, VectorT<1, B, P> const& _w); + constexpr vec(vec<3, A, P> const& _xyz, vec<1, B, P> const& _w); template - constexpr VectorT(A _x, VectorT<3, B, P> const& _yzw); + constexpr vec(A _x, vec<3, B, P> const& _yzw); template - constexpr VectorT(VectorT<1, A, P> const& _x, VectorT<3, B, P> const& _yzw); + constexpr vec(vec<1, A, P> const& _x, vec<3, B, P> const& _yzw); template - constexpr VectorT(VectorT<2, A, P> const& _xy, VectorT<2, B, P> const& _zw); + constexpr vec(vec<2, A, P> const& _xy, vec<2, B, P> const& _zw); /// Assignment Operators - constexpr VectorT<4, T, Q>& operator=(VectorT<4, T, Q> const& v); + constexpr vec<4, T, Q>& operator=(vec<4, T, Q> const& v); template - constexpr VectorT<4, T, Q>& operator=(VectorT<4, U, Q> const& v); + constexpr vec<4, T, Q>& operator=(vec<4, U, Q> const& v); template - constexpr VectorT<4, T, Q>& operator+=(U scalar); + constexpr vec<4, T, Q>& operator+=(U scalar); template - constexpr VectorT<4, T, Q>& operator+=(VectorT<1, U, Q> const& v); + constexpr vec<4, T, Q>& operator+=(vec<1, U, Q> const& v); template - constexpr VectorT<4, T, Q>& operator+=(VectorT<4, U, Q> const& v); + constexpr vec<4, T, Q>& operator+=(vec<4, U, Q> const& v); template - constexpr VectorT<4, T, Q>& operator-=(U scalar); + constexpr vec<4, T, Q>& operator-=(U scalar); template - constexpr VectorT<4, T, Q>& operator-=(VectorT<1, U, Q> const& v); + constexpr vec<4, T, Q>& operator-=(vec<1, U, Q> const& v); template - constexpr VectorT<4, T, Q>& operator-=(VectorT<4, U, Q> const& v); + constexpr vec<4, T, Q>& operator-=(vec<4, U, Q> const& v); template - constexpr VectorT<4, T, Q>& operator*=(U scalar); + constexpr vec<4, T, Q>& operator*=(U scalar); template - constexpr VectorT<4, T, Q>& operator*=(VectorT<1, U, Q> const& v); + constexpr vec<4, T, Q>& operator*=(vec<1, U, Q> const& v); template - constexpr VectorT<4, T, Q>& operator*=(VectorT<4, U, Q> const& v); + constexpr vec<4, T, Q>& operator*=(vec<4, U, Q> const& v); template - constexpr VectorT<4, T, Q>& operator/=(U scalar); + constexpr vec<4, T, Q>& operator/=(U scalar); template - constexpr VectorT<4, T, Q>& operator/=(VectorT<1, U, Q> const& v); + constexpr vec<4, T, Q>& operator/=(vec<1, U, Q> const& v); template - constexpr VectorT<4, T, Q>& operator/=(VectorT<4, U, Q> const& v); + constexpr vec<4, T, Q>& operator/=(vec<4, U, Q> const& v); template - constexpr VectorT<4, T, Q>& operator%=(U scalar); + constexpr vec<4, T, Q>& operator%=(U scalar); template - constexpr VectorT<4, T, Q>& operator%=(VectorT<1, U, Q> const& v); + constexpr vec<4, T, Q>& operator%=(vec<1, U, Q> const& v); template - constexpr VectorT<4, T, Q>& operator%=(VectorT<4, U, Q> const& v); + constexpr vec<4, T, Q>& operator%=(vec<4, U, Q> const& v); /// Increment and Decrement Operators - constexpr VectorT<4, T, Q>& operator++(); + constexpr vec<4, T, Q>& operator++(); - constexpr VectorT<4, T, Q>& operator--(); + constexpr vec<4, T, Q>& operator--(); - constexpr const VectorT<4, T, Q> operator++(int); + constexpr const vec<4, T, Q> operator++(int); - constexpr const VectorT<4, T, Q> operator--(int); + constexpr const vec<4, T, Q> operator--(int); /// Bitwise Assignment Operators template - constexpr VectorT<4, T, Q>& operator&=(U scalar); + constexpr vec<4, T, Q>& operator&=(U scalar); template - constexpr VectorT<4, T, Q>& operator&=(VectorT<1, U, Q> const& v); + constexpr vec<4, T, Q>& operator&=(vec<1, U, Q> const& v); template - constexpr VectorT<4, T, Q>& operator&=(VectorT<4, U, Q> const& v); + constexpr vec<4, T, Q>& operator&=(vec<4, U, Q> const& v); template - constexpr VectorT<4, T, Q>& operator|=(U scalar); + constexpr vec<4, T, Q>& operator|=(U scalar); template - constexpr VectorT<4, T, Q>& operator|=(VectorT<1, U, Q> const& v); + constexpr vec<4, T, Q>& operator|=(vec<1, U, Q> const& v); template - constexpr VectorT<4, T, Q>& operator|=(VectorT<4, U, Q> const& v); + constexpr vec<4, T, Q>& operator|=(vec<4, U, Q> const& v); template - constexpr VectorT<4, T, Q>& operator^=(U scalar); + constexpr vec<4, T, Q>& operator^=(U scalar); template - constexpr VectorT<4, T, Q>& operator^=(VectorT<1, U, Q> const& v); + constexpr vec<4, T, Q>& operator^=(vec<1, U, Q> const& v); template - constexpr VectorT<4, T, Q>& operator^=(VectorT<4, U, Q> const& v); + constexpr vec<4, T, Q>& operator^=(vec<4, U, Q> const& v); template - constexpr VectorT<4, T, Q>& operator<<=(U scalar); + constexpr vec<4, T, Q>& operator<<=(U scalar); template - constexpr VectorT<4, T, Q>& operator<<=(VectorT<1, U, Q> const& v); + constexpr vec<4, T, Q>& operator<<=(vec<1, U, Q> const& v); template - constexpr VectorT<4, T, Q>& operator<<=(VectorT<4, U, Q> const& v); + constexpr vec<4, T, Q>& operator<<=(vec<4, U, Q> const& v); template - constexpr VectorT<4, T, Q>& operator>>=(U scalar); + constexpr vec<4, T, Q>& operator>>=(U scalar); template - constexpr VectorT<4, T, Q>& operator>>=(VectorT<1, U, Q> const& v); + constexpr vec<4, T, Q>& operator>>=(vec<1, U, Q> const& v); template - constexpr VectorT<4, T, Q>& operator>>=(VectorT<4, U, Q> const& v); + constexpr vec<4, T, Q>& operator>>=(vec<4, U, Q> const& v); /// Generic Function Declarations @@ -266,204 +266,204 @@ namespace mim constexpr void normalize(); - constexpr VectorT<4, T, Q> normalized() const; + constexpr vec<4, T, Q> normalized() const; MIM_NODISCARD constexpr bool is_normalized() const; - constexpr T distance(const VectorT<4, T, Q>& v) const; + constexpr T distance(const vec<4, T, Q>& v) const; - constexpr T distance_squared(const VectorT<4, T, Q>& v) const; + constexpr T distance_squared(const vec<4, T, Q>& v) const; /// Function Declarations - constexpr T dot(const VectorT<4, T, Q>& v) const; - constexpr T cross(const VectorT<4, T, Q>& v) const; - constexpr VectorT<4, T, Q> rotated(T angle) const; - constexpr VectorT<4, T, Q> clamp(const VectorT<4, T, Q>& min, const VectorT<4, T, Q>& max) const; - constexpr VectorT<4, T, Q> reflect(const VectorT<4, T, Q>& normal) const; - constexpr VectorT<4, T, Q> refract(const VectorT<4, T, Q>& normal, T eta) const; - constexpr VectorT<4, T, Q> project(const VectorT<4, T, Q>& normal) const; + constexpr T dot(const vec<4, T, Q>& v) const; + constexpr T cross(const vec<4, T, Q>& v) const; + constexpr vec<4, T, Q> rotated(T angle) const; + constexpr vec<4, T, Q> clamp(const vec<4, T, Q>& min, const vec<4, T, Q>& max) const; + constexpr vec<4, T, Q> reflect(const vec<4, T, Q>& normal) const; + constexpr vec<4, T, Q> refract(const vec<4, T, Q>& normal, T eta) const; + constexpr vec<4, T, Q> project(const vec<4, T, Q>& normal) const; }; /// Unary Operators template - constexpr VectorT<4, T, Q> operator+(VectorT<4, T, Q> const& v); + constexpr vec<4, T, Q> operator+(vec<4, T, Q> const& v); template - constexpr VectorT<4, T, Q> operator-(VectorT<4, T, Q> const& v); + constexpr vec<4, T, Q> operator-(vec<4, T, Q> const& v); /// Binary Operators template - constexpr VectorT<4, T, Q> operator+(VectorT<4, T, Q> const& v, T const& scalar); + constexpr vec<4, T, Q> operator+(vec<4, T, Q> const& v, T const& scalar); template - constexpr VectorT<4, T, Q> operator+(T scalar, VectorT<4, T, Q> const& v); + constexpr vec<4, T, Q> operator+(T scalar, vec<4, T, Q> const& v); template - constexpr VectorT<4, T, Q> operator+(VectorT<4, T, Q> const& v1, VectorT<1, T, Q> const& v2); + constexpr vec<4, T, Q> operator+(vec<4, T, Q> const& v1, vec<1, T, Q> const& v2); template - constexpr VectorT<4, T, Q> operator+(VectorT<1, T, Q> const& v1, VectorT<4, T, Q> const& v2); + constexpr vec<4, T, Q> operator+(vec<1, T, Q> const& v1, vec<4, T, Q> const& v2); template - constexpr VectorT<4, T, Q> operator+(VectorT<4, T, Q> const& v1, VectorT<4, T, Q> const& v2); + constexpr vec<4, T, Q> operator+(vec<4, T, Q> const& v1, vec<4, T, Q> const& v2); template - constexpr VectorT<4, T, Q> operator-(VectorT<4, T, Q> const& v, T const& scalar); + constexpr vec<4, T, Q> operator-(vec<4, T, Q> const& v, T const& scalar); template - constexpr VectorT<4, T, Q> operator-(T scalar, VectorT<4, T, Q> const& v); + constexpr vec<4, T, Q> operator-(T scalar, vec<4, T, Q> const& v); template - constexpr VectorT<4, T, Q> operator-(VectorT<4, T, Q> const& v1, VectorT<1, T, Q> const& v2); + constexpr vec<4, T, Q> operator-(vec<4, T, Q> const& v1, vec<1, T, Q> const& v2); template - constexpr VectorT<4, T, Q> operator-(VectorT<1, T, Q> const& v1, VectorT<4, T, Q> const& v2); + constexpr vec<4, T, Q> operator-(vec<1, T, Q> const& v1, vec<4, T, Q> const& v2); template - constexpr VectorT<4, T, Q> operator-(VectorT<4, T, Q> const& v1, VectorT<4, T, Q> const& v2); + constexpr vec<4, T, Q> operator-(vec<4, T, Q> const& v1, vec<4, T, Q> const& v2); template - constexpr VectorT<4, T, Q> operator*(VectorT<4, T, Q> const& v, T const& scalar); + constexpr vec<4, T, Q> operator*(vec<4, T, Q> const& v, T const& scalar); template - constexpr VectorT<4, T, Q> operator*(T scalar, VectorT<4, T, Q> const& v); + constexpr vec<4, T, Q> operator*(T scalar, vec<4, T, Q> const& v); template - constexpr VectorT<4, T, Q> operator*(VectorT<4, T, Q> const& v1, VectorT<1, T, Q> const& v2); + constexpr vec<4, T, Q> operator*(vec<4, T, Q> const& v1, vec<1, T, Q> const& v2); template - constexpr VectorT<4, T, Q> operator*(VectorT<1, T, Q> const& v1, VectorT<4, T, Q> const& v2); + constexpr vec<4, T, Q> operator*(vec<1, T, Q> const& v1, vec<4, T, Q> const& v2); template - constexpr VectorT<4, T, Q> operator*(VectorT<4, T, Q> const& v1, VectorT<4, T, Q> const& v2); + constexpr vec<4, T, Q> operator*(vec<4, T, Q> const& v1, vec<4, T, Q> const& v2); template - constexpr VectorT<4, T, Q> operator/(VectorT<4, T, Q> const& v, T const& scalar); + constexpr vec<4, T, Q> operator/(vec<4, T, Q> const& v, T const& scalar); template - constexpr VectorT<4, T, Q> operator/(T scalar, VectorT<4, T, Q> const& v); + constexpr vec<4, T, Q> operator/(T scalar, vec<4, T, Q> const& v); template - constexpr VectorT<4, T, Q> operator/(VectorT<4, T, Q> const& v1, VectorT<1, T, Q> const& v2); + constexpr vec<4, T, Q> operator/(vec<4, T, Q> const& v1, vec<1, T, Q> const& v2); template - constexpr VectorT<4, T, Q> operator/(VectorT<1, T, Q> const& v1, VectorT<4, T, Q> const& v2); + constexpr vec<4, T, Q> operator/(vec<1, T, Q> const& v1, vec<4, T, Q> const& v2); template - constexpr VectorT<4, T, Q> operator/(VectorT<4, T, Q> const& v1, VectorT<4, T, Q> const& v2); + constexpr vec<4, T, Q> operator/(vec<4, T, Q> const& v1, vec<4, T, Q> const& v2); template - constexpr VectorT<4, T, Q> operator%(VectorT<4, T, Q> const& v, T scalar); + constexpr vec<4, T, Q> operator%(vec<4, T, Q> const& v, T scalar); template - constexpr VectorT<4, T, Q> operator%(T scalar, VectorT<4, T, Q> const& v); + constexpr vec<4, T, Q> operator%(T scalar, vec<4, T, Q> const& v); template - constexpr VectorT<4, T, Q> operator%(VectorT<4, T, Q> const& v, VectorT<1, T, Q> const& v2); + constexpr vec<4, T, Q> operator%(vec<4, T, Q> const& v, vec<1, T, Q> const& v2); template - constexpr VectorT<4, T, Q> operator%(VectorT<1, T, Q> const& scalar, VectorT<4, T, Q> const& v); + constexpr vec<4, T, Q> operator%(vec<1, T, Q> const& scalar, vec<4, T, Q> const& v); template - constexpr VectorT<4, T, Q> operator%(VectorT<4, T, Q> const& v1, VectorT<4, T, Q> const& v2); + constexpr vec<4, T, Q> operator%(vec<4, T, Q> const& v1, vec<4, T, Q> const& v2); /// Bitwise Binary Operators template - constexpr VectorT<4, T, Q> operator&(VectorT<4, T, Q> const& v, T scalar); + constexpr vec<4, T, Q> operator&(vec<4, T, Q> const& v, T scalar); template - constexpr VectorT<4, T, Q> operator&(T scalar, VectorT<4, T, Q> const& v); + constexpr vec<4, T, Q> operator&(T scalar, vec<4, T, Q> const& v); template - constexpr VectorT<4, T, Q> operator&(VectorT<4, T, Q> const& v, VectorT<1, T, Q> const& scalar); + constexpr vec<4, T, Q> operator&(vec<4, T, Q> const& v, vec<1, T, Q> const& scalar); template - constexpr VectorT<4, T, Q> operator&(VectorT<1, T, Q> const& v1, VectorT<4, T, Q> const& v); + constexpr vec<4, T, Q> operator&(vec<1, T, Q> const& v1, vec<4, T, Q> const& v); template - constexpr VectorT<4, T, Q> operator&(VectorT<4, T, Q> const& v1, VectorT<4, T, Q> const& v2); + constexpr vec<4, T, Q> operator&(vec<4, T, Q> const& v1, vec<4, T, Q> const& v2); template - constexpr VectorT<4, T, Q> operator|(VectorT<4, T, Q> const& v, T scalar); + constexpr vec<4, T, Q> operator|(vec<4, T, Q> const& v, T scalar); template - constexpr VectorT<4, T, Q> operator|(T scalar, VectorT<4, T, Q> const& v); + constexpr vec<4, T, Q> operator|(T scalar, vec<4, T, Q> const& v); template - constexpr VectorT<4, T, Q> operator|(VectorT<4, T, Q> const& v, VectorT<1, T, Q> const& v2); + constexpr vec<4, T, Q> operator|(vec<4, T, Q> const& v, vec<1, T, Q> const& v2); template - constexpr VectorT<4, T, Q> operator|(VectorT<1, T, Q> const& v1, VectorT<4, T, Q> const& v); + constexpr vec<4, T, Q> operator|(vec<1, T, Q> const& v1, vec<4, T, Q> const& v); template - constexpr VectorT<4, T, Q> operator|(VectorT<4, T, Q> const& v1, VectorT<4, T, Q> const& v2); + constexpr vec<4, T, Q> operator|(vec<4, T, Q> const& v1, vec<4, T, Q> const& v2); template - constexpr VectorT<4, T, Q> operator^(VectorT<4, T, Q> const& v, T scalar); + constexpr vec<4, T, Q> operator^(vec<4, T, Q> const& v, T scalar); template - constexpr VectorT<4, T, Q> operator^(T scalar, VectorT<4, T, Q> const& v); + constexpr vec<4, T, Q> operator^(T scalar, vec<4, T, Q> const& v); template - constexpr VectorT<4, T, Q> operator^(VectorT<4, T, Q> const& v, VectorT<1, T, Q> const& v2); + constexpr vec<4, T, Q> operator^(vec<4, T, Q> const& v, vec<1, T, Q> const& v2); template - constexpr VectorT<4, T, Q> operator^(VectorT<1, T, Q> const& v1, VectorT<4, T, Q> const& v); + constexpr vec<4, T, Q> operator^(vec<1, T, Q> const& v1, vec<4, T, Q> const& v); template - constexpr VectorT<4, T, Q> operator^(VectorT<4, T, Q> const& v1, VectorT<4, T, Q> const& v2); + constexpr vec<4, T, Q> operator^(vec<4, T, Q> const& v1, vec<4, T, Q> const& v2); template - constexpr VectorT<4, T, Q> operator<<(VectorT<4, T, Q> const& v, T scalar); + constexpr vec<4, T, Q> operator<<(vec<4, T, Q> const& v, T scalar); template - constexpr VectorT<4, T, Q> operator<<(T scalar, VectorT<4, T, Q> const& v); + constexpr vec<4, T, Q> operator<<(T scalar, vec<4, T, Q> const& v); template - constexpr VectorT<4, T, Q> operator<<(VectorT<4, T, Q> const& v, VectorT<1, T, Q> const& v2); + constexpr vec<4, T, Q> operator<<(vec<4, T, Q> const& v, vec<1, T, Q> const& v2); template - constexpr VectorT<4, T, Q> operator<<(VectorT<1, T, Q> const& v1, VectorT<4, T, Q> const& v); + constexpr vec<4, T, Q> operator<<(vec<1, T, Q> const& v1, vec<4, T, Q> const& v); template - constexpr VectorT<4, T, Q> operator<<(VectorT<4, T, Q> const& v1, VectorT<4, T, Q> const& v2); + constexpr vec<4, T, Q> operator<<(vec<4, T, Q> const& v1, vec<4, T, Q> const& v2); template - constexpr VectorT<4, T, Q> operator>>(VectorT<4, T, Q> const& v, T scalar); + constexpr vec<4, T, Q> operator>>(vec<4, T, Q> const& v, T scalar); template - constexpr VectorT<4, T, Q> operator>>(T scalar, VectorT<4, T, Q> const& v); + constexpr vec<4, T, Q> operator>>(T scalar, vec<4, T, Q> const& v); template - constexpr VectorT<4, T, Q> operator>>(VectorT<4, T, Q> const& v, VectorT<1, T, Q> const& v2); + constexpr vec<4, T, Q> operator>>(vec<4, T, Q> const& v, vec<1, T, Q> const& v2); template - constexpr VectorT<4, T, Q> operator>>(VectorT<1, T, Q> const& v1, VectorT<4, T, Q> const& v); + constexpr vec<4, T, Q> operator>>(vec<1, T, Q> const& v1, vec<4, T, Q> const& v); template - constexpr VectorT<4, T, Q> operator>>(VectorT<4, T, Q> const& v1, VectorT<4, T, Q> const& v2); + constexpr vec<4, T, Q> operator>>(vec<4, T, Q> const& v1, vec<4, T, Q> const& v2); template - constexpr VectorT<4, T, Q> operator~(VectorT<4, T, Q> const& v); + constexpr vec<4, T, Q> operator~(vec<4, T, Q> const& v); /// Conditional Binary Operators template - constexpr bool operator==(VectorT<4, T, Q> const& v1, VectorT<4, T, Q> const& v2); + constexpr bool operator==(vec<4, T, Q> const& v1, vec<4, T, Q> const& v2); template - constexpr bool operator!=(VectorT<4, T, Q> const& v1, VectorT<4, T, Q> const& v2); + constexpr bool operator!=(vec<4, T, Q> const& v1, vec<4, T, Q> const& v2); template - constexpr bool operator&&(VectorT<4, bool, Q> const& v1, VectorT<4, bool, Q> const& v2); + constexpr bool operator&&(vec<4, bool, Q> const& v1, vec<4, bool, Q> const& v2); template - constexpr bool operator||(VectorT<4, bool, Q> const& v1, VectorT<4, bool, Q> const& v2); + constexpr bool operator||(vec<4, bool, Q> const& v1, vec<4, bool, Q> const& v2); } // namespace mim diff --git a/include/mim/detail/type/type_vector4.inl b/include/mim/detail/type/type_vector4.inl index a0f882f..b172543 100644 --- a/include/mim/detail/type/type_vector4.inl +++ b/include/mim/detail/type/type_vector4.inl @@ -6,7 +6,7 @@ namespace mim { template - constexpr T& VectorT<4, T, Q>::operator[](size_type i) + constexpr T& vec<4, T, Q>::operator[](size_type i) { switch (i) { default: @@ -18,7 +18,7 @@ namespace mim } template - constexpr T const& VectorT<4, T, Q>::operator[](size_type i) const + constexpr T const& vec<4, T, Q>::operator[](size_type i) const { switch (i) { default: @@ -32,22 +32,22 @@ namespace mim /// Constructors template - constexpr VectorT<4, T, Q>::VectorT() : x(0), y(0), z(0), w(0) + constexpr vec<4, T, Q>::vec() : x(0), y(0), z(0), w(0) { } template - constexpr VectorT<4, T, Q>::VectorT(T _x, T _y, T _z, T _w) : x(_x), y(_y), z(_z), w(_w) + constexpr vec<4, T, Q>::vec(T _x, T _y, T _z, T _w) : x(_x), y(_y), z(_z), w(_w) { } template - constexpr VectorT<4, T, Q>::VectorT(VectorT<4, T, Q> const& v) : x(v.x), y(v.y), z(v.z), w(v.w) + constexpr vec<4, T, Q>::vec(vec<4, T, Q> const& v) : x(v.x), y(v.y), z(v.z), w(v.w) { } template - constexpr VectorT<4, T, Q>::VectorT(T scalar) : x(scalar), y(scalar), z(scalar), w(scalar) + constexpr vec<4, T, Q>::vec(T scalar) : x(scalar), y(scalar), z(scalar), w(scalar) { } @@ -55,243 +55,243 @@ namespace mim template template - constexpr VectorT<4, T, Q>::VectorT(VectorT<4, T, P> const& v) : x(v.x), y(v.y), z(v.z), w(v.w) + constexpr vec<4, T, Q>::vec(vec<4, T, P> const& v) : x(v.x), y(v.y), z(v.z), w(v.w) { } template template - constexpr VectorT<4, T, Q>::VectorT(VectorT<1, U, P> const& v) + constexpr vec<4, T, Q>::vec(vec<1, U, P> const& v) : x(static_cast(v.x)), y(static_cast(v.x)), z(static_cast(v.x)), w(static_cast(v.x)) { } template template - constexpr VectorT<4, T, Q>::VectorT(X _x, Y _y, Z _z, W _w) : x(static_cast(_x)), y(static_cast(_y)), z(static_cast(_z)), w(static_cast(_w)) + constexpr vec<4, T, Q>::vec(X _x, Y _y, Z _z, W _w) : x(static_cast(_x)), y(static_cast(_y)), z(static_cast(_z)), w(static_cast(_w)) { } template template - constexpr VectorT<4, T, Q>::VectorT(VectorT<1, X, Q> const& _x, Y _y, Z _z, W _w) + constexpr vec<4, T, Q>::vec(vec<1, X, Q> const& _x, Y _y, Z _z, W _w) : x(static_cast(_x.x)), y(static_cast(_y)), z(static_cast(_z)), w(static_cast(_w)) { } template template - constexpr VectorT<4, T, Q>::VectorT(X _x, VectorT<1, Y, Q> const& _y, Z _z, W _w) + constexpr vec<4, T, Q>::vec(X _x, vec<1, Y, Q> const& _y, Z _z, W _w) : x(static_cast(_x)), y(static_cast(_y.x)), z(static_cast(_z)), w(static_cast(_w)) { } template template - constexpr VectorT<4, T, Q>::VectorT(VectorT<1, X, Q> const& _x, VectorT<1, Y, Q> const& _y, Z _z, W _w) + constexpr vec<4, T, Q>::vec(vec<1, X, Q> const& _x, vec<1, Y, Q> const& _y, Z _z, W _w) : x(static_cast(_x.x)), y(static_cast(_y.x)), z(static_cast(_z)), w(static_cast(_w)) { } template template - constexpr VectorT<4, T, Q>::VectorT(X _x, Y _y, VectorT<1, Z, Q> const& _z, W _w) + constexpr vec<4, T, Q>::vec(X _x, Y _y, vec<1, Z, Q> const& _z, W _w) : x(static_cast(_x)), y(static_cast(_y)), z(static_cast(_z.x)), w(static_cast(_w)) { } template template - constexpr VectorT<4, T, Q>::VectorT(VectorT<1, X, Q> const& _x, Y _y, VectorT<1, Z, Q> const& _z, W _w) + constexpr vec<4, T, Q>::vec(vec<1, X, Q> const& _x, Y _y, vec<1, Z, Q> const& _z, W _w) : x(static_cast(_x.x)), y(static_cast(_y)), z(static_cast(_z.x)), w(static_cast(_w)) { } template template - constexpr VectorT<4, T, Q>::VectorT(X _x, VectorT<1, Y, Q> const& _y, VectorT<1, Z, Q> const& _z, W _w) + constexpr vec<4, T, Q>::vec(X _x, vec<1, Y, Q> const& _y, vec<1, Z, Q> const& _z, W _w) : x(static_cast(_x)), y(static_cast(_y.x)), z(static_cast(_z.x)), w(static_cast(_w)) { } template template - constexpr VectorT<4, T, Q>::VectorT(VectorT<1, X, Q> const& _x, VectorT<1, Y, Q> const& _y, VectorT<1, Z, Q> const& _z, W _w) + constexpr vec<4, T, Q>::vec(vec<1, X, Q> const& _x, vec<1, Y, Q> const& _y, vec<1, Z, Q> const& _z, W _w) : x(static_cast(_x.x)), y(static_cast(_y.x)), z(static_cast(_z.x)), w(static_cast(_w)) { } template template - constexpr VectorT<4, T, Q>::VectorT(VectorT<1, X, Q> const& _x, Y _y, Z _z, VectorT<1, W, Q> const& _w) + constexpr vec<4, T, Q>::vec(vec<1, X, Q> const& _x, Y _y, Z _z, vec<1, W, Q> const& _w) : x(static_cast(_x.x)), y(static_cast(_y)), z(static_cast(_z)), w(static_cast(_w.x)) { } template template - constexpr VectorT<4, T, Q>::VectorT(X _x, VectorT<1, Y, Q> const& _y, Z _z, VectorT<1, W, Q> const& _w) + constexpr vec<4, T, Q>::vec(X _x, vec<1, Y, Q> const& _y, Z _z, vec<1, W, Q> const& _w) : x(static_cast(_x)), y(static_cast(_y.x)), z(static_cast(_z)), w(static_cast(_w.x)) { } template template - constexpr VectorT<4, T, Q>::VectorT(VectorT<1, X, Q> const& _x, VectorT<1, Y, Q> const& _y, Z _z, VectorT<1, W, Q> const& _w) + constexpr vec<4, T, Q>::vec(vec<1, X, Q> const& _x, vec<1, Y, Q> const& _y, Z _z, vec<1, W, Q> const& _w) : x(static_cast(_x.x)), y(static_cast(_y.x)), z(static_cast(_z)), w(static_cast(_w.x)) { } template template - constexpr VectorT<4, T, Q>::VectorT(X _x, Y _y, VectorT<1, Z, Q> const& _z, VectorT<1, W, Q> const& _w) + constexpr vec<4, T, Q>::vec(X _x, Y _y, vec<1, Z, Q> const& _z, vec<1, W, Q> const& _w) : x(static_cast(_x)), y(static_cast(_y)), z(static_cast(_z.x)), w(static_cast(_w.x)) { } template template - constexpr VectorT<4, T, Q>::VectorT(VectorT<1, X, Q> const& _x, Y _y, VectorT<1, Z, Q> const& _z, VectorT<1, W, Q> const& _w) + constexpr vec<4, T, Q>::vec(vec<1, X, Q> const& _x, Y _y, vec<1, Z, Q> const& _z, vec<1, W, Q> const& _w) : x(static_cast(_x.x)), y(static_cast(_y)), z(static_cast(_z.x)), w(static_cast(_w.x)) { } template template - constexpr VectorT<4, T, Q>::VectorT(X _x, VectorT<1, Y, Q> const& _y, VectorT<1, Z, Q> const& _z, VectorT<1, W, Q> const& _w) + constexpr vec<4, T, Q>::vec(X _x, vec<1, Y, Q> const& _y, vec<1, Z, Q> const& _z, vec<1, W, Q> const& _w) : x(static_cast(_x)), y(static_cast(_y.x)), z(static_cast(_z.x)), w(static_cast(_w.x)) { } template template - constexpr VectorT<4, T, Q>::VectorT(VectorT<1, X, Q> const& _x, VectorT<1, Y, Q> const& _y, VectorT<1, Z, Q> const& _z, VectorT<1, W, Q> const& _w) + constexpr vec<4, T, Q>::vec(vec<1, X, Q> const& _x, vec<1, Y, Q> const& _y, vec<1, Z, Q> const& _z, vec<1, W, Q> const& _w) : x(static_cast(_x.x)), y(static_cast(_y.x)), z(static_cast(_z.x)), w(static_cast(_w.x)) { } template template - constexpr VectorT<4, T, Q>::VectorT(VectorT<2, A, P> const& _xy, B _z, C _w) + constexpr vec<4, T, Q>::vec(vec<2, A, P> const& _xy, B _z, C _w) : x(static_cast(_xy.x)), y(static_cast(_xy.y)), z(static_cast(_z)), w(static_cast(_w)) { } template template - constexpr VectorT<4, T, Q>::VectorT(VectorT<2, A, P> const& _xy, VectorT<1, B, P> const& _z, C _w) + constexpr vec<4, T, Q>::vec(vec<2, A, P> const& _xy, vec<1, B, P> const& _z, C _w) : x(static_cast(_xy.x)), y(static_cast(_xy.y)), z(static_cast(_z.x)), w(static_cast(_w)) { } template template - constexpr VectorT<4, T, Q>::VectorT(VectorT<2, A, P> const& _xy, B _z, VectorT<1, C, P> const& _w) + constexpr vec<4, T, Q>::vec(vec<2, A, P> const& _xy, B _z, vec<1, C, P> const& _w) : x(static_cast(_xy.x)), y(static_cast(_xy.y)), z(static_cast(_z)), w(static_cast(_w.x)) { } template template - constexpr VectorT<4, T, Q>::VectorT(VectorT<2, A, P> const& _xy, VectorT<1, B, P> const& _z, VectorT<1, C, P> const& _w) + constexpr vec<4, T, Q>::vec(vec<2, A, P> const& _xy, vec<1, B, P> const& _z, vec<1, C, P> const& _w) : x(static_cast(_xy.x)), y(static_cast(_xy.y)), z(static_cast(_z.x)), w(static_cast(_w.x)) { } template template - constexpr VectorT<4, T, Q>::VectorT(A _x, VectorT<2, B, P> const& _yz, C _w) + constexpr vec<4, T, Q>::vec(A _x, vec<2, B, P> const& _yz, C _w) : x(static_cast(_x)), y(static_cast(_yz.x)), z(static_cast(_yz.y)), w(static_cast(_w)) { } template template - constexpr VectorT<4, T, Q>::VectorT(VectorT<1, A, P> const& _x, VectorT<2, B, P> const& _yz, C _w) + constexpr vec<4, T, Q>::vec(vec<1, A, P> const& _x, vec<2, B, P> const& _yz, C _w) : x(static_cast(_x.x)), y(static_cast(_yz.x)), z(static_cast(_yz.y)), w(static_cast(_w)) { } template template - constexpr VectorT<4, T, Q>::VectorT(A _x, VectorT<2, B, P> const& _yz, VectorT<1, C, P> const& _w) + constexpr vec<4, T, Q>::vec(A _x, vec<2, B, P> const& _yz, vec<1, C, P> const& _w) : x(static_cast(_x)), y(static_cast(_yz.x)), z(static_cast(_yz.y)), w(static_cast(_w.x)) { } template template - constexpr VectorT<4, T, Q>::VectorT(VectorT<1, A, P> const& _x, VectorT<2, B, P> const& _yz, VectorT<1, C, P> const& _w) + constexpr vec<4, T, Q>::vec(vec<1, A, P> const& _x, vec<2, B, P> const& _yz, vec<1, C, P> const& _w) : x(static_cast(_x.x)), y(static_cast(_yz.x)), z(static_cast(_yz.y)), w(static_cast(_w.x)) { } template template - constexpr VectorT<4, T, Q>::VectorT(A _x, B _y, VectorT<2, C, P> const& _zw) + constexpr vec<4, T, Q>::vec(A _x, B _y, vec<2, C, P> const& _zw) : x(static_cast(_x)), y(static_cast(_y)), z(static_cast(_zw.x)), w(static_cast(_zw.y)) { } template template - constexpr VectorT<4, T, Q>::VectorT(VectorT<1, A, P> const& _x, B _y, VectorT<2, C, P> const& _zw) + constexpr vec<4, T, Q>::vec(vec<1, A, P> const& _x, B _y, vec<2, C, P> const& _zw) : x(static_cast(_x.x)), y(static_cast(_y)), z(static_cast(_zw.x)), w(static_cast(_zw.y)) { } template template - constexpr VectorT<4, T, Q>::VectorT(A _x, VectorT<1, B, P> const& _y, VectorT<2, C, P> const& _zw) + constexpr vec<4, T, Q>::vec(A _x, vec<1, B, P> const& _y, vec<2, C, P> const& _zw) : x(static_cast(_x)), y(static_cast(_y.x)), z(static_cast(_zw.x)), w(static_cast(_zw.y)) { } template template - constexpr VectorT<4, T, Q>::VectorT(VectorT<1, A, P> const& _x, VectorT<1, B, P> const& _y, VectorT<2, C, P> const& _zw) + constexpr vec<4, T, Q>::vec(vec<1, A, P> const& _x, vec<1, B, P> const& _y, vec<2, C, P> const& _zw) : x(static_cast(_x.x)), y(static_cast(_y.x)), z(static_cast(_zw.x)), w(static_cast(_zw.y)) { } template template - constexpr VectorT<4, T, Q>::VectorT(VectorT<3, A, P> const& _xyz, B _w) + constexpr vec<4, T, Q>::vec(vec<3, A, P> const& _xyz, B _w) : x(static_cast(_xyz.x)), y(static_cast(_xyz.y)), z(static_cast(_xyz.z)), w(static_cast(_w)) { } template template - constexpr VectorT<4, T, Q>::VectorT(VectorT<3, A, P> const& _xyz, VectorT<1, B, P> const& _w) + constexpr vec<4, T, Q>::vec(vec<3, A, P> const& _xyz, vec<1, B, P> const& _w) : x(static_cast(_xyz.x)), y(static_cast(_xyz.y)), z(static_cast(_xyz.z)), w(static_cast(_w.x)) { } template template - constexpr VectorT<4, T, Q>::VectorT(A _x, VectorT<3, B, P> const& _yzw) + constexpr vec<4, T, Q>::vec(A _x, vec<3, B, P> const& _yzw) : x(static_cast(_x)), y(static_cast(_yzw.x)), z(static_cast(_yzw.y)), w(static_cast(_yzw.z)) { } template template - constexpr VectorT<4, T, Q>::VectorT(VectorT<1, A, P> const& _x, VectorT<3, B, P> const& _yzw) + constexpr vec<4, T, Q>::vec(vec<1, A, P> const& _x, vec<3, B, P> const& _yzw) : x(static_cast(_x.x)), y(static_cast(_yzw.x)), z(static_cast(_yzw.y)), w(static_cast(_yzw.z)) { } template template - constexpr VectorT<4, T, Q>::VectorT(VectorT<2, A, P> const& _xy, VectorT<2, B, P> const& _zw) + constexpr vec<4, T, Q>::vec(vec<2, A, P> const& _xy, vec<2, B, P> const& _zw) : x(static_cast(_xy.x)), y(static_cast(_xy.y)), z(static_cast(_zw.x)), w(static_cast(_zw.y)) { } template template - constexpr VectorT<4, T, Q>::VectorT(VectorT<4, U, P> const& v) + constexpr vec<4, T, Q>::vec(vec<4, U, P> const& v) : x(static_cast(v.x)), y(static_cast(v.y)), z(static_cast(v.z)), w(static_cast(v.w)) { } @@ -299,7 +299,7 @@ namespace mim /// Assignment operators template - constexpr VectorT<4, T, Q>& VectorT<4, T, Q>::operator=(VectorT<4, T, Q> const& v) + constexpr vec<4, T, Q>& vec<4, T, Q>::operator=(vec<4, T, Q> const& v) { this->x = v.x; this->y = v.y; @@ -310,7 +310,7 @@ namespace mim template template - constexpr VectorT<4, T, Q>& VectorT<4, T, Q>::operator=(VectorT<4, U, Q> const& v) + constexpr vec<4, T, Q>& vec<4, T, Q>::operator=(vec<4, U, Q> const& v) { this->x = static_cast(v.x); this->y = static_cast(v.y); @@ -321,9 +321,9 @@ namespace mim template template - constexpr VectorT<4, T, Q>& VectorT<4, T, Q>::operator+=(U scalar) + constexpr vec<4, T, Q>& vec<4, T, Q>::operator+=(U scalar) { - return (*this = detail::Add::value>::compute(*this, VectorT<4, T, Q>(scalar))); + return (*this = detail::Add::value>::compute(*this, vec<4, T, Q>(scalar))); } /* @@ -331,23 +331,23 @@ namespace mim */ template template - constexpr VectorT<4, T, Q>& VectorT<4, T, Q>::operator+=(VectorT<1, U, Q> const& v) + constexpr vec<4, T, Q>& vec<4, T, Q>::operator+=(vec<1, U, Q> const& v) { - return (*this = detail::Add::value>::compute(*this, VectorT<4, T, Q>(v.x))); + return (*this = detail::Add::value>::compute(*this, vec<4, T, Q>(v.x))); } template template - constexpr VectorT<4, T, Q>& VectorT<4, T, Q>::operator+=(VectorT<4, U, Q> const& v) + constexpr vec<4, T, Q>& vec<4, T, Q>::operator+=(vec<4, U, Q> const& v) { - return (*this = detail::Add::value>::compute(*this, VectorT<4, T, Q>(v))); + return (*this = detail::Add::value>::compute(*this, vec<4, T, Q>(v))); } template template - constexpr VectorT<4, T, Q>& VectorT<4, T, Q>::operator-=(U scalar) + constexpr vec<4, T, Q>& vec<4, T, Q>::operator-=(U scalar) { - return (*this = detail::Sub::value>::compute(*this, VectorT<4, T, Q>(scalar))); + return (*this = detail::Sub::value>::compute(*this, vec<4, T, Q>(scalar))); } /* @@ -355,23 +355,23 @@ namespace mim */ template template - constexpr VectorT<4, T, Q>& VectorT<4, T, Q>::operator-=(VectorT<1, U, Q> const& v) + constexpr vec<4, T, Q>& vec<4, T, Q>::operator-=(vec<1, U, Q> const& v) { - return (*this = detail::Sub::value>::compute(*this, VectorT<4, T, Q>(v.x))); + return (*this = detail::Sub::value>::compute(*this, vec<4, T, Q>(v.x))); } template template - constexpr VectorT<4, T, Q>& VectorT<4, T, Q>::operator-=(VectorT<4, U, Q> const& v) + constexpr vec<4, T, Q>& vec<4, T, Q>::operator-=(vec<4, U, Q> const& v) { - return (*this = detail::Sub::value>::compute(*this, VectorT<4, T, Q>(v))); + return (*this = detail::Sub::value>::compute(*this, vec<4, T, Q>(v))); } template template - constexpr VectorT<4, T, Q>& VectorT<4, T, Q>::operator*=(U scalar) + constexpr vec<4, T, Q>& vec<4, T, Q>::operator*=(U scalar) { - return (*this = detail::Mul::value>::compute(*this, VectorT<4, T, Q>(scalar))); + return (*this = detail::Mul::value>::compute(*this, vec<4, T, Q>(scalar))); } /* @@ -379,23 +379,23 @@ namespace mim */ template template - constexpr VectorT<4, T, Q>& VectorT<4, T, Q>::operator*=(VectorT<1, U, Q> const& v) + constexpr vec<4, T, Q>& vec<4, T, Q>::operator*=(vec<1, U, Q> const& v) { - return (*this = detail::Mul::value>::compute(*this, VectorT<4, T, Q>(v.x))); + return (*this = detail::Mul::value>::compute(*this, vec<4, T, Q>(v.x))); } template template - constexpr VectorT<4, T, Q>& VectorT<4, T, Q>::operator*=(VectorT<4, U, Q> const& v) + constexpr vec<4, T, Q>& vec<4, T, Q>::operator*=(vec<4, U, Q> const& v) { - return (*this = detail::Mul::value>::compute(*this, VectorT<4, T, Q>(v))); + return (*this = detail::Mul::value>::compute(*this, vec<4, T, Q>(v))); } template template - constexpr VectorT<4, T, Q>& VectorT<4, T, Q>::operator/=(U scalar) + constexpr vec<4, T, Q>& vec<4, T, Q>::operator/=(U scalar) { - return (*this = detail::Div::value>::compute(*this, VectorT<4, T, Q>(scalar))); + return (*this = detail::Div::value>::compute(*this, vec<4, T, Q>(scalar))); } /* @@ -403,23 +403,23 @@ namespace mim */ template template - constexpr VectorT<4, T, Q>& VectorT<4, T, Q>::operator/=(VectorT<1, U, Q> const& v) + constexpr vec<4, T, Q>& vec<4, T, Q>::operator/=(vec<1, U, Q> const& v) { - return (*this = detail::Div::value>::compute(*this, VectorT<4, T, Q>(v.x))); + return (*this = detail::Div::value>::compute(*this, vec<4, T, Q>(v.x))); } template template - constexpr VectorT<4, T, Q>& VectorT<4, T, Q>::operator/=(VectorT<4, U, Q> const& v) + constexpr vec<4, T, Q>& vec<4, T, Q>::operator/=(vec<4, U, Q> const& v) { - return (*this = detail::Div::value>::compute(*this, VectorT<4, T, Q>(v))); + return (*this = detail::Div::value>::compute(*this, vec<4, T, Q>(v))); } template template - constexpr VectorT<4, T, Q>& VectorT<4, T, Q>::operator%=(U scalar) + constexpr vec<4, T, Q>& vec<4, T, Q>::operator%=(U scalar) { - return (*this = detail::Mod::value>::compute(*this, VectorT<4, T, Q>(scalar))); + return (*this = detail::Mod::value>::compute(*this, vec<4, T, Q>(scalar))); } /* @@ -427,22 +427,22 @@ namespace mim */ template template - constexpr VectorT<4, T, Q>& VectorT<4, T, Q>::operator%=(VectorT<1, U, Q> const& v) + constexpr vec<4, T, Q>& vec<4, T, Q>::operator%=(vec<1, U, Q> const& v) { - return (*this = detail::Mod::value>::compute(*this, VectorT<4, T, Q>(v))); + return (*this = detail::Mod::value>::compute(*this, vec<4, T, Q>(v))); } template template - constexpr VectorT<4, T, Q>& VectorT<4, T, Q>::operator%=(VectorT<4, U, Q> const& v) + constexpr vec<4, T, Q>& vec<4, T, Q>::operator%=(vec<4, U, Q> const& v) { - return (*this = detail::Mod::value>::compute(*this, VectorT<4, T, Q>(v))); + return (*this = detail::Mod::value>::compute(*this, vec<4, T, Q>(v))); } /// Increment and Decrement Operators template - constexpr VectorT<4, T, Q>& VectorT<4, T, Q>::operator++() + constexpr vec<4, T, Q>& vec<4, T, Q>::operator++() { ++this->x; ++this->y; @@ -452,7 +452,7 @@ namespace mim } template - constexpr VectorT<4, T, Q>& VectorT<4, T, Q>::operator--() + constexpr vec<4, T, Q>& vec<4, T, Q>::operator--() { --this->x; --this->y; @@ -462,17 +462,17 @@ namespace mim } template - constexpr const VectorT<4, T, Q> VectorT<4, T, Q>::operator++(int) + constexpr const vec<4, T, Q> vec<4, T, Q>::operator++(int) { - VectorT<4, T, Q> result(*this); + vec<4, T, Q> result(*this); ++*this; return result; } template - constexpr const VectorT<4, T, Q> VectorT<4, T, Q>::operator--(int) + constexpr const vec<4, T, Q> vec<4, T, Q>::operator--(int) { - VectorT<4, T, Q> result(*this); + vec<4, T, Q> result(*this); --*this; return result; } @@ -481,10 +481,10 @@ namespace mim template template - constexpr VectorT<4, T, Q>& VectorT<4, T, Q>::operator&=(U scalar) + constexpr vec<4, T, Q>& vec<4, T, Q>::operator&=(U scalar) { return (*this = detail::BitwiseAnd::is_iec559, sizeof(T) * 8, detail::IsAligned::value>::compute( - *this, VectorT<4, T, Q>(scalar))); + *this, vec<4, T, Q>(scalar))); } /* @@ -492,26 +492,26 @@ namespace mim */ template template - constexpr VectorT<4, T, Q>& VectorT<4, T, Q>::operator&=(VectorT<1, U, Q> const& v) + constexpr vec<4, T, Q>& vec<4, T, Q>::operator&=(vec<1, U, Q> const& v) { return (*this = detail::BitwiseAnd::is_iec559, sizeof(T) * 8, detail::IsAligned::value>::compute(*this, - VectorT<4, T, Q>(v))); + vec<4, T, Q>(v))); } template template - constexpr VectorT<4, T, Q>& VectorT<4, T, Q>::operator&=(VectorT<4, U, Q> const& v) + constexpr vec<4, T, Q>& vec<4, T, Q>::operator&=(vec<4, U, Q> const& v) { return (*this = detail::BitwiseAnd::is_iec559, sizeof(T) * 8, detail::IsAligned::value>::compute(*this, - VectorT<4, T, Q>(v))); + vec<4, T, Q>(v))); } template template - constexpr VectorT<4, T, Q>& VectorT<4, T, Q>::operator|=(U scalar) + constexpr vec<4, T, Q>& vec<4, T, Q>::operator|=(U scalar) { return (*this = detail::BitwiseOr::is_iec559, sizeof(T) * 8, detail::IsAligned::value>::compute( - *this, VectorT<4, T, Q>(scalar))); + *this, vec<4, T, Q>(scalar))); } /* @@ -519,26 +519,26 @@ namespace mim */ template template - constexpr VectorT<4, T, Q>& VectorT<4, T, Q>::operator|=(VectorT<1, U, Q> const& v) + constexpr vec<4, T, Q>& vec<4, T, Q>::operator|=(vec<1, U, Q> const& v) { return (*this = detail::BitwiseOr::is_iec559, sizeof(T) * 8, detail::IsAligned::value>::compute(*this, - VectorT<4, T, Q>(v))); + vec<4, T, Q>(v))); } template template - constexpr VectorT<4, T, Q>& VectorT<4, T, Q>::operator|=(VectorT<4, U, Q> const& v) + constexpr vec<4, T, Q>& vec<4, T, Q>::operator|=(vec<4, U, Q> const& v) { return (*this = detail::BitwiseOr::is_iec559, sizeof(T) * 8, detail::IsAligned::value>::compute(*this, - VectorT<4, T, Q>(v))); + vec<4, T, Q>(v))); } template template - constexpr VectorT<4, T, Q>& VectorT<4, T, Q>::operator^=(U scalar) + constexpr vec<4, T, Q>& vec<4, T, Q>::operator^=(U scalar) { return (*this = - detail::Xor::is_iec559, sizeof(T) * 8, detail::IsAligned::value>::compute(*this, VectorT<4, T, Q>(scalar))); + detail::Xor::is_iec559, sizeof(T) * 8, detail::IsAligned::value>::compute(*this, vec<4, T, Q>(scalar))); } /* @@ -546,24 +546,24 @@ namespace mim */ template template - constexpr VectorT<4, T, Q>& VectorT<4, T, Q>::operator^=(VectorT<1, U, Q> const& v) + constexpr vec<4, T, Q>& vec<4, T, Q>::operator^=(vec<1, U, Q> const& v) { - return (*this = detail::Xor::is_iec559, sizeof(T) * 8, detail::IsAligned::value>::compute(*this, VectorT<4, T, Q>(v))); + return (*this = detail::Xor::is_iec559, sizeof(T) * 8, detail::IsAligned::value>::compute(*this, vec<4, T, Q>(v))); } template template - constexpr VectorT<4, T, Q>& VectorT<4, T, Q>::operator^=(VectorT<4, U, Q> const& v) + constexpr vec<4, T, Q>& vec<4, T, Q>::operator^=(vec<4, U, Q> const& v) { - return (*this = detail::Xor::is_iec559, sizeof(T) * 8, detail::IsAligned::value>::compute(*this, VectorT<4, T, Q>(v))); + return (*this = detail::Xor::is_iec559, sizeof(T) * 8, detail::IsAligned::value>::compute(*this, vec<4, T, Q>(v))); } template template - constexpr VectorT<4, T, Q>& VectorT<4, T, Q>::operator<<=(U scalar) + constexpr vec<4, T, Q>& vec<4, T, Q>::operator<<=(U scalar) { return (*this = detail::ShiftLeft::is_iec559, sizeof(T) * 8, detail::IsAligned::value>::compute( - *this, VectorT<4, T, Q>(scalar))); + *this, vec<4, T, Q>(scalar))); } /* @@ -571,26 +571,26 @@ namespace mim */ template template - constexpr VectorT<4, T, Q>& VectorT<4, T, Q>::operator<<=(VectorT<1, U, Q> const& v) + constexpr vec<4, T, Q>& vec<4, T, Q>::operator<<=(vec<1, U, Q> const& v) { return (*this = detail::ShiftLeft::is_iec559, sizeof(T) * 8, detail::IsAligned::value>::compute(*this, - VectorT<4, T, Q>(v))); + vec<4, T, Q>(v))); } template template - constexpr VectorT<4, T, Q>& VectorT<4, T, Q>::operator<<=(VectorT<4, U, Q> const& v) + constexpr vec<4, T, Q>& vec<4, T, Q>::operator<<=(vec<4, U, Q> const& v) { return (*this = detail::ShiftLeft::is_iec559, sizeof(T) * 8, detail::IsAligned::value>::compute(*this, - VectorT<4, T, Q>(v))); + vec<4, T, Q>(v))); } template template - constexpr VectorT<4, T, Q>& VectorT<4, T, Q>::operator>>=(U scalar) + constexpr vec<4, T, Q>& vec<4, T, Q>::operator>>=(U scalar) { return (*this = detail::ShiftRight::is_iec559, sizeof(T) * 8, detail::IsAligned::value>::compute( - *this, VectorT<4, T, Q>(scalar))); + *this, vec<4, T, Q>(scalar))); } /* @@ -598,400 +598,400 @@ namespace mim */ template template - constexpr VectorT<4, T, Q>& VectorT<4, T, Q>::operator>>=(VectorT<1, U, Q> const& v) + constexpr vec<4, T, Q>& vec<4, T, Q>::operator>>=(vec<1, U, Q> const& v) { return (*this = detail::ShiftRight::is_iec559, sizeof(T) * 8, detail::IsAligned::value>::compute(*this, - VectorT<4, T, Q>(v))); + vec<4, T, Q>(v))); } template template - constexpr VectorT<4, T, Q>& VectorT<4, T, Q>::operator>>=(VectorT<4, U, Q> const& v) + constexpr vec<4, T, Q>& vec<4, T, Q>::operator>>=(vec<4, U, Q> const& v) { return (*this = detail::ShiftRight::is_iec559, sizeof(T) * 8, detail::IsAligned::value>::compute(*this, - VectorT<4, T, Q>(v))); + vec<4, T, Q>(v))); } /// Unary Operators template - constexpr VectorT<4, T, Q> operator+(VectorT<4, T, Q> const& v) + constexpr vec<4, T, Q> operator+(vec<4, T, Q> const& v) { return v; } template - constexpr VectorT<4, T, Q> operator-(VectorT<4, T, Q> const& v) + constexpr vec<4, T, Q> operator-(vec<4, T, Q> const& v) { - return VectorT<4, T, Q>(0) -= v; + return vec<4, T, Q>(0) -= v; } /// Binary Operators template - constexpr VectorT<4, T, Q> operator+(VectorT<4, T, Q> const& v, T const& scalar) + constexpr vec<4, T, Q> operator+(vec<4, T, Q> const& v, T const& scalar) { - return VectorT<4, T, Q>(v) += scalar; + return vec<4, T, Q>(v) += scalar; } template - constexpr VectorT<4, T, Q> operator+(T scalar, VectorT<4, T, Q> const& v) + constexpr vec<4, T, Q> operator+(T scalar, vec<4, T, Q> const& v) { - return VectorT<4, T, Q>(v) += scalar; + return vec<4, T, Q>(v) += scalar; } /* * \note Vec1 is deliberately treated like a scalar to mimic shader languages. */ template - constexpr VectorT<4, T, Q> operator+(VectorT<4, T, Q> const& v1, VectorT<1, T, Q> const& v2) + constexpr vec<4, T, Q> operator+(vec<4, T, Q> const& v1, vec<1, T, Q> const& v2) { - return VectorT<4, T, Q>(v1) += v2; + return vec<4, T, Q>(v1) += v2; } /* * \note Vec1 is deliberately treated like a scalar to mimic shader languages. */ template - constexpr VectorT<4, T, Q> operator+(VectorT<1, T, Q> const& v1, VectorT<4, T, Q> const& v2) + constexpr vec<4, T, Q> operator+(vec<1, T, Q> const& v1, vec<4, T, Q> const& v2) { - return VectorT<4, T, Q>(v2) += v1; + return vec<4, T, Q>(v2) += v1; } template - constexpr VectorT<4, T, Q> operator+(VectorT<4, T, Q> const& v1, VectorT<4, T, Q> const& v2) + constexpr vec<4, T, Q> operator+(vec<4, T, Q> const& v1, vec<4, T, Q> const& v2) { - return VectorT<4, T, Q>(v1) += v2; + return vec<4, T, Q>(v1) += v2; } template - constexpr VectorT<4, T, Q> operator-(VectorT<4, T, Q> const& v, T const& scalar) + constexpr vec<4, T, Q> operator-(vec<4, T, Q> const& v, T const& scalar) { - return VectorT<4, T, Q>(v) -= scalar; + return vec<4, T, Q>(v) -= scalar; } template - constexpr VectorT<4, T, Q> operator-(T scalar, VectorT<4, T, Q> const& v) + constexpr vec<4, T, Q> operator-(T scalar, vec<4, T, Q> const& v) { - return VectorT<4, T, Q>(scalar) -= v; + return vec<4, T, Q>(scalar) -= v; } /* * \note Vec1 is deliberately treated like a scalar to mimic shader languages. */ template - constexpr VectorT<4, T, Q> operator-(VectorT<4, T, Q> const& v1, VectorT<1, T, Q> const& v2) + constexpr vec<4, T, Q> operator-(vec<4, T, Q> const& v1, vec<1, T, Q> const& v2) { - return VectorT<4, T, Q>(v1) -= v2; + return vec<4, T, Q>(v1) -= v2; } /* * \note Vec1 is deliberately treated like a scalar to mimic shader languages. */ template - constexpr VectorT<4, T, Q> operator-(VectorT<1, T, Q> const& v1, VectorT<4, T, Q> const& v2) + constexpr vec<4, T, Q> operator-(vec<1, T, Q> const& v1, vec<4, T, Q> const& v2) { - return VectorT<4, T, Q>(v1.x) -= v2; + return vec<4, T, Q>(v1.x) -= v2; } template - constexpr VectorT<4, T, Q> operator-(VectorT<4, T, Q> const& v1, VectorT<4, T, Q> const& v2) + constexpr vec<4, T, Q> operator-(vec<4, T, Q> const& v1, vec<4, T, Q> const& v2) { - return VectorT<4, T, Q>(v1) -= v2; + return vec<4, T, Q>(v1) -= v2; } template - constexpr VectorT<4, T, Q> operator*(VectorT<4, T, Q> const& v, T const& scalar) + constexpr vec<4, T, Q> operator*(vec<4, T, Q> const& v, T const& scalar) { - return VectorT<4, T, Q>(v) *= scalar; + return vec<4, T, Q>(v) *= scalar; } template - constexpr VectorT<4, T, Q> operator*(T scalar, VectorT<4, T, Q> const& v) + constexpr vec<4, T, Q> operator*(T scalar, vec<4, T, Q> const& v) { - return VectorT<4, T, Q>(v) *= scalar; + return vec<4, T, Q>(v) *= scalar; } /* * \note Vec1 is deliberately treated like a scalar to mimic shader languages. */ template - constexpr VectorT<4, T, Q> operator*(VectorT<4, T, Q> const& v1, VectorT<1, T, Q> const& v2) + constexpr vec<4, T, Q> operator*(vec<4, T, Q> const& v1, vec<1, T, Q> const& v2) { - return VectorT<4, T, Q>(v1) *= v2; + return vec<4, T, Q>(v1) *= v2; } /* * \note Vec1 is deliberately treated like a scalar to mimic shader languages. */ template - constexpr VectorT<4, T, Q> operator*(VectorT<1, T, Q> const& v1, VectorT<4, T, Q> const& v2) + constexpr vec<4, T, Q> operator*(vec<1, T, Q> const& v1, vec<4, T, Q> const& v2) { - return VectorT<4, T, Q>(v2) *= v1; + return vec<4, T, Q>(v2) *= v1; } template - constexpr VectorT<4, T, Q> operator*(VectorT<4, T, Q> const& v1, VectorT<4, T, Q> const& v2) + constexpr vec<4, T, Q> operator*(vec<4, T, Q> const& v1, vec<4, T, Q> const& v2) { - return VectorT<4, T, Q>(v1) *= v2; + return vec<4, T, Q>(v1) *= v2; } template - constexpr VectorT<4, T, Q> operator/(VectorT<4, T, Q> const& v, T const& scalar) + constexpr vec<4, T, Q> operator/(vec<4, T, Q> const& v, T const& scalar) { - return VectorT<4, T, Q>(v) /= scalar; + return vec<4, T, Q>(v) /= scalar; } template - constexpr VectorT<4, T, Q> operator/(T scalar, VectorT<4, T, Q> const& v) + constexpr vec<4, T, Q> operator/(T scalar, vec<4, T, Q> const& v) { - return VectorT<4, T, Q>(scalar) /= v; + return vec<4, T, Q>(scalar) /= v; } /* * \note Vec1 is deliberately treated like a scalar to mimic shader languages. */ template - constexpr VectorT<4, T, Q> operator/(VectorT<4, T, Q> const& v1, VectorT<1, T, Q> const& v2) + constexpr vec<4, T, Q> operator/(vec<4, T, Q> const& v1, vec<1, T, Q> const& v2) { - return VectorT<4, T, Q>(v1) /= v2; + return vec<4, T, Q>(v1) /= v2; } /* * \note Vec1 is deliberately treated like a scalar to mimic shader languages. */ template - constexpr VectorT<4, T, Q> operator/(VectorT<1, T, Q> const& v1, VectorT<4, T, Q> const& v2) + constexpr vec<4, T, Q> operator/(vec<1, T, Q> const& v1, vec<4, T, Q> const& v2) { - return VectorT<4, T, Q>(v1.x) /= v2; + return vec<4, T, Q>(v1.x) /= v2; } template - constexpr VectorT<4, T, Q> operator/(VectorT<4, T, Q> const& v1, VectorT<4, T, Q> const& v2) + constexpr vec<4, T, Q> operator/(vec<4, T, Q> const& v1, vec<4, T, Q> const& v2) { - return VectorT<4, T, Q>(v1) /= v2; + return vec<4, T, Q>(v1) /= v2; } template - constexpr VectorT<4, T, Q> operator%(VectorT<4, T, Q> const& v, T scalar) + constexpr vec<4, T, Q> operator%(vec<4, T, Q> const& v, T scalar) { - return VectorT<4, T, Q>(v) %= scalar; + return vec<4, T, Q>(v) %= scalar; } template - constexpr VectorT<4, T, Q> operator%(T scalar, VectorT<4, T, Q> const& v) + constexpr vec<4, T, Q> operator%(T scalar, vec<4, T, Q> const& v) { - return VectorT<4, T, Q>(scalar) %= v; + return vec<4, T, Q>(scalar) %= v; } /* * \note Vec1 is deliberately treated like a scalar to mimic shader languages. */ template - constexpr VectorT<4, T, Q> operator%(VectorT<4, T, Q> const& v1, VectorT<1, T, Q> const& v2) + constexpr vec<4, T, Q> operator%(vec<4, T, Q> const& v1, vec<1, T, Q> const& v2) { - return VectorT<4, T, Q>(v1) %= v2.x; + return vec<4, T, Q>(v1) %= v2.x; } /* * \note Vec1 is deliberately treated like a scalar to mimic shader languages. */ template - constexpr VectorT<4, T, Q> operator%(VectorT<1, T, Q> const& scalar, VectorT<4, T, Q> const& v) + constexpr vec<4, T, Q> operator%(vec<1, T, Q> const& scalar, vec<4, T, Q> const& v) { - return VectorT<4, T, Q>(scalar.x) %= v; + return vec<4, T, Q>(scalar.x) %= v; } template - constexpr VectorT<4, T, Q> operator%(VectorT<4, T, Q> const& v1, VectorT<4, T, Q> const& v2) + constexpr vec<4, T, Q> operator%(vec<4, T, Q> const& v1, vec<4, T, Q> const& v2) { - return VectorT<4, T, Q>(v1) %= v2; + return vec<4, T, Q>(v1) %= v2; } /// Bitwise Binary Operators template - constexpr VectorT<4, T, Q> operator&(VectorT<4, T, Q> const& v, T scalar) + constexpr vec<4, T, Q> operator&(vec<4, T, Q> const& v, T scalar) { - return VectorT<4, T, Q>(v) &= scalar; + return vec<4, T, Q>(v) &= scalar; } template - constexpr VectorT<4, T, Q> operator&(T scalar, VectorT<4, T, Q> const& v) + constexpr vec<4, T, Q> operator&(T scalar, vec<4, T, Q> const& v) { - return VectorT<4, T, Q>(scalar) &= v; + return vec<4, T, Q>(scalar) &= v; } /* * \note Vec1 is deliberately treated like a scalar to mimic shader languages. */ template - constexpr VectorT<4, T, Q> operator&(VectorT<4, T, Q> const& v, VectorT<1, T, Q> const& scalar) + constexpr vec<4, T, Q> operator&(vec<4, T, Q> const& v, vec<1, T, Q> const& scalar) { - return VectorT<4, T, Q>(v) &= scalar; + return vec<4, T, Q>(v) &= scalar; } /* * \note Vec1 is deliberately treated like a scalar to mimic shader languages. */ template - constexpr VectorT<4, T, Q> operator&(VectorT<1, T, Q> const& v1, VectorT<4, T, Q> const& v2) + constexpr vec<4, T, Q> operator&(vec<1, T, Q> const& v1, vec<4, T, Q> const& v2) { - return VectorT<4, T, Q>(v1.x) &= v2; + return vec<4, T, Q>(v1.x) &= v2; } template - constexpr VectorT<4, T, Q> operator&(VectorT<4, T, Q> const& v1, VectorT<4, T, Q> const& v2) + constexpr vec<4, T, Q> operator&(vec<4, T, Q> const& v1, vec<4, T, Q> const& v2) { - return VectorT<4, T, Q>(v1) &= v2; + return vec<4, T, Q>(v1) &= v2; } template - constexpr VectorT<4, T, Q> operator|(VectorT<4, T, Q> const& v, T scalar) + constexpr vec<4, T, Q> operator|(vec<4, T, Q> const& v, T scalar) { - return VectorT<4, T, Q>(v) |= scalar; + return vec<4, T, Q>(v) |= scalar; } template - constexpr VectorT<4, T, Q> operator|(T scalar, VectorT<4, T, Q> const& v) + constexpr vec<4, T, Q> operator|(T scalar, vec<4, T, Q> const& v) { - return VectorT<4, T, Q>(scalar) |= v; + return vec<4, T, Q>(scalar) |= v; } /* * \note Vec1 is deliberately treated like a scalar to mimic shader languages. */ template - constexpr VectorT<4, T, Q> operator|(VectorT<4, T, Q> const& v1, VectorT<1, T, Q> const& v2) + constexpr vec<4, T, Q> operator|(vec<4, T, Q> const& v1, vec<1, T, Q> const& v2) { - return VectorT<4, T, Q>(v1) |= v2.x; + return vec<4, T, Q>(v1) |= v2.x; } /* * \note Vec1 is deliberately treated like a scalar to mimic shader languages. */ template - constexpr VectorT<4, T, Q> operator|(VectorT<1, T, Q> const& v1, VectorT<4, T, Q> const& v2) + constexpr vec<4, T, Q> operator|(vec<1, T, Q> const& v1, vec<4, T, Q> const& v2) { - return VectorT<4, T, Q>(v1.x) |= v2; + return vec<4, T, Q>(v1.x) |= v2; } template - constexpr VectorT<4, T, Q> operator|(VectorT<4, T, Q> const& v1, VectorT<4, T, Q> const& v2) + constexpr vec<4, T, Q> operator|(vec<4, T, Q> const& v1, vec<4, T, Q> const& v2) { - return VectorT<4, T, Q>(v1) |= v2; + return vec<4, T, Q>(v1) |= v2; } template - constexpr VectorT<4, T, Q> operator^(VectorT<4, T, Q> const& v, T scalar) + constexpr vec<4, T, Q> operator^(vec<4, T, Q> const& v, T scalar) { - return VectorT<4, T, Q>(v) ^= scalar; + return vec<4, T, Q>(v) ^= scalar; } template - constexpr VectorT<4, T, Q> operator^(T scalar, VectorT<4, T, Q> const& v) + constexpr vec<4, T, Q> operator^(T scalar, vec<4, T, Q> const& v) { - return VectorT<4, T, Q>(scalar) ^= v; + return vec<4, T, Q>(scalar) ^= v; } /* * \note Vec1 is deliberately treated like a scalar to mimic shader languages. */ template - constexpr VectorT<4, T, Q> operator^(VectorT<4, T, Q> const& v1, VectorT<1, T, Q> const& v2) + constexpr vec<4, T, Q> operator^(vec<4, T, Q> const& v1, vec<1, T, Q> const& v2) { - return VectorT<4, T, Q>(v1) ^= v2.x; + return vec<4, T, Q>(v1) ^= v2.x; } /* * \note Vec1 is deliberately treated like a scalar to mimic shader languages. */ template - constexpr VectorT<4, T, Q> operator^(VectorT<1, T, Q> const& v1, VectorT<4, T, Q> const& v2) + constexpr vec<4, T, Q> operator^(vec<1, T, Q> const& v1, vec<4, T, Q> const& v2) { - return VectorT<4, T, Q>(v1.x) ^= v2; + return vec<4, T, Q>(v1.x) ^= v2; } template - constexpr VectorT<4, T, Q> operator^(VectorT<4, T, Q> const& v1, VectorT<4, T, Q> const& v2) + constexpr vec<4, T, Q> operator^(vec<4, T, Q> const& v1, vec<4, T, Q> const& v2) { - return VectorT<4, T, Q>(v1) ^= v2; + return vec<4, T, Q>(v1) ^= v2; } template - constexpr VectorT<4, T, Q> operator<<(VectorT<4, T, Q> const& v, T scalar) + constexpr vec<4, T, Q> operator<<(vec<4, T, Q> const& v, T scalar) { - return VectorT<4, T, Q>(v) <<= scalar; + return vec<4, T, Q>(v) <<= scalar; } template - constexpr VectorT<4, T, Q> operator<<(T scalar, VectorT<4, T, Q> const& v) + constexpr vec<4, T, Q> operator<<(T scalar, vec<4, T, Q> const& v) { - return VectorT<4, T, Q>(scalar) <<= v; + return vec<4, T, Q>(scalar) <<= v; } /* * \note Vec1 is deliberately treated like a scalar to mimic shader languages. */ template - constexpr VectorT<4, T, Q> operator<<(VectorT<4, T, Q> const& v1, VectorT<1, T, Q> const& v2) + constexpr vec<4, T, Q> operator<<(vec<4, T, Q> const& v1, vec<1, T, Q> const& v2) { - return VectorT<4, T, Q>(v1) <<= v2.x; + return vec<4, T, Q>(v1) <<= v2.x; } /* * \note Vec1 is deliberately treated like a scalar to mimic shader languages. */ template - constexpr VectorT<4, T, Q> operator<<(VectorT<1, T, Q> const& v1, VectorT<4, T, Q> const& v2) + constexpr vec<4, T, Q> operator<<(vec<1, T, Q> const& v1, vec<4, T, Q> const& v2) { - return VectorT<4, T, Q>(v1.x) <<= v2; + return vec<4, T, Q>(v1.x) <<= v2; } template - constexpr VectorT<4, T, Q> operator<<(VectorT<4, T, Q> const& v1, VectorT<4, T, Q> const& v2) + constexpr vec<4, T, Q> operator<<(vec<4, T, Q> const& v1, vec<4, T, Q> const& v2) { - return VectorT<4, T, Q>(v1) <<= v2; + return vec<4, T, Q>(v1) <<= v2; } template - constexpr VectorT<4, T, Q> operator>>(VectorT<4, T, Q> const& v, T scalar) + constexpr vec<4, T, Q> operator>>(vec<4, T, Q> const& v, T scalar) { - return VectorT<4, T, Q>(v) >>= scalar; + return vec<4, T, Q>(v) >>= scalar; } template - constexpr VectorT<4, T, Q> operator>>(T scalar, VectorT<4, T, Q> const& v) + constexpr vec<4, T, Q> operator>>(T scalar, vec<4, T, Q> const& v) { - return VectorT<4, T, Q>(scalar) >>= v; + return vec<4, T, Q>(scalar) >>= v; } /* * \note Vec1 is deliberately treated like a scalar to mimic shader languages. */ template - constexpr VectorT<4, T, Q> operator>>(VectorT<4, T, Q> const& v1, VectorT<1, T, Q> const& v2) + constexpr vec<4, T, Q> operator>>(vec<4, T, Q> const& v1, vec<1, T, Q> const& v2) { - return VectorT<4, T, Q>(v1) >>= v2.x; + return vec<4, T, Q>(v1) >>= v2.x; } /* * \note Vec1 is deliberately treated like a scalar to mimic shader languages. */ template - constexpr VectorT<4, T, Q> operator>>(VectorT<1, T, Q> const& v1, VectorT<4, T, Q> const& v2) + constexpr vec<4, T, Q> operator>>(vec<1, T, Q> const& v1, vec<4, T, Q> const& v2) { - return VectorT<4, T, Q>(v1.x) >>= v2; + return vec<4, T, Q>(v1.x) >>= v2; } template - constexpr VectorT<4, T, Q> operator>>(VectorT<4, T, Q> const& v1, VectorT<4, T, Q> const& v2) + constexpr vec<4, T, Q> operator>>(vec<4, T, Q> const& v1, vec<4, T, Q> const& v2) { - return VectorT<4, T, Q>(v1) >>= v2; + return vec<4, T, Q>(v1) >>= v2; } template - constexpr VectorT<4, T, Q> operator~(VectorT<4, T, Q> const& v) + constexpr vec<4, T, Q> operator~(vec<4, T, Q> const& v) { return detail::BitwiseNot::is_iec559, sizeof(T) * 8, detail::IsAligned::value>::compute(v); } @@ -999,25 +999,25 @@ namespace mim /// Conditional Operators template - constexpr bool operator==(VectorT<4, T, Q> const& v1, VectorT<4, T, Q> const& v2) + constexpr bool operator==(vec<4, T, Q> const& v1, vec<4, T, Q> const& v2) { return detail::Equal::is_iec559, sizeof(T) * 8, detail::IsAligned::value>::compute(v1, v2); } template - constexpr bool operator!=(VectorT<4, T, Q> const& v1, VectorT<4, T, Q> const& v2) + constexpr bool operator!=(vec<4, T, Q> const& v1, vec<4, T, Q> const& v2) { return detail::NotEqual::is_iec559, sizeof(T) * 8, detail::IsAligned::value>::compute(v1, v2); } template - constexpr bool operator&&(VectorT<4, bool, Q> const& v1, VectorT<4, bool, Q> const& v2) + constexpr bool operator&&(vec<4, bool, Q> const& v1, vec<4, bool, Q> const& v2) { return (v1.x && v2.x, v1.y && v2.y, v1.z && v2.z, v1.w && v2.w); } template - constexpr bool operator||(VectorT<4, bool, Q> const& v1, VectorT<4, bool, Q> const& v2) + constexpr bool operator||(vec<4, bool, Q> const& v1, vec<4, bool, Q> const& v2) { return (v1.x || v2.x, v1.y || v2.y, v1.z || v2.z, v1.w || v2.w); } diff --git a/include/mim/quat.hpp b/include/mim/quat.hpp index f9689e8..e172633 100644 --- a/include/mim/quat.hpp +++ b/include/mim/quat.hpp @@ -8,9 +8,7 @@ namespace mim { - template - using quat = Quaternion; - using quatf = Quaternion; - using quatd = Quaternion; + using quatf = quat; + using quatd = quat; } diff --git a/include/mim/vec.hpp b/include/mim/vec.hpp index b5087c1..9e2066e 100644 --- a/include/mim/vec.hpp +++ b/include/mim/vec.hpp @@ -11,15 +11,3 @@ #include "mim/vec3.hpp" #include "mim/vec4.hpp" -namespace mim -{ - /** - * \brief Templated helper alias for all vector types. - * \tparam T Type of the vector. - * \tparam Dim Dimension of the vector. - * \tparam Q Qualifier of the vector. - * \addtogroup VectorCore - */ - template - using vec = typename std::enable_if<(Dim <= 4), VectorT>::type; -} // namespace mim diff --git a/include/mim/vec1.hpp b/include/mim/vec1.hpp index 62e8c4f..406e021 100644 --- a/include/mim/vec1.hpp +++ b/include/mim/vec1.hpp @@ -19,66 +19,66 @@ namespace mim * \addtogroup VectorCore */ template - using vec1 = VectorT<1, T, Q>; + using vec1 = vec<1, T, Q>; /** * \brief Helper alias for 1D vectors of type float. * \addtogroup VectorCore */ - using vec1f = VectorT<1, float, qualifier::defaultp>; + using vec1f = vec<1, float, qualifier::defaultp>; /** * \brief Helper alias for 1D vectors of type double. * \addtogroup VectorCore */ - using vec1d = VectorT<1, double, qualifier::defaultp>; + using vec1d = vec<1, double, qualifier::defaultp>; /** * \brief Helper alias for 1D vectors of type int. * \addtogroup VectorCore */ - using vec1i = VectorT<1, int, qualifier::defaultp>; + using vec1i = vec<1, int, qualifier::defaultp>; /** * \brief Helper alias for 1D vectors of type unsigned int. * \addtogroup VectorCore */ - using vec1u = VectorT<1, unsigned int, qualifier::defaultp>; + using vec1u = vec<1, unsigned int, qualifier::defaultp>; /** * \brief Helper alias for 1D vectors of type bool. * \addtogroup VectorCore */ - using vec1b = VectorT<1, bool, qualifier::defaultp>; + using vec1b = vec<1, bool, qualifier::defaultp>; /** * \brief Helper alias for 1D vectors of type half. * \addtogroup VectorCore */ - using vec1h = VectorT<1, half, qualifier::defaultp>; - - using highp_vec1 = VectorT<1, float, qualifier::highp>; - using highp_vec1f = VectorT<1, float, qualifier::highp>; - using highp_vec1d = VectorT<1, double, qualifier::highp>; - using highp_vec1i = VectorT<1, int, qualifier::highp>; - using highp_vec1u = VectorT<1, unsigned int, qualifier::highp>; - using highp_vec1b = VectorT<1, bool, qualifier::highp>; - using highp_vec1h = VectorT<1, half, qualifier::highp>; - - using mediump_vec1 = VectorT<1, float, qualifier::mediump>; - using mediump_vec1f = VectorT<1, float, qualifier::mediump>; - using mediump_vec1d = VectorT<1, double, qualifier::mediump>; - using mediump_vec1i = VectorT<1, int, qualifier::mediump>; - using mediump_vec1u = VectorT<1, unsigned int, qualifier::mediump>; - using mediump_vec1b = VectorT<1, bool, qualifier::mediump>; - using mediump_vec1h = VectorT<1, half, qualifier::mediump>; - - using lowp_vec1 = VectorT<1, float, qualifier::lowp>; - using lowp_vec1f = VectorT<1, float, qualifier::lowp>; - using lowp_vec1d = VectorT<1, double, qualifier::lowp>; - using lowp_vec1i = VectorT<1, int, qualifier::lowp>; - using lowp_vec1u = VectorT<1, unsigned int, qualifier::lowp>; - using lowp_vec1b = VectorT<1, bool, qualifier::lowp>; - using lowp_vec1h = VectorT<1, half, qualifier::lowp>; + using vec1h = vec<1, half, qualifier::defaultp>; + + using highp_vec1 = vec<1, float, qualifier::highp>; + using highp_vec1f = vec<1, float, qualifier::highp>; + using highp_vec1d = vec<1, double, qualifier::highp>; + using highp_vec1i = vec<1, int, qualifier::highp>; + using highp_vec1u = vec<1, unsigned int, qualifier::highp>; + using highp_vec1b = vec<1, bool, qualifier::highp>; + using highp_vec1h = vec<1, half, qualifier::highp>; + + using mediump_vec1 = vec<1, float, qualifier::mediump>; + using mediump_vec1f = vec<1, float, qualifier::mediump>; + using mediump_vec1d = vec<1, double, qualifier::mediump>; + using mediump_vec1i = vec<1, int, qualifier::mediump>; + using mediump_vec1u = vec<1, unsigned int, qualifier::mediump>; + using mediump_vec1b = vec<1, bool, qualifier::mediump>; + using mediump_vec1h = vec<1, half, qualifier::mediump>; + + using lowp_vec1 = vec<1, float, qualifier::lowp>; + using lowp_vec1f = vec<1, float, qualifier::lowp>; + using lowp_vec1d = vec<1, double, qualifier::lowp>; + using lowp_vec1i = vec<1, int, qualifier::lowp>; + using lowp_vec1u = vec<1, unsigned int, qualifier::lowp>; + using lowp_vec1b = vec<1, bool, qualifier::lowp>; + using lowp_vec1h = vec<1, half, qualifier::lowp>; } // namespace mim diff --git a/include/mim/vec2.hpp b/include/mim/vec2.hpp index 6dff6b6..6922291 100644 --- a/include/mim/vec2.hpp +++ b/include/mim/vec2.hpp @@ -19,66 +19,66 @@ namespace mim * \addtogroup VectorCore */ template - using vec2 = VectorT<2, T, Q>; + using vec2 = vec<2, T, Q>; /** * \brief Helper alias for 2D vectors of type float. * \addtogroup VectorCore */ - using vec2f = VectorT<2, float, defaultp>; + using vec2f = vec<2, float, defaultp>; /** * \brief Helper alias for 2D vectors of type int. * \addtogroup VectorCore */ - using vec2i = VectorT<2, int, defaultp>; + using vec2i = vec<2, int, defaultp>; /** * \brief Helper alias for 2D vectors of type unsigned int. * \addtogroup VectorCore */ - using vec2u = VectorT<2, unsigned int, defaultp>; + using vec2u = vec<2, unsigned int, defaultp>; /** * \brief Helper alias for 2D vectors of type double. * \addtogroup VectorCore */ - using vec2d = VectorT<2, double, defaultp>; + using vec2d = vec<2, double, defaultp>; /** * \brief Helper alias for 2D vectors of type bool. * \addtogroup VectorCore */ - using vec2b = VectorT<2, bool, defaultp>; + using vec2b = vec<2, bool, defaultp>; /** * \brief Helper alias for 2D vectors of type half. * \addtogroup VectorCore */ - using vec2h = VectorT<2, half, defaultp>; - - using highp_vec2 = VectorT<2, float, highp>; - using highp_vec2f = VectorT<2, float, highp>; - using highp_vec2i = VectorT<2, int, highp>; - using highp_vec2u = VectorT<2, unsigned int, highp>; - using highp_vec2d = VectorT<2, double, highp>; - using highp_vec2b = VectorT<2, bool, highp>; - using highp_vec2h = VectorT<2, half, highp>; - - using mediump_vec2 = VectorT<2, float, mediump>; - using mediump_vec2f = VectorT<2, float, mediump>; - using mediump_vec2i = VectorT<2, int, mediump>; - using mediump_vec2u = VectorT<2, unsigned int, mediump>; - using mediump_vec2d = VectorT<2, double, mediump>; - using mediump_vec2b = VectorT<2, bool, mediump>; - using mediump_vec2h = VectorT<2, half, mediump>; - - using lowp_vec2 = VectorT<2, float, lowp>; - using lowp_vec2f = VectorT<2, float, lowp>; - using lowp_vec2i = VectorT<2, int, lowp>; - using lowp_vec2u = VectorT<2, unsigned int, lowp>; - using lowp_vec2d = VectorT<2, double, lowp>; - using lowp_vec2b = VectorT<2, bool, lowp>; - using lowp_vec2h = VectorT<2, half, lowp>; + using vec2h = vec<2, half, defaultp>; + + using highp_vec2 = vec<2, float, highp>; + using highp_vec2f = vec<2, float, highp>; + using highp_vec2i = vec<2, int, highp>; + using highp_vec2u = vec<2, unsigned int, highp>; + using highp_vec2d = vec<2, double, highp>; + using highp_vec2b = vec<2, bool, highp>; + using highp_vec2h = vec<2, half, highp>; + + using mediump_vec2 = vec<2, float, mediump>; + using mediump_vec2f = vec<2, float, mediump>; + using mediump_vec2i = vec<2, int, mediump>; + using mediump_vec2u = vec<2, unsigned int, mediump>; + using mediump_vec2d = vec<2, double, mediump>; + using mediump_vec2b = vec<2, bool, mediump>; + using mediump_vec2h = vec<2, half, mediump>; + + using lowp_vec2 = vec<2, float, lowp>; + using lowp_vec2f = vec<2, float, lowp>; + using lowp_vec2i = vec<2, int, lowp>; + using lowp_vec2u = vec<2, unsigned int, lowp>; + using lowp_vec2d = vec<2, double, lowp>; + using lowp_vec2b = vec<2, bool, lowp>; + using lowp_vec2h = vec<2, half, lowp>; } // namespace mim diff --git a/include/mim/vec3.hpp b/include/mim/vec3.hpp index 1f51116..81d1c56 100644 --- a/include/mim/vec3.hpp +++ b/include/mim/vec3.hpp @@ -19,63 +19,63 @@ namespace mim * \addtogroup VectorCore */ template - using vec3 = VectorT<3, T, Q>; + using vec3 = vec<3, T, Q>; /** * \brief Helper alias for 3D vectors of type float. * \addtogroup VectorCore */ - using vec3f = VectorT<3, float, qualifier::defaultp>; + using vec3f = vec<3, float, qualifier::defaultp>; /** * \brief Helper alias for 3D vectors of type double. * \addtogroup VectorCore */ - using vec3d = VectorT<3, double, qualifier::defaultp>; + using vec3d = vec<3, double, qualifier::defaultp>; /** * \brief Helper alias for 3D vectors of type int. * \addtogroup VectorCore */ - using vec3i = VectorT<3, int, qualifier::defaultp>; + using vec3i = vec<3, int, qualifier::defaultp>; /** * \brief Helper alias for 3D vectors of type unsigned int. * \addtogroup VectorCore */ - using vec3u = VectorT<3, unsigned int, qualifier::defaultp>; + using vec3u = vec<3, unsigned int, qualifier::defaultp>; /** * \brief Helper alias for 3D vectors of type bool. * \addtogroup VectorCore */ - using vec3b = VectorT<3, bool, qualifier::defaultp>; + using vec3b = vec<3, bool, qualifier::defaultp>; /** * \brief Helper alias for 3D vectors of type half. * \addtogroup VectorCore */ - using vec3h = VectorT<3, half, qualifier::defaultp>; - - using highp_vec3 = VectorT<3, float, qualifier::highp>; - using highp_vec3f = VectorT<3, float, qualifier::highp>; - using highp_vec3d = VectorT<3, double, qualifier::highp>; - using highp_vec3i = VectorT<3, int, qualifier::highp>; - using highp_vec3u = VectorT<3, unsigned int, qualifier::highp>; - using highp_vec3b = VectorT<3, bool, qualifier::highp>; - - using mediump_vec3 = VectorT<3, float, qualifier::mediump>; - using mediump_vec3f = VectorT<3, float, qualifier::mediump>; - using mediump_vec3d = VectorT<3, double, qualifier::mediump>; - using mediump_vec3i = VectorT<3, int, qualifier::mediump>; - using mediump_vec3u = VectorT<3, unsigned int, qualifier::mediump>; - using mediump_vec3b = VectorT<3, bool, qualifier::mediump>; - - using lowp_vec3 = VectorT<3, float, qualifier::lowp>; - using lowp_vec3f = VectorT<3, float, qualifier::lowp>; - using lowp_vec3d = VectorT<3, double, qualifier::lowp>; - using lowp_vec3i = VectorT<3, int, qualifier::lowp>; - using lowp_vec3u = VectorT<3, unsigned int, qualifier::lowp>; - using lowp_vec3b = VectorT<3, bool, qualifier::lowp>; + using vec3h = vec<3, half, qualifier::defaultp>; + + using highp_vec3 = vec<3, float, qualifier::highp>; + using highp_vec3f = vec<3, float, qualifier::highp>; + using highp_vec3d = vec<3, double, qualifier::highp>; + using highp_vec3i = vec<3, int, qualifier::highp>; + using highp_vec3u = vec<3, unsigned int, qualifier::highp>; + using highp_vec3b = vec<3, bool, qualifier::highp>; + + using mediump_vec3 = vec<3, float, qualifier::mediump>; + using mediump_vec3f = vec<3, float, qualifier::mediump>; + using mediump_vec3d = vec<3, double, qualifier::mediump>; + using mediump_vec3i = vec<3, int, qualifier::mediump>; + using mediump_vec3u = vec<3, unsigned int, qualifier::mediump>; + using mediump_vec3b = vec<3, bool, qualifier::mediump>; + + using lowp_vec3 = vec<3, float, qualifier::lowp>; + using lowp_vec3f = vec<3, float, qualifier::lowp>; + using lowp_vec3d = vec<3, double, qualifier::lowp>; + using lowp_vec3i = vec<3, int, qualifier::lowp>; + using lowp_vec3u = vec<3, unsigned int, qualifier::lowp>; + using lowp_vec3b = vec<3, bool, qualifier::lowp>; } // namespace mim diff --git a/include/mim/vec4.hpp b/include/mim/vec4.hpp index 7b604bd..6aa37c5 100644 --- a/include/mim/vec4.hpp +++ b/include/mim/vec4.hpp @@ -18,69 +18,69 @@ namespace mim * \addtogroup VectorCore */ template - using vec4 = VectorT<4, T, Q>; + using vec4 = vec<4, T, Q>; /** * \brief Helper alias for 4D vectors of type float. * \addtogroup VectorCore */ - using vec4f = VectorT<4, float, qualifier::defaultp>; + using vec4f = vec<4, float, qualifier::defaultp>; /** * \brief Helper alias for 4D vectors of type double. * \addtogroup VectorCore */ - using vec4d = VectorT<4, double, qualifier::defaultp>; + using vec4d = vec<4, double, qualifier::defaultp>; /** * \brief Helper alias for 4D vectors of type int. * \addtogroup VectorCore */ - using vec4i = VectorT<4, int, qualifier::defaultp>; + using vec4i = vec<4, int, qualifier::defaultp>; /** * \brief Helper alias for 4D vectors of type unsigned int. * \addtogroup VectorCore */ - using vec4u = VectorT<4, unsigned int, qualifier::defaultp>; + using vec4u = vec<4, unsigned int, qualifier::defaultp>; /** * \brief Helper alias for 4D vectors of type bool. * \addtogroup VectorCore */ - using vec4b = VectorT<4, bool, qualifier::defaultp>; + using vec4b = vec<4, bool, qualifier::defaultp>; /** * \brief Helper alias for 4D vectors of type half. * \addtogroup VectorCore */ - using vec4h = VectorT<4, half, qualifier::defaultp>; + using vec4h = vec<4, half, qualifier::defaultp>; template - using highp_vec4 = VectorT<4, T, qualifier::highp>; - using highp_vec4f = VectorT<4, float, qualifier::highp>; - using highp_vec4d = VectorT<4, double, qualifier::highp>; - using highp_vec4i = VectorT<4, int, qualifier::highp>; - using highp_vec4u = VectorT<4, unsigned int, qualifier::highp>; - using highp_vec4b = VectorT<4, bool, qualifier::highp>; - using highp_vec4h = VectorT<4, half, qualifier::highp>; + using highp_vec4 = vec<4, T, qualifier::highp>; + using highp_vec4f = vec<4, float, qualifier::highp>; + using highp_vec4d = vec<4, double, qualifier::highp>; + using highp_vec4i = vec<4, int, qualifier::highp>; + using highp_vec4u = vec<4, unsigned int, qualifier::highp>; + using highp_vec4b = vec<4, bool, qualifier::highp>; + using highp_vec4h = vec<4, half, qualifier::highp>; template - using mediump_vec4 = VectorT<4, float, qualifier::mediump>; - using mediump_vec4f = VectorT<4, float, qualifier::mediump>; - using mediump_vec4d = VectorT<4, double, qualifier::mediump>; - using mediump_vec4i = VectorT<4, int, qualifier::mediump>; - using mediump_vec4u = VectorT<4, unsigned int, qualifier::mediump>; - using mediump_vec4b = VectorT<4, bool, qualifier::mediump>; - using mediump_vec4h = VectorT<4, half, qualifier::mediump>; + using mediump_vec4 = vec<4, float, qualifier::mediump>; + using mediump_vec4f = vec<4, float, qualifier::mediump>; + using mediump_vec4d = vec<4, double, qualifier::mediump>; + using mediump_vec4i = vec<4, int, qualifier::mediump>; + using mediump_vec4u = vec<4, unsigned int, qualifier::mediump>; + using mediump_vec4b = vec<4, bool, qualifier::mediump>; + using mediump_vec4h = vec<4, half, qualifier::mediump>; template - using lowp_vec4 = VectorT<4, float, qualifier::lowp>; - using lowp_vec4f = VectorT<4, float, qualifier::lowp>; - using lowp_vec4d = VectorT<4, double, qualifier::lowp>; - using lowp_vec4i = VectorT<4, int, qualifier::lowp>; - using lowp_vec4u = VectorT<4, unsigned int, qualifier::lowp>; - using lowp_vec4b = VectorT<4, bool, qualifier::lowp>; - using lowp_vec4h = VectorT<4, half, qualifier::lowp>; + using lowp_vec4 = vec<4, float, qualifier::lowp>; + using lowp_vec4f = vec<4, float, qualifier::lowp>; + using lowp_vec4d = vec<4, double, qualifier::lowp>; + using lowp_vec4i = vec<4, int, qualifier::lowp>; + using lowp_vec4u = vec<4, unsigned int, qualifier::lowp>; + using lowp_vec4b = vec<4, bool, qualifier::lowp>; + using lowp_vec4h = vec<4, half, qualifier::lowp>; } // namespace mim From e53ed74f3b929484ecb77779ff4366d457258694 Mon Sep 17 00:00:00 2001 From: Rinzii Date: Thu, 13 Jul 2023 21:02:11 -0400 Subject: [PATCH 03/14] Start process of adding operators to mat --- include/mim/detail/type/type_matrix4x3.hpp | 119 ++++++++++++++++++++- 1 file changed, 118 insertions(+), 1 deletion(-) diff --git a/include/mim/detail/type/type_matrix4x3.hpp b/include/mim/detail/type/type_matrix4x3.hpp index 8971d9b..5ee218c 100644 --- a/include/mim/detail/type/type_matrix4x3.hpp +++ b/include/mim/detail/type/type_matrix4x3.hpp @@ -32,6 +32,123 @@ namespace mim constexpr row_type row(size_type i) const noexcept; constexpr column_type column(size_type i) const noexcept; - // constexpr column_type at(size_type i, size_type j) const noexcept; + constexpr column_type at(size_type i, size_type j) const noexcept; + + constexpr mat() noexcept; + explicit constexpr mat(T const& val) noexcept; + constexpr mat( + T const& x0, T const& y0, T const& z0, + T const& x1, T const& y1, T const& z1, + T const& x2, T const& y2, T const& z2, + T const& x3, T const& y3, T const& z3); + constexpr mat( + column_type const& v0, + column_type const& v1, + column_type const& v2, + column_type const& v3); + + template + constexpr mat(mat<4, 3, T, P> const& m) noexcept; + + /// General conversions + + + template < + typename X1, typename Y1, typename Z1, + typename X2, typename Y2, typename Z2, + typename X3, typename Y3, typename Z3, + typename X4, typename Y4, typename Z4> + constexpr mat( + X1 const& x1, Y1 const& y1, Z1 const& z1, + X2 const& x2, Y2 const& y2, Z2 const& z2, + X3 const& x3, Y3 const& y3, Z3 const& z3, + X4 const& x4, Y4 const& y4, Z4 const& z4); + + template + constexpr mat( + vec<3, V1, Q> const& v1, + vec<3, V2, Q> const& v2, + vec<3, V3, Q> const& v3, + vec<3, V4, Q> const& v4); + + + /// Matrix conversions + + explicit constexpr mat(mat<2, 2, T, Q> const& m); + explicit constexpr mat(mat<3, 3, T, Q> const& m); + explicit constexpr mat(mat<4, 4, T, Q> const& m); + explicit constexpr mat(mat<2, 3, T, Q> const& m); + explicit constexpr mat(mat<3, 2, T, Q> const& m); + explicit constexpr mat(mat<2, 4, T, Q> const& m); + explicit constexpr mat(mat<4, 2, T, Q> const& m); + explicit constexpr mat(mat<3, 4, T, Q> const& m); + + template + explicit constexpr mat(mat<4, 3, U, P> const& m); + + + /// Arithmetic operators + + template + mat<4, 3, T, Q> & operator = (mat<4, 3, U, Q> const& m); + template + mat<4, 3, T, Q> & operator += (U const& s); + template + mat<4, 3, T, Q> & operator += (mat<4, 3, U, Q> const& m); + template + mat<4, 3, T, Q> & operator -= (U const& s); + template + mat<4, 3, T, Q> & operator -= (mat<4, 3, U, Q> const& m); + template + mat<4, 3, T, Q> & operator *= (U const& s); + template + mat<4, 3, T, Q> & operator /= (U const& s); + + + /// Increment and decrement operators + + mat<4, 3, T, Q> & operator ++ (); + mat<4, 3, T, Q> & operator -- (); + mat<4, 3, T, Q> operator ++ (int); + mat<4, 3, T, Q> operator -- (int); + }; + + /// Unary operators + + template + mat<4, 3, T, Q> operator + (mat<4, 3, T, Q> const& m); + + template + mat<4, 3, T, Q> operator - (mat<4, 3, T, Q> const& m); + + + /// Binary operators + + template + mat<4, 3, T, Q> operator + (mat<4, 3, T, Q> const& m, T const& s); + + template + mat<4, 3, T, Q> operator + (mat<4, 3, T, Q> const& m1, mat<4, 3, T, Q> const& m2); + + template + mat<4, 3, T, Q> operator - (mat<4, 3, T, Q> const& m, T const& s); + + template + mat<4, 3, T, Q> operator - (mat<4, 3, T, Q> const& m1, mat<4, 3, T, Q> const& m2); + + template + mat<4, 3, T, Q> operator * (mat<4, 3, T, Q> const& m, T const& s); + + template + mat<4, 3, T, Q> operator * (T const& s, mat<4, 3, T, Q> const& m); + + template + typename mat<4, 3, T, Q>::col_type operator * (mat<4, 3, T, Q> const& m, typename mat<4, 3, T, Q>::row_type const& v); + + template + typename mat<4, 3, T, Q>::row_type operator * (typename mat<4, 3, T, Q>::col_type const& v, mat<4, 3, T, Q> const& m); + + + } // namespace mim From c119d48d69d5cffd9c1e97c5610ea40763a67606 Mon Sep 17 00:00:00 2001 From: Ian Pike Date: Thu, 13 Jul 2023 23:23:03 -0400 Subject: [PATCH 04/14] Update cmake global config to actually detect the arch --- cmake/GlobalConfig.cmake | 45 ++++++++-------------------------------- 1 file changed, 9 insertions(+), 36 deletions(-) diff --git a/cmake/GlobalConfig.cmake b/cmake/GlobalConfig.cmake index d8b9b36..eb6ddd0 100644 --- a/cmake/GlobalConfig.cmake +++ b/cmake/GlobalConfig.cmake @@ -1,34 +1,5 @@ include(cmake/Macros.cmake) -# TODO: I need more data on CYGWIN and MSYS to know if they are supported or not. -# Try to look into this further at a later date. - -# check for cygwin -if(CYGWIN) - if(NOT MIM_NO_CMAKE_WARNINGS) - message(WARNING "MIM: - Cygwin may not be supported. If you notice any issues please report it! - REPORT ALL ISSUES HERE: https://github.com/Rinzii/mim/issues/ - - To disable this warning set MIM_NO_CMAKE_WARNINGS to ON - " ) - endif () -endif() - -# check for msys -if(MSYS) - if(NOT MIM_NO_CMAKE_WARNINGS) - message(WARNING "MIM: - MSYS may not be supported. If you notice any issues please report it! - REPORT ALL ISSUES HERE: https://github.com/Rinzii/mim/issues/ - - To disable this warning set MIM_NO_CMAKE_WARNINGS to ON - " ) - endif () -endif() - - - # detect our OS if(${CMAKE_SYSTEM_NAME} STREQUAL "Windows") set(MIM_OS_WINDOWS 1) @@ -43,7 +14,7 @@ elseif(CMAKE_SYSTEM_NAME MATCHES "^OpenBSD$") elseif(CMAKE_SYSTEM_NAME MATCHES "^NetBSD$") set(MIM_OS_NETBSD 1) else() - message(FATAL_ERROR "Unsupported OS: ${CMAKE_SYSTEM_NAME}") + message(WARNING "Mim could not detected a know supported OS: ${CMAKE_SYSTEM_NAME}") endif() @@ -71,12 +42,14 @@ endif() # detect the architecture (note: this test won't work for cross-compilation) -include(CheckTypeSize) -check_type_size(void* SIZEOF_VOID_PTR) -if(${SIZEOF_VOID_PTR} STREQUAL "4") - set(MIM_ARCH_32BITS 1) -elseif(${SIZEOF_VOID_PTR} STREQUAL "8") - set(MIM_ARCH_64BITS 1) +if(CMAKE_SIZEOF_VOID_P EQUAL 8) + set(MIM_ARCH_X64 1) +elseif(CMAKE_SIZEOF_VOID_P EQUAL 4) + set(MIM_ARCH_X86 1) +elseif (CMAKE_SYSTEM_PROCESSOR MATCHES "^armv7") + set(MIM_ARCH_ARM 1) +elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^aarch64") + set(MIM_ARCH_ARM64 1) else() message(FATAL_ERROR "Unsupported architecture") return() From 050f275cf0ebd0a139e90f868b477524f7fdf48b Mon Sep 17 00:00:00 2001 From: Ian Pike Date: Thu, 13 Jul 2023 23:29:57 -0400 Subject: [PATCH 05/14] Update cmake to be a bit better --- CMakeLists.txt | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 036d732..d5a9fa6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,7 +15,7 @@ endif() # We will hit 1.0.0 when we have a stable API # We will hit 0.1.0 when we have finished the basic API -set(build_version 0.0.3) +set(build_version 0.0.4) include(CheckPIESupported) check_pie_supported() @@ -30,7 +30,6 @@ endif() # TO THE IMPLEMENTOR: If MIM_BUILD_TEST is set to OFF then googletest can be deleted from the ext folder. option(MIM_BUILD_TEST "Build mim tests" ${is_root_project}) option(MIM_INSTALL "Setup install and package steps" ${is_root_project}) -option(MIM_NO_CMAKE_WARNINGS "Suppress mim warnings outputted through cmake" OFF) option(MIM_USE_SIMD "Use SIMD instructions" OFF) @@ -74,7 +73,7 @@ endif() if (MIM_USE_SIMD) # TODO: Add a better way to handle enabling simd internally. - #add_compile_definitions(INTERNAL_ENABLE_CHECK_FOR_SIMD) + add_compile_definitions(INTERNAL_ENABLE_CHECK_FOR_SIMD) endif () From 47e92d72e309a2e881a037b33b2dcd10eeed5dad Mon Sep 17 00:00:00 2001 From: Ian Pike Date: Sun, 16 Jul 2023 03:00:23 -0400 Subject: [PATCH 06/14] Update clang-format --- .clang-format | 74 ++++++++++++++++++++++++++++----------------------- 1 file changed, 41 insertions(+), 33 deletions(-) diff --git a/.clang-format b/.clang-format index ce210c2..c61a8a3 100644 --- a/.clang-format +++ b/.clang-format @@ -1,26 +1,44 @@ --- Language: Cpp -BasedOnStyle: LLVM -AlwaysBreakTemplateDeclarations: Yes -BreakBeforeBraces: Linux -ColumnLimit: 160 -SpaceAfterTemplateKeyword: true -Standard: c++20 -TabWidth: 4 -IndentWidth: 4 -UseTab: Always -NamespaceIndentation: All -FixNamespaceComments: true -CompactNamespaces: true +BasedOnStyle: Microsoft +AccessModifierOffset: -4 +AlignConsecutiveAssignments: Consecutive +AlignConsecutiveMacros: Consecutive +AlignEscapedNewlines: Right +AlignTrailingComments: Always AllowShortEnumsOnASingleLine: true AllowShortCaseLabelsOnASingleLine: true AllowShortFunctionsOnASingleLine: InlineOnly AllowShortLambdasOnASingleLine: All AllowShortBlocksOnASingleLine: Always -AllowShortIfStatementsOnASingleLine: Always +AllowShortIfStatementsOnASingleLine: WithoutElse AllowShortLoopsOnASingleLine: true -AccessModifierOffset: -4 +AlwaysBreakTemplateDeclarations: Yes +BraceWrapping: + AfterCaseLabel: true + AfterClass: true + AfterControlStatement: Always + AfterEnum: true + AfterFunction: true + AfterNamespace: true + AfterStruct: true + AfterUnion: true + AfterExternBlock: false + BeforeCatch: false + BeforeElse: false + BeforeLambdaBody: false + BeforeWhile: false + IndentBraces: true + SplitEmptyFunction: true + SplitEmptyRecord: true + SplitEmptyNamespace: true +BreakAfterAttributes: Never +BreakBeforeBraces: Allman +ColumnLimit: 160 +CompactNamespaces: false +FixNamespaceComments: true IndentPPDirectives: BeforeHash +IndentWidth: 4 IncludeCategories: # Headers in <> with .h extension. - Regex: '<([A-Za-z0-9\/-_])+\.h>' @@ -31,22 +49,12 @@ IncludeCategories: # Headers in <> without extension. - Regex: '<([A-Za-z0-9\/-_])+>' Priority: 30 -PointerAlignment: Left -BraceWrapping: - AfterCaseLabel: false - AfterClass: false - AfterEnum: false - AfterFunction: false - AfterNamespace: true - AfterObjCDeclaration: false - AfterStruct: false - AfterUnion: false - AfterExternBlock: false - BeforeCatch: false - BeforeElse: false - IndentBraces: false - SplitEmptyFunction: false - SplitEmptyRecord: false - SplitEmptyNamespace: false - BeforeLambdaBody: false - BeforeWhile: false +NamespaceIndentation: All +PointerAlignment: Middle +SpaceAfterTemplateKeyword: true +Standard: c++20 +TabWidth: 4 +UseTab: Always + + + From 5a802d738b16a1de32fc79de960682e91fc5b0a2 Mon Sep 17 00:00:00 2001 From: Rinzii Date: Wed, 19 Jul 2023 21:11:01 -0400 Subject: [PATCH 07/14] Start process of adding unit tests to quat --- include/mim/detail/type/type_quaternion.inl | 5 +- test/quat/quat_tests.cpp | 167 ++++++++++++++++++-- 2 files changed, 158 insertions(+), 14 deletions(-) diff --git a/include/mim/detail/type/type_quaternion.inl b/include/mim/detail/type/type_quaternion.inl index 1b3950e..cfd9dcc 100644 --- a/include/mim/detail/type/type_quaternion.inl +++ b/include/mim/detail/type/type_quaternion.inl @@ -5,6 +5,7 @@ #include "mim/detail/compute/compute_quaternion.hpp" #include +#include namespace mim { @@ -115,8 +116,8 @@ namespace mim template constexpr quat::quat(const vec<3, T, Q>& euler) { - vec<3, T, Q> c = cos(euler * static_cast(0.5)); - vec<3, T, Q> s = sin(euler * static_cast(0.5)); + vec<3, T, Q> c = ::std::cos(euler * static_cast(0.5)); + vec<3, T, Q> s = ::std::sin(euler * static_cast(0.5)); w = c.x * c.y * c.z + s.x * s.y * s.z; x = s.x * c.y * c.z - c.x * s.y * s.z; diff --git a/test/quat/quat_tests.cpp b/test/quat/quat_tests.cpp index 3b84d0a..1f2e8b6 100644 --- a/test/quat/quat_tests.cpp +++ b/test/quat/quat_tests.cpp @@ -1,25 +1,168 @@ // Copyright (c) 2023-Present Mim contributors (see LICENSE) #include +#include #include -TEST(QuatTests, DefaultConstructor) +#define PI 3.14159265358979323846 + +using namespace mim; + +// Helper function to compare floating-point values within a small epsilon +template +bool IsClose(T a, T b, T epsilon = static_cast(1e-6)) +{ + return std::abs(a - b) < epsilon; +} + +// Test fixture for the quaternion class +template +class QuaternionTest : public ::testing::Test +{ +protected: + // Helper function to create a vector with specified components + vec<3, T> MakeVector(T x, T y, T z) + { + return vec<3, T>(x, y, z); + } +}; + +// List of types to test (float and double) +using QuaternionTypes = ::testing::Types; +TYPED_TEST_SUITE(QuaternionTest, QuaternionTypes); + +TYPED_TEST(QuaternionTest, DefaultConstructor) +{ + quat q; + EXPECT_TRUE(IsClose(q.x, static_cast(0))); + EXPECT_TRUE(IsClose(q.y, static_cast(0))); + EXPECT_TRUE(IsClose(q.z, static_cast(0))); + EXPECT_TRUE(IsClose(q.w, static_cast(1))); +} + +TYPED_TEST(QuaternionTest, CopyConstructor) +{ + quat q1(1, 2, 3, 4); + quat q2(q1); + EXPECT_EQ(q1, q2); +} + +TYPED_TEST(QuaternionTest, VectorConstructor) +{ + vec<3, TypeParam> v(1, 2, 3); + quat q(4, v); + EXPECT_TRUE(IsClose(q.x, static_cast(1))); + EXPECT_TRUE(IsClose(q.y, static_cast(2))); + EXPECT_TRUE(IsClose(q.z, static_cast(3))); + EXPECT_TRUE(IsClose(q.w, static_cast(4))); +} + +TYPED_TEST(QuaternionTest, AxisAngleConstructor) +{ + vec<3, TypeParam> axis = this->MakeVector(1, 0, 0); + quat q(PI / 2, axis); + + EXPECT_TRUE(IsClose(q.w, static_cast(std::cos(PI / 4)))); + EXPECT_TRUE(IsClose(q.x, static_cast(std::sin(PI / 4)))); + EXPECT_TRUE(IsClose(q.y, static_cast(0))); + EXPECT_TRUE(IsClose(q.z, static_cast(0))); +} + +/* +TYPED_TEST(QuaternionTest, EulerConstructor) +{ + vec<3, TypeParam> euler(PI / 2, 0, PI / 2); + quat q(euler); + + EXPECT_TRUE(IsClose(q.w, static_cast(std::cos(PI / 4) * std::cos(PI / 4)))); + EXPECT_TRUE(IsClose(q.x, static_cast(std::sin(PI / 4) * std::cos(PI / 4)))); + EXPECT_TRUE(IsClose(q.y, static_cast(0))); + EXPECT_TRUE(IsClose(q.z, static_cast(std::cos(PI / 4) * std::sin(PI / 4)))); +} +*/ + +TYPED_TEST(QuaternionTest, AssignmentOperator) +{ + quat q1(1, 2, 3, 4); + quat q2 = q1; + EXPECT_EQ(q1, q2); +} + +TYPED_TEST(QuaternionTest, AdditionOperator) +{ + quat q1(1, 2, 3, 4); + quat q2(5, 6, 7, 8); + quat result = q1 + q2; + quat expected(6, 8, 10, 12); + EXPECT_EQ(result, expected); +} + +TYPED_TEST(QuaternionTest, SubtractionOperator) +{ + quat q1(5, 6, 7, 8); + quat q2(1, 2, 3, 4); + quat result = q1 - q2; + quat expected(4, 4, 4, 4); + EXPECT_EQ(result, expected); +} + +TYPED_TEST(QuaternionTest, MultiplicationOperator) +{ + quat q1(1, 2, 3, 4); + quat q2(5, 6, 7, 8); + quat result = q1 * q2; + quat expected(-60, 12, 30, 24); + EXPECT_EQ(result, expected); +} + +TYPED_TEST(QuaternionTest, ScalarMultiplication) +{ + quat q(1, 2, 3, 4); + auto scalar = static_cast(2); + quat result = q * scalar; + quat expected(2, 4, 6, 8); + EXPECT_EQ(result, expected); +} + +TYPED_TEST(QuaternionTest, ScalarDivision) +{ + quat q(2, 4, 6, 8); + auto scalar = static_cast(2); + quat result = q / scalar; + quat expected(1, 2, 3, 4); + EXPECT_EQ(result, expected); +} + +TYPED_TEST(QuaternionTest, EqualityOperator) +{ + quat q1(1, 2, 3, 4); + quat q2(1, 2, 3, 4); + EXPECT_TRUE(q1 == q2); + + quat q3(5, 6, 7, 8); + EXPECT_FALSE(q1 == q3); +} + +TYPED_TEST(QuaternionTest, InequalityOperator) { - mim::quatf q; - EXPECT_EQ(q.w, 1.0f); - EXPECT_EQ(q.x, 0.0f); - EXPECT_EQ(q.y, 0.0f); - EXPECT_EQ(q.z, 0.0f); + quat q1(1, 2, 3, 4); + quat q2(1, 2, 3, 4); + EXPECT_FALSE(q1 != q2); + + quat q3(5, 6, 7, 8); + EXPECT_TRUE(q1 != q3); } -TEST(QuatTests, ScalarVectorConstructor) +/* +TYPED_TEST(QuaternionTest, QuaternionMultiplicationVector) { - mim::quatf q(1.0f, 2.0f, 3.0f, 4.0f); - EXPECT_EQ(q.w, 1.0f); - EXPECT_EQ(q.x, 2.0f); - EXPECT_EQ(q.y, 3.0f); - EXPECT_EQ(q.z, 4.0f); + quat q(1, 2, 3, 4); + vec<3, TypeParam> v(1, 2, 3); + vec<3, TypeParam> result = q * v; + vec<3, TypeParam> expected(14, 22, 32); + EXPECT_EQ(result, expected); } +*/ From 4c047d4cf9f1b690df7292e4d72fc4b211c25eee Mon Sep 17 00:00:00 2001 From: Ian Pike Date: Fri, 21 Jul 2023 10:51:22 -0400 Subject: [PATCH 08/14] Make the code more explicit and fix some bugs --- include/mim/cmath.hpp | 10 ++ include/mim/detail/func/func_quaternion.inl | 21 ++- include/mim/detail/func/func_vector3.inl | 43 +++-- include/mim/detail/type/type_quaternion.hpp | 7 + include/mim/detail/type/type_quaternion.inl | 63 +++----- include/mim/detail/type/type_vector3.hpp | 12 ++ test/quat/quat_tests.cpp | 166 +------------------- 7 files changed, 103 insertions(+), 219 deletions(-) diff --git a/include/mim/cmath.hpp b/include/mim/cmath.hpp index 90a6af3..5214036 100644 --- a/include/mim/cmath.hpp +++ b/include/mim/cmath.hpp @@ -1,5 +1,13 @@ // Copyright (c) 2023-Present Mim contributors (see LICENSE) +/** + * @file cmath.hpp + * @brief mim cmath provides a set of math functions from the standard cmath library implemented in constexpr. + * + * This is not a comprehensive implementation of the cmath library, but rather a set of functions that are + * useful for mim that are needed to be constexpr. + */ + #pragma once #include @@ -73,6 +81,8 @@ namespace mim::math return detail::is_close(a, b, epsilon); } + + // TODO: Implement sine and cosine functions as constexpr. } // namespace mim diff --git a/include/mim/detail/func/func_quaternion.inl b/include/mim/detail/func/func_quaternion.inl index 0c8847d..c22a3c7 100644 --- a/include/mim/detail/func/func_quaternion.inl +++ b/include/mim/detail/func/func_quaternion.inl @@ -8,16 +8,18 @@ namespace mim { + /// Member functions + template constexpr T quat::length() const { - return math::sqrt(w * w + x * x + y * y + z * z); + return ::mim::math::sqrt(w * w + x * x + y * y + z * z); } template constexpr void quat::normalize() { - T len = length(); + T len = this->length(); if (len > 0) { T invLen = 1 / len; @@ -31,7 +33,7 @@ namespace mim template constexpr quat quat::normalized() const { - T len = length(); + T len = this->length(); if (len > 0) { T invLen = 1 / len; @@ -43,13 +45,13 @@ namespace mim template constexpr bool quat::is_normalized() const { - return mim::math::abs(length() - 1) < MIM_UNIT_EPSILON; + return ::mim::math::abs(this->length() - 1) < MIM_UNIT_EPSILON; } template constexpr quat quat::inverse() const { - T len = length(); + T len = this->length(); if (len > 0) { T invLen = 1 / len; @@ -57,4 +59,13 @@ namespace mim } return quat(0, 0, 0, 0); } + + + /// Free functions + + template + constexpr quat normalize(const quat& q) + { + return q.normalized(); + } } diff --git a/include/mim/detail/func/func_vector3.inl b/include/mim/detail/func/func_vector3.inl index 8bd33ed..2526e28 100644 --- a/include/mim/detail/func/func_vector3.inl +++ b/include/mim/detail/func/func_vector3.inl @@ -10,10 +10,12 @@ namespace mim { + /// Member functions + template constexpr T vec<3, T, Q>::length() const { - return mim::math::sqrt(x * x + y * y + z * z); + return ::mim::math::sqrt(x * x + y * y + z * z); } template @@ -30,7 +32,7 @@ namespace mim T len = length_squared(); if (len != 0) { - len = mim::math::sqrt(len); + len = ::mim::math::sqrt(len); x /= len; y /= len; z /= len; @@ -53,13 +55,13 @@ namespace mim static_assert(std::is_floating_point::value, "Cannot normalize a non-floating-point vector."); // We want to use length_squared() over length() to avoid the use of sqrt. - return nearlyEquals(length_squared(), T{ 1 }, MIM_UNIT_EPSILON); + return ::mim::math::is_close(length_squared(), T{ 1 }, MIM_UNIT_EPSILON); } template constexpr T vec<3, T, Q>::distance(const vec<3, T, Q>& v) const { - return mim::math::sqrt((x - v.x) * (x - v.x) + (y - v.y) * (y - v.y) + (z - v.z) * (z - v.z)); + return ::mim::math::sqrt((x - v.x) * (x - v.x) + (y - v.y) * (y - v.y) + (z - v.z) * (z - v.z)); } template @@ -68,9 +70,6 @@ namespace mim return (x - v.x) * (x - v.x) + (y - v.y) * (y - v.y) + (z - v.z) * (z - v.z); } - - /// Functions - template constexpr T vec<3, T, Q>::dot(const vec<3, T, Q>& v) const { @@ -103,9 +102,9 @@ namespace mim constexpr vec<3, T, Q> vec<3, T, Q>::clamp(const vec<3, T, Q>& min, const vec<3, T, Q>& max) const { return vec<3, T, Q>( - mim::math::clamp(x, min.x, max.x), - mim::math::clamp(y, min.y, max.y), - mim::math::clamp(z, min.z, max.z) + ::mim::math::clamp(x, min.x, max.x), + ::mim::math::clamp(y, min.y, max.y), + ::mim::math::clamp(z, min.z, max.z) ); } @@ -135,7 +134,7 @@ namespace mim } else { - return eta * *this - (eta * dot + mim::math::sqrt(k)) * normal; + return eta * (*this) - (eta * dot + ::mim::math::sqrt(k)) * normal; } } @@ -145,4 +144,26 @@ namespace mim // TODO: Validate this function. return to * (this->dot(to) / to.length_squared()); } + + + + /// Free functions + + template + constexpr vec<3, T, Q> dot(const vec<3, T, Q>& v1, const vec<3, T, Q>& v2) + { + return v1.dot(v2); + } + + template + constexpr vec<3, T, Q> cross(const vec<3, T, Q>& v1, const vec<3, T, Q>& v2) + { + return v1.cross(v2); + } + + template + constexpr vec<3, T, Q> inverse(const vec<3, T, Q>& v) + { + return vec<3, T, Q>(T{ 1 } / v.x, T{ 1 } / v.y, T{ 1 } / v.z); + } } diff --git a/include/mim/detail/type/type_quaternion.hpp b/include/mim/detail/type/type_quaternion.hpp index 210ec10..66a46da 100644 --- a/include/mim/detail/type/type_quaternion.hpp +++ b/include/mim/detail/type/type_quaternion.hpp @@ -137,6 +137,13 @@ namespace mim template constexpr bool operator!=(quat const& q1, quat const& p); + + /// Free functions + + template + constexpr quat normalize(quat const& q); + + } // namespace mim #include "mim/detail/type/type_quaternion.inl" diff --git a/include/mim/detail/type/type_quaternion.inl b/include/mim/detail/type/type_quaternion.inl index cfd9dcc..42f79e1 100644 --- a/include/mim/detail/type/type_quaternion.inl +++ b/include/mim/detail/type/type_quaternion.inl @@ -3,6 +3,9 @@ #pragma once #include "mim/detail/compute/compute_quaternion.hpp" +#include "mim/detail/type/type_vector3.hpp" + +#include "mim/cmath.hpp" #include #include @@ -12,73 +15,43 @@ namespace mim template constexpr quat::quat() { -#if MIM_FORCE_QUATERNION_XYZW - x = static_cast(0); - y = static_cast(0); - z = static_cast(0); - w = static_cast(1); -#else w = static_cast(1); x = static_cast(0); y = static_cast(0); z = static_cast(0); -#endif } template constexpr quat::quat(quat const& q) { -#if MIM_FORCE_QUATERNION_XYZW - x = q.x; - y = q.y; - z = q.z; - w = q.w; -#else w = q.w; x = q.x; y = q.y; z = q.z; -#endif } template template constexpr quat::quat(quat const& q) -#if MIM_FORCE_QUATERNION_XYZW - : x(q.x), y(q.y), z(q.z), w(q.w) -#else : w(q.w), x(q.x), y(q.y), z(q.z) -#endif { } template constexpr quat::quat(const T& s, const vec<3, T, Q>& v) -#if MIM_FORCE_QUATERNION_XYZW - : x(v.x), y(v.y), z(v.z), w(s) -#else : w(s), x(v.x), y(v.y), z(v.z) -#endif { } template -#if MIM_FORCE_QUATERNION_XYZW - constexpr quat::quat(const T& x_, const T& y_, const T& z_, const T& w_) : x(x_), y(y_), z(z_), w(w_) -#else constexpr quat::quat(const T& w_, const T& x_, const T& y_, const T& z_) : w(w_), x(x_), y(y_), z(z_) -#endif { } template template constexpr quat::quat(quat const& q) -#if MIM_FORCE_QUATERNION_XYZW - : x(static_cast(q.x)), y(static_cast(q.y)), z(static_cast(q.z)), w(static_cast(q.w)) -#else : w(static_cast(q.w)), x(static_cast(q.x)), y(static_cast(q.y)), z(static_cast(q.z)) -#endif { } @@ -97,22 +70,24 @@ namespace mim template quat::quat(const vec<3, T, Q>& a1, const vec<3, T, Q>& a2) { - T normalizeAxis = sqrt(dot(a1, a1) * dot(a2, a2)); - T real = normalizeAxis + dot(a1, a2); + T normalizeAxis = ::mim::math::sqrt(::mim::dot(a1, a1) * ::mim::dot(a2, a2)); + T real = normalizeAxis + ::mim::dot(a1, a2); vec<3, T, Q> tmp; if (real < static_cast(1.e-6f) * normalizeAxis) { // If a1 and a2 are exactly opposite, rotate 180 degrees real = static_cast(0); - tmp = abs(a1.x) > abs(a1.z) ? vec<3, T, Q>(-a1.y, a1.x, static_cast(0)) : vec<3, T, Q>(static_cast(0), -a1.z, a1.y); + tmp = ::mim::math::abs(a1.x) > ::mim::math::abs(a1.z) ? vec<3, T, Q>(-a1.y, a1.x, static_cast(0)) : vec<3, T, Q>(static_cast(0), -a1.z, a1.y); } else { // Else, build normal quaternion - tmp = cross(a1, a2); + tmp = ::mim::cross(a1, a2); } - *this = normalize(quat(real, tmp)); + *this = ::mim::normalize(quat(real, tmp)); } + // TODO: This may not work as constexpr due to using std::cos and std::sin. + template constexpr quat::quat(const vec<3, T, Q>& euler) { @@ -145,7 +120,7 @@ namespace mim this->y = static_cast(q.x); this->z = static_cast(q.y); this->w = static_cast(q.z); - return *this; + return (*this); } template @@ -156,7 +131,7 @@ namespace mim this->x += static_cast(q.x); this->y += static_cast(q.y); this->z += static_cast(q.z); - return *this; + return (*this); } template @@ -167,7 +142,7 @@ namespace mim this->x -= static_cast(q.x); this->y -= static_cast(q.y); this->z -= static_cast(q.z); - return *this; + return (*); } template @@ -181,14 +156,14 @@ namespace mim this->x = p.w * q.x + p.x * q.w + p.y * q.z - p.z * q.y; this->y = p.w * q.y + p.y * q.w + p.z * q.x - p.x * q.z; this->z = p.w * q.z + p.z * q.w + p.x * q.y - p.y * q.x; - return *this; + return (*this); } template template constexpr quat& quat::operator/=(const U& scalar) { - return *this *= static_cast(1) / scalar; + return (*this) *= static_cast(1) / scalar; } template @@ -199,7 +174,7 @@ namespace mim this->y *= scalar; this->z *= scalar; this->w *= scalar; - return *this; + return (*this); } template @@ -236,8 +211,8 @@ namespace mim constexpr quat operator*(quat const& q, vec<3, T, Q> const& v) { vec<3, T, Q> const QuatVector(q.x, q.y, q.z); - vec<3, T, Q> const uv(cross(QuatVector, v)); - vec<3, T, Q> const uuv(cross(QuatVector, uv)); + vec<3, T, Q> const uv(::mim::cross(QuatVector, v)); + vec<3, T, Q> const uuv(::mim::cross(QuatVector, uv)); return v + ((uv * q.w) + uuv) * static_cast(2); } @@ -245,7 +220,7 @@ namespace mim template constexpr quat operator*(vec<3, T, Q> const& v, quat const& q) { - inverse(q) * v; + ::mim::inverse(q) * v; } template diff --git a/include/mim/detail/type/type_vector3.hpp b/include/mim/detail/type/type_vector3.hpp index 1ce6ff7..02f948c 100644 --- a/include/mim/detail/type/type_vector3.hpp +++ b/include/mim/detail/type/type_vector3.hpp @@ -412,6 +412,18 @@ namespace mim constexpr bool operator||(vec<3, T, Q> const& v1, vec<3, T, Q> const& v2); + // Free functions + + template + constexpr vec<3, T, Q> dot(vec<3, T, Q> const& v1, vec<3, T, Q> const& v2); + + template + constexpr vec<3, T, Q> cross(vec<3, T, Q> const& v1, vec<3, T, Q> const& v2); + + template + constexpr vec<3, T, Q> inverse(vec<3, T, Q> const& v, T epsilon = 0.001f); + + } // namespace mim #include "mim/detail/type/type_vector3.inl" diff --git a/test/quat/quat_tests.cpp b/test/quat/quat_tests.cpp index 1f2e8b6..6588ab4 100644 --- a/test/quat/quat_tests.cpp +++ b/test/quat/quat_tests.cpp @@ -2,167 +2,15 @@ #include #include +#include #include -#define PI 3.14159265358979323846 - -using namespace mim; - -// Helper function to compare floating-point values within a small epsilon -template -bool IsClose(T a, T b, T epsilon = static_cast(1e-6)) -{ - return std::abs(a - b) < epsilon; -} - -// Test fixture for the quaternion class -template -class QuaternionTest : public ::testing::Test -{ -protected: - // Helper function to create a vector with specified components - vec<3, T> MakeVector(T x, T y, T z) - { - return vec<3, T>(x, y, z); - } -}; - -// List of types to test (float and double) -using QuaternionTypes = ::testing::Types; -TYPED_TEST_SUITE(QuaternionTest, QuaternionTypes); - -TYPED_TEST(QuaternionTest, DefaultConstructor) -{ - quat q; - EXPECT_TRUE(IsClose(q.x, static_cast(0))); - EXPECT_TRUE(IsClose(q.y, static_cast(0))); - EXPECT_TRUE(IsClose(q.z, static_cast(0))); - EXPECT_TRUE(IsClose(q.w, static_cast(1))); -} - -TYPED_TEST(QuaternionTest, CopyConstructor) -{ - quat q1(1, 2, 3, 4); - quat q2(q1); - EXPECT_EQ(q1, q2); -} - -TYPED_TEST(QuaternionTest, VectorConstructor) +TEST(QuaternionDefaultTests, DefaultConstructor) { - vec<3, TypeParam> v(1, 2, 3); - quat q(4, v); - EXPECT_TRUE(IsClose(q.x, static_cast(1))); - EXPECT_TRUE(IsClose(q.y, static_cast(2))); - EXPECT_TRUE(IsClose(q.z, static_cast(3))); - EXPECT_TRUE(IsClose(q.w, static_cast(4))); + mim::quat q; + EXPECT_EQ(q.w, 1.0f); + EXPECT_EQ(q.x, 0.0f); + EXPECT_EQ(q.y, 0.0f); + EXPECT_EQ(q.z, 0.0f); } -TYPED_TEST(QuaternionTest, AxisAngleConstructor) -{ - vec<3, TypeParam> axis = this->MakeVector(1, 0, 0); - quat q(PI / 2, axis); - - EXPECT_TRUE(IsClose(q.w, static_cast(std::cos(PI / 4)))); - EXPECT_TRUE(IsClose(q.x, static_cast(std::sin(PI / 4)))); - EXPECT_TRUE(IsClose(q.y, static_cast(0))); - EXPECT_TRUE(IsClose(q.z, static_cast(0))); -} - -/* -TYPED_TEST(QuaternionTest, EulerConstructor) -{ - vec<3, TypeParam> euler(PI / 2, 0, PI / 2); - quat q(euler); - - EXPECT_TRUE(IsClose(q.w, static_cast(std::cos(PI / 4) * std::cos(PI / 4)))); - EXPECT_TRUE(IsClose(q.x, static_cast(std::sin(PI / 4) * std::cos(PI / 4)))); - EXPECT_TRUE(IsClose(q.y, static_cast(0))); - EXPECT_TRUE(IsClose(q.z, static_cast(std::cos(PI / 4) * std::sin(PI / 4)))); -} -*/ - -TYPED_TEST(QuaternionTest, AssignmentOperator) -{ - quat q1(1, 2, 3, 4); - quat q2 = q1; - EXPECT_EQ(q1, q2); -} - -TYPED_TEST(QuaternionTest, AdditionOperator) -{ - quat q1(1, 2, 3, 4); - quat q2(5, 6, 7, 8); - quat result = q1 + q2; - quat expected(6, 8, 10, 12); - EXPECT_EQ(result, expected); -} - -TYPED_TEST(QuaternionTest, SubtractionOperator) -{ - quat q1(5, 6, 7, 8); - quat q2(1, 2, 3, 4); - quat result = q1 - q2; - quat expected(4, 4, 4, 4); - EXPECT_EQ(result, expected); -} - -TYPED_TEST(QuaternionTest, MultiplicationOperator) -{ - quat q1(1, 2, 3, 4); - quat q2(5, 6, 7, 8); - quat result = q1 * q2; - quat expected(-60, 12, 30, 24); - EXPECT_EQ(result, expected); -} - -TYPED_TEST(QuaternionTest, ScalarMultiplication) -{ - quat q(1, 2, 3, 4); - auto scalar = static_cast(2); - quat result = q * scalar; - quat expected(2, 4, 6, 8); - EXPECT_EQ(result, expected); -} - -TYPED_TEST(QuaternionTest, ScalarDivision) -{ - quat q(2, 4, 6, 8); - auto scalar = static_cast(2); - quat result = q / scalar; - quat expected(1, 2, 3, 4); - EXPECT_EQ(result, expected); -} - -TYPED_TEST(QuaternionTest, EqualityOperator) -{ - quat q1(1, 2, 3, 4); - quat q2(1, 2, 3, 4); - EXPECT_TRUE(q1 == q2); - - quat q3(5, 6, 7, 8); - EXPECT_FALSE(q1 == q3); -} - -TYPED_TEST(QuaternionTest, InequalityOperator) -{ - quat q1(1, 2, 3, 4); - quat q2(1, 2, 3, 4); - EXPECT_FALSE(q1 != q2); - - quat q3(5, 6, 7, 8); - EXPECT_TRUE(q1 != q3); -} - -/* -TYPED_TEST(QuaternionTest, QuaternionMultiplicationVector) -{ - quat q(1, 2, 3, 4); - vec<3, TypeParam> v(1, 2, 3); - vec<3, TypeParam> result = q * v; - vec<3, TypeParam> expected(14, 22, 32); - EXPECT_EQ(result, expected); -} - -*/ - - From 42c579881046987a2e7f4416f66a0c6d38eebbf7 Mon Sep 17 00:00:00 2001 From: Ian Pike Date: Fri, 21 Jul 2023 20:49:04 -0400 Subject: [PATCH 09/14] Implement some more fixes --- include/mim/cmath.hpp | 84 +++++++++++++-------- include/mim/detail/func/func_vector3.inl | 2 +- include/mim/detail/func/func_vector4.inl | 2 +- include/mim/detail/type/type_quaternion.inl | 2 +- test/CMakeLists.txt | 2 +- test/common/cmath_tests.cpp | 80 ++++++++++++++++++++ test/common/mimMath_tests.cpp | 5 -- 7 files changed, 138 insertions(+), 39 deletions(-) create mode 100644 test/common/cmath_tests.cpp delete mode 100644 test/common/mimMath_tests.cpp diff --git a/include/mim/cmath.hpp b/include/mim/cmath.hpp index 5214036..d9ff665 100644 --- a/include/mim/cmath.hpp +++ b/include/mim/cmath.hpp @@ -11,78 +11,102 @@ #pragma once #include +#include #include namespace mim::math { template - constexpr T abs(const T& val) + [[nodiscard]] constexpr bool isnan(const T& val) noexcept { - return (val >= 0) ? val : -val; + return val != val; } template - constexpr T min(const T& a, const T& b) + [[nodiscard]] constexpr T abs(const T& val) noexcept { - static_assert(std::is_arithmetic::value, "T must be an arithmetic type."); - return (b < a) ? b : a; + return (val >= 0) ? val : -val; } template - constexpr T min(const T& a, const T& b, const Args&... args) - { - return min(min(a, b), std::forward(args)...); - } + [[nodiscard]] constexpr auto min(const T&& a, const T&& b, const Args&&... args) noexcept + -> std::enable_if_t, T> + { + if constexpr (sizeof...(args) == 0) { + return (a < b) ? std::forward(a) : std::forward(b); + } else { + return ::mim::math::min(::mim::math::min(std::forward(a), std::forward(b)), std::forward(args)...); + } + } - template - constexpr T max(const T& a, const T& b) - { - static_assert(std::is_arithmetic::value, "T must be an arithmetic type."); - return (a < b) ? b : a; - } + template + [[nodiscard]] constexpr auto min(T&& a, T&& b, Args&&... args) noexcept + -> std::enable_if_t, T> + { + if constexpr (sizeof...(args) == 0) { + return (a < b) ? std::forward(a) : std::forward(b); + } else { + return ::mim::math::min(::mim::math::min(std::forward(a), std::forward(b)), std::forward(args)...); + } + } template - constexpr T max(const T& a, const T& b, const Args&... args) + [[nodiscard]] constexpr auto max(const T&& a, const T&& b, const Args&&... args) noexcept + -> std::enable_if_t, T> { - return max(max(a, b), std::forward(args)...); + if constexpr (sizeof...(args) == 0) { + return (a < b) ? std::forward(b) : std::forward(a); + } else { + return ::mim::math::max(::mim::math::max(std::forward(a), std::forward(b)), std::forward(args)...); + } + } + template + [[nodiscard]] constexpr auto max(T&& a, T&& b, Args&&... args) noexcept + -> std::enable_if_t, T> + { + if constexpr (sizeof...(args) == 0) { + return (a < b) ? std::forward(b) : std::forward(a); + } else { + return ::mim::math::max(::mim::math::max(std::forward(a), std::forward(b)), std::forward(args)...); + } + } + namespace detail { template - constexpr bool is_close(T a, T b, T epsilon = std::numeric_limits::epsilon()) noexcept + [[nodiscard]] constexpr bool isclose(T a, T b, T epsilon = std::numeric_limits::epsilon()) noexcept { - return mim::math::abs(a - b) <= epsilon * mim::math::max(mim::math::abs(a), mim::math::abs(b)); + return ::mim::math::abs(a - b) <= epsilon * ::mim::math::max(::mim::math::abs(a), ::mim::math::abs(b)); } template - constexpr T sqrt_helper(T x, T y) noexcept + [[nodiscard]] constexpr T sqrt_helper(T x, T y) noexcept { - return is_close(x, y*y) ? y : sqrt_helper(x, (y + x/y) / 2); + return ::mim::math::detail::isclose(x, y*y) ? y : sqrt_helper(x, (y + x/y) / 2); } } - template - constexpr T clamp(const T& val, const T& min, const T& max) + [[nodiscard]] constexpr auto clamp(const T& val, const T& lo, const T& hi) noexcept + -> std::enable_if_t, T> { - return min(max(val, min), max); + return ::mim::math::min(::mim::math::max(val, lo), hi); } template - constexpr T sqrt(T x) noexcept + [[nodiscard]] constexpr T sqrt(T x) noexcept { - return detail::sqrt_helper(x, x); + return ::mim::math::detail::sqrt_helper(x, x); } template - constexpr bool is_close(T a, T b, T epsilon = std::numeric_limits::epsilon()) noexcept + [[nodiscard]] constexpr bool isclose(T a, T b, T epsilon = std::numeric_limits::epsilon()) noexcept { - return detail::is_close(a, b, epsilon); + return ::mim::math::detail::isclose(a, b, epsilon); } - - // TODO: Implement sine and cosine functions as constexpr. } // namespace mim diff --git a/include/mim/detail/func/func_vector3.inl b/include/mim/detail/func/func_vector3.inl index 2526e28..e453f27 100644 --- a/include/mim/detail/func/func_vector3.inl +++ b/include/mim/detail/func/func_vector3.inl @@ -55,7 +55,7 @@ namespace mim static_assert(std::is_floating_point::value, "Cannot normalize a non-floating-point vector."); // We want to use length_squared() over length() to avoid the use of sqrt. - return ::mim::math::is_close(length_squared(), T{ 1 }, MIM_UNIT_EPSILON); + return ::mim::math::isclose(length_squared(), T{ 1 }, MIM_UNIT_EPSILON); } template diff --git a/include/mim/detail/func/func_vector4.inl b/include/mim/detail/func/func_vector4.inl index 6947daf..3b762d8 100644 --- a/include/mim/detail/func/func_vector4.inl +++ b/include/mim/detail/func/func_vector4.inl @@ -50,7 +50,7 @@ namespace mim static_assert(std::is_floating_point::value, "Cannot normalize a non-floating-point vector."); // We want to use length_squared() over length() to avoid the use of sqrt. - return mim::math::is_close(length_squared(), T{ 1 }, MIM_UNIT_EPSILON); + return mim::math::isclose(length_squared(), T{ 1 }, MIM_UNIT_EPSILON); } template diff --git a/include/mim/detail/type/type_quaternion.inl b/include/mim/detail/type/type_quaternion.inl index 42f79e1..57b9c7c 100644 --- a/include/mim/detail/type/type_quaternion.inl +++ b/include/mim/detail/type/type_quaternion.inl @@ -142,7 +142,7 @@ namespace mim this->x -= static_cast(q.x); this->y -= static_cast(q.y); this->z -= static_cast(q.z); - return (*); + return (*this); } template diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 5dc5317..d837160 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -20,7 +20,7 @@ target_sources(mim-test PRIVATE add_executable(mim-test-common) target_sources(mim-test-common PRIVATE - common/mimMath_tests.cpp + common/cmath_tests.cpp common/random_tests.cpp ) target_link_libraries(mim-test-common PRIVATE diff --git a/test/common/cmath_tests.cpp b/test/common/cmath_tests.cpp new file mode 100644 index 0000000..e23b517 --- /dev/null +++ b/test/common/cmath_tests.cpp @@ -0,0 +1,80 @@ +// Copyright (c) 2023-Present Mim contributors (see LICENSE) + +#include +#include +#include +#include +#include + + +TEST(cmathDefaultTests, isnan) +{ + EXPECT_TRUE(mim::math::isnan(std::numeric_limits::quiet_NaN())); + EXPECT_TRUE(mim::math::isnan(std::numeric_limits::quiet_NaN())); + EXPECT_TRUE(mim::math::isnan(std::numeric_limits::quiet_NaN())); + EXPECT_FALSE(mim::math::isnan(0.0f)); + EXPECT_FALSE(mim::math::isnan(0.0)); + EXPECT_FALSE(mim::math::isnan(0.0l)); +} + +TEST(cmathDefaultTests, abs) +{ + EXPECT_EQ(mim::math::abs(0), 0); + EXPECT_EQ(mim::math::abs(0.0f), 0.0f); + EXPECT_EQ(mim::math::abs(0.0), 0.0); + EXPECT_EQ(mim::math::abs(0.0l), 0.0l); + EXPECT_EQ(mim::math::abs(-1), 1); + EXPECT_EQ(mim::math::abs(-1.0f), 1.0f); + EXPECT_EQ(mim::math::abs(-1.0), 1.0); + EXPECT_EQ(mim::math::abs(-1.0l), 1.0l); +} + +TEST(cmathDefaultTests, min) +{ + EXPECT_EQ(mim::math::min(0, 1), 0); + EXPECT_EQ(mim::math::min(1, 0), 0); + EXPECT_EQ(mim::math::min(0.0f, 1.0f), 0.0f); + EXPECT_EQ(mim::math::min(1.0f, 0.0f), 0.0f); + EXPECT_EQ(mim::math::min(0.0, 1.0), 0.0); + EXPECT_EQ(mim::math::min(1.0, 0.0), 0.0); + EXPECT_EQ(mim::math::min(0.0l, 1.0l), 0.0l); + EXPECT_EQ(mim::math::min(1.0l, 0.0l), 0.0l); + + EXPECT_EQ(mim::math::min(0, 1, 2), 0); + EXPECT_EQ(mim::math::min(1, 0, 2), 0); + EXPECT_EQ(mim::math::min(2, 1, 0, 5, 8, 19), 0); + +} + +TEST(cmathDefaultTests, max) +{ + EXPECT_EQ(mim::math::max(0, 1), 1); + EXPECT_EQ(mim::math::max(1, 0), 1); + EXPECT_EQ(mim::math::max(0.0f, 1.0f), 1.0f); + EXPECT_EQ(mim::math::max(1.0f, 0.0f), 1.0f); + EXPECT_EQ(mim::math::max(0.0, 1.0), 1.0); + EXPECT_EQ(mim::math::max(1.0, 0.0), 1.0); + EXPECT_EQ(mim::math::max(0.0l, 1.0l), 1.0l); + EXPECT_EQ(mim::math::max(1.0l, 0.0l), 1.0l); + + EXPECT_EQ(mim::math::max(0, 1, 2), 2); + EXPECT_EQ(mim::math::max(1, 0, 2), 2); + EXPECT_EQ(mim::math::max(2, 1, 0, 5, 8, 19), 19); +} +/* +TEST(cmathDefaultTests, clamp) +{ + EXPECT_EQ(mim::math::clamp(0, 1, 2), 1); + EXPECT_EQ(mim::math::clamp(1, 0, 2), 1); + EXPECT_EQ(mim::math::clamp(2, 0, 1), 1); + EXPECT_EQ(mim::math::clamp(0.0f, 1.0f, 2.0f), 1.0f); + EXPECT_EQ(mim::math::clamp(1.0f, 0.0f, 2.0f), 1.0f); + EXPECT_EQ(mim::math::clamp(2.0f, 0.0f, 1.0f), 1.0f); + EXPECT_EQ(mim::math::clamp(0.0, 1.0, 2.0), 1.0); + EXPECT_EQ(mim::math::clamp(1.0, 0.0, 2.0), 1.0); + EXPECT_EQ(mim::math::clamp(2.0, 0.0, 1.0), 1.0); + EXPECT_EQ(mim::math::clamp(0.0l, 1.0l, 2.0l), 1.0l); + EXPECT_EQ(mim::math::clamp(1.0l, 0.0l, 2.0l), 1.0l); + EXPECT_EQ(mim::math::clamp(2.0l, 0.0l, 1.0l), 1.0l); +} +*/ diff --git a/test/common/mimMath_tests.cpp b/test/common/mimMath_tests.cpp deleted file mode 100644 index 8907a1b..0000000 --- a/test/common/mimMath_tests.cpp +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright (c) 2023-Present Mim contributors (see LICENSE) - -#include - - From 6479ca1f695284a27ef192eda83476ac96ca8c75 Mon Sep 17 00:00:00 2001 From: Ian Pike Date: Tue, 1 Aug 2023 15:37:40 -0400 Subject: [PATCH 10/14] Add more test cases --- test/common/cmath_tests.cpp | 4 +- test/quat/quat_tests.cpp | 78 +++++++++++++++++++++++++++++++++++++ 2 files changed, 80 insertions(+), 2 deletions(-) diff --git a/test/common/cmath_tests.cpp b/test/common/cmath_tests.cpp index e23b517..108e931 100644 --- a/test/common/cmath_tests.cpp +++ b/test/common/cmath_tests.cpp @@ -61,7 +61,7 @@ TEST(cmathDefaultTests, max) EXPECT_EQ(mim::math::max(1, 0, 2), 2); EXPECT_EQ(mim::math::max(2, 1, 0, 5, 8, 19), 19); } -/* + TEST(cmathDefaultTests, clamp) { EXPECT_EQ(mim::math::clamp(0, 1, 2), 1); @@ -77,4 +77,4 @@ TEST(cmathDefaultTests, clamp) EXPECT_EQ(mim::math::clamp(1.0l, 0.0l, 2.0l), 1.0l); EXPECT_EQ(mim::math::clamp(2.0l, 0.0l, 1.0l), 1.0l); } -*/ + diff --git a/test/quat/quat_tests.cpp b/test/quat/quat_tests.cpp index 6588ab4..4c0b251 100644 --- a/test/quat/quat_tests.cpp +++ b/test/quat/quat_tests.cpp @@ -14,3 +14,81 @@ TEST(QuaternionDefaultTests, DefaultConstructor) EXPECT_EQ(q.z, 0.0f); } +TEST(QuaternionDefaultTests, CheckSizeOfDataStructure) +{ + mim::quat q; + EXPECT_EQ(sizeof(q), 16); +} + +TEST(QuaternionDefaultTests, Size) +{ + mim::quat q; + EXPECT_EQ(q.size(), 4); +} + +TEST(QuaternionDefaultTests, ArrayAccessor) +{ + mim::quat q; + EXPECT_EQ(q[0], 1.0f); + EXPECT_EQ(q[1], 0.0f); + EXPECT_EQ(q[2], 0.0f); + EXPECT_EQ(q[3], 0.0f); +} + +TEST(QuaternionDefaultTests, At) +{ + mim::quat q; + EXPECT_EQ(q.at(0), 1.0f); + EXPECT_EQ(q.at(1), 0.0f); + EXPECT_EQ(q.at(2), 0.0f); + EXPECT_EQ(q.at(3), 0.0f); +} + +TEST(QuaternionDefaultTests, QuatConstructor) +{ + mim::quat q1(1.0f, 2.0f, 3.0f, 4.0f); + mim::quat q2(q1); + + EXPECT_EQ(q2.w, 1.0f); + EXPECT_EQ(q2.x, 2.0f); + EXPECT_EQ(q2.y, 3.0f); + EXPECT_EQ(q2.z, 4.0f); +} + +TEST(QuaternionDefaultTests, QuatConstructorWithQualifier) +{ + mim::quat q1(1.0f, 2.0f, 3.0f, 4.0f); + mim::quat q2(q1); + + EXPECT_EQ(q2.w, 1.0f); + EXPECT_EQ(q2.x, 2.0f); + EXPECT_EQ(q2.y, 3.0f); + EXPECT_EQ(q2.z, 4.0f); +} + +TEST(QuaternionDefaultTests, QuatConstructorWithVecAndW) +{ + mim::vec<3, float> v(1.0f, 2.0f, 3.0f); + mim::quat q(4.0f, v); + + EXPECT_EQ(q.w, 4.0f); + EXPECT_EQ(q.x, 1.0f); + EXPECT_EQ(q.y, 2.0f); + EXPECT_EQ(q.z, 3.0f); +} + +// TODO: Add tests for mat type conversion + +/* Broken at moment +TEST(QuaternionDefaultTests, QuatConstructorWithVec3s) +{ + const mim::vec<3, float> v1(1.0f, 2.0f, 3.0f); + const mim::vec<3, float> v2(4.0f, 5.0f, 6.0f); + mim::quat q(v1, v2); + + EXPECT_EQ(q.w, -28.0f); + EXPECT_EQ(q.x, 4.0f); + EXPECT_EQ(q.y, 5.0f); + EXPECT_EQ(q.z, 6.0f); +} +*/ From 739d09a19f9842d6a53d57195e6f64866eee2c0a Mon Sep 17 00:00:00 2001 From: Ian Pike Date: Tue, 1 Aug 2023 15:38:12 -0400 Subject: [PATCH 11/14] Bug fixes galore! --- include/mim/cmath.hpp | 29 +++++++++++---- include/mim/detail/type/type_quaternion.hpp | 39 ++++++++++++++------- include/mim/detail/type/type_quaternion.inl | 1 + include/mim/detail/type/type_vector1.inl | 2 +- include/mim/mimConstants.hpp | 20 ++++++----- 5 files changed, 63 insertions(+), 28 deletions(-) diff --git a/include/mim/cmath.hpp b/include/mim/cmath.hpp index d9ff665..d51ba85 100644 --- a/include/mim/cmath.hpp +++ b/include/mim/cmath.hpp @@ -14,8 +14,13 @@ #include #include +#include "mim/mimConstants.hpp" + namespace mim::math { + + + template [[nodiscard]] constexpr bool isnan(const T& val) noexcept { @@ -25,12 +30,11 @@ namespace mim::math template [[nodiscard]] constexpr T abs(const T& val) noexcept { - return (val >= 0) ? val : -val; + return val == 0 ? 0 : (val < 0 ? -val : val); } template [[nodiscard]] constexpr auto min(const T&& a, const T&& b, const Args&&... args) noexcept - -> std::enable_if_t, T> { if constexpr (sizeof...(args) == 0) { return (a < b) ? std::forward(a) : std::forward(b); @@ -41,7 +45,6 @@ namespace mim::math template [[nodiscard]] constexpr auto min(T&& a, T&& b, Args&&... args) noexcept - -> std::enable_if_t, T> { if constexpr (sizeof...(args) == 0) { return (a < b) ? std::forward(a) : std::forward(b); @@ -52,7 +55,6 @@ namespace mim::math template [[nodiscard]] constexpr auto max(const T&& a, const T&& b, const Args&&... args) noexcept - -> std::enable_if_t, T> { if constexpr (sizeof...(args) == 0) { return (a < b) ? std::forward(b) : std::forward(a); @@ -64,7 +66,6 @@ namespace mim::math template [[nodiscard]] constexpr auto max(T&& a, T&& b, Args&&... args) noexcept - -> std::enable_if_t, T> { if constexpr (sizeof...(args) == 0) { return (a < b) ? std::forward(b) : std::forward(a); @@ -90,7 +91,6 @@ namespace mim::math template [[nodiscard]] constexpr auto clamp(const T& val, const T& lo, const T& hi) noexcept - -> std::enable_if_t, T> { return ::mim::math::min(::mim::math::max(val, lo), hi); } @@ -107,6 +107,23 @@ namespace mim::math return ::mim::math::detail::isclose(a, b, epsilon); } + namespace detail + { + template + [[nodiscard]] constexpr T compute_sine(const T x) noexcept + { + T{2} * x / (T{1} + x * x); + } + + template + [[nodiscard]] constexpr T sin_impl(const T x) noexcept + { + return + ::mim::math::isnan(x) ? + std::numeric_limits::quiet_NaN() : std::numeric_limits::min() + } + } + // TODO: Implement sine and cosine functions as constexpr. } // namespace mim diff --git a/include/mim/detail/type/type_quaternion.hpp b/include/mim/detail/type/type_quaternion.hpp index 66a46da..b21f116 100644 --- a/include/mim/detail/type/type_quaternion.hpp +++ b/include/mim/detail/type/type_quaternion.hpp @@ -19,25 +19,40 @@ namespace mim static constexpr auto size() { return sizeV; } - constexpr T& operator[](size_type i) + constexpr T& operator[](const size_type i) { - static_assert(i < size(), "Out of range: quat::operator[]"); - - return (&w)[i]; + switch (i) + { + default: // TODO: Should we make this throw an exception as the default case? + case 0: return w; + case 1: return x; + case 2: return y; + case 3: return z; + } } - constexpr T const& operator[](size_type i) const + constexpr T const& operator[](const size_type i) const { - static_assert(i < size(), "Out of range: quat::operator[]"); - - return (&w)[i]; + switch (i) + { + default: // TODO: Should we make this throw an exception as the default case? + case 0: return w; + case 1: return x; + case 2: return y; + case 3: return z; + } } - constexpr T const& at(size_type i) const + constexpr T const& at(const size_type i) const { - static_assert(i < size(), "Out of range: quat::at"); - - return (&w)[i]; + switch (i) + { + default: // TODO: Should we make this throw an exception as the default case? + case 0: return w; + case 1: return x; + case 2: return y; + case 3: return z; + } } diff --git a/include/mim/detail/type/type_quaternion.inl b/include/mim/detail/type/type_quaternion.inl index 57b9c7c..3e77663 100644 --- a/include/mim/detail/type/type_quaternion.inl +++ b/include/mim/detail/type/type_quaternion.inl @@ -67,6 +67,7 @@ namespace mim return mat<4, 4, T, Q>(); } + // TODO: This is currently broken. template quat::quat(const vec<3, T, Q>& a1, const vec<3, T, Q>& a2) { diff --git a/include/mim/detail/type/type_vector1.inl b/include/mim/detail/type/type_vector1.inl index 4fb0114..63f90b2 100644 --- a/include/mim/detail/type/type_vector1.inl +++ b/include/mim/detail/type/type_vector1.inl @@ -23,7 +23,7 @@ namespace mim template T& vec<1, T, Q>::at(typename vec<1, T, Q>::size_type i) { - static_assert(i < size(), "vec<1, T, Q>::at() : Index out of range."); + static_assert(i < this->size(), "vec<1, T, Q>::at() : Index out of range."); return x; } diff --git a/include/mim/mimConstants.hpp b/include/mim/mimConstants.hpp index 85bb5f6..ca7a02b 100644 --- a/include/mim/mimConstants.hpp +++ b/include/mim/mimConstants.hpp @@ -19,18 +19,20 @@ namespace mim * Mathematical constants */ - template inline constexpr T MIM_PI = static_cast(3.14159265358979323846); //!< pi - template inline constexpr T MIM_2PI = static_cast(6.28318530717958647693); //!< 2 * pi - template inline constexpr T MIM_4PI = static_cast(12.5663706143591729539); //!< 4 * pi - template inline constexpr T MIM_PI_2 = static_cast(1.57079632679489661923); //!< pi / 2 - template inline constexpr T MIM_PI_4 = static_cast(0.785398163397448309616); //!< pi / 4 - template inline constexpr T MIM_TAU = static_cast(6.28318530717958647693); //!< tau - template inline constexpr T MIM_E = static_cast(2.71828182845904523536); //!< e + template inline constexpr T MIM_PI = static_cast(3.1415926535897932384626433832795028841972L); //!< pi + template inline constexpr T MIM_2PI = static_cast(6.2831853071795864769252867665590057683943L); //!< 2 * pi + template inline constexpr T MIM_4PI = static_cast(12.566370614359172953850573533118011536789L); //!< 4 * pi + template inline constexpr T MIM_HALF_PI = static_cast(1.5707963267948966192313216916397514420986L); //!< pi / 2 + template inline constexpr T MIM_QUARTER_PI = static_cast(0.78539816339744830961566084581987572104929L); //!< pi / 4 + template inline constexpr T MIM_TAU = static_cast(6.2831853071795864769252867665590057683943L); //!< tau + template inline constexpr T MIM_E = static_cast(2.7182818284590452353602874713526624977572L); //!< e template inline constexpr T MIM_SQRT2 = static_cast(1.41421356237309504880); //!< sqrt(2) template inline constexpr T MIM_LOG2E = static_cast(1.44269504088896340736); //!< 1 / log(2) template inline constexpr T MIM_LOG10E = static_cast(0.434294481903251827651); //!< 1 / log(10) - template inline constexpr T MIM_LOG210 = static_cast(3.321928094887362347808); //!< log2(10) - template inline constexpr T MIM_LN2 = static_cast(0.693147180559945309417); //!< log(2) + template inline constexpr T MIM_LOG2_10 = static_cast(3.321928094887362347808); //!< log2(10) + template inline constexpr T MIM_LOG2 = static_cast(0.693147180559945309417); //!< log(2) + template inline constexpr T MIM_NLOG10 = static_cast(2.3025850929940456840179914546843642076011L); //!< ln(10) + template inline constexpr T MIM_SMALLEST_NORMAL = static_cast(2.2250738585072014E-308); //!< smallest normal number template <> inline constexpr double MIM_SMALLEST_NORMAL = 2.2250738585072014E-308; //!< smallest normal number, double From 79e53d7f947a88d7085197545283522f039c41cf Mon Sep 17 00:00:00 2001 From: Ian Pike Date: Tue, 1 Aug 2023 22:53:44 -0400 Subject: [PATCH 12/14] Fix dependency conflict with clang 16 --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 504d3fc..111269b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -15,7 +15,7 @@ jobs: - name: install g++11 and ninja run: sudo apt install -yqq ninja-build g++-11 - name: update to clang 16 - run: sudo wget https://apt.llvm.org/llvm.sh && sudo chmod +x llvm.sh && sudo ./llvm.sh 16 + run: sudo apt --purge remove python3-lldb-14 && sudo wget https://apt.llvm.org/llvm.sh && sudo chmod +x llvm.sh && sudo ./llvm.sh 16 - name: configure gcc run: cmake -S . --preset=default -B build -DCMAKE_CXX_COMPILER=g++-11 - name: configure clang From a7e76074f918db2b5ff9029f3a0eee75709a28c5 Mon Sep 17 00:00:00 2001 From: Ian Pike Date: Fri, 4 Aug 2023 19:29:47 -0400 Subject: [PATCH 13/14] Update cmath.hpp --- include/mim/cmath.hpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/include/mim/cmath.hpp b/include/mim/cmath.hpp index d51ba85..dd45c7b 100644 --- a/include/mim/cmath.hpp +++ b/include/mim/cmath.hpp @@ -119,8 +119,7 @@ namespace mim::math [[nodiscard]] constexpr T sin_impl(const T x) noexcept { return - ::mim::math::isnan(x) ? - std::numeric_limits::quiet_NaN() : std::numeric_limits::min() + ::mim::math::isnan(x) ? std::numeric_limits::quiet_NaN() : std::numeric_limits::min(); } } From 027a7090bf10ebbf839b343ae5336bbe46356111 Mon Sep 17 00:00:00 2001 From: ian Date: Sun, 20 Aug 2023 19:09:24 -0400 Subject: [PATCH 14/14] Small updates to readme --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index c891daf..10f9018 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ - Nearly completely header only. - Various utility functions for common math operations. - Lightweight and portable. No external dependencies. -- Using modern C++20 features. +- Using modern C++ with support for C++17 and C++20. > Mim is still in development and not ready for production use. Expect many bugs and missing features. Along with constant API change till we reach a stable release! @@ -24,7 +24,7 @@ ### Technology Used -- C++20 +- C++17 & C++20 - Cmake 3.18 (may reduce) - Doxygen (planned) - Cppcheck