简体   繁体   English

俯仰,偏航,横滚计算混乱

[英]Pitch, Yaw, Roll calculation confusion

I am reading the this tutorial and I got a bit confused. 我正在阅读教程,但有些困惑。 Why is the x value changing with the pitch when the pitch is a rotation about the x axis. 当螺距是绕x轴旋转时,为什么x值会随着螺距而变化。

direction.x = cos(glm::radians(pitch)) * cos(glm::radians(yaw));
direction.y = sin(glm::radians(pitch));
direction.z = cos(glm::radians(pitch)) * sin(glm::radians(yaw));

I get how the rest are changing, but not the cos(glm::radians(pitch)) in direction.x . 我知道其余部分的变化方式,但是对direction.xcos(glm::radians(pitch))没有变化。 How come this is the case ? 怎么会这样呢?

First of all, your pitch seems to rotate around Z, not X. 首先,您的音高似乎绕Z旋转,而不是X。

Second, Euler angles are applied sequentially, in this case Yaw is applied first, then Pitch. 其次,依次施加欧拉角,在这种情况下,先施加偏航角,然后施加俯仰角。 So as you noticed, yaw does not affect Y axis, as expected. 因此,正如您所注意到的, yaw不会像预期的那样影响Y轴。 But once it is applied, pitch rotates around the new Z axis, instead of the original one. 但是,一旦应用,俯仰将围绕新的Z轴而不是原始Z轴旋转。 If you set yaw=0, you will see that pitch no longer affects direction.z (since it is always 0). 如果您将yaw = 0设置为零,您将看到pitch不再影响direction.z (因为它始终为0)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM