QVector4D Class
The QVector4D class represents a vector or vertex in 4D space. More...
Header: | #include <QVector4D> |
qmake: | QT += gui |
Since: | Qt 4.6 |
This class was introduced in Qt 4.6.
Public Functions
QVector4D(const QVector3D &vector, float wpos) | |
QVector4D(const QVector3D &vector) | |
QVector4D(const QVector2D &vector, float zpos, float wpos) | |
QVector4D(const QVector2D &vector) | |
float | length() const |
float | lengthSquared() const |
void | normalize() |
QVector4D | normalized() const |
QVector2D | toVector2D() const |
QVector2D | toVector2DAffine() const |
QVector3D | toVector3D() const |
QVector3D | toVector3DAffine() const |
QVariant | operator QVariant() const |
Static Public Members
float | dotProduct(const QVector4D &v1, const QVector4D &v2) |
Detailed Description
The QVector4D class can also be used to represent vertices in 4D space. We therefore do not need to provide a separate vertex class.
See also QQuaternion, QVector2D, and QVector3D.
Member Function Documentation
QVector4D::QVector4D(const QVector3D &vector, float wpos)
Constructs a 4D vector from the specified 3D vector. The w coordinate is set to wpos.
See also toVector3D().
QVector4D::QVector4D(const QVector3D &vector)
Constructs a 4D vector from the specified 3D vector. The w coordinate is set to zero.
See also toVector3D().
QVector4D::QVector4D(const QVector2D &vector, float zpos, float wpos)
Constructs a 4D vector from the specified 2D vector. The z and w coordinates are set to zpos and wpos respectively.
See also toVector2D().
QVector4D::QVector4D(const QVector2D &vector)
Constructs a 4D vector from the specified 2D vector. The z and w coordinates are set to zero.
See also toVector2D().
[static]
float QVector4D::dotProduct(const QVector4D &v1, const QVector4D &v2)
Returns the dot product of v1 and v2.
float QVector4D::length() const
Returns the length of the vector from the origin.
See also lengthSquared() and normalized().
float QVector4D::lengthSquared() const
Returns the squared length of the vector from the origin. This is equivalent to the dot product of the vector with itself.
See also length() and dotProduct().
void QVector4D::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 length() and normalized().
QVector4D QVector4D::normalized() const
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 length() and normalize().
QVector2D QVector4D::toVector2D() const
Returns the 2D vector form of this 4D vector, dropping the z and w coordinates.
See also toVector2DAffine(), toVector3D(), and toPoint().
QVector2D QVector4D::toVector2DAffine() const
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.
See also toVector2D(), toVector3DAffine(), and toPoint().
QVector3D QVector4D::toVector3D() const
Returns the 3D vector form of this 4D vector, dropping the w coordinate.
See also toVector3DAffine(), toVector2D(), and toPoint().
QVector3D QVector4D::toVector3DAffine() const
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.
See also toVector3D(), toVector2DAffine(), and toPoint().
QVariant QVector4D::operator QVariant() const
Returns the 4D vector as a QVariant.