5#include <Infinity/Types/Core/Value.hpp>
6#include <Infinity/Types/Containers/Array.hpp>
7#include <Infinity/Types/Math/Vector4.hpp>
163 T v4, T v5, T v6, T v7,
164 T v8, T v9, T v10, T v11,
165 T v12, T v13, T v14, T v15) :
166 value{{v0, v1, v2, v3},
169 {v12, v13, v14, v15}}
186 value{{v[0], v[1], v[2], v[3]},
187 {v[4], v[5], v[6], v[7]},
188 {v[8], v[9], v[10], v[11]},
189 {v[12], v[13], v[14], v[15]}} {}
213 value{c0, c1, c2, c3}
239 constexpr size_t size()
const {
return 16; }
246 constexpr size_t columns()
const {
return 4; }
253 constexpr size_t rows()
const {
return 4; }
305 T
operator()(
size_t c,
size_t r)
const {
return value[c][r]; }
333 void set(T v0, T v1, T v2, T v3,
334 T v4, T v5, T v6, T v7,
335 T v8, T v9, T v10, T v11,
336 T v12, T v13, T v14, T v15)
338 value[0].set(v0, v1, v2, v3);
339 value[1].set(v4, v5, v6, v7);
340 value[2].set(v8, v9, v10, v11);
341 value[3].set(v12, v13, v14, v15);
368 T*
data() {
return value[0].data(); }
375 const T*
data()
const {
return value[0].data(); }
393 value[0].x * scalar, value[0].y * scalar, value[0].z * scalar, value[0].w * scalar,
394 value[1].x * scalar, value[1].y * scalar, value[1].z * scalar, value[1].w * scalar,
395 value[2].x * scalar, value[2].y * scalar, value[2].z * scalar, value[2].w * scalar,
396 value[3].x * scalar, value[3].y * scalar, value[3].z * scalar, value[3].w * scalar
438 value[0].x * rhs.
value[0].x + value[0].y * rhs.
value[1].x + value[0].z * rhs.
value[2].x + value[0].w * rhs.
value[3].x,
439 value[0].x * rhs.
value[0].y + value[0].y * rhs.
value[1].y + value[0].z * rhs.
value[2].y + value[0].w * rhs.
value[3].y,
440 value[0].x * rhs.
value[0].z + value[0].y * rhs.
value[1].z + value[0].z * rhs.
value[2].z + value[0].w * rhs.
value[3].z,
441 value[0].x * rhs.
value[0].w + value[0].y * rhs.
value[1].w + value[0].z * rhs.
value[2].w + value[0].w * rhs.
value[3].w,
443 value[1].x * rhs.
value[0].x + value[1].y * rhs.
value[1].x + value[1].z * rhs.
value[2].x + value[1].w * rhs.
value[3].x,
444 value[1].x * rhs.
value[0].y + value[1].y * rhs.
value[1].y + value[1].z * rhs.
value[2].y + value[1].w * rhs.
value[3].y,
445 value[1].x * rhs.
value[0].z + value[1].y * rhs.
value[1].z + value[1].z * rhs.
value[2].z + value[1].w * rhs.
value[3].z,
446 value[1].x * rhs.
value[0].w + value[1].y * rhs.
value[1].w + value[1].z * rhs.
value[2].w + value[1].w * rhs.
value[3].w,
448 value[2].x * rhs.
value[0].x + value[2].y * rhs.
value[1].x + value[2].z * rhs.
value[2].x + value[2].w * rhs.
value[3].x,
449 value[2].x * rhs.
value[0].y + value[2].y * rhs.
value[1].y + value[2].z * rhs.
value[2].y + value[2].w * rhs.
value[3].y,
450 value[2].x * rhs.
value[0].z + value[2].y * rhs.
value[1].z + value[2].z * rhs.
value[2].z + value[2].w * rhs.
value[3].z,
451 value[2].x * rhs.
value[0].w + value[2].y * rhs.
value[1].w + value[2].z * rhs.
value[2].w + value[2].w * rhs.
value[3].w,
453 value[3].x * rhs.
value[0].x + value[3].y * rhs.
value[1].x + value[3].z * rhs.
value[2].x + value[3].w * rhs.
value[3].x,
454 value[3].x * rhs.
value[0].y + value[3].y * rhs.
value[1].y + value[3].z * rhs.
value[2].y + value[3].w * rhs.
value[3].y,
455 value[3].x * rhs.
value[0].z + value[3].y * rhs.
value[1].z + value[3].z * rhs.
value[2].z + value[3].w * rhs.
value[3].z,
456 value[3].x * rhs.
value[0].w + value[3].y * rhs.
value[1].w + value[3].z * rhs.
value[2].w + value[3].w * rhs.
value[3].w
499 value[0].x * v.
x + value[0].y * v.
y + value[0].z * v.
z,
500 value[1].x * v.
x + value[1].y * v.
y + value[1].z * v.
z,
501 value[2].x * v.
x + value[2].y * v.
y + value[2].z * v.
z,
502 value[3].x * v.
x + value[3].y * v.
y + value[3].z * v.
z
517 value[0].x + rhs.
value[0].x, value[0].y + rhs.
value[0].y, value[0].z + rhs.
value[0].z, value[0].w + rhs.
value[0].w,
518 value[1].x + rhs.
value[1].x, value[1].y + rhs.
value[1].y, value[1].z + rhs.
value[1].z, value[1].w + rhs.
value[1].w,
519 value[2].x + rhs.
value[2].x, value[2].y + rhs.
value[2].y, value[2].z + rhs.
value[2].z, value[2].w + rhs.
value[2].w,
520 value[3].x + rhs.
value[3].x, value[3].y + rhs.
value[3].y, value[3].z + rhs.
value[3].z, value[3].w + rhs.
value[3].w
534 value[0] += rhs.
value[0];
535 value[1] += rhs.
value[1];
536 value[2] += rhs.
value[2];
537 value[3] += rhs.
value[3];
552 value[0].x - rhs.
value[0].x, value[0].y - rhs.
value[0].y, value[0].z - rhs.
value[0].z, value[0].w - rhs.
value[0].w,
553 value[1].x - rhs.
value[1].x, value[1].y - rhs.
value[1].y, value[1].z - rhs.
value[1].z, value[1].w - rhs.
value[1].w,
554 value[2].x - rhs.
value[2].x, value[2].y - rhs.
value[2].y, value[2].z - rhs.
value[2].z, value[2].w - rhs.
value[2].w,
555 value[3].x - rhs.
value[3].x, value[3].y - rhs.
value[3].y, value[3].z - rhs.
value[3].z, value[3].w - rhs.
value[3].w
569 value[0] -= rhs.
value[0];
570 value[1] -= rhs.
value[1];
571 value[2] -= rhs.
value[2];
572 value[3] -= rhs.
value[3];
589 if constexpr (std::is_floating_point_v<T>)
591 T inv =
static_cast<T
>(1.0) / scalar;
593 value[0].x * inv, value[0].y * inv, value[0].z * inv, value[0].w * inv,
594 value[1].x * inv, value[1].y * inv, value[1].z * inv, value[1].w * inv,
595 value[2].x * inv, value[2].y * inv, value[2].z * inv, value[2].w * inv,
596 value[3].x * inv, value[3].y * inv, value[3].z * inv, value[3].w * inv
602 value[0].x / scalar, value[0].y / scalar, value[0].z / scalar, value[0].w / scalar,
603 value[1].x / scalar, value[1].y / scalar, value[1].z / scalar, value[1].w / scalar,
604 value[2].x / scalar, value[2].y / scalar, value[2].z / scalar, value[2].w / scalar,
605 value[3].x / scalar, value[3].y / scalar, value[3].z / scalar, value[3].w / scalar
622 if constexpr (std::is_floating_point_v<T>)
624 T inv =
static_cast<T
>(1.0) / scalar;
650 return value[0] == rhs.
value[0] &&
651 value[1] == rhs.
value[1] &&
652 value[2] == rhs.
value[2] &&
653 value[3] == rhs.
value[3];
664 return !(*
this == rhs);
678 if (value[0] < rhs.
value[0])
return true;
679 if (value[0] > rhs.
value[0])
return false;
680 if (value[1] < rhs.
value[1])
return true;
681 if (value[1] > rhs.
value[1])
return false;
682 if (value[2] < rhs.
value[2])
return true;
683 if (value[2] > rhs.
value[2])
return false;
684 return value[3] < rhs.
value[3];
708 value[0].x, value[1].x, value[2].x, value[3].x,
709 value[0].y, value[1].y, value[2].y, value[3].y,
710 value[0].z, value[1].z, value[2].z, value[3].z,
711 value[0].w, value[1].w, value[2].w, value[3].w
725 -value[0].x, -value[0].y, -value[0].z,
726 -value[1].x, -value[1].y, -value[1].z,
727 -value[2].x, -value[2].y, -value[2].z,
728 -value[3].x, -value[3].y, -value[3].z
739 explicit operator bool() const noexcept
778 inline std::ostream& operator<<(std::ostream& out,
const t_Matrix4<T>& m)
Dynamic contiguous container for homogeneous elements in the Infinity type system.
Definition Array.hpp:77
Template wrapper for primitive types to integrate with the Infinity type system.
Definition Value.hpp:89
Template structure representing a 4x4 matrix.
Definition Matrix4.hpp:93
t_Vector4< T > & operator[](size_t c)
Column access operator (mutable).
Definition Matrix4.hpp:268
constexpr t_Matrix4(T v)
Constructs a diagonal matrix with the same value on the diagonal.
Definition Matrix4.hpp:138
t_Matrix4 operator-() const
Unary negation operator.
Definition Matrix4.hpp:722
constexpr t_Matrix4(T v[16])
Constructs a matrix from an array of sixteen elements.
Definition Matrix4.hpp:185
t_Matrix4 & operator=(const t_Matrix4< R > &rhs)
Type-converting assignment operator.
Definition Matrix4.hpp:317
void set(const t_Matrix4< R > &rhs)
Sets this matrix equal to another matrix.
Definition Matrix4.hpp:351
bool operator==(const t_Matrix4 &rhs) const
Equality comparison operator.
Definition Matrix4.hpp:648
const T * data() const
Gets a const pointer to the underlying data.
Definition Matrix4.hpp:375
t_Vector4< T > value[4]
Column vectors comprising the matrix.
Definition Matrix4.hpp:102
t_Matrix4 & operator*=(T scalar)
Scalar multiplication assignment operator.
Definition Matrix4.hpp:408
void set(T v0, T v1, T v2, T v3, T v4, T v5, T v6, T v7, T v8, T v9, T v10, T v11, T v12, T v13, T v14, T v15)
Sets all sixteen matrix elements.
Definition Matrix4.hpp:333
t_Matrix4 operator*(T scalar) const
Scalar multiplication operator.
Definition Matrix4.hpp:390
t_Matrix4 & operator+=(const t_Matrix4 &rhs)
Matrix addition assignment operator.
Definition Matrix4.hpp:532
t_Matrix4 & operator/=(T scalar)
Scalar division assignment operator.
Definition Matrix4.hpp:620
t_Matrix4 & operator*=(const t_Matrix4 &rhs)
Matrix multiplication assignment operator.
Definition Matrix4.hpp:468
t_Matrix4(const t_Matrix4< R > &rhs)
Type-converting constructor.
Definition Matrix4.hpp:226
constexpr t_Matrix4(T v0, T v1, T v2, T v3, T v4, T v5, T v6, T v7, T v8, T v9, T v10, T v11, T v12, T v13, T v14, T v15)
Constructs a matrix from sixteen individual elements.
Definition Matrix4.hpp:162
const t_Vector4< T > & operator[](size_t c) const
Column access operator (const).
Definition Matrix4.hpp:278
t_Vector4< T > operator*(const t_Vector4< T > &v) const
Matrix-vector multiplication operator.
Definition Matrix4.hpp:496
t_Matrix4 operator+(const t_Matrix4 &rhs) const
Matrix addition operator.
Definition Matrix4.hpp:514
constexpr t_Matrix4(const t_Vector4< T > &c0, const t_Vector4< T > &c1, const t_Vector4< T > &c2, const t_Vector4< T > &c3)
Constructs a matrix from four column vectors.
Definition Matrix4.hpp:209
bool operator<(const t_Matrix4 &rhs) const
Less-than comparison operator for ordering.
Definition Matrix4.hpp:676
t_Matrix4 & operator-=(const t_Matrix4 &rhs)
Matrix subtraction assignment operator.
Definition Matrix4.hpp:567
bool operator!=(const t_Matrix4 &rhs) const
Inequality comparison operator.
Definition Matrix4.hpp:662
T & operator()(size_t c, size_t r)
Element access operator (mutable).
Definition Matrix4.hpp:294
constexpr t_Matrix4()
Default constructor.
Definition Matrix4.hpp:115
constexpr size_t rows() const
Gets the number of rows in the matrix.
Definition Matrix4.hpp:253
t_Matrix4 transpose() const
Computes the transpose of this matrix.
Definition Matrix4.hpp:705
t_Matrix4 operator*(const t_Matrix4 &rhs) const
Matrix multiplication operator.
Definition Matrix4.hpp:435
constexpr size_t columns() const
Gets the number of columns in the matrix.
Definition Matrix4.hpp:246
t_Matrix4 operator-(const t_Matrix4 &rhs) const
Matrix subtraction operator.
Definition Matrix4.hpp:549
T operator()(size_t c, size_t r) const
Element access operator (const).
Definition Matrix4.hpp:305
t_Matrix4 operator/(T scalar) const
Scalar division operator.
Definition Matrix4.hpp:587
T * data()
Gets a pointer to the underlying data.
Definition Matrix4.hpp:368
constexpr size_t size() const
Gets the total number of elements in the matrix.
Definition Matrix4.hpp:239
Template structure representing a 4-component vector.
Definition Vector4.hpp:85
T y
Definition Vector4.hpp:100
T x
Definition Vector4.hpp:100
T z
Definition Vector4.hpp:100