# 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 on other sites
Quote:
 Original post by RAZORUNREALSo 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 on other sites
Thanks, it worked! I'd tried it before, but I didn't negate w, which makes quite a difference.

## Create an account

Register a new account

• ### Forum Statistics

• Total Topics
628285
• Total Posts
2981836

• 10
• 10
• 10
• 11
• 17