Jump to content
  • Advertisement
Sign in to follow this  
NeffWasHere

Euler rotations from matrices: converting between coordinate systems

This topic is 4025 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'm exporting animation from a right-handed coordinate system package as matrix keys. On the import side, I need to extract Euler rotation values which will be interpolated for animation. The import side uses a left handed coordinate system. I'm not very familiar with Euler rotations, and I'm having a really difficult time figuring this out. So, if I just export a frame with no orientations, it exports the identity. Importing this yields the desired result (the alignment is as desired). However, when rotations start, they occur about the wrong axes. For instance, I want rotation about the X-axis in the modeler to result in rotation about the Y-axis. I tried mapping the extracted Euler angles to the appropriate new axes (for instance, putting the X rotation into the Y rotatoin channel, and perhaps negating it), and this worked in general. However, no winding information is recorded with the matrices. So I tried to compare the angles to the previous angles and wind them, but it turns out that Euler angles are a little more complicated than that. I couldn't get it to work. I have access to a lot of math utilities, so if anyone can outline a method for doing this, I would appreciate it. Thanks for your time!

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by NeffWasHere
I'm exporting animation from a right-handed coordinate system package as matrix keys.


Try transposing the matrix - this should change the rotation from right-handed to left-handed (at least, it works converting 3ds Max's right-handed quaternions to left-handed!)

I hate Euler rotations. In fact I'm messing with them right now with an FBX conversion tool. I don't know who the amateur was that decided that Euler would be a good way to express arbitrary rotations, but I have a few choice words to share with him.

Share this post


Link to post
Share on other sites
I was really hopeful that this would be the solution, since the transpose of the identity is still the identity. It just seems to reverse the direction of the rotations. They rotate about the original axes however. It still may be a step in the right direction. Any idea how I can cause the rotations to occur about different axes completely? Thanks!

Share this post


Link to post
Share on other sites
So, I read the original message a little more closely this time. Honestly, I have never seen a game engine or third-party animation system - and I've seen quite a few - do animation with Euler angles. Does Maya/FBX do this... I don't know? I'm not even sure it's possible to do this. Even if you could make it work, what's your plan to prevent Gimbal lock?

I'm afraid that I'm at a loss for a Euler-based solution for you. :(



Share this post


Link to post
Share on other sites
The ironic thing about all this is that the animation is being driven by Euler keys (apparently animators actually prefer that kind of thing, especially with heirarchal objects or something). I'd really like to just export those keys and map them to the correct channels (I hope it would work.. not sure), but I cannot. So the exporter is converting from those keys to the matrix and exporting that. Thanks anyway!

Share this post


Link to post
Share on other sites
Quote:
Original post by NeffWasHere
The ironic thing about all this is that the animation is being driven by Euler keys (apparently animators actually prefer that kind of thing, especially with heirarchal objects or something). I'd really like to just export those keys and map them to the correct channels (I hope it would work.. not sure), but I cannot. So the exporter is converting from those keys to the matrix and exporting that. Thanks anyway!


Well what I think is going on is in some animation packages that use Euler angles, you can specify the the order of the rotations. What's going on is the program is applying these rotations in the specified order and creating a rotation matrix out of it. I am pretty sure that at this point you can not recover the order of the Euler angles from the rotation matrix because you're multiplying three matrices together and you loose the order.


Share this post


Link to post
Share on other sites
I finally got the transformation almost working. I multiply the orientation matrix (R) between the coordinate system conversion matrix (T) and it's transpose (T^) like this: R' = T * R * T^. This will find the orientation transformation relative to the modeling package, but in the imported frame. My current problem is that the Euler key extraction is still giving me problems. Rotation about the X-axis, for example, will yield Euler angles like <24, 180, 180>. I expect this, but now need to figure out how to 'unwind' it so I have an orientation which better matches the previous key (something like <170, 0, 0>) that will interpolate better. I am not aware of how to formally do this. Thanks!

Share this post


Link to post
Share on other sites
What exactly do you mean by "Euler rotations"? If you mean rotation around three axes, there are several ways how to do that. Do you know order of rotations preferred by that import? It looks like that import would like a completely correct finalized data. (no gimbal lock, no floating point errors)

I have on HD 2.5 KB of text about a derivation of CORRECT rotations around three axes. However it's easier to derive it yourself, than try to understand how this could work from detailed equations.

If you know position of the original point, and a rotated point, it's fairly trivial to find minimal amount of rotations (or a sequence of rotations that would minimize floating point error).
In worst case you might build all sets of rotations, and choose the simplest one.


BTW there might be some interesting info: http://www.fastgraph.com/makegames/3Drotation/

Share this post


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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!