QGIS API Documentation
3.14.0-Pi (9f7028fd23)
|
Go to the documentation of this file.
34 return QgsVector( mX * scalar, mY * scalar );
39 return *
this * ( 1.0 / scalar );
44 return mX * v.mX + mY * v.mY;
49 return QgsVector( mX + other.mX, mY + other.mY );
61 return QgsVector( mX - other.mX, mY - other.mY );
73 return std::sqrt( mX * mX + mY * mY );
93 double angle = std::atan2( mY, mX );
104 return mX * v.
y() - mY * v.
x();
109 double angle = std::atan2( mY, mX ) + rot;
120 throw QgsException( QStringLiteral(
"normalized vector of null vector undefined" ) );
double crossProduct(QgsVector v) const
Returns the 2D cross product of this vector and another vector v.
QgsVector normalized() const
Returns the vector's normalized (or "unit") vector (ie same angle but length of 1....
QgsVector & operator-=(QgsVector other)
Subtracts another vector to this vector in place.
QgsVector()=default
Default constructor for QgsVector.
QgsVector operator*(double scalar) const
Returns a vector where the components have been multiplied by a scalar value.
double x() const
Returns the vector's x-component.
bool qgsDoubleNear(double a, double b, double epsilon=4 *std::numeric_limits< double >::epsilon())
Compare two doubles (but allow some difference)
bool operator!=(QgsVector other) const
Inequality operator.
QgsVector operator+(QgsVector other) const
Adds another vector to this vector.
QgsVector operator-() const
Swaps the sign of the x and y components of the vector.
bool operator==(QgsVector other) const
Equality operator.
double y() const
Returns the vector's y-component.
double angle() const
Returns the angle of the vector in radians.
double length() const
Returns the length of the vector.
QgsVector & operator+=(QgsVector other)
Adds another vector to this vector in place.
QgsVector perpVector() const
Returns the perpendicular vector to this vector (rotated 90 degrees counter-clockwise)
QgsVector rotateBy(double rot) const
Rotates the vector by a specified angle.
QgsVector operator/(double scalar) const
Returns a vector where the components have been divided by a scalar value.