matrix4x4 QML值类型
A matrix4x4 type is a 4-row and 4-column matrix. 更多...
详细描述
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
函数签名 | 描述 | 示例 |
---|---|---|
translate(vector3d vector) | 将 this 矩阵4x4乘以另一个矩阵,该矩阵通过 vector 的分量平移坐标 | |
rotate(real angle, vector3d axis) | 将 this 矩阵4x4乘以另一个矩阵,该矩阵通过 axis 旋转坐标 angle 度 | |
rotate(quaternion quaternion) | 将 this 矩阵4x4乘以另一个矩阵,该矩阵根据指定的 quaternion 旋转坐标。假设 quaternion 已归一化。 | |
scale(real factor) | 将 this 矩阵4x4乘以另一个矩阵,该矩阵根据给定的 factor 缩放坐标 | 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) | 将 this 矩阵4x4乘以另一个矩阵,该矩阵根据分量 x 、y 和 z 缩放坐标 | 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) | 将 this 矩阵4x4乘以另一个矩阵,该矩阵根据 vector 的分量缩放坐标 | |
lookAt(vector3d eye, vector3d center, vector3d up) | 将 this 矩阵4x4乘以由 eye 点推导出的观察矩阵。向量3d的 center 表示 eye 观看的视角中心。向量3d的 up 表示相对于 eye 哪个方向被认为是向上的。 | |
matrix4x4 times(matrix4x4 other) | 返回将 this 矩阵4x4与另一个矩阵4x4相乘的矩阵4x4结果 | |
vector4d times(vector4d vector) | 根据此矩阵4x4将 vector 进行变换,并且应用矩阵的预向量 | |
vector3d times(vector3d vector) | 根据此矩阵4x4将 vector 进行变换,并且应用矩阵的预向量 | |
matrix4x4 times(real factor) | 返回将此matrix4x4矩阵与标量factor 相乘的结果matrix4x4 | 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) | 返回this 矩阵4x4与other 矩阵4x4相加的结果matrix4x4 | |
matrix4x4 minus(matrix4x4 other) | 返回从this 矩阵4x4中减去other 矩阵4x4的结果matrix4x4 | |
vector4d row(int which) | 返回根据which 指定的this 矩阵4x4行vector4d。注意:which 是从0开始的矩阵访问。 | |
vector4d column(int which) | 返回根据which 指定的this 矩阵4x4列vector4d。注意:which 是从0开始的矩阵访问。 | |
real determinant() | 返回this 矩阵4x4的行列式 | 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() | 返回如果存在,则返回this 矩阵4x4的逆矩阵,否则返回单位矩阵。 | 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() | 返回this 矩阵4x4的转置 | 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) | 将提供的矩形映射到由此矩阵定义的坐标系中。如果指定了旋转或剪切,则此函数返回边界矩形。此函数自Qt 6.5版本开始引入。 | |
point map(point) | 将提供的点映射到由此矩阵定义的坐标系中。此函数自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) | 如果this 矩阵4x4近似等于other 矩阵4x4,则返回true。当此的每个属性在epsilon范围内等同于other的相应属性时,近似为true。注意,epsilon是可选参数,默认epsilon是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 |
此值类型由
另请参阅 QML 值类型.
© 2024 The Qt Company Ltd. 本文档中的文档贡献归其各自所有者所有。本提供的文档是在自由软件基金会发布并按GNU自由文档许可证1.3版本条款下授权的。Qt和相应的徽标是芬兰和/或世界其他地区的The Qt Company Ltd的商标。所有其他商标均为其各自所有者的财产。