Jump to content
  • Advertisement
Sign in to follow this  
SmartPtr

Calculate Euler Angle for a left-handed coordinate system

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

If you intended to correct an error in the post then please contact us.

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

 

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!