• FEATURED

View more

View more

View more

### Image of the Day Submit

IOTD | Top Screenshots

### The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.

# Angular Velocity and Quaternion - problems

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

5 replies to this topic

### #1Sword7  Members

Posted 23 April 2013 - 08:12 PM

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

### #2apatriarca  Members

Posted 24 April 2013 - 01:39 AM

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.

### #3DT....  Members

Posted 24 April 2013 - 01:47 AM

http://www.euclideanspace.com/physics/kinematics/angularvelocity/QuaternionDifferentiation2.pdf

### #4Sword7  Members

Posted 24 April 2013 - 06:09 PM

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

### #5Sword7  Members

Posted 25 April 2013 - 07:04 PM

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

### #6Dirk Gregorius  Members

Posted 26 April 2013 - 11:37 AM

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'

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.