Question

i have rotationmatrixes in a "selfmade" GL coordinate system, and want to apply them to a collada coordinate system.

I know i need a Matrix to multiply the GL rotations to convert them into the collada coordinate system ( where Z is actually UP). The coordinate systems are shown in the picture here :

enter image description here

i need the conversion from the left system to the right..for more understanding:
ColladaMatrix=GLRotMatrix*NeededMatrix

Does someone know the matrix i need?

Was it helpful?

Solution

I think that you need to multiply by two matrices to change the basis of your rotation matrix.

Indeed, the ColladaMatrix is the one that does ([col] mean in the collada coordinates, [gl] in the GL coordinates)

y[col] = R[col,col] x[col]

but if you want to use the GL matrix, you need to transform the x[col] into GL coordinates, then apply the rotation in the GL basis and finally come back to the Collada coordinates. So

y[col] = B[gl->col] R[gl,gl] B[col->gl] x[col]

So,

R[col,col] = B[gl->col] R[gl,gl] B[col->gl]

and here B[gl->col] and B[col->gl] are the same, so

                  [1 0 0                  [1 0 0
MatrixCollada  =   0 0 1   * MatrixGL *    0 0 1
                   0 1 0]                  0 1 0]

Hope it helps!

Remark: The same happen when diagonalizing a matrix (which is actually a change of basis), you need to pre- and post-multiply the matrix that you want to diagonalize.

Edit: I wrote the two coordinates systems for the matrices, because in general, a matrix can send a vector from a coordinate system to another one. This makes it more clear.

OTHER TIPS

I see, that I misread the part about rotation matrices in your question. I thought you were asking for the rotation matrix, that would convert the GL coordinates into COLLODA coordinates.

These are the matrices that will convert the left system (the one you labeled "GL") to the right system ("COLLADA"):

1 0 0
0 0 1
0 1 0

to convert the other way around you would use the same matrix.

DirectX and many libraries and game engines (not OpenGL) work with left hand rule system, and almost all mathematics models and devices that you will find work with right hand rule, this referred to math cross product of vectors.

That's why there is no possible to convert one system to another throw simple rotations.

You must choose one coord system to work, try to use that will use most, and then make some useful functions to convert to one coord system to another.

For experience I can tell you that quaternions are the best way to void this problems, choosing the correct matrix taking on count the hand system of destiny.

If you have problems with rotation (and you will if you use pitch over 90°), search for gimbal lock, and then use quaternions, that will save a lot of time and effort.

Then look this : Euler to Quaternion, and change sin(x) by -sin(x) to change between one coord system to another.

best regards.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top