Class: QgsVector3D

A 3D vector (similar to QVector3D) with the difference that it uses double precision instead of single precision floating point numbers.

class qgis.core.QgsVector3D[source]

Bases: object

__init__()

Constructs a null vector

__init__(x: float, y: float, z: float)

Constructs a vector from given coordinates

Parameters:
  • x (float)

  • y (float)

  • z (float)

__init__(v: QVector3D)

Constructs a vector from single-precision QVector3D

Parameters:

v (QVector3D)

__init__(a0: QgsVector3D)
Parameters:

a0 (QgsVector3D)

static crossProduct(v1: QgsVector3D, v2: QgsVector3D) QgsVector3D[source]

Returns the cross product of two vectors

Parameters:
Return type:

QgsVector3D

distance(self, other: QgsVector3D) float[source]

Returns the distance with the other QgsVector3D

Parameters:

other (QgsVector3D)

Return type:

float

static dotProduct(v1: QgsVector3D, v2: QgsVector3D) float[source]

Returns the dot product of two vectors

Parameters:
Return type:

float

isNull(self) bool[source]

Returns True if all three coordinates are zero

Return type:

bool

length(self) float[source]

Returns the length of the vector.

See also

lengthSquared()

Return type:

float

lengthSquared(self) float[source]

Returns the squared length of the vector.

See also

length()

Added in version 4.0.

Return type:

float

normalize(self)[source]

Normalizes the current vector in place.

static perpendicularPoint(v1: QgsVector3D, v2: QgsVector3D, vp: QgsVector3D) QgsVector3D[source]

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

Parameters:
Return type:

QgsVector3D

set(self, x: float, y: float, z: float)[source]

Sets vector coordinates

Parameters:
  • x (float)

  • y (float)

  • z (float)

setX(self, x: float)[source]

Sets X coordinate

Added in version 3.34.

Parameters:

x (float)

setY(self, y: float)[source]

Sets Y coordinate

Added in version 3.34.

Parameters:

y (float)

setZ(self, z: float)[source]

Sets Z coordinate

Added in version 3.34.

Parameters:

z (float)

toString(self, precision: int = 17) str[source]

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[source]

Converts the current object to QVector3D

Warning

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

Added in version 3.24.

Return type:

QVector3D

x(self) float[source]

Returns X coordinate

Return type:

float

y(self) float[source]

Returns Y coordinate

Return type:

float

z(self) float[source]

Returns Z coordinate

Return type:

float