62 return QgsVector( mX * scalar, mY * scalar );
71 return *
this * ( 1.0 / scalar );
81 return mX * v.mX + mY * v.mY;
89 return QgsVector( mX + other.mX, mY + other.mY );
107 return QgsVector( mX - other.mX, mY - other.mY );
126 return std::sqrt( mX * mX + mY * mY );
136 return mX * mX + mY * mY;
170 const double angle = std::atan2( mY, mX );
171 return angle < 0.0 ? angle + 2.0 * M_PI : angle;
179 return v.angle() - angle();
190 return mX * v.y() - mY * v.x();
222 QString str =
"Vector (";
231 SIP_PYOBJECT __repr__();
233 QString str = QStringLiteral(
"<QgsVector: %1>" ).arg( sipCpp->toString() );
234 sipRes = PyUnicode_FromString( str.toUtf8().constData() );
Defines a QGIS exception class.
A class to represent a 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.
double y() const
Returns the vector's y-component.
QgsVector(double x, double y)
Constructor for QgsVector taking x and y component values.
QgsVector operator-(QgsVector other) const
Subtracts another vector to this vector.
double lengthSquared() const
Returns the length of the vector.
QString toString(int precision=17) const
Returns a string representation of the vector.
double crossProduct(QgsVector v) const
Returns the 2D cross product of this vector and another vector v.
QgsVector operator/(double scalar) const
Returns a vector where the components have been divided by a scalar value.
double angle() const
Returns the angle of the vector in radians.
double operator*(QgsVector v) const
Returns the dot product of two vectors, which is the sum of the x component of this vector multiplied...
double angle(QgsVector v) const
Returns the angle between this vector and another vector in radians.
QgsVector operator+(QgsVector other) const
Adds another vector to this vector.
QgsVector & operator-=(QgsVector other)
Subtracts another vector to this vector in place.
QgsVector perpVector() const
Returns the perpendicular vector to this vector (rotated 90 degrees counter-clockwise)
double x() const
Returns the vector's x-component.
QgsVector operator*(double scalar) const
Returns a vector where the components have been multiplied by a scalar value.
QgsVector()=default
Default constructor for QgsVector.
double length() const
Returns the length of the vector.
bool operator!=(QgsVector other) const
QString qgsDoubleToString(double a, int precision=17)
Returns a string representation of a double.
bool qgsDoubleNear(double a, double b, double epsilon=4 *std::numeric_limits< double >::epsilon())
Compare two doubles (but allow some difference)
#define SIP_THROW(name,...)
Q_DECLARE_TYPEINFO(QgsVector, Q_MOVABLE_TYPE)