mirror of
https://github.com/BlackMATov/vmath.hpp.git
synced 2026-01-04 17:21:04 +07:00
matrix ctor from diagonal vector
This commit is contained in:
@@ -186,7 +186,8 @@ public:
|
||||
{0, 1}};
|
||||
|
||||
constexpr mat_base() = default;
|
||||
constexpr explicit mat_base(T v);
|
||||
constexpr explicit mat_base(T d);
|
||||
constexpr explicit mat_base(const row_type& d);
|
||||
|
||||
constexpr mat_base(
|
||||
T m11, T m12,
|
||||
@@ -211,7 +212,8 @@ public:
|
||||
{0, 0, 1}};
|
||||
|
||||
constexpr mat_base() = default;
|
||||
constexpr explicit mat_base(T v);
|
||||
constexpr explicit mat_base(T d);
|
||||
constexpr explicit mat_base(const row_type& d);
|
||||
|
||||
constexpr mat_base(
|
||||
T m11, T m12, T m13,
|
||||
@@ -239,7 +241,8 @@ public:
|
||||
{0, 0, 0, 1}};
|
||||
|
||||
constexpr mat_base() = default;
|
||||
constexpr explicit mat_base(T v);
|
||||
constexpr explicit mat_base(T d);
|
||||
constexpr explicit mat_base(const row_type& d);
|
||||
|
||||
constexpr mat_base(
|
||||
T m11, T m12, T m13, T m14,
|
||||
|
||||
@@ -26,10 +26,15 @@ namespace vmath_hpp::detail
|
||||
public:
|
||||
constexpr mat_base() = default;
|
||||
|
||||
constexpr explicit mat_base(T v)
|
||||
constexpr explicit mat_base(T d)
|
||||
: rows{
|
||||
row_type{v, 0},
|
||||
row_type{0, v}} {}
|
||||
row_type{d, 0},
|
||||
row_type{0, d}} {}
|
||||
|
||||
constexpr explicit mat_base(const row_type& d)
|
||||
: rows{
|
||||
row_type{d[0], 0},
|
||||
row_type{0, d[1]}} {}
|
||||
|
||||
constexpr mat_base(
|
||||
T m11, T m12,
|
||||
@@ -67,11 +72,17 @@ namespace vmath_hpp::detail
|
||||
public:
|
||||
constexpr mat_base() = default;
|
||||
|
||||
constexpr explicit mat_base(T v)
|
||||
constexpr explicit mat_base(T d)
|
||||
: rows{
|
||||
row_type{v, 0, 0},
|
||||
row_type{0, v, 0},
|
||||
row_type{0, 0, v}} {}
|
||||
row_type{d, 0, 0},
|
||||
row_type{0, d, 0},
|
||||
row_type{0, 0, d}} {}
|
||||
|
||||
constexpr explicit mat_base(const row_type& d)
|
||||
: rows{
|
||||
row_type{d[0], 0, 0},
|
||||
row_type{0, d[1], 0},
|
||||
row_type{0, 0, d[2]}} {}
|
||||
|
||||
constexpr mat_base(
|
||||
T m11, T m12, T m13,
|
||||
@@ -115,12 +126,19 @@ namespace vmath_hpp::detail
|
||||
public:
|
||||
constexpr mat_base() = default;
|
||||
|
||||
constexpr explicit mat_base(T v)
|
||||
constexpr explicit mat_base(T d)
|
||||
: rows{
|
||||
row_type{v, 0, 0, 0},
|
||||
row_type{0, v, 0, 0},
|
||||
row_type{0, 0, v, 0},
|
||||
row_type{0, 0, 0, v}} {}
|
||||
row_type{d, 0, 0, 0},
|
||||
row_type{0, d, 0, 0},
|
||||
row_type{0, 0, d, 0},
|
||||
row_type{0, 0, 0, d}} {}
|
||||
|
||||
constexpr explicit mat_base(const row_type& d)
|
||||
: rows{
|
||||
row_type{d[0], 0, 0, 0},
|
||||
row_type{0, d[1], 0, 0},
|
||||
row_type{0, 0, d[2], 0},
|
||||
row_type{0, 0, 0, d[3]}} {}
|
||||
|
||||
constexpr mat_base(
|
||||
T m11, T m12, T m13, T m14,
|
||||
|
||||
@@ -48,6 +48,7 @@ TEST_CASE("vmath/mat") {
|
||||
{
|
||||
STATIC_REQUIRE(int2x2() == int2x2(1,0,0,1));
|
||||
STATIC_REQUIRE(int2x2(2) == int2x2(2,0,0,2));
|
||||
STATIC_REQUIRE(int2x2(int2{2,3}) == int2x2(2,0,0,3));
|
||||
STATIC_REQUIRE(int2x2(1,2,3,4) == int2x2(1,2,3,4));
|
||||
STATIC_REQUIRE(int2x2({1,2},{3,4}) == int2x2(1,2,3,4));
|
||||
STATIC_REQUIRE(int2x2(int2x2({1,2},{3,4})) == int2x2(1,2,3,4));
|
||||
@@ -56,6 +57,7 @@ TEST_CASE("vmath/mat") {
|
||||
|
||||
STATIC_REQUIRE(int3x3() == int3x3(1,0,0,0,1,0,0,0,1));
|
||||
STATIC_REQUIRE(int3x3(2) == int3x3(2,0,0,0,2,0,0,0,2));
|
||||
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(int3x3({1,2,3},{4,5,6},{7,8,9})) == int3x3(1,2,3,4,5,6,7,8,9));
|
||||
@@ -64,6 +66,7 @@ TEST_CASE("vmath/mat") {
|
||||
|
||||
STATIC_REQUIRE(int4x4() == int4x4(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1));
|
||||
STATIC_REQUIRE(int4x4(2) == int4x4(2,0,0,0,0,2,0,0,0,0,2,0,0,0,0,2));
|
||||
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(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));
|
||||
|
||||
Reference in New Issue
Block a user