QRotationReading Class
QRotationReading 类表示来自旋转传感器的单次读数。更多内容...
| 头文件: | #include <QRotationReading> |
| CMake: | find_package(Qt6 REQUIRED COMPONENTS Sensors) target_link_libraries(mytarget PRIVATE Qt6::Sensors) |
| qmake: | QT += sensors |
| 继承自: | QSensorReading |
属性
公共函数
| void | setFromEuler(qreal x, qreal y, qreal z) |
| qreal | x() const |
| qreal | y() const |
| qreal | z() const |
详细说明
QRotationReading 单位
旋转读数包含 3 个角度,单位为度,用于定义设备在三维空间中的姿态。这些角度类似于偏航角、俯仰角和横滚角,但仅采用右手旋转规则进行定义,其轴系由右手笛卡尔坐标系确定。

这三个角度按以下顺序应用于设备。
- 右手旋转 z (-180, 180]。从 y 轴开始,沿逆时针方向递增。
- 右手旋转 x [-90, 90]。从新的(旋转一次后的)y 轴开始,朝 z 轴方向递增。
- 右手旋转 y (-180, 180]。从新的(旋转过一次的)z 轴开始,并沿 x 轴方向递增。
下图直观展示了角度应用的顺序。
z 角度的 0 点被定义为一个固定的外部实体,且因设备而异。虽然通常使用磁北作为该参考点,但情况可能并非如此。请勿尝试比较不同设备之间的 z 角度值,即使是在同一设备上,如果该设备已移动了相当大的距离,也不应进行比较。
如果设备无法检测到固定的外部实体,z角度将始终为0,且QRotationSensor::hasZ 属性将被设置为false。
x 角和 y 角的 0 点定义为:当设备的 x 轴和 y 轴朝向地平线时。以下是一个示例,展示了 x 值如何随设备移动而变化。

以下是一个示例,展示了y值如何随设备移动而变化。

请注意,当 x 值为 90 或 -90 时,z 和 y 的数值会围绕同一轴旋转(这是由于运算顺序所致)。在这种情况下,y 旋转角将为 0。
属性文档
[read-only] x : qreal
该属性表示绕 x 轴的旋转角度。
单位为度。
访问函数:
| qreal | x() const |
另请参阅 QRotationReading Units 。
[read-only] y : qreal
该属性表示绕 y 轴的旋转。
单位为度。
访问函数:
| qreal | y() const |
另请参阅 QRotationReading Units 。
[read-only] z : qreal
该属性存储了围绕 z 轴的旋转角度。
单位为度。
访问函数:
| qreal | z() const |
另请参阅 QRotationReading Units 。
© 2026 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.