
We bake cookies in your browser for a better experience. Using this site means that you consent.Read More
TheQVector2D class represents a vector or vertex in 2D space.More...
| Header: | #include <QVector2D> |
| Since: | Qt 4.6 |
| QVector2D() | |
| QVector2D(qreal xpos, qreal ypos) | |
| QVector2D(const QPoint & point) | |
| QVector2D(const QPointF & point) | |
| QVector2D(const QVector3D & vector) | |
| QVector2D(const QVector4D & vector) | |
| bool | isNull() const |
| qreal | length() const |
| qreal | lengthSquared() const |
| void | normalize() |
| QVector2D | normalized() const |
| void | setX(qreal x) |
| void | setY(qreal y) |
| QPoint | toPoint() const |
| QPointF | toPointF() const |
| QVector3D | toVector3D() const |
| QVector4D | toVector4D() const |
| qreal | x() const |
| qreal | y() const |
| operator QVariant() const | |
| QVector2D & | operator*=(qreal factor) |
| QVector2D & | operator*=(const QVector2D & vector) |
| QVector2D & | operator+=(const QVector2D & vector) |
| QVector2D & | operator-=(const QVector2D & vector) |
| QVector2D & | operator/=(qreal divisor) |
| qreal | dotProduct(const QVector2D & v1, const QVector2D & v2) |
| bool | qFuzzyCompare(const QVector2D & v1, const QVector2D & v2) |
| bool | operator!=(const QVector2D & v1, const QVector2D & v2) |
| const QVector2D | operator*(qreal factor, const QVector2D & vector) |
| const QVector2D | operator*(const QVector2D & vector, qreal factor) |
| const QVector2D | operator*(const QVector2D & v1, const QVector2D & v2) |
| const QVector2D | operator+(const QVector2D & v1, const QVector2D & v2) |
| const QVector2D | operator-(const QVector2D & v1, const QVector2D & v2) |
| const QVector2D | operator-(const QVector2D & vector) |
| const QVector2D | operator/(const QVector2D & vector, qreal divisor) |
| QDataStream & | operator<<(QDataStream & stream, const QVector2D & vector) |
| bool | operator==(const QVector2D & v1, const QVector2D & v2) |
| QDataStream & | operator>>(QDataStream & stream, QVector2D & vector) |
TheQVector2D class represents a vector or vertex in 2D space.
TheQVector2D class can also be used to represent vertices in 2D space. We therefore do not need to provide a separate vertex class.
Note: By design values in theQVector2D instance are stored asfloat. This means that on platforms where theqreal arguments toQVector2D functions are represented bydouble values, it is possible to lose precision.
See alsoQVector3D,QVector4D, andQQuaternion.
Constructs a null vector, i.e. with coordinates (0, 0, 0).
Constructs a vector with coordinates (xpos,ypos).
Constructs a vector with x and y coordinates from a 2Dpoint.
Constructs a vector with x and y coordinates from a 2Dpoint.
Constructs a vector with x and y coordinates from a 3Dvector. The z coordinate ofvector is dropped.
See alsotoVector3D().
Constructs a vector with x and y coordinates from a 3Dvector. The z and w coordinates ofvector are dropped.
See alsotoVector4D().
[static]qreal QVector2D::dotProduct(constQVector2D & v1, constQVector2D & v2)Returns the dot product ofv1 andv2.
Returns true if the x and y coordinates are set to 0.0, otherwise returns false.
Returns the length of the vector from the origin.
See alsolengthSquared() andnormalized().
Returns the squared length of the vector from the origin. This is equivalent to the dot product of the vector with itself.
See alsolength() anddotProduct().
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 alsolength() andnormalized().
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 alsolength() andnormalize().
Sets the x coordinate of this point to the givenx coordinate.
Sets the y coordinate of this point to the giveny coordinate.
Returns theQPoint form of this 2D vector.
See alsotoPointF() andtoVector3D().
Returns theQPointF form of this 2D vector.
See alsotoPoint() andtoVector3D().
Returns the 3D form of this 2D vector, with the z coordinate set to zero.
See alsotoVector4D() andtoPoint().
Returns the 4D form of this 2D vector, with the z and w coordinates set to zero.
See alsotoVector3D() andtoPoint().
Returns the x coordinate of this point.
Returns the y coordinate of this point.
Returns the 2D vector as aQVariant.
Multiplies this vector's coordinates by the givenfactor, and returns a reference to this vector.
See alsooperator/=().
Multiplies the components of this vector by the corresponding components invector.
Adds the givenvector to this vector and returns a reference to this vector.
See alsooperator-=().
Subtracts the givenvector from this vector and returns a reference to this vector.
See alsooperator+=().
Divides this vector's coordinates by the givendivisor, and returns a reference to this vector.
See alsooperator*=().
Returns true ifv1 andv2 are equal, allowing for a small fuzziness factor for floating-point comparisons; false otherwise.
Returns true ifv1 is not equal tov2; otherwise returns false. This operator uses an exact floating-point comparison.
Returns a copy of the givenvector, multiplied by the givenfactor.
See alsoQVector2D::operator*=().
Returns a copy of the givenvector, multiplied by the givenfactor.
See alsoQVector2D::operator*=().
Multiplies the components ofv1 by the corresponding components inv2.
Returns aQVector2D object that is the sum of the given vectors,v1 andv2; each component is added separately.
See alsoQVector2D::operator+=().
Returns aQVector2D object that is formed by subtractingv2 fromv1; each component is subtracted separately.
See alsoQVector2D::operator-=().
This is an overloaded function.
Returns aQVector2D object that is formed by changing the sign of the components of the givenvector.
Equivalent toQVector2D(0,0) - vector.
Returns theQVector2D object formed by dividing all three components of the givenvector by the givendivisor.
See alsoQVector2D::operator/=().
Writes the givenvector to the givenstream and returns a reference to the stream.
See alsoSerializing Qt Data Types.
Returns true ifv1 is equal tov2; otherwise returns false. This operator uses an exact floating-point comparison.
Reads a 2D vector from the givenstream into the givenvector and returns a reference to the stream.
See alsoSerializing Qt Data Types.
© 2016 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 theGNU 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.