vmmlib
1.11.0
Templatized C++ vector and matrix math library
|
Matrix with R rows and C columns of element type T. More...
#include <matrix.hpp>
Public Member Functions | |
Matrix () | |
Construct a zero-initialized matrix. More... | |
Matrix (const T *begin, const T *end) | |
Construct a matrix with default values. More... | |
Matrix (const std::vector< T > &data) | |
Construct a matrix with default values. More... | |
template<size_t P, size_t Q> | |
Matrix (const Matrix< P, Q, T > &source) | |
Copy-construct a matrix. More... | |
template<size_t S> | |
Matrix (const Quaternion< T > &rotation, const vector< S, T > &translation, typename enable_if< R==S+1 &&C==S+1 &&S==3 >::type *=0) | |
Construct a new 4x4 transformation matrix from a rotation quaternion and a translation vector. | |
template<size_t S> | |
Matrix (const vector< S, T > &eye, const vector< S, T > &lookat, const vector< S, T > &up, typename enable_if< R==S+1 &&C==S+1 &&S==3 >::type *=0) | |
Construct a new transformation matrix from an eye position, lookat position and up vector, following convention from gluLookAt(). | |
matrix-matrix operations | |
bool | operator== (const Matrix &other) const |
bool | operator!= (const Matrix &other) const |
bool | equals (const Matrix &other, T tolerance=std::numeric_limits< T >::epsilon()) const |
template<size_t P> | |
Matrix< R, C, T > & | multiply (const Matrix< R, P, T > &left, const Matrix< P, C, T > &right) |
Set this to the product of the two matrices (left_RxP * right_PxC) | |
template<size_t P> | |
Matrix< R, P, T > | operator* (const Matrix< C, P, T > &other) const |
template<size_t O, size_t P, typename = typename enable_if< R == C && O == P && R == O >::type> | |
Matrix< R, C, T > & | operator*= (const Matrix< O, P, T > &right) |
Multiply two square matrices. | |
Matrix | operator+ (const Matrix &other) const |
Element-wise addition of two matrices. | |
Matrix | operator- (const Matrix &other) const |
Element-wise substraction of two matrices. | |
void | operator+= (const Matrix &other) |
Element-wise addition of two matrices. | |
void | operator-= (const Matrix &other) |
Element-wise substraction of two matrices. | |
matrix-vector operations | |
vector< R, T > | operator* (const vector< C, T > &other) const |
Transform column vector by matrix ( res = matrix * vec ) | |
Data access | |
T & | operator() (size_t rowIndex, size_t colIndex) |
T | operator() (size_t rowIndex, size_t colIndex) const |
const T * | data () const |
template<size_t O, size_t P> | |
Matrix< O, P, T > | getSubMatrix (size_t rowOffset, size_t colOffset, typename enable_if< O<=R &&P<=C >::type *=0) const |
template<size_t O, size_t P> | |
enable_if< O<=R &&P<=C >::type *setSubMatrix(const Matrix< O, P, T > &sub_matrix, size_t rowOffset, size_t colOffset);const Matrix &operator=(const Matrix< R, C, T > &source_);template< size_t P, size_t Q > const Matrix &operator=(const Matrix< P, Q, T > &source_);void operator=(const std::vector< T > &data);Matrix< R, C, T > operator-() const ;vector< R, T > getColumn(size_t columnIndex) const ;void setColumn(size_t index, const vector< R, T > &column);vector< C, T > getRow(size_t index) const ;void setRow(size_t index, const vector< C, T > &row);vector< C-1, T > getTranslation() const ;Matrix< R, C, T > &setTranslation(const vector< C-1, T > &t);template< size_t S > void getLookAt(vector< S, T > &eye, vector< S, T > &lookAt, vector< S, T > &up, typename enable_if< R==S+1 &&C==S+1 &&S==3 >::type *=0) const ;Matrix< R, C, T > inverse() const ;template< size_t O, size_t P > typename enable_if< O==P &&R==C &&O==R &&R >=2 >::type *getAdjugate(Matrix< O, P, T > &adjugate) const ;template< size_t O, size_t P > typename enable_if< O==P &&R==C &&O==R &&R >=2 >::type * | getCofactors (Matrix< O, P, T > &cofactors) const |
Set the sub matrix of size OxP at the given start indices. More... | |
template<size_t O, size_t P> | |
T | getMinor (Matrix< O, P, T > &minor_, size_t row_to_cut, size_t col_to_cut, typename enable_if< O==R-1 &&P==C-1 &&R==C &&R >=2 >::type *=0) const |
Transformations on 4*4 matrices | |
template<typename TT > | |
Matrix< R, C, T > & | rotate_x (TT angle, typename enable_if< R==C &&R==4, TT >::type *=0) |
template<typename TT > | |
Matrix< R, C, T > & | rotate_y (TT angle, typename enable_if< R==C &&R==4, TT >::type *=0) |
template<typename TT > | |
Matrix< R, C, T > & | rotate_z (TT angle, typename enable_if< R==C &&R==4, TT >::type *=0) |
template<typename TT > | |
Matrix< R, C, T > & | pre_rotate_x (TT angle, typename enable_if< R==C &&R==4, TT >::type *=0) |
template<typename TT > | |
Matrix< R, C, T > & | pre_rotate_y (TT angle, typename enable_if< R==C &&R==4, TT >::type *=0) |
template<typename TT > | |
Matrix< R, C, T > & | pre_rotate_z (TT angle, typename enable_if< R==C &&R==4, TT >::type *=0) |
template<typename TT > | |
Matrix< R, C, T > & | scale (const vector< 3, TT > &scale_, typename enable_if< R==C &&R==4, TT >::type *=0) |
template<typename TT > | |
Matrix< R, C, T > & | scaleTranslation (const vector< 3, TT > &scale_, typename enable_if< R==C &&R==4, TT >::type *=0) |
Public Attributes | |
T | array [R *C] |
column by column storage | |
Friends | |
std::ostream & | operator<< (std::ostream &os, const Matrix< R, C, T > &matrix) |
Matrix with R rows and C columns of element type T.
Definition at line 51 of file matrix.hpp.
vmml::Matrix< R, C, T >::Matrix | ( | ) |
Construct a zero-initialized matrix.
Square matrices are initialized as identity.
Definition at line 493 of file matrix.hpp.
vmml::Matrix< R, C, T >::Matrix | ( | const T * | begin, |
const T * | end | ||
) |
Construct a matrix with default values.
Missing data is zero-initialized. Additional data is ignored.
Definition at line 502 of file matrix.hpp.
|
explicit |
Construct a matrix with default values.
Missing data is zero-initialized. Additional data is ignored.
Definition at line 510 of file matrix.hpp.
vmml::Matrix< R, C, T >::Matrix | ( | const Matrix< P, Q, T > & | source | ) |
Copy-construct a matrix.
Missing data is zero-initialized. Additional data is ignored.
Definition at line 517 of file matrix.hpp.
|
inline |
Definition at line 155 of file matrix.hpp.
References vmml::Matrix< R, C, T >::array.
bool vmml::Matrix< R, C, T >::equals | ( | const Matrix< R, C, T > & | other, |
T | tolerance = std::numeric_limits< T >::epsilon( ) |
||
) | const |
Definition at line 593 of file matrix.hpp.
References vmml::Matrix< R, C, T >::array.
enable_if< O <= R && P <= C >::type* setSubMatrix( const Matrix< O, P, T >& sub_matrix, size_t rowOffset, size_t colOffset ); const Matrix& operator=( const Matrix< R, C, T >& source_ ); template< size_t P, size_t Q > const Matrix& operator=( const Matrix< P, Q, T >& source_ ); void operator=( const std::vector< T >& data ); Matrix< R, C, T > operator-() const; vector< R, T > getColumn( size_t columnIndex ) const; void setColumn( size_t index, const vector< R, T >& column ); vector< C, T > getRow( size_t index ) const; void setRow( size_t index, const vector< C, T >& row ); vector< C-1, T > getTranslation() const; Matrix< R, C, T >& setTranslation( const vector< C-1, T >& t ); template< size_t S > void getLookAt( vector< S, T >& eye, vector< S, T >& lookAt, vector< S, T >& up, typename enable_if< R == S+1 && C == S+1 && S == 3 >::type* = 0 ) const; Matrix< R, C, T > inverse() const; template< size_t O, size_t P > typename enable_if< O == P && R == C && O == R && R >= 2 >::type* getAdjugate( Matrix< O, P, T >& adjugate ) const; template< size_t O, size_t P > typename enable_if< O == P && R == C && O == R && R >= 2 >::type* vmml::Matrix< R, C, T >::getCofactors | ( | Matrix< O, P, T > & | cofactors | ) | const |
Set the sub matrix of size OxP at the given start indices.
Matrix< O, P, T > vmml::Matrix< R, C, T >::getSubMatrix | ( | size_t | rowOffset, |
size_t | colOffset | ||
) | const |
Definition at line 787 of file matrix.hpp.
bool vmml::Matrix< R, C, T >::operator!= | ( | const Matrix< R, C, T > & | other | ) | const |
Definition at line 587 of file matrix.hpp.
|
inline |
Definition at line 562 of file matrix.hpp.
|
inline |
Definition at line 570 of file matrix.hpp.
Matrix< R, P, T > vmml::Matrix< R, C, T >::operator* | ( | const Matrix< C, P, T > & | other | ) | const |
Definition at line 664 of file matrix.hpp.
References vmml::Matrix< R, C, T >::multiply().
bool vmml::Matrix< R, C, T >::operator== | ( | const Matrix< R, C, T > & | other | ) | const |
Definition at line 578 of file matrix.hpp.
References vmml::Matrix< R, C, T >::array.