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?

  • $\begingroup$ Would it help to say that the transformation is given by reflecting across $y=z$? $\endgroup$ – Toby Mak Oct 20 '18 at 9:25
  • $\begingroup$ @TobyMak, as far as I suppose, this would help for point coordinates, but not for rotations. Correct me please if I'm not true $\endgroup$ – Simon Oct 20 '18 at 9:27
  • $\begingroup$ 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. $\endgroup$ – Krupip Apr 19 '19 at 21:03
  • $\begingroup$ @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. $\endgroup$ – Simon Apr 20 '19 at 5:57
  • $\begingroup$ @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. $\endgroup$ – 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} $$

  • $\begingroup$ 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?.. $\endgroup$ – 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!


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.