ML Reference
ml::Tmat4< DT > Class Template Reference

A 4x4 matrix class consisting of four row vectors. More...

#include <mlMatrix4.h>

Inheritance diagram for ml::Tmat4< DT >:
ml::FloatingPointMatrix< Tvec4< DT >, 4 >

Public Types

typedef DT ComponentType
 A typedef to 'export' the type of components.
Public Types inherited from ml::FloatingPointMatrix< Tvec4< DT >, 4 >
enum  
enum  
enum  
typedef Tvec4< DT >::ComponentType ComponentType
 A typedef to 'export' the type of subcomponents.
typedef Tvec4< DT > VectorType
 A typedef to 'export' the type of component vector.

Public Member Functions

Tvec3< DT > transformPoint (const Tvec3< DT > &sourceVec) const
 Transforms the given sourceVec and returns the result vector.
bool operator< (const Tmat4< DT > &) const
template<class IDX_TYP>
DT determinantLower3 (const IDX_TYP col1, const IDX_TYP col2, const IDX_TYP col3) const
 Determines the (sub)determinant of columns given by col1, col2, and col3.
Public Member Functions inherited from ml::FloatingPointMatrix< Tvec4< DT >, 4 >
const Tvec4< DT > & operator[] (const size_t i) const
ComponentTypelinearIndexed (const size_t idx)
ComponentType linearIndexedConst (const size_t idx) const
ComponentType compAbsSum () const
void setValuesFromPtr (const ComponentType *const values)
void getValuesToPtr (ComponentType *values) const

Constructors, set, and get functionality of class Tmat4.

 Tmat4 ()
 Constructs a matrix from 16 zero elements.
 Tmat4 (const DT diagValue)
 Builds a matrix that has the argument diagValue as the diagonal values, zero otherwise.
 Tmat4 (const Tvec4< DT > &row0, const Tvec4< DT > &row1, const Tvec4< DT > &row2, const Tvec4< DT > &row3)
 Composes a matrix from the four row vectors row0, row1, row2, and row3.
 Tmat4 (const Tmat4< DT > &mat)
 Copy constructor from the Tmat4 mat.
 Tmat4 (const float mat[16])
 Constructor from 16 floating point values in an array given by mat, row by row.
 Tmat4 (const double mat[16])
 Constructor from 16 double values in an array given by mat, row by row.
Tmat4< DT > getRotationMatrix () const
 Returns the rotational part of the matrix (removes scaling and translation).
void set (const DT val)
 Sets all values to val.
const Tmat4< DT > & operator= (const Tmat4< DT > &m)
 Assigns from a Tmat4.
const Tmat4< DT > & operator+= (const Tmat4< DT > &m)
 Increments by a Tmat4.
const Tmat4< DT > & operator-= (const Tmat4< DT > &m)
 Decrements by a Tmat4.
const Tmat4< DT > & operator*= (const DT d)
 Multiplies by a constant d.
const Tmat4< DT > & operator/= (const DT d)
 Divides by a constant d. Division by zero is not handled and must be avoided by caller.
const Tmat4< DT > & apply (MLDblFuncPtr fct)
 Applies the function fct to each component.
static Tmat4< DT > getMat (const double val)
 Returns a matrix filled with values val.

Tmat4<DT> member functions

 Tmat4 (const double in00, const double in01, const double in02, const double in03, const double in10, const double in11, const double in12, const double in13, const double in20, const double in21, const double in22, const double in23, const double in30, const double in31, const double in32, const double in33)
 Initializes all matrix elements explicitly with scalars, row by row.
 Tmat4 (const Tvec3< DT > &n0, const Tvec3< DT > &n1, const Tvec3< DT > &n3, const Tvec3< DT > &t)
 Constructs a matrix from three base vectors and translation (as column vectors).
void setValues (const float mat[16])
 Copies the contents from float array mat into *this, row by row.
void getValues (float mat[16]) const
void setValues (const double mat[16])
 Copies the contents from double array mat into *this, row by row.
void getValues (double mat[16]) const
void setScaleMatrix (const DT scale)
 Sets a diagonal matrix with [ scale on the diagonal.
DT det3 (DT A, DT B, DT C, DT D, DT E, DT F, DT G, DT H, DT I) const
 Determines the determinant of a 3x3 matrix given by A,B,C,D,E,F,G,H,I.
DT det () const
 Returns the determinant of this.
Tmat4< DT > transpose () const
 Returns the transposed *this.
Tmat4< DT > inverse (bool *isInvertible=nullptr) const
static Tmat4< DT > getIdentity ()
 Returns the identity matrix.

Additional Inherited Members

Protected Attributes inherited from ml::FloatingPointMatrix< Tvec4< DT >, 4 >
Tvec4< DT > v [size]
 The rows constituting the matrix.

Detailed Description

template<class DT>
class ml::Tmat4< DT >

A 4x4 matrix class consisting of four row vectors.

Definition at line 35 of file mlMatrix4.h.

Member Typedef Documentation

◆ ComponentType

template<class DT>
typedef DT ml::Tmat4< DT >::ComponentType

A typedef to 'export' the type of components.

Definition at line 40 of file mlMatrix4.h.

Constructor & Destructor Documentation

◆ Tmat4() [1/8]

template<class DT>
ml::Tmat4< DT >::Tmat4 ( )
inline

◆ Tmat4() [2/8]

template<class DT>
ml::Tmat4< DT >::Tmat4 ( const DT diagValue)
inline

Builds a matrix that has the argument diagValue as the diagonal values, zero otherwise.

Constructs a matrix that has the argument diagValue as the diagonal values, zero otherwise.

Definition at line 186 of file mlMatrix4.h.

References Tmat4(), and ml::FloatingPointMatrix< Tvec4< DT >, 4 >::v.

◆ Tmat4() [3/8]

template<class DT>
ml::Tmat4< DT >::Tmat4 ( const Tvec4< DT > & row0,
const Tvec4< DT > & row1,
const Tvec4< DT > & row2,
const Tvec4< DT > & row3 )
inline

Composes a matrix from the four row vectors row0, row1, row2, and row3.

Composes a matrix from the four vectors row0, row1, row2, and row3.

Definition at line 195 of file mlMatrix4.h.

References Tmat4(), and ml::FloatingPointMatrix< Tvec4< DT >, 4 >::v.

◆ Tmat4() [4/8]

template<class DT>
ml::Tmat4< DT >::Tmat4 ( const Tmat4< DT > & mat)
inline

Copy constructor from the Tmat4 mat.

Definition at line 205 of file mlMatrix4.h.

References Tmat4(), ml::FloatingPointMatrix< VectorT, size >::v, and ml::FloatingPointMatrix< Tvec4< DT >, 4 >::v.

◆ Tmat4() [5/8]

template<class DT>
ml::Tmat4< DT >::Tmat4 ( const float mat[16])
inline

Constructor from 16 floating point values in an array given by mat, row by row.

Definition at line 215 of file mlMatrix4.h.

References setValues(), and Tmat4().

◆ Tmat4() [6/8]

template<class DT>
ml::Tmat4< DT >::Tmat4 ( const double mat[16])
inline

Constructor from 16 double values in an array given by mat, row by row.

Definition at line 222 of file mlMatrix4.h.

References setValues(), and Tmat4().

◆ Tmat4() [7/8]

template<class DT>
ml::Tmat4< DT >::Tmat4 ( const double in00,
const double in01,
const double in02,
const double in03,
const double in10,
const double in11,
const double in12,
const double in13,
const double in20,
const double in21,
const double in22,
const double in23,
const double in30,
const double in31,
const double in32,
const double in33 )

Initializes all matrix elements explicitly with scalars, row by row.

Initializes all matrix elements explicitly with scalars, filling it row by row.

Definition at line 471 of file mlMatrix4.h.

References Tmat4(), and ml::FloatingPointMatrix< Tvec4< DT >, 4 >::v.

◆ Tmat4() [8/8]

template<class DT>
ml::Tmat4< DT >::Tmat4 ( const Tvec3< DT > & n0,
const Tvec3< DT > & n1,
const Tvec3< DT > & n3,
const Tvec3< DT > & t )
inline

Constructs a matrix from three base vectors and translation (as column vectors).

Constructs a matrix from three base vectors n0, ... n3 and a translation t, all given as column vectors.

Definition at line 443 of file mlMatrix4.h.

References Tmat4(), and ml::FloatingPointMatrix< Tvec4< DT >, 4 >::v.

Member Function Documentation

◆ apply()

template<class DT>
const Tmat4< DT > & ml::Tmat4< DT >::apply ( MLDblFuncPtr fct)
inline

Applies the function fct to each component.

Applies the function fct to all vectors of *this and returns the matrix.

Definition at line 329 of file mlMatrix4.h.

References apply(), Tmat4(), and ml::FloatingPointMatrix< Tvec4< DT >, 4 >::v.

Referenced by apply().

◆ det()

template<class DT>
DT ml::Tmat4< DT >::det ( ) const
inline

Returns the determinant of this.

Returns the determinant of *this.

Definition at line 560 of file mlMatrix4.h.

References det(), determinantLower3(), and ml::FloatingPointMatrix< Tvec4< DT >, 4 >::v.

Referenced by det(), and ml::Tmat5< DT >::determinantLower4().

◆ det3()

template<class DT>
DT ml::Tmat4< DT >::det3 ( DT A,
DT B,
DT C,
DT D,
DT E,
DT F,
DT G,
DT H,
DT I ) const
inline

Determines the determinant of a 3x3 matrix given by A,B,C,D,E,F,G,H,I.

Definition at line 550 of file mlMatrix4.h.

References det3().

Referenced by det3().

◆ determinantLower3()

template<class DT>
template<class IDX_TYP>
DT ml::Tmat4< DT >::determinantLower3 ( const IDX_TYP col1,
const IDX_TYP col2,
const IDX_TYP col3 ) const
inline

Determines the (sub)determinant of columns given by col1, col2, and col3.

Definition at line 140 of file mlMatrix4.h.

Referenced by det().

◆ getIdentity()

template<class DT>
Tmat4< DT > ml::Tmat4< DT >::getIdentity ( )
inlinestatic

Returns the identity matrix.

Definition at line 584 of file mlMatrix4.h.

References getIdentity(), and Tmat4().

Referenced by ml::TQuaternion< MLfloat >::getAsMat4(), getIdentity(), ml::identity3D(), and inverse().

◆ getMat()

template<class DT>
Tmat4< DT > ml::Tmat4< DT >::getMat ( const double val)
inlinestatic

Returns a matrix filled with values val.

Definition at line 229 of file mlMatrix4.h.

References getMat(), and Tmat4().

Referenced by getMat().

◆ getRotationMatrix()

template<class DT>
Tmat4< DT > ml::Tmat4< DT >::getRotationMatrix ( ) const
inline

Returns the rotational part of the matrix (removes scaling and translation).

Definition at line 238 of file mlMatrix4.h.

References getRotationMatrix(), ml::FloatingPointVector< T, size, DataContainer >::normalize(), and Tmat4().

Referenced by getRotationMatrix().

◆ getValues() [1/2]

template<class DT>
void ml::Tmat4< DT >::getValues ( double mat[16]) const

Copies the contents of *this into into double matrix mat, row by row. Note that range and precision of the double values may not be sufficient for long double matrix contents.

Copies the contents of *this into mat, row by row. Note that range and precision of the float values may not be sufficient for long double matrix contents.

Definition at line 526 of file mlMatrix4.h.

References getValues(), and ml::FloatingPointMatrix< Tvec4< DT >, 4 >::v.

◆ getValues() [2/2]

template<class DT>
void ml::Tmat4< DT >::getValues ( float mat[16]) const

Copies the contents of *this into floating point matrix mat, row by row. Note that range and precision of the float values may not be sufficient for double or long double matrix contents.

Definition at line 500 of file mlMatrix4.h.

References getValues(), and ml::FloatingPointMatrix< Tvec4< DT >, 4 >::v.

Referenced by getValues(), and getValues().

◆ inverse()

template<class DT>
Tmat4< DT > ml::Tmat4< DT >::inverse ( bool * isInvertible = nullptr) const

Returns the inverse. Gauss-Jordan elimination with partial pivoting. If a non-NULL boolean pointer is passed to isInvertible, then true is returned in *isInvertible in the case of a successful inversion or false if the inversion is not possible (function returns the identity then). If a NULL pointer is passed as isInvertible, the matrix must be invertible; otherwise, errors will occur.

Returns the inverse Gauss-Jordan elimination with partial pivoting. If a non-NULL boolean pointer is passed to isInvertible, then true is returned in *isInvertible in the case of a successful inversion or false if the inversion is not possible (function return is the identity then). If a NULL pointer is passed as isInvertible, the matrix must be invertible; otherwise, errors will occur.

Definition at line 685 of file mlMatrix4.h.

References getIdentity(), inverse(), ml::MLInverseMatHelper(), and Tmat4().

Referenced by inverse().

◆ operator*=()

template<class DT>
const Tmat4< DT > & ml::Tmat4< DT >::operator*= ( const DT d)
inline

Multiplies by a constant d.

Multiplies by an MLdouble constant d.

Definition at line 307 of file mlMatrix4.h.

References operator*=(), Tmat4(), and ml::FloatingPointMatrix< Tvec4< DT >, 4 >::v.

Referenced by operator*=().

◆ operator+=()

template<class DT>
const Tmat4< DT > & ml::Tmat4< DT >::operator+= ( const Tmat4< DT > & m)
inline

◆ operator-=()

template<class DT>
const Tmat4< DT > & ml::Tmat4< DT >::operator-= ( const Tmat4< DT > & m)
inline

◆ operator/=()

template<class DT>
const Tmat4< DT > & ml::Tmat4< DT >::operator/= ( const DT d)
inline

Divides by a constant d. Division by zero is not handled and must be avoided by caller.

Divides by an MLdouble constant d. Division by zero is not handled and must be avoided by caller.

Definition at line 318 of file mlMatrix4.h.

References operator/=(), Tmat4(), and ml::FloatingPointMatrix< Tvec4< DT >, 4 >::v.

Referenced by operator/=().

◆ operator<()

template<class DT>
bool ml::Tmat4< DT >::operator< ( const Tmat4< DT > & ) const
inline

Dummy 'lesser than operator' that always returns false. It is needed to make class work with some STL containers on VC7.

Definition at line 113 of file mlMatrix4.h.

◆ operator=()

template<class DT>
const Tmat4< DT > & ml::Tmat4< DT >::operator= ( const Tmat4< DT > & m)
inline

◆ set()

template<class DT>
void ml::Tmat4< DT >::set ( const DT val)
inline

Sets all values to val.

Sets all values to double val.

Definition at line 265 of file mlMatrix4.h.

References set(), and ml::FloatingPointMatrix< Tvec4< DT >, 4 >::v.

Referenced by ml::TQuaternion< MLfloat >::getAsMat4(), and set().

◆ setScaleMatrix()

template<class DT>
void ml::Tmat4< DT >::setScaleMatrix ( const DT scale)

Sets a diagonal matrix with [ scale on the diagonal.

Sets a diagonal matrix with scale on the diagonal.

Definition at line 538 of file mlMatrix4.h.

References setScaleMatrix(), and ml::FloatingPointMatrix< Tvec4< DT >, 4 >::v.

Referenced by setScaleMatrix().

◆ setValues() [1/2]

template<class DT>
void ml::Tmat4< DT >::setValues ( const double mat[16])

Copies the contents from double array mat into *this, row by row.

Copies the contents of mat into *this, row by row.

Definition at line 512 of file mlMatrix4.h.

References setValues(), and ml::FloatingPointMatrix< Tvec4< DT >, 4 >::v.

◆ setValues() [2/2]

template<class DT>
void ml::Tmat4< DT >::setValues ( const float mat[16])

Copies the contents from float array mat into *this, row by row.

Copies the contents of mat into *this, row by row.

Definition at line 486 of file mlMatrix4.h.

References setValues(), and ml::FloatingPointMatrix< Tvec4< DT >, 4 >::v.

Referenced by setValues(), setValues(), Tmat4(), and Tmat4().

◆ transformPoint()

template<class DT>
Tvec3< DT > ml::Tmat4< DT >::transformPoint ( const Tvec3< DT > & sourceVec) const
inline

Transforms the given sourceVec and returns the result vector.

Definition at line 94 of file mlMatrix4.h.

◆ transpose()

template<class DT>
Tmat4< DT > ml::Tmat4< DT >::transpose ( ) const
inline

Returns the transposed *this.

Definition at line 572 of file mlMatrix4.h.

References Tmat4(), transpose(), and ml::FloatingPointMatrix< Tvec4< DT >, 4 >::v.

Referenced by ml::operator*(), ml::operator*(), and transpose().


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