• Advertisement
Sign in to follow this  

Quaternion handedness

This topic is 4612 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
Advertisement
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
Thanks, it worked! I'd tried it before, but I didn't negate w, which makes quite a difference.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement