QVector3D¶
The QVector3D
class represents a vector or vertex in 3D space. More…
New in version 4.6.
Synopsis¶
Functions¶
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__
(factor)def
__mul__
(matrix)def
__mul__
(matrix)def
__mul__
(quaternion)def
__mul__
(v2)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
()
Static functions¶
def
crossProduct
(v1, v2)def
dotProduct
(v1, v2)def
normal
(v1, v2)def
normal
(v1, v2, v3)
Detailed Description¶
Vectors are one of the main building blocks of 3D representation and drawing. They consist of three finite floating-point coordinates, traditionally called x, y, and z.
The QVector3D
class can also be used to represent vertices in 3D space. We therefore do not need to provide a separate vertex class.
See also
- class PySide6.QtGui.QVector3D¶
PySide6.QtGui.QVector3D(point)
PySide6.QtGui.QVector3D(point)
PySide6.QtGui.QVector3D(vector)
PySide6.QtGui.QVector3D(vector, zpos)
PySide6.QtGui.QVector3D(vector)
PySide6.QtGui.QVector3D(xpos, ypos, zpos)
- Parameters
point –
PySide6.QtCore.QPoint
xpos – float
vector –
PySide6.QtGui.QVector2D
zpos – float
ypos – float
Constructs a null vector, i.e. with coordinates (0, 0, 0).
Constructs a vector with x and y coordinates from a 2D point
, and a z coordinate of 0.
Constructs a vector with x and y coordinates from a 2D point
, and a z coordinate of 0.
Constructs a 3D vector from the specified 2D vector
. The z coordinate is set to zero.
See also
Constructs a 3D vector from the specified 2D vector
. The z coordinate is set to zpos
, which must be finite.
See also
Constructs a 3D vector from the specified 4D vector
. The w coordinate is dropped.
See also
Constructs a vector with coordinates (xpos
, ypos
, zpos
). All parameters must be finite.
- PySide6.QtGui.QVector3D.__reduce__()¶
- Return type
object
- PySide6.QtGui.QVector3D.__repr__()¶
- Return type
object
- static PySide6.QtGui.QVector3D.crossProduct(v1, v2)¶
- Parameters
- Return type
Returns the cross-product of vectors v1
and v2
, which is normal to the plane spanned by v1
and v2
. It will be zero if the two vectors are parallel.
See also
- PySide6.QtGui.QVector3D.distanceToLine(point, direction)¶
- Parameters
point –
PySide6.QtGui.QVector3D
direction –
PySide6.QtGui.QVector3D
- Return type
float
Returns the distance that this vertex is from a line defined by point
and the unit vector direction
.
If direction
is a null vector, then it does not define a line. In that case, the distance from point
to this vertex is returned.
See also
- PySide6.QtGui.QVector3D.distanceToPlane(plane, normal)¶
- Parameters
plane –
PySide6.QtGui.QVector3D
normal –
PySide6.QtGui.QVector3D
- Return type
float
Returns the distance from this vertex to a plane defined by the vertex plane
and a 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.
See also
- PySide6.QtGui.QVector3D.distanceToPlane(plane1, plane2, plane3)
- Parameters
plane1 –
PySide6.QtGui.QVector3D
plane2 –
PySide6.QtGui.QVector3D
plane3 –
PySide6.QtGui.QVector3D
- Return type
float
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
.
See also
- PySide6.QtGui.QVector3D.distanceToPoint(point)¶
- Parameters
point –
PySide6.QtGui.QVector3D
- Return type
float
Returns the distance from this vertex to a point defined by the vertex point
.
See also
- static PySide6.QtGui.QVector3D.dotProduct(v1, v2)¶
- Parameters
- Return type
float
Returns the dot product of v1
and v2
.
- PySide6.QtGui.QVector3D.isNull()¶
- Return type
bool
Returns true
if the x, y, and z coordinates are set to 0.0, otherwise returns false
.
- PySide6.QtGui.QVector3D.length()¶
- Return type
float
Returns the length of the vector from the origin.
See also
- PySide6.QtGui.QVector3D.lengthSquared()¶
- Return type
float
Returns the squared length of the vector from the origin. This is equivalent to the dot product of the vector with itself.
See also
- static PySide6.QtGui.QVector3D.normal(v1, v2)¶
- Parameters
- Return type
Returns the unit normal vector of a plane spanned by vectors v1
and v2
, which must not be parallel to one another.
Use crossProduct()
to compute the cross-product of v1
and v2
if you do not need the result to be normalized to a unit vector.
See also
- static PySide6.QtGui.QVector3D.normal(v1, v2, v3)
- Parameters
- Return type
Returns the unit normal vector of a plane spanned by vectors v2
- v1
and v3
- v1
, which must not be parallel to one another.
Use 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.
See also
- PySide6.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.
See also
- PySide6.QtGui.QVector3D.normalized()¶
- Return type
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.
See also
- PySide6.QtGui.QVector3D.__ne__(v2)¶
- Parameters
- Return type
bool
- PySide6.QtGui.QVector3D.__mul__(factor)¶
- Parameters
factor – float
- Return type
- PySide6.QtGui.QVector3D.__mul__(factor)
- Parameters
factor – float
- Return type
- PySide6.QtGui.QVector3D.__mul__(quaternion)
- Parameters
quaternion –
PySide6.QtGui.QQuaternion
- Return type
- PySide6.QtGui.QVector3D.__mul__(matrix)
- Parameters
matrix –
PySide6.QtGui.QMatrix4x4
- Return type
Note
This function is deprecated.
- PySide6.QtGui.QVector3D.__mul__(v2)
- Parameters
- Return type
- PySide6.QtGui.QVector3D.__mul__(matrix)
- Parameters
matrix –
PySide6.QtGui.QMatrix4x4
- Return type
Note
This function is deprecated.
- PySide6.QtGui.QVector3D.__imul__(vector)¶
- Parameters
vector –
PySide6.QtGui.QVector3D
- Return type
This is an overloaded function.
Multiplies each component of this vector by the corresponding component in vector
and returns a reference to this vector.
Note: this is not the same as the crossProduct()
of this vector and vector
. (Its components add up to the dot product of this vector and vector
.)
See also
crossProduct()
operator/=()
operator*()
- PySide6.QtGui.QVector3D.__imul__(factor)
- Parameters
factor – float
- Return type
Multiplies this vector’s coordinates by the given finite factor
and returns a reference to this vector.
See also
operator/=()
operator*()
- PySide6.QtGui.QVector3D.__add__(v2)¶
- Parameters
- Return type
- PySide6.QtGui.QVector3D.__iadd__(vector)¶
- Parameters
vector –
PySide6.QtGui.QVector3D
- Return type
Adds the given vector
to this vector and returns a reference to this vector.
See also
operator-=()
- PySide6.QtGui.QVector3D.__sub__()¶
- Return type
- PySide6.QtGui.QVector3D.__sub__(v2)
- Parameters
- Return type
This is an overloaded function.
Returns a QVector3D
object that is formed by changing the sign of each component of the given vector
.
Equivalent to QVector3D(0,0,0) - vector
.
- PySide6.QtGui.QVector3D.__isub__(vector)¶
- Parameters
vector –
PySide6.QtGui.QVector3D
- Return type
Subtracts the given vector
from this vector and returns a reference to this vector.
See also
operator+=()
- PySide6.QtGui.QVector3D.__div__(divisor)¶
- Parameters
divisor –
PySide6.QtGui.QVector3D
- Return type
- PySide6.QtGui.QVector3D.__div__(divisor)
- Parameters
divisor – float
- Return type
- PySide6.QtGui.QVector3D.__idiv__(vector)¶
- Parameters
vector –
PySide6.QtGui.QVector3D
- Return type
Divides each component of this vector by the corresponding component in vector
and returns a reference to this vector.
The vector
must have no component that is either zero or NaN.
See also
operator*=()
operator/()
- PySide6.QtGui.QVector3D.__idiv__(divisor)
- Parameters
divisor – float
- Return type
Divides this vector’s coordinates by the given divisor
, and returns a reference to this vector. The divisor
must not be either zero or NaN.
See also
operator*=()
operator/()
- PySide6.QtGui.QVector3D.__eq__(v2)¶
- Parameters
- Return type
bool
- PySide6.QtGui.QVector3D.operator[](i)
- Parameters
i – int
- Return type
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).
- PySide6.QtGui.QVector3D.project(modelView, projection, viewport)¶
- Parameters
modelView –
PySide6.QtGui.QMatrix4x4
projection –
PySide6.QtGui.QMatrix4x4
viewport –
PySide6.QtCore.QRect
- Return type
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 viewport
.
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.
Note
the returned y coordinates are in OpenGL orientation. OpenGL expects the bottom to be 0 whereas for Qt top is 0.
See also
- PySide6.QtGui.QVector3D.setX(x)¶
- Parameters
x – float
Sets the x coordinate of this point to the given finite x
coordinate.
- PySide6.QtGui.QVector3D.setY(y)¶
- Parameters
y – float
Sets the y coordinate of this point to the given finite y
coordinate.
- PySide6.QtGui.QVector3D.setZ(z)¶
- Parameters
z – float
Sets the z coordinate of this point to the given finite z
coordinate.
- PySide6.QtGui.QVector3D.toPoint()¶
- Return type
Returns the QPoint
form of this 3D vector. The z coordinate is dropped. The x and y coordinates are rounded to nearest integers.
See also
- PySide6.QtGui.QVector3D.toPointF()¶
- Return type
Returns the QPointF
form of this 3D vector. The z coordinate is dropped.
See also
- PySide6.QtGui.QVector3D.toTuple()¶
- Return type
object
- PySide6.QtGui.QVector3D.toVector2D()¶
- Return type
Returns the 2D vector form of this 3D vector, dropping the z coordinate.
See also
- PySide6.QtGui.QVector3D.toVector4D()¶
- Return type
Returns the 4D form of this 3D vector, with the w coordinate set to zero.
See also
- PySide6.QtGui.QVector3D.unproject(modelView, projection, viewport)¶
- Parameters
modelView –
PySide6.QtGui.QMatrix4x4
projection –
PySide6.QtGui.QMatrix4x4
viewport –
PySide6.QtCore.QRect
- Return type
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 viewport
.
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.
Note
y coordinates in viewport
should use OpenGL orientation. OpenGL expects the bottom to be 0 whereas for Qt top is 0.
See also
- PySide6.QtGui.QVector3D.x()¶
- Return type
float
Returns the x coordinate of this point.
- PySide6.QtGui.QVector3D.y()¶
- Return type
float
Returns the y coordinate of this point.
- PySide6.QtGui.QVector3D.z()¶
- Return type
float
Returns the z coordinate of this point.
© 2022 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 the GNU 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.