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

6.5k Views Asked by At

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)

enter image description here enter image description here

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?

2

There are 2 best solutions below

0
On BEST ANSWER

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!

1
On

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} $$