t
Loading...
Searching...
No Matches
t::Matrix3x3 Class Reference

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.
 
Matrix3x3copy (const Matrix3x3 &source)
 Copies the elements of another \(3 \times 3\) matrix into this matrix.
 
Matrix3x3set (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.
 
Matrix3x3set (int row, int column, int value)
 Sets the element at the specified row and column of this matrix to the specified value.
 
Matrix3x3reset ()
 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.
 
Matrix3x3operator+= (const Matrix3x3 &m)
 Adds the specified \(3 \times 3\) matrix to this matrix.
 
Matrix3x3operator+= (double s)
 Adds the specified constant to all elements in this matrix.
 
Matrix3x3operator-= (const Matrix3x3 &m)
 Substracts the specified \(3 \times 3\) matrix from this matrix.
 
Matrix3x3operator-= (double s)
 Substracts the specified constant from all elements in this matrix.
 
Matrix3x3operator*= (const Matrix3x3 &m)
 Multiplies this matrix with another \(3 \times 3\) matrix and copies the result into this instance.
 
Matrix3x3operator*= (double s)
 Multiplies the elements of this matrix with the specified constant.
 
Matrix3x3operator/= (const Matrix3x3 &m)
 Divides the elements of this matrix by the corresponding elements of the specified \(3 \times 3\) matrix.
 
Matrix3x3operator/= (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.
 

Detailed Description

The \(3 \times 3\) matrix class.

Constructor & Destructor Documentation

◆ Matrix3x3()

t::Matrix3x3::Matrix3x3 ( double _n11,
double _n12,
double _n13,
double _n21,
double _n22,
double _n23,
double _n31,
double _n32,
double _n33 )
inline

Creates a new \(3 \times 3\) matrix with the specified elements.

Parameters
_n11The \((1, 1)\) element of the new matrix.
_n12The \((1, 2)\) element of the new matrix.
_n13The \((1, 3)\) element of the new matrix.
_n21The \((2, 1)\) element of the new matrix.
_n22The \((2, 2)\) element of the new matrix.
_n23The \((2, 3)\) element of the new matrix.
_n31The \((3, 1)\) element of the new matrix.
_n32The \((3, 2)\) element of the new matrix.
_n33The \((3, 3)\) element of the new matrix.

Member Function Documentation

◆ clone()

Matrix3x3 t::Matrix3x3::clone ( ) const
inline

Returns a copy of this matrix.

Returns
A copy of this matrix.

◆ copy()

Matrix3x3 & t::Matrix3x3::copy ( const Matrix3x3 & source)
inline

Copies the elements of another \(3 \times 3\) matrix into this matrix.

Parameters
sourceThe \(3 \times 3\) matrix to copy from.
Returns
This matrix.

◆ determinant()

double t::Matrix3x3::determinant ( ) const
inline

Returns the determinant of this matrix.

Returns
The determinant of this matrix.

◆ get()

double t::Matrix3x3::get ( int row,
int column ) const
inline

Gets the element at the specified row and column of this matrix with bounds checking.

Parameters
rowThe 0-based index of the row of the element.
columnThe 0-based index of the column of the element.
Returns
The element at the specified row and column of this matrix.
Exceptions
std::out_of_rangeif the row or column is out of bounds.
See also
operator[] for accessing without bounds checking.

◆ identity()

static Matrix3x3 t::Matrix3x3::identity ( )
inlinestatic

Returns a \(3 \times 3\) identity matrix.

Returns
A \(3 \times 3\) identity matrix.

◆ inverse()

Matrix3x3 t::Matrix3x3::inverse ( ) const
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.

Returns
The inverse of this matrix.

◆ operator*=() [1/2]

Matrix3x3 & t::Matrix3x3::operator*= ( const Matrix3x3 & m)
inline

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.

Parameters
mA \(3 \times 3\) matrix to multiply with.
Returns
This matrix.

◆ operator*=() [2/2]

Matrix3x3 & t::Matrix3x3::operator*= ( double s)
inline

Multiplies the elements of this matrix with the specified constant.

Parameters
sA constant.
Returns
This matrix.

◆ operator+=() [1/2]

Matrix3x3 & t::Matrix3x3::operator+= ( const Matrix3x3 & m)
inline

Adds the specified \(3 \times 3\) matrix to this matrix.

Parameters
mA \(3 \times 3\) matrix.
Returns
This matrix.

◆ operator+=() [2/2]

Matrix3x3 & t::Matrix3x3::operator+= ( double s)
inline

Adds the specified constant to all elements in this matrix.

Parameters
sA constant.
Returns
This matrix.

◆ operator-=() [1/2]

Matrix3x3 & t::Matrix3x3::operator-= ( const Matrix3x3 & m)
inline

Substracts the specified \(3 \times 3\) matrix from this matrix.

Parameters
mA \(3 \times 3\) matrix.
Returns
This matrix.

◆ operator-=() [2/2]

Matrix3x3 & t::Matrix3x3::operator-= ( double s)
inline

Substracts the specified constant from all elements in this matrix.

Parameters
sA constant.
Returns
This matrix.

◆ operator/=() [1/2]

Matrix3x3 & t::Matrix3x3::operator/= ( const Matrix3x3 & m)
inline

Divides the elements of this matrix by the corresponding elements of the specified \(3 \times 3\) matrix.

Parameters
mA \(3 \times 3\) matrix.
Returns
This matrix.

◆ operator/=() [2/2]

Matrix3x3 & t::Matrix3x3::operator/= ( double s)
inline

Divides the elements of this matrix with the specified constant.

Parameters
sA constant.
Returns
This matrix.

◆ operator[]()

double t::Matrix3x3::operator[] ( std::size_t index) const
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.

Parameters
indexThe 0-based index of the element in row-major order.
Returns
The element at the specified index of this matrix.
See also
get for accessing with bounds checking.

◆ reset()

Matrix3x3 & t::Matrix3x3::reset ( )
inline

Resets this matrix to the \(3 \times 3\) identity matrix.

Returns
This matrix.

◆ set() [1/2]

Matrix3x3 & t::Matrix3x3::set ( double _n11,
double _n12,
double _n13,
double _n21,
double _n22,
double _n23,
double _n31,
double _n32,
double _n33 )
inline

Sets the elements of this matrix.

Parameters
_n11The new \((1, 1)\) element of this matrix.
_n12The new \((1, 2)\) element of this matrix.
_n13The new \((1, 3)\) element of this matrix.
_n21The new \((2, 1)\) element of this matrix.
_n22The new \((2, 2)\) element of this matrix.
_n23The new \((2, 3)\) element of this matrix.
_n31The new \((3, 1)\) element of this matrix.
_n32The new \((3, 2)\) element of this matrix.
_n33The new \((3, 3)\) element of this matrix.
Returns
This matrix.

◆ set() [2/2]

Matrix3x3 & t::Matrix3x3::set ( int row,
int column,
int value )
inline

Sets the element at the specified row and column of this matrix to the specified value.

Parameters
rowThe 0-based index of the row of the element.
columnThe 0-based index of the column of the element.
valueThe new value for the element.
Returns
This matrix.

◆ transpose()

Matrix3x3 t::Matrix3x3::transpose ( ) const
inline

Returns the transpose of this matrix.

Note that this method does not modify this instance.

Returns
The transpose of this matrix.

◆ zero()

static Matrix3x3 t::Matrix3x3::zero ( )
inlinestatic

Returns a \(3 \times 3\) zero matrix.

Returns
A \(3 \times 3\) zero matrix.

Friends And Related Symbol Documentation

◆ operator* [1/4]

Matrix3x3 operator* ( const Matrix3x3 & a,
const Matrix3x3 & b )
friend

Multiplies two \(3 \times 3\) matrices.

Note that this is not an element-wise multiplication, but matrix multiplication.

Parameters
aA \(3 \times 3\) matrix.
bAnother \(3 \times 3\) matrix.
Returns
The matrix product of a and b.

◆ operator* [2/4]

Vector3 operator* ( const Matrix3x3 & a,
const Vector3 & v )
friend

Multiplies a \(3 \times 3\) matrix with a 3D vector.

Parameters
aA \(3 \times 3\) matrix.
vA 3D vector.
Returns
The product of a and v.

◆ operator* [3/4]

Matrix3x3 operator* ( const Matrix3x3 & a,
double s )
friend

Multiplies all elements of a \(3 \times 3\) matrix with a constant.

Parameters
aA \(3 \times 3\) matrix.
sA constant.
Returns
The resulting matrix when multiplying all elements of a with s.

◆ operator* [4/4]

Matrix3x3 operator* ( double s,
const Matrix3x3 & a )
friend

Multiplies all elements of a \(3 \times 3\) matrix with a constant.

Parameters
sA constant.
aA \(3 \times 3\) matrix.
Returns
The resulting matrix when multiplying all elements of a with s.

◆ operator+ [1/3]

Matrix3x3 operator+ ( const Matrix3x3 & a,
const Matrix3x3 & b )
friend

Adds two \(3 \times 3\) matrices.

Parameters
aA \(3 \times 3\) matrix.
bAnother \(3 \times 3\) matrix.
Returns
The sum of a and b.

◆ operator+ [2/3]

Matrix3x3 operator+ ( const Matrix3x3 & a,
double s )
friend

Adds a constant to all elements of a \(3 \times 3\) matrix.

Parameters
aA \(3 \times 3\) matrix.
sA constant.
Returns
The resulting matrix when adding s to all elements of a.

◆ operator+ [3/3]

Matrix3x3 operator+ ( double s,
const Matrix3x3 & a )
friend

Adds a constant to all elements of a \(3 \times 3\) matrix.

Parameters
sA constant.
aA \(3 \times 3\) matrix.
Returns
The resulting matrix when adding s to all elements of a.

◆ operator- [1/3]

Matrix3x3 operator- ( const Matrix3x3 & a,
const Matrix3x3 & b )
friend

Substracts 2 \(3 \times 3\) matrices.

Parameters
aA \(3 \times 3\) matrix.
bAnother \(3 \times 3\) matrix.
Returns
The difference of a and b.

◆ operator- [2/3]

Matrix3x3 operator- ( const Matrix3x3 & a,
double s )
friend

Substracts a constant from all elements of a \(3 \times 3\) matrix.

Parameters
aA \(3 \times 3\) matrix.
sA constant.
Returns
The resulting matrix when substracting s from all elements of a.

◆ operator- [3/3]

Matrix3x3 operator- ( double s,
const Matrix3x3 & a )
friend

Substracts a \(3 \times 3\) matrix from a \(3 \times 3\) constant matrix.

Parameters
sA constant for a \(3 \times 3\) constant matrix.
aA \(3 \times 3\) matrix.
Returns
The resulting matrix when substracting a from the constant matrix of s.

◆ operator/ [1/3]

Matrix3x3 operator/ ( const Matrix3x3 & a,
const Matrix3x3 & b )
friend

Returns the element-wise division of two \(3 \times 3\) matrices.

Parameters
aA \(3 \times 3\) matrix.
bAnother \(3 \times 3\) matrix.
Returns
The element-wise division of a and b.

◆ operator/ [2/3]

Matrix3x3 operator/ ( const Matrix3x3 & a,
double s )
friend

Divides all elements of a \(3 \times 3\) matrix by a constant.

Parameters
aA \(3 \times 3\) matrix.
sA constant.
Returns
The resulting matrix when dividing all elements of a by s.

◆ operator/ [3/3]

Matrix3x3 operator/ ( double s,
const Matrix3x3 & a )
friend

Returns the element-wise division of a \(3 \times 3\) constant matrix and a \(3 \times 3\) matrix.

Parameters
sA constant for a \(3 \times 3\) constant matrix.
aAnother \(3 \times 3\) matrix.
Returns
The element-wise division of the constant matrix and a.

◆ operator==

bool operator== ( const Matrix3x3 & a,
const Matrix3x3 & b )
friend

Returns whether two \(3 \times 3\) matrices are equal.

Parameters
aA \(3 \times 3\) matrix.
bAnother \(3 \times 3\) matrix.
Returns
true if a equals b, false otherwise.

The documentation for this class was generated from the following file: