Skip to main content
GameDev.net gamedev.net
🔒 Locked

How to?

Started by HellRiZZer Feb 27, 2003 at 7:31 PM 5 replies 500+ views
Fantasio
Fantasio
first, Rotation(x,y,z) is useless. you will never need of that.
and scale is the [0][0] [1][1] [2][2] of the matrix and these element of teh matrix is a part of the rotation matrix.
Fantasio
Fantasio
I never needed to do that, but... I think if you convert your matrix in quaternion, you will be able to get what you want.
A quaternion represents an axis in 3-D space and a rotation around that axis.



          
VOID QuaternionFromMatrix( FLOAT& x, FLOAT& y, FLOAT& z, FLOAT& w,
D3DMATRIX& mat )
{
if( mat._11 + mat._22 + mat._33 > 0.0f )
{
FLOAT s = sqrtf( mat._11 + mat._22 + mat._33 + mat._44 );

x = (mat._23-mat._32) / (2*s);
y = (mat._31-mat._13) / (2*s);
z = (mat._12-mat._21) / (2*s);
w = 0.5f * s;
}
}



[edited by - fantasio on February 27, 2003 12:11:34 AM]
Fantasio
Fantasio
What do you want to do with angles?
you will probably need to compute a matrix with your angle and apply the Matrix to some vectors.
SantaClaws
SantaClaws
OpenGL''s matrices are 4x4, and in column order:

[ 0 4 8 12 ]
[ 1 5 9 13 ]
[ 2 6 10 14 ]
[ 3 7 11 15 ]


(0, 1, 2) is the normal pointing right.
(4, 5, 6) is the normal pointing up.
(8, 9, 10) is the normal pointing forward.
(12, 13, 14) is the translation.

At least, IIRC.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.