# axis-angle to yaw pitch roll?

## Recommended Posts

Is there any way to get the yaw, pitch and roll components of a rotation matrix (gotten from D3DXMatrixRotationAxis)?

##### Share on other sites
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

##### Share on other sites
Quote:
 Original post by Steve132A 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?

##### Share on other sites
Quote:
 Original post by xytorI 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?

##### Share on other sites
Quote:
Original post by jyk
Quote:
 Original post by xytorI 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.

##### Share on other sites
Quote:
 Original post by xytorObject 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?

##### Share on other sites
Quote:
Original post by jyk
Quote:
 Original post by xytorObject 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 :)

##### Share on other sites
These methods might be useful:
D3DXMatrixRotationX
D3DXMatrixRotationY
D3DXMatrixRotationZ
D3DXMatrixRotationAxis
D3DXMatrixRotationYawPitchRoll

##### Share on other sites
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;}

##### Share on other sites
Quote:
 Original post by DawoodozThese methods might be useful:D3DXMatrixRotationXD3DXMatrixRotationYD3DXMatrixRotationZD3DXMatrixRotationAxisD3DXMatrixRotationYawPitchRoll
The OP was asking how to extract a set of Euler angles from a rotation matrix (which none of the above functions does).

## Create an account

Register a new account

• ### Forum Statistics

• Total Topics
628328
• Total Posts
2982099

• 22
• 9
• 9
• 13
• 11