Jump to content
  • Advertisement
Sign in to follow this  
Xhadow

Quaternion Headache - DX

This topic is 3692 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello, i'd been trying to rotate whit quaternions but im still falling in gimbal lock, i have some questions abaut this...
1.-¿Quaternions work whit acumulative angles?
2.-¿Quaternions can rotate in 3 angles at the same time?
I dont really know the answer of this questions because id never seen an example showing any of those, i alredy know the math behind the quaternions but i guess im coding grong.
void vRotQuat( ... pd3dDevice, ... &matRot, float fRX, float fRY, float fRZ )
{
	D3DXQUATERNION qRot;
	D3DXQuaternionRotationYawPitchRoll( &qRot, D3DXToRadian( fRY ), D3DXToRadian( fRX ), D3DXToRadian( fRZ ) );
	D3DXQuaternionNormalize( &qRot, &qRot );
	D3DXMatrixRotationQuaternion( &matRot, &qRot );

	pd3dDevice->SetTransform( D3DTS_WORLD, &matTemp );
	pd3dDevice->SetStreamSource( 0, lpLineList, sizeof( MYVERTEX ) );
	pd3dDevice->SetVertexShader( D3DFVF_MYVERTEX );
	pd3dDevice->DrawPrimitive( D3DPT_LINELIST, 0, 3 );
}



Anyone know an example doing the same as my questions? in case they can be done... ummm... [Edited by - Xhadow on October 11, 2008 11:39:08 AM]

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by Xhadow
1.-¿Quaternions work whit acumulative angles?
2.-¿Quaternions can rotate in 3 angles at the same time?

A unit quaternion can be interpreted as a rotation around a single axis and by a single angle. Having a (more or less) arbitrary rotation axis at hand is by no means the same as "rotate in 3 angles at the same time".

Several unit quaternions can be combined to represent an overall rotation, similarly to several rotation matrices that are multiplied to yield in an overall rotation matrix. Hence, if you choose to combine 3 rotations, and furthur choose the rotation axes to be those of an Euler rotation, you actually do perform an Euler rotation. That you suffer from gimbal lock isn't a question of the way you _represent_ the rotations but how you combine them.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!