20 #include "qgis_core.h"
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 );
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(double x, double y)
Constructor for QgsVector taking x and y component values.
QgsVector perpVector() const SIP_HOLDGIL
Returns the perpendicular vector to this vector (rotated 90 degrees counter-clockwise)
QgsVector operator+(QgsVector other) const SIP_HOLDGIL
Adds another vector to this vector.
QgsVector operator-() const SIP_HOLDGIL
Swaps the sign of the x and y components of the vector.
double lengthSquared() const SIP_HOLDGIL
Returns the length of the vector.
QString toString(int precision=17) const SIP_HOLDGIL
Returns a string representation of the vector.
double crossProduct(QgsVector v) const SIP_HOLDGIL
Returns the 2D cross product of this vector and another vector v.
QgsVector operator*(double scalar) const SIP_HOLDGIL
Returns a vector where the components have been multiplied by a scalar value.
double y() const SIP_HOLDGIL
Returns the vector's y-component.
double angle() const SIP_HOLDGIL
Returns the angle of the vector in radians.
double operator*(QgsVector v) const SIP_HOLDGIL
Returns the dot product of two vectors, which is the sum of the x component of this vector multiplied...
double angle(QgsVector v) const SIP_HOLDGIL
Returns the angle between this vector and another vector in radians.
QgsVector & operator+=(QgsVector other) SIP_HOLDGIL
Adds another vector to this vector in place.
QgsVector operator/(double scalar) const SIP_HOLDGIL
Returns a vector where the components have been divided by a scalar value.
QgsVector()=default
Default constructor for QgsVector.
QgsVector & operator-=(QgsVector other) SIP_HOLDGIL
Subtracts another vector to this vector in place.
bool operator!=(QgsVector other) const
Inequality operator.
double x() const SIP_HOLDGIL
Returns the vector's x-component.
QgsVector operator-(QgsVector other) const SIP_HOLDGIL
Subtracts another vector to this vector.
double length() const SIP_HOLDGIL
Returns the length of the vector.
double ANALYSIS_EXPORT angle(QgsPoint *p1, QgsPoint *p2, QgsPoint *p3, QgsPoint *p4)
Calculates the angle between two segments (in 2 dimension, z-values are ignored)
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)
Q_DECLARE_TYPEINFO(QgsVector, Q_MOVABLE_TYPE)