<p>I've read multiple tutorials, but I still can't understand how do I properly rotate an object in 3D space on all 3 axis at once. For example, I'd like to give the object a pitch of 60 degrees, yaw of 20 degrees and roll of 70 degrees. <strong>How can I properly do this in OpenGL, preferrably using GLM?</strong></p>

CC BY-SA 4.0
2019-06-17T05:36:32.573Z
"*I'd like to give the object a pitch of 60 degrees, yaw of 20 degrees and roll of 70 degrees.*" Why? Why do you want to do this thing?
Nicol Bolas
CC BY-SA 4.0
2019-06-17T11:17:24.973Z
OpenGL has *nothing* to do with that. GLM might very well regarding the implementation (but in turns has nothing to do with OpenGL either). But ultimately that's a purely mathematic problem, the *practical* implementation of which depends on a lot more things than if you're using GLM. And even the mathematical theory of which depends on a few other unclarities, e.g. what "pitch", "yaw" and "roll" even mean in your context and what *exactly* you want your object to behave like.
Christian Rau
CC BY-SA 4.0
2019-06-17T14:27:12.840Z
@Nicol Bolas Because those are all the three rotation values that an object can take at a time. Such thing is needed for example, in games with planes and helicopters, since they can turn around these 3 axis all at the same time.
John
CC BY-SA 4.0
2019-06-17T17:37:45.717Z
@Nicol Bolas Nevermind, I just realised that the answer is simpler than I first thought. I think that simply creating a rotation matrix for each axis and then multiplying them would do the trick.
John
CC BY-SA 4.0
2019-06-17T17:39:16.987Z
And then you'll be back tomorrow asking about [Gimbal Lock](https://stackoverflow.com/search?q=gimbal+lock) or other similar [Euler angle](https://stackoverflow.com/search?q=Euler+Angle) problems.
Nicol Bolas
CC BY-SA 4.0
2019-06-17T20:15:57.630Z
@Nicol Bolas I've heard about that Gimbal Lock issue. I heard that Quaternions can help fix it, but I'm not sure how to use them yet.
John
<opengl><glm>
How to rotate an object in OpenGL on the X, Y and Z axis on its local coordinates?
John
# How to rotate an object in OpenGL on the X, Y and Z axis on its local coordinates?

(Asked by: username_0 on 2019-06-17)

I've read multiple tutorials, but I still can't understand how do I properly rotate an object in 3D space on all 3 axis at once. For example, I'd like to give the object a pitch of 60 degrees, yaw of 20 degrees and roll of 70 degrees. **How can I properly do this in OpenGL, preferrably using GLM?**

**Tags:** opengl, glm

> **Comments:**
> **username_1**: "*I'd like to give the object a pitch of 60 degrees, yaw of 20 degrees and roll of 70 degrees.*" Why? Why do you want to do this thing?  
> **username_2**: OpenGL has *nothing* to do with that. GLM might very well regarding the implementation (but in turns has nothing to do with OpenGL either). But ultimately that's a purely mathematic problem, the *practical* implementation of which depends on a lot more things than if you're using GLM. And even the mathematical theory of which depends on a few other unclarities, e.g. what "pitch", "yaw" and "roll" even mean in your context and what *exactly* you want your object to behave like.  
> **username_0**: @username_1 Because those are all the three rotation values that an object can take at a time. Such thing is needed for example, in games with planes and helicopters, since they can turn around these 3 axis all at the same time.  
> **username_0**: @username_1 Nevermind, I just realised that the answer is simpler than I first thought. I think that simply creating a rotation matrix for each axis and then multiplying them would do the trick.  
> **username_1**: And then you'll be back tomorrow asking about [Gimbal Lock](https://stackoverflow.com/search?q=gimbal+lock) or other similar [Euler angle](https://stackoverflow.com/search?q=Euler+Angle) problems.  
> **username_0**: @username_1 I've heard about that Gimbal Lock issue. I heard that Quaternions can help fix it, but I'm not sure how to use them yet.  

---

## 0 answers

