|
QGIS API Documentation 4.1.0-Master (60fea48833c)
|
Represent a 2-dimensional vector. More...
#include <qgsvector.h>
Public Member Functions | |
| QgsVector ()=default | |
| Default constructor for QgsVector. | |
| QgsVector (double x, double y) | |
| Constructor for QgsVector taking x and y component values. | |
| double | angle () const |
| Returns the angle of the vector in radians. | |
| double | angle (QgsVector v) const |
| Returns the angle between this vector and another vector in radians. | |
| double | crossProduct (QgsVector v) const |
| Returns the 2D cross product of this vector and another vector v. | |
| double | length () const |
| Returns the length of the vector. | |
| double | lengthSquared () const |
| Returns the length of the vector. | |
| QgsVector | normalized () const |
| Returns the vector's normalized (or "unit") vector (ie same angle but length of 1.0). | |
| bool | operator!= (QgsVector other) const |
| QgsVector | operator* (double scalar) const |
| Returns a vector where the components have been multiplied by a scalar value. | |
| double | operator* (QgsVector v) const |
| Returns the dot product of two vectors, which is the sum of the x component of this vector multiplied by the x component of another vector plus the y component of this vector multiplied by the y component of another vector. | |
| QgsVector | operator+ (QgsVector other) const |
| Adds another vector to this vector. | |
| QgsVector & | operator+= (QgsVector other) |
| Adds another vector to this vector in place. | |
| QgsVector | operator- () const |
| Swaps the sign of the x and y components of the vector. | |
| QgsVector | operator- (QgsVector other) const |
| Subtracts another vector to this vector. | |
| QgsVector & | operator-= (QgsVector other) |
| Subtracts another vector to this vector in place. | |
| QgsVector | operator/ (double scalar) const |
| Returns a vector where the components have been divided by a scalar value. | |
| bool | operator== (QgsVector other) const |
| QgsVector | perpVector () const |
| Returns the perpendicular vector to this vector (rotated 90 degrees counter-clockwise). | |
| QgsVector | rotateBy (double rot) const |
| Rotates the vector by a specified angle. | |
| QString | toString (int precision=17) const |
| Returns a string representation of the vector. | |
| double | x () const |
| Returns the vector's x-component. | |
| double | y () const |
| Returns the vector's y-component. | |
Represent a 2-dimensional vector.
No Z axis / 2.5D support is implemented. See QgsVector3D for a 3D equivalent.
Definition at line 33 of file qgsvector.h.
|
default |
Default constructor for QgsVector.
Creates a vector with length of 0.0.
|
inline |
Constructor for QgsVector taking x and y component values.
| x | x-component |
| y | y-component |
Definition at line 46 of file qgsvector.h.
|
inline |
Returns the angle of the vector in radians.
Definition at line 171 of file qgsvector.h.
|
inline |
Returns the angle between this vector and another vector in radians.
Definition at line 180 of file qgsvector.h.
|
inline |
Returns the 2D cross product of this vector and another vector v.
(This is sometimes referred to as a "perpendicular dot product", and equals x1 * y1 - y1 * x2).
Definition at line 191 of file qgsvector.h.
|
inline |
Returns the length of the vector.
Definition at line 127 of file qgsvector.h.
|
inline |
Returns the length of the vector.
Definition at line 137 of file qgsvector.h.
| QgsVector QgsVector::normalized | ( | ) | const |
Returns the vector's normalized (or "unit") vector (ie same angle but length of 1.0).
| QgsException | if called on a vector with length of 0. |
Definition at line 33 of file qgsvector.cpp.
|
inline |
Definition at line 214 of file qgsvector.h.
|
inline |
Returns a vector where the components have been multiplied by a scalar value.
| scalar | factor to multiply by |
Definition at line 63 of file qgsvector.h.
|
inline |
Returns the dot product of two vectors, which is the sum of the x component of this vector multiplied by the x component of another vector plus the y component of this vector multiplied by the y component of another vector.
Definition at line 82 of file qgsvector.h.
Adds another vector to this vector.
Definition at line 90 of file qgsvector.h.
Adds another vector to this vector in place.
Definition at line 98 of file qgsvector.h.
|
inline |
Swaps the sign of the x and y components of the vector.
Definition at line 53 of file qgsvector.h.
Subtracts another vector to this vector.
Definition at line 108 of file qgsvector.h.
Subtracts another vector to this vector in place.
Definition at line 116 of file qgsvector.h.
|
inline |
Returns a vector where the components have been divided by a scalar value.
| scalar | factor to divide by |
Definition at line 72 of file qgsvector.h.
|
inline |
Definition at line 209 of file qgsvector.h.
|
inline |
Returns the perpendicular vector to this vector (rotated 90 degrees counter-clockwise).
Definition at line 163 of file qgsvector.h.
| QgsVector QgsVector::rotateBy | ( | double | rot | ) | const |
Rotates the vector by a specified angle.
| rot | angle in radians |
Definition at line 26 of file qgsvector.cpp.
|
inline |
Returns a string representation of the vector.
Members will be truncated to the specified precision.
Definition at line 223 of file qgsvector.h.
|
inline |
|
inline |