# How to convert from left-handed coordinate system to right-handed?

I need to convert coordinates and rotations from left-handed coordinate system (used by Unity) to right-handed (used by camera calib. toolbox in MATLAB\Octave)

While converting point coordinates may be easy, I cannot say the same for rotations. I need rotations in form of 3x3 rotation matrices, not quaternions.

For each object I have

$$t_{left} = \begin{bmatrix} x \\ y \\ z \end{bmatrix}$$ and $$R_{left} = \begin{bmatrix} r11 & r12 & r13 \\ r21 & r22 & r23 \\ r31 & r32 & r33 \end{bmatrix}$$

defined in coordinate frame from the left image. Which transformation should I apply to get $$t_{right}$$ and $$R_{right}$$ in the right coordinate frame?

• Would it help to say that the transformation is given by reflecting across $y=z$? – Toby Mak Oct 20 '18 at 9:25
• @TobyMak, as far as I suppose, this would help for point coordinates, but not for rotations. Correct me please if I'm not true – Simon Oct 20 '18 at 9:27
• The way you've labed your axis makes it look like they are both right handed systems and they treat z as up instead of y in one. You'll need to label axis correctly with respect to sign if you want proper help. – Krupip Apr 19 '19 at 21:03
• @opa, they are labelled absolutely correctly, they come from different software. What I need is a conversion from system from the left to the system on the right. – Simon Apr 20 '19 at 5:57
• @Simon Well they are both the same handed-ness as they are labeled now, so either the labels are wrong with respect to your question or you don't need handed-ness conversions. – Krupip Apr 20 '19 at 18:56

Flip $$y\leftrightarrow z$$, apply the original rotation, flip $$y\leftrightarrow z$$ again. So $$\begin{pmatrix}r11&r12&r13\\r31&r33&r32\\r21&r23&r22\end{pmatrix}$$

• Unfortunately this does not work for me... This is what I have as a source: i.stack.imgur.com/fh2bO.png and this is what I get as a result of this conversion: i.stack.imgur.com/G9vGw.png The objects are rotated in a strange way. Maybe I've implemented something incorrectly? Could you please explain your answer a bit more?.. – Simon Oct 25 '18 at 16:01

Finally I managed to solve this by saving all data in Euler angles in Unity and converting it to Matlab/Octave coordinate system.

$$R_X = rotX(-a_x);$$

$$R_Y = rotY(-a_y);$$

$$R_Z = rotZ(-a_z);$$

$$R = R_Z*R_X*R_Y;$$

$$coords = [x; z; y];$$

The code is here: https://gist.github.com/tushev/b5c162c059b5e1c0011809ae0e871015

You will need Camera Calibration Toolbox by Jean-Yves Bouguet to get it working.

Thanks to everyone for help!