QGIS API Documentation
3.16.0-Hannover (43b64b13f3)
|
Go to the documentation of this file.
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 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() );
252 #endif // QGSVECTOR_H
Defines a QGIS exception class.
QgsVector operator*(double scalar) const SIP_HOLDGIL
Returns a vector where the components have been multiplied by a scalar value.
QgsVector(double x, double y)
Constructor for QgsVector taking x and y component values.
Q_DECLARE_TYPEINFO(QgsVector, Q_MOVABLE_TYPE)
double angle() const SIP_HOLDGIL
Returns the angle of the vector in radians.
QgsVector()=default
Default constructor for QgsVector.
QString qgsDoubleToString(double a, int precision=17)
Returns a string representation of a double.
QgsVector perpVector() const SIP_HOLDGIL
Returns the perpendicular vector to this vector (rotated 90 degrees counter-clockwise)
double length() const SIP_HOLDGIL
Returns the length of the vector.
double lengthSquared() const SIP_HOLDGIL
Returns the length of the vector.
bool qgsDoubleNear(double a, double b, double epsilon=4 *std::numeric_limits< double >::epsilon())
Compare two doubles (but allow some difference)
double x() const SIP_HOLDGIL
Returns the vector's x-component.
bool operator!=(QgsVector other) const
Inequality operator.
QgsVector operator+(QgsVector other) const SIP_HOLDGIL
Adds another vector to this vector.
double y() const SIP_HOLDGIL
Returns the vector's y-component.
QgsVector operator-() const SIP_HOLDGIL
Swaps the sign of the x and y components of the vector.
double crossProduct(QgsVector v) const SIP_HOLDGIL
Returns the 2D cross product of this vector and another vector v.
QgsVector & operator-=(QgsVector other) SIP_HOLDGIL
Subtracts another vector to this vector in place.
A class to represent a vector.
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.
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...
QString toString(int precision=17) const SIP_HOLDGIL
Returns a string representation 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)
double angle(QgsVector v) const SIP_HOLDGIL
Returns the angle between this vector and another vector in radians.
QgsVector operator-(QgsVector other) const SIP_HOLDGIL
Subtracts another vector to this vector.