t
|
The \(3 \times 3\) matrix class. More...
#include <Matrix3x3.hpp>
Public Member Functions | |
Matrix3x3 (double _n11, double _n12, double _n13, double _n21, double _n22, double _n23, double _n31, double _n32, double _n33) | |
Creates a new \(3 \times 3\) matrix with the specified elements. | |
Matrix3x3 | clone () const |
Returns a copy of this matrix. | |
Matrix3x3 & | copy (const Matrix3x3 &source) |
Copies the elements of another \(3 \times 3\) matrix into this matrix. | |
Matrix3x3 & | set (double _n11, double _n12, double _n13, double _n21, double _n22, double _n23, double _n31, double _n32, double _n33) |
Sets the elements of this matrix. | |
double | get (int row, int column) const |
Gets the element at the specified row and column of this matrix with bounds checking. | |
Matrix3x3 & | set (int row, int column, int value) |
Sets the element at the specified row and column of this matrix to the specified value. | |
Matrix3x3 & | reset () |
Resets this matrix to the \(3 \times 3\) identity matrix. | |
double | determinant () const |
Returns the determinant of this matrix. | |
Matrix3x3 | transpose () const |
Returns the transpose of this matrix. | |
Matrix3x3 | inverse () const |
Returns the inverse of this matrix or the zero matrix if this matrix does not have an inverse. | |
double | operator[] (std::size_t index) const |
Returns the element at the specified index of this matrix without bounds checking and assuming row-major ordering. | |
Matrix3x3 & | operator+= (const Matrix3x3 &m) |
Adds the specified \(3 \times 3\) matrix to this matrix. | |
Matrix3x3 & | operator+= (double s) |
Adds the specified constant to all elements in this matrix. | |
Matrix3x3 & | operator-= (const Matrix3x3 &m) |
Substracts the specified \(3 \times 3\) matrix from this matrix. | |
Matrix3x3 & | operator-= (double s) |
Substracts the specified constant from all elements in this matrix. | |
Matrix3x3 & | operator*= (const Matrix3x3 &m) |
Multiplies this matrix with another \(3 \times 3\) matrix and copies the result into this instance. | |
Matrix3x3 & | operator*= (double s) |
Multiplies the elements of this matrix with the specified constant. | |
Matrix3x3 & | operator/= (const Matrix3x3 &m) |
Divides the elements of this matrix by the corresponding elements of the specified \(3 \times 3\) matrix. | |
Matrix3x3 & | operator/= (double s) |
Divides the elements of this matrix with the specified constant. | |
Static Public Member Functions | |
static Matrix3x3 | identity () |
Returns a \(3 \times 3\) identity matrix. | |
static Matrix3x3 | zero () |
Returns a \(3 \times 3\) zero matrix. | |
Public Attributes | |
std::array< double, 9 > | elements |
The array containing the elements of this matrix in row-major order. | |
Friends | |
bool | operator== (const Matrix3x3 &a, const Matrix3x3 &b)=default |
Returns whether two \(3 \times 3\) matrices are equal. | |
Matrix3x3 | operator+ (const Matrix3x3 &a, const Matrix3x3 &b) |
Adds two \(3 \times 3\) matrices. | |
Matrix3x3 | operator+ (const Matrix3x3 &a, double s) |
Adds a constant to all elements of a \(3 \times 3\) matrix. | |
Matrix3x3 | operator+ (double s, const Matrix3x3 &a) |
Adds a constant to all elements of a \(3 \times 3\) matrix. | |
Matrix3x3 | operator- (const Matrix3x3 &a, const Matrix3x3 &b) |
Substracts 2 \(3 \times 3\) matrices. | |
Matrix3x3 | operator- (const Matrix3x3 &a, double s) |
Substracts a constant from all elements of a \(3 \times 3\) matrix. | |
Matrix3x3 | operator- (double s, const Matrix3x3 &a) |
Substracts a \(3 \times 3\) matrix from a \(3 \times 3\) constant matrix. | |
Matrix3x3 | operator* (const Matrix3x3 &a, const Matrix3x3 &b) |
Multiplies two \(3 \times 3\) matrices. | |
Matrix3x3 | operator* (const Matrix3x3 &a, double s) |
Multiplies all elements of a \(3 \times 3\) matrix with a constant. | |
Matrix3x3 | operator* (double s, const Matrix3x3 &a) |
Multiplies all elements of a \(3 \times 3\) matrix with a constant. | |
Vector3 | operator* (const Matrix3x3 &a, const Vector3 &v) |
Multiplies a \(3 \times 3\) matrix with a 3D vector. | |
Matrix3x3 | operator/ (const Matrix3x3 &a, const Matrix3x3 &b) |
Returns the element-wise division of two \(3 \times 3\) matrices. | |
Matrix3x3 | operator/ (const Matrix3x3 &a, double s) |
Divides all elements of a \(3 \times 3\) matrix by a constant. | |
Matrix3x3 | operator/ (double s, const Matrix3x3 &a) |
Returns the element-wise division of a \(3 \times 3\) constant matrix and a \(3 \times 3\) matrix. | |
The \(3 \times 3\) matrix class.
|
inline |
Creates a new \(3 \times 3\) matrix with the specified elements.
_n11 | The \((1, 1)\) element of the new matrix. |
_n12 | The \((1, 2)\) element of the new matrix. |
_n13 | The \((1, 3)\) element of the new matrix. |
_n21 | The \((2, 1)\) element of the new matrix. |
_n22 | The \((2, 2)\) element of the new matrix. |
_n23 | The \((2, 3)\) element of the new matrix. |
_n31 | The \((3, 1)\) element of the new matrix. |
_n32 | The \((3, 2)\) element of the new matrix. |
_n33 | The \((3, 3)\) element of the new matrix. |
|
inline |
Returns a copy of this matrix.
Copies the elements of another \(3 \times 3\) matrix into this matrix.
source | The \(3 \times 3\) matrix to copy from. |
|
inline |
Returns the determinant of this matrix.
|
inline |
Gets the element at the specified row and column of this matrix with bounds checking.
row | The 0-based index of the row of the element. |
column | The 0-based index of the column of the element. |
std::out_of_range | if the row or column is out of bounds. |
operator[]
for accessing without bounds checking.
|
inlinestatic |
Returns a \(3 \times 3\) identity matrix.
|
inline |
Returns the inverse of this matrix or the zero matrix if this matrix does not have an inverse.
The inverse of a matrix \(A\) is the matrix \(A^{-1}\) such that \(AA^{-1} = I\) where \(I\) is the identity matrix. A matrix does not have an inverse if its determinant is zero.
Note that this method does not modify this instance.
Multiplies this matrix with another \(3 \times 3\) matrix and copies the result into this instance.
Note that this is not an element-wise multiplication, but matrix multiplication.
m | A \(3 \times 3\) matrix to multiply with. |
|
inline |
Multiplies the elements of this matrix with the specified constant.
s | A constant. |
Adds the specified \(3 \times 3\) matrix to this matrix.
m | A \(3 \times 3\) matrix. |
|
inline |
Adds the specified constant to all elements in this matrix.
s | A constant. |
Substracts the specified \(3 \times 3\) matrix from this matrix.
m | A \(3 \times 3\) matrix. |
|
inline |
Substracts the specified constant from all elements in this matrix.
s | A constant. |
Divides the elements of this matrix by the corresponding elements of the specified \(3 \times 3\) matrix.
m | A \(3 \times 3\) matrix. |
|
inline |
Divides the elements of this matrix with the specified constant.
s | A constant. |
|
inline |
Returns the element at the specified index of this matrix without bounds checking and assuming row-major ordering.
The element at row \(i\) and column \(j\) of this matrix has the index \(3i + j\) assuming \(i\) and \(j\) are zero-based.
index | The 0-based index of the element in row-major order. |
get
for accessing with bounds checking.
|
inline |
Resets this matrix to the \(3 \times 3\) identity matrix.
|
inline |
Sets the elements of this matrix.
_n11 | The new \((1, 1)\) element of this matrix. |
_n12 | The new \((1, 2)\) element of this matrix. |
_n13 | The new \((1, 3)\) element of this matrix. |
_n21 | The new \((2, 1)\) element of this matrix. |
_n22 | The new \((2, 2)\) element of this matrix. |
_n23 | The new \((2, 3)\) element of this matrix. |
_n31 | The new \((3, 1)\) element of this matrix. |
_n32 | The new \((3, 2)\) element of this matrix. |
_n33 | The new \((3, 3)\) element of this matrix. |
|
inline |
Sets the element at the specified row and column of this matrix to the specified value.
row | The 0-based index of the row of the element. |
column | The 0-based index of the column of the element. |
value | The new value for the element. |
|
inline |
Returns the transpose of this matrix.
Note that this method does not modify this instance.
|
inlinestatic |
Returns a \(3 \times 3\) zero matrix.
Multiplies two \(3 \times 3\) matrices.
Note that this is not an element-wise multiplication, but matrix multiplication.
a | A \(3 \times 3\) matrix. |
b | Another \(3 \times 3\) matrix. |
a
and b
. Multiplies a \(3 \times 3\) matrix with a 3D vector.
a | A \(3 \times 3\) matrix. |
v | A 3D vector. |
a
and v
. Multiplies all elements of a \(3 \times 3\) matrix with a constant.
a | A \(3 \times 3\) matrix. |
s | A constant. |
a
with s
. Multiplies all elements of a \(3 \times 3\) matrix with a constant.
s | A constant. |
a | A \(3 \times 3\) matrix. |
a
with s
. Adds two \(3 \times 3\) matrices.
a | A \(3 \times 3\) matrix. |
b | Another \(3 \times 3\) matrix. |
a
and b
. Adds a constant to all elements of a \(3 \times 3\) matrix.
a | A \(3 \times 3\) matrix. |
s | A constant. |
s
to all elements of a
. Adds a constant to all elements of a \(3 \times 3\) matrix.
s | A constant. |
a | A \(3 \times 3\) matrix. |
s
to all elements of a
. Substracts 2 \(3 \times 3\) matrices.
a | A \(3 \times 3\) matrix. |
b | Another \(3 \times 3\) matrix. |
a
and b
. Substracts a constant from all elements of a \(3 \times 3\) matrix.
a | A \(3 \times 3\) matrix. |
s | A constant. |
s
from all elements of a
. Substracts a \(3 \times 3\) matrix from a \(3 \times 3\) constant matrix.
s | A constant for a \(3 \times 3\) constant matrix. |
a | A \(3 \times 3\) matrix. |
a
from the constant matrix of s
. Returns the element-wise division of two \(3 \times 3\) matrices.
a | A \(3 \times 3\) matrix. |
b | Another \(3 \times 3\) matrix. |
a
and b
. Divides all elements of a \(3 \times 3\) matrix by a constant.
a | A \(3 \times 3\) matrix. |
s | A constant. |
a
by s
. Returns the element-wise division of a \(3 \times 3\) constant matrix and a \(3 \times 3\) matrix.
s | A constant for a \(3 \times 3\) constant matrix. |
a | Another \(3 \times 3\) matrix. |
a
. Returns whether two \(3 \times 3\) matrices are equal.
a | A \(3 \times 3\) matrix. |
b | Another \(3 \times 3\) matrix. |
true
if a
equals b
, false
otherwise.