Original Post
Regards, i am using the following function to do Quaternion rotation. i am caling the function twice to do the rotation once aronud the X axis and another around the Y. however, when i excute it and multiply the resultant matrix with the current one, the object drawn on screen keeps rotating around its Y axis not the global one. it works fine in the case of rotating around the global X axis, i dont know why!!! any suggestion??? tahnx in advance void Quaternion(GLfloat X , GLfloat Y , GLfloat Z , GLfloat degree , GLfloat *pMatrix ) { GLfloat w, x, z, y; // convert the degrees to radians GLfloat angle = GLfloat((degree / 180) * 3.14); // calculate the sin( theta / 2) GLfloat result = Math::Sin(angle / 2); // Calcualte the w value by cos( theta / 2 ) w = Math::Cos(angle / 2); // Calculate the x, y and z of the quaternion x = X * result; y = Y * result; z = Z * result; // pMatrix will hold the [16] quaternion matrix if(!pMatrix) return; // First row pMatrix[ 0] = w*w + x*x - y*y - z*z; pMatrix[ 1] = 2 * (x * y + z * w); pMatrix[ 2] = 2 * (x * z - y * w); pMatrix[ 3] = 0; // Second row pMatrix[ 4] = 2 * ( x * y - z * w ); pMatrix[ 5] = w*w - x*x + y*y - z*z; pMatrix[ 6] = 2 * (z * y + x * w ); pMatrix[ 7] = 0; // Third row pMatrix[ 8] = 2 * ( x * z + y * w ); pMatrix[ 9] = 2 * ( y * z - x * w ); pMatrix[10] = w*w - x*x - y*y + z*z; pMatrix[11] = 0; // Fourth row pMatrix[12] = 0; pMatrix[13] = 0; pMatrix[14] = 0; pMatrix[15] = 1; }