Sign in to follow this  
ludoz

Rotation matrix

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 this post


Link to post
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 this post


Link to post
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 this post


Link to post
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

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this