Advertisement

Calculate Euler Angle for a left-handed coordinate system

Started by April 19, 2017 10:54 PM
0 comments, last by _WeirdCat_ 7 years, 9 months ago

Hi guys,

I am currently working on a project that requires converting a 3 * 4 OpenCV transform matrix (includes rotation and translation) from a right-handed coordinates system to a left-handed transform matrix. The right-handed coordinates system is an OpenCV camera space where z positive is pointing on the screen, y positive is pointing down and x is pointing to the right. The left-handed coordinates system is the default camera space of Unreal, where the looking direction is x-axis, up is z positive, and y positive is pointing to the right.

I know that flipping the odd number of axes can convert a RHS to a LHS or vice verse. In my code, I flipped the y-axis first. (the second row in this matrix)


TransformMatrix.at<double>(0, 1) *= -1;
TransformMatrix.at<double>(1, 1) *= -1;
TransformMatrix.at<double>(2, 1) *= -1;

And flipped the sign of the y component in the translation part.

And then, I swapped the z axis and y axis in this transform matrix, which is the first row and the third row in the matrix, so that the x is pointing inside the screen and z positive is pointing to the right. Then I swapped the first row and the second row to swap the y axis and the z axis so that the z is pointing up and y positive is pointing to the right. I also swap the position of x, y , z in the translation part accordingly. I also attached a pic that shows the conversion result in this post.

But now I need to get Euler Angles from this left-handed transform matrix. I don't know how to get these values. I found the function that is able to calculate pitch, yaw, roll with a right-handed rotation matrix.

So, can anyone knows how to get the right Euler Angles in this situation or any other ways to get to the same goal?

Thanks,

Zhdn

This topic is closed to new replies.

Advertisement