diff --git a/untests/vmath_fix_tests.cpp b/untests/vmath_fix_tests.cpp new file mode 100644 index 0000000..d20ace1 --- /dev/null +++ b/untests/vmath_fix_tests.cpp @@ -0,0 +1,946 @@ +/******************************************************************************* + * This file is part of the "https://github.com/blackmatov/vmath.hpp" + * For conditions of distribution and use, see copyright notice in LICENSE.md + * Copyright (C) 2020-2021, by Matvey Cherevko (blackmatov@gmail.com) + ******************************************************************************/ + +#include "vmath_tests.hpp" + +namespace +{ + using namespace vmath_hpp; + using namespace vmath_tests; + + template < typename T > + class fix { + public: + fix() = default; + + fix(fix&&) = default; + fix& operator=(fix&&) = default; + + fix(const fix&) = default; + fix& operator=(const fix&) = default; + + constexpr explicit fix(T underlying): underlying_(underlying) {} + constexpr T underlying() const noexcept { return underlying_; } + + constexpr friend fix abs(const fix& l) { return { fix{abs(l.underlying())} }; } + constexpr friend fix sqr(const fix& l) { return { fix{sqr(l.underlying())} }; } + constexpr friend fix sign(const fix& l) { return { fix{sign(l.underlying())} }; } + + constexpr friend fix rcp(const fix& l) { return { fix{rcp(l.underlying())} }; } + constexpr friend fix floor(const fix& l) { return { fix{floor(l.underlying())} }; } + constexpr friend fix trunc(const fix& l) { return { fix{trunc(l.underlying())} }; } + constexpr friend fix round(const fix& l) { return { fix{round(l.underlying())} }; } + constexpr friend fix ceil(const fix& l) { return { fix{ceil(l.underlying())} }; } + constexpr friend fix fract(const fix& l) { return { fix{fract(l.underlying())} }; } + + constexpr friend fix fmod(const fix& l, const fix& r) { return { fix{fmod(l.underlying(), r.underlying())} }; } + constexpr friend fix copysign(const fix& l, const fix& r) { return { fix{copysign(l.underlying(), r.underlying())} }; } + + constexpr friend fix min(const fix& l, const fix& r) { return fix{min(l.underlying(), r.underlying())}; } + constexpr friend fix max(const fix& l, const fix& r) { return fix{max(l.underlying(), r.underlying())}; } + constexpr friend fix clamp(const fix& l, const fix& min_l, const fix& max_l) { return fix{clamp(l.underlying(), min_l.underlying(), max_l.underlying())}; } + constexpr friend fix saturate(const fix& l) { return fix{saturate(l.underlying())}; } + constexpr friend fix lerp(const fix& l, const fix& r, const fix& a) { return fix{lerp(l.underlying(), r.underlying(), a.underlying())}; } + constexpr friend fix lerp(const fix& l, const fix& r, const fix& a, const fix& b) { return fix{lerp(l.underlying(), r.underlying(), a.underlying(), b.underlying())}; } + + constexpr friend fix step(const fix& e, const fix& l) { return fix{step(e.underlying(), l.underlying())}; } + constexpr friend fix smoothstep(const fix& e0, const fix& e1, const fix& l) { return fix{smoothstep(e0.underlying(), e1.underlying(), l.underlying())}; } + + constexpr friend fix fma(const fix& x, const fix& y, const fix& z) { return fix{fma(x.underlying(), y.underlying(), z.underlying())}; } + + // + + constexpr friend fix any(const fix& l) { return fix{any(l.underlying())}; } + constexpr friend fix all(const fix& l) { return fix{all(l.underlying())}; } + + constexpr friend fix approx(const fix& l, const fix& r) { return fix{approx(l.underlying(), r.underlying())}; } + constexpr friend fix approx(const fix& l, const fix& r, const fix& e) { return fix{approx(l.underlying(), r.underlying(), e.underlying())}; } + + constexpr friend fix less(const fix& l, const fix& r) { return fix{less(l.underlying(), r.underlying())}; } + constexpr friend fix less_equal(const fix& l, const fix& r) { return fix{less_equal(l.underlying(), r.underlying())}; } + constexpr friend fix greater(const fix& l, const fix& r) { return fix{greater(l.underlying(), r.underlying())}; } + constexpr friend fix greater_equal(const fix& l, const fix& r) { return fix{greater_equal(l.underlying(), r.underlying())}; } + constexpr friend fix equal_to(const fix& l, const fix& r) { return fix{equal_to(l.underlying(), r.underlying())}; } + constexpr friend fix not_equal_to(const fix& l, const fix& r) { return fix{not_equal_to(l.underlying(), r.underlying())}; } + + // + + constexpr friend fix radians(const fix& l) { return fix{radians(l.underlying())}; } + constexpr friend fix degrees(const fix& l) { return fix{degrees(l.underlying())}; } + friend fix sin(const fix& l) { return fix{sin(l.underlying())}; } + friend fix cos(const fix& l) { return fix{cos(l.underlying())}; } + friend fix tan(const fix& l) { return fix{tan(l.underlying())}; } + friend fix asin(const fix& l) { return fix{asin(l.underlying())}; } + friend fix acos(const fix& l) { return fix{acos(l.underlying())}; } + friend fix atan(const fix& l) { return fix{atan(l.underlying())}; } + friend fix atan2(const fix& l, const fix& r) { return fix{atan2(l.underlying(), r.underlying())}; } + friend fix sinh(const fix& l) { return fix{sinh(l.underlying())}; } + friend fix cosh(const fix& l) { return fix{cosh(l.underlying())}; } + friend fix tanh(const fix& l) { return fix{tanh(l.underlying())}; } + friend fix asinh(const fix& l) { return fix{asinh(l.underlying())}; } + friend fix acosh(const fix& l) { return fix{acosh(l.underlying())}; } + friend fix atanh(const fix& l) { return fix{atanh(l.underlying())}; } + friend std::pair sincos(const fix& l) { return { sin(l), cos(l) }; } + friend void sincos(const fix& l, fix* s, fix* c) { *s = sin(l); *c = cos(l); } + + // + + friend fix pow(const fix& l, const fix& r) { return fix{pow(l.underlying(), r.underlying())}; } + friend fix exp(const fix& l) { return fix{exp(l.underlying())}; } + friend fix log(const fix& l) { return fix{log(l.underlying())}; } + friend fix exp2(const fix& l) { return fix{exp2(l.underlying())}; } + friend fix log2(const fix& l) { return fix{log2(l.underlying())}; } + friend fix sqrt(const fix& l) { return fix{sqrt(l.underlying())}; } + friend fix rsqrt(const fix& l) { return fix{rsqrt(l.underlying())}; } + + // + + constexpr friend fix operator+(const fix& l) { return { fix{+l.underlying()} }; } + constexpr friend fix operator-(const fix& l) { return { fix{-l.underlying()} }; } + constexpr friend fix operator~(const fix& l) { return { fix{~l.underlying()} }; } + constexpr friend fix operator!(const fix& l) { return { fix{!l.underlying()} }; } + + constexpr friend fix operator+(const fix& l, const fix& r) { return fix{l.underlying() + r.underlying()}; } + constexpr friend fix operator-(const fix& l, const fix& r) { return fix{l.underlying() - r.underlying()}; } + constexpr friend fix operator*(const fix& l, const fix& r) { return fix{l.underlying() * r.underlying()}; } + constexpr friend fix operator/(const fix& l, const fix& r) { return fix{l.underlying() / r.underlying()}; } + + constexpr friend fix operator&(const fix& l, const fix& r) { return fix{l.underlying() & r.underlying()}; } + constexpr friend fix operator|(const fix& l, const fix& r) { return fix{l.underlying() | r.underlying()}; } + constexpr friend fix operator^(const fix& l, const fix& r) { return fix{l.underlying() ^ r.underlying()}; } + + constexpr friend fix operator&&(const fix& l, const fix& r) { return fix{l.underlying() && r.underlying()}; } + constexpr friend fix operator||(const fix& l, const fix& r) { return fix{l.underlying() || r.underlying()}; } + + constexpr friend bool operator<(const fix& l, const fix& r) { return l.underlying() < r.underlying(); } + constexpr friend bool operator==(const fix& l, const fix& r) { return l.underlying() == r.underlying(); } + constexpr friend bool operator!=(const fix& l, const fix& r) { return l.underlying() != r.underlying(); } + private: + T underlying_{}; + }; + + using qfix = qua>; + + using fix2b = vec, 2>; + using fix3b = vec, 3>; + using fix4b = vec, 4>; + + using fix2i = vec, 2>; + using fix3i = vec, 3>; + using fix4i = vec, 4>; + + using fix2f = vec, 2>; + using fix3f = vec, 3>; + using fix4f = vec, 4>; + + using fix2x2b = mat, 2>; + using fix3x3b = mat, 3>; + using fix4x4b = mat, 4>; + + using fix2x2i = mat, 2>; + using fix3x3i = mat, 3>; + using fix4x4i = mat, 4>; + + using fix2x2f = mat, 2>; + using fix3x3f = mat, 3>; + using fix4x4f = mat, 4>; +} + +// +// Common Functions +// + +namespace vmath_hpp +{ + template fix2f abs(const fix2f&); + template fix2f sqr(const fix2f&); + template fix2f sign(const fix2f&); + + template fix2f rcp(const fix2f&); + template fix2f floor(const fix2f&); + template fix2f trunc(const fix2f&); + template fix2f round(const fix2f&); + template fix2f ceil(const fix2f&); + template fix2f fract(const fix2f&); + + template fix2f fmod(const fix2f&, fix); + template fix2f fmod(const fix2f&, const fix2f&); + + template fix2f copysign(const fix2f&, fix); + template fix2f copysign(const fix2f&, const fix2f&); + + template fix min(const fix2f&); + template fix2f min(const fix2f&, fix); + template fix2f min(fix, const fix2f&); + template fix2f min(const fix2f&, const fix2f&); + + template fix max(const fix2f&); + template fix2f max(const fix2f&, fix); + template fix2f max(fix, const fix2f&); + template fix2f max(const fix2f&, const fix2f&); + + template fix2f clamp(const fix2f&, fix, fix); + template fix2f clamp(const fix2f&, const fix2f&, const fix2f&); + + template fix2f saturate(const fix2f&); + + template fix2f lerp(const fix2f&, const fix2f&, fix); + template fix2f lerp(const fix2f&, const fix2f&, fix, fix); + template fix2f lerp(const fix2f&, const fix2f&, const fix2f&); + template fix2f lerp(const fix2f&, const fix2f&, const fix2f&, const fix2f&); + + template fix2f step(fix, const fix2f&); + template fix2f step(const fix2f&, const fix2f&); + template fix2f smoothstep(fix, fix, const fix2f&); + template fix2f smoothstep(const fix2f&, const fix2f&, const fix2f&); + + template fix2f fma(const fix2f&, const fix2f&, const fix2f&); +} + +namespace vmath_hpp +{ + template qfix lerp(const qfix&, const qfix&, fix); + template qfix lerp(const qfix&, const qfix&, fix, fix); + template qfix nlerp(const qfix&, const qfix&, fix); + template qfix slerp(const qfix&, const qfix&, fix); +} + +// +// Angle and Trigonometric Functions +// + +namespace vmath_hpp +{ + template fix2f radians(const fix2f&); + template fix2f degrees(const fix2f&); + template fix2f sin(const fix2f&); + template fix2f cos(const fix2f&); + template fix2f tan(const fix2f&); + template fix2f asin(const fix2f&); + template fix2f acos(const fix2f&); + template fix2f atan(const fix2f&); + template fix2f atan2(const fix2f&, const fix2f&); + template fix2f sinh(const fix2f&); + template fix2f cosh(const fix2f&); + template fix2f tanh(const fix2f&); + template fix2f asinh(const fix2f&); + template fix2f acosh(const fix2f&); + template fix2f atanh(const fix2f&); + template std::pair sincos(const fix2f&); + template void sincos(const fix2f&, fix2f*, fix2f*); +} + +// +// Exponential Functions +// + +namespace vmath_hpp +{ + template fix2f pow(const fix2f&, const fix2f&); + template fix2f exp(const fix2f&); + template fix2f log(const fix2f&); + template fix2f exp2(const fix2f&); + template fix2f log2(const fix2f&); + template fix2f sqrt(const fix2f&); + template fix2f rsqrt(const fix2f&); +} + +// +// Geometric Functions +// + +namespace vmath_hpp +{ + template fix dot(const fix2f&, const fix2f&); + template fix length(const fix2f&); + template fix length2(const fix2f&); + template fix distance(const fix2f&, const fix2f&); + template fix distance2(const fix2f&, const fix2f&); + template fix cross(const fix2f&, const fix2f&); + template fix3f cross(const fix3f&, const fix3f&); + template fix2f normalize(const fix2f&); +} + +namespace vmath_hpp +{ + template fix dot(const qfix&, const qfix&); + template fix length(const qfix&); + template fix length2(const qfix&); + template fix distance(const qfix&, const qfix&); + template qfix normalize(const qfix&); +} + +// +// Relational Functions +// + +namespace vmath_hpp +{ + template fix any(const fix2f&); + template fix all(const fix2f&); + template fix2b approx(const fix2f&, const fix2f&); + template fix2b approx(const fix2f&, const fix2f&, fix); + template fix2b less(const fix2f&, const fix2f&); + template fix2b less_equal(const fix2f&, const fix2f&); + template fix2b greater(const fix2f&, const fix2f&); + template fix2b greater_equal(const fix2f&, const fix2f&); + template fix2b equal_to(const fix2f&, const fix2f&); + template fix2b not_equal_to(const fix2f&, const fix2f&); +} + +namespace vmath_hpp +{ + template fix any(const fix2x2f&); + template fix all(const fix2x2f&); + template fix2x2b approx(const fix2x2f&, const fix2x2f&); + template fix2x2b approx(const fix2x2f&, const fix2x2f&, fix); + template fix2x2b less(const fix2x2f&, const fix2x2f&); + template fix2x2b less_equal(const fix2x2f&, const fix2x2f&); + template fix2x2b greater(const fix2x2f&, const fix2x2f&); + template fix2x2b greater_equal(const fix2x2f&, const fix2x2f&); + template fix2x2b equal_to(const fix2x2f&, const fix2x2f&); + template fix2x2b not_equal_to(const fix2x2f&, const fix2x2f&); +} + +namespace vmath_hpp +{ + template fix any(const qfix&); + template fix all(const qfix&); + template fix4b approx(const qfix&, const qfix&); + template fix4b approx(const qfix&, const qfix&, fix); + template fix4b less(const qfix&, const qfix&); + template fix4b less_equal(const qfix&, const qfix&); + template fix4b greater(const qfix&, const qfix&); + template fix4b greater_equal(const qfix&, const qfix&); + template fix4b equal_to(const qfix&, const qfix&); + template fix4b not_equal_to(const qfix&, const qfix&); +} + +// +// Matrix Functions +// + +namespace vmath_hpp +{ + template fix2x2f transpose(const fix2x2f&); + template fix3x3f transpose(const fix3x3f&); + template fix4x4f transpose(const fix4x4f&); + + template fix determinant(const fix2x2f&); + template fix determinant(const fix3x3f&); + template fix determinant(const fix4x4f&); + + template fix2x2f inverse(const fix2x2f&); + template fix3x3f inverse(const fix3x3f&); + template fix4x4f inverse(const fix4x4f&); +} + +// +// Quaternion Functions +// + +namespace vmath_hpp +{ + template qfix conjugate(const qfix&); + template qfix inverse(const qfix&); +} + +// +// Access +// + +namespace vmath_hpp +{ + template fix component(const fix2f&, std::size_t); + template fix2f component(fix2f, std::size_t, fix); + + template fix2f row(const fix2x2f&, std::size_t); + template fix2x2f row(fix2x2f, std::size_t, const fix2f&); + + template fix2f column(const fix2x2f&, std::size_t); + template fix2x2f column(const fix2x2f&, std::size_t, const fix2f&); + + template fix real(const qfix&); + template qfix real(qfix, fix); + + template fix3f imag(const qfix&); + template qfix imag(qfix, const fix3f&); +} + +// +// Matrix Transform 3D +// + +namespace vmath_hpp +{ + template fix4x4f translate(fix x, fix y, fix z); + template fix4x4f translate(const fix4x4f&, fix, fix, fix); + template fix4x4f translate(const fix3f&); + template fix4x4f translate(const fix4x4f&, const fix3f&); + + template fix4x4f rotate(const qfix&); + template fix4x4f rotate(const fix4x4f&, const qfix&); + template fix4x4f rotate(fix, const fix3f&); + template fix4x4f rotate(const fix4x4f&, fix, const fix3f&); + + template fix4x4f rotate_x(fix); + template fix4x4f rotate_x(const fix4x4f&, fix); + + template fix4x4f rotate_y(fix); + template fix4x4f rotate_y(const fix4x4f&, fix); + + template fix4x4f rotate_z(fix); + template fix4x4f rotate_z(const fix4x4f&, fix); + + template fix4x4f scale(fix, fix, fix); + template fix4x4f scale(const fix4x4f&, fix, fix, fix); + template fix4x4f scale(const fix3f&); + template fix4x4f scale(const fix4x4f&, const fix3f&); + + template fix4x4f look_at_lh(const fix3f&, const fix3f&, const fix3f&); + template fix4x4f look_at_rh(const fix3f&, const fix3f&, const fix3f&); +} + +// +// Matrix Transform 2D +// + +namespace vmath_hpp +{ + template fix3x3f translate(fix, fix); + template fix3x3f translate(const fix3x3f&, fix, fix); + template fix3x3f translate(const fix2f&); + template fix3x3f translate(const fix3x3f&, const fix2f&); + + template fix3x3f rotate(fix); + template fix3x3f rotate(const fix3x3f&, fix); + + template fix3x3f scale(fix, fix); + template fix3x3f scale(const fix3x3f&, fix, fix); + template fix3x3f scale(const fix2f&); + template fix3x3f scale(const fix3x3f&, const fix2f&); + + template fix3x3f shear(fix, fix); + template fix3x3f shear(const fix3x3f&, fix, fix); + template fix3x3f shear(const fix2f&); + template fix3x3f shear(const fix3x3f&, const fix2f&); + + template fix3x3f shear_x(fix); + template fix3x3f shear_x(const fix3x3f&, fix); + + template fix3x3f shear_y(fix); + template fix3x3f shear_y(const fix3x3f&, fix); +} + +// +// Matrix Projections +// + +namespace vmath_hpp +{ + template fix4x4f orthographic_lh(fix, fix, fix, fix); + template fix4x4f orthographic_rh(fix, fix, fix, fix); + + template fix4x4f orthographic_lh(fix, fix, fix, fix, fix, fix); + template fix4x4f orthographic_rh(fix, fix, fix, fix, fix, fix); + + template fix4x4f perspective_lh(fix, fix, fix, fix); + template fix4x4f perspective_rh(fix, fix, fix, fix); + + template fix4x4f perspective_lh(fix, fix, fix, fix, fix, fix); + template fix4x4f perspective_rh(fix, fix, fix, fix, fix, fix); + + template fix4x4f perspective_fov_lh(fix, fix, fix, fix); + template fix4x4f perspective_fov_rh(fix, fix, fix, fix); +} + +// +// Vector Transform +// + +namespace vmath_hpp +{ + template fix angle(const fix3f&, const fix3f&); + template fix2f rotate(const fix2f&, fix); + template fix3f rotate_x(const fix3f&, fix); + template fix3f rotate_y(const fix3f&, fix); + template fix3f rotate_z(const fix3f&, fix); + template fix3f rotate(const fix3f&, const qfix&); + template fix3f rotate(const fix3f&, fix, const fix3f&); + template fix3f project(const fix3f&, const fix3f&); + template fix3f perpendicular(const fix3f&, const fix3f&); +} + +// +// Quaternion Transform +// + +namespace vmath_hpp +{ + template qfix qrotate(const fix3x3f&); + template qfix qrotate(const qfix&, const fix3x3f&); + + template qfix qrotate(const fix3f&, const fix3f&); + template qfix qrotate(const qfix&, const fix3f&, const fix3f&); + + template qfix qrotate(fix, const fix3f&); + template qfix qrotate(const qfix&, fix, const fix3f&); + + template qfix qrotate_x(fix); + template qfix qrotate_x(const qfix&, fix); + + template qfix qrotate_y(fix); + template qfix qrotate_y(const qfix&, fix); + + template qfix qrotate_z(fix); + template qfix qrotate_z(const qfix&, fix); + + template qfix qlook_at_lh(const fix3f&, const fix3f&); + template qfix qlook_at_rh(const fix3f&, const fix3f&); +} + +// +// fix_vec +// + +TEST_CASE("vmath/fix_vec") { + SUBCASE("fix2 ctors") { + constexpr fix2i v0{}; + constexpr fix2i v1{fix(1)}; + constexpr fix2i v2{fix(1), fix(2)}; + constexpr fix2i v3{fix3i{fix(1), fix(2), fix(3)}}; + constexpr fix2i v4{fix4i{fix(1), fix(2), fix(3), fix(4)}}; + + STATIC_CHECK((v0[0] == fix(0))); + STATIC_CHECK((v1[0] == fix(1) && v1[1] == fix(1))); + STATIC_CHECK((v2[0] == fix(1) && v2[1] == fix(2))); + STATIC_CHECK((v3[0] == fix(1) && v3[1] == fix(2))); + STATIC_CHECK((v4[0] == fix(1) && v4[1] == fix(2))); + } + + SUBCASE("fix3 ctors") { + constexpr fix3i v0{}; + constexpr fix3i v1{fix(1)}; + constexpr fix3i v2{fix(1), fix(2), fix(3)}; + constexpr fix3i v3{fix2i{fix(1), fix(2)}, fix(3)}; + constexpr fix3i v4{fix(1), fix2i{fix(2), fix(3)}}; + constexpr fix3i v5{fix4i{fix(1), fix(2), fix(3), fix(4)}}; + + STATIC_CHECK((v0[0] == fix(0))); + STATIC_CHECK((v1[0] == fix(1) && v1[1] == fix(1) && v1[2] == fix(1))); + STATIC_CHECK((v2[0] == fix(1) && v2[1] == fix(2) && v2[2] == fix(3))); + STATIC_CHECK((v3[0] == fix(1) && v3[1] == fix(2) && v3[2] == fix(3))); + STATIC_CHECK((v4[0] == fix(1) && v4[1] == fix(2) && v4[2] == fix(3))); + STATIC_CHECK((v5[0] == fix(1) && v5[1] == fix(2) && v5[2] == fix(3))); + } + + SUBCASE("fix4 ctors") { + constexpr fix4i v0{}; + constexpr fix4i v1{fix(1)}; + constexpr fix4i v2{fix(1), fix(2), fix(3), fix(4)}; + constexpr fix4i v3{fix2i{fix(1), fix(2)}, fix(3), fix(4)}; + constexpr fix4i v4{fix(1), fix2i{fix(2), fix(3)}, fix(4)}; + constexpr fix4i v5{fix(1), fix(2), fix2i{fix(3), fix(4)}}; + constexpr fix4i v6{fix2i{fix(1), fix(2)}, fix2i{fix(3), fix(4)}}; + constexpr fix4i v7{fix3i{fix(1), fix(2), fix(3)}, fix(4)}; + constexpr fix4i v8{fix(1), fix3i{fix(2), fix(3), fix(4)}}; + + STATIC_CHECK((v0.at(0) == fix(0))); + STATIC_CHECK((v1.at(0) == fix(1) && v1.at(1) == fix(1) && v1.at(2) == fix(1) && v1.at(3) == fix(1))); + STATIC_CHECK((v2.at(0) == fix(1) && v2.at(1) == fix(2) && v2.at(2) == fix(3) && v2.at(3) == fix(4))); + STATIC_CHECK((v3.at(0) == fix(1) && v3.at(1) == fix(2) && v3.at(2) == fix(3) && v3.at(3) == fix(4))); + STATIC_CHECK((v4.at(0) == fix(1) && v4.at(1) == fix(2) && v4.at(2) == fix(3) && v4.at(3) == fix(4))); + STATIC_CHECK((v5.at(0) == fix(1) && v5.at(1) == fix(2) && v5.at(2) == fix(3) && v5.at(3) == fix(4))); + STATIC_CHECK((v6.at(0) == fix(1) && v6.at(1) == fix(2) && v6.at(2) == fix(3) && v6.at(3) == fix(4))); + STATIC_CHECK((v7.at(0) == fix(1) && v7.at(1) == fix(2) && v7.at(2) == fix(3) && v7.at(3) == fix(4))); + STATIC_CHECK((v8.at(0) == fix(1) && v8.at(1) == fix(2) && v8.at(2) == fix(3) && v8.at(3) == fix(4))); + } + + SUBCASE("swap") { + { + vec v0{fix(1), fix(2)}; + vec v1{fix(3), fix(4)}; + swap(v0, v1); + CHECK(v0 == fix2i(fix(3),fix(4))); + CHECK(v1 == fix2i(fix(1),fix(2))); + } + { + vec v0{fix{1},fix{2},fix{3}}; + vec v1{fix2i{fix(3),fix(4)}, fix{5}}; + swap(v0, v1); + CHECK(v0 == fix3i(fix(3),fix(4),fix(5))); + CHECK(v1 == fix3i(fix(1),fix(2),fix(3))); + } + { + vec v0{fix{1},fix{2},fix{3},fix{4}}; + vec v1{fix{3},fix3i{fix(4),fix(5),fix(6)}}; + swap(v0, v1); + CHECK(v0 == fix4i(fix(3),fix(4),fix(5),fix(6))); + CHECK(v1 == fix4i(fix(1),fix(2),fix(3),fix(4))); + } + } + + SUBCASE("operators") { + fix2b vb{}; + fix2i vi{}; + bool b{}; + + vi = {+fix2i{fix(1),fix(2)}}; + vi = {-fix2i{fix(1),fix(2)}}; + vi = {~fix2i{fix(1),fix(2)}}; + vb = {!fix2i{fix(1),fix(2)}}; + + vi = {fix2i{fix(1),fix(2)} + fix{3}}; + vi = {fix{3} + fix2i{fix(1),fix(2)}}; + vi = {fix2i{fix(1),fix(2)} + fix2i{fix(1),fix(2)}}; + + vi = {fix2i{fix(1),fix(2)} - fix{3}}; + vi = {fix{3} - fix2i{fix(1),fix(2)}}; + vi = {fix2i{fix(1),fix(2)} - fix2i{fix(1),fix(2)}}; + + vi = {fix2i{fix(1),fix(2)} * fix{3}}; + vi = {fix{3} * fix2i{fix(1),fix(2)}}; + vi = {fix2i{fix(1),fix(2)} * fix2i{fix(1),fix(2)}}; + + vi = {fix2i{fix(1),fix(2)} / fix{3}}; + vi = {fix{3} / fix2i{fix(1),fix(2)}}; + vi = {fix2i{fix(1),fix(2)} / fix2i{fix(1),fix(2)}}; + + vi = {fix2i{fix(1),fix(2)} & fix{3}}; + vi = {fix{3} & fix2i{fix(1),fix(2)}}; + vi = {fix2i{fix(1),fix(2)} & fix2i{fix(1),fix(2)}}; + + vi = {fix2i{fix(1),fix(2)} | fix{3}}; + vi = {fix{3} | fix2i{fix(1),fix(2)}}; + vi = {fix2i{fix(1),fix(2)} | fix2i{fix(1),fix(2)}}; + + vi = {fix2i{fix(1),fix(2)} ^ fix{3}}; + vi = {fix{3} ^ fix2i{fix(1),fix(2)}}; + vi = {fix2i{fix(1),fix(2)} ^ fix2i{fix(1),fix(2)}}; + + vb = {fix2i{fix(1),fix(2)} && fix{3}}; + vb = {fix{3} && fix2i{fix(1),fix(2)}}; + vb = {fix2i{fix(1),fix(2)} && fix2i{fix(1),fix(2)}}; + + vb = {fix2i{fix(1),fix(2)} || fix{3}}; + vb = {fix{3} || fix2i{fix(1),fix(2)}}; + vb = {fix2i{fix(1),fix(2)} || fix2i{fix(1),fix(2)}}; + + b = {fix2i{fix(1),fix(2)} == fix2i{fix(3),fix(4)}}; + b = {fix2i{fix(1),fix(2)} != fix2i{fix(3),fix(4)}}; + b = {fix2i{fix(1),fix(2)} < fix2i{fix(3),fix(4)}}; + + { + fix2i v{}; + fix2i vi{}; + vi = {v += fix{3}}; + vi = {v += fix2i{fix(4),fix(5)}}; + vi = {v -= fix{3}}; + vi = {v -= fix2i{fix(4),fix(5)}}; + vi = {v *= fix{3}}; + vi = {v *= fix2i{fix(4),fix(5)}}; + vi = {v /= fix{3}}; + vi = {v /= fix2i{fix(4),fix(5)}}; + vi = {v &= fix{3}}; + vi = {v &= fix2i{fix(4),fix(5)}}; + vi = {v |= fix{3}}; + vi = {v |= fix2i{fix(4),fix(5)}}; + vi = {v ^= fix{3}}; + vi = {v ^= fix2i{fix(4),fix(5)}}; + } + } +} + +// +// fix_mat +// + +TEST_CASE("vmath/fix_mat") { + SUBCASE("fix2x2 ctors") { + constexpr fix2x2i v0{}; + constexpr fix2x2i v1{fix(2)}; + constexpr fix2x2i v2{fix2i{fix(1), fix(2)}}; + constexpr fix2x2i v3{fix(1), fix(2), fix(3), fix(4)}; + constexpr fix2x2i v4{{fix(1), fix(2)}, {fix(3), fix(4)}}; + constexpr fix2x2i v5{fix3x3i{fix(1)}}; + constexpr fix2x2i v6{fix4x4i{fix(1)}}; + + STATIC_CHECK((v0[0] == fix2i(fix(1),fix(0)) && v0[1] == fix2i(fix(0),fix(1)))); + STATIC_CHECK((v1[0] == fix2i(fix(2),fix(0)) && v1[1] == fix2i(fix(0),fix(2)))); + STATIC_CHECK((v2[0] == fix2i(fix(1),fix(0)) && v2[1] == fix2i(fix(0),fix(2)))); + STATIC_CHECK((v3[0] == fix2i(fix(1),fix(2)) && v3[1] == fix2i(fix(3),fix(4)))); + STATIC_CHECK((v4[0] == fix2i(fix(1),fix(2)) && v4[1] == fix2i(fix(3),fix(4)))); + STATIC_CHECK((v5[0] == fix2i(fix(1),fix(0)) && v5[1] == fix2i(fix(0),fix(1)))); + STATIC_CHECK((v6[0] == fix2i(fix(1),fix(0)) && v6[1] == fix2i(fix(0),fix(1)))); + } + + SUBCASE("fix3x3 ctors") { + constexpr fix3x3i v0{}; + constexpr fix3x3i v1{fix(2)}; + constexpr fix3x3i v2{fix3i{fix(1), fix(2), fix(3)}}; + constexpr fix3x3i v3{fix(1),fix(2),fix(3),fix(4),fix(5),fix(6),fix(7),fix(8),fix(9)}; + constexpr fix3x3i v4{{fix(1),fix(2),fix(3)},{fix(4),fix(5),fix(6)},{fix(7),fix(8),fix(9)}}; + constexpr fix3x3i v5{fix2x2i{fix(1)},fix2i{fix(0)}}; + constexpr fix3x3i v6{fix2x2i{fix(1)}}; + constexpr fix3x3i v7{fix4x4i{fix(1)}}; + + STATIC_CHECK((v0[0] == fix3i(fix(1),fix(0),fix(0)) && v0[1] == fix3i(fix(0),fix(1),fix(0)) && v0[2] == fix3i(fix(0),fix(0),fix(1)))); + STATIC_CHECK((v1[0] == fix3i(fix(2),fix(0),fix(0)) && v1[1] == fix3i(fix(0),fix(2),fix(0)) && v1[2] == fix3i(fix(0),fix(0),fix(2)))); + STATIC_CHECK((v2[0] == fix3i(fix(1),fix(0),fix(0)) && v2[1] == fix3i(fix(0),fix(2),fix(0)) && v2[2] == fix3i(fix(0),fix(0),fix(3)))); + STATIC_CHECK((v3[0] == fix3i(fix(1),fix(2),fix(3)) && v3[1] == fix3i(fix(4),fix(5),fix(6)) && v3[2] == fix3i(fix(7),fix(8),fix(9)))); + STATIC_CHECK((v4[0] == fix3i(fix(1),fix(2),fix(3)) && v4[1] == fix3i(fix(4),fix(5),fix(6)) && v4[2] == fix3i(fix(7),fix(8),fix(9)))); + STATIC_CHECK((v5[0] == fix3i(fix(1),fix(0),fix(0)) && v5[1] == fix3i(fix(0),fix(1),fix(0)) && v5[2] == fix3i(fix(0),fix(0),fix(1)))); + STATIC_CHECK((v6[0] == fix3i(fix(1),fix(0),fix(0)) && v6[1] == fix3i(fix(0),fix(1),fix(0)) && v6[2] == fix3i(fix(0),fix(0),fix(1)))); + STATIC_CHECK((v7[0] == fix3i(fix(1),fix(0),fix(0)) && v7[1] == fix3i(fix(0),fix(1),fix(0)) && v7[2] == fix3i(fix(0),fix(0),fix(1)))); + } + + SUBCASE("fix4x4 ctors") { + constexpr fix4x4i v0{}; + constexpr fix4x4i v1{fix(2)}; + constexpr fix4x4i v2{fix4i{fix(1),fix(2),fix(3),fix(4)}}; + constexpr fix4x4i v3{fix(1),fix(2),fix(3),fix(4),fix(5),fix(6),fix(7),fix(8),fix(9),fix(10),fix(11),fix(12),fix(13),fix(14),fix(15),fix(16)}; + constexpr fix4x4i v4{{fix(1),fix(2),fix(3),fix(4)},{fix(5),fix(6),fix(7),fix(8)},{fix(9),fix(10),fix(11),fix(12)},{fix(13),fix(14),fix(15),fix(16)}}; + constexpr fix4x4i v5{fix3x3i{fix(1)},fix3i{fix(0)}}; + constexpr fix4x4i v6{fix2x2i{fix(1)}}; + constexpr fix4x4i v7{fix3x3i{fix(1)}}; + + STATIC_CHECK((v0[0] == fix4i(fix(1),fix(0),fix(0),fix(0)) && v0[1] == fix4i(fix(0),fix(1),fix(0),fix(0)) && v0[2] == fix4i(fix(0),fix(0),fix(1),fix(0)) && v0[3] == fix4i(fix(0),fix(0),fix(0),fix(1)))); + STATIC_CHECK((v1[0] == fix4i(fix(2),fix(0),fix(0),fix(0)) && v1[1] == fix4i(fix(0),fix(2),fix(0),fix(0)) && v1[2] == fix4i(fix(0),fix(0),fix(2),fix(0)) && v1[3] == fix4i(fix(0),fix(0),fix(0),fix(2)))); + STATIC_CHECK((v2[0] == fix4i(fix(1),fix(0),fix(0),fix(0)) && v2[1] == fix4i(fix(0),fix(2),fix(0),fix(0)) && v2[2] == fix4i(fix(0),fix(0),fix(3),fix(0)) && v2[3] == fix4i(fix(0),fix(0),fix(0),fix(4)))); + STATIC_CHECK((v3[0] == fix4i(fix(1),fix(2),fix(3),fix(4)) && v3[1] == fix4i(fix(5),fix(6),fix(7),fix(8)) && v3[2] == fix4i(fix(9),fix(10),fix(11),fix(12)) && v3[3] == fix4i(fix(13),fix(14),fix(15),fix(16)))); + STATIC_CHECK((v4[0] == fix4i(fix(1),fix(2),fix(3),fix(4)) && v4[1] == fix4i(fix(5),fix(6),fix(7),fix(8)) && v4[2] == fix4i(fix(9),fix(10),fix(11),fix(12)) && v4[3] == fix4i(fix(13),fix(14),fix(15),fix(16)))); + STATIC_CHECK((v5[0] == fix4i(fix(1),fix(0),fix(0),fix(0)) && v5[1] == fix4i(fix(0),fix(1),fix(0),fix(0)) && v5[2] == fix4i(fix(0),fix(0),fix(1),fix(0)) && v5[3] == fix4i(fix(0),fix(0),fix(0),fix(1)))); + STATIC_CHECK((v6[0] == fix4i(fix(1),fix(0),fix(0),fix(0)) && v6[1] == fix4i(fix(0),fix(1),fix(0),fix(0)) && v6[2] == fix4i(fix(0),fix(0),fix(1),fix(0)) && v6[3] == fix4i(fix(0),fix(0),fix(0),fix(1)))); + STATIC_CHECK((v7[0] == fix4i(fix(1),fix(0),fix(0),fix(0)) && v7[1] == fix4i(fix(0),fix(1),fix(0),fix(0)) && v7[2] == fix4i(fix(0),fix(0),fix(1),fix(0)) && v7[3] == fix4i(fix(0),fix(0),fix(0),fix(1)))); + } + + SUBCASE("swap") { + { + fix2x2i v0{fix(1)}; + fix2x2i v1{fix(2)}; + swap(v0, v1); + CHECK(v0 == fix2x2i(fix(2))); + CHECK(v1 == fix2x2i(fix(1))); + } + { + fix3x3i v0{fix(1)}; + fix3x3i v1{fix(2)}; + swap(v0, v1); + CHECK(v0 == fix3x3i(fix(2))); + CHECK(v1 == fix3x3i(fix(1))); + } + { + fix4x4i v0{fix(1)}; + fix4x4i v1{fix(2)}; + swap(v0, v1); + CHECK(v0 == fix4x4i(fix(2))); + CHECK(v1 == fix4x4i(fix(1))); + } + } + + SUBCASE("operators") { + fix2x2b mb{}; + fix2x2i mi{}; + fix2i vi{}; + bool b{}; + + mi = {+fix2x2i{fix(1),fix(2),fix(3),fix(4)}}; + mi = {-fix2x2i{fix(1),fix(2),fix(3),fix(4)}}; + mi = {~fix2x2i{fix(1),fix(2),fix(3),fix(4)}}; + mb = {!fix2x2i{fix(1),fix(2),fix(3),fix(4)}}; + + mi = {fix2x2i{fix(1),fix(2),fix(3),fix(4)} + fix{3}}; + mi = {fix{3} + fix2x2i{fix(1),fix(2),fix(3),fix(4)}}; + mi = {fix2x2i{fix(1),fix(2),fix(3),fix(4)} + fix2x2i{fix(1),fix(2),fix(3),fix(4)}}; + + mi = {fix2x2i{fix(1),fix(2),fix(3),fix(4)} - fix{3}}; + mi = {fix{3} - fix2x2i{fix(1),fix(2),fix(3),fix(4)}}; + mi = {fix2x2i{fix(1),fix(2),fix(3),fix(4)} - fix2x2i{fix(1),fix(2),fix(3),fix(4)}}; + + mi = {fix2x2i{fix(1),fix(2),fix(3),fix(4)} * fix{3}}; + mi = {fix{3} * fix2x2i{fix(1),fix(2),fix(3),fix(4)}}; + vi = {vi * mi}; + mi = {fix2x2i{fix(1),fix(2),fix(3),fix(4)} * fix2x2i{fix(1),fix(2),fix(3),fix(4)}}; + + mi = {fix2x2i{fix(1),fix(2),fix(3),fix(4)} / fix{3}}; + mi = {fix{3} / fix2x2i{fix(1),fix(2),fix(3),fix(4)}}; + // mi = {fix2x2i{fix(1),fix(2),fix(3),fix(4)} / fix2x2i{fix(1),fix(2),fix(3),fix(4)}}; + + mi = {fix2x2i{fix(1),fix(2),fix(3),fix(4)} & fix{3}}; + mi = {fix{3} & fix2x2i{fix(1),fix(2),fix(3),fix(4)}}; + mi = {fix2x2i{fix(1),fix(2),fix(3),fix(4)} & fix2x2i{fix(1),fix(2),fix(3),fix(4)}}; + + mi = {fix2x2i{fix(1),fix(2),fix(3),fix(4)} | fix{3}}; + mi = {fix{3} | fix2x2i{fix(1),fix(2),fix(3),fix(4)}}; + mi = {fix2x2i{fix(1),fix(2),fix(3),fix(4)} | fix2x2i{fix(1),fix(2),fix(3),fix(4)}}; + + mi = {fix2x2i{fix(1),fix(2),fix(3),fix(4)} ^ fix{3}}; + mi = {fix{3} ^ fix2x2i{fix(1),fix(2),fix(3),fix(4)}}; + mi = {fix2x2i{fix(1),fix(2),fix(3),fix(4)} ^ fix2x2i{fix(1),fix(2),fix(3),fix(4)}}; + + mb = {fix2x2i{fix(1),fix(2),fix(3),fix(4)} && fix{3}}; + mb = {fix{3} && fix2x2i{fix(1),fix(2),fix(3),fix(4)}}; + mb = {fix2x2i{fix(1),fix(2),fix(3),fix(4)} && fix2x2i{fix(1),fix(2),fix(3),fix(4)}}; + + mb = {fix2x2i{fix(1),fix(2),fix(3),fix(4)} || fix{3}}; + mb = {fix{3} || fix2x2i{fix(1),fix(2),fix(3),fix(4)}}; + mb = {fix2x2i{fix(1),fix(2),fix(3),fix(4)} || fix2x2i{fix(1),fix(2),fix(3),fix(4)}}; + + b = {fix2x2i{fix(1),fix(2),fix(3),fix(4)} == fix2x2i{fix(3),fix(4),fix(5),fix(6)}}; + b = {fix2x2i{fix(1),fix(2),fix(3),fix(4)} != fix2x2i{fix(3),fix(4),fix(5),fix(6)}}; + b = {fix2x2i{fix(1),fix(2),fix(3),fix(4)} < fix2x2i{fix(3),fix(4),fix(5),fix(6)}}; + + { + mi = {mi += fix{3}}; + mi = {mi += fix2x2i{fix(4),fix(5),fix(6),fix(7)}}; + mi = {mi -= fix{3}}; + mi = {mi -= fix2x2i{fix(4),fix(5),fix(6),fix(7)}}; + mi = {mi *= fix{3}}; + vi = {vi *= fix2x2i{fix(4),fix(5),fix(6),fix(7)}}; + mi = {mi *= fix2x2i{fix(4),fix(5),fix(6),fix(7)}}; + mi = {mi /= fix{3}}; + //mi = {mi /= fix2x2i{fix(4),fix(5),fix(6),fix(7)}}; + mi = {mi &= fix{3}}; + mi = {mi &= fix2x2i{fix(4),fix(5),fix(6),fix(7)}}; + mi = {mi |= fix{3}}; + mi = {mi |= fix2x2i{fix(4),fix(5),fix(6),fix(7)}}; + mi = {mi ^= fix{3}}; + mi = {mi ^= fix2x2i{fix(4),fix(5),fix(6),fix(7)}}; + } + } +} + +// +// fix_qua +// + +TEST_CASE("vmath/fix_qua") { + SUBCASE("ctors") { + constexpr qfix v0{}; + constexpr qfix v1{fix(1.f), fix(2.f), fix(3.f), fix(4.f)}; + constexpr qfix v2{fix3f{fix(1.f), fix(2.f), fix(3.f)}, fix(4.f)}; + constexpr qfix v3{fix4f{fix(1.f), fix(2.f), fix(3.f), fix(4.f)}}; + + STATIC_CHECK((v0.at(0) == fix(0.f))); + STATIC_CHECK((v1.at(0) == fix(1.f) && v1.at(1) == fix(2.f) && v1.at(2) == fix(3.f) && v1.at(3) == fix(4.f))); + STATIC_CHECK((v2.at(0) == fix(1.f) && v2.at(1) == fix(2.f) && v2.at(2) == fix(3.f) && v2.at(3) == fix(4.f))); + STATIC_CHECK((v3.at(0) == fix(1.f) && v3.at(1) == fix(2.f) && v3.at(2) == fix(3.f) && v3.at(3) == fix(4.f))); + } + + SUBCASE("swap") { + qfix v0{fix(1.f),fix(2.f),fix(3.f),fix(4.f)}; + qfix v1{fix(4.f),fix(3.f),fix(2.f),fix(1.f)}; + swap(v0, v1); + CHECK(v0 == qfix(fix(4.f),fix(3.f),fix(2.f),fix(1.f))); + CHECK(v1 == qfix(fix(1.f),fix(2.f),fix(3.f),fix(4.f))); + } + + SUBCASE("operators") { + qfix qf; + fix3f vf; + bool b{}; + + qf = {+qfix{fix(1.f),fix(2.f),fix(3.f),fix(4.f)}}; + qf = {-qfix{fix(1.f),fix(2.f),fix(3.f),fix(4.f)}}; + + qf = {qfix{fix(1.f),fix(2.f),fix(3.f),fix(4.f)} + qfix{fix(1.f),fix(2.f),fix(3.f),fix(4.f)}}; + qf = {qfix{fix(1.f),fix(2.f),fix(3.f),fix(4.f)} - qfix{fix(1.f),fix(2.f),fix(3.f),fix(4.f)}}; + qf = {qfix{fix(1.f),fix(2.f),fix(3.f),fix(4.f)} * fix{1.f}}; + qf = {fix{1.f} * qfix{fix(1.f),fix(2.f),fix(3.f),fix(4.f)}}; + vf = {fix3f{fix(1.f),fix(2.f),fix(3.f)} * qfix{fix(1.f),fix(2.f),fix(3.f),fix(4.f)}}; + qf = {qfix{fix(1.f),fix(2.f),fix(3.f),fix(4.f)} * qfix{fix(1.f),fix(2.f),fix(3.f),fix(4.f)}}; + qf = {qfix{fix(1.f),fix(2.f),fix(3.f),fix(4.f)} / fix{1.f}}; + qf = {fix{1.f} / qfix{fix(1.f),fix(2.f),fix(3.f),fix(4.f)}}; + + qf = {qf += qfix{fix(1.f),fix(2.f),fix(3.f),fix(4.f)}}; + qf = {qf -= qfix{fix(1.f),fix(2.f),fix(3.f),fix(4.f)}}; + qf = {qf *= fix{1.f}}; + vf = {vf *= qfix{fix(1.f),fix(2.f),fix(3.f),fix(4.f)}}; + qf = {qf *= qfix{fix(1.f),fix(2.f),fix(3.f),fix(4.f)}}; + qf = {qf /= fix{1.f}}; + + b = {qfix{fix(1.f),fix(2.f),fix(3.f),fix(4.f)} == qfix{fix(1.f),fix(2.f),fix(3.f),fix(4.f)}}; + b = {qfix{fix(1.f),fix(2.f),fix(3.f),fix(4.f)} != qfix{fix(1.f),fix(2.f),fix(3.f),fix(4.f)}}; + b = {qfix{fix(1.f),fix(2.f),fix(3.f),fix(4.f)} < qfix{fix(1.f),fix(2.f),fix(3.f),fix(4.f)}}; + } +} + +// +// Units +// + +TEST_CASE("vmath/fix_units") { + { + STATIC_CHECK(zero2> == fix2f{fix(0.f),fix(0.f)}); + STATIC_CHECK(zero3> == fix3f{fix(0.f),fix(0.f),fix(0.f)}); + STATIC_CHECK(zero4> == fix4f{fix(0.f),fix(0.f),fix(0.f),fix(0.f)}); + } + { + STATIC_CHECK(unit2> == fix2f{fix(1.f),fix(1.f)}); + STATIC_CHECK(unit3> == fix3f{fix(1.f),fix(1.f),fix(1.f)}); + STATIC_CHECK(unit4> == fix4f{fix(1.f),fix(1.f),fix(1.f),fix(1.f)}); + } + { + STATIC_CHECK(unit2_x> == fix2f{fix(1.f),fix(0.f)}); + STATIC_CHECK(unit2_y> == fix2f{fix(0.f),fix(1.f)}); + + STATIC_CHECK(unit3_x> == fix3f{fix(1.f),fix(0.f),fix(0.f)}); + STATIC_CHECK(unit3_y> == fix3f{fix(0.f),fix(1.f),fix(0.f)}); + STATIC_CHECK(unit3_z> == fix3f{fix(0.f),fix(0.f),fix(1.f)}); + + STATIC_CHECK(unit4_x> == fix4f{fix(1.f),fix(0.f),fix(0.f),fix(0.f)}); + STATIC_CHECK(unit4_y> == fix4f{fix(0.f),fix(1.f),fix(0.f),fix(0.f)}); + STATIC_CHECK(unit4_z> == fix4f{fix(0.f),fix(0.f),fix(1.f),fix(0.f)}); + STATIC_CHECK(unit4_w> == fix4f{fix(0.f),fix(0.f),fix(0.f),fix(1.f)}); + } + { + STATIC_CHECK(zero2x2> == fix2x2f{ + fix(0.f),fix(0.f), + fix(0.f),fix(0.f)}); + STATIC_CHECK(zero3x3> == fix3x3f{ + fix(0.f),fix(0.f),fix(0.f), + fix(0.f),fix(0.f),fix(0.f), + fix(0.f),fix(0.f),fix(0.f)}); + STATIC_CHECK(zero4x4> == fix4x4f{ + fix(0.f),fix(0.f),fix(0.f),fix(0.f), + fix(0.f),fix(0.f),fix(0.f),fix(0.f), + fix(0.f),fix(0.f),fix(0.f),fix(0.f), + fix(0.f),fix(0.f),fix(0.f),fix(0.f)}); + } + { + STATIC_CHECK(unit2x2> == fix2x2f{ + fix(1.f),fix(1.f), + fix(1.f),fix(1.f)}); + STATIC_CHECK(unit3x3> == fix3x3f{ + fix(1.f),fix(1.f),fix(1.f), + fix(1.f),fix(1.f),fix(1.f), + fix(1.f),fix(1.f),fix(1.f)}); + STATIC_CHECK(unit4x4> == fix4x4f{ + fix(1.f),fix(1.f),fix(1.f),fix(1.f), + fix(1.f),fix(1.f),fix(1.f),fix(1.f), + fix(1.f),fix(1.f),fix(1.f),fix(1.f), + fix(1.f),fix(1.f),fix(1.f),fix(1.f)}); + } + { + STATIC_CHECK(identity2x2> == fix2x2f{ + fix(1.f),fix(0.f), + fix(0.f),fix(1.f)}); + STATIC_CHECK(identity3x3> == fix3x3f{ + fix(1.f),fix(0.f),fix(0.f), + fix(0.f),fix(1.f),fix(0.f), + fix(0.f),fix(0.f),fix(1.f)}); + STATIC_CHECK(identity4x4> == fix4x4f{ + fix(1.f),fix(0.f),fix(0.f),fix(0.f), + fix(0.f),fix(1.f),fix(0.f),fix(0.f), + fix(0.f),fix(0.f),fix(1.f),fix(0.f), + fix(0.f),fix(0.f),fix(0.f),fix(1.f)}); + } + { + STATIC_CHECK(qidentity> == qfix{ + fix(0.f),fix(0.f),fix(0.f), + fix(1.f)}); + } +}