Rotate a sphere around two axis separately (with quaternions)

If I rotate each axis separately then my sphere rotates ok, but when i try a combined rotation using both axis the second rotation is not exactly ok.The sphere seems to rotate diagonically. I tried to solve the problem with quaternions…

CreateFromAxisAngle(0.0f,1.0f,0.0f,roty);
MatrixFromQuat(qyMatrix);
glMultMatrixf(qyMatrix);

CreateFromAxisAngle1.0f,0.0f,0.0f,rotx);
MatrixFromQuat(qxMatrix);
glMultMatrixf(qxMatrix);

gluSphere(quadric,0.8f,50,30);

Any suggestions?

Are you loading a new matrix for each sphere?
Could be that your first matrix operations are effecting the second sphere. Make sure you reset the matrix for each operation.

Have you thought about using push/pop matrix to keep the matrix operations sperate?

Originally posted by Puma1140:
[b]If I rotate each axis separately then my sphere rotates ok, but when i try a combined rotation using both axis the second rotation is not exactly ok.The sphere seems to rotate diagonically. I tried to solve the problem with quaternions…

CreateFromAxisAngle(0.0f,1.0f,0.0f,roty);
MatrixFromQuat(qyMatrix);
glMultMatrixf(qyMatrix);

CreateFromAxisAngle1.0f,0.0f,0.0f,rotx);
MatrixFromQuat(qxMatrix);
glMultMatrixf(qxMatrix);

gluSphere(quadric,0.8f,50,30);

Any suggestions?[/b]

This doesn’t work either…do I have to use spherical linear interpolation?