CopperSpice API
1.9.2
|
The QMatrix4x4 class represents a 4x4 transformation matrix in 3D space. More...
Public Methods | |
QMatrix4x4 () | |
template<int N, int M> | |
QMatrix4x4 (const QGenericMatrix< N, M, qreal > &matrix) | |
QMatrix4x4 (const QMatrix &matrix) | |
QMatrix4x4 (const qreal *values) | |
QMatrix4x4 (const QTransform &transform) | |
QMatrix4x4 (qreal m11, qreal m12, qreal m13, qreal m14, qreal m21, qreal m22, qreal m23, qreal m24, qreal m31, qreal m32, qreal m33, qreal m34, qreal m41, qreal m42, qreal m43, qreal m44) | |
QVector4D | column (int index) const |
const qreal * | constData () const |
void | copyDataTo (qreal *values) const |
qreal * | data () |
const qreal * | data () const |
qreal | determinant () const |
void | fill (qreal value) |
void | flipCoordinates () |
void | frustum (qreal left, qreal right, qreal bottom, qreal top, qreal nearPlane, qreal farPlane) |
QMatrix4x4 | inverted (bool *invertible=nullptr) const |
bool | isAffine () const |
bool | isIdentity () const |
void | lookAt (const QVector3D &eye, const QVector3D ¢er, const QVector3D &up) |
QPoint | map (const QPoint &point) const |
QPointF | map (const QPointF &point) const |
QVector3D | map (const QVector3D &point) const |
QVector4D | map (const QVector4D &point) const |
QRect | mapRect (const QRect &rect) const |
QRectF | mapRect (const QRectF &rect) const |
QVector3D | mapVector (const QVector3D &vector) const |
QMatrix3x3 | normalMatrix () const |
qreal & | operator () (int row, int column) |
const qreal & | operator () (int row, int column) const |
operator QVariant () const | |
bool | operator!= (const QMatrix4x4 &other) const |
QMatrix4x4 & | operator*= (QMatrix4x4 other) |
QMatrix4x4 & | operator*= (qreal factor) |
QMatrix4x4 & | operator+= (const QMatrix4x4 &other) |
QMatrix4x4 & | operator-= (const QMatrix4x4 &other) |
QMatrix4x4 & | operator/= (qreal divisor) |
bool | operator== (const QMatrix4x4 &other) const |
void | optimize () |
void | ortho (const QRect &rect) |
void | ortho (const QRectF &rect) |
void | ortho (qreal left, qreal right, qreal bottom, qreal top, qreal nearPlane, qreal farPlane) |
void | perspective (qreal angle, qreal aspect, qreal nearPlane, qreal farPlane) |
void | rotate (const QQuaternion &quaternion) |
void | rotate (qreal angle, const QVector3D &vector) |
void | rotate (qreal angle, qreal x, qreal y, qreal z=0.0f) |
QVector4D | row (int index) const |
void | scale (const QVector3D &vector) |
void | scale (qreal factor) |
void | scale (qreal x, qreal y) |
void | scale (qreal x, qreal y, qreal z) |
void | setColumn (int index, const QVector4D &value) |
void | setRow (int index, const QVector4D &value) |
void | setToIdentity () |
QMatrix | toAffine () const |
template<int N, int M> | |
QGenericMatrix< N, M, qreal > | toGenericMatrix () const |
QTransform | toTransform () const |
QTransform | toTransform (qreal distanceToPlane) const |
void | translate (const QVector3D &vector) |
void | translate (qreal x, qreal y) |
void | translate (qreal x, qreal y, qreal z) |
QMatrix4x4 | transposed () const |
void | viewport (const QRectF &rect) |
void | viewport (qreal left, qreal bottom, qreal width, qreal height, qreal nearPlane=0.0, qreal farPlane=1.0) |
Friends | |
class | QGraphicsRotation |
The QMatrix4x4 class represents a 4x4 transformation matrix in 3D space.
|
inline |
Constructs an identity matrix.
|
explicit |
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.
|
inline |
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.
|
inlineexplicit |
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.
QMatrix4x4::QMatrix4x4 | ( | const QTransform & | transform | ) |
Constructs a 4x4 matrix from the conventional 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.
QMatrix4x4::QMatrix4x4 | ( | const QMatrix & | matrix | ) |
Constructs a 4x4 matrix from a conventional 2D affine transformation matrix.
If 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.
|
inline |
Returns the elements of column index as a 4D vector.
|
inline |
Returns a constant pointer to the raw data of this matrix.
void QMatrix4x4::copyDataTo | ( | qreal * | values | ) | const |
Retrieves the 16 items in this matrix and copies them to values in row-major order.
|
inline |
Returns a pointer to the raw data of this matrix.
|
inline |
Returns a constant pointer to the raw data of this matrix.
qreal QMatrix4x4::determinant | ( | ) | const |
Returns the determinant of this matrix.
|
inline |
Fills all elements of this matrix with value.
void QMatrix4x4::flipCoordinates | ( | ) |
void QMatrix4x4::frustum | ( | qreal | left, |
qreal | right, | ||
qreal | bottom, | ||
qreal | top, | ||
qreal | nearPlane, | ||
qreal | farPlane | ||
) |
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.
QMatrix4x4 QMatrix4x4::inverted | ( | bool * | invertible = nullptr | ) | const |
Returns the inverse of this matrix. Returns the identity if this matrix can not 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.
|
inline |
Returns true if this matrix is an affine matrix, return false otherwise. An affine matrix is a 4x4 matrix with row 3 equal to (0, 0, 0, 1), e.g. no projective coefficients.
|
inline |
Returns true if this matrix is the identity; false otherwise.
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.
Maps point by multiplying this matrix by point.
Maps point by multiplying this matrix by point.
Maps point by multiplying this matrix by point.
Maps point by multiplying this matrix by point.
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.
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.
Maps vector by multiplying the top 3x3 portion of this matrix by vector. The translation and projection components of this matrix are ignored.
QMatrix3x3 QMatrix4x4::normalMatrix | ( | ) | const |
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 method returns the identity.
|
inline |
Returns a reference to the element at position (row, column) in this matrix so that the element can be assigned to.
|
inline |
|
inline |
Returns true if this matrix is not identical to other, otherwise returns false. This operator uses an exact floating point comparison.
|
inline |
Multiplies the contents of other by this matrix.
|
inline |
Multiplies all elements of this matrix by factor.
|
inline |
Adds the contents of other to this matrix.
|
inline |
Subtracts the contents of other from this matrix.
QMatrix4x4 & QMatrix4x4::operator/= | ( | qreal | divisor | ) |
Divides all elements of this matrix by divisor.
|
inline |
Returns true if this matrix is identical to other; false otherwise. This operator uses an exact floating-point comparison.
void QMatrix4x4::optimize | ( | ) |
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 this method after directly modifying the matrix you can force QMatrix4x4 to recover the special type if the elements appear to conform to one of the known optimized types.
void QMatrix4x4::ortho | ( | const QRect & | rect | ) |
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.
void QMatrix4x4::ortho | ( | const QRectF & | rect | ) |
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.
void QMatrix4x4::ortho | ( | qreal | left, |
qreal | right, | ||
qreal | bottom, | ||
qreal | top, | ||
qreal | nearPlane, | ||
qreal | farPlane | ||
) |
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.
void QMatrix4x4::rotate | ( | const QQuaternion & | quaternion | ) |
Multiples this matrix by another that rotates coordinates according to a specified quaternion. The quaternion is assumed to have been normalized.
Multiples this matrix by another that rotates coordinates through angle degrees about vector.
Multiplies this matrix by another that rotates coordinates through angle degrees about the vector (x, y, z).
|
inline |
void QMatrix4x4::scale | ( | const QVector3D & | vector | ) |
Multiplies this matrix by another that scales coordinates by the components of vector.
void QMatrix4x4::scale | ( | qreal | factor | ) |
Multiplies this matrix by another that scales coordinates by the given factor.
Multiplies this matrix by another that scales coordinates by the components x, and y.
Multiplies this matrix by another that scales coordinates by the components x, y, and z.
|
inline |
|
inline |
Sets the elements of row index to the components of value.
|
inline |
Sets this matrix to the identity.
QMatrix QMatrix4x4::toAffine | ( | ) | const |
Returns the conventional 2D affine transformation matrix that corresponds to this matrix. It is assumed that this matrix only contains 2D affine transformation elements.
QGenericMatrix< N, M, qreal > QMatrix4x4::toGenericMatrix | ( | ) | const |
Constructs a NxM generic matrix from the left-most N columns and top-most M rows of this 4x4 matrix. If N or M is greater than 4, then the remaining elements are filled with elements from the identity matrix.
QTransform QMatrix4x4::toTransform | ( | ) | const |
Returns the conventional 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 coordinate should be dropped rather than projected.
QTransform QMatrix4x4::toTransform | ( | qreal | distanceToPlane | ) | const |
Returns the conventional 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 coordinate. 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 coordinate should be dropped rather than projected.
void QMatrix4x4::translate | ( | const QVector3D & | vector | ) |
QMatrix4x4 QMatrix4x4::transposed | ( | ) | const |
Returns this matrix, transposed about its diagonal.
|
inline |
Sets up viewport transform for viewport bounded by rect and with near and far set to 0 and 1 respectively.
void QMatrix4x4::viewport | ( | qreal | left, |
qreal | bottom, | ||
qreal | width, | ||
qreal | height, | ||
qreal | nearPlane = 0.0 , |
||
qreal | farPlane = 1.0 |
||
) |
Multiplies this matrix by a viewport matrix. The result can be used to transform from normalized device coordinates (NDC) to viewport (window) coordinates.
Points are mapped from the cube ranging over [-1, 1] in each dimension to the viewport with the near-lower-left corner at (left, bottom, nearPlane) and with size (width, height, (farPlane - nearPlane)).