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 );
94 return angle < 0.0 ? angle + 2.0 * M_PI :
angle;
104 double angle = std::atan2( mY, mX ) + rot;
106 return QgsVector( len * std::cos( angle ), len * std::sin( angle ) );
115 throw QgsException( QStringLiteral(
"normalized vector of null vector undefined" ) );
QgsVector operator+(QgsVector other) const
Adds another vector to this vector.
bool operator!=(QgsVector other) const
Inequality operator.
QgsVector & operator+=(const QgsVector other)
Adds another vector to this vector in place.
bool qgsDoubleNear(double a, double b, double epsilon=4 *DBL_EPSILON)
Compare two doubles (but allow some difference)
QgsVector operator/(double scalar) const
Returns a vector where the components have been divided by a scalar value.
double length() const
Returns the length of the vector.
A class to represent a vector.
double angle() const
Returns the angle of the vector in radians.
QgsVector perpVector() const
Returns the perpendicular vector to this vector (rotated 90 degrees counter-clockwise) ...
QgsVector operator*(double scalar) const
Returns a vector where the components have been multiplied by a scalar value.
QgsVector rotateBy(double rot) const
Rotates the vector by a specified angle.
double x() const
Returns the vector's x-component.
QgsVector operator-() const
Swaps the sign of the x and y components of the vector.
double y() const
Returns the vector's y-component.
Defines a QGIS exception class.
bool operator==(QgsVector other) const
Equality operator.
QgsVector()=default
Default constructor for QgsVector.
QgsVector normalized() const
Returns the vector's normalized (or "unit") vector (ie same angle but length of 1.0).
QgsVector & operator-=(const QgsVector other)
Subtracts another vector to this vector in place.