QtBase
v6.3.1
|
The QVector4D class represents a vector or vertex in 4D space. More...
#include <qvectornd.h>
Public Member Functions | |
constexpr | QVector4D () noexcept |
QVector4D (Qt::Initialization) noexcept | |
constexpr | QVector4D (float xpos, float ypos, float zpos, float wpos) noexcept |
constexpr | QVector4D (QPoint point) noexcept |
constexpr | QVector4D (QPointF point) noexcept |
constexpr | QVector4D (QVector2D vector) noexcept |
constexpr | QVector4D (QVector2D vector, float zpos, float wpos) noexcept |
constexpr | QVector4D (QVector3D vector) noexcept |
constexpr | QVector4D (QVector3D vector, float wpos) noexcept |
constexpr bool | isNull () const noexcept |
constexpr float | x () const noexcept |
constexpr float | y () const noexcept |
constexpr float | z () const noexcept |
constexpr float | w () const noexcept |
constexpr void | setX (float x) noexcept |
constexpr void | setY (float y) noexcept |
constexpr void | setZ (float z) noexcept |
constexpr void | setW (float w) noexcept |
constexpr float & | operator[] (int i) |
constexpr float | operator[] (int i) const |
float | length () const noexcept |
constexpr float | lengthSquared () const noexcept |
QVector4D | normalized () const noexcept |
void | normalize () noexcept |
constexpr QVector4D & | operator+= (QVector4D vector) noexcept |
constexpr QVector4D & | operator-= (QVector4D vector) noexcept |
constexpr QVector4D & | operator*= (float factor) noexcept |
constexpr QVector4D & | operator*= (QVector4D vector) noexcept |
constexpr QVector4D & | operator/= (float divisor) |
constexpr QVector4D & | operator/= (QVector4D vector) |
constexpr QVector2D | toVector2D () const noexcept |
constexpr QVector2D | toVector2DAffine () const noexcept |
constexpr QVector3D | toVector3D () const noexcept |
constexpr QVector3D | toVector3DAffine () const noexcept |
constexpr QPoint | toPoint () const noexcept |
constexpr QPointF | toPointF () const noexcept |
Q_GUI_EXPORT | operator QVariant () const |
Static Public Member Functions | |
static constexpr float | dotProduct (QVector4D v1, QVector4D v2) noexcept |
Related Functions | |
(Note that these are not member functions.) | |
QDataStream & | operator<< (QDataStream &stream, QVector4D vector) |
QDataStream & | operator>> (QDataStream &stream, QVector4D &vector) |
The QVector4D class represents a vector or vertex in 4D space.
\inmodule QtGui
Vectors are one of the main building blocks of 4D affine representations of 3D space. They consist of four finite floating-point coordinates, traditionally called x, y, z and w.
The QVector4D class can also be used to represent vertices in 4D space. We therefore do not need to provide a separate vertex class.
Definition at line 368 of file qvectornd.h.
|
inlineconstexprnoexcept |
Constructs a null vector, i.e. with coordinates (0, 0, 0, 0).
Definition at line 902 of file qvectornd.h.
|
inlineexplicitnoexcept |
Definition at line 372 of file qvectornd.h.
|
inlineconstexprnoexcept |
Constructs a vector with coordinates (xpos, ypos, zpos, wpos). All parameters must be finite.
Definition at line 904 of file qvectornd.h.
|
inlineexplicitconstexprnoexcept |
Constructs a vector with x and y coordinates from a 2D point, and z and w coordinates of 0.
Definition at line 906 of file qvectornd.h.
|
inlineexplicitconstexprnoexcept |
Constructs a vector with x and y coordinates from a 2D point, and z and w coordinates of 0.
Definition at line 908 of file qvectornd.h.
|
explicitconstexprnoexcept |
Constructs a 4D vector from the specified 2D vector. The z and w coordinates are set to zero.
Definition at line 911 of file qvectornd.h.
|
constexprnoexcept |
Constructs a 4D vector from the specified 2D vector. The z and w coordinates are set to zpos and wpos respectively, each of which must be finite.
Definition at line 912 of file qvectornd.h.
|
explicitconstexprnoexcept |
Constructs a 4D vector from the specified 3D vector. The w coordinate is set to zero.
Definition at line 915 of file qvectornd.h.
|
constexprnoexcept |
Constructs a 4D vector from the specified 3D vector. The w coordinate is set to wpos, which must be finite.
Definition at line 916 of file qvectornd.h.
Returns the dot product of v1 and v2.
Definition at line 1034 of file qvectornd.h.
|
inlineconstexprnoexcept |
Returns true
if the x, y, z, and w coordinates are set to 0.0, otherwise returns false
.
Definition at line 919 of file qvectornd.h.
|
inlinenoexcept |
Returns the length of the vector from the origin.
Definition at line 946 of file qvectornd.h.
|
inlineconstexprnoexcept |
Returns the squared length of the vector from the origin. This is equivalent to the dot product of the vector with itself.
Definition at line 951 of file qvectornd.h.
|
inlinenoexcept |
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.
Definition at line 963 of file qvectornd.h.
|
inlinenoexcept |
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.
Definition at line 956 of file qvectornd.h.
QVector4D::operator QVariant | ( | ) | const |
Returns the 4D vector as a QVariant.
Definition at line 1612 of file qvectornd.cpp.
|
inlineconstexprnoexcept |
Multiplies this vector's coordinates by the given finite factor, and returns a reference to this vector.
Definition at line 993 of file qvectornd.h.
Multiplies each component of this vector by the corresponding component of vector and returns a reference to this vector.
Definition at line 1002 of file qvectornd.h.
Adds the given vector to this vector and returns a reference to this vector.
Definition at line 975 of file qvectornd.h.
Subtracts the given vector from this vector and returns a reference to this vector.
Definition at line 984 of file qvectornd.h.
|
inlineconstexpr |
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.
Definition at line 1011 of file qvectornd.h.
Divides each component of this vector by the corresponding component of vector and returns a reference to this vector.
The vector must have no component that is either zero or NaN.
Definition at line 1021 of file qvectornd.h.
|
inlineconstexpr |
Returns the component of the vector at index position i as a modifiable reference.
i must be a valid index position in the vector (i.e., 0 <= i < 4).
Definition at line 934 of file qvectornd.h.
|
inlineconstexpr |
Returns the component of the vector at index position i.
i must be a valid index position in the vector (i.e., 0 <= i < 4).
Definition at line 940 of file qvectornd.h.
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
Returns the QPoint form of this 4D vector. The z and w coordinates are dropped. The x and y coordinates are rounded to nearest integers.
Definition at line 1071 of file qvectornd.h.
|
inlineconstexprnoexcept |
Returns the QPointF form of this 4D vector. The z and w coordinates are dropped.
Definition at line 1076 of file qvectornd.h.
|
inlineconstexprnoexcept |
Returns the 2D vector form of this 4D vector, dropping the z and w coordinates.
Definition at line 1041 of file qvectornd.h.
|
inlineconstexprnoexcept |
Returns the 2D vector form of this 4D vector, dividing the x and y coordinates by the w coordinate and dropping the z coordinate. Returns a null vector if w is zero.
Definition at line 1046 of file qvectornd.h.
|
inlineconstexprnoexcept |
Returns the 3D vector form of this 4D vector, dropping the w coordinate.
Definition at line 1057 of file qvectornd.h.
|
constexprnoexcept |
Returns the 3D vector form of this 4D vector, dividing the x, y, and z coordinates by the w coordinate. Returns a null vector if w is zero.
Definition at line 1062 of file qvectornd.h.
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
|
friend |
Returns true
if v1 is not equal to v2; otherwise returns false
. This operator uses an exact floating-point comparison.
Definition at line 422 of file qvectornd.h.
|
friend |
Definition at line 789 of file qmatrix4x4.h.
|
friend |
Definition at line 767 of file qmatrix4x4.h.
//! friend
Returns a copy of the given vector, multiplied by the given factor.
Definition at line 437 of file qvectornd.h.
//! friend
Returns the QVector4D object formed by multiplying each component of v1 by the corresponding component of v2.
Definition at line 447 of file qvectornd.h.
//! friend
Returns a copy of the given vector, multiplied by the given factor.
Definition at line 442 of file qvectornd.h.
//! friend
Returns a QVector4D object that is the sum of the given vectors, v1 and v2; each component is added separately.
Definition at line 427 of file qvectornd.h.
//! friend
Returns a QVector4D object that is formed by subtracting v2 from v1; each component is subtracted separately.
Definition at line 432 of file qvectornd.h.
//! friend
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Returns a QVector4D object that is formed by changing the sign of all three components of the given vector.
Equivalent to {QVector4D(0,0,0,0)
- vector}.
Definition at line 452 of file qvectornd.h.
//! friend
Returns the QVector4D object formed by dividing each component of the given vector by the given divisor.
The divisor must not be either zero or NaN.
Definition at line 457 of file qvectornd.h.
//! friend
Returns the QVector4D object formed by dividing each component of the given vector by the corresponding component of the given divisor.
The divisor must have no component that is either zero or NaN.
Definition at line 463 of file qvectornd.h.
|
related |
Writes the given vector to the given stream and returns a reference to the stream.
Definition at line 1642 of file qvectornd.cpp.
Returns true
if v1 is equal to v2; otherwise returns false
. This operator uses an exact floating-point comparison.
Definition at line 417 of file qvectornd.h.
|
related |
Reads a 4D vector from the given stream into the given vector and returns a reference to the stream.
Definition at line 1659 of file qvectornd.cpp.
//! friend
Returns true
if v1 and v2 are equal, allowing for a small fuzziness factor for floating-point comparisons; false otherwise.
Definition at line 1540 of file qvectornd.cpp.
|
friend |
Definition at line 494 of file qvectornd.h.
|
friend |
Definition at line 492 of file qvectornd.h.
|
friend |
Definition at line 493 of file qvectornd.h.