Simple question concering rotation.

Started by
12 comments, last by Paradigm Shifter 11 years ago

So I got it to work in XNA and it works beatifully, however using my own quaternion class or directx's quaternions the spaceship keeps 'flipping over' when you get behind on the Z axis it seems. Is there something specific I'm doing wrong?

my basic algorithm is :

Quaternion q1 = (shipforward, 0.0f)

Quaternion q2 = (shipposition - LookAtPosition, 0.0f)

then get the angular velocity using the method you described. weird thing is it works very well in XNA but trying to port it to my c++ engine keeps bringing this annoying bug.

A reason I thought of is that my division operator is wrong? what is the exact implementation of the division operator here?

Advertisement
I am not sure what (something, 0.0f) means. What is the 0.0f?

0.0f is simply the scalar( I guess real part) of the quaternion.

the f suffix means its a float.

What problems with flipping are you having?

If you set up a quaternion with just a vector part and the w part being 0 you get a 180 degree rotation around the axis specified in the imaginary part... probably not what you want.

If flipping means you interpolate "the long way round" you can get rid of that by doing a dot product (in 4d) of the 2 quaternions and negating one if the dot product is negative.

"Most people think, great God will come from the sky, take away everything, and make everybody feel high" - Bob Marley

This topic is closed to new replies.

Advertisement