quaternion QML Value Type
四元数类型具有标量、x、y 和 z 属性。更多
详细说明
quaternion
类型具有scalar
、x
、y
和z
属性。
要创建quaternion
值,可将其指定为 "scalar,x,y,z "字符串,或单独定义组件,或使用 Qt.quaternion() 函数组成。
四元数类型有以下可在 QML 中调用的幂函数:
函数签名 | 说明 | 示例 |
---|---|---|
real dotProduct(quaternion other) | 返回this 四元数与other 四元数点积的标量实数结果。 | |
四元数 times(quaternion other) | 返回this 四元数与other 四元数相乘的四元数结果,相当于应用了两个旋转结果 | |
vector3d times(vector3d vector) | 返回vector 与this 四元数相乘的四元数结果。 | |
四元数 times(real factor) | 返回this 四元数与标量相乘的四元数结果factor | var a = Qt.quaternion(1,2,3,4); var b = 4.48; var c = a.times(b); console.log(c.toString()); // QQuaternion(4.48, 8.96, 13.44, 17.92) |
四元数 plus(quaternion other) | 返回this 四元数与other 四元数相加的四元数结果。 | |
四元数减(其他四元数) | 返回other 四元数与this 四元数相减的四元数结果。 | |
四元数归一化() | 返回this 四元数的归一化单位形式 | var a = Qt.quaternion(1,2,3,4); var b = a.normalized(); console.log(b.toString()); // QQuaternion(0.182574, 0.365148, 0.547723, 0.730297) |
四元数倒置() | 返回this 四元数的倒数 | var a = Qt.quaternion(0.5,0.5,0.5,-0.5); var b = a.inverted(); console.log(b.toString()); // QQuaternion(0.5, -0.5, -0.5, 0.5) |
四元数共轭() | 返回this 四元数的共轭数 | var a = Qt.quaternion(1,2,3,4); var b = a.conjugated() console.log(b.toString()); // QQuaternion(1, -2, -3, -4) |
real length() | 返回this 四元数长度的标量实值 | var a = Qt.quaternion(1,2,3,4); var b = a.length(); console.log(b.toString()); // 5.477225575051661 |
vector3d toEulerAngles() | 返回与this 四元数对应的 vector3d 欧拉角(以度为单位)。 | var a = Qt.quaternion(0.933012,0.25,-0.25,0.066987); var b = a.toEulerAngles(); console.log(b.toString()); // QVector3D(30, -30, -4.28846e-05) |
vector4d toVector4d() | 返回将this 四元数转换为矢量 4d 的结果 | var a = Qt.quaternion(1,2,3,4); var b = a.toVector4d(); console.log(b.toString()); // QVector4D(2, 3, 4, 1) |
bool fuzzyEquals(quaternion other, real epsilon) | 如果this 四元数近似等于other 四元数,则返回 true。如果this 的每个属性都在other 的epsilon 范围内,近似值将为真。请注意,epsilon 是可选参数,默认epsilon 为 0.00001。 |
quaternion
类型的属性默认值为Qt.quaternion(1, 0, 0, 0)
。
该值类型由QtQuick 导入提供。
另请参阅 QML 值类型。
© 2025 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.