Need some clarification on transformation matrices

Hello, I need some clarification on transformation matrices. I have given x ( x1, x2, x3), y (y1, y2, y3) and z (z1, z2, z3) axis basis vectors. Does the required rotation transformation matrix look like this:

|x1 y1 z1 0|
|x2 y2 z2 0|
|x3 y3 z3 0|
|0 0 0 1 |

If I multiply an object by this transformation matrix, I don’t get the required transformation.
Please give some clarification.

Thanks.

Not even close!
And where is the rotation angle?

Take a look at Appendix F of the Red Book, or any other 3D graphics book covering the transformations.

[QUOTE=Lee_Jennifer_82;1260256]Hello, I need some clarification on transformation matrices. I have given x ( x1, x2, x3), y (y1, y2, y3) and z (z1, z2, z3) axis basis vectors. Does the required rotation transformation matrix look like this:

|x1 y1 z1 0|
|x2 y2 z2 0|
|x3 y3 z3 0|
|0 0 0 1 |[/QUOTE]

Yes. This is the UVW-to-XYZ basis transform (where X, Y, and Z are the UVW vectors expressed in the XYZ basis).

Of course if you want the XYZ-to-UVW transform instead, you want the inverse (if your basis is orthonormal, just take the transpose).

(NOTE: I’m using OpenGL column major order in my response above. If you’re using row-major, transpose the above.)

[QUOTE=Dark Photon;1260260]Yes. This is the UVW-to-XYZ basis transform (where X, Y, and Z are the UVW vectors expressed in the XYZ basis).
Of course if you want the XYZ-to-UVW transform instead, you want the inverse (if your basis is orthonormal, just take the transpose).[/QUOTE]

What he said.

I’ sorry for not understanding the question on the first glance and giving a wrong advice. OP called it a rotation matrix, which confused me. It was a model-view matrix defined by the orientation of the local coordinate system.

Thank you all for the reply. Have any one have done matrix transformation from OpenCV to OpenGL? I am doing by multiplying the opencv matrix by the following:

|1 0 0 0|
|0 1 0 0|
|0 0 1 0|
|0 0 0 1|

It makes the y, z axis basis vectors reverse.

Could any one post some reply regarding this? Recently I did some search in the web about transforming opencv matrix to opengl matrix, but didn’t get much information.

Thanks.

[QUOTE=Lee_Jennifer_82;1260294]Thank you all for the reply. Have any one have done matrix transformation from OpenCV to OpenGL? I am doing by multiplying the opencv matrix by the following:

|1 0 0 0|
|0 1 0 0|
|0 0 1 0|
|0 0 0 1|

It makes the y, z axis basis vectors reverse.

Could any one post some reply regarding this? Recently I did some search in the web about transforming opencv matrix to opengl matrix, but didn’t get much information.

Thanks.[/QUOTE]

So sorry for my mistake. The matrix should be as follows:

|1 0 0 0|
|0 -1 0 0|
|0 0 -1 0|
|0 0 0 1|

OpenCV:

OpenGL:

So yep. Negating Y and Z seems to make sense.

Thanks for the provided link. I am clear now about the coordinate systems in opencv and opengl. But the way I could make it work right is as follows:

1)First, post multiply the above mentioned unit matrix ( Y and Z negated) with the opencv matrix, [M’] = [M]*[u];

2)Then, pre-multiply the above-mentioned unit matrix with the result from the above step, [M’’] = [u]*[M’];

I don’t have enough justification why it needs me to work two steps. Only pre-multiplication of the unit matrix with opencv matrix is supposed give the correct result.

Could any one explain a bit or help me identify my mistake.

Thanks

[QUOTE=Lee_Jennifer_82;1260305]…the way I could make it work right is as follows:

1)First, post multiply the above mentioned unit matrix ( Y and Z negated) with the opencv matrix, [M’] = [M]*[u];

2)Then, pre-multiply the above-mentioned unit matrix with the result from the above step, [M’’] = [u]*[M’];

I don’t have enough justification why it needs me to work two steps.[/QUOTE]

It sounds like someone/something is telling you this should be two steps. Who/what is stating that?

You’re saying:

[M’’] = [u][M][u]

where M is an OpenCV matrix and U is a mating transform to convert between GL and CV. It happens to be symmetric so it converts both GL->CV and CV->GL. So:

[GLstuff2] = [M’’] * [GLstuff1]

Inferring from your post, I think we’re just talking about a general formula for plugging an OpenCV matrix into an OpenGL matrix computation. That said, I’ve not worked with OpenCV before.

Hi Dark Photon, thank you very much again for commenting on my post. I know as a newbie, my question my be too simple to ask. We don’t need to consider opencv. Let us consider the two coordinate systems as found in the image attached.

[ATTACH=CONFIG]669[/ATTACH]

I think the first step i.e. ( [M’] = [M]*[u]) converts any object in coordinate system (a) so that it looks with similar orientation in coordinate system (b).

Next step ([M’’] = [u]*[M’]) did conversion so that it matches the coordinate system (b) i.e. opengl coordinate system.

I tried on some simple model and it works. But would be happy to hear further justification from you.

Please help with further comments or suggestions.

I’m sorry. I don’t understand your question.

Sorry for the confusion. Let me try to explain again. Suppose I have a rotation matrix in coordinate system (a). I would like to see it in coordinate system (b) but with same orientation as shown in (a). The first step ( [M’] = [M]*[u]) does this. Am I right?

If I understand your question correctly, yes.