# OpenGL OpenGL matrix calculations

This topic is 4913 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Im trying to simulate the way OpenGL handles matrices, namely how at every transformation, the axis are always aligned with the way you are facing (ie. -z is front, +x is right, +y is up). How is this done? I tried using matrices with euler angles, but then i realized that that always rotates around the global axis. So how does OpenGL do its rotations? Does it actually rotate the axis at every rotation, and then use quaternions? Or is there a simpler way? Thanks. edit: hmmm.. after a little more research, it seems that this is exactly euler angles. So then, my implementation of it is somehow wrong. Currently, im taking the rotational matrices and multiplying them together. But it seems that this isnt correct. So what is the correct way to implement euler angles? Thanks. edit2: just to clarify, what im trying to do is so that rotating the point (0,0,-1) 45 degrees about the y axis, and then 45 degrees about the x axis, should result in (-0.5,0.5,-0.5). My current implementation gives me (-0.707,0.5,-0.5). [Edited by - HalcyonX on August 7, 2005 3:16:28 AM]

##### Share on other sites
The OpenGL spec should contain the infomation required, see OpenGL.org for details.

##### Share on other sites
hmmm... i checked out the opengl2.0 spec, and it seems like they're just multiplying the rotation matrices together too. Shouldnt that make it rotate around the global axes then? But how come their glRotate() function works like yaw/pitch/roll?

##### Share on other sites
It does rotate around the axes. But because of how matrix multiplication happens to work, if you call glTranslate, then glRotate, the rotation actually occurs first. So the object will be rotated as if it were at 0,0,0 and _then_ translated to where you specify. Reverse the order of the calls and you'll see it rotate around the axes instead of acting like yaw/pitch/roll.

##### Share on other sites
If you want to seriously handle matrix multiplications see Matrix and Quaternion faqs (remember that the code use the standard notation, GL uses the transposed one!)

See also the OpenGL specifications to see how to handle projection and perspective matrices

• ### What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

• 27
• 16
• 10
• 10
• 11
• ### Forum Statistics

• Total Topics
634101
• Total Posts
3015528
×