Applying Angular Velocity to Quaternion problems

Sword7

Active member
Joined
Mar 23, 2008
Messages
176
Reaction score
32
Points
28
Location
Gaithersburg, MD
Hello folks,

I am working on my small program to simulate orbital flight simulator. I implemented angular velocity controls by using keyboard to pitch, yaw, or roll spacecraft. When I pitched down to 90 degrees and then tried to rotate right, spacecraft rolls right instead (origin axes instead of current local axes). I want to control local axes as long as spacecraft points at current Z-axis instead of zero Z-axis origin.

dt = now - lastTime;
dr = (angularVelocity * 0.5) * orientation;
orientation += (dr * dt);
orientation.normalize();

Where:

angularVelocity = relative vector(x, y, z)
orientation = [w (x, y, z)]
dt = delta time
dr = delta rotation

Does anyone know about other method to control in current local axes, not origin axes? For example, I pitch up or down and then yam right or left horizontally.

Update:

I found solution when I googled quaternion and angular velocity. I finally fixed that formula and it now functions correctly.

Correction:

qav = Quaternion(0, av.x, av.y, av.z);
dr = 0.5 * (orientation * qav);

For rotation in world space, use 0.5 * (qav * q)
For rotation in local space, use 0.5 * (q * qav)

Thanks!
Sword7
 
Last edited:
Back
Top