**0**

# Some clarification about inversing rotation only around particular axes

Started by jenny_wui, Jun 29 2014 07:53 PM

7 replies to this topic

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

Posted 29 June 2014 - 07:53 PM

Suppose, I have a given matrix. I only need to inverse the rotation around z-axis and the rotation around y-axis keeping the rotation around x-axis intact (without any change). I am a bit confused about what changes in unit matrix needed to be done so that if I multiply the given rotation matrix by that unit matrix, I can get the needed transformation.Could anyone give some clarification.

Thanks in advance.

Thanks in advance.

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

Posted 29 June 2014 - 08:41 PM

First you have to define what you mean by "the rotation around z-axis". The answer will probably just contain the algorithm for doing what you want. For instance, if you think of the rotation as being built as the composition of three rotations, first around the x-axis, then around the y-axis and then around the z-axis, the algorithm is to first express the rotation as that type of composition (Google for `rotation matrix to Euler angles', for example), then flip the signs you want, then recompose the rotation matrix.

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.

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 for the reply. I understand you are suggesting to decompose the matrix and then negate the corresponding rotation angle and again build the matrix. Is there any way to get that by multiplying the unit reflection matrix?

Thanks again in advance.

Thanks again in advance.

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

Posted 30 June 2014 - 06:38 PM

Thank you. I am trying to rotate an object by multiplying with a rotation matrix, but can't find it get right. That's why I was asking whether there is any difference getting transformation from basis vectors.

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.

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: **38067**

Posted 30 June 2014 - 08:35 PM

You should probably start by learning a lot of linear algebra.

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.

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

Thanks for the suggestion and sorry for my poor knowledge. Actually I again want to write down some observation. As I said I have an opencv matrix. I would like to convert it to OpenGL matrix. As opencv is row-major, in opengl, I need to store in column-major order. I did that.

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.

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.