QMatrix4x4 类表示 3D 空间中的 4x4 变换矩阵。 更多...
头: | #include <QMatrix4x4> |
CMake: |
find_package(Qt6 COMPONENTS Gui REQUIRED)
target_link_libraries(mytarget PRIVATE Qt6::Gui) |
qmake: | QT += gui |
flags | Flags |
QMatrix4x4 (const QTransform & transform ) | |
QMatrix4x4 (const QGenericMatrix<N, M, float> & matrix = N) | |
QMatrix4x4 (float m11 , float m12 , float m13 , float m14 , float m21 , float m22 , float m23 , float m24 , float m31 , float m32 , float m33 , float m34 , float m41 , float m42 , float m43 , float m44 ) | |
QMatrix4x4 (const float * values ) | |
QMatrix4x4 () | |
QVector4D | column (int index ) const |
const float * | constData () const |
void | copyDataTo (float * values ) const |
float * | data () |
const float * | data () const |
double | determinant () const |
void | fill (float value ) |
void | frustum (float left , float right , float bottom , float top , float nearPlane , float farPlane ) |
QMatrix4x4 | inverted (bool * invertible = nullptr) const |
bool | isAffine () const |
bool | isIdentity () const |
void | lookAt (const QVector3D & eye , const QVector3D & center , 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 |
void | optimize () |
void | ortho (float left , float right , float bottom , float top , float nearPlane , float farPlane ) |
void | ortho (const QRect & rect ) |
void | ortho (const QRectF & rect ) |
void | perspective (float verticalAngle , float aspectRatio , float nearPlane , float farPlane ) |
void | rotate (float angle , const QVector3D & vector ) |
void | rotate (float angle , float x , float y , float z = 0.0f) |
void | rotate (const QQuaternion & quaternion ) |
QVector4D | row (int index ) const |
void | scale (const QVector3D & vector ) |
void | scale (float x , float y ) |
void | scale (float x , float y , float z ) |
void | scale (float factor ) |
void | setColumn (int index , const QVector4D & value ) |
void | setRow (int index , const QVector4D & value ) |
void | setToIdentity () |
QGenericMatrix<N, M, float> | toGenericMatrix () const |
QTransform | toTransform () const |
QTransform | toTransform (float distanceToPlane ) const |
void | translate (const QVector3D & vector ) |
void | translate (float x , float y ) |
void | translate (float x , float y , float z ) |
QMatrix4x4 | transposed () const |
void | viewport (float left , float bottom , float width , float height , float nearPlane = 0.0f, float farPlane = 1.0f) |
void | viewport (const QRectF & rect ) |
QVariant | operator QVariant () const |
bool | operator!= (const QMatrix4x4 & other ) const |
const float & | operator() (int row , int column ) const |
float & | operator() (int row , int column ) |
QMatrix4x4 & | operator*= (const QMatrix4x4 & other ) |
QMatrix4x4 & | operator*= (float factor ) |
QMatrix4x4 & | operator+= (const QMatrix4x4 & other ) |
QMatrix4x4 & | operator-= (const QMatrix4x4 & other ) |
QMatrix4x4 & | operator/= (float divisor ) |
bool | operator== (const QMatrix4x4 & other ) const |
QMatrix4x4 | operator* (const QMatrix4x4 & m1 , const QMatrix4x4 & m2 ) |
QVector4D | operator* (const QVector4D & vector , const QMatrix4x4 & matrix ) |
QVector4D | operator* (const QMatrix4x4 & matrix , const QVector4D & vector ) |
QPoint | operator* (const QPoint & point , const QMatrix4x4 & matrix ) |
QPointF | operator* (const QPointF & point , const QMatrix4x4 & matrix ) |
QMatrix4x4 | operator* (float factor , const QMatrix4x4 & matrix ) |
QMatrix4x4 | operator* (const QMatrix4x4 & matrix , float factor ) |
QMatrix4x4 | operator+ (const QMatrix4x4 & m1 , const QMatrix4x4 & m2 ) |
QMatrix4x4 | operator- (const QMatrix4x4 & m1 , const QMatrix4x4 & m2 ) |
QMatrix4x4 | operator- (const QMatrix4x4 & matrix ) |
QMatrix4x4 | operator/ (const QMatrix4x4 & matrix , float divisor ) |
QDataStream & | operator<< (QDataStream & stream , const QMatrix4x4 & matrix ) |
QDataStream & | operator>> (QDataStream & stream , QMatrix4x4 & matrix ) |
The QMatrix4x4 class in general is treated as a row-major matrix, in that the constructors and operator () functions take data in row-major format, as is familiar in C-style usage.
Internally the data is stored as column-major format, so as to be optimal for passing to OpenGL functions, which expect column-major data.
When using these functions be aware that they return data in column-major format:
另请参阅 QVector3D and QGenericMatrix .
Constructs a 4x4 matrix from the conventional Qt 2D transformation matrix transform .
若 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 (),等。
另请参阅 toTransform () 和 optimize ().
Constructs a 4x4 matrix from the left-most 4 columns and top-most 4 rows of matrix 。若 matrix has less than 4 columns or rows, the remaining elements are filled with elements from the identity matrix.
另请参阅 toGenericMatrix ().
Constructs a matrix from the 16 elements m11 , m12 , m13 , m14 , m21 , m22 , m23 , m24 , m31 , m32 , m33 , m34 , m41 , m42 , m43 ,和 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 (),等。
另请参阅 optimize ().
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 (),等。
另请参阅 copyDataTo () 和 optimize ().
构造恒等矩阵。
Returns the elements of column index as a 4D vector.
Returns a constant pointer to the raw data of this matrix. This raw data is stored in column-major format.
另请参阅 data ().
Retrieves the 16 items in this matrix and copies them to values in row-major order.
Returns a pointer to the raw data of this matrix.
另请参阅 constData () 和 optimize ().
Returns a constant pointer to the raw data of this matrix. This raw data is stored in column-major format.
另请参阅 constData ().
Returns the determinant of this matrix.
Fills all elements of this matrx with value .
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.
另请参阅 ortho () 和 perspective ().
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.
另请参阅 determinant () 和 normalMatrix ().
[since 5.5]
bool
QMatrix4x4::
isAffine
() const
返回
true
if this matrix is affine matrix; false otherwise.
An affine matrix is a 4x4 matrix with row 3 equal to (0, 0, 0, 1), e.g. no projective coefficients.
该函数在 Qt 5.5 引入。
另请参阅 isIdentity ().
返回
true
if this matrix is the identity; false otherwise.
另请参阅 setToIdentity ().
Multiplies this matrix by a viewing matrix derived from an eye point. 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 .
注意: up vector must not be parallel to the line of sight from eye to center .
映射 point by multiplying this matrix by point . The matrix is applied pre-point.
另请参阅 mapRect ().
映射 point by post-multiplying this matrix by point . The matrix is applied pre-point.
另请参阅 mapRect ().
映射 point by multiplying this matrix by point . The matrix is applied pre-point.
另请参阅 mapRect () 和 mapVector ().
映射 point by multiplying this matrix by point . The matrix is applied pre-point.
另请参阅 mapRect ().
映射 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.
另请参阅 map ().
映射 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.
另请参阅 map ().
映射 vector by multiplying the top 3x3 portion of this matrix by vector . The translation and projection components of this matrix are ignored. The matrix is applied pre-vector.
另请参阅 map ().
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.
另请参阅 inverted ().
Optimize the usage of this matrix from its current elements.
Some operations such as translate (), scale (),和 rotate () can be performed more efficiently if the matrix being modified is already known to be the identity, a previous translate (), a previous scale (),等。
Normally the QMatrix4x4 class keeps track of this special type internally as operations are performed. However, if the matrix is modified directly with operator ()(int, int) or data (),然后 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.
另请参阅 operator ()(int, int), data (),和 translate ().
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.
另请参阅 frustum () 和 perspective ().
这是重载函数。
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.
另请参阅 frustum () 和 perspective ().
这是重载函数。
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.
另请参阅 frustum () 和 perspective ().
Multiplies this matrix by another that applies a perspective projection. The vertical field of view will be verticalAngle degrees within a window with a given aspectRatio that determines the horizontal field of view. The projection will have the specified nearPlane and farPlane clipping planes which are the distances from the viewer to the corresponding planes.
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 ).
Multiples this matrix by another that rotates coordinates according to a specified quaternion 。 quaternion is assumed to have been normalized.
另请参阅 scale (), translate (),和 QQuaternion .
Returns the elements of row index as a 4D vector.
Multiplies this matrix by another that scales coordinates by the components of vector .
另请参阅 translate () 和 rotate ().
这是重载函数。
Multiplies this matrix by another that scales coordinates by the components x ,和 y .
另请参阅 translate () 和 rotate ().
这是重载函数。
Multiplies this matrix by another that scales coordinates by the components x , y ,和 z .
另请参阅 translate () 和 rotate ().
这是重载函数。
Multiplies this matrix by another that scales coordinates by the given factor .
另请参阅 translate () 和 rotate ().
Sets the elements of column index to the components of value .
Sets the elements of row index to the components of value .
将此矩阵设为恒等。
另请参阅 isIdentity ().
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.
Returns the conventional Qt 2D transformation matrix that corresponds to this matrix.
返回的 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.
Returns the conventional Qt 2D transformation matrix that corresponds to this matrix.
若 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.
若 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.
Multiplies this matrix by another that translates coordinates by the components of vector .
这是重载函数。
Multiplies this matrix by another that translates coordinates by the components x ,和 y .
这是重载函数。
Multiplies this matrix by another that translates coordinates by the components x , y ,和 z .
Returns this matrix, transposed about its diagonal.
Multiplies this matrix by another that performs the scale and bias transformation used by OpenGL to transform from normalized device coordinates (NDC) to viewport (window) coordinates. That is it maps points from the cube ranging over [-1, 1] in each dimension to the viewport with it's near-lower-left corner at ( left , bottom , nearPlane ) and with size ( width , height , farPlane - nearPlane ).
This matches the transform used by the fixed function OpenGL viewport transform controlled by the functions glViewport() and glDepthRange().
这是重载函数。
Sets up viewport transform for viewport bounded by rect and with near and far set to 0 and 1 respectively.
Returns the matrix as a QVariant .
返回
true
if this matrix is not identical to
other
; false otherwise. This operator uses an exact floating-point comparison.
Returns a constant reference to the element at position ( row , column ) in this matrix.
Returns a reference to the element at position ( row , column ) in this matrix so that the element can be assigned to.
另请参阅 optimize (), setColumn (),和 setRow ().
Multiplies the contents of other by this matrix.
这是重载函数。
Multiplies all elements of this matrix by factor .
Adds the contents of other to this matrix.
Subtracts the contents of other from this matrix.
这是重载函数。
Divides all elements of this matrix by divisor .
返回
true
if this matrix is identical to
other
; false otherwise. This operator uses an exact floating-point comparison.
Returns the product of m1 and m2 .
Returns the result of transforming vector according to matrix , with the matrix applied post-vector.
Returns the result of transforming vector according to matrix , with the matrix applied pre-vector.
Returns the result of transforming point according to matrix , with the matrix applied post-point.
Returns the result of transforming point according to matrix , with the matrix applied post-point.
Returns the result of multiplying all elements of matrix by factor .
Returns the result of multiplying all elements of matrix by factor .
Returns the sum of m1 and m2 .
Returns the difference of m1 and m2 .
这是重载函数。
Returns the negation of matrix .
Returns the result of dividing all elements of matrix by divisor .
写入给定 matrix 到给定 stream 并返回流引用。
另请参阅 序列化 Qt 数据类型 .
Reads a 4x4 matrix from the given stream 进给定 matrix 并返回流引用。
另请参阅 序列化 Qt 数据类型 .