axis-angle to yaw pitch roll?

Started by
8 comments, last by Zakwayda 13 years, 6 months ago
Is there any way to get the yaw, pitch and roll components of a rotation matrix (gotten from D3DXMatrixRotationAxis)?
Advertisement
A rotation matrix is NOT an axis-angle representation. They are two completely different things. Yaw/pitch/roll are known as Euler Angles. Google "Rotation Matrix to Euler Angles" and you'll probably find what you are looking for
Quote:Original post by Steve132
A rotation matrix is NOT an axis-angle representation. They are two completely different things. Yaw/pitch/roll are known as Euler Angles. Google "Rotation Matrix to Euler Angles" and you'll probably find what you are looking for


I am asking if there is a built in function that does that?
Quote:Original post by xytor
I am asking if there is a built in function that does that?
I don't remember the DX math library having such a function (it may though - you can always look through the documentation).

But as always, I'll ask: what do you need the Euler angles for?
Quote:Original post by jyk
Quote:Original post by xytor
I am asking if there is a built in function that does that?
I don't remember the DX math library having such a function (it may though - you can always look through the documentation).

But as always, I'll ask: what do you need the Euler angles for?


Object rotation; I want to rotate an object, but the only interface I'm given is Euler angles. I figure if I can do the axis-angle rotation, and then decompose the matrix, I'll pass the Euler angles down the pipeline.
Quote:Original post by xytor
Object rotation; I want to rotate an object, but the only interface I'm given is Euler angles. I figure if I can do the axis-angle rotation, and then decompose the matrix, I'll pass the Euler angles down the pipeline.
If the DX math library doesn't already have such a function (and if you really have no choice but to use Euler angles), then you may need to write the function yourself. I'd start by searching for 'matrix euler angles conversion' (just make sure when implementing your function that you get the conventions for matrix storage, vector notation, and axis order right).

May I ask what API you're working with that will only accept the rotation in Euler-angle form?
Quote:Original post by jyk
Quote:Original post by xytor
Object rotation; I want to rotate an object, but the only interface I'm given is Euler angles. I figure if I can do the axis-angle rotation, and then decompose the matrix, I'll pass the Euler angles down the pipeline.
If the DX math library doesn't already have such a function (and if you really have no choice but to use Euler angles), then you may need to write the function yourself. I'd start by searching for 'matrix euler angles conversion' (just make sure when implementing your function that you get the conventions for matrix storage, vector notation, and axis order right).

May I ask what API you're working with that will only accept the rotation in Euler-angle form?


Cool, I wrote the function. The angles seem counter-intuitive, but they resolve to the correct rotation, thanks!
The API is a custom framework a friend made :)
These methods might be useful:
D3DXMatrixRotationX
D3DXMatrixRotationY
D3DXMatrixRotationZ
D3DXMatrixRotationAxis
D3DXMatrixRotationYawPitchRoll
Here is the function I wrote, if anybody is interested:

Vec3 rotToEuler(const Mat44& rot){	Vec3 angles;	if(rot._31 != 1 && rot._31 != -1)	{		angles.x = -asin(rot._31);		angles.y = atan2(rot._32/cos(angles.x),rot._33/cos(angles.x));		angles.z = atan2(rot._21/cos(angles.x),rot._11/cos(angles.x));	}	else	{		angles.z = 0;		if(rot._31 == -1)		{			angles.x = PI/2;			angles.y = atan2(rot._12,rot._13);		}		else		{			angles.x = -PI/2;			angles.y = atan2(-rot._12,-rot._13);		}	}	angles *= 180.0f/PI;	return angles;}

Quote:Original post by Dawoodoz
These methods might be useful:
D3DXMatrixRotationX
D3DXMatrixRotationY
D3DXMatrixRotationZ
D3DXMatrixRotationAxis
D3DXMatrixRotationYawPitchRoll
The OP was asking how to extract a set of Euler angles from a rotation matrix (which none of the above functions does).

This topic is closed to new replies.

Advertisement