# Rotation matrix

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

## Recommended Posts

Hello. I have a rotation matrix like this: |X Y Z 0| |X Y Z 0| |X Y Z 0| |0 0 0 1| If i rotate an object around the y axis with a proper matrix, the object rotate clockwise. But the X and Z vectors of the matrix that represent my rotation rotate anti-clockwise! Is that correct ? and why ?

##### Share on other sites
It all depends on what are you expecting to see... In the mirror, left and right are switched, but not up and down ;)

But seriously, I think it may be happening because you expect another coordinate system than your driver. GL uses RH, DX uses LH, which do you?
Change of that kind often results in negated angles for two rotation-planes.
Obviously, since you have only one switched, you have negated the angle yourself for addition. But that's not what you should be concerned of.

First, check out what you generate (vectors, dot products, angles) on the low level. Try to check what values are generated, are the angles really as they should be?
/def

##### Share on other sites
I created a matrix that rotate around Y axis by 90 dregrees:

D3DXMatrixRotationAxis(&matY, D3DX_PI/2);

If i multiply a vector [1,0,0], that lies in the X axis, by this matrix
the vector rotate and goes to [0,0,-1]. I expect that in the same way
the X axis of my matY is [0,0,-1], but [matY._11, matY._21,matY_21]
(the first column of my matrix) is [0,0,1].
The propoer X axis is found in [matY._11, matY._12,matY_13] (the first row of my matrix) !
So, whit d3dx matrix, what is correct to say ? that the axis are found
in the column of the matrix or in the row of the matrix ?

Here http://www.toymaker.info/Games/html/camera.html it says that the axis are found in the column, but this not match
with my test.. am i wrong ?

##### Share on other sites
Hem, I'm a bit confused about what is your matrix and what is DX's matrix i your description. Could you make it more clear?

Another thing, it is a good thing to switch to a vector-based description (and constructors) of a matrix instead of a common m[][]. That way there is no confusion between rows and columns anymore (which I strongly expect it may be the case here).

For comparison, this is my simple camera settings. It's quake-style. Has XZ angle(angle in XZ plane) and Y-angle(looking up/down).
float	cy  = cosf(m_fAngUpY),      sy  = sinf(m_fAngUpY),      cxz = cosf(m_fAngDirXZ),      sxz = sinf(m_fAngDirXZ);      m_VecRight   = xvec( cxz,                           0.0f,                           -sxz ); // X      m_VecUp      = xvec( -sy * sxz,                           cy,                           -sy * cxz ); // Y      m_VecLookDir = xvec( cy * sxz,                           sy,                           cy * cxz ); // Z

1. 1
2. 2
Rutin
18
3. 3
4. 4
5. 5

• 9
• 14
• 9
• 9
• 9
• ### Forum Statistics

• Total Topics
632921
• Total Posts
3009214
• ### Who's Online (See full list)

There are no registered users currently online

×