Convert left handed to right handed coordinates

When working with different 3D applications you might have to convert between left handed and right handed coordinate system from time to time.
The math behind this is quite simple. You have to create an inversion matrix that indicates which axis is inverted in one of the apps.

In the following example we convert coordinates between Maya in Y-UP and Unity in Y-Up.

Looking at the coordinate system in maya and unity you will realise that X-axis is inverted..

In Maya the x axis points in the opposite direction as in unity. This means, when the x translation is positive in Maya, it will be negative in Unity.
For translations this is really simple, you can just invert thethe maya translate X channelbox value to get the correct coordinates for Unity.
But as soon as rotations are in play as well it is not that simple anymore.

Here is how you do it:

– get the matrix of your object (object- or world-space), let’s call it “Mo
– create an inversion matrix “Mi” that looks like this:
   -1, 0, 0, 0
    0, 1, 0, 0
    0, 0, 1, 0
    0, 0, 0, 1

    (note how the x component is inverted)
– get the converted Matrix “Mc” with this formula: Mc = Mi * Mo * Mi

So multiply the Inversion Matrix Mi with the Object Matrix Mo and multiply again with the Inversion Matrix Mi.

It doesn’t matter whether you convert from maya to unity or the other way. The math is the same.
You can always get the coordinates and euler angles from the Matrix easily or use the Matrix directly in your scripts.

Please follow and like:

Leave a comment

Your email address will not be published.