Movatterモバイル変換


[0]ホーム

URL:


We bake cookies in your browser for a better experience. Using this site means that you consent.Read More

Menu

Qt Documentation

QMatrix4x4 Class

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

Header:#include <QMatrix4x4>
Since: Qt 4.6

Public Functions

QMatrix4x4()
QMatrix4x4(const qreal * values)
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)
QMatrix4x4(const QGenericMatrix<N, M, qreal> & matrix)
QMatrix4x4(const QTransform & transform)
QMatrix4x4(const QMatrix & matrix)
QVector4Dcolumn(int index) const
const qreal *constData() const
voidcopyDataTo(qreal * values) const
qreal *data()
const qreal *data() const
qrealdeterminant() const
voidfill(qreal value)
voidflipCoordinates()
voidfrustum(qreal left, qreal right, qreal bottom, qreal top, qreal nearPlane, qreal farPlane)
QMatrix4x4inverted(bool * invertible = 0) const
boolisIdentity() const
voidlookAt(const QVector3D & eye, const QVector3D & center, const QVector3D & up)
QPointmap(const QPoint & point) const
QPointFmap(const QPointF & point) const
QVector3Dmap(const QVector3D & point) const
QVector4Dmap(const QVector4D & point) const
QRectmapRect(const QRect & rect) const
QRectFmapRect(const QRectF & rect) const
QVector3DmapVector(const QVector3D & vector) const
QMatrix3x3normalMatrix() const
voidoptimize()
voidortho(qreal left, qreal right, qreal bottom, qreal top, qreal nearPlane, qreal farPlane)
voidortho(const QRect & rect)
voidortho(const QRectF & rect)
voidperspective(qreal angle, qreal aspect, qreal nearPlane, qreal farPlane)
voidrotate(qreal angle, const QVector3D & vector)
voidrotate(const QQuaternion & quaternion)
voidrotate(qreal angle, qreal x, qreal y, qreal z = 0.0f)
QVector4Drow(int index) const
voidscale(const QVector3D & vector)
voidscale(qreal x, qreal y)
voidscale(qreal x, qreal y, qreal z)
voidscale(qreal factor)
voidsetColumn(int index, const QVector4D & value)
voidsetRow(int index, const QVector4D & value)
voidsetToIdentity()
QMatrixtoAffine() const
QGenericMatrix<N, M, qreal>toGenericMatrix() const
QTransformtoTransform() const
QTransformtoTransform(qreal distanceToPlane) const
voidtranslate(const QVector3D & vector)
voidtranslate(qreal x, qreal y)
voidtranslate(qreal x, qreal y, qreal z)
QMatrix4x4transposed() const
operator QVariant() const
booloperator!=(const QMatrix4x4 & other) const
const qreal &operator()(int row, int column) const
qreal &operator()(int row, int column)
QMatrix4x4 &operator*=(const QMatrix4x4 & other)
QMatrix4x4 &operator*=(qreal factor)
QMatrix4x4 &operator+=(const QMatrix4x4 & other)
QMatrix4x4 &operator-=(const QMatrix4x4 & other)
QMatrix4x4 &operator/=(qreal divisor)
booloperator==(const QMatrix4x4 & other) const

Related Non-Members

boolqFuzzyCompare(const QMatrix4x4 & m1, const QMatrix4x4 & m2)
QMatrix4x4operator*(const QMatrix4x4 & m1, const QMatrix4x4 & m2)
QVector3Doperator*(const QVector3D & vector, const QMatrix4x4 & matrix)
QVector3Doperator*(const QMatrix4x4 & matrix, const QVector3D & vector)
QVector4Doperator*(const QVector4D & vector, const QMatrix4x4 & matrix)
QVector4Doperator*(const QMatrix4x4 & matrix, const QVector4D & vector)
QPointoperator*(const QPoint & point, const QMatrix4x4 & matrix)
QPointFoperator*(const QPointF & point, const QMatrix4x4 & matrix)
QPointoperator*(const QMatrix4x4 & matrix, const QPoint & point)
QPointFoperator*(const QMatrix4x4 & matrix, const QPointF & point)
QMatrix4x4operator*(qreal factor, const QMatrix4x4 & matrix)
QMatrix4x4operator*(const QMatrix4x4 & matrix, qreal factor)
QMatrix4x4operator+(const QMatrix4x4 & m1, const QMatrix4x4 & m2)
QMatrix4x4operator-(const QMatrix4x4 & m1, const QMatrix4x4 & m2)
QMatrix4x4operator-(const QMatrix4x4 & matrix)
QMatrix4x4operator/(const QMatrix4x4 & matrix, qreal divisor)
QDataStream &operator<<(QDataStream & stream, const QMatrix4x4 & matrix)
QDataStream &operator>>(QDataStream & stream, QMatrix4x4 & matrix)

Detailed Description

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

See alsoQVector3D andQGenericMatrix.

Member Function Documentation

QMatrix4x4::QMatrix4x4()

Constructs an identity matrix.

QMatrix4x4::QMatrix4x4(constqreal * values)

Constructs a matrix from the given 16 floating-pointvalues. The contents of the arrayvalues 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 tooptimize() if they wishQMatrix4x4 to optimize further calls totranslate(),scale(), etc.

See alsocopyDataTo() andoptimize().

QMatrix4x4::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)

Constructs a matrix from the 16 elementsm11,m12,m13,m14,m21,m22,m23,m24,m31,m32,m33,m34,m41,m42,m43, andm44. 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 tooptimize() if they wishQMatrix4x4 to optimize further calls totranslate(),scale(), etc.

See alsooptimize().

QMatrix4x4::QMatrix4x4(constQGenericMatrix<N,M,qreal> & matrix)

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

See alsotoGenericMatrix().

QMatrix4x4::QMatrix4x4(constQTransform & transform)

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

Iftransform has a special type (identity, translate, scale, etc), the programmer should follow this constructor with a call tooptimize() if they wishQMatrix4x4 to optimize further calls totranslate(),scale(), etc.

See alsotoTransform() andoptimize().

QMatrix4x4::QMatrix4x4(constQMatrix & matrix)

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

Ifmatrix has a special type (identity, translate, scale, etc), the programmer should follow this constructor with a call tooptimize() if they wishQMatrix4x4 to optimize further calls totranslate(),scale(), etc.

See alsotoAffine() andoptimize().

QVector4D QMatrix4x4::column(int index) const

Returns the elements of columnindex as a 4D vector.

See alsosetColumn() androw().

constqreal * QMatrix4x4::constData() const

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

See alsodata().

void QMatrix4x4::copyDataTo(qreal * values) const

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

qreal * QMatrix4x4::data()

Returns a pointer to the raw data of this matrix.

See alsoconstData() andoptimize().

constqreal * QMatrix4x4::data() const

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

See alsoconstData().

qreal QMatrix4x4::determinant() const

Returns the determinant of this matrix.

void QMatrix4x4::fill(qreal value)

Fills all elements of this matrx withvalue.

void 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 asortho() does.

See alsoortho().

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 specifiednearPlane andfarPlane clipping planes.

See alsoortho() andperspective().

QMatrix4x4 QMatrix4x4::inverted(bool * invertible = 0) const

Returns the inverse of this matrix. Returns the identity if this matrix cannot be inverted; i.e.determinant() is zero. Ifinvertible 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 alsodeterminant() andnormalMatrix().

bool QMatrix4x4::isIdentity() const

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

See alsosetToIdentity().

void QMatrix4x4::lookAt(constQVector3D & eye, constQVector3D & center, constQVector3D & up)

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

QPoint QMatrix4x4::map(constQPoint & point) const

Mapspoint by multiplying this matrix bypoint.

See alsomapRect().

QPointF QMatrix4x4::map(constQPointF & point) const

Mapspoint by multiplying this matrix bypoint.

See alsomapRect().

QVector3D QMatrix4x4::map(constQVector3D & point) const

Mapspoint by multiplying this matrix bypoint.

See alsomapRect() andmapVector().

QVector4D QMatrix4x4::map(constQVector4D & point) const

Mapspoint by multiplying this matrix bypoint.

See alsomapRect().

QRect QMatrix4x4::mapRect(constQRect & rect) const

Mapsrect by multiplying this matrix by the corners ofrect 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 alsomap().

QRectF QMatrix4x4::mapRect(constQRectF & rect) const

Mapsrect by multiplying this matrix by the corners ofrect 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 alsomap().

QVector3D QMatrix4x4::mapVector(constQVector3D & vector) const

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

See alsomap().

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 function returns the identity.

See alsoinverted().

void QMatrix4x4::optimize()

Optimize the usage of this matrix from its current elements.

Some operations such astranslate(),scale(), androtate() can be performed more efficiently if the matrix being modified is already known to be the identity, a previoustranslate(), a previousscale(), etc.

Normally theQMatrix4x4 class keeps track of this special type internally as operations are performed. However, if the matrix is modified directly with operator()() ordata(), thenQMatrix4x4 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 forceQMatrix4x4 to recover the special type if the elements appear to conform to one of the known optimized types.

See alsooperator()(),data(), andtranslate().

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 specifiednearPlane andfarPlane clipping planes.

See alsofrustum() andperspective().

void QMatrix4x4::ortho(constQRect & rect)

This is an overloaded function.

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

See alsofrustum() andperspective().

void QMatrix4x4::ortho(constQRectF & rect)

This is an overloaded function.

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

See alsofrustum() andperspective().

void QMatrix4x4::perspective(qreal angle,qreal aspect,qreal nearPlane,qreal farPlane)

Multiplies this matrix by another that applies a perspective projection. The field of view will beangle degrees within a window with a givenaspect ratio. The projection will have the specifiednearPlane andfarPlane clipping planes.

See alsoortho() andfrustum().

void QMatrix4x4::rotate(qreal angle, constQVector3D & vector)

Multiples this matrix by another that rotates coordinates throughangle degrees aboutvector.

See alsoscale() andtranslate().

void QMatrix4x4::rotate(constQQuaternion & quaternion)

Multiples this matrix by another that rotates coordinates according to a specifiedquaternion. Thequaternion is assumed to have been normalized.

See alsoscale(),translate(), andQQuaternion.

void QMatrix4x4::rotate(qreal angle,qreal x,qreal y,qreal z = 0.0f)

This is an overloaded function.

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

See alsoscale() andtranslate().

QVector4D QMatrix4x4::row(int index) const

Returns the elements of rowindex as a 4D vector.

See alsosetRow() andcolumn().

void QMatrix4x4::scale(constQVector3D & vector)

Multiplies this matrix by another that scales coordinates by the components ofvector.

See alsotranslate() androtate().

void QMatrix4x4::scale(qreal x,qreal y)

This is an overloaded function.

Multiplies this matrix by another that scales coordinates by the componentsx, andy.

See alsotranslate() androtate().

void QMatrix4x4::scale(qreal x,qreal y,qreal z)

This is an overloaded function.

Multiplies this matrix by another that scales coordinates by the componentsx,y, andz.

See alsotranslate() androtate().

void QMatrix4x4::scale(qreal factor)

This is an overloaded function.

Multiplies this matrix by another that scales coordinates by the givenfactor.

See alsotranslate() androtate().

void QMatrix4x4::setColumn(int index, constQVector4D & value)

Sets the elements of columnindex to the components ofvalue.

See alsocolumn() andsetRow().

void QMatrix4x4::setRow(int index, constQVector4D & value)

Sets the elements of rowindex to the components ofvalue.

See alsorow() andsetColumn().

void QMatrix4x4::setToIdentity()

Sets this matrix to the identity.

See alsoisIdentity().

QMatrix QMatrix4x4::toAffine() const

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 alsotoTransform().

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 Qt 2D transformation matrix that corresponds to this matrix.

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

See alsotoAffine().

QTransform QMatrix4x4::toTransform(qreal distanceToPlane) const

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

IfdistanceToPlane 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 byQTransform::rotate() for the x and y axes.

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

See alsotoAffine().

void QMatrix4x4::translate(constQVector3D & vector)

Multiplies this matrix by another that translates coordinates by the components ofvector.

See alsoscale() androtate().

void QMatrix4x4::translate(qreal x,qreal y)

This is an overloaded function.

Multiplies this matrix by another that translates coordinates by the componentsx, andy.

See alsoscale() androtate().

void QMatrix4x4::translate(qreal x,qreal y,qreal z)

This is an overloaded function.

Multiplies this matrix by another that translates coordinates by the componentsx,y, andz.

See alsoscale() androtate().

QMatrix4x4 QMatrix4x4::transposed() const

Returns this matrix, transposed about its diagonal.

QMatrix4x4::operator QVariant() const

Returns the matrix as aQVariant.

bool QMatrix4x4::operator!=(constQMatrix4x4 & other) const

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

constqreal & QMatrix4x4::operator()(int row,int column) const

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

See alsocolumn() androw().

qreal & QMatrix4x4::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.

See alsooptimize(),setColumn(), andsetRow().

QMatrix4x4 & QMatrix4x4::operator*=(constQMatrix4x4 & other)

Multiplies the contents ofother by this matrix.

QMatrix4x4 & QMatrix4x4::operator*=(qreal factor)

This is an overloaded function.

Multiplies all elements of this matrix byfactor.

QMatrix4x4 & QMatrix4x4::operator+=(constQMatrix4x4 & other)

Adds the contents ofother to this matrix.

QMatrix4x4 & QMatrix4x4::operator-=(constQMatrix4x4 & other)

Subtracts the contents ofother from this matrix.

QMatrix4x4 & QMatrix4x4::operator/=(qreal divisor)

This is an overloaded function.

Divides all elements of this matrix bydivisor.

bool QMatrix4x4::operator==(constQMatrix4x4 & other) const

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

Related Non-Members

boolqFuzzyCompare(constQMatrix4x4 & m1, constQMatrix4x4 & m2)

Returns true ifm1 andm2 are equal, allowing for a small fuzziness factor for floating-point comparisons; false otherwise.

QMatrix4x4operator*(constQMatrix4x4 & m1, constQMatrix4x4 & m2)

Returns the product ofm1 andm2.

QVector3Doperator*(constQVector3D & vector, constQMatrix4x4 & matrix)

Returns the result of transformingvector according tomatrix, with the matrix applied post-vector.

QVector3Doperator*(constQMatrix4x4 & matrix, constQVector3D & vector)

Returns the result of transformingvector according tomatrix, with the matrix applied pre-vector.

QVector4Doperator*(constQVector4D & vector, constQMatrix4x4 & matrix)

Returns the result of transformingvector according tomatrix, with the matrix applied post-vector.

QVector4Doperator*(constQMatrix4x4 & matrix, constQVector4D & vector)

Returns the result of transformingvector according tomatrix, with the matrix applied pre-vector.

QPointoperator*(constQPoint & point, constQMatrix4x4 & matrix)

Returns the result of transformingpoint according tomatrix, with the matrix applied post-point.

QPointFoperator*(constQPointF & point, constQMatrix4x4 & matrix)

Returns the result of transformingpoint according tomatrix, with the matrix applied post-point.

QPointoperator*(constQMatrix4x4 & matrix, constQPoint & point)

Returns the result of transformingpoint according tomatrix, with the matrix applied pre-point.

QPointFoperator*(constQMatrix4x4 & matrix, constQPointF & point)

Returns the result of transformingpoint according tomatrix, with the matrix applied pre-point.

QMatrix4x4operator*(qreal factor, constQMatrix4x4 & matrix)

Returns the result of multiplying all elements ofmatrix byfactor.

QMatrix4x4operator*(constQMatrix4x4 & matrix,qreal factor)

Returns the result of multiplying all elements ofmatrix byfactor.

QMatrix4x4operator+(constQMatrix4x4 & m1, constQMatrix4x4 & m2)

Returns the sum ofm1 andm2.

QMatrix4x4operator-(constQMatrix4x4 & m1, constQMatrix4x4 & m2)

Returns the difference ofm1 andm2.

QMatrix4x4operator-(constQMatrix4x4 & matrix)

This is an overloaded function.

Returns the negation ofmatrix.

QMatrix4x4operator/(constQMatrix4x4 & matrix,qreal divisor)

Returns the result of dividing all elements ofmatrix bydivisor.

QDataStream &operator<<(QDataStream & stream, constQMatrix4x4 & matrix)

Writes the givenmatrix to the givenstream and returns a reference to the stream.

See alsoSerializing Qt Data Types.

QDataStream &operator>>(QDataStream & stream,QMatrix4x4 & matrix)

Reads a 4x4 matrix from the givenstream into the givenmatrix and returns a reference to the stream.

See alsoSerializing Qt Data Types.

© 2016 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of theGNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.


[8]ページ先頭

©2009-2025 Movatter.jp