Quaternion strangeness

kavilimone
Posts: 2
Joined: Thu Nov 18, 2010 2:38 pm

Quaternion strangeness

Post by kavilimone »

I have the following Quaternion(x,y,z,w) = [-0.876204 -0.447583 0.173706 -0.0419935]

If I now do:

Code: Select all

btTransform transform;
transform.setRotation( btQuaternion(-0.0419935,-0.876204,-0.447583,0.173706) ); // because btQuaternion is (w,x,y,z)
std::cout << transform.getRotation().x() << " " << transform.getRotation().y() << " " << transform.getRotation().z() << " " << transform.getRotation().w() << std::endl;
I get:
0.0419935 0.876204 0.447583 -0.173706

Why??
Dominik
Posts: 32
Joined: Fri Dec 19, 2008 2:51 pm

Re: Quaternion strangeness

Post by Dominik »

btQuaternion.h, line 33

Code: Select all

btQuaternion(const btScalar& x, const btScalar& y, const btScalar& z, const btScalar& w)
Why do you think you should pass w first?
kavilimone
Posts: 2
Joined: Thu Nov 18, 2010 2:38 pm

Re: Quaternion strangeness

Post by kavilimone »

ok, thanks, this turns the quaternion into:

0.876204 0.447583 -0.173706 0.0419935

So, all sign are altered, which shouldn't be a problem, because of q==-q.

But why does this change the axes of the corresponding rotation matrix....?