QMatrix4x4class represents a 4x4 transformation matrix in 3D space. 更多 …
4.6 版新增。
def
__add__
(, m2)
def
__div__
(, divisor)
def
__dummy
(arg__1)
def
__eq__
(other)
def
__iadd__
(other)
def
__idiv__
(divisor)
def
__imul__
(factor)
def
__imul__
(other)
def
__isub__
(other)
def
__mgetitem__
()
def
__mul__
(, factor)
def
__mul__
(, m2)
def
__mul__
(factor)
def
__ne__
(other)
def
__reduce__
()
def
__repr__
()
def
__sub__
()
def
__sub__
(, m2)
def
column
(index)
def
copyDataTo
()
def
determinant
()
def
fill
(value)
def
flipCoordinates
()
def
frustum
(left, right, bottom, top, nearPlane, farPlane)
def
inverted
()
def
isAffine
()
def
isIdentity
()
def
lookAt
(eye, center, up)
def
map
(point)
def
map
(point)
def
map
(point)
def
map
(point)
def
mapRect
(rect)
def
mapRect
(rect)
def
mapVector
(vector)
def
normalMatrix
()
def
optimize
()
def
ortho
(left, right, bottom, top, nearPlane, farPlane)
def
ortho
(rect)
def
ortho
(rect)
def
perspective
(verticalAngle, aspectRatio, nearPlane, farPlane)
def
rotate
(angle, vector)
def
rotate
(angle, x, y[, z=0.0f])
def
rotate
(quaternion)
def
row
(index)
def
scale
(factor)
def
scale
(vector)
def
scale
(x, y)
def
scale
(x, y, z)
def
setColumn
(index, value)
def
setRow
(index, value)
def
setToIdentity
()
def
toAffine
()
def
toTransform
()
def
toTransform
(distanceToPlane)
def
translate
(vector)
def
translate
(x, y)
def
translate
(x, y, z)
def
transposed
()
def
视口
(left, bottom, width, height[, nearPlane=0.0f[, farPlane=1.0f]])
def
视口
(rect)
QMatrix4x4class in general is treated as a row-major matrix, in that the constructors andoperator()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:
data()
constData()另请参阅
QVector3DQGenericMatrix
QMatrix4x4
¶
QMatrix4x4(matrix)
QMatrix4x4(transform)
QMatrix4x4(values)
QMatrix4x4(m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34, m41, m42, m43, m44)
- param m43
float- param m44
float- param m31
float- param m32
float- param m33
float- param m34
float- param transform
- param m21
float- param m22
float- param m23
float- param m24
float- param m11
float- param m12
float- param m13
float- param m14
float- param values
float- param matrix
- param m41
float- param m42
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()
,等。
另请参阅
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()
,等。
另请参阅
PySide2.QtGui.QMatrix4x4.
enum_383
¶
PySide2.QtGui.QMatrix4x4.
__dummy
(
arg__1
)
¶
arg__1 –
PySide2.QtGui.QMatrix4x4.
__mgetitem__
(
)
¶
PyObject
PySide2.QtGui.QMatrix4x4.
__reduce__
(
)
¶
PyObject
PySide2.QtGui.QMatrix4x4.
__repr__
(
)
¶
PyObject
PySide2.QtGui.QMatrix4x4.
column
(
index
)
¶
index
–
int
Returns the elements of column
index
as a 4D vector.
另请参阅
PySide2.QtGui.QMatrix4x4.
copyDataTo
(
)
¶
Retrieves the 16 items in this matrix and copies them to
values
in row-major order.
PySide2.QtGui.QMatrix4x4.
determinant
(
)
¶
double
Returns the determinant of this matrix.
PySide2.QtGui.QMatrix4x4.
fill
(
value
)
¶
value
–
float
Fills all elements of this matrx with
value
.
PySide2.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
ortho()
does.
另请参阅
PySide2.QtGui.QMatrix4x4.
frustum
(
left
,
right
,
bottom
,
top
,
nearPlane
,
farPlane
)
¶
left
–
float
right
–
float
bottom
–
float
top
–
float
nearPlane
–
float
farPlane
–
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.
另请参阅
PySide2.QtGui.QMatrix4x4.
inverted
(
)
¶
PyTuple
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.
PySide2.QtGui.QMatrix4x4.
isAffine
(
)
¶
bool
返回
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.
另请参阅
PySide2.QtGui.QMatrix4x4.
isIdentity
(
)
¶
bool
返回
true
if this matrix is the identity; false otherwise.
另请参阅
PySide2.QtGui.QMatrix4x4.
lookAt
(
eye
,
center
,
up
)
¶
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
.
PySide2.QtGui.QMatrix4x4.
map
(
point
)
¶
point
–
QPoint
QPoint
PySide2.QtGui.QMatrix4x4.
map
(
point
)
¶
point
–
QPointF
QPointF
PySide2.QtGui.QMatrix4x4.
mapRect
(
rect
)
¶
rect
–
QRect
QRect
PySide2.QtGui.QMatrix4x4.
mapRect
(
rect
)
¶
rect
–
QRectF
QRectF
PySide2.QtGui.QMatrix4x4.
mapVector
(
vector
)
¶
Maps
vector
by multiplying the top 3x3 portion of this matrix by
vector
. The translation and projection components of this matrix are ignored.
另请参阅
PySide2.QtGui.QMatrix4x4.
normalMatrix
(
)
¶
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.
另请参阅
PySide2.QtGui.QMatrix4x4.
__ne__
(
other
)
¶
other
–
QMatrix4x4
bool
返回
true
if this matrix is not identical to
other
; false otherwise. This operator uses an exact floating-point comparison.
PySide2.QtGui.QMatrix4x4.
__mul__
(
factor
)
¶
factor
–
float
PySide2.QtGui.QMatrix4x4.
__mul__
(
m2
)
¶
m2
–
QMatrix4x4
PySide2.QtGui.QMatrix4x4.
__mul__
(
factor
)
¶
factor
–
float
PySide2.QtGui.QMatrix4x4.
__imul__
(
other
)
¶
other
–
QMatrix4x4
PySide2.QtGui.QMatrix4x4.
__imul__
(
factor
)
¶
factor
–
float
这是重载函数。
Multiplies all elements of this matrix by
factor
.
PySide2.QtGui.QMatrix4x4.
__add__
(
m2
)
¶
m2
–
QMatrix4x4
PySide2.QtGui.QMatrix4x4.
__iadd__
(
other
)
¶
other
–
QMatrix4x4
Adds the contents of
other
to this matrix.
PySide2.QtGui.QMatrix4x4.
__sub__
(
)
¶
PySide2.QtGui.QMatrix4x4.
__sub__
(
m2
)
¶
m2
–
QMatrix4x4
这是重载函数。
Returns the negation of
matrix
.
PySide2.QtGui.QMatrix4x4.
__isub__
(
other
)
¶
other
–
QMatrix4x4
Subtracts the contents of
other
from this matrix.
PySide2.QtGui.QMatrix4x4.
__div__
(
divisor
)
¶
divisor
–
float
PySide2.QtGui.QMatrix4x4.
__idiv__
(
divisor
)
¶
divisor
–
float
这是重载函数。
Divides all elements of this matrix by
divisor
.
PySide2.QtGui.QMatrix4x4.
__eq__
(
other
)
¶
other
–
QMatrix4x4
bool
返回
true
if this matrix is identical to
other
; false otherwise. This operator uses an exact floating-point comparison.
PySide2.QtGui.QMatrix4x4.
optimize
(
)
¶
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()
}{
operator()
()} or
data()
,那么
QMatrix4x4
will lose track of the special type and will revert to the safest but least efficient operations thereafter.
By calling 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()()
data()
translate()
PySide2.QtGui.QMatrix4x4.
ortho
(
rect
)
¶
rect
–
QRect
PySide2.QtGui.QMatrix4x4.
ortho
(
rect
)
¶
rect
–
QRectF
PySide2.QtGui.QMatrix4x4.
ortho
(
left
,
right
,
bottom
,
top
,
nearPlane
,
farPlane
)
¶
left
–
float
right
–
float
bottom
–
float
top
–
float
nearPlane
–
float
farPlane
–
float
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.
另请参阅
PySide2.QtGui.QMatrix4x4.
perspective
(
verticalAngle
,
aspectRatio
,
nearPlane
,
farPlane
)
¶
verticalAngle
–
float
aspectRatio
–
float
nearPlane
–
float
farPlane
–
float
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.
PySide2.QtGui.QMatrix4x4.
rotate
(
quaternion
)
¶
quaternion
–
QQuaternion
Multiples this matrix by another that rotates coordinates according to a specified
quaternion
。
quaternion
is assumed to have been normalized.
PySide2.QtGui.QMatrix4x4.
rotate
(
angle
,
x
,
y
[
,
z=0.0f
]
)
¶
angle
–
float
x
–
float
y
–
float
z
–
float
这是重载函数。
Multiplies this matrix by another that rotates coordinates through
angle
degrees about the vector (
x
,
y
,
z
).
另请参阅
PySide2.QtGui.QMatrix4x4.
rotate
(
angle
,
vector
)
¶
angle
–
float
vector
–
QVector3D
Multiples this matrix by another that rotates coordinates through
angle
degrees about
vector
.
另请参阅
PySide2.QtGui.QMatrix4x4.
row
(
index
)
¶
index
–
int
Returns the elements of row
index
as a 4D vector.
PySide2.QtGui.QMatrix4x4.
scale
(
factor
)
¶
factor
–
float
这是重载函数。
Multiplies this matrix by another that scales coordinates by the given
factor
.
另请参阅
PySide2.QtGui.QMatrix4x4.
scale
(
x
,
y
)
¶
x
–
float
y
–
float
这是重载函数。
Multiplies this matrix by another that scales coordinates by the components
x
,和
y
.
另请参阅
PySide2.QtGui.QMatrix4x4.
scale
(
x
,
y
,
z
)
¶
x
–
float
y
–
float
z
–
float
这是重载函数。
Multiplies this matrix by another that scales coordinates by the components
x
,
y
,和
z
.
另请参阅
PySide2.QtGui.QMatrix4x4.
setColumn
(
index
,
value
)
¶
index
–
int
value
–
QVector4D
Sets the elements of column
index
to the components of
value
.
PySide2.QtGui.QMatrix4x4.
setRow
(
index
,
value
)
¶
index
–
int
value
–
QVector4D
Sets the elements of row
index
to the components of
value
.
另请参阅
PySide2.QtGui.QMatrix4x4.
setToIdentity
(
)
¶
将此矩阵设为恒等。
另请参阅
PySide2.QtGui.QMatrix4x4.
toAffine
(
)
¶
注意
此函数被弃用。
使用
toTransform()
代替。
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.
另请参阅
PySide2.QtGui.QMatrix4x4.
toTransform
(
)
¶
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 co-ordinate should be dropped rather than projected.
另请参阅
PySide2.QtGui.QMatrix4x4.
toTransform
(
distanceToPlane
)
¶
distanceToPlane
–
float
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 co-ordinate. The value of 1024 corresponds to the projection factor used by
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 co-ordinate should be dropped rather than projected.
另请参阅
PySide2.QtGui.QMatrix4x4.
translate
(
vector
)
¶
vector
–
QVector3D
Multiplies this matrix by another that translates coordinates by the components of
vector
.
PySide2.QtGui.QMatrix4x4.
translate
(
x
,
y
)
¶
x
–
float
y
–
float
这是重载函数。
Multiplies this matrix by another that translates coordinates by the components
x
,和
y
.
PySide2.QtGui.QMatrix4x4.
translate
(
x
,
y
,
z
)
¶
x
–
float
y
–
float
z
–
float
这是重载函数。
Multiplies this matrix by another that translates coordinates by the components
x
,
y
,和
z
.
PySide2.QtGui.QMatrix4x4.
transposed
(
)
¶
Returns this matrix, transposed about its diagonal.
PySide2.QtGui.QMatrix4x4.
视口
(
rect
)
¶
rect
–
QRectF
这是重载函数。
Sets up viewport transform for viewport bounded by
rect
and with near and far set to 0 and 1 respectively.
PySide2.QtGui.QMatrix4x4.
视口
(
left
,
bottom
,
width
,
height
[
,
nearPlane=0.0f
[
,
farPlane=1.0f
]
]
)
¶
left
–
float
bottom
–
float
width
–
float
height
–
float
nearPlane
–
float
farPlane
–
float
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().