Open CASCADE Technology 7.8.0
Public Member Functions | Static Public Member Functions
NCollection_Mat4< Element_t > Class Template Reference

Generic matrix of 4 x 4 elements. To be used in conjunction with NCollection_Vec4 entities. Originally introduced for 3D space projection and orientation operations. Warning, empty constructor returns an identity matrix. More...

#include <NCollection_Mat4.hxx>

Public Member Functions

 NCollection_Mat4 ()
 Empty constructor. Construct the identity matrix.
 
template<typename OtherElement_t >
 NCollection_Mat4 (const NCollection_Mat4< OtherElement_t > &theOtherMat4)
 Conversion constructor (explicitly converts some 4 x 4 matrix with other element type to a new 4 x 4 matrix with the element type Element_t, whose elements are static_cast'ed corresponding elements of theOtherMat4 matrix)
 
Element_t GetValue (const size_t theRow, const size_t theCol) const
 Get element at the specified row and column.
 
Element_tChangeValue (const size_t theRow, const size_t theCol)
 Access element at the specified row and column.
 
void SetValue (const size_t theRow, const size_t theCol, const Element_t theValue)
 Set value for the element specified by row and columns.
 
Element_toperator() (const size_t theRow, const size_t theCol)
 Return value.
 
Element_t operator() (const size_t theRow, const size_t theCol) const
 Return value.
 
NCollection_Vec4< Element_tGetRow (const size_t theRow) const
 Get vector of elements for the specified row.
 
void SetRow (const size_t theRow, const NCollection_Vec3< Element_t > &theVec)
 Change first 3 row values by the passed vector.
 
void SetRow (const size_t theRow, const NCollection_Vec4< Element_t > &theVec)
 Set row values by the passed 4 element vector.
 
NCollection_Vec4< Element_tGetColumn (const size_t theCol) const
 Get vector of elements for the specified column.
 
void SetColumn (const size_t theCol, const NCollection_Vec3< Element_t > &theVec)
 Change first 3 column values by the passed vector.
 
void SetColumn (const size_t theCol, const NCollection_Vec4< Element_t > &theVec)
 Set column values by the passed 4 element vector.
 
NCollection_Vec4< Element_tGetDiagonal () const
 Get vector of diagonal elements.
 
void SetDiagonal (const NCollection_Vec3< Element_t > &theVec)
 Change first 3 elements of the diagonal matrix.
 
void SetDiagonal (const NCollection_Vec4< Element_t > &theVec)
 Set diagonal elements of the matrix by the passed vector.
 
NCollection_Mat3< Element_tGetMat3 () const
 Return 3x3 sub-matrix.
 
void InitZero ()
 Initialize the zero matrix.
 
bool IsZero () const
 Checks the matrix for zero (without tolerance).
 
void InitIdentity ()
 Initialize the identity matrix.
 
bool IsIdentity () const
 Checks the matrix for identity (without tolerance).
 
bool IsEqual (const NCollection_Mat4 &theOther) const
 Check this matrix for equality with another matrix (without tolerance!).
 
bool operator== (const NCollection_Mat4 &theOther) const
 Check this matrix for equality with another matrix (without tolerance!).
 
bool operator!= (const NCollection_Mat4 &theOther) const
 Check this matrix for non-equality with another matrix (without tolerance!).
 
const Element_tGetData () const
 Raw access to the data (for OpenGL exchange); the data is returned in column-major order.
 
Element_tChangeData ()
 
NCollection_Vec4< Element_toperator* (const NCollection_Vec4< Element_t > &theVec) const
 Multiply by the vector (M * V).
 
void Multiply (const NCollection_Mat4 &theMat)
 Compute matrix multiplication.
 
NCollection_Mat4operator*= (const NCollection_Mat4 &theMat)
 Multiply by the another matrix.
 
NCollection_Mat4 operator* (const NCollection_Mat4 &theMat) const
 Compute matrix multiplication product.
 
NCollection_Mat4 Multiplied (const NCollection_Mat4 &theMat) const
 Compute matrix multiplication product.
 
void Multiply (const Element_t theFactor)
 Compute per-component multiplication.
 
NCollection_Mat4operator*= (const Element_t theFactor)
 Compute per-element multiplication.
 
NCollection_Mat4 operator* (const Element_t theFactor) const
 Compute per-element multiplication.
 
NCollection_Mat4 Multiplied (const Element_t theFactor) const
 Compute per-element multiplication.
 
void Divide (const Element_t theFactor)
 Compute per-component division.
 
NCollection_Mat4operator/= (const Element_t theScalar)
 Per-component division.
 
NCollection_Mat4 Divided (const Element_t theScalar) const
 Divides all the coefficients of the matrix by scalar.
 
NCollection_Mat4 operator/ (const Element_t theScalar) const
 Divides all the coefficients of the matrix by scalar.
 
void Add (const NCollection_Mat4 &theMat)
 Per-component addition of another matrix.
 
NCollection_Mat4operator+= (const NCollection_Mat4 &theMat)
 Per-component addition of another matrix.
 
void Subtract (const NCollection_Mat4 &theMat)
 Per-component subtraction of another matrix.
 
NCollection_Mat4operator-= (const NCollection_Mat4 &theMat)
 Per-component subtraction of another matrix.
 
NCollection_Mat4 Added (const NCollection_Mat4 &theMat) const
 Per-component addition of another matrix.
 
NCollection_Mat4 operator+ (const NCollection_Mat4 &theMat) const
 Per-component addition of another matrix.
 
NCollection_Mat4 Subtracted (const NCollection_Mat4 &theMat) const
 Per-component subtraction of another matrix.
 
NCollection_Mat4 operator- (const NCollection_Mat4 &theMat) const
 Per-component subtraction of another matrix.
 
NCollection_Mat4 Negated () const
 Returns matrix with all components negated.
 
NCollection_Mat4 operator- () const
 Returns matrix with all components negated.
 
void Translate (const NCollection_Vec3< Element_t > &theVec)
 Translate the matrix on the passed vector.
 
NCollection_Mat4 Transposed () const
 Transpose the matrix.
 
void Transpose ()
 Transpose the matrix.
 
bool Inverted (NCollection_Mat4< Element_t > &theOutMx, Element_t &theDet) const
 Compute inverted matrix.
 
bool Inverted (NCollection_Mat4< Element_t > &theOutMx) const
 Compute inverted matrix.
 
NCollection_Mat4 Inverted () const
 Return inverted matrix.
 
Element_t DeterminantMat3 () const
 Return determinant of the 3x3 sub-matrix.
 
NCollection_Mat4< Element_tAdjoint () const
 Return adjoint (adjugate matrix, e.g. conjugate transpose).
 
template<typename Other_t >
void ConvertFrom (const NCollection_Mat4< Other_t > &theFrom)
 Take values from NCollection_Mat4 with a different element type with type conversion.
 
template<typename Other_t >
void Convert (const NCollection_Mat4< Other_t > &theFrom)
 Take values from NCollection_Mat4 with a different element type with type conversion.
 
void DumpJson (Standard_OStream &theOStream, Standard_Integer) const
 Dumps the content of me into the stream.
 

Static Public Member Functions

static size_t Rows ()
 Get number of rows.
 
static size_t Cols ()
 Get number of columns. @retur number of columns.
 
static NCollection_Mat4 Identity ()
 Return identity matrix.
 
static NCollection_Mat4 Zero ()
 Return zero matrix.
 
static NCollection_Mat4 Multiply (const NCollection_Mat4 &theMatA, const NCollection_Mat4 &theMatB)
 Compute matrix multiplication product: A * B.
 
static NCollection_Mat4< Element_t > & Map (Element_t *theData)
 Maps plain C array to matrix type.
 
static const NCollection_Mat4< Element_t > & Map (const Element_t *theData)
 Maps plain C array to matrix type.
 

Detailed Description

template<typename Element_t>
class NCollection_Mat4< Element_t >

Generic matrix of 4 x 4 elements. To be used in conjunction with NCollection_Vec4 entities. Originally introduced for 3D space projection and orientation operations. Warning, empty constructor returns an identity matrix.

Constructor & Destructor Documentation

◆ NCollection_Mat4() [1/2]

Empty constructor. Construct the identity matrix.

◆ NCollection_Mat4() [2/2]

Conversion constructor (explicitly converts some 4 x 4 matrix with other element type to a new 4 x 4 matrix with the element type Element_t, whose elements are static_cast'ed corresponding elements of theOtherMat4 matrix)

Template Parameters
OtherElement_tthe element type of the other 4 x 4 matrix theOtherVec4
Parameters
theOtherMat4the 4 x 4 matrix that needs to be converted

Member Function Documentation

◆ Add()

template<typename Element_t >
void NCollection_Mat4< Element_t >::Add ( const NCollection_Mat4< Element_t > &  theMat)
inline

Per-component addition of another matrix.

◆ Added()

template<typename Element_t >
NCollection_Mat4 NCollection_Mat4< Element_t >::Added ( const NCollection_Mat4< Element_t > &  theMat) const
inline

Per-component addition of another matrix.

◆ Adjoint()

template<typename Element_t >
NCollection_Mat4< Element_t > NCollection_Mat4< Element_t >::Adjoint ( ) const
inline

Return adjoint (adjugate matrix, e.g. conjugate transpose).

◆ ChangeData()

template<typename Element_t >
Element_t * NCollection_Mat4< Element_t >::ChangeData ( )
inline

◆ ChangeValue()

template<typename Element_t >
Element_t & NCollection_Mat4< Element_t >::ChangeValue ( const size_t  theRow,
const size_t  theCol 
)
inline

Access element at the specified row and column.

Parameters
theRow[in] the row to access.
theCol[in] the column to access.
Returns
reference on the matrix element.

◆ Cols()

template<typename Element_t >
static size_t NCollection_Mat4< Element_t >::Cols ( )
inlinestatic

Get number of columns. @retur number of columns.

◆ Convert()

template<typename Element_t >
template<typename Other_t >
void NCollection_Mat4< Element_t >::Convert ( const NCollection_Mat4< Other_t > &  theFrom)
inline

Take values from NCollection_Mat4 with a different element type with type conversion.

◆ ConvertFrom()

template<typename Element_t >
template<typename Other_t >
void NCollection_Mat4< Element_t >::ConvertFrom ( const NCollection_Mat4< Other_t > &  theFrom)
inline

Take values from NCollection_Mat4 with a different element type with type conversion.

◆ DeterminantMat3()

template<typename Element_t >
Element_t NCollection_Mat4< Element_t >::DeterminantMat3 ( ) const
inline

Return determinant of the 3x3 sub-matrix.

◆ Divide()

template<typename Element_t >
void NCollection_Mat4< Element_t >::Divide ( const Element_t  theFactor)
inline

Compute per-component division.

Parameters
theFactor[in] the scale factor.

◆ Divided()

template<typename Element_t >
NCollection_Mat4 NCollection_Mat4< Element_t >::Divided ( const Element_t  theScalar) const
inline

Divides all the coefficients of the matrix by scalar.

◆ DumpJson()

template<typename Element_t >
void NCollection_Mat4< Element_t >::DumpJson ( Standard_OStream theOStream,
Standard_Integer   
) const
inline

Dumps the content of me into the stream.

◆ GetColumn()

template<typename Element_t >
NCollection_Vec4< Element_t > NCollection_Mat4< Element_t >::GetColumn ( const size_t  theCol) const
inline

Get vector of elements for the specified column.

Parameters
theCol[in] the column to access.
Returns
vector of elements.

◆ GetData()

template<typename Element_t >
const Element_t * NCollection_Mat4< Element_t >::GetData ( ) const
inline

Raw access to the data (for OpenGL exchange); the data is returned in column-major order.

◆ GetDiagonal()

template<typename Element_t >
NCollection_Vec4< Element_t > NCollection_Mat4< Element_t >::GetDiagonal ( ) const
inline

Get vector of diagonal elements.

Returns
vector of diagonal elements.

◆ GetMat3()

template<typename Element_t >
NCollection_Mat3< Element_t > NCollection_Mat4< Element_t >::GetMat3 ( ) const
inline

Return 3x3 sub-matrix.

◆ GetRow()

template<typename Element_t >
NCollection_Vec4< Element_t > NCollection_Mat4< Element_t >::GetRow ( const size_t  theRow) const
inline

Get vector of elements for the specified row.

Parameters
theRow[in] the row to access.
Returns
vector of elements.

◆ GetValue()

template<typename Element_t >
Element_t NCollection_Mat4< Element_t >::GetValue ( const size_t  theRow,
const size_t  theCol 
) const
inline

Get element at the specified row and column.

Parameters
theRow[in] the row to address.
theCol[in] the column to address.
Returns
the value of the addressed element.

◆ Identity()

template<typename Element_t >
static NCollection_Mat4 NCollection_Mat4< Element_t >::Identity ( )
inlinestatic

Return identity matrix.

◆ InitIdentity()

template<typename Element_t >
void NCollection_Mat4< Element_t >::InitIdentity ( )
inline

Initialize the identity matrix.

◆ InitZero()

template<typename Element_t >
void NCollection_Mat4< Element_t >::InitZero ( )
inline

Initialize the zero matrix.

◆ Inverted() [1/3]

template<typename Element_t >
NCollection_Mat4 NCollection_Mat4< Element_t >::Inverted ( ) const
inline

Return inverted matrix.

◆ Inverted() [2/3]

template<typename Element_t >
bool NCollection_Mat4< Element_t >::Inverted ( NCollection_Mat4< Element_t > &  theOutMx) const
inline

Compute inverted matrix.

Parameters
theOutMx[out] the inverted matrix
Returns
true if reversion success

◆ Inverted() [3/3]

template<typename Element_t >
bool NCollection_Mat4< Element_t >::Inverted ( NCollection_Mat4< Element_t > &  theOutMx,
Element_t theDet 
) const
inline

Compute inverted matrix.

Parameters
theOutMx[out] the inverted matrix
theDet[out] determinant of matrix
Returns
true if reversion success

◆ IsEqual()

template<typename Element_t >
bool NCollection_Mat4< Element_t >::IsEqual ( const NCollection_Mat4< Element_t > &  theOther) const
inline

Check this matrix for equality with another matrix (without tolerance!).

◆ IsIdentity()

template<typename Element_t >
bool NCollection_Mat4< Element_t >::IsIdentity ( ) const
inline

Checks the matrix for identity (without tolerance).

◆ IsZero()

template<typename Element_t >
bool NCollection_Mat4< Element_t >::IsZero ( ) const
inline

Checks the matrix for zero (without tolerance).

◆ Map() [1/2]

template<typename Element_t >
static const NCollection_Mat4< Element_t > & NCollection_Mat4< Element_t >::Map ( const Element_t theData)
inlinestatic

Maps plain C array to matrix type.

◆ Map() [2/2]

template<typename Element_t >
static NCollection_Mat4< Element_t > & NCollection_Mat4< Element_t >::Map ( Element_t theData)
inlinestatic

Maps plain C array to matrix type.

◆ Multiplied() [1/2]

template<typename Element_t >
NCollection_Mat4 NCollection_Mat4< Element_t >::Multiplied ( const Element_t  theFactor) const
inline

Compute per-element multiplication.

Parameters
theFactor[in] the scale factor.
Returns
the result of multiplication.

◆ Multiplied() [2/2]

template<typename Element_t >
NCollection_Mat4 NCollection_Mat4< Element_t >::Multiplied ( const NCollection_Mat4< Element_t > &  theMat) const
inline

Compute matrix multiplication product.

Parameters
theMat[in] the other matrix.
Returns
result of multiplication.

◆ Multiply() [1/3]

template<typename Element_t >
void NCollection_Mat4< Element_t >::Multiply ( const Element_t  theFactor)
inline

Compute per-component multiplication.

Parameters
theFactor[in] the scale factor.

◆ Multiply() [2/3]

template<typename Element_t >
void NCollection_Mat4< Element_t >::Multiply ( const NCollection_Mat4< Element_t > &  theMat)
inline

Compute matrix multiplication.

Parameters
theMat[in] the matrix to multiply.

◆ Multiply() [3/3]

template<typename Element_t >
static NCollection_Mat4 NCollection_Mat4< Element_t >::Multiply ( const NCollection_Mat4< Element_t > &  theMatA,
const NCollection_Mat4< Element_t > &  theMatB 
)
inlinestatic

Compute matrix multiplication product: A * B.

Parameters
theMatA[in] the matrix "A".
theMatB[in] the matrix "B".

◆ Negated()

template<typename Element_t >
NCollection_Mat4 NCollection_Mat4< Element_t >::Negated ( ) const
inline

Returns matrix with all components negated.

◆ operator!=()

template<typename Element_t >
bool NCollection_Mat4< Element_t >::operator!= ( const NCollection_Mat4< Element_t > &  theOther) const
inline

Check this matrix for non-equality with another matrix (without tolerance!).

◆ operator()() [1/2]

template<typename Element_t >
Element_t & NCollection_Mat4< Element_t >::operator() ( const size_t  theRow,
const size_t  theCol 
)
inline

Return value.

◆ operator()() [2/2]

template<typename Element_t >
Element_t NCollection_Mat4< Element_t >::operator() ( const size_t  theRow,
const size_t  theCol 
) const
inline

Return value.

◆ operator*() [1/3]

Compute per-element multiplication.

Parameters
theFactor[in] the scale factor.
Returns
the result of multiplication.

◆ operator*() [2/3]

Compute matrix multiplication product.

Parameters
theMat[in] the other matrix.
Returns
result of multiplication.

◆ operator*() [3/3]

Multiply by the vector (M * V).

Parameters
theVec[in] the vector to multiply.

◆ operator*=() [1/2]

Compute per-element multiplication.

Parameters
theFactor[in] the scale factor.

◆ operator*=() [2/2]

Multiply by the another matrix.

Parameters
theMat[in] the other matrix.

◆ operator+()

Per-component addition of another matrix.

◆ operator+=()

Per-component addition of another matrix.

◆ operator-() [1/2]

Returns matrix with all components negated.

◆ operator-() [2/2]

Per-component subtraction of another matrix.

◆ operator-=()

Per-component subtraction of another matrix.

◆ operator/()

Divides all the coefficients of the matrix by scalar.

◆ operator/=()

Per-component division.

Parameters
theScalar[in] the scale factor.

◆ operator==()

Check this matrix for equality with another matrix (without tolerance!).

◆ Rows()

template<typename Element_t >
static size_t NCollection_Mat4< Element_t >::Rows ( )
inlinestatic

Get number of rows.

Returns
number of rows.

◆ SetColumn() [1/2]

template<typename Element_t >
void NCollection_Mat4< Element_t >::SetColumn ( const size_t  theCol,
const NCollection_Vec3< Element_t > &  theVec 
)
inline

Change first 3 column values by the passed vector.

Parameters
theCol[in] the column to change.
theVec[in] the vector of values.

◆ SetColumn() [2/2]

template<typename Element_t >
void NCollection_Mat4< Element_t >::SetColumn ( const size_t  theCol,
const NCollection_Vec4< Element_t > &  theVec 
)
inline

Set column values by the passed 4 element vector.

Parameters
theCol[in] the column to change.
theVec[in] the vector of values.

◆ SetDiagonal() [1/2]

template<typename Element_t >
void NCollection_Mat4< Element_t >::SetDiagonal ( const NCollection_Vec3< Element_t > &  theVec)
inline

Change first 3 elements of the diagonal matrix.

Parameters
theVecthe vector of values.

◆ SetDiagonal() [2/2]

template<typename Element_t >
void NCollection_Mat4< Element_t >::SetDiagonal ( const NCollection_Vec4< Element_t > &  theVec)
inline

Set diagonal elements of the matrix by the passed vector.

Parameters
theVec[in] the vector of values.

◆ SetRow() [1/2]

template<typename Element_t >
void NCollection_Mat4< Element_t >::SetRow ( const size_t  theRow,
const NCollection_Vec3< Element_t > &  theVec 
)
inline

Change first 3 row values by the passed vector.

Parameters
theRow[in] the row to change.
theVec[in] the vector of values.

◆ SetRow() [2/2]

template<typename Element_t >
void NCollection_Mat4< Element_t >::SetRow ( const size_t  theRow,
const NCollection_Vec4< Element_t > &  theVec 
)
inline

Set row values by the passed 4 element vector.

Parameters
theRow[in] the row to change.
theVec[in] the vector of values.

◆ SetValue()

template<typename Element_t >
void NCollection_Mat4< Element_t >::SetValue ( const size_t  theRow,
const size_t  theCol,
const Element_t  theValue 
)
inline

Set value for the element specified by row and columns.

Parameters
theRow[in] the row to change.
theCol[in] the column to change.
theValue[in] the value to set.

◆ Subtract()

template<typename Element_t >
void NCollection_Mat4< Element_t >::Subtract ( const NCollection_Mat4< Element_t > &  theMat)
inline

Per-component subtraction of another matrix.

◆ Subtracted()

template<typename Element_t >
NCollection_Mat4 NCollection_Mat4< Element_t >::Subtracted ( const NCollection_Mat4< Element_t > &  theMat) const
inline

Per-component subtraction of another matrix.

◆ Translate()

template<typename Element_t >
void NCollection_Mat4< Element_t >::Translate ( const NCollection_Vec3< Element_t > &  theVec)
inline

Translate the matrix on the passed vector.

Parameters
theVec[in] the translation vector.

◆ Transpose()

template<typename Element_t >
void NCollection_Mat4< Element_t >::Transpose ( )
inline

Transpose the matrix.

◆ Transposed()

template<typename Element_t >
NCollection_Mat4 NCollection_Mat4< Element_t >::Transposed ( ) const
inline

Transpose the matrix.

Returns
transposed copy of the matrix.

◆ Zero()

template<typename Element_t >
static NCollection_Mat4 NCollection_Mat4< Element_t >::Zero ( )
inlinestatic

Return zero matrix.


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