How do I swap quaternion rotation coordinates?

Started by
2 comments, last by monkeyman 22 years, 4 months ago
Hey- I'm using quaternions for an animation system..the problem is, the data exported to file appears to be in a different coordinate system than the animation system.. Can I simply swap the vector components of the quaternion?..will that do it?..if that's the case, then the exporter has problems..the only reason I'm dealing with any of this is because the exported data does not appear to be correct..of course, I can't tell by looking at a quaternion if it's right or not, it's only when I see the incorrect rotations occuring that I know something went wrong.. It appears to be a coordinate system discrepancy, which is what led me onto this path into quaternion hell that I am now on.. The only way I can verify what's going on is to convert the quaternions to euler angles, but my x and y transforms appear to be swapped, and no matter how I mix and match I can't get it working.. I tried all combinations of swapping the vector components of the quaternions AND the geometry in all possible coordinate systems, but I can't find the winning combination that produces the correct rotations.. My functions to convert quaternions to euler angles and back are broken in some way(get different results with some quaternions, most are consistent though), otherwise it would be no problem to swap the x and y transforms.. I'm not too worried about those particular functions though, the only reason I'm dealing with that at all is for debugging purposes..of course, if anyone here knows of a guaranteed solid way to convert quats to angles and back I'd love to see it "Like all good things, it starts with a monkey.." Edited by - monkeyman on December 11, 2001 6:53:10 PM
"Like all good things, it starts with a monkey.."
Advertisement
How I did it was to get an axis angle representation of the quaternion (rotation around an arbitary axis), changed the axis, put it back to the quat.

If there is scaling, then you need to get rid of it first.

Ken Shoemake describes a method for Euler Angle Conversion in "Graphics Gems IV".

You can find the article and some sample code in:

http://vered.rose.utoronto.ca/people/david_dir/GEMS/GEMS.html

However I think I found a little bug in the code. The macro EulGetOrd has a couple of o>>1 statements, whereas it should be o=o>>1 .

Also, the sample program converts static angles to a matrix and then back to rotating angles. I don''t know why it does this, because if you want to get the same angles back you should use the same conversion method.

I didn''t really understand the concept of static angles and rotating ones, so I would appreciate a more detailed explanation if someone knows about it.

I hope this helps.
Thanks for the responses

I''m not sure about the static and rotating angles, though, I''ll let you know if I can figure out what that means..

"Like all good things, it starts with a monkey.."
"Like all good things, it starts with a monkey.."

This topic is closed to new replies.

Advertisement