Archived

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

Quaternions and angular velocity

This topic is 5377 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

I am writing a pool simulation game and wish to represent the orientation of my balls using quaternions. Unfortunately I have no idea how to add angular velocities to quaternions and my calculus is pretty poor. I would be most grateful if anyone could offer any advice regarding this subject. I am desperate.

Share this post


Link to post
Share on other sites
if you represent Angular velocity as a AxisAngle ,
in code the Angle is a Len of vector and unit of vector is a rotation Axis



float AVLen = AngularVelocity.len();
float RotAngle = AVLen*DeltaTime;
float SinHRA = (float)sin( RA*0.5f );
float CosHRA = (float)cos( RA*0.5f );
float S = SinHRA/AVLen;
quaternion DeltaOrientation( AngularVelocity.x*S,
AngularVelocity.y*S,
AngularVelocity.z*S,
CosHRA );

Orientation = DeltaOrientation*Orientation;

Share this post


Link to post
Share on other sites
Google "quaternion angular velocity" and you''ll find lots of relevant pages. This article on Gamasutra briefly mentions using quaternions with angular velocity, it''s where I got started a while ago.

Share this post


Link to post
Share on other sites
Thanks,
Both replies are helpful.Though I would like to try and store the angular velocity as a quaternion too. The gamasutra article does mention it but I have no idea how to implement the formula provided to add an angular velocity quaternion to an orientation quaternion (my calculus is awful). Any further help would be most appreciated.

Share this post


Link to post
Share on other sites
Just use some kind of numerical integration, Euler integration if you want to keep it simple. The differential equation is:

dQ/dt = 0.5 * Q * omega

Omega is the angular velocity vector as a quaternion with 0 for the scalar component. Q is the current orientation. Using Euler integration the new orientation Q'' after a time dt is:

Q'' = Q + dQ*dt
Q'' = Q + 0.5 * Q * omega * dt

So do Q * omega as a quaternion multiplication, then do a scalar multiplication of 0.5 * dt. To add that to the current orientation Q just add the individual components, scalar + scalar and vector + vector.

You may have to normalize Q'', I forget, it''s just done like 4d vector normalization.

Share this post


Link to post
Share on other sites