diff --git a/include/J3ML/LinearAlgebra/Matrix2x2.h b/include/J3ML/LinearAlgebra/Matrix2x2.h index 9ff362f..7a5b894 100644 --- a/include/J3ML/LinearAlgebra/Matrix2x2.h +++ b/include/J3ML/LinearAlgebra/Matrix2x2.h @@ -6,12 +6,19 @@ namespace LinearAlgebra { class Matrix2x2 { public: + enum { Rows = 3 }; + enum { Cols = 3 }; static const Matrix2x2 Zero; static const Matrix2x2 Identity; static const Matrix2x2 NaN; - Vector2 GetRow() const; - Vector2 GetColumn() const; + Vector2 GetRow(int index) const; + Vector2 GetColumn(int index) const; + float At(int x, int y) const; + + + Vector2 operator * (const Vector2& rhs) const; + Matrix2x2 operator * (const Matrix2x2 &rhs) const; protected: float elems[2][2]; diff --git a/src/J3ML/LinearAlgebra/Matrix2x2.cpp b/src/J3ML/LinearAlgebra/Matrix2x2.cpp index e87685f..9f13257 100644 --- a/src/J3ML/LinearAlgebra/Matrix2x2.cpp +++ b/src/J3ML/LinearAlgebra/Matrix2x2.cpp @@ -2,4 +2,20 @@ namespace LinearAlgebra { + Vector2 Matrix2x2::GetRow(int index) const { + float x = this->elems[index][0]; + float y = this->elems[index][1]; + + return {x, y}; + } + + Vector2 Matrix2x2::GetColumn(int index) const { + float x = this->elems[0][index]; + float y = this->elems[1][index]; + return {x, y}; + } + + float Matrix2x2::At(int x, int y) const { + return this->elems[x][y]; + } } \ No newline at end of file