Class: QgsMatrix4x4

A simple 4x4 matrix implementation useful for transformation in 3D space.

It is similar to QMatrix4x4, but working with double precision values. Most of the time, doing transform using QMatrix4x4 is fine, however QgsMatrix4x4 is useful in situations where single precision floats are not enough. For example, when using transform matrix where translation component has values in order of millions.

Warning

Non-stable API, exposed to Python for unit testing only.

Added in version 3.34.

Methods

data

Returns matrix data (in column-major order)

isIdentity

Returns whether this matrix is an identity matrix

map

Matrix-vector multiplication (vector is converted to homogeneous coordinates [X,Y,Z,1] and back)

setToIdentity

Sets matrix to be identity matrix

translate

Multiplies this matrix by another that translates coordinates by the components of a vector.

class qgis.core.QgsMatrix4x4[source]

Bases: object

__init__()

Initializes identity matrix

__init__(m11: float, m12: float, m13: float, m14: float, m21: float, m22: float, m23: float, m24: float, m31: float, m32: float, m33: float, m34: float, m41: float, m42: float, m43: float, m44: float)

Initializes matrix by setting all values in row-major order

Parameters:
  • m11 (float)

  • m12 (float)

  • m13 (float)

  • m14 (float)

  • m21 (float)

  • m22 (float)

  • m23 (float)

  • m24 (float)

  • m31 (float)

  • m32 (float)

  • m33 (float)

  • m34 (float)

  • m41 (float)

  • m42 (float)

  • m43 (float)

  • m44 (float)

__init__(a0: QgsMatrix4x4)
Parameters:

a0 (QgsMatrix4x4)

data(self) List[float]

Returns matrix data (in column-major order)

Return type:

List[float]

isIdentity(self) bool[source]

Returns whether this matrix is an identity matrix

Return type:

bool

map(self, vector: QgsVector3D) QgsVector3D[source]

Matrix-vector multiplication (vector is converted to homogeneous coordinates [X,Y,Z,1] and back)

Parameters:

vector (QgsVector3D)

Return type:

QgsVector3D

setToIdentity(self)[source]

Sets matrix to be identity matrix

translate(self, vector: QgsVector3D)[source]

Multiplies this matrix by another that translates coordinates by the components of a vector.

Parameters:

vector (QgsVector3D)