QGIS API Documentation
3.8.0-Zanzibar (11aff65)
|
A class to represent a vector. More...
#include <qgsvector.h>
Public Member Functions | |
QgsVector ()=default | |
Default constructor for QgsVector. More... | |
QgsVector (double x, double y) | |
Constructor for QgsVector taking x and y component values. More... | |
double | angle () const |
Returns the angle of the vector in radians. More... | |
double | angle (QgsVector v) const |
Returns the angle between this vector and another vector in radians. More... | |
double | crossProduct (QgsVector v) const |
Returns the 2D cross product of this vector and another vector v. More... | |
double | length () const |
Returns the length of the vector. More... | |
double | lengthSquared () const |
Returns the length of the vector. More... | |
QgsVector | normalized () const |
Returns the vector's normalized (or "unit") vector (ie same angle but length of 1.0). More... | |
bool | operator!= (QgsVector other) const |
Inequality operator. More... | |
QgsVector | operator* (double scalar) const |
Returns a vector where the components have been multiplied by a scalar value. More... | |
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. More... | |
QgsVector | operator+ (QgsVector other) const |
Adds another vector to this vector. More... | |
QgsVector & | operator+= (QgsVector other) |
Adds another vector to this vector in place. More... | |
QgsVector | operator- () const |
Swaps the sign of the x and y components of the vector. More... | |
QgsVector | operator- (QgsVector other) const |
Subtracts another vector to this vector. More... | |
QgsVector & | operator-= (QgsVector other) |
Subtracts another vector to this vector in place. More... | |
QgsVector | operator/ (double scalar) const |
Returns a vector where the components have been divided by a scalar value. More... | |
bool | operator== (QgsVector other) const |
Equality operator. More... | |
QgsVector | perpVector () const |
Returns the perpendicular vector to this vector (rotated 90 degrees counter-clockwise) More... | |
QgsVector | rotateBy (double rot) const |
Rotates the vector by a specified angle. More... | |
QString | toString (int precision=17) const |
Returns a string representation of the vector. More... | |
double | x () const |
Returns the vector's x-component. More... | |
double | y () const |
Returns the vector's y-component. More... | |
A class to represent a vector.
Currently no Z axis / 2.5D support is implemented.
Definition at line 29 of file qgsvector.h.
|
default |
Default constructor for QgsVector.
Creates a vector with length of 0.0.
QgsVector::QgsVector | ( | double | x, |
double | y | ||
) |
Constructor for QgsVector taking x and y component values.
x | x-component |
y | y-component |
Definition at line 21 of file qgsvector.cpp.
double QgsVector::angle | ( | ) | const |
Returns the angle of the vector in radians.
Definition at line 91 of file qgsvector.cpp.
double QgsVector::angle | ( | QgsVector | v | ) | const |
Returns the angle between this vector and another vector in radians.
Definition at line 97 of file qgsvector.cpp.
double QgsVector::crossProduct | ( | QgsVector | v | ) | const |
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 102 of file qgsvector.cpp.
double QgsVector::length | ( | ) | const |
Returns the length of the vector.
Definition at line 71 of file qgsvector.cpp.
|
inline |
Returns the length of the vector.
Definition at line 103 of file qgsvector.h.
QgsVector QgsVector::normalized | ( | ) | const |
Returns the vector's normalized (or "unit") vector (ie same angle but length of 1.0).
Will throw a QgsException if called on a vector with length of 0.
Definition at line 114 of file qgsvector.cpp.
bool QgsVector::operator!= | ( | QgsVector | other | ) | const |
Inequality operator.
Definition at line 131 of file qgsvector.cpp.
QgsVector QgsVector::operator* | ( | double | scalar | ) | const |
Returns a vector where the components have been multiplied by a scalar value.
scalar | factor to multiply by |
Definition at line 32 of file qgsvector.cpp.
double QgsVector::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.
Definition at line 42 of file qgsvector.cpp.
Adds another vector to this vector in place.
Definition at line 52 of file qgsvector.cpp.
QgsVector QgsVector::operator- | ( | ) | const |
Swaps the sign of the x and y components of the vector.
Definition at line 27 of file qgsvector.cpp.
Subtracts another vector to this vector in place.
Definition at line 64 of file qgsvector.cpp.
QgsVector QgsVector::operator/ | ( | double | scalar | ) | const |
Returns a vector where the components have been divided by a scalar value.
scalar | factor to divide by |
Definition at line 37 of file qgsvector.cpp.
bool QgsVector::operator== | ( | QgsVector | other | ) | const |
Equality operator.
Definition at line 126 of file qgsvector.cpp.
QgsVector QgsVector::perpVector | ( | ) | const |
Returns the perpendicular vector to this vector (rotated 90 degrees counter-clockwise)
Definition at line 86 of file qgsvector.cpp.
QgsVector QgsVector::rotateBy | ( | double | rot | ) | const |
Rotates the vector by a specified angle.
rot | angle in radians |
Definition at line 107 of file qgsvector.cpp.
|
inline |
Returns a string representation of the vector.
Members will be truncated to the specified precision.
Definition at line 166 of file qgsvector.h.
double QgsVector::x | ( | ) | const |
double QgsVector::y | ( | ) | const |