PDA

View Full Version : Rotate a sphere around two axis separately (with quaternions)



Puma1140
12-16-2003, 02:26 AM
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?

nexusone
12-16-2003, 04:57 AM
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:
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?

Puma1140
12-16-2003, 06:52 AM
This doesn't work either...do I have to use spherical linear interpolation?