Sign in to follow this  
RAZORUNREAL

Quaternion handedness

Recommended Posts

I have an interesting problem for you all. I'm trying to load md5 files, but they have a left handed coordinate system. At least they have y and z swapped, I've never been very clear on handedness. Now for the most part this is no problem, I can just swap y and z of all the vectors on load. Where I got stumped is that the quaternions are also affected by handedness. So what I need is some way of swapping y and z for a quaternion. Obviously just swapping the y and z components won't work. What I did try was this:
Quaternion original; //Got from file.
Float3 end = original.Rotate(Float3(1, 0, 0)); //Rotate a vector on the x axis with it.
swap = end.y; //Swap the vectors y and z.
end.y = end.z;
end.z = swap;
Quaternion swapped = QuatDifference(Float3(1, 0, 0), end); //Create quaternion from difference between vector and x axis.

Now that almost worked. Not quite though, it's still a bit off. Anyone know how to do it properly? I'd really appreciate any help, I don't even know what to google.

Share this post


Link to post
Share on other sites
Quote:
Original post by RAZORUNREAL
So what I need is some way of swapping y and z for a quaternion. Obviously just swapping the y and z components won't work.


It should have worked.
I did exactly that in my MDX-models loader, and it went just fine. Only that I had xyz->zxy swap, so it was still the same handedness. As you have the opposite, you need to explicitly negate all angles (w coord) in the quaternions.

As I like to have w nonnegative, I'd prefer negating the axis (xyz coords).

Cheers.
/def

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this