Quaternion (look at function)

Started by
1 comment, last by _DarkWIng_ 22 years, 2 months ago
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...
You should never let your fears become the boundaries of your dreams.
Advertisement
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."
------------------------------------------------------------
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...
You should never let your fears become the boundaries of your dreams.

This topic is closed to new replies.

Advertisement