matrix4x4 QML Value Type
A matrix4x4 type is a 4-row and 4-column matrix. More...
Detailed Description
A matrix4x4 type has sixteen values, each accessible via the properties m11 through m44 in QML (in row/column order). Values of this type can be composed with the Qt.matrix4x4() function. Each attribute in a matrix4x4 is stored as a real (single-precision on ARM, double-precision on x86).
A property of type matrix4x4 defaults to the identity matrix, whose diagonal entries m11, m22, m33 and m44 are all 1, with all other components 0.
The matrix4x4 type has the following idempotent functions which can be invoked in QML:
| Function Signature | Description | Example | 
|---|---|---|
| translate(vector3d vector) | Multiplies thismatrix4x4 by another that translates coordinates by the components ofvector | var m = Qt.matrix4x4(); m.translate(Qt.vector3d(1,2,3)); console.log(m.toString()); // QMatrix4x4(1, 0, 0, 1, 0, 1, 0, 2, 0, 0, 1, 3, 0, 0, 0, 1) | 
| rotate(real angle, vector3d axis) | Multiples thismatrix4x4 by another that rotates coordinates throughangledegrees aboutaxis | var m = Qt.matrix4x4(); m.rotate(180,Qt.vector3d(1,0,0)); console.log(m.toString()); // QMatrix4x4(1, 0, 0, 0, 0, -1, 0, 0, 0, 0, -1, 0, 0, 0, 0, 1) | 
| rotate(quaternion quaternion) | Multiples thismatrix4x4 by another that rotates coordinates according to a specifiedquaternion. Thequaternionis assumed to have been normalized. | var m = Qt.matrix4x4(); m.rotate(Qt.quaternion(0.5,0.5,0.5,-0.5)); console.log(m.toString()); // QMatrix4x4(0, 1, 0, 0, 0, 0, -1, 0, -1, 0, 0, 0, 0, 0, 0, 1) | 
| scale(real factor) | Multiplies thismatrix4x4 by another that scales coordinates by the givenfactor | var m = Qt.matrix4x4(); m.scale(2); console.log(m.toString()); // QMatrix4x4(2, 0, 0, 0, 0, 2, 0, 0, 0, 0, 2, 0, 0, 0, 0, 1) | 
| scale(real x, real y, real z) | Multiplies thismatrix4x4 by another that scales coordinates by the componentsx,y, andz | var m = Qt.matrix4x4(); m.scale(1,2,3); console.log(m.toString()); // QMatrix4x4(1, 0, 0, 0, 0, 2, 0, 0, 0, 0, 3, 0, 0, 0, 0, 1) | 
| scale(vector3d vector) | Multiplies thismatrix4x4 by another that scales coordinates by the components ofvector | var m = Qt.matrix4x4(); m.scale(Qt.vector3d(1,2,3)); console.log(m.toString()); // QMatrix4x4(1, 0, 0, 0, 0, 2, 0, 0, 0, 0, 3, 0, 0, 0, 0, 1) | 
| lookAt(vector3d eye, vector3d center, vector3d up) | Multiplies thismatrix4x4 by a viewing matrix derived from aneyepoint. Thecentervector3d indicates the center of the view that theeyeis looking at. Theupvector3d indicates which direction should be considered up with respect to theeye. | var m = Qt.matrix4x4(); m.lookAt(Qt.vector3d(1,2,3),Qt.vector3d(1,2,0),Qt.vector3d(0,1,0)); console.log(m.toString()); // QMatrix4x4(1, 0, 0, -1, 0, 1, 0, -2, 0, 0, 1, -3, 0, 0, 0, 1) | 
| matrix4x4 times(matrix4x4 other) | Returns the matrix4x4 result of multiplying thismatrix4x4 with theothermatrix4x4 | var a = Qt.matrix4x4(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16); var b = Qt.matrix4x4(4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19); var c = a.times(b); console.log(c.toString()); // QMatrix4x4(120, 130, 140, 150, 280, 306, 332, 358, 440, 482, //524, 566, 600, 658, 716, 774) | 
| vector4d times(vector4d vector) | Returns the vector4d result of transforming the vectoraccording tothismatrix4x4 with the matrix applied pre-vector | var a = Qt.matrix4x4(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16); var b = Qt.vector4d(5,6,7,8); var c = a.times(b); console.log(c.toString()); // QVector4D(70, 174, 278, 382) | 
| vector3d times(vector3d vector) | Returns the vector3d result of transforming the vectoraccording tothismatrix4x4 with the matrix applied pre-vector | var a = Qt.matrix4x4(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16); var b = Qt.vector3d(5,6,7); var c = a.times(b); console.log(c.toString()); // QVector3D(0.155556, 0.437037, 0.718518) | 
| matrix4x4 times(real factor) | Returns the matrix4x4 result of multiplying thismatrix4x4 with the scalarfactor | var a = Qt.matrix4x4(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16); var b = 4.48; var c = a.times(b); console.log(c.toString()); // QMatrix4x4(4.48, 8.96, 13.44, 17.92, 22.4, 26.88, 31.36, 35.84, // 40.32, 44.8, 49.28, 53.76, 58.24, 62.72, 67.2, 71.68) | 
| matrix4x4 plus(matrix4x4 other) | Returns the matrix4x4 result of the addition of thismatrix4x4 with theothermatrix4x4 | var a = Qt.matrix4x4(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16); var b = Qt.matrix4x4(5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20); var c = a.plus(b); console.log(c.toString()); // QMatrix4x4(6, 8, 10, 12, 14, 16, 18, 20, 22, // 24, 26, 28, 30, 32, 34, 36) | 
| matrix4x4 minus(matrix4x4 other) | Returns the matrix4x4 result of the subtraction of othermatrix4x4 fromthismatrix4x4 | var a = Qt.matrix4x4(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16); var b = Qt.matrix4x4(5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20); var c = a.minus(b); console.log(c.toString()); // QMatrix4x4(-4, -4, -4, -4, -4, -4, -4, -4, -4, // -4, -4, -4, -4, -4, -4, -4) | 
| vector4d row(int which) | Returns the vector4d row of thisspecified bywhich. Note: thewhichis 0-based access into the matrix. | var a = Qt.matrix4x4(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16); var b = Qt.vector4d(a.m21, a.m22, a.m23, a.m24); var c = a.row(2); // zero based access! so not equal to b console.log(b.toString() + " " + c.toString()); // QVector4D(5, 6, 7, 8) QVector4D(9, 10, 11, 12) | 
| vector4d column(int which) | Returns the vector4d column of thisspecified bywhich. Note: thewhichis 0-based access into the matrix. | var a = Qt.matrix4x4(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16); var b = Qt.vector4d(a.m12, a.m22, a.m32, a.m42); var c = a.column(2); // zero based access! so not equal to b console.log(b.toString() + " " + c.toString()); // QVector4D(2, 6, 10, 14) QVector4D(3, 7, 11, 15) | 
| real determinant() | Returns the determinant of thismatrix4x4 | var a = Qt.matrix4x4(1,0,0,0,0,2,0,0,0,0,3,0,100,200,300,1); var b = a.determinant(); console.log(b); // 6 | 
| matrix4x4 inverted() | Returns the inverse of thismatrix4x4 if it exists, else the identity matrix. | var a = Qt.matrix4x4(1,0,0,0,0,2,0,0,0,0,3,0,100,200,300,1); var b = a.inverted(); console.log(b.toString()); // QMatrix4x4(1, 0, 0, 0, 0, 0.5, 0, 0, 0, 0, 0.333333, 0, -100, // -100, -100, 1) | 
| matrix4x4 transposed() | Returns the transpose of thismatrix4x4 | var a = Qt.matrix4x4(1,0,0,0,0,2,0,0,0,0,3,0,100,200,300,1); var b = a.transposed(); console.log(b.toString()); // QMatrix4x4(1, 0, 0, 100, 0, 2, 0, 200, 0, 0, 3, 300, 0, 0, 0, 1) | 
| rect mapRect(rect) | Maps the provided rectangle into the coordinate system defined by this matrix. If rotation or shearing has been specified, this function returns the bounding rectangle. This function was introduced in Qt 6.5. | var a = Qt.matrix4x4(2,0,0,0,0,2,0,0,0,0,1,0,0,0,0,1); var b = a.mapRect(Qt.rect(10, 20, 30, 40)); console.log(b.toString()); // Qt.rect(20, 40, 60, 80) | 
| point map(point) | Maps the provided point into the coordinate system defined by this matrix. This function was introduced in Qt 6.5. | var a = Qt.matrix4x4(2,0,0,0,0,2,0,0,0,0,1,0,0,0,0,1); var b = a.map(10, 20); console.log(b.toString()); // Qt.point(20, 40) | 
| bool fuzzyEquals(matrix4x4 other, real epsilon) | Returns true if thismatrix4x4 is approximately equal to theothermatrix4x4. The approximation will be true if each attribute ofthisis withinepsilonof the respective attribute ofother. Note thatepsilonis an optional argument, the defaultepsilonis 0.00001. | var a = Qt.matrix4x4(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16); var b = Qt.matrix4x4(1.0001,2.0001,3.0002,4.0003,5.0001,6.0002, 7.0002,8.0004, 9.0001,10.0003, 11.0003,12.0004,13.0001, 14.0002,15.0003,16.0004); var c = a.fuzzyEquals(b); // default epsilon var d = a.fuzzyEquals(b, 0.005); // supplied epsilon console.log(c + " " + d); // false true | 
This value type is provided by the QtQuick import.
See also QML Value Types.