Table Of Contents

Previous topic

QVector2D

Next topic

QQuaternion

QMatrix4x4

Inheritance diagram of QMatrix4x4

Note

This class was introduced in Qt 4.6

Synopsis

Functions

Detailed Description

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

See also

PySide.QtGui.QVector3D QGenericMatrix

class PySide.QtGui.QMatrix4x4
class PySide.QtGui.QMatrix4x4(matrix)
class PySide.QtGui.QMatrix4x4(QMatrix4x4)
class PySide.QtGui.QMatrix4x4(transform)
class PySide.QtGui.QMatrix4x4(values)
class PySide.QtGui.QMatrix4x4(m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34, m41, m42, m43, m44)
Parameters:
  • m42PySide.QtCore.qreal
  • valuesPySide.QtCore.qreal
  • m43PySide.QtCore.qreal
  • m44PySide.QtCore.qreal
  • m21PySide.QtCore.qreal
  • m22PySide.QtCore.qreal
  • m23PySide.QtCore.qreal
  • m24PySide.QtCore.qreal
  • QMatrix4x4PySide.QtGui.QMatrix4x4
  • m31PySide.QtCore.qreal
  • m32PySide.QtCore.qreal
  • m33PySide.QtCore.qreal
  • m34PySide.QtCore.qreal
  • m11PySide.QtCore.qreal
  • m12PySide.QtCore.qreal
  • matrixPySide.QtGui.QMatrix
  • m13PySide.QtCore.qreal
  • m14PySide.QtCore.qreal
  • transformPySide.QtGui.QTransform
  • m41PySide.QtCore.qreal

Constructs an identity matrix.

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

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

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 PySide.QtGui.QMatrix4x4.optimize() if they wish PySide.QtGui.QMatrix4x4 to optimize further calls to PySide.QtGui.QMatrix4x4.translate() , PySide.QtGui.QMatrix4x4.scale() , etc.

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 PySide.QtGui.QMatrix4x4.optimize() if they wish PySide.QtGui.QMatrix4x4 to optimize further calls to PySide.QtGui.QMatrix4x4.translate() , PySide.QtGui.QMatrix4x4.scale() , etc.

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 PySide.QtGui.QMatrix4x4.optimize() if they wish PySide.QtGui.QMatrix4x4 to optimize further calls to PySide.QtGui.QMatrix4x4.translate() , PySide.QtGui.QMatrix4x4.scale() , etc.

PySide.QtGui.QMatrix4x4.__mgetitem__()
Return type:PyObject
PySide.QtGui.QMatrix4x4.__reduce__()
Return type:PyObject
PySide.QtGui.QMatrix4x4.__repr__()
Return type:PyObject
PySide.QtGui.QMatrix4x4.column(index)
Parameters:indexPySide.QtCore.int
Return type:PySide.QtGui.QVector4D

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

PySide.QtGui.QMatrix4x4.copyDataTo()

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

PySide.QtGui.QMatrix4x4.determinant()
Return type:PySide.QtCore.qreal

Returns the determinant of this matrix.

PySide.QtGui.QMatrix4x4.fill(value)
Parameters:valuePySide.QtCore.qreal

Fills all elements of this matrx with value .

PySide.QtGui.QMatrix4x4.flipCoordinates()

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 PySide.QtGui.QMatrix4x4.ortho() does.

PySide.QtGui.QMatrix4x4.frustum(left, right, bottom, top, nearPlane, farPlane)
Parameters:
  • leftPySide.QtCore.qreal
  • rightPySide.QtCore.qreal
  • bottomPySide.QtCore.qreal
  • topPySide.QtCore.qreal
  • nearPlanePySide.QtCore.qreal
  • farPlanePySide.QtCore.qreal

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.

PySide.QtGui.QMatrix4x4.inverted([invertible=0])
Parameters:invertiblePySide.QtCore.bool
Return type:PySide.QtGui.QMatrix4x4

Returns the inverse of this matrix. Returns the identity if this matrix cannot be inverted; i.e. PySide.QtGui.QMatrix4x4.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.

PySide.QtGui.QMatrix4x4.isIdentity()
Return type:PySide.QtCore.bool

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

PySide.QtGui.QMatrix4x4.lookAt(eye, center, up)
Parameters:

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 .

PySide.QtGui.QMatrix4x4.map(point)
Parameters:pointPySide.QtGui.QVector4D
Return type:PySide.QtGui.QVector4D

Maps point by multiplying this matrix by point .

PySide.QtGui.QMatrix4x4.map(point)
Parameters:pointPySide.QtGui.QVector3D
Return type:PySide.QtGui.QVector3D

Maps point by multiplying this matrix by point .

PySide.QtGui.QMatrix4x4.map(point)
Parameters:pointPySide.QtCore.QPoint
Return type:PySide.QtCore.QPoint

Maps point by multiplying this matrix by point .

PySide.QtGui.QMatrix4x4.map(point)
Parameters:pointPySide.QtCore.QPointF
Return type:PySide.QtCore.QPointF

Maps point by multiplying this matrix by point .

PySide.QtGui.QMatrix4x4.mapRect(rect)
Parameters:rectPySide.QtCore.QRectF
Return type:PySide.QtCore.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.

PySide.QtGui.QMatrix4x4.mapRect(rect)
Parameters:rectPySide.QtCore.QRect
Return type:PySide.QtCore.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.

PySide.QtGui.QMatrix4x4.mapVector(vector)
Parameters:vectorPySide.QtGui.QVector3D
Return type:PySide.QtGui.QVector3D

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

PySide.QtGui.QMatrix4x4.normalMatrix()
Return type:PySide.QtGui.QMatrix3x3

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.

PySide.QtGui.QMatrix4x4.__ne__(other)
Parameters:otherPySide.QtGui.QMatrix4x4
Return type:PySide.QtCore.bool

Returns true if this matrix is not identical to other ; false otherwise. This operator uses an exact floating-point comparison.

PySide.QtGui.QMatrix4x4.__mul__(factor)
Parameters:factorPySide.QtCore.qreal
Return type:PySide.QtGui.QMatrix4x4
PySide.QtGui.QMatrix4x4.__mul__(factor)
Parameters:factorPySide.QtCore.qreal
Return type:PySide.QtGui.QMatrix4x4
PySide.QtGui.QMatrix4x4.__mul__(m2)
Parameters:m2PySide.QtGui.QMatrix4x4
Return type:PySide.QtGui.QMatrix4x4
PySide.QtGui.QMatrix4x4.__imul__(factor)
Parameters:factorPySide.QtCore.qreal
Return type:PySide.QtGui.QMatrix4x4

This is an overloaded function.

Multiplies all elements of this matrix by factor .

PySide.QtGui.QMatrix4x4.__imul__(other)
Parameters:otherPySide.QtGui.QMatrix4x4
Return type:PySide.QtGui.QMatrix4x4

Multiplies the contents of other by this matrix.

PySide.QtGui.QMatrix4x4.__add__(m2)
Parameters:m2PySide.QtGui.QMatrix4x4
Return type:PySide.QtGui.QMatrix4x4
PySide.QtGui.QMatrix4x4.__iadd__(other)
Parameters:otherPySide.QtGui.QMatrix4x4
Return type:PySide.QtGui.QMatrix4x4

Adds the contents of other to this matrix.

PySide.QtGui.QMatrix4x4.__sub__()
Return type:PySide.QtGui.QMatrix4x4
PySide.QtGui.QMatrix4x4.__sub__(m2)
Parameters:m2PySide.QtGui.QMatrix4x4
Return type:PySide.QtGui.QMatrix4x4
PySide.QtGui.QMatrix4x4.__isub__(other)
Parameters:otherPySide.QtGui.QMatrix4x4
Return type:PySide.QtGui.QMatrix4x4

Subtracts the contents of other from this matrix.

PySide.QtGui.QMatrix4x4.__div__(divisor)
Parameters:divisorPySide.QtCore.qreal
Return type:PySide.QtGui.QMatrix4x4
PySide.QtGui.QMatrix4x4.__idiv__(divisor)
Parameters:divisorPySide.QtCore.qreal
Return type:PySide.QtGui.QMatrix4x4

This is an overloaded function.

Divides all elements of this matrix by divisor .

PySide.QtGui.QMatrix4x4.__eq__(other)
Parameters:otherPySide.QtGui.QMatrix4x4
Return type:PySide.QtCore.bool

Returns true if this matrix is identical to other ; false otherwise. This operator uses an exact floating-point comparison.

PySide.QtGui.QMatrix4x4.optimize()

Optimize the usage of this matrix from its current elements.

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

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

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

See also

operator()() PySide.QtGui.QMatrix4x4.data() PySide.QtGui.QMatrix4x4.translate()

PySide.QtGui.QMatrix4x4.ortho(rect)
Parameters:rectPySide.QtCore.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.

PySide.QtGui.QMatrix4x4.ortho(left, right, bottom, top, nearPlane, farPlane)
Parameters:
  • leftPySide.QtCore.qreal
  • rightPySide.QtCore.qreal
  • bottomPySide.QtCore.qreal
  • topPySide.QtCore.qreal
  • nearPlanePySide.QtCore.qreal
  • farPlanePySide.QtCore.qreal

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.

PySide.QtGui.QMatrix4x4.ortho(rect)
Parameters:rectPySide.QtCore.QRect

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.

PySide.QtGui.QMatrix4x4.orthonormalInverse()
Return type:PySide.QtGui.QMatrix4x4
PySide.QtGui.QMatrix4x4.perspective(angle, aspect, nearPlane, farPlane)
Parameters:
  • anglePySide.QtCore.qreal
  • aspectPySide.QtCore.qreal
  • nearPlanePySide.QtCore.qreal
  • farPlanePySide.QtCore.qreal

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.

PySide.QtGui.QMatrix4x4.projectedRotate(angle, x, y, z)
Parameters:
  • anglePySide.QtCore.qreal
  • xPySide.QtCore.qreal
  • yPySide.QtCore.qreal
  • zPySide.QtCore.qreal
PySide.QtGui.QMatrix4x4.rotate(angle, x, y[, z=0.0f])
Parameters:
  • anglePySide.QtCore.qreal
  • xPySide.QtCore.qreal
  • yPySide.QtCore.qreal
  • zPySide.QtCore.qreal

This is an overloaded function.

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

PySide.QtGui.QMatrix4x4.rotate(quaternion)
Parameters:quaternionPySide.QtGui.QQuaternion

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

PySide.QtGui.QMatrix4x4.rotate(angle, vector)
Parameters:

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

PySide.QtGui.QMatrix4x4.row(index)
Parameters:indexPySide.QtCore.int
Return type:PySide.QtGui.QVector4D

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

PySide.QtGui.QMatrix4x4.scale(x, y, z)
Parameters:
  • xPySide.QtCore.qreal
  • yPySide.QtCore.qreal
  • zPySide.QtCore.qreal

This is an overloaded function.

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

PySide.QtGui.QMatrix4x4.scale(x, y)
Parameters:
  • xPySide.QtCore.qreal
  • yPySide.QtCore.qreal

This is an overloaded function.

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

PySide.QtGui.QMatrix4x4.scale(factor)
Parameters:factorPySide.QtCore.qreal

This is an overloaded function.

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

PySide.QtGui.QMatrix4x4.scale(vector)
Parameters:vectorPySide.QtGui.QVector3D

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

PySide.QtGui.QMatrix4x4.setColumn(index, value)
Parameters:

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

PySide.QtGui.QMatrix4x4.setRow(index, value)
Parameters:

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

PySide.QtGui.QMatrix4x4.setToIdentity()

Sets this matrix to the identity.

PySide.QtGui.QMatrix4x4.toAffine()
Return type:PySide.QtGui.QMatrix

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.

PySide.QtGui.QMatrix4x4.toTransform(distanceToPlane)
Parameters:distanceToPlanePySide.QtCore.qreal
Return type:PySide.QtGui.QTransform

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 PySide.QtGui.QTransform is formed by simply dropping the third row and third column of the PySide.QtGui.QMatrix4x4 . This is suitable for implementing orthographic projections where the z co-ordinate should be dropped rather than projected.

PySide.QtGui.QMatrix4x4.toTransform()
Return type:PySide.QtGui.QTransform

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

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

PySide.QtGui.QMatrix4x4.translate(x, y, z)
Parameters:
  • xPySide.QtCore.qreal
  • yPySide.QtCore.qreal
  • zPySide.QtCore.qreal

This is an overloaded function.

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

PySide.QtGui.QMatrix4x4.translate(vector)
Parameters:vectorPySide.QtGui.QVector3D

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

PySide.QtGui.QMatrix4x4.translate(x, y)
Parameters:
  • xPySide.QtCore.qreal
  • yPySide.QtCore.qreal

This is an overloaded function.

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

PySide.QtGui.QMatrix4x4.transposed()
Return type:PySide.QtGui.QMatrix4x4

Returns this matrix, transposed about its diagonal.