• Advertisement
Sign in to follow this  

Angular Velocity and Quaternion - problems

This topic is 1732 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 folks,

 

I am new to this gamedev.net forum that I searched for and found.  I searched for angular velocity and quaternion on Google but they did not help so much.  I implemented quaternion and angular velocity control (by using keyboard).  When I pitch to 90 degrees down, I tried to yaw right but it rolls right instead.  At zero Z-axis angle, it normally yaw right or left.  I want to rotate at current local axes, not origin axes.   My code implementation is:

 

dr = (angularVelocity * 0.5) * orientation;

orientation += (dr * dt);

orientation.normalize();

 

Where dt = delta time, dr = delta rotation

 

Does anyone have different angular velocity/quaternion formula to yaw, pitch, and roll at current local axes?

 

Thanks,

Sword7

Share this post


Link to post
Share on other sites
Advertisement

If q_t is the current orientation of the object (the rotation accumulated so far), d the local rotation and x the point you want to transform, then you want to compute qdxd*q* (where quaternion multiplication is denoted by juxtaposition and q* and d* are the conjugate of q and d). You are currently computing instead dqxq*d*. You have to store the current orientation somewhere and multiply the two rotations in the correct order.

Share this post


Link to post
Share on other sites

Ok, I changed that lines to:

 

dr = orientation * (angularVelocity * 0.5) * orientation.conjugate();

orientation += (dr * dt);

 

I resolved a problem but I got another new problem.  For example, When I roll right to 90 degress, tried to yaw right but rotate 45 degrees between pitch and yaw axis.  Also, I continued to play controls, controls became locked out.  I can't yaw, pitch, or roll anymore after a few minutes when w in orentation became zero [ 0 (x, y, z)]. 

 

I tried that 'dr = orientation * angularVelocity * orientation.conjugate()' but it resulted the same.

 

Quaternion<double> conjugate()

{

   return Quaternion<double>(w, -x, -y, -z);

}

 

Right?

 

Thanks!

Sword7

Share this post


Link to post
Share on other sites

Hello folks,

 

Good news!!! I now found a problem and corrected formula. It finally works!!!

 

Quaternion w(0, angularVelocity);

 

dr = 0.5 * (orientation * w);

orientation += (dr * dt);

orentation.normalize();

 

It now rotates in local axes!!

 

If w * orientation, it rotates in world axes.

if orientation * w, it rotates in local axes.

 

I googled and found article that explains about world axes and local axes in quaternions.

 

http://stackoverflow.com/questions/9715776/using-quaternions-for-opengl-rotations

http://www.arcsynthesis.org/gltut/Positioning/Tut08%20Quaternions.html

Share this post


Link to post
Share on other sites

This is actually very easy to prove:

 

dq/dt = 0.5 * w * q // The quaternion time derivative

 

w = q * w' * conjugate( q ) // Here w' is the local angular velocity and we transform it to world space. Now we simply plug this into the equation above

 

dq/dt = 0.5 * ( q * w' * conjugate( q ) ) * q = 0.5 * q * w' 

Share this post


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

  • Advertisement