Matt Phillips
04-20-2010, 08:19 AM
Hi,
I'm having difficulty implementing quaternions in Qt using their QQuaternion class, and haven't heard anything back yet from the community boards where I've posted my query. This is my first time trying to use quaternions so I want to see if the issue is just that I don't understand how they're supposed to work. I figured you guys would know.
All I want to do is to rotate a point in 3-space a given angular distance about an axis. So let
vector_pre = (1,0,0);
I.e. the unit vector along the x-axis. Now let's say I want to rotate it 90deg counterclockwise in the x-y plane. To do this, I create the following quaternion:
quat = (90,0,0,1);
The vector component is the unit vector along the z axis, normal to the x-y plane. Then let
vector_post = (quat * vector_pre) * conjugate(quat);
vector_pre gets reinterpreted as a quaternion with scalar part 0, multiplication and conjugacy are as described in Wikipedia. Then my expectation is that
vector_post == (0,1,0);
This is emphatically *not* what I'm getting with the corresponding Qt method (rotatedVector) so I want to see if I am just not understanding things at a basic level. (And it's not a radians vs. degrees issue.) Have I misunderstood the basics? Thank you--
Matt
I'm having difficulty implementing quaternions in Qt using their QQuaternion class, and haven't heard anything back yet from the community boards where I've posted my query. This is my first time trying to use quaternions so I want to see if the issue is just that I don't understand how they're supposed to work. I figured you guys would know.
All I want to do is to rotate a point in 3-space a given angular distance about an axis. So let
vector_pre = (1,0,0);
I.e. the unit vector along the x-axis. Now let's say I want to rotate it 90deg counterclockwise in the x-y plane. To do this, I create the following quaternion:
quat = (90,0,0,1);
The vector component is the unit vector along the z axis, normal to the x-y plane. Then let
vector_post = (quat * vector_pre) * conjugate(quat);
vector_pre gets reinterpreted as a quaternion with scalar part 0, multiplication and conjugacy are as described in Wikipedia. Then my expectation is that
vector_post == (0,1,0);
This is emphatically *not* what I'm getting with the corresponding Qt method (rotatedVector) so I want to see if I am just not understanding things at a basic level. (And it's not a radians vs. degrees issue.) Have I misunderstood the basics? Thank you--
Matt