Matrix to Euler Angles, for all XYZ.

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
Delee
Posts: 18
Joined: Sat Apr 14, 2007 8:36 am

Matrix to Euler Angles, for all XYZ.

Post by Delee »

Hi everyone. I have been using the following function to convert a rotation along the Y axis to a euler angle.

Code: Select all

vector3df Camera::getRotationDegrees(vector3df rotation) {
	vector3df angle  = vector3df(0.0f, 0.0f, 0.0f);
	vector3df target = vector3df(0, 0, 1);

	matrix4 matrix;
	matrix.setRotationDegrees(rotation); 
	matrix.rotateVect(target);

	angle.Y = atan2f(matrix[8], matrix[10]) * 180 / PI;

	if (angle.Y < 0.0) { angle.Y += 360.0f; }

	return angle;
}
However, I now need a formula to get the angle along the X and Z axis. I profess a distinct lack of understanding when it comes to mathematics, so I cannot even guess at the answer.

I have tried using various combinations of matrix[8], matrix[9] and matrix[10] with the above formula to no avail. I have tried looking on the forums for a formula, but I have only found answers for the Y rotation. Other answers provide all angles, but require a matrix that is formed in a way that is not shown. The way I have listed above does not work with those formulas.

Any help is always appreciated. My thanks!
Post Reply