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 : const qreal
此属性表示绕 x 轴的旋转角度。
以度为单位。
访问函数:
qreal | x() const |
另请参见 QRotationReading Units 。
[read-only]
y : const qreal
此属性表示绕 Y 轴的旋转角度。
以度为单位。
访问函数:
qreal | y() const |
另请参阅 QRotationReading Units 。
[read-only]
z : const qreal
此属性表示围绕 Z 轴的旋转。
以度为单位。
访问函数:
qreal | z() const |
另请参阅 QRotationReading Units 。
© 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.