Class: QgsVector¶
- class qgis.core.QgsVector¶
Bases:
sip.wrapper
A class to represent a vector. Currently no Z axis / 2.5D support is implemented.
QgsVector() Default constructor for
QgsVector
. Creates a vector with length of 0.0.QgsVector(x: float, y: float) Constructor for
QgsVector
taking x and y component values.- Parameters
x – x-component
y – y-component
QgsVector(
QgsVector
)Methods
Returns the angle of the vector in radians.
Returns the 2D cross product of this vector and another vector
v
.Returns the length of the vector.
Returns the length of the vector.
Returns the vector's normalized (or "unit") vector (ie same angle but length of 1.0).
Returns the perpendicular vector to this vector (rotated 90 degrees counter-clockwise)
Rotates the vector by a specified angle.
Returns a string representation of the vector.
Returns the vector's x-component.
Returns the vector's y-component.
- angle(self) float ¶
Returns the angle of the vector in radians.
angle(self, v:
QgsVector
) -> float Returns the angle between this vector and another vector in radians.- Return type
float
- crossProduct(self, v: QgsVector) float ¶
Returns the 2D cross product of this vector and another vector
v
. (This is sometimes referred to as a “perpendicular dot product”, and equals x1 * y1 - y1 * x2).New in version 3.2.
- Parameters
v (QgsVector) –
- Return type
float
- length(self) float ¶
Returns the length of the vector.
See also
- Return type
float
- lengthSquared(self) float ¶
Returns the length of the vector.
See also
New in version 3.2.
- Return type
float
- normalized(self) QgsVector ¶
Returns the vector’s normalized (or “unit”) vector (ie same angle but length of 1.0).
- Raises
QgsException – if called on a vector with length of 0.
- Return type
- perpVector(self) QgsVector ¶
Returns the perpendicular vector to this vector (rotated 90 degrees counter-clockwise)
- Return type
- rotateBy(self, rot: float) QgsVector ¶
Rotates the vector by a specified angle.
- Parameters
rot (float) – angle in radians
- Return type
- toString(self, precision: int = 17) str ¶
Returns a string representation of the vector. Members will be truncated to the specified
precision
.- Parameters
precision (int = 17) –
- Return type
str
- x(self) float ¶
Returns the vector’s x-component.
See also
y
- Return type
float
- y(self) float ¶
Returns the vector’s y-component.
See also
x
- Return type
float