Reputation: 313
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.
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
. How come this is the case ?
Upvotes: 0
Views: 1607
Reputation: 7343
First of all, your pitch seems to rotate around Z, not 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. But once it is applied, pitch rotates around the new Z axis, instead of the original one. If you set yaw=0, you will see that pitch
no longer affects direction.z
(since it is always 0).
Upvotes: 2