Sign in to follow this  
xytor

axis-angle to yaw pitch roll?

Recommended Posts

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

Share this post


Link to post
Share on other sites
Steve132    433
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 this post


Link to post
Share on other sites
xytor    136
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?

Share this post


Link to post
Share on other sites
jyk    2094
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?

Share this post


Link to post
Share on other sites
xytor    136
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.

Share this post


Link to post
Share on other sites
jyk    2094
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?

Share this post


Link to post
Share on other sites
xytor    136
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 :)

Share this post


Link to post
Share on other sites
Dawoodoz    461
These methods might be useful:
D3DXMatrixRotationX
D3DXMatrixRotationY
D3DXMatrixRotationZ
D3DXMatrixRotationAxis
D3DXMatrixRotationYawPitchRoll

Share this post


Link to post
Share on other sites
xytor    136
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 this post


Link to post
Share on other sites
jyk    2094
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).

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this