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.
List of all members, including inherited members
Constructor
Methods
Returns matrix data (in column-major order) |
|
Returns the determinant of this matrix. |
|
Performs fuzzy comparison between this matrix and other using an epsilon. |
|
Returns whether this matrix is an identity matrix |
|
Matrix-vector multiplication (vector is converted to homogeneous coordinates [X,Y,Z,1] and back) |
|
Maps vector by multiplying the top 3x3 portion of this matrix by vector. |
|
Multiples this matrix by another that rotates coordinates through angle degrees about the vector (x, y, z). |
|
Multiplies this matrix by another that scales coordinates by the components of a vector. |
|
Sets matrix to be identity matrix |
|
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]
- determinant(self) float[source]¶
Returns the determinant of this matrix.
Added in version 4.2.
- Return type:
float
- fuzzyEqual(self, other: QgsMatrix4x4, epsilon: float = 1e-08) bool[source]¶
Performs fuzzy comparison between this matrix and
otherusing anepsilon.Added in version 4.2.
- Parameters:
other (QgsMatrix4x4)
epsilon (float = 1e-08)
- Return type:
bool
- map(self, vector: QgsVector3D) QgsVector3D[source]¶
Matrix-vector multiplication (vector is converted to homogeneous coordinates [X,Y,Z,1] and back)
See also
Note
This function is not the same as
mapVector(). For points, always usemap().mapVector()is suitable for vectors (directions) only.- Parameters:
vector (QgsVector3D)
- Return type:
- mapVector(self, vector: QgsVector3D) QgsVector3D[source]¶
Maps vector by multiplying the top 3x3 portion of this matrix by
vector. The translation and projection components of this matrix are ignored. The matrix is applied pre-vector.- Parameters:
vector (QgsVector3D) – input vector to transform
See also
Added in version 4.2.
- Return type:
- rotate(self, angle: float, x: float, y: float, z: float)[source]¶
Multiples this matrix by another that rotates coordinates through
angledegrees about the vector (x,y,z).Added in version 4.2.
rotate(self, angle: float, vector:
QgsVector3D) Multiples this matrix by another that rotates coordinates throughangledegrees aboutvector.Added in version 4.2.
- Parameters:
angle (float)
x (float)
y (float)
z (float)
- scale(self, vector: QgsVector3D)[source]¶
Multiplies this matrix by another that scales coordinates by the components of a
vector.Added in version 4.2.
- Parameters:
vector (QgsVector3D)
- translate(self, vector: QgsVector3D)[source]¶
Multiplies this matrix by another that translates coordinates by the components of a
vector.- Parameters:
vector (QgsVector3D)