diff --git a/README.md b/README.md index aeaf61c..a345c56 100644 --- a/README.md +++ b/README.md @@ -248,6 +248,10 @@ public: const row_type& row1, const row_type& row2); + constexpr mat_base( + const mat_base& m, + const vec_base& v); + constexpr explicit mat_base(const mat_base& other); constexpr explicit mat_base(const mat_base& other); }; @@ -279,6 +283,10 @@ public: const row_type& row2, const row_type& row3); + constexpr mat_base( + const mat_base& m, + const vec_base& v); + constexpr explicit mat_base(const mat_base& other); constexpr explicit mat_base(const mat_base& other); }; diff --git a/headers/vmath.hpp/vmath_mat.hpp b/headers/vmath.hpp/vmath_mat.hpp index 65d8b4c..7111014 100644 --- a/headers/vmath.hpp/vmath_mat.hpp +++ b/headers/vmath.hpp/vmath_mat.hpp @@ -99,6 +99,14 @@ namespace vmath_hpp::detail const row_type& row2) : rows{row0, row1, row2} {} + constexpr mat_base( + const mat_base& m, + const vec_base& v) + : rows{ + row_type{m.rows[0], 0}, + row_type{m.rows[1], 0}, + row_type{v, 1}} {} + constexpr explicit mat_base( const mat_base& other) : rows{ @@ -158,6 +166,15 @@ namespace vmath_hpp::detail const row_type& row3) : rows{row0, row1, row2, row3} {} + constexpr mat_base( + const mat_base& m, + const vec_base& v) + : rows{ + row_type{m.rows[0], 0}, + row_type{m.rows[1], 0}, + row_type{m.rows[2], 0}, + row_type{v, 1}} {} + constexpr explicit mat_base( const mat_base& other) : rows{ @@ -281,6 +298,9 @@ namespace vmath_hpp template < typename T > mat(const vec&, const vec&, const vec&) -> mat; + template < typename T > + mat(const mat&, const vec&) -> mat; + template < typename T > mat(std::initializer_list, std::initializer_list, std::initializer_list) -> mat; @@ -292,6 +312,9 @@ namespace vmath_hpp template < typename T > mat(const vec&, const vec&, const vec&, const vec&) -> mat; + template < typename T > + mat(const mat&, const vec&) -> mat; + template < typename T > mat(std::initializer_list, std::initializer_list, std::initializer_list, std::initializer_list) -> mat; diff --git a/untests/vmath_mat_tests.cpp b/untests/vmath_mat_tests.cpp index 97688d1..fed8be3 100644 --- a/untests/vmath_mat_tests.cpp +++ b/untests/vmath_mat_tests.cpp @@ -32,10 +32,12 @@ TEST_CASE("vmath/mat") { STATIC_REQUIRE(mat{1,2,3,4,5,6,7,8,9}.size == 3); STATIC_REQUIRE(mat{{1,2,3},{4,5,6},{7,8,9}}.size == 3); STATIC_REQUIRE(mat{vec{1,2,3},vec{4,5,6},vec{7,8,9}}.size == 3); + STATIC_REQUIRE(mat{mat{1,2,3,4},vec{5,6}}.size == 3); STATIC_REQUIRE(mat{1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16}.size == 4); STATIC_REQUIRE(mat{{1,2,3,4},{5,6,7,8},{9,10,11,12},{13,14,15,16}}.size == 4); STATIC_REQUIRE(mat{vec{1,2,3,4},vec{5,6,7,8},vec{9,10,11,12},vec{13,14,15,16}}.size == 4); + STATIC_REQUIRE(mat{mat{1,2,3,4,5,6,7,8,9},vec{5,6,7}}.size == 4); } SUBCASE("ctors") { @@ -74,6 +76,7 @@ TEST_CASE("vmath/mat") { STATIC_REQUIRE(int3x3(int3{2,3,4}) == int3x3(2,0,0,0,3,0,0,0,4)); STATIC_REQUIRE(int3x3(1,2,3,4,5,6,7,8,9) == int3x3(1,2,3,4,5,6,7,8,9)); STATIC_REQUIRE(int3x3({1,2,3},{4,5,6},{7,8,9}) == int3x3(1,2,3,4,5,6,7,8,9)); + STATIC_REQUIRE(int3x3(int2x2({1,2},{3,4}),int2{5,6}) == int3x3(1,2,0,3,4,0,5,6,1)); STATIC_REQUIRE(int3x3(int3x3({1,2,3},{4,5,6},{7,8,9})) == int3x3(1,2,3,4,5,6,7,8,9)); STATIC_REQUIRE(int3x3(int2x2({1,2},{3,4})) == int3x3(1,2,0,3,4,0,0,0,1)); STATIC_REQUIRE(int3x3(int4x4({1,2,3,4},{5,6,7,8},{9,10,11,12},{13,14,15,16})) == int3x3(1,2,3,5,6,7,9,10,11)); @@ -83,6 +86,7 @@ TEST_CASE("vmath/mat") { STATIC_REQUIRE(int4x4(int4{2,3,4,5}) == int4x4(2,0,0,0,0,3,0,0,0,0,4,0,0,0,0,5)); STATIC_REQUIRE(int4x4(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16) == int4x4(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16)); STATIC_REQUIRE(int4x4({1,2,3,4},{5,6,7,8},{9,10,11,12},{13,14,15,16}) == int4x4(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16)); + STATIC_REQUIRE(int4x4(int3x3({1,2,3},{4,5,6},{7,8,9}),int3{10,11,12}) == int4x4(1,2,3,0,4,5,6,0,7,8,9,0,10,11,12,1)); STATIC_REQUIRE(int4x4(int4x4({1,2,3,4},{5,6,7,8},{9,10,11,12},{13,14,15,16})) == int4x4(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16)); STATIC_REQUIRE(int4x4(int2x2({1,2},{3,4})) == int4x4(1,2,0,0,3,4,0,0,0,0,1,0,0,0,0,1)); STATIC_REQUIRE(int4x4(int3x3({1,2,3},{4,5,6},{7,8,9})) == int4x4(1,2,3,0,4,5,6,0,7,8,9,0,0,0,0,1));