62 return QgsVector( mX * scalar, mY * scalar );
71 return *
this * ( 1.0 / scalar );
81 return mX * v.mX + mY * v.mY;
90 return QgsVector( mX + other.mX, mY + other.mY );
110 return QgsVector( mX - other.mX, mY - other.mY );
130 return std::sqrt( mX * mX + mY * mY );
140 return mX * mX + mY * mY;
174 const double angle = std::atan2( mY, mX );
175 return angle < 0.0 ? angle + 2.0 * M_PI : angle;
183 return v.angle() - angle();
194 return mX * v.y() - mY * v.x();
228 QString
str =
"Vector (";
237 SIP_PYOBJECT __repr__();
239 QString
str = QStringLiteral(
"<QgsVector: %1>" ).arg( sipCpp->toString() );
240 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
Inequality operator.
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)