Sign in to follow this  
Xhadow

Quaternion Headache - DX

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
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

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