cantrem
cantrem

Reputation: 646

OpenGL rotation vector from matrix

Ok, so here is what I have:

e.g.: if you locally yaw the object by 45 degrees in CCW direction, then

rotMatrix = newRotationZMatrix(45) * rotMatrix;

What I would like to know is what is the best way of getting the global rotation of the object as a vector - generally speaking, how do you get the rotation angles around X,Y and Z from a transformation matrix that contains JUST rotations.

Upvotes: 1

Views: 2533

Answers (2)

Dr. Snoopy
Dr. Snoopy

Reputation: 56407

There are techniques to obtain that, just get the euler angles from a rotation matrix, it involves a bit of math. Here you can read about it.

Upvotes: 2

user464230
user464230

Reputation: 876

I have a similar class. It's one of the most fun part to me work with matrix 3D.

Well, let's to the answer. I'm working with OpenGL ES, so to me performance is a crucial part. I make a routine, test it, test it, stress tests, rebuild whole routine and test, test... until to find the best way to save memory and increase performance.

So, thinking in maximum performance, and if you, like me, have a class to work with matrices, I tell you that the best way to get it is:

• Store the rotation's values in variables before put it in the matrix.

At this way you don't need to perform complex Euler calculations at every time that you want to get these values. The same is true for the scale's values. Just the translations that have separated indexes don't need this.

Upvotes: 0

Related Questions