QGIS API Documentation 4.1.0-Master (64029b4150b)
Loading...
Searching...
No Matches
QgsMatrix4x4 Class Reference

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

#include <qgsmatrix4x4.h>

Public Member Functions

 QgsMatrix4x4 ()
 Initializes identity matrix.
 QgsMatrix4x4 (double m11, double m12, double m13, double m14, double m21, double m22, double m23, double m24, double m31, double m32, double m33, double m34, double m41, double m42, double m43, double m44)
 Initializes matrix by setting all values in row-major order.
const double * constData () const
 Returns pointer to the matrix data (stored in column-major order).
double * data ()
 Returns pointer to the matrix data (stored in column-major order).
QList< double > dataList () const
 Returns matrix data (in column-major order).
double determinant () const
 Returns the determinant of this matrix.
bool fuzzyEqual (const QgsMatrix4x4 &other, double epsilon=1e-8) const
 Performs fuzzy comparison between this matrix and other using an epsilon.
bool isIdentity () const
 Returns whether this matrix is an identity matrix.
QgsVector3D map (const QgsVector3D &vector) const
 Matrix-vector multiplication (vector is converted to homogeneous coordinates [X,Y,Z,1] and back).
QgsVector3D mapVector (const QgsVector3D &vector) const
 Maps vector by multiplying the top 3x3 portion of this matrix by vector.
bool operator!= (const QgsMatrix4x4 &other) const
bool operator== (const QgsMatrix4x4 &other) const
void rotate (double angle, const QgsVector3D &vector)
 Multiples this matrix by another that rotates coordinates through angle degrees about vector.
void rotate (double angle, double x, double y, double z)
 Multiples this matrix by another that rotates coordinates through angle degrees about the vector (x, y, z).
void scale (const QgsVector3D &vector)
 Multiplies this matrix by another that scales coordinates by the components of a vector.
void setToIdentity ()
 Sets matrix to be identity matrix.
void translate (const QgsVector3D &vector)
 Multiplies this matrix by another that translates coordinates by the components of a vector.

Friends

CORE_EXPORT QgsMatrix4x4 operator* (const QgsMatrix4x4 &m1, const QgsMatrix4x4 &m2)
 Matrix-matrix multiplication (useful to concatenate transforms).
CORE_EXPORT QgsVector3D operator* (const QgsMatrix4x4 &matrix, const QgsVector3D &vector)
 Matrix-vector multiplication (vector is converted to homogeneous coordinates [X,Y,Z,1] and back).

Detailed Description

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.
Since
QGIS 3.34

Definition at line 41 of file qgsmatrix4x4.h.

Constructor & Destructor Documentation

◆ QgsMatrix4x4() [1/2]

QgsMatrix4x4::QgsMatrix4x4 ( )
inline

Initializes identity matrix.

Definition at line 45 of file qgsmatrix4x4.h.

◆ QgsMatrix4x4() [2/2]

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

Initializes matrix by setting all values in row-major order.

Definition at line 22 of file qgsmatrix4x4.cpp.

Member Function Documentation

◆ constData()

const double * QgsMatrix4x4::constData ( ) const
inline

Returns pointer to the matrix data (stored in column-major order).

Definition at line 70 of file qgsmatrix4x4.h.

◆ data()

double * QgsMatrix4x4::data ( )
inline

Returns pointer to the matrix data (stored in column-major order).

Definition at line 72 of file qgsmatrix4x4.h.

◆ dataList()

QList< double > QgsMatrix4x4::dataList ( ) const

Returns matrix data (in column-major order).

Definition at line 71 of file qgsmatrix4x4.cpp.

◆ determinant()

double QgsMatrix4x4::determinant ( ) const

Returns the determinant of this matrix.

Since
QGIS 4.2

Definition at line 270 of file qgsmatrix4x4.cpp.

◆ fuzzyEqual()

bool QgsMatrix4x4::fuzzyEqual ( const QgsMatrix4x4 & other,
double epsilon = 1e-8 ) const

Performs fuzzy comparison between this matrix and other using an epsilon.

Since
QGIS 4.2

Definition at line 48 of file qgsmatrix4x4.cpp.

◆ isIdentity()

bool QgsMatrix4x4::isIdentity ( ) const

Returns whether this matrix is an identity matrix.

Definition at line 109 of file qgsmatrix4x4.cpp.

◆ map()

QgsVector3D QgsMatrix4x4::map ( const QgsVector3D & vector) const
inline

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

See also
mapVector()
Note
This function is not the same as mapVector(). For points, always use map(). mapVector() is suitable for vectors (directions) only.

Definition at line 91 of file qgsmatrix4x4.h.

◆ mapVector()

QgsVector3D QgsMatrix4x4::mapVector ( const QgsVector3D & vector) const

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
vectorinput vector to transform
See also
map()
Since
QGIS 4.2

Definition at line 98 of file qgsmatrix4x4.cpp.

◆ operator!=()

bool QgsMatrix4x4::operator!= ( const QgsMatrix4x4 & other) const
inline

Definition at line 58 of file qgsmatrix4x4.h.

◆ operator==()

bool QgsMatrix4x4::operator== ( const QgsMatrix4x4 & other) const
inline

Definition at line 56 of file qgsmatrix4x4.h.

◆ rotate() [1/2]

void QgsMatrix4x4::rotate ( double angle,
const QgsVector3D & vector )

Multiples this matrix by another that rotates coordinates through angle degrees about vector.

Since
QGIS 4.2

Definition at line 234 of file qgsmatrix4x4.cpp.

◆ rotate() [2/2]

void QgsMatrix4x4::rotate ( double angle,
double x,
double y,
double z )

Multiples this matrix by another that rotates coordinates through angle degrees about the vector (x, y, z).

Since
QGIS 4.2

Definition at line 188 of file qgsmatrix4x4.cpp.

◆ scale()

void QgsMatrix4x4::scale ( const QgsVector3D & vector)

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

Since
QGIS 4.2

Definition at line 170 of file qgsmatrix4x4.cpp.

◆ setToIdentity()

void QgsMatrix4x4::setToIdentity ( )

Sets matrix to be identity matrix.

Definition at line 124 of file qgsmatrix4x4.cpp.

◆ translate()

void QgsMatrix4x4::translate ( const QgsVector3D & vector)

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

Definition at line 63 of file qgsmatrix4x4.cpp.

◆ operator* [1/2]

CORE_EXPORT QgsMatrix4x4 operator* ( const QgsMatrix4x4 & m1,
const QgsMatrix4x4 & m2 )
friend

Matrix-matrix multiplication (useful to concatenate transforms).

Definition at line 145 of file qgsmatrix4x4.cpp.

◆ operator* [2/2]

CORE_EXPORT QgsVector3D operator* ( const QgsMatrix4x4 & matrix,
const QgsVector3D & vector )
friend

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

Definition at line 82 of file qgsmatrix4x4.cpp.


The documentation for this class was generated from the following files: