Jet
v1.3.3
|
4-D matrix class. More...
#include <jet/matrix4x4.h>
Public Member Functions | |
Matrix () | |
Constructs identity matrix. More... | |
Matrix (T s) | |
Constructs constant value matrix. More... | |
Matrix (T m00, T m01, T m02, T m10, T m11, T m12, T m20, T m21, T m22) | |
Matrix (T m00, T m01, T m02, T m03, T m10, T m11, T m12, T m13, T m20, T m21, T m22, T m23, T m30, T m31, T m32, T m33) | |
template<typename U > | |
Matrix (const std::initializer_list< std::initializer_list< U >> &lst) | |
Constructs a matrix with given initializer list lst . More... | |
Matrix (const Matrix3x3< T > &m33) | |
Matrix (const Matrix &m) | |
Constructs a matrix with input matrix. More... | |
Matrix (const T *arr) | |
void | set (T s) |
Sets whole matrix with input scalar. More... | |
void | set (T m00, T m01, T m02, T m10, T m11, T m12, T m20, T m21, T m22) |
void | set (T m00, T m01, T m02, T m03, T m10, T m11, T m12, T m13, T m20, T m21, T m22, T m23, T m30, T m31, T m32, T m33) |
template<typename U > | |
void | set (const std::initializer_list< std::initializer_list< U >> &lst) |
Sets a matrix with given initializer list lst . More... | |
void | set (const Matrix3x3< T > &m33) |
void | set (const Matrix &m) |
Copies from input matrix. More... | |
void | set (const T *arr) |
void | setDiagonal (T s) |
Sets diagonal elements with input scalar. More... | |
void | setOffDiagonal (T s) |
Sets off-diagonal elements with input scalar. More... | |
void | setRow (size_t i, const Vector4< T > &row) |
Sets i-th row with input vector. More... | |
void | setColumn (size_t i, const Vector4< T > &col) |
Sets i-th column with input vector. More... | |
bool | isSimilar (const Matrix &m, double tol=std::numeric_limits< double >::epsilon()) const |
bool | isSquare () const |
Returns true if this matrix is a square matrix. More... | |
size_t | rows () const |
Returns number of rows of this matrix. More... | |
size_t | cols () const |
Returns number of columns of this matrix. More... | |
T * | data () |
Returns data pointer of this matrix. More... | |
const T * | data () const |
Returns constant pointer of this matrix. More... | |
Matrix< T, 3, 3 > | matrix3 () const |
Returns 3x3 part of this matrix. More... | |
Matrix | add (T s) const |
Returns this matrix + input scalar. More... | |
Matrix | add (const Matrix &m) const |
Returns this matrix + input matrix (element-wise). More... | |
Matrix | sub (T s) const |
Returns this matrix - input scalar. More... | |
Matrix | sub (const Matrix &m) const |
Returns this matrix - input matrix (element-wise). More... | |
Matrix | mul (T s) const |
Returns this matrix * input scalar. More... | |
Vector4< T > | mul (const Vector4< T > &v) const |
Returns this matrix * input vector. More... | |
Matrix | mul (const Matrix &m) const |
Returns this matrix * input matrix. More... | |
Matrix | div (T s) const |
Returns this matrix / input scalar. More... | |
Matrix | radd (T s) const |
Returns input scalar + this matrix. More... | |
Matrix | radd (const Matrix &m) const |
Returns input matrix + this matrix (element-wise). More... | |
Matrix | rsub (T s) const |
Returns input scalar - this matrix. More... | |
Matrix | rsub (const Matrix &m) const |
Returns input matrix - this matrix (element-wise). More... | |
Matrix | rmul (T s) const |
Returns input scalar * this matrix. More... | |
Matrix | rmul (const Matrix &m) const |
Returns input matrix * this matrix. More... | |
Matrix | rdiv (T s) const |
Returns input matrix / this scalar. More... | |
void | iadd (T s) |
Adds input scalar to this matrix. More... | |
void | iadd (const Matrix &m) |
Adds input matrix to this matrix (element-wise). More... | |
void | isub (T s) |
Subtracts input scalar from this matrix. More... | |
void | isub (const Matrix &m) |
Subtracts input matrix from this matrix (element-wise). More... | |
void | imul (T s) |
Multiplies input scalar to this matrix. More... | |
void | imul (const Matrix3x3< T > &m33) |
void | imul (const Matrix &m) |
Multiplies input matrix to this matrix. More... | |
void | idiv (T s) |
Divides this matrix with input scalar. More... | |
void | transpose () |
Transposes this matrix. More... | |
void | invert () |
Inverts this matrix. More... | |
T | sum () const |
Returns sum of all elements. More... | |
T | avg () const |
Returns average of all elements. More... | |
T | min () const |
Returns minimum among all elements. More... | |
T | max () const |
Returns maximum among all elements. More... | |
T | absmin () const |
Returns absolute minimum among all elements. More... | |
T | absmax () const |
Returns absolute maximum among all elements. More... | |
T | trace () const |
Returns sum of all diagonal elements. More... | |
T | determinant () const |
Returns determinant of this matrix. More... | |
Matrix | diagonal () const |
Returns diagonal part of this matrix. More... | |
Matrix | offDiagonal () const |
Returns off-diagonal part of this matrix. More... | |
Matrix | strictLowerTri () const |
Returns strictly lower triangle part of this matrix. More... | |
Matrix | strictUpperTri () const |
Returns strictly upper triangle part of this matrix. More... | |
Matrix | lowerTri () const |
Returns lower triangle part of this matrix (including the diagonal). More... | |
Matrix | upperTri () const |
Returns upper triangle part of this matrix (including the diagonal). More... | |
Matrix | transposed () const |
Returns transposed matrix. More... | |
Matrix | inverse () const |
Returns inverse matrix. More... | |
template<typename U > | |
Matrix< U, 4, 4 > | castTo () const |
Matrix & | operator= (const Matrix &m) |
Assigns input matrix. More... | |
Matrix & | operator+= (T s) |
Addition assignment with input scalar. More... | |
Matrix & | operator+= (const Matrix &m) |
Addition assignment with input matrix (element-wise). More... | |
Matrix & | operator-= (T s) |
Subtraction assignment with input scalar. More... | |
Matrix & | operator-= (const Matrix &m) |
Subtraction assignment with input matrix (element-wise). More... | |
Matrix & | operator*= (T s) |
Multiplication assignment with input scalar. More... | |
Matrix & | operator*= (const Matrix &m) |
Multiplication assignment with input matrix. More... | |
Matrix & | operator*= (const Matrix3x3< T > &m) |
Matrix & | operator/= (T s) |
Division assignment with input scalar. More... | |
T & | operator[] (size_t i) |
Returns reference of i-th element. More... | |
const T & | operator[] (size_t i) const |
Returns constant reference of i-th element. More... | |
T & | operator() (size_t i, size_t j) |
Returns reference of (i,j) element. More... | |
const T & | operator() (size_t i, size_t j) const |
Returns constant reference of (i,j) element. More... | |
bool | operator== (const Matrix &m) const |
Returns true if is equal to m. More... | |
bool | operator!= (const Matrix &m) const |
Returns true if is not equal to m. More... | |
Static Public Member Functions | |
static Matrix | makeZero () |
Sets all matrix entries to zero. More... | |
static Matrix | makeIdentity () |
Makes all diagonal elements to 1, and other elements to 0. More... | |
static Matrix | makeScaleMatrix (T sx, T sy, T sz) |
Makes scale matrix. More... | |
static Matrix | makeScaleMatrix (const Vector3< T > &s) |
Makes scale matrix. More... | |
static Matrix | makeRotationMatrix (const Vector3< T > &axis, T rad) |
static Matrix | makeTranslationMatrix (const Vector3< T > &t) |
Makes translation matrix. More... | |
4-D matrix class.
This class is a row-major 4-D matrix class, which means each element of the matrix is stored in order of (0,0), ... , (0,3), (1,0), ... , (3,3). Also, this 4-D matrix is speciallized for geometric transformations.
T | - Type of the element. |
jet::Matrix< T, 4, 4 >::Matrix | ( | ) |
Constructs identity matrix.
|
explicit |
Constructs constant value matrix.
jet::Matrix< T, 4, 4 >::Matrix | ( | T | m00, |
T | m01, | ||
T | m02, | ||
T | m10, | ||
T | m11, | ||
T | m12, | ||
T | m20, | ||
T | m21, | ||
T | m22 | ||
) |
Constructs a matrix with input elements. This constructor initialize 3x3 part, and other parts are set to 0 except (3,3) which will be set to 1.
jet::Matrix< T, 4, 4 >::Matrix | ( | T | m00, |
T | m01, | ||
T | m02, | ||
T | m03, | ||
T | m10, | ||
T | m11, | ||
T | m12, | ||
T | m13, | ||
T | m20, | ||
T | m21, | ||
T | m22, | ||
T | m23, | ||
T | m30, | ||
T | m31, | ||
T | m32, | ||
T | m33 | ||
) |
Constructs a matrix with input elements.
jet::Matrix< T, 4, 4 >::Matrix | ( | const std::initializer_list< std::initializer_list< U >> & | lst | ) |
Constructs a matrix with given initializer list lst
.
This constructor will build a matrix with given initializer list lst
such as
Note the initializer also has 4x4 structure.
lst | Initializer list that should be copy to the new matrix. |
|
explicit |
Constructs a matrix with 3x3 matrix. This constructor initialize 3x3 part, and other parts are set to 0 except (3,3) which is set to 1.
jet::Matrix< T, 4, 4 >::Matrix | ( | const Matrix< T, 4, 4 > & | m | ) |
Constructs a matrix with input matrix.
|
explicit |
Constructs a matrix with input array.
T jet::Matrix< T, 4, 4 >::absmax | ( | ) | const |
Returns absolute maximum among all elements.
T jet::Matrix< T, 4, 4 >::absmin | ( | ) | const |
Returns absolute minimum among all elements.
Matrix jet::Matrix< T, 4, 4 >::add | ( | const Matrix< T, 4, 4 > & | m | ) | const |
Returns this matrix + input matrix (element-wise).
Matrix jet::Matrix< T, 4, 4 >::add | ( | T | s | ) | const |
Returns this matrix + input scalar.
T jet::Matrix< T, 4, 4 >::avg | ( | ) | const |
Returns average of all elements.
Matrix<U, 4, 4> jet::Matrix< T, 4, 4 >::castTo | ( | ) | const |
size_t jet::Matrix< T, 4, 4 >::cols | ( | ) | const |
Returns number of columns of this matrix.
T* jet::Matrix< T, 4, 4 >::data | ( | ) |
Returns data pointer of this matrix.
const T* jet::Matrix< T, 4, 4 >::data | ( | ) | const |
Returns constant pointer of this matrix.
T jet::Matrix< T, 4, 4 >::determinant | ( | ) | const |
Returns determinant of this matrix.
Matrix jet::Matrix< T, 4, 4 >::diagonal | ( | ) | const |
Returns diagonal part of this matrix.
Matrix jet::Matrix< T, 4, 4 >::div | ( | T | s | ) | const |
Returns this matrix / input scalar.
void jet::Matrix< T, 4, 4 >::iadd | ( | const Matrix< T, 4, 4 > & | m | ) |
Adds input matrix to this matrix (element-wise).
void jet::Matrix< T, 4, 4 >::iadd | ( | T | s | ) |
Adds input scalar to this matrix.
void jet::Matrix< T, 4, 4 >::idiv | ( | T | s | ) |
Divides this matrix with input scalar.
void jet::Matrix< T, 4, 4 >::imul | ( | const Matrix< T, 4, 4 > & | m | ) |
Multiplies input matrix to this matrix.
void jet::Matrix< T, 4, 4 >::imul | ( | const Matrix3x3< T > & | m33 | ) |
Multiplies input 3x3 matrix to this matrix. This method assumes missing part of the input matrix has 0 for the off-diagonal and 1 for the diagonal part.
void jet::Matrix< T, 4, 4 >::imul | ( | T | s | ) |
Multiplies input scalar to this matrix.
Matrix jet::Matrix< T, 4, 4 >::inverse | ( | ) | const |
Returns inverse matrix.
void jet::Matrix< T, 4, 4 >::invert | ( | ) |
Inverts this matrix.
bool jet::Matrix< T, 4, 4 >::isSimilar | ( | const Matrix< T, 4, 4 > & | m, |
double | tol = std::numeric_limits< double >::epsilon() |
||
) | const |
Returns true if this matrix is similar to the input matrix within the given tolerance.
bool jet::Matrix< T, 4, 4 >::isSquare | ( | ) | const |
Returns true if this matrix is a square matrix.
void jet::Matrix< T, 4, 4 >::isub | ( | const Matrix< T, 4, 4 > & | m | ) |
Subtracts input matrix from this matrix (element-wise).
void jet::Matrix< T, 4, 4 >::isub | ( | T | s | ) |
Subtracts input scalar from this matrix.
Matrix jet::Matrix< T, 4, 4 >::lowerTri | ( | ) | const |
Returns lower triangle part of this matrix (including the diagonal).
|
static |
Makes all diagonal elements to 1, and other elements to 0.
|
static |
Makes rotation matrix.
|
static |
Makes scale matrix.
|
static |
Makes scale matrix.
|
static |
Makes translation matrix.
|
static |
Sets all matrix entries to zero.
Matrix<T, 3, 3> jet::Matrix< T, 4, 4 >::matrix3 | ( | ) | const |
Returns 3x3 part of this matrix.
T jet::Matrix< T, 4, 4 >::max | ( | ) | const |
Returns maximum among all elements.
T jet::Matrix< T, 4, 4 >::min | ( | ) | const |
Returns minimum among all elements.
Matrix jet::Matrix< T, 4, 4 >::mul | ( | const Matrix< T, 4, 4 > & | m | ) | const |
Returns this matrix * input matrix.
Vector4<T> jet::Matrix< T, 4, 4 >::mul | ( | const Vector4< T > & | v | ) | const |
Returns this matrix * input vector.
Matrix jet::Matrix< T, 4, 4 >::mul | ( | T | s | ) | const |
Returns this matrix * input scalar.
Matrix jet::Matrix< T, 4, 4 >::offDiagonal | ( | ) | const |
Returns off-diagonal part of this matrix.
bool jet::Matrix< T, 4, 4 >::operator!= | ( | const Matrix< T, 4, 4 > & | m | ) | const |
Returns true if is not equal to m.
T& jet::Matrix< T, 4, 4 >::operator() | ( | size_t | i, |
size_t | j | ||
) |
Returns reference of (i,j) element.
const T& jet::Matrix< T, 4, 4 >::operator() | ( | size_t | i, |
size_t | j | ||
) | const |
Returns constant reference of (i,j) element.
Matrix& jet::Matrix< T, 4, 4 >::operator*= | ( | const Matrix< T, 4, 4 > & | m | ) |
Multiplication assignment with input matrix.
Matrix& jet::Matrix< T, 4, 4 >::operator*= | ( | const Matrix3x3< T > & | m | ) |
Multiplication assignment with input 3x3 matrix. This method assumes missing part of the input matrix has 0 for the off-diagonal and 1 for the diagonal part.
Matrix& jet::Matrix< T, 4, 4 >::operator*= | ( | T | s | ) |
Multiplication assignment with input scalar.
Matrix& jet::Matrix< T, 4, 4 >::operator+= | ( | const Matrix< T, 4, 4 > & | m | ) |
Addition assignment with input matrix (element-wise).
Matrix& jet::Matrix< T, 4, 4 >::operator+= | ( | T | s | ) |
Addition assignment with input scalar.
Matrix& jet::Matrix< T, 4, 4 >::operator-= | ( | const Matrix< T, 4, 4 > & | m | ) |
Subtraction assignment with input matrix (element-wise).
Matrix& jet::Matrix< T, 4, 4 >::operator-= | ( | T | s | ) |
Subtraction assignment with input scalar.
Matrix& jet::Matrix< T, 4, 4 >::operator/= | ( | T | s | ) |
Division assignment with input scalar.
Matrix& jet::Matrix< T, 4, 4 >::operator= | ( | const Matrix< T, 4, 4 > & | m | ) |
Assigns input matrix.
bool jet::Matrix< T, 4, 4 >::operator== | ( | const Matrix< T, 4, 4 > & | m | ) | const |
Returns true if is equal to m.
T& jet::Matrix< T, 4, 4 >::operator[] | ( | size_t | i | ) |
Returns reference of i-th element.
const T& jet::Matrix< T, 4, 4 >::operator[] | ( | size_t | i | ) | const |
Returns constant reference of i-th element.
Matrix jet::Matrix< T, 4, 4 >::radd | ( | const Matrix< T, 4, 4 > & | m | ) | const |
Returns input matrix + this matrix (element-wise).
Matrix jet::Matrix< T, 4, 4 >::radd | ( | T | s | ) | const |
Returns input scalar + this matrix.
Matrix jet::Matrix< T, 4, 4 >::rdiv | ( | T | s | ) | const |
Returns input matrix / this scalar.
Matrix jet::Matrix< T, 4, 4 >::rmul | ( | const Matrix< T, 4, 4 > & | m | ) | const |
Returns input matrix * this matrix.
Matrix jet::Matrix< T, 4, 4 >::rmul | ( | T | s | ) | const |
Returns input scalar * this matrix.
size_t jet::Matrix< T, 4, 4 >::rows | ( | ) | const |
Returns number of rows of this matrix.
Matrix jet::Matrix< T, 4, 4 >::rsub | ( | const Matrix< T, 4, 4 > & | m | ) | const |
Returns input matrix - this matrix (element-wise).
Matrix jet::Matrix< T, 4, 4 >::rsub | ( | T | s | ) | const |
Returns input scalar - this matrix.
void jet::Matrix< T, 4, 4 >::set | ( | const Matrix< T, 4, 4 > & | m | ) |
Copies from input matrix.
void jet::Matrix< T, 4, 4 >::set | ( | const Matrix3x3< T > & | m33 | ) |
Sets this matrix with input 3x3 matrix. This method copies 3x3 part only, and other parts are set to 0 except (3,3) which will be set to 1.
void jet::Matrix< T, 4, 4 >::set | ( | const std::initializer_list< std::initializer_list< U >> & | lst | ) |
Sets a matrix with given initializer list lst
.
This function will fill the matrix with given initializer list lst
such as
Note the initializer also has 3x3 structure.
lst | Initializer list that should be copy to the new matrix. |
void jet::Matrix< T, 4, 4 >::set | ( | const T * | arr | ) |
Copies from input array.
void jet::Matrix< T, 4, 4 >::set | ( | T | m00, |
T | m01, | ||
T | m02, | ||
T | m03, | ||
T | m10, | ||
T | m11, | ||
T | m12, | ||
T | m13, | ||
T | m20, | ||
T | m21, | ||
T | m22, | ||
T | m23, | ||
T | m30, | ||
T | m31, | ||
T | m32, | ||
T | m33 | ||
) |
Sets this matrix with input elements.
void jet::Matrix< T, 4, 4 >::set | ( | T | m00, |
T | m01, | ||
T | m02, | ||
T | m10, | ||
T | m11, | ||
T | m12, | ||
T | m20, | ||
T | m21, | ||
T | m22 | ||
) |
Sets this matrix with input elements. This method copies 3x3 part only, and other parts are set to 0 except (3,3) which is set to 1.
void jet::Matrix< T, 4, 4 >::set | ( | T | s | ) |
Sets whole matrix with input scalar.
void jet::Matrix< T, 4, 4 >::setColumn | ( | size_t | i, |
const Vector4< T > & | col | ||
) |
Sets i-th column with input vector.
void jet::Matrix< T, 4, 4 >::setDiagonal | ( | T | s | ) |
Sets diagonal elements with input scalar.
void jet::Matrix< T, 4, 4 >::setOffDiagonal | ( | T | s | ) |
Sets off-diagonal elements with input scalar.
void jet::Matrix< T, 4, 4 >::setRow | ( | size_t | i, |
const Vector4< T > & | row | ||
) |
Sets i-th row with input vector.
Matrix jet::Matrix< T, 4, 4 >::strictLowerTri | ( | ) | const |
Returns strictly lower triangle part of this matrix.
Matrix jet::Matrix< T, 4, 4 >::strictUpperTri | ( | ) | const |
Returns strictly upper triangle part of this matrix.
Matrix jet::Matrix< T, 4, 4 >::sub | ( | const Matrix< T, 4, 4 > & | m | ) | const |
Returns this matrix - input matrix (element-wise).
Matrix jet::Matrix< T, 4, 4 >::sub | ( | T | s | ) | const |
Returns this matrix - input scalar.
T jet::Matrix< T, 4, 4 >::sum | ( | ) | const |
Returns sum of all elements.
T jet::Matrix< T, 4, 4 >::trace | ( | ) | const |
Returns sum of all diagonal elements.
void jet::Matrix< T, 4, 4 >::transpose | ( | ) |
Transposes this matrix.
Matrix jet::Matrix< T, 4, 4 >::transposed | ( | ) | const |
Returns transposed matrix.
Matrix jet::Matrix< T, 4, 4 >::upperTri | ( | ) | const |
Returns upper triangle part of this matrix (including the diagonal).