**0**

# Some clarification about inversing rotation only around particular axes

###
#1
Members - Reputation: **200**

Posted 29 June 2014 - 07:53 PM

Thanks in advance.

###
#2
Crossbones+ - Reputation: **19326**

Posted 29 June 2014 - 08:41 PM

But chances are you really don't know what you mean by "the rotation around z-axis", because otherwise you would have described it better.

Perhaps you can back up a little and tell us what you are trying to do.

###
#3
Members - Reputation: **200**

Posted 29 June 2014 - 10:04 PM

Thanks again in advance.

###
#6
Members - Reputation: **200**

Posted 30 June 2014 - 06:38 PM

Actually I have opencv rotation matrix which I need to use for my OpenGL programming.I swapped the rows for columns to get rotation matrix to be used for OpenGL. Now I find the rotation around x axis is inversed. How can I make it correct? I know it is possible to make it correct by manipulating the basis vectors, but I need to know where I am wrong. Please let me know.

How to get the correct rotation matrix from OpenCV to OpenGL? I have posted this topic before but without any clarification.

Please shed some light if you have answer.

###
#7
Moderators - Reputation: **39640**

Posted 30 June 2014 - 08:35 PM

The math behind 3D graphics gets very intense, very quickly. Usually it requires college level math in the topic called linear algebra.

It is certainly possible to do a small amount of 3D graphics programming without understanding the math, but you will have a hard time creating new things.

As a parallel to finding the math online, you can use pre-packaged containers of ingredients that you mix with specified volumes of water or oil to make food products, or you can learn to cook with real ingredients and learn to adjust the recipes to fit your desires.

The transformation between the two is very small, but you need to follow all the steps exactly. You are trying to make a change to a recipe. You can either ask someone else to make an entirely new recipe for you, or you can learn what all the parts do and understand the change you want to make.

If you intend to do anything more than following a few pre-built formulas you will need an understanding of WHY they do what they do. As you have just discovered, when you try to deviate from the easy-bake formula things can go horribly wrong. You need to understand the reasoning behind it before you can make changes. There are a huge number of good books and web sites out there that can teach you the fundamentals of the math.

Check out my book, Game Development with Unity, aimed at beginners who want to build fun games fast.

Also check out my personal website at bryanwagstaff.com, where I occasionally write about assorted stuff.

###
#8
Members - Reputation: **200**

Posted 01 July 2014 - 06:44 PM

Next, Opencv y and z axis need to be reversed too. In order to get back the proper-oriented matrix in OpenGL, I multiplied the matrix with the following unit matrix:

|1 0 0 0|

|0 -1 0 0|

|0 0 -1 0|

|0 0 0 1|

I get the matrix with proper orientation ( I assume), but still with y and z axis vectors reversed. I know if I just inverse the sign of y and z-axis vectors, it will give me the desired result.

My question, what is the standard step of converting an opencv matrix to opengl matrix.

If anyone has done similar work, please let me know.