5#include <Infinity/Types/Core/Value.hpp>
6#include <Infinity/Types/Containers/Array.hpp>
7#include <Infinity/Types/Math/Vector3.hpp>
176 value{{v[0], v[1], v[2]},
178 {v[6], v[7], v[8]}} {}
224 constexpr size_t size()
const {
return 9; }
231 constexpr size_t columns()
const {
return 3; }
238 constexpr size_t rows()
const {
return 3; }
290 T
operator()(
size_t c,
size_t r)
const {
return value[c][r]; }
317 void set(T v0, T v1, T v2,
321 value[0].set(v0, v1, v2);
322 value[1].set(v3, v4, v5);
323 value[2].set(v6, v7, v8);
348 T*
data() {
return value[0].data(); }
355 const T*
data()
const {
return value[0].data(); }
373 value[0].x * rhs.
value[0].x + value[0].y * rhs.
value[1].x + value[0].z * rhs.
value[2].x,
374 value[0].x * rhs.
value[0].y + value[0].y * rhs.
value[1].y + value[0].z * rhs.
value[2].y,
375 value[0].x * rhs.
value[0].z + value[0].y * rhs.
value[1].z + value[0].z * rhs.
value[2].z,
377 value[1].x * rhs.
value[0].x + value[1].y * rhs.
value[1].x + value[1].z * rhs.
value[2].x,
378 value[1].x * rhs.
value[0].y + value[1].y * rhs.
value[1].y + value[1].z * rhs.
value[2].y,
379 value[1].x * rhs.
value[0].z + value[1].y * rhs.
value[1].z + value[1].z * rhs.
value[2].z,
381 value[2].x * rhs.
value[0].x + value[2].y * rhs.
value[1].x + value[2].z * rhs.
value[2].x,
382 value[2].x * rhs.
value[0].y + value[2].y * rhs.
value[1].y + value[2].z * rhs.
value[2].y,
383 value[2].x * rhs.
value[0].z + value[2].y * rhs.
value[1].z + value[2].z * rhs.
value[2].z
417 value[0].x * scalar, value[0].y * scalar, value[0].z * scalar,
418 value[1].x * scalar, value[1].y * scalar, value[1].z * scalar,
419 value[2].x * scalar, value[2].y * scalar, value[2].z * scalar
456 value[0].x * v.
x + value[0].y * v.
y + value[0].z * v.
z,
457 value[1].x * v.
x + value[1].y * v.
y + value[1].z * v.
z,
458 value[2].x * v.
x + value[2].y * v.
y + value[2].z * v.
z
473 value[0].x + rhs.
value[0].x, value[0].y + rhs.
value[0].y, value[0].z + rhs.
value[0].z,
474 value[1].x + rhs.
value[1].x, value[1].y + rhs.
value[1].y, value[1].z + rhs.
value[1].z,
475 value[2].x + rhs.
value[2].x, value[2].y + rhs.
value[2].y, value[2].z + rhs.
value[2].z
489 value[0] += rhs.
value[0];
490 value[1] += rhs.
value[1];
491 value[2] += rhs.
value[2];
506 value[0].x - rhs.
value[0].x, value[0].y - rhs.
value[0].y, value[0].z - rhs.
value[0].z,
507 value[1].x - rhs.
value[1].x, value[1].y - rhs.
value[1].y, value[1].z - rhs.
value[1].z,
508 value[2].x - rhs.
value[2].x, value[2].y - rhs.
value[2].y, value[2].z - rhs.
value[2].z
522 value[0] -= rhs.
value[0];
523 value[1] -= rhs.
value[1];
524 value[2] -= rhs.
value[2];
541 if constexpr (std::is_floating_point_v<T>)
543 T inv =
static_cast<T
>(1.0) / scalar;
545 value[0].x * inv, value[0].y * inv, value[0].z * inv,
546 value[1].x * inv, value[1].y * inv, value[1].z * inv,
547 value[2].x * inv, value[2].y * inv, value[2].z * inv
553 value[0].x / scalar, value[0].y / scalar, value[0].z / scalar,
554 value[1].x / scalar, value[1].y / scalar, value[1].z / scalar,
555 value[2].x / scalar, value[2].y / scalar, value[2].z / scalar
572 if constexpr (std::is_floating_point_v<T>)
574 T inv =
static_cast<T
>(1.0) / scalar;
598 return value[0] == rhs.
value[0] &&
599 value[1] == rhs.
value[1] &&
600 value[2] == rhs.
value[2];
611 return !(*
this == rhs);
625 if (value[0] < rhs.
value[0])
return true;
626 if (value[0] > rhs.
value[0])
return false;
627 if (value[1] < rhs.
value[1])
return true;
628 if (value[1] > rhs.
value[1])
return false;
629 return value[2] < rhs.
value[2];
649 value[0].x, value[1].x, value[2].x,
650 value[0].y, value[1].y, value[2].y,
651 value[0].z, value[1].z, value[2].z
665 -value[0].x, -value[0].y, -value[0].z,
666 -value[1].x, -value[1].y, -value[1].z,
667 -value[2].x, -value[2].y, -value[2].z
678 explicit operator bool() const noexcept
709 inline std::ostream& operator<<(std::ostream& out,
const t_Matrix3<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 3x3 matrix.
Definition Matrix3.hpp:83
constexpr size_t columns() const
Gets the number of columns in the matrix.
Definition Matrix3.hpp:231
T & operator()(size_t c, size_t r)
Element access operator (mutable).
Definition Matrix3.hpp:279
t_Vector3< T > operator*(const t_Vector3< T > &v) const
Matrix-vector multiplication operator.
Definition Matrix3.hpp:453
void set(T v0, T v1, T v2, T v3, T v4, T v5, T v6, T v7, T v8)
Sets all nine matrix elements.
Definition Matrix3.hpp:317
t_Matrix3 & operator/=(T scalar)
Scalar division assignment operator.
Definition Matrix3.hpp:570
const t_Vector3< T > & operator[](size_t c) const
Column access operator (const).
Definition Matrix3.hpp:263
bool operator!=(const t_Matrix3 &rhs) const
Inequality comparison operator.
Definition Matrix3.hpp:609
t_Matrix3 operator-(const t_Matrix3 &rhs) const
Matrix subtraction operator.
Definition Matrix3.hpp:503
constexpr t_Matrix3(T v[9])
Constructs a matrix from an array of nine elements.
Definition Matrix3.hpp:175
t_Matrix3 operator*(const t_Matrix3 &rhs) const
Matrix multiplication operator.
Definition Matrix3.hpp:370
t_Matrix3 operator/(T scalar) const
Scalar division operator.
Definition Matrix3.hpp:539
const T * data() const
Gets a const pointer to the underlying data.
Definition Matrix3.hpp:355
t_Matrix3 & operator=(const t_Matrix3< R > &rhs)
Type-converting assignment operator.
Definition Matrix3.hpp:302
constexpr t_Matrix3(T v0, T v1, T v2, T v3, T v4, T v5, T v6, T v7, T v8)
Constructs a matrix from nine individual elements.
Definition Matrix3.hpp:154
constexpr size_t rows() const
Gets the number of rows in the matrix.
Definition Matrix3.hpp:238
T operator()(size_t c, size_t r) const
Element access operator (const).
Definition Matrix3.hpp:290
constexpr t_Matrix3(const t_Vector3< T > &c0, const t_Vector3< T > &c1, const t_Vector3< T > &c2)
Constructs a matrix from three column vectors.
Definition Matrix3.hpp:196
t_Matrix3 operator-() const
Unary negation operator.
Definition Matrix3.hpp:662
t_Matrix3 & operator*=(T scalar)
Scalar multiplication assignment operator.
Definition Matrix3.hpp:431
constexpr t_Matrix3()
Default constructor.
Definition Matrix3.hpp:103
t_Matrix3(const t_Matrix3< R > &rhs)
Type-converting constructor.
Definition Matrix3.hpp:212
void set(const t_Matrix3< R > &rhs)
Sets this matrix equal to another matrix.
Definition Matrix3.hpp:333
constexpr size_t size() const
Gets the total number of elements in the matrix.
Definition Matrix3.hpp:224
t_Vector3< T > & operator[](size_t c)
Column access operator (mutable).
Definition Matrix3.hpp:253
bool operator<(const t_Matrix3 &rhs) const
Less-than comparison operator for ordering.
Definition Matrix3.hpp:623
t_Matrix3 operator+(const t_Matrix3 &rhs) const
Matrix addition operator.
Definition Matrix3.hpp:470
constexpr t_Matrix3(T v)
Constructs a diagonal matrix with the same value on the diagonal.
Definition Matrix3.hpp:124
t_Matrix3 & operator+=(const t_Matrix3 &rhs)
Matrix addition assignment operator.
Definition Matrix3.hpp:487
t_Vector3< T > value[3]
Column vectors comprising the matrix.
Definition Matrix3.hpp:91
T * data()
Gets a pointer to the underlying data.
Definition Matrix3.hpp:348
t_Matrix3 transpose() const
Computes the transpose of this matrix.
Definition Matrix3.hpp:646
bool operator==(const t_Matrix3 &rhs) const
Equality comparison operator.
Definition Matrix3.hpp:596
t_Matrix3 & operator*=(const t_Matrix3 &rhs)
Matrix multiplication assignment operator.
Definition Matrix3.hpp:395
t_Matrix3 operator*(T scalar) const
Scalar multiplication operator.
Definition Matrix3.hpp:414
t_Matrix3 & operator-=(const t_Matrix3 &rhs)
Matrix subtraction assignment operator.
Definition Matrix3.hpp:520
Template structure representing a 3-component vector.
Definition Vector3.hpp:82
T x
Definition Vector3.hpp:97
T z
Cartesian coordinate interpretation.
Definition Vector3.hpp:97
T y
Definition Vector3.hpp:97