Matrix4x4.h
Go to the documentation of this file.
#pragma once
#include <cstring>
#include <array>
#include <ostream>
namespace Eule
{
template <class T>
class Vector3;
typedef Vector3<double> Vector3d;
class Matrix4x4
{
public:
Matrix4x4();
Matrix4x4(const Matrix4x4& other);
Matrix4x4(Matrix4x4&& other) noexcept;
std::array<std::array<double, 4>, 4> v;
Matrix4x4 operator*(const Matrix4x4& other) const;
void operator*=(const Matrix4x4& other);
Matrix4x4 operator/(const Matrix4x4& other) const;
void operator/=(const Matrix4x4& other);
Matrix4x4 operator*(const double scalar) const;
void operator*=(const double scalar);
Matrix4x4 operator/(const double denominator) const;
void operator/=(const double denominator);
Matrix4x4 operator+(const Matrix4x4& other) const;
void operator+=(const Matrix4x4& other);
Matrix4x4 operator-(const Matrix4x4& other) const;
void operator-=(const Matrix4x4& other);
std::array<double, 4>& operator[](std::size_t y);
const std::array<double, 4>& operator[](std::size_t y) const;
void operator=(const Matrix4x4& other);
void operator=(Matrix4x4&& other) noexcept;
bool operator==(const Matrix4x4& other);
bool operator!=(const Matrix4x4& other);
const Vector3d GetTranslationComponent() const;
void SetTranslationComponent(const Vector3d& trans);
Matrix4x4 DropTranslationComponents() const;
Matrix4x4 Transpose3x3() const;
Matrix4x4 Transpose4x4() const;
Matrix4x4 Multiply4x4(const Matrix4x4& o) const;
Matrix4x4 GetCofactors(std::size_t p, std::size_t q, std::size_t n) const;
double Determinant(std::size_t n) const;
Matrix4x4 Adjoint(std::size_t n) const;
Matrix4x4 Inverse3x3() const;
Matrix4x4 Inverse4x4() const;
bool IsInversible3x3() const;
bool IsInversible4x4() const;
bool Similar(const Matrix4x4& other, double epsilon = 0.00001) const;
friend std::ostream& operator<<(std::ostream& os, const Matrix4x4& m);
friend std::wostream& operator<<(std::wostream& os, const Matrix4x4& m);
// Shorthands
double& a = v[0][0];
double& b = v[0][1];
double& c = v[0][2];
double& d = v[0][3];
double& e = v[1][0];
double& f = v[1][1];
double& g = v[1][2];
double& h = v[1][3];
double& i = v[2][0];
double& j = v[2][1];
double& k = v[2][2];
double& l = v[2][3];
double& m = v[3][0];
double& n = v[3][1];
double& o = v[3][2];
double& p = v[3][3];
};
}
Eule::Matrix4x4::j
double & j
Definition: Matrix4x4.h:137
Eule::Matrix4x4::Inverse4x4
Matrix4x4 Inverse4x4() const
Will return the full 4x4-inverse of this matrix.
Definition: Matrix4x4.cpp:577
Eule::Matrix4x4::Adjoint
Matrix4x4 Adjoint(std::size_t n) const
Will return the adjoint of this matrix, by dimension n.
Definition: Matrix4x4.cpp:533
Eule::Matrix4x4::operator==
bool operator==(const Matrix4x4 &other)
Definition: Matrix4x4.cpp:397
Eule::Matrix4x4::operator+
Matrix4x4 operator+(const Matrix4x4 &other) const
Cellwise addition.
Definition: Matrix4x4.cpp:221
Eule::Matrix4x4::i
double & i
Definition: Matrix4x4.h:136
Eule::Matrix4x4::operator-=
void operator-=(const Matrix4x4 &other)
Cellwise subtraction.
Definition: Matrix4x4.cpp:338
Eule::Matrix4x4::Transpose4x4
Matrix4x4 Transpose4x4() const
Will return the 4x4 transpose of this matrix.
Definition: Matrix4x4.cpp:440
Eule::Matrix4x4::operator!=
bool operator!=(const Matrix4x4 &other)
Definition: Matrix4x4.cpp:402
Eule::Vector3
Representation of a 3d vector.
Definition: Matrix4x4.h:9
Eule::Matrix4x4::operator[]
std::array< double, 4 > & operator[](std::size_t y)
Definition: Matrix4x4.cpp:375
Eule::Matrix4x4::DropTranslationComponents
Matrix4x4 DropTranslationComponents() const
Will return this Matrix4x4 with d,h,l being set to 0.
Definition: Matrix4x4.cpp:420
Eule::Matrix4x4::e
double & e
Definition: Matrix4x4.h:132
Eule::Matrix4x4::f
double & f
Definition: Matrix4x4.h:133
Eule::Matrix4x4::operator*=
void operator*=(const Matrix4x4 &other)
Definition: Matrix4x4.cpp:147
Eule::Matrix4x4::Inverse3x3
Matrix4x4 Inverse3x3() const
Will return the 3x3-inverse of this matrix.
Definition: Matrix4x4.cpp:558
Eule::Matrix4x4::k
double & k
Definition: Matrix4x4.h:138
Eule::Matrix4x4::operator/
Matrix4x4 operator/(const Matrix4x4 &other) const
Definition: Matrix4x4.cpp:153
Eule::Matrix4x4::v
std::array< std::array< double, 4 >, 4 > v
Array holding the matrices values.
Definition: Matrix4x4.h:44
Eule::Matrix4x4::operator*
Matrix4x4 operator*(const Matrix4x4 &other) const
Definition: Matrix4x4.cpp:34
Eule::Vector3d
Vector3< double > Vector3d
Definition: Matrix4x4.h:9
Eule::Matrix4x4::operator=
void operator=(const Matrix4x4 &other)
Definition: Matrix4x4.cpp:385
Eule::Matrix4x4
A matrix 4x4 class representing a 3d transformation.
Definition: Matrix4x4.h:36
Eule::Matrix4x4::IsInversible4x4
bool IsInversible4x4() const
Will check if the entire matrix is inversible.
Definition: Matrix4x4.cpp:603
Eule::Matrix4x4::b
double & b
Definition: Matrix4x4.h:129
Eule::Matrix4x4::Similar
bool Similar(const Matrix4x4 &other, double epsilon=0.00001) const
Will compare if two matrices are similar to a certain epsilon value.
Definition: Matrix4x4.cpp:608
Eule::Matrix4x4::g
double & g
Definition: Matrix4x4.h:134
Eule::Matrix4x4::operator/=
void operator/=(const Matrix4x4 &other)
Definition: Matrix4x4.cpp:158
Eule::Matrix4x4::operator<<
friend std::ostream & operator<<(std::ostream &os, const Matrix4x4 &m)
Definition: Matrix4x4.cpp:620
Eule::Matrix4x4::p
double & p
Definition: Matrix4x4.h:143
Eule::Matrix4x4::IsInversible3x3
bool IsInversible3x3() const
Will check if the 3x3-component is inversible.
Definition: Matrix4x4.cpp:598
Eule::Matrix4x4::Transpose3x3
Matrix4x4 Transpose3x3() const
Will return the 3x3 transpose of this matrix.
Definition: Matrix4x4.cpp:429
Eule::Matrix4x4::l
double & l
Definition: Matrix4x4.h:139
Eule::Matrix4x4::operator-
Matrix4x4 operator-(const Matrix4x4 &other) const
Cellwise subtraction.
Definition: Matrix4x4.cpp:298
Eule::Matrix4x4::Determinant
double Determinant(std::size_t n) const
Will return the determinant, by dimension n.
Definition: Matrix4x4.cpp:511
Eule::Matrix4x4::operator+=
void operator+=(const Matrix4x4 &other)
Cellwise addition.
Definition: Matrix4x4.cpp:261
Eule::Matrix4x4::Matrix4x4
Matrix4x4()
Definition: Matrix4x4.cpp:12
Eule::Matrix4x4::SetTranslationComponent
void SetTranslationComponent(const Vector3d &trans)
Will set d,h,l from a Vector3d(x,y,z)
Definition: Matrix4x4.cpp:412
Eule::Matrix4x4::c
double & c
Definition: Matrix4x4.h:130
Eule::Matrix4x4::Multiply4x4
Matrix4x4 Multiply4x4(const Matrix4x4 &o) const
Will return the Matrix4x4 of an actual 4x4 multiplication. operator* only does a 3x3.
Definition: Matrix4x4.cpp:451
Eule::Matrix4x4::o
double & o
Definition: Matrix4x4.h:142
Eule::Matrix4x4::a
double & a
Definition: Matrix4x4.h:128
Eule::Matrix4x4::m
double & m
Definition: Matrix4x4.h:140
Eule::Matrix4x4::GetCofactors
Matrix4x4 GetCofactors(std::size_t p, std::size_t q, std::size_t n) const
Will return the cofactors of this matrix, by dimension n.
Definition: Matrix4x4.cpp:478
Eule::Matrix4x4::GetTranslationComponent
const Vector3d GetTranslationComponent() const
Will return d,h,l as a Vector3d(x,y,z)
Definition: Matrix4x4.cpp:407
Eule::Matrix4x4::n
double & n
Definition: Matrix4x4.h:141
Eule::Matrix4x4::h
double & h
Definition: Matrix4x4.h:135
Eule
Definition: Collider.h:4
Eule::Matrix4x4::d
double & d
Definition: Matrix4x4.h:131