Class: QgsVector3D

class qgis.core.QgsVector3D

Bases: sip.wrapper

Class for storage of 3D vectors similar to QVector3D, with the difference that it uses double precision instead of single precision floating point numbers.

New in version 3.0.

QgsVector3D() Constructs a null vector

QgsVector3D(x: float, y: float, z: float) Constructs a vector from given coordinates

QgsVector3D(v: QVector3D) Constructs a vector from single-precision QVector3D

QgsVector3D(QgsVector3D)

Methods

crossProduct

Returns the cross product of two vectors

distance

Returns the distance with the other QgsVector3

dotProduct

Returns the dot product of two vectors

isNull

Returns True if all three coordinates are zero

length

Returns the length of the vector

normalize

Normalizes the current vector in place.

perpendicularPoint

Returns the perpendicular point of vector vp from [v1 - v2]

set

Sets vector coordinates

toString

Returns a string representation of the 3D vector.

toVector3D

Converts the current object to QVector3D

x

Returns X coordinate

y

Returns Y coordinate

z

Returns Z coordinate

crossProduct(v1: QgsVector3D, v2: QgsVector3D) QgsVector3D

Returns the cross product of two vectors

Parameters
Return type

QgsVector3D

distance(self, other: QgsVector3D) float

Returns the distance with the other QgsVector3

Parameters

other (QgsVector3D) –

Return type

float

dotProduct(v1: QgsVector3D, v2: QgsVector3D) float

Returns the dot product of two vectors

Parameters
Return type

float

isNull(self) bool

Returns True if all three coordinates are zero

Return type

bool

length(self) float

Returns the length of the vector

Return type

float

normalize(self)

Normalizes the current vector in place.

perpendicularPoint(v1: QgsVector3D, v2: QgsVector3D, vp: QgsVector3D) QgsVector3D

Returns the perpendicular point of vector vp from [v1 - v2]

Parameters
Return type

QgsVector3D

set(self, x: float, y: float, z: float)

Sets vector coordinates

Parameters
  • x (float) –

  • y (float) –

  • z (float) –

toString(self, precision: int = 17) str

Returns a string representation of the 3D vector. Members will be truncated to the specified precision.

Parameters

precision (int = 17) –

Return type

str

toVector3D(self) QVector3D

Converts the current object to QVector3D

Warning

the conversion may decrease the accuracy (double to float values conversion)

New in version 3.24.

Return type

QVector3D

x(self) float

Returns X coordinate

Return type

float

y(self) float

Returns Y coordinate

Return type

float

z(self) float

Returns Z coordinate

Return type

float