Archived

This topic is now archived and is closed to further replies.

_DarkWIng_

Quaternion (look at function)

Recommended Posts

Can someone please give me a function that rotates quaternion so it faces some direction in space. So far I got this but it doesn''t work very well. It starts "shaking" very badly when it should stand still.. kind like pulse effect.. alternating small + and - rotation... void UCamera::SetDirection( const UVector &dir ) { if ( dir.IsZero() == true ) return; UVector adjustVec( dir.x, dir.y, dir.z ); adjustVec.Normalize(); float rotAngle = arccos( (-frontVector) % adjustVec ); // dot product UVector rotAxis = frontVector * adjustVec; // cross product if ( rotAxis.IsZero() == true ) { rotAxis = upVector; } UQuaternion rotQuat; rotQuat.SetAxisAngle( rotAxis.x, rotAxis.y, rotAxis.z, rotAngle ); rotation.PostMultiply( rotQuat ); RebuildVectors(); } There are more worlds than the one that you hold in your hand...

Share this post


Link to post
Share on other sites
sorry I can''t help you with your code, but there''s a new Game Programming Tutorial on NeHe''s site that demonstrates quaternion rotations.


------------------------------------------------------------
Email
Website

"If you try and don''t succeed, destroy all evidence that you tried."
------------------------------------------------------------

Share this post


Link to post
Share on other sites
wojtos: I know alot about quaternion rotations but this tutorial is not exacley the best. I just need this function or someone to tell me what is wrong with mine.

There are more worlds than the one that you hold in your hand...

Share this post


Link to post
Share on other sites