4.6 版新增。
def
__add__
(, v2)
def
__div__
(, divisor)
def
__div__
(, divisor)
def
__eq__
(, v2)
def
__iadd__
(vector)
def
__idiv__
(divisor)
def
__idiv__
(vector)
def
__imul__
(factor)
def
__imul__
(vector)
def
__isub__
(vector)
def
__mul__
(, factor)
def
__mul__
(, matrix)
def
__mul__
(, v2)
def
__mul__
(factor)
def
__mul__
(matrix)
def
__mul__
(quaternion)
def
__ne__
(, v2)
def
__reduce__
()
def
__repr__
()
def
__sub__
()
def
__sub__
(, v2)
def
distanceToLine
(point, direction)
def
distanceToPlane
(plane, normal)
def
distanceToPlane
(plane1, plane2, plane3)
def
distanceToPoint
(point)
def
isNull
()
def
length
()
def
lengthSquared
()
def
normalize
()
def
normalized
()
def
operator[]
(i)
def
project
(modelView, projection, viewport)
def
setX
(x)
def
setY
(y)
def
setZ
(z)
def
toPoint
()
def
toPointF
()
def
toTuple
()
def
toVector2D
()
def
toVector4D
()
def
unproject
(modelView, projection, viewport)
def
x
()
def
y
()
def
z
()
def
crossProduct
(v1, v2)
def
dotProduct
(v1, v2)
def
normal
(v1, v2)
def
normal
(v1, v2, v3)
Vectors are one of the main building blocks of 3D representation and drawing. They consist of three coordinates, traditionally called x, y, and z.
QVector3Dclass can also be used to represent vertices in 3D space. We therefore do not need to provide a separate vertex class.
QVector3D
¶
QVector3D(point)
QVector3D(point)
QVector3D(vector)
QVector3D(vector, zpos)
QVector3D(vector)
QVector3D(xpos, ypos, zpos)
- param ypos
float- param point
QPoint- param zpos
float- param vector
- param xpos
float
构造 null 向量,即:采用坐标 (0, 0, 0)。
构造 3D 向量从指定 2D
vector
。z 坐标被设为
zpos
.
另请参阅
构造向量采用坐标 (
xpos
,
ypos
,
zpos
).
PySide2.QtGui.QVector3D.
__reduce__
(
)
¶
PyObject
PySide2.QtGui.QVector3D.
__repr__
(
)
¶
PyObject
PySide2.QtGui.QVector3D.
crossProduct
(
v1
,
v2
)
¶
Returns the cross-product of vectors
v1
and
v2
, which corresponds to the normal vector of a plane defined by
v1
and
v2
.
另请参阅
PySide2.QtGui.QVector3D.
distanceToLine
(
point
,
direction
)
¶
Returns the distance that this vertex is from a line defined by
point
and the unit vector
direction
.
若
direction
is a null vector, then it does not define a line. In that case, the distance from
point
to this vertex is returned.
另请参阅
PySide2.QtGui.QVector3D.
distanceToPlane
(
plane
,
normal
)
¶
Returns the distance from this vertex to a plane defined by the vertex
plane
和
normal
unit vector. The
normal
parameter is assumed to have been normalized to a unit vector.
The return value will be negative if the vertex is below the plane, or zero if it is on the plane.
另请参阅
PySide2.QtGui.QVector3D.
distanceToPlane
(
plane1
,
plane2
,
plane3
)
¶
这是重载函数。
Returns the distance from this vertex to a plane defined by the vertices
plane1
,
plane2
and
plane3
.
The return value will be negative if the vertex is below the plane, or zero if it is on the plane.
The two vectors that define the plane are
plane2
-
plane1
and
plane3
-
plane1
.
另请参阅
PySide2.QtGui.QVector3D.
distanceToPoint
(
point
)
¶
point
–
QVector3D
float
Returns the distance from this vertex to a point defined by the vertex
point
.
PySide2.QtGui.QVector3D.
dotProduct
(
v1
,
v2
)
¶
Returns the dot product of
v1
and
v2
.
PySide2.QtGui.QVector3D.
isNull
(
)
¶
bool
返回
true
若 x、y 和 z 坐标被设为 0.0,否则返回
false
.
PySide2.QtGui.QVector3D.
length
(
)
¶
float
从原点返回向量长度。
PySide2.QtGui.QVector3D.
lengthSquared
(
)
¶
float
Returns the squared length of the vector from the origin. This is equivalent to the dot product of the vector with itself.
另请参阅
PySide2.QtGui.QVector3D.
normal
(
v1
,
v2
)
¶
Returns the normal vector of a plane defined by vectors
v1
and
v2
, normalized to be a unit vector.
使用
crossProduct()
to compute the cross-product of
v1
and
v2
if you do not need the result to be normalized to a unit vector.
PySide2.QtGui.QVector3D.
normal
(
v1
,
v2
,
v3
)
¶
这是重载函数。
Returns the normal vector of a plane defined by vectors
v2
-
v1
and
v3
-
v1
, normalized to be a unit vector.
使用
crossProduct()
to compute the cross-product of
v2
-
v1
and
v3
-
v1
if you do not need the result to be normalized to a unit vector.
PySide2.QtGui.QVector3D.
normalize
(
)
¶
Normalizes the currect vector in place. Nothing happens if this vector is a null vector or the length of the vector is very close to 1.
另请参阅
PySide2.QtGui.QVector3D.
normalized
(
)
¶
Returns the normalized unit vector form of this vector.
If this vector is null, then a null vector is returned. If the length of the vector is very close to 1, then the vector will be returned as-is. Otherwise the normalized form of the vector of length 1 will be returned.
另请参阅
PySide2.QtGui.QVector3D.
__mul__
(
matrix
)
¶
matrix
–
QMatrix4x4
PySide2.QtGui.QVector3D.
__mul__
(
matrix
)
¶
matrix
–
QMatrix4x4
PySide2.QtGui.QVector3D.
__mul__
(
quaternion
)
¶
quaternion
–
QQuaternion
PySide2.QtGui.QVector3D.
__imul__
(
factor
)
¶
factor
–
float
Multiplies this vector’s coordinates by the given
factor
, and returns a reference to this vector.
另请参阅
operator/=()
PySide2.QtGui.QVector3D.
__iadd__
(
vector
)
¶
添加给定
vector
to this vector and returns a reference to this vector.
另请参阅
operator-=()
PySide2.QtGui.QVector3D.
__isub__
(
vector
)
¶
Subtracts the given
vector
from this vector and returns a reference to this vector.
另请参阅
operator+=()
PySide2.QtGui.QVector3D.
__idiv__
(
divisor
)
¶
divisor
–
float
Divides this vector’s coordinates by the given
divisor
, and returns a reference to this vector.
另请参阅
operator*=()
PySide2.QtGui.QVector3D.operator[](i)
i
–
int
float
Returns the component of the vector at index position
i
.
i
must be a valid index position in the vector (i.e., 0 <=
i
< 3).
PySide2.QtGui.QVector3D.
project
(
modelView
,
projection
,
视口
)
¶
modelView
–
QMatrix4x4
projection
–
QMatrix4x4
视口
–
QRect
Returns the window coordinates of this vector initially in object/model coordinates using the model view matrix
modelView
, the projection matrix
projection
and the viewport dimensions
视口
.
When transforming from clip to normalized space, a division by the w component on the vector components takes place. To prevent dividing by 0 if w equals to 0, it is set to 1.
注意
the returned y coordinates are in OpenGL orientation. OpenGL expects the bottom to be 0 whereas for Qt top is 0.
另请参阅
PySide2.QtGui.QVector3D.
setX
(
x
)
¶
x
–
float
Sets the x coordinate of this point to the given
x
坐标。
PySide2.QtGui.QVector3D.
setY
(
y
)
¶
y
–
float
Sets the y coordinate of this point to the given
y
坐标。
PySide2.QtGui.QVector3D.
setZ
(
z
)
¶
z
–
float
Sets the z coordinate of this point to the given
z
坐标。
PySide2.QtGui.QVector3D.
toPoint
(
)
¶
QPoint
返回
QPoint
form of this 3D vector. The z coordinate is dropped.
另请参阅
PySide2.QtGui.QVector3D.
toPointF
(
)
¶
QPointF
返回
QPointF
form of this 3D vector. The z coordinate is dropped.
另请参阅
PySide2.QtGui.QVector3D.
toTuple
(
)
¶
PyObject
PySide2.QtGui.QVector3D.
toVector2D
(
)
¶
Returns the 2D vector form of this 3D vector, dropping the z coordinate.
另请参阅
PySide2.QtGui.QVector3D.
toVector4D
(
)
¶
Returns the 4D form of this 3D vector, with the w coordinate set to zero.
另请参阅
PySide2.QtGui.QVector3D.
unproject
(
modelView
,
projection
,
视口
)
¶
modelView
–
QMatrix4x4
projection
–
QMatrix4x4
视口
–
QRect
Returns the object/model coordinates of this vector initially in window coordinates using the model view matrix
modelView
, the projection matrix
projection
and the viewport dimensions
视口
.
When transforming from clip to normalized space, a division by the w component of the vector components takes place. To prevent dividing by 0 if w equals to 0, it is set to 1.
注意
y coordinates in
视口
should use OpenGL orientation. OpenGL expects the bottom to be 0 whereas for Qt top is 0.
另请参阅
PySide2.QtGui.QVector3D.
x
(
)
¶
float
返回此点的 x 坐标。
PySide2.QtGui.QVector3D.
y
(
)
¶
float
返回此点的 y 坐标。
PySide2.QtGui.QVector3D.
z
(
)
¶
float
返回此点的 z 坐标。