Subgroup: Vector

Class: QgsVector

class qgis.core.QgsVector

Bases: sip.wrapper

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)

A class to represent a vector. Currently no Z axis / 2.5D support is implemented.

Methods

angle Returns the angle of the vector in radians.
length Returns the length of the vector.
normalized Returns the vector’s normalized (or “unit”) vector (ie same angle but length of 1.
perpVector Returns the perpendicular vector to this vector (rotated 90 degrees counter-clockwise)
rotateBy Rotates the vector by a specified angle.
x Returns the vector’s x-component.
y Returns the vector’s y-component.

Signals

Attributes

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.

length(self) → float

Returns the length of the vector.

normalized(self) → QgsVector

Returns the vector’s normalized (or “unit”) vector (ie same angle but length of 1.0). Will throw a QgsException if called on a vector with length of 0.

perpVector(self) → QgsVector

Returns the perpendicular vector to this vector (rotated 90 degrees counter-clockwise)

rotateBy(self, rot: float) → QgsVector

Rotates the vector by a specified angle.

Parameters:rot – angle in radians
x(self) → float

Returns the vector’s x-component.

See also

y

y(self) → float

Returns the vector’s y-component.

See also

x