Skip to main content
GameDev.net gamedev.net
🔒 Locked

Rotation angle

Started by GeorgeV Aug 10, 2002 at 5:14 AM 6 replies 350+ views
Original Post
GeorgeV
GeorgeV
How can I extract out of the rotation martix the yaw, pitch, roll rotation angle? Thanks: George Varga
Evil Bill
Evil Bill
You can''t.

You can create a matrix from yaw, pitch and roll, but you can''t get YPR from a rotation matrix (unless of course you know 2 of the YPRs)

Steve
DirectX Programmer
Soon to be the new Bill Gates
Member of the Unban Mindwipe Society (UMWS)
GeorgeV
GeorgeV
I use the D3DXQuaternionRotationAxis() for rotation (work fine), because the normal matrix rotation have a "glimbal lock".

Therefore I don''t no, how the yaw,pitch,roll rotation angle.

George Varga
ZeroEffect
ZeroEffect
So you are rotating a point around an arbitry axis. If you know what your axis is and the angle you are moving around it then you know what your yaw, pitch and roll angles are (depending on what the axis is -- X, Y or Z). So in your setup of the quaternion you are giving it the angle.

I may not be understanding what you are asking but I don''t know how you are settin up you rotation matrix without knowing the rotation angles.
Chris Z. GPU FX
GeorgeV
GeorgeV
I rotate the object around the object vDir, vUp and vRight axis. If I rotate the object first around vDir (roll), then the objects UP is not equal with the Y axis UP.

The Code: (yaw, pitch, roll is rotate object only in current frame):

D3DXQuaternionRotationAxis(&pQy,&m_pShip->vUp,m_pShip->yaw );
D3DXQuaternionRotationAxis(&pQp,&m_pShip->vRight,m_pShip->pitch );
D3DXQuaternionRotationAxis(&pQr,&m_pShip->vDir,m_pShip->roll );

George Varga
ZeroEffect
ZeroEffect
Two things:

1) You can simplify your quaternion rotation by using D3DXQuaternionRotationYawPitchRoll( D3DXQUATERNION*, FLOAT, FLOAT, FLOAT ) where the floats are your yaw, pitch and roll respectively. This will leave you with a single quaternion.

2) To change the quaternion into a rotation matrix use:
D3DXMATRIX* D3DXMatrixRotationQuaternion( D3DXMATRIX*, CONST D3DXQUATERNION* )

See the SDK Docs for more info...

I think this is what you were looking for.

Chris Z.
Chris Z. GPU FX
GeorgeV
GeorgeV
I use D3DXQuaternionRotationYawPitchRoll() for camera rotation in world space and I use D3DXQuaternionRotationAxis() the object (ship) rotation in own object world space, where UP,DOWN,... is the objects UP,DOWN,...

George Varga

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.