Rotation and Angular Velocity Elementary Problem

Buzzer
Posts: 7
Joined: Mon Feb 05, 2007 6:08 pm

Rotation and Angular Velocity Elementary Problem

Post by Buzzer »

Can someone help me understand what I am doing wrong, it seems so simple...

I use a quaternion to store the current orientation of the object ( relative to the world axes). I use another quaternion to store the angular velocity (right now, a just something I entered in the source). Every frame, I go:

Code: Select all

quaternionRotation += quaternionAngularVelocity * floatFrameTime;
Then I convert the quaternion into a world matrix and render the thing.

But this doesn't work.

I thought the whole advantage of quaternions is that the above line made sense. Can anyone point out what I'm doing wrong (other than being an idiot)?
dog
Posts: 40
Joined: Fri Jul 22, 2005 8:00 pm
Location: Santa Monica

Post by dog »

I think you want:

Code: Select all

quaternionRotation = Normalize(quaternionRotation + quaternionRotation * Quaternion(Vector4(angularVelocity) * (0.5f * floatFrameTime)));
Buzzer
Posts: 7
Joined: Mon Feb 05, 2007 6:08 pm

Post by Buzzer »

This code seems the same, with the exception that:
  • floatFrameTime was changed to 0.5 * floatFrameTime
  • We normalize the quaternion, which I tried and doesn't seem to help.
Dirk Gregorius
Posts: 861
Joined: Sun Jul 03, 2005 4:06 pm
Location: Kirkland, WA

Post by Dirk Gregorius »

For me your code and dogs post don't look the same. I suggest to look at Bullet and see how it works. I think Erwin has two implementations to integrate the angular velocity.
Buzzer
Posts: 7
Joined: Mon Feb 05, 2007 6:08 pm

Post by Buzzer »

Missed the "quaternionRotation *" in "quaternionRotation * Quaternion(Vector4(angularVelocity)"

Thanks dog, it actually works quite well.
Sorry for doubting you.