![]() |
Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
|
The QVector4D class represents a vector or vertex in 4D space. More...
#include <qvectornd.h>
Public Member Functions | |
constexpr | QVector4D () noexcept |
Constructs a null vector, i.e. | |
QVector4D (Qt::Initialization) noexcept | |
constexpr | QVector4D (float xpos, float ypos, float zpos, float wpos) noexcept |
Constructs a vector with coordinates (xpos, ypos, zpos, wpos). | |
constexpr | QVector4D (QPoint point) noexcept |
Constructs a vector with x and y coordinates from a 2D point, and z and w coordinates of 0. | |
constexpr | QVector4D (QPointF point) noexcept |
Constructs a vector with x and y coordinates from a 2D point, and z and w coordinates of 0. | |
constexpr | QVector4D (QVector2D vector) noexcept |
Constructs a 4D vector from the specified 2D vector. | |
constexpr | QVector4D (QVector2D vector, float zpos, float wpos) noexcept |
Constructs a 4D vector from the specified 2D vector. | |
constexpr | QVector4D (QVector3D vector) noexcept |
Constructs a 4D vector from the specified 3D vector. | |
constexpr | QVector4D (QVector3D vector, float wpos) noexcept |
Constructs a 4D vector from the specified 3D vector. | |
constexpr bool | isNull () const noexcept |
Returns true if the x, y, z, and w coordinates are set to 0.0, otherwise returns false . | |
constexpr float | x () const noexcept |
Returns the x coordinate of this point. | |
constexpr float | y () const noexcept |
Returns the y coordinate of this point. | |
constexpr float | z () const noexcept |
Returns the z coordinate of this point. | |
constexpr float | w () const noexcept |
Returns the w coordinate of this point. | |
constexpr void | setX (float x) noexcept |
Sets the x coordinate of this point to the given finite x coordinate. | |
constexpr void | setY (float y) noexcept |
Sets the y coordinate of this point to the given finite y coordinate. | |
constexpr void | setZ (float z) noexcept |
Sets the z coordinate of this point to the given finite z coordinate. | |
constexpr void | setW (float w) noexcept |
Sets the w coordinate of this point to the given finite w coordinate. | |
constexpr float & | operator[] (int i) |
constexpr float | operator[] (int i) const |
float | length () const noexcept |
Returns the length of the vector from the origin. | |
constexpr float | lengthSquared () const noexcept |
Returns the squared length of the vector from the origin. | |
QVector4D | normalized () const noexcept |
Returns the normalized unit vector form of this vector. | |
void | normalize () noexcept |
Normalizes the current vector in place. | |
constexpr QVector4D & | operator+= (QVector4D vector) noexcept |
Adds the given vector to this vector and returns a reference to this vector. | |
constexpr QVector4D & | operator-= (QVector4D vector) noexcept |
Subtracts the given vector from this vector and returns a reference to this vector. | |
constexpr QVector4D & | operator*= (float factor) noexcept |
Multiplies this vector's coordinates by the given finite factor, and returns a reference to this vector. | |
constexpr QVector4D & | operator*= (QVector4D vector) noexcept |
Multiplies each component of this vector by the corresponding component of vector and returns a reference to this vector. | |
constexpr QVector4D & | operator/= (float divisor) |
Divides this vector's coordinates by the given divisor, and returns a reference to this vector. | |
constexpr QVector4D & | operator/= (QVector4D vector) |
constexpr QVector2D | toVector2D () const noexcept |
Returns the 2D vector form of this 4D vector, dropping the z and w coordinates. | |
constexpr QVector2D | toVector2DAffine () const noexcept |
Returns the 2D vector form of this 4D vector, dividing the x and y coordinates by the w coordinate and dropping the z coordinate. | |
constexpr QVector3D | toVector3D () const noexcept |
Returns the 3D vector form of this 4D vector, dropping the w coordinate. | |
constexpr QVector3D | toVector3DAffine () const noexcept |
Returns the 3D vector form of this 4D vector, dividing the x, y, and z coordinates by the w coordinate. | |
constexpr QPoint | toPoint () const noexcept |
Returns the QPoint form of this 4D vector. | |
constexpr QPointF | toPointF () const noexcept |
Returns the QPointF form of this 4D vector. | |
Q_GUI_EXPORT | operator QVariant () const |
Returns the 4D vector as a QVariant. | |
Static Public Member Functions | |
static constexpr float | dotProduct (QVector4D v1, QVector4D v2) noexcept |
Returns the dot product of v1 and v2. | |
Friends | |
class | QVector2D |
class | QVector3D |
class | QMatrix4x4 |
QT_WARNING_PUSH QT_WARNING_DISABLE_FLOAT_COMPARE constexpr friend bool | operator== (QVector4D v1, QVector4D v2) noexcept |
Returns true if v1 is equal to v2; otherwise returns false . | |
constexpr friend bool | operator!= (QVector4D v1, QVector4D v2) noexcept |
Returns true if v1 is not equal to v2; otherwise returns false . | |
QT_WARNING_POP constexpr friend QVector4D | operator+ (QVector4D v1, QVector4D v2) noexcept |
//! | |
constexpr friend QVector4D | operator- (QVector4D v1, QVector4D v2) noexcept |
//! | |
constexpr friend QVector4D | operator* (float factor, QVector4D vector) noexcept |
//! | |
constexpr friend QVector4D | operator* (QVector4D vector, float factor) noexcept |
//! | |
constexpr friend QVector4D | operator* (QVector4D v1, QVector4D v2) noexcept |
//! | |
constexpr friend QVector4D | operator- (QVector4D vector) noexcept |
//! | |
constexpr friend QVector4D | operator/ (QVector4D vector, float divisor) |
//! | |
constexpr friend QVector4D | operator/ (QVector4D vector, QVector4D divisor) |
//! | |
Q_GUI_EXPORT bool | qFuzzyCompare (QVector4D v1, QVector4D v2) |
//! | |
QVector4D | operator* (const QVector4D &vector, const QMatrix4x4 &matrix) |
QVector4D | operator* (const QMatrix4x4 &matrix, const QVector4D &vector) |
template<std::size_t I, typename V, std::enable_if_t<(I< 4), bool > = true, std::enable_if_t< std::is_same_v< q20::remove_cvref_t< V >, QVector4D >, bool > = true> | |
constexpr decltype(auto) | get (V &&vec) noexcept |
Related Symbols | |
(Note that these are not member symbols.) | |
QDataStream & | operator<< (QDataStream &stream, QVector4D vector) |
Writes the given vector to the given stream and returns a reference to the stream. | |
QDataStream & | operator>> (QDataStream &stream, QVector4D &vector) |
Reads a 4D vector from the given stream into the given vector and returns a reference to the stream. | |
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 329 of file qvectornd.h.
|
inlineconstexprnoexcept |
Constructs a null vector, i.e.
with coordinates (0, 0, 0, 0).
Definition at line 856 of file qvectornd.h.
Referenced by normalized().
|
inlineexplicitnoexcept |
Constructs a vector without initializing the contents.
Definition at line 333 of file qvectornd.h.
|
inlineconstexprnoexcept |
Constructs a vector with coordinates (xpos, ypos, zpos, wpos).
All parameters must be finite.
Definition at line 858 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 860 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 862 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 865 of file qvectornd.h.
References QVector2D::operator[]().
|
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 866 of file qvectornd.h.
References QVector2D::operator[]().
|
explicitconstexprnoexcept |
Constructs a 4D vector from the specified 3D vector.
The w coordinate is set to zero.
Definition at line 869 of file qvectornd.h.
References QVector3D::operator[]().
|
constexprnoexcept |
Constructs a 4D vector from the specified 3D vector.
The w coordinate is set to wpos, which must be finite.
Definition at line 870 of file qvectornd.h.
References QVector3D::operator[]().
Referenced by QVector3D::project(), and QVector3D::unproject().
Returns the dot product of v1 and v2.
Definition at line 988 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 873 of file qvectornd.h.
|
inlinenodiscardnoexcept |
Returns the length of the vector from the origin.
Definition at line 900 of file qvectornd.h.
Referenced by normalize(), and normalized().
|
inlinenodiscardconstexprnoexcept |
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 905 of file qvectornd.h.
|
inlinenoexcept |
Normalizes the current 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 917 of file qvectornd.h.
References length().
|
inlinenodiscardnoexcept |
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 910 of file qvectornd.h.
References QVector4D(), and length().
QVector4D::operator QVariant | ( | ) | const |
Returns the 4D vector as a QVariant.
Definition at line 1576 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 947 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 956 of file qvectornd.h.
Adds the given vector to this vector and returns a reference to this vector.
Definition at line 929 of file qvectornd.h.
Subtracts the given vector from this vector and returns a reference to this vector.
Definition at line 938 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 965 of file qvectornd.h.
Referenced by QVector3D::project(), and QVector3D::unproject().
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 975 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 888 of file qvectornd.h.
Referenced by QVector2D::QVector2D(), and QVector3D::QVector3D().
|
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 894 of file qvectornd.h.
|
inlineconstexprnoexcept |
Sets the w coordinate of this point to the given finite w coordinate.
Definition at line 886 of file qvectornd.h.
Referenced by operator>>(), QVector3D::project(), and QVector3D::unproject().
|
inlineconstexprnoexcept |
Sets the x coordinate of this point to the given finite x coordinate.
Definition at line 883 of file qvectornd.h.
Referenced by operator>>(), QVector3D::project(), and QVector3D::unproject().
|
inlineconstexprnoexcept |
Sets the y coordinate of this point to the given finite y coordinate.
Definition at line 884 of file qvectornd.h.
Referenced by operator>>(), QVector3D::project(), and QVector3D::unproject().
|
inlineconstexprnoexcept |
Sets the z coordinate of this point to the given finite z coordinate.
Definition at line 885 of file qvectornd.h.
Referenced by operator>>().
|
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 1025 of file qvectornd.h.
|
inlineconstexprnoexcept |
Returns the QPointF form of this 4D vector.
The z and w coordinates are dropped.
Definition at line 1030 of file qvectornd.h.
|
inlineconstexprnoexcept |
Returns the 2D vector form of this 4D vector, dropping the z and w coordinates.
Definition at line 995 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 1000 of file qvectornd.h.
References QVector2D::QVector2D().
|
inlineconstexprnoexcept |
Returns the 3D vector form of this 4D vector, dropping the w coordinate.
Definition at line 1011 of file qvectornd.h.
Referenced by QVector3D::project(), and QVector3D::unproject().
|
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 1016 of file qvectornd.h.
References QVector3D::QVector3D().
|
inlineconstexprnoexcept |
Returns the w coordinate of this point.
Definition at line 881 of file qvectornd.h.
Referenced by operator<<(), operator<<(), QVector3D::project(), and QVector3D::unproject().
|
inlineconstexprnoexcept |
Returns the x coordinate of this point.
Definition at line 878 of file qvectornd.h.
Referenced by operator<<(), operator<<(), QVector3D::project(), and QVector3D::unproject().
|
inlineconstexprnoexcept |
Returns the y coordinate of this point.
Definition at line 879 of file qvectornd.h.
Referenced by operator<<(), operator<<(), QVector3D::project(), and QVector3D::unproject().
|
inlineconstexprnoexcept |
Returns the z coordinate of this point.
Definition at line 880 of file qvectornd.h.
Referenced by operator<<(), and operator<<().
|
friend |
Definition at line 465 of file qvectornd.h.
Returns true
if v1 is not equal to v2; otherwise returns false
.
This operator uses an exact floating-point comparison.
Definition at line 383 of file qvectornd.h.
|
friend |
Definition at line 759 of file qmatrix4x4.h.
|
friend |
Definition at line 737 of file qmatrix4x4.h.
//!
friend
Returns a copy of the given vector, multiplied by the given factor.
Definition at line 398 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 408 of file qvectornd.h.
//!
friend
Returns a copy of the given vector, multiplied by the given factor.
Definition at line 403 of file qvectornd.h.
|
friend |
//!
friend
Returns a QVector4D object that is the sum of the given vectors, v1 and v2; each component is added separately.
Definition at line 388 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 393 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 413 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 418 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 424 of file qvectornd.h.
|
|
friend |
Returns true
if v1 is equal to v2; otherwise returns false
.
This operator uses an exact floating-point comparison.
Definition at line 378 of file qvectornd.h.
|
//!
friend
Returns true
if v1 and v2 are equal, allowing for a small fuzziness factor for floating-point comparisons; false otherwise.
Definition at line 1504 of file qvectornd.cpp.
|
friend |
Definition at line 455 of file qvectornd.h.
|
friend |
Definition at line 453 of file qvectornd.h.
|
friend |
Definition at line 454 of file qvectornd.h.