|  | Home · All Classes · Modules

# QMatrix4x4 Class Reference
[QtGui module]

The QMatrix4x4 class represents a 4x4 transformation matrix in 3D space. More...

### Methods

- __init__ (self)
- __init__ (self, sequence-of-float)
- __init__ (self, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float)
- __init__ (self, QTransform)
- __init__ (self, QMatrix)
- __init__ (self, QMatrix4x4)
- QVector4D column (self, int)
- list-of-float copyDataTo (self)
- list-of-float data (self)
- float determinant (self)
- fill (self, float)
- flipCoordinates (self)
- frustum (self, float, float, float, float, float, float)
- (QMatrix4x4, bool invertible) inverted (self)
- bool isIdentity (self)
- lookAt (self, QVector3D, QVector3D, QVector3D)
- QPoint map (self, QPoint)
- QPointF map (self, QPointF)
- QVector3D map (self, QVector3D)
- QVector4D map (self, QVector4D)
- QRect mapRect (self, QRect)
- QRectF mapRect (self, QRectF)
- QVector3D mapVector (self, QVector3D)
- QMatrix3x3 normalMatrix (self)
- optimize (self)
- ortho (self, QRect)
- ortho (self, QRectF)
- ortho (self, float, float, float, float, float, float)
- perspective (self, float, float, float, float)
- rotate (self, float, QVector3D)
- rotate (self, float, float, float, float z = 0)
- rotate (self, QQuaternion)
- QVector4D row (self, int)
- scale (self, QVector3D)
- scale (self, float, float)
- scale (self, float, float, float)
- scale (self, float)
- setColumn (self, int, QVector4D)
- setRow (self, int, QVector4D)
- setToIdentity (self)
- QMatrix toAffine (self)
- QTransform toTransform (self)
- QTransform toTransform (self, float)
- translate (self, QVector3D)
- translate (self, float, float)
- translate (self, float, float, float)
- QMatrix4x4 transposed (self)

### Special Methods

- QMatrix4x4 __add__ (self, QMatrix4x4)
- QMatrix4x4 __div__ (self, float)
- bool __eq__ (self, QMatrix4x4)
- object __getitem__ (self, object)
- QMatrix4x4 __iadd__ (self, QMatrix4x4)
- QMatrix4x4 __idiv__ (self, float)
- QMatrix4x4 __imul__ (self, QMatrix4x4)
- QMatrix4x4 __imul__ (self, float)
- QMatrix4x4 __isub__ (self, QMatrix4x4)
- QMatrix4x4 __mul__ (self, QMatrix4x4)
- QVector3D __mul__ (self, QVector3D)
- QVector4D __mul__ (self, QVector4D)
- QPoint __mul__ (self, QPoint)
- QPointF __mul__ (self, QPointF)
- QMatrix4x4 __mul__ (self, QMatrix4x4)
- QMatrix4x4 __mul__ (self, float)
- bool __ne__ (self, QMatrix4x4)
- QMatrix4x4 __neg__ (self, QMatrix4x4)
- str __repr__ (self)
- __setitem__ (self, object, float)
- QMatrix4x4 __sub__ (self, QMatrix4x4)

## Detailed Description

This class can be pickled.

The QMatrix4x4 class represents a 4x4 transformation matrix in 3D space.

See also QVector3D and QGenericMatrix.

## Method Documentation

### QMatrix4x4.__init__ (self)

Constructs an identity matrix.

### QMatrix4x4.__init__ (self, sequence-of-float)

Constructs a matrix from the given 16 floating-point values. The contents of the array values is assumed to be in row-major order.

If the matrix has a special type (identity, translate, scale, etc), the programmer should follow this constructor with a call to optimize() if they wish QMatrix4x4 to optimize further calls to translate(), scale(), etc.

See also copyDataTo() and optimize().

### QMatrix4x4.__init__ (self, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float)

Constructs a matrix from the 16 elements m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34, m41, m42, m43, and m44. The elements are specified in row-major order.

If the matrix has a special type (identity, translate, scale, etc), the programmer should follow this constructor with a call to optimize() if they wish QMatrix4x4 to optimize further calls to translate(), scale(), etc.

See also optimize().

### QMatrix4x4.__init__ (self, QTransform)

Constructs a 4x4 matrix from the left-most 4 columns and top-most 4 rows of matrix. If matrix has less than 4 columns or rows, the remaining elements are filled with elements from the identity matrix.

See also toGenericMatrix() and qGenericMatrixToMatrix4x4().

### QMatrix4x4.__init__ (self, QMatrix)

### QMatrix4x4.__init__ (self, QMatrix4x4)

Constructs a 4x4 matrix from the conventional Qt 2D transformation matrix transform.

If transform has a special type (identity, translate, scale, etc), the programmer should follow this constructor with a call to optimize() if they wish QMatrix4x4 to optimize further calls to translate(), scale(), etc.

See also toTransform() and optimize().

### QVector4D QMatrix4x4.column (self, int)

Returns the elements of column index as a 4D vector.

See also setColumn() and row().

### list-of-float QMatrix4x4.copyDataTo (self)

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

### list-of-float QMatrix4x4.data (self)

Returns a pointer to the raw data of this matrix.

See also constData() and optimize().

### float QMatrix4x4.determinant (self)

Returns the determinant of this matrix.

### QMatrix4x4.fill (self, float)

Fills all elements of this matrx with value.

### QMatrix4x4.flipCoordinates (self)

Flips between right-handed and left-handed coordinate systems by multiplying the y and z co-ordinates by -1. This is normally used to create a left-handed orthographic view without scaling the viewport as ortho() does.

See also ortho().

### QMatrix4x4.frustum (self, float, float, float, float, float, float)

Multiplies this matrix by another that applies a perspective frustum projection for a window with lower-left corner (left, bottom), upper-right corner (right, top), and the specified nearPlane and farPlane clipping planes.

See also ortho() and perspective().

### (QMatrix4x4, bool invertible) QMatrix4x4.inverted (self)

Returns the inverse of this matrix. Returns the identity if this matrix cannot be inverted; i.e. determinant() is zero. If invertible is not null, then true will be written to that location if the matrix can be inverted; false otherwise.

If the matrix is recognized as the identity or an orthonormal matrix, then this function will quickly invert the matrix using optimized routines.

See also determinant() and normalMatrix().

### bool QMatrix4x4.isIdentity (self)

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

See also setToIdentity().

### QMatrix4x4.lookAt (self, QVector3D, QVector3D, QVector3D)

Multiplies this matrix by another that applies an eye position transformation. The center value indicates the center of the view that the eye is looking at. The up value indicates which direction should be considered up with respect to the eye.

### QPoint QMatrix4x4.map (self, QPoint)

Maps point by multiplying this matrix by point.

See also mapRect().

### QPointF QMatrix4x4.map (self, QPointF)

Maps point by multiplying this matrix by point.

See also mapRect().

### QVector3D QMatrix4x4.map (self, QVector3D)

Maps point by multiplying this matrix by point.

See also mapRect() and mapVector().

### QVector4D QMatrix4x4.map (self, QVector4D)

Maps point by multiplying this matrix by point.

See also mapRect().

### QRect QMatrix4x4.mapRect (self, QRect)

Maps rect by multiplying this matrix by the corners of rect and then forming a new rectangle from the results. The returned rectangle will be an ordinary 2D rectangle with sides parallel to the horizontal and vertical axes.

See also map().

### QRectF QMatrix4x4.mapRect (self, QRectF)

Maps rect by multiplying this matrix by the corners of rect and then forming a new rectangle from the results. The returned rectangle will be an ordinary 2D rectangle with sides parallel to the horizontal and vertical axes.

See also map().

### QVector3D QMatrix4x4.mapVector (self, QVector3D)

Maps vector by multiplying the top 3x3 portion of this matrix by vector. The translation and projection components of this matrix are ignored.

See also map().

### QMatrix3x3 QMatrix4x4.normalMatrix (self)

Returns the normal matrix corresponding to this 4x4 transformation. The normal matrix is the transpose of the inverse of the top-left 3x3 part of this 4x4 matrix. If the 3x3 sub-matrix is not invertible, this function returns the identity.

See also inverted().

### QMatrix4x4.optimize (self)

Optimize the usage of this matrix from its current elements.

Some operations such as translate(), scale(), and rotate() can be performed more efficiently if the matrix being modified is already known to be the identity, a previous translate(), a previous scale(), etc.

Normally the QMatrix4x4 class keeps track of this special type internally as operations are performed. However, if the matrix is modified directly with operator()() or data(), then QMatrix4x4 will lose track of the special type and will revert to the safest but least efficient operations thereafter.

By calling optimize() after directly modifying the matrix, the programmer can force QMatrix4x4 to recover the special type if the elements appear to conform to one of the known optimized types.

See also operator()(), data(), and translate().

### QMatrix4x4.ortho (self, QRect)

Multiplies this matrix by another that applies an orthographic projection for a window with lower-left corner (left, bottom), upper-right corner (right, top), and the specified nearPlane and farPlane clipping planes.

See also frustum() and perspective().

### QMatrix4x4.ortho (self, QRectF)

This is an overloaded function.

Multiplies this matrix by another that applies an orthographic projection for a window with boundaries specified by rect. The near and far clipping planes will be -1 and 1 respectively.

See also frustum() and perspective().

### QMatrix4x4.ortho (self, float, float, float, float, float, float)

This is an overloaded function.

Multiplies this matrix by another that applies an orthographic projection for a window with boundaries specified by rect. The near and far clipping planes will be -1 and 1 respectively.

See also frustum() and perspective().

### QMatrix4x4.perspective (self, float, float, float, float)

Multiplies this matrix by another that applies a perspective projection. The field of view will be angle degrees within a window with a given aspect ratio. The projection will have the specified nearPlane and farPlane clipping planes.

See also ortho() and frustum().

### QMatrix4x4.rotate (self, float, QVector3D)

Multiples this matrix by another that rotates coordinates through angle degrees about vector.

See also scale() and translate().

### QMatrix4x4.rotate (self, float, float, float, float z = 0)

Multiples this matrix by another that rotates coordinates according to a specified quaternion. The quaternion is assumed to have been normalized.

See also scale(), translate(), and QQuaternion.

### QMatrix4x4.rotate (self, QQuaternion)

This is an overloaded function.

Multiplies this matrix by another that rotates coordinates through angle degrees about the vector (x, y, z).

See also scale() and translate().

### QVector4D QMatrix4x4.row (self, int)

Returns the elements of row index as a 4D vector.

See also setRow() and column().

### QMatrix4x4.scale (self, QVector3D)

Multiplies this matrix by another that scales coordinates by the components of vector.

See also translate() and rotate().

### QMatrix4x4.scale (self, float, float)

This is an overloaded function.

Multiplies this matrix by another that scales coordinates by the components x, and y.

See also translate() and rotate().

### QMatrix4x4.scale (self, float, float, float)

This is an overloaded function.

Multiplies this matrix by another that scales coordinates by the components x, y, and z.

See also translate() and rotate().

### QMatrix4x4.scale (self, float)

This is an overloaded function.

Multiplies this matrix by another that scales coordinates by the given factor.

See also translate() and rotate().

### QMatrix4x4.setColumn (self, int, QVector4D)

Sets the elements of column index to the components of value.

See also column() and setRow().

### QMatrix4x4.setRow (self, int, QVector4D)

Sets the elements of row index to the components of value.

See also row() and setColumn().

### QMatrix4x4.setToIdentity (self)

Sets this matrix to the identity.

See also isIdentity().

### QMatrix QMatrix4x4.toAffine (self)

Returns the conventional Qt 2D affine transformation matrix that corresponds to this matrix. It is assumed that this matrix only contains 2D affine transformation elements.

See also toTransform().

### QTransform QMatrix4x4.toTransform (self)

Returns the conventional Qt 2D transformation matrix that corresponds to this matrix.

The returned QTransform is formed by simply dropping the third row and third column of the QMatrix4x4. This is suitable for implementing orthographic projections where the z co-ordinate should be dropped rather than projected.

See also toAffine().

### QTransform QMatrix4x4.toTransform (self, float)

Returns the conventional Qt 2D transformation matrix that corresponds to this matrix.

If distanceToPlane is non-zero, it indicates a projection factor to use to adjust for the z co-ordinate. The value of 1024 corresponds to the projection factor used by QTransform.rotate() for the x and y axes.

If distanceToPlane is zero, then the returned QTransform is formed by simply dropping the third row and third column of the QMatrix4x4. This is suitable for implementing orthographic projections where the z co-ordinate should be dropped rather than projected.

See also toAffine().

### QMatrix4x4.translate (self, QVector3D)

Multiplies this matrix by another that translates coordinates by the components of vector.

See also scale() and rotate().

### QMatrix4x4.translate (self, float, float)

This is an overloaded function.

Multiplies this matrix by another that translates coordinates by the components x, and y.

See also scale() and rotate().

### QMatrix4x4.translate (self, float, float, float)

This is an overloaded function.

Multiplies this matrix by another that translates coordinates by the components x, y, and z.

See also scale() and rotate().

### QMatrix4x4 QMatrix4x4.transposed (self)

Returns this matrix, transposed about its diagonal.

### QMatrix4x4 QMatrix4x4.__add__ (self, QMatrix4x4)

### QMatrix4x4 QMatrix4x4.__div__ (self, float)

### bool QMatrix4x4.__eq__ (self, QMatrix4x4)

### object QMatrix4x4.__getitem__ (self, object)

### QMatrix4x4 QMatrix4x4.__iadd__ (self, QMatrix4x4)

### QMatrix4x4 QMatrix4x4.__idiv__ (self, float)

### QMatrix4x4 QMatrix4x4.__imul__ (self, QMatrix4x4)

### QMatrix4x4 QMatrix4x4.__imul__ (self, float)

### QMatrix4x4 QMatrix4x4.__isub__ (self, QMatrix4x4)

### QMatrix4x4 QMatrix4x4.__mul__ (self, QMatrix4x4)

### QVector3D QMatrix4x4.__mul__ (self, QVector3D)

### QVector4D QMatrix4x4.__mul__ (self, QVector4D)

### QPoint QMatrix4x4.__mul__ (self, QPoint)

### QPointF QMatrix4x4.__mul__ (self, QPointF)

### QMatrix4x4 QMatrix4x4.__mul__ (self, QMatrix4x4)

### QMatrix4x4 QMatrix4x4.__mul__ (self, float)

### bool QMatrix4x4.__ne__ (self, QMatrix4x4)

### QMatrix4x4 QMatrix4x4.__neg__ (self, QMatrix4x4)

### str QMatrix4x4.__repr__ (self)

### QMatrix4x4.__setitem__ (self, object, float)

### QMatrix4x4 QMatrix4x4.__sub__ (self, QMatrix4x4)