Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
QGenericMatrix< N, M, T > Class Template Reference

The QGenericMatrix class is a template class that represents a NxM transformation matrix with N columns and M rows. More...

#include <qgenericmatrix.h>

+ Collaboration diagram for QGenericMatrix< N, M, T >:

Public Member Functions

 QGenericMatrix ()
 
 QGenericMatrix (Qt::Initialization)
 
 QGenericMatrix (const T *values)
 Constructs a matrix from the given N * M floating-point values.
 
const T & operator() (int row, int column) const
 Returns a constant reference to the element at position (row, column) in this matrix.
 
T & operator() (int row, int column)
 Returns a reference to the element at position (row, column) in this matrix so that the element can be assigned to.
 
bool isIdentity () const
 Returns true if this matrix is the identity; false otherwise.
 
void setToIdentity ()
 Sets this matrix to the identity.
 
void fill (T value)
 Fills all elements of this matrix with value.
 
QGenericMatrix< M, N, T > transposed () const
 Returns this matrix, transposed about its diagonal.
 
QGenericMatrix< N, M, T > & operator+= (const QGenericMatrix< N, M, T > &other)
 Adds the contents of other to this matrix.
 
QGenericMatrix< N, M, T > & operator-= (const QGenericMatrix< N, M, T > &other)
 Subtracts the contents of other from this matrix.
 
QGenericMatrix< N, M, T > & operator*= (T factor)
 Multiplies all elements of this matrix by factor.
 
QGenericMatrix< N, M, T > & operator/= (T divisor)
 Divides all elements of this matrix by divisor.
 
bool operator== (const QGenericMatrix< N, M, T > &other) const
 Returns true if this matrix is identical to other; false otherwise.
 
bool operator!= (const QGenericMatrix< N, M, T > &other) const
 Returns true if this matrix is not identical to other; false otherwise.
 
void copyDataTo (T *values) const
 Retrieves the N * M items in this matrix and copies them to values in row-major order.
 
T * data ()
 Returns a pointer to the raw data of this matrix.
 
const T * data () const
 Returns a constant pointer to the raw data of this matrix.
 
const T * constData () const
 Returns a constant pointer to the raw data of this matrix.
 

Friends

template<int NN, int MM, typename TT >
class QGenericMatrix
 Constructs a NxM identity matrix.
 
template<int NN, int MM, typename TT >
QGenericMatrix< NN, MM, TT > operator+ (const QGenericMatrix< NN, MM, TT > &m1, const QGenericMatrix< NN, MM, TT > &m2)
 
template<int NN, int MM, typename TT >
QGenericMatrix< NN, MM, TT > operator- (const QGenericMatrix< NN, MM, TT > &m1, const QGenericMatrix< NN, MM, TT > &m2)
 
template<int NN, int M1, int M2, typename TT >
QGenericMatrix< M1, M2, TT > operator* (const QGenericMatrix< NN, M2, TT > &m1, const QGenericMatrix< M1, NN, TT > &m2)
 Returns the product of the NNxM2 matrix m1 and the M1xNN matrix m2 to produce a M1xM2 matrix result.
 
template<int NN, int MM, typename TT >
QGenericMatrix< NN, MM, TT > operator- (const QGenericMatrix< NN, MM, TT > &matrix)
 
template<int NN, int MM, typename TT >
QGenericMatrix< NN, MM, TT > operator* (TT factor, const QGenericMatrix< NN, MM, TT > &matrix)
 
template<int NN, int MM, typename TT >
QGenericMatrix< NN, MM, TT > operator* (const QGenericMatrix< NN, MM, TT > &matrix, TT factor)
 
template<int NN, int MM, typename TT >
QGenericMatrix< NN, MM, TT > operator/ (const QGenericMatrix< NN, MM, TT > &matrix, TT divisor)
 

Related Symbols

(Note that these are not member symbols.)

template< int N, int M, typename T > QGenericMatrix< N, M, T > operator+ (const QGenericMatrix< N, M, T > &m1, const QGenericMatrix< N, M, T > &m2)
 Returns the sum of m1 and m2.
 
template< int N, int M, typename T > QGenericMatrix< N, M, T > operator- (const QGenericMatrix< N, M, T > &m1, const QGenericMatrix< N, M, T > &m2)
 Returns the difference of m1 and m2.
 
template< int N, int M, typename T > QGenericMatrix< N, M, T > operator- (const QGenericMatrix< N, M, T > &matrix)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
template< int N, int M, typename T > QGenericMatrix< N, M, T > operator* (T factor, const QGenericMatrix< N, M, T > &matrix)
 Returns the result of multiplying all elements of matrix by factor.
 
template< int N, int M, typename T > QGenericMatrix< N, M, T > operator* (const QGenericMatrix< N, M, T > &matrix, T factor)
 Returns the result of multiplying all elements of matrix by factor.
 
template< int N, int M, typename T > QGenericMatrix< N, M, T > operator/ (const QGenericMatrix< N, M, T > &matrix, T divisor)
 Returns the result of dividing all elements of matrix by divisor.
 
template< int N, int M, typename T > QDataStreamoperator<< (QDataStream &stream, const QGenericMatrix< N, M, T > &matrix)
 Writes the given matrix to the given stream and returns a reference to the stream.
 
template< int N, int M, typename T > QDataStreamoperator>> (QDataStream &stream, QGenericMatrix< N, M, T > &matrix)
 Reads a NxM matrix from the given stream into the given matrix and returns a reference to the stream.
 
 QMatrix2x2
 The QMatrix2x2 type defines a convenient instantiation of the QGenericMatrix template for 2 columns, 2 rows, and float as the element type.
 
 QMatrix2x3
 The QMatrix2x3 type defines a convenient instantiation of the QGenericMatrix template for 2 columns, 3 rows, and float as the element type.
 
 QMatrix2x4
 The QMatrix2x4 type defines a convenient instantiation of the QGenericMatrix template for 2 columns, 4 rows, and float as the element type.
 
 QMatrix3x2
 The QMatrix3x2 type defines a convenient instantiation of the QGenericMatrix template for 3 columns, 2 rows, and float as the element type.
 
 QMatrix3x3
 The QMatrix3x3 type defines a convenient instantiation of the QGenericMatrix template for 3 columns, 3 rows, and float as the element type.
 
 QMatrix3x4
 The QMatrix3x4 type defines a convenient instantiation of the QGenericMatrix template for 3 columns, 4 rows, and float as the element type.
 
 QMatrix4x2
 The QMatrix4x2 type defines a convenient instantiation of the QGenericMatrix template for 4 columns, 2 rows, and float as the element type.
 
 QMatrix4x3
 The QMatrix4x3 type defines a convenient instantiation of the QGenericMatrix template for 4 columns, 3 rows, and float as the element type.
 

Detailed Description

template<int N, int M, typename T>
class QGenericMatrix< N, M, T >

The QGenericMatrix class is a template class that represents a NxM transformation matrix with N columns and M rows.

Since
4.6

\inmodule QtGui

The QGenericMatrix template has three parameters:

\table \row

  • N
  • Number of columns. \row
  • M
  • Number of rows. \row
  • T
  • Element type that is visible to users of the class. \endtable
See also
QMatrix4x4

Definition at line 16 of file qgenericmatrix.h.

Constructor & Destructor Documentation

◆ QGenericMatrix() [1/3]

template<int N, int M, typename T >
Q_INLINE_TEMPLATE QGenericMatrix< N, M, T >::QGenericMatrix ( )

Definition at line 74 of file qgenericmatrix.h.

◆ QGenericMatrix() [2/3]

template<int N, int M, typename T >
template< int N, int M, typename T > QGenericMatrix< N, M, T >::QGenericMatrix ( Qt::Initialization )
inlineexplicit
Since
5.5

Constructs a NxM matrix without initializing the contents.

Definition at line 20 of file qgenericmatrix.h.

◆ QGenericMatrix() [3/3]

template<int N, int M, typename T >
Q_OUTOFLINE_TEMPLATE QGenericMatrix< N, M, T >::QGenericMatrix ( const T * values)
explicit

Constructs a matrix from the given N * M floating-point values.

The contents of the array values is assumed to be in row-major order.

See also
copyDataTo()

Definition at line 80 of file qgenericmatrix.h.

References M.

Member Function Documentation

◆ constData()

template<int N, int M, typename T >
template< int N, int M, typename T > const T * QGenericMatrix< N, M, T >::constData ( ) const
inline

Returns a constant pointer to the raw data of this matrix.

See also
data()

Definition at line 44 of file qgenericmatrix.h.

◆ copyDataTo()

template<int N, int M, typename T >
Q_OUTOFLINE_TEMPLATE void QGenericMatrix< N, M, T >::copyDataTo ( T * values) const

Retrieves the N * M items in this matrix and copies them to values in row-major order.

Definition at line 283 of file qgenericmatrix.h.

References M.

◆ data() [1/2]

template<int N, int M, typename T >
template< int N, int M, typename T > T * QGenericMatrix< N, M, T >::data ( )
inline

Returns a pointer to the raw data of this matrix.

See also
constData()

Definition at line 42 of file qgenericmatrix.h.

Referenced by QSvgFeColorMatrix::QSvgFeColorMatrix(), QSvgFeColorMatrix::apply(), QMatrix4x4::normalMatrix(), and QDynamicRigidBody::setInertiaMatrix().

+ Here is the caller graph for this function:

◆ data() [2/2]

template<int N, int M, typename T >
template< int N, int M, typename T > const T * QGenericMatrix< N, M, T >::data ( ) const
inline

Returns a constant pointer to the raw data of this matrix.

See also
constData()

Definition at line 43 of file qgenericmatrix.h.

◆ fill()

template<int N, int M, typename T >
Q_OUTOFLINE_TEMPLATE void QGenericMatrix< N, M, T >::fill ( T value)

Fills all elements of this matrix with value.

Definition at line 132 of file qgenericmatrix.h.

References M.

Referenced by QSvgFeColorMatrix::QSvgFeColorMatrix(), and createFeColorMatrixNode().

+ Here is the caller graph for this function:

◆ isIdentity()

template<int N, int M, typename T >
Q_OUTOFLINE_TEMPLATE bool QGenericMatrix< N, M, T >::isIdentity ( ) const

Returns true if this matrix is the identity; false otherwise.

See also
setToIdentity()

Definition at line 102 of file qgenericmatrix.h.

References M.

◆ operator!=()

template<int N, int M, typename T >
Q_OUTOFLINE_TEMPLATE bool QGenericMatrix< N, M, T >::operator!= ( const QGenericMatrix< N, M, T > & other) const

Returns true if this matrix is not identical to other; false otherwise.

Definition at line 191 of file qgenericmatrix.h.

References other().

+ Here is the call graph for this function:

◆ operator()() [1/2]

template<int N, int M, typename T >
Q_INLINE_TEMPLATE T & QGenericMatrix< N, M, T >::operator() ( int row,
int column )

Returns a reference to the element at position (row, column) in this matrix so that the element can be assigned to.

Definition at line 95 of file qgenericmatrix.h.

References Q_ASSERT.

◆ operator()() [2/2]

template<int N, int M, typename T >
Q_INLINE_TEMPLATE const T & QGenericMatrix< N, M, T >::operator() ( int row,
int column ) const

Returns a constant reference to the element at position (row, column) in this matrix.

Definition at line 88 of file qgenericmatrix.h.

References Q_ASSERT.

◆ operator*=()

template<int N, int M, typename T >
Q_OUTOFLINE_TEMPLATE QGenericMatrix< N, M, T > & QGenericMatrix< N, M, T >::operator*= ( T factor)

Multiplies all elements of this matrix by factor.

Definition at line 168 of file qgenericmatrix.h.

◆ operator+=()

template<int N, int M, typename T >
Q_OUTOFLINE_TEMPLATE QGenericMatrix< N, M, T > & QGenericMatrix< N, M, T >::operator+= ( const QGenericMatrix< N, M, T > & other)

Adds the contents of other to this matrix.

Definition at line 150 of file qgenericmatrix.h.

References M, and other().

+ Here is the call graph for this function:

◆ operator-=()

template<int N, int M, typename T >
Q_OUTOFLINE_TEMPLATE QGenericMatrix< N, M, T > & QGenericMatrix< N, M, T >::operator-= ( const QGenericMatrix< N, M, T > & other)

Subtracts the contents of other from this matrix.

Definition at line 159 of file qgenericmatrix.h.

◆ operator/=()

template<int N, int M, typename T >
QT_WARNING_POP Q_OUTOFLINE_TEMPLATE QGenericMatrix< N, M, T > & QGenericMatrix< N, M, T >::operator/= ( T divisor)

Divides all elements of this matrix by divisor.

Definition at line 199 of file qgenericmatrix.h.

References M.

◆ operator==()

template<int N, int M, typename T >
QT_WARNING_PUSH QT_WARNING_DISABLE_FLOAT_COMPARE Q_OUTOFLINE_TEMPLATE bool QGenericMatrix< N, M, T >::operator== ( const QGenericMatrix< N, M, T > & other) const

Returns true if this matrix is identical to other; false otherwise.

Definition at line 180 of file qgenericmatrix.h.

◆ setToIdentity()

template<int N, int M, typename T >
Q_OUTOFLINE_TEMPLATE void QGenericMatrix< N, M, T >::setToIdentity ( )

Sets this matrix to the identity.

See also
isIdentity()

Definition at line 119 of file qgenericmatrix.h.

References M.

◆ transposed()

template<int N, int M, typename T >
Q_OUTOFLINE_TEMPLATE QGenericMatrix< M, N, T > QGenericMatrix< N, M, T >::transposed ( ) const

Returns this matrix, transposed about its diagonal.

Definition at line 140 of file qgenericmatrix.h.

References M, and Qt::Uninitialized.

Friends And Related Symbol Documentation

◆ QGenericMatrix

template<int N, int M, typename T >
template<int NN, int MM, typename TT >
template< int N, int M, typename T > QGenericMatrix< N, M, T >::QGenericMatrix
friend

Constructs a NxM identity matrix.

Definition at line 65 of file qgenericmatrix.h.

◆ operator*() [1/5]

template<int N, int M, typename T >
template< int N, int M, typename T > QGenericMatrix< N, M, T > operator* ( const QGenericMatrix< N, M, T > & matrix,
T factor )
related

Returns the result of multiplying all elements of matrix by factor.

Definition at line 263 of file qgenericmatrix.h.

References M, and Qt::Uninitialized.

◆ operator* [2/5]

template<int N, int M, typename T >
template<int NN, int M1, int M2, typename TT >
template< int N, int M, typename T > template< int NN, int M1, int M2, typename TT > QGenericMatrix< M1, M2, TT > QGenericMatrix< N, M, T >::operator* ( const QGenericMatrix< NN, M2, TT > & m1,
const QGenericMatrix< M1, NN, TT > & m2 )
friend

Returns the product of the NNxM2 matrix m1 and the M1xNN matrix m2 to produce a M1xM2 matrix result.

◆ operator* [3/5]

template<int N, int M, typename T >
template<int NN, int MM, typename TT >
QGenericMatrix< NN, MM, TT > operator* ( const QGenericMatrix< NN, MM, TT > & matrix,
TT factor )
friend

◆ operator*() [4/5]

template<int N, int M, typename T >
template< int N, int M, typename T > QGenericMatrix< N, M, T > operator* ( T factor,
const QGenericMatrix< N, M, T > & matrix )
related

Returns the result of multiplying all elements of matrix by factor.

Definition at line 253 of file qgenericmatrix.h.

References M, and Qt::Uninitialized.

◆ operator* [5/5]

template<int N, int M, typename T >
template<int NN, int MM, typename TT >
QGenericMatrix< NN, MM, TT > operator* ( TT factor,
const QGenericMatrix< NN, MM, TT > & matrix )
friend

◆ operator+() [1/2]

template<int N, int M, typename T >
template< int N, int M, typename T > QGenericMatrix< N, M, T > operator+ ( const QGenericMatrix< N, M, T > & m1,
const QGenericMatrix< N, M, T > & m2 )
related

Returns the sum of m1 and m2.

Definition at line 208 of file qgenericmatrix.h.

References M, and Qt::Uninitialized.

◆ operator+ [2/2]

template<int N, int M, typename T >
template<int NN, int MM, typename TT >
QGenericMatrix< NN, MM, TT > operator+ ( const QGenericMatrix< NN, MM, TT > & m1,
const QGenericMatrix< NN, MM, TT > & m2 )
friend

◆ operator-() [1/4]

template<int N, int M, typename T >
template< int N, int M, typename T > QGenericMatrix< N, M, T > operator- ( const QGenericMatrix< N, M, T > & m1,
const QGenericMatrix< N, M, T > & m2 )
related

Returns the difference of m1 and m2.

Definition at line 218 of file qgenericmatrix.h.

References M, and Qt::Uninitialized.

◆ operator-() [2/4]

template<int N, int M, typename T >
template< int N, int M, typename T > QGenericMatrix< N, M, T > operator- ( const QGenericMatrix< N, M, T > & matrix)
related

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Returns the negation of matrix.

Definition at line 243 of file qgenericmatrix.h.

◆ operator- [3/4]

template<int N, int M, typename T >
template<int NN, int MM, typename TT >
QGenericMatrix< NN, MM, TT > operator- ( const QGenericMatrix< NN, MM, TT > & m1,
const QGenericMatrix< NN, MM, TT > & m2 )
friend

◆ operator- [4/4]

template<int N, int M, typename T >
template<int NN, int MM, typename TT >
QGenericMatrix< NN, MM, TT > operator- ( const QGenericMatrix< NN, MM, TT > & matrix)
friend

◆ operator/() [1/2]

template<int N, int M, typename T >
template< int N, int M, typename T > QGenericMatrix< N, M, T > operator/ ( const QGenericMatrix< N, M, T > & matrix,
T divisor )
related

Returns the result of dividing all elements of matrix by divisor.

Definition at line 273 of file qgenericmatrix.h.

References M, and Qt::Uninitialized.

◆ operator/ [2/2]

template<int N, int M, typename T >
template<int NN, int MM, typename TT >
QGenericMatrix< NN, MM, TT > operator/ ( const QGenericMatrix< NN, MM, TT > & matrix,
TT divisor )
friend

◆ operator<<()

template<int N, int M, typename T >
template< int N, int M, typename T > QDataStream & operator<< ( QDataStream & stream,
const QGenericMatrix< N, M, T > & matrix )
related

Writes the given matrix to the given stream and returns a reference to the stream.

See also
{Serializing Qt Data Types}

Definition at line 323 of file qgenericmatrix.h.

References M.

◆ operator>>()

template<int N, int M, typename T >
template< int N, int M, typename T > QDataStream & operator>> ( QDataStream & stream,
QGenericMatrix< N, M, T > & matrix )
related

Reads a NxM matrix from the given stream into the given matrix and returns a reference to the stream.

See also
{Serializing Qt Data Types}

Definition at line 332 of file qgenericmatrix.h.

References M.

◆ QMatrix2x2()

template<int N, int M, typename T >
QMatrix2x2
related

The QMatrix2x2 type defines a convenient instantiation of the QGenericMatrix template for 2 columns, 2 rows, and float as the element type.

Definition at line 291 of file qgenericmatrix.h.

◆ QMatrix2x3()

template<int N, int M, typename T >
QMatrix2x3
related

The QMatrix2x3 type defines a convenient instantiation of the QGenericMatrix template for 2 columns, 3 rows, and float as the element type.

Definition at line 292 of file qgenericmatrix.h.

◆ QMatrix2x4()

template<int N, int M, typename T >
QMatrix2x4
related

The QMatrix2x4 type defines a convenient instantiation of the QGenericMatrix template for 2 columns, 4 rows, and float as the element type.

Definition at line 293 of file qgenericmatrix.h.

◆ QMatrix3x2()

template<int N, int M, typename T >
QMatrix3x2
related

The QMatrix3x2 type defines a convenient instantiation of the QGenericMatrix template for 3 columns, 2 rows, and float as the element type.

Definition at line 294 of file qgenericmatrix.h.

◆ QMatrix3x3()

template<int N, int M, typename T >
QMatrix3x3
related

The QMatrix3x3 type defines a convenient instantiation of the QGenericMatrix template for 3 columns, 3 rows, and float as the element type.

Definition at line 295 of file qgenericmatrix.h.

◆ QMatrix3x4()

template<int N, int M, typename T >
QMatrix3x4
related

The QMatrix3x4 type defines a convenient instantiation of the QGenericMatrix template for 3 columns, 4 rows, and float as the element type.

Definition at line 296 of file qgenericmatrix.h.

◆ QMatrix4x2()

template<int N, int M, typename T >
QMatrix4x2
related

The QMatrix4x2 type defines a convenient instantiation of the QGenericMatrix template for 4 columns, 2 rows, and float as the element type.

Definition at line 297 of file qgenericmatrix.h.

◆ QMatrix4x3()

template<int N, int M, typename T >
QMatrix4x3
related

The QMatrix4x3 type defines a convenient instantiation of the QGenericMatrix template for 4 columns, 3 rows, and float as the element type.

Definition at line 298 of file qgenericmatrix.h.


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