# Calculate Euler Angle for a left-handed coordinate system

This topic is 595 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

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

1. 1
2. 2
Rutin
16
3. 3
4. 4
5. 5

• 13
• 26
• 10
• 11
• 9
• ### Forum Statistics

• Total Topics
633722
• Total Posts
3013547
×