   openGl transformation
  Hello,I'm trying to implement the movement of a tank. I try to rotate the tank and transform it in the rotated direction. But tank rotation and forward movement seems to be unrelated when I run the code.Movement is not in the direction of tanks forward vector but in some other direction. Part of the code is below. What could be wrong ? The rotation code was taken from digiben's camera tutorial. VK_LEFT and VK_RIGHT rotates tank, VK_UP and VK_DOWN moves tank forward and backward.void Application::CheckForMovement(){if(GetKeyState(VK_LEFT)& 0x80){tank_rot-=0.9f;rotateTank(tank_rot,0.0f,1.0f,0.0f);}if(GetKeyState(VK_RIGHT)& 0x80){tank_rot+=0.9f;rotateTank(tank_rot,0.0f,1.0f,0.0f);}if(GetKeyState(VK_UP)& 0x80){moveTank(0.05f);}if(GetKeyState(VK_DOWN)& 0x80){moveTank(-0.05f);}}void Application::rotateTank(float angle,float x, float y, float z){CVector3 vNewView;// Get the view vector (The direction we are facing)CVector3 vView = tankFwd; // Calculate the sine and cosine of the angle oncefloat cosTheta = (float)cos(angle*Pi/180);float sinTheta = (float)sin(angle*Pi/180);// Find the new x position for the new rotated pointvNewView.x  = (cosTheta + (1 - cosTheta) * x * x)* vView.x;vNewView.x += ((1 - cosTheta) * x * y - z * sinTheta)* vView.y;vNewView.x += ((1 - cosTheta) * x * z + y * sinTheta)* vView.z;// Find the new y position for the new rotated pointvNewView.y  = ((1 - cosTheta) * x * y + z * sinTheta)* vView.x;vNewView.y += (cosTheta + (1 - cosTheta) * y * y)* vView.y;vNewView.y += ((1 - cosTheta) * y * z - x * sinTheta)* vView.z;// Find the new z position for the new rotated pointvNewView.z  = ((1 - cosTheta) * x * z - y * sinTheta)* vView.x;vNewView.z += ((1 - cosTheta) * y * z + x * sinTheta)* vView.y;vNewView.z += (cosTheta + (1 - cosTheta) * z * z)* vView.z;// Now we just add the newly rotated vector to our position to set// our new rotated view of our camera.tankFwd.x = vNewView.x;tankFwd.y = vNewView.y;tankFwd.z = vNewView.z;}void Application::moveTank(float speed){CVector3 vVector = tankFwd;vVector = Normalize(vVector);positionTank.x += float(vVector.x) * speed;positionTank.y += float(vVector.y) * speed;positionTank.z += float(vVector.z) * speed;   }void Application::Render(){window.glObject.begin();glMatrixMode(GL_MODELVIEW);glLoadIdentity();gluLookAt(positionCamera.x,positionCamera.y,positionCamera.z,cameraFwd.x,cameraFwd.y,cameraFwd.z,cameraUp.x,cameraUp.y,cameraUp.z);glPushMatrix();glTranslatef(-512.0f,0.0f,-750.0f);glDisable(GL_LIGHTING);Draw_Ground(g_HeightMap);glEnable(GL_LIGHTING);glPopMatrix();glPushMatrix();glTranslatef(positionTank.x,positionTank.y,positionTank.z);glRotatef(tank_rot,0,1,0);Draw_T80();glPopMatrix();glPushMatrix();glTranslatef(positionF15.x,positionF15.y,positionF15.z);glRotatef(f15Yaw,0,1,0);glRotatef(f15Pitch,1,0,0);glRotatef(f15Roll,0,0,1);Draw_F_15();glPopMatrix();window.glObject.end();}   
  I'm not sure about this but i got a feeling that u're doing the rotation wrong.instead of calculating how each rotation effects the point, you rotate each invidual coord (y for example) and then you go for the z and etc.What i think you should do is this Point = rotateion-of-a-point-around-yaxis(Point);Point = rotateion-of-a-point-around-xaxis(Point);Point = rotateion-of-a-point-around-zaxis(Point);because each rotation effects the whole axis of a point.(still, I havent looked up in the rotation code but this seems to me like something you have to change anyway)   ;  Hi,Thanks for your reply. What I'm doing in rotation code is to rotate the view vector around any axis ( x, y or z directions in rotateTank parameters). Here I rotate around y axis (Passing parameter 1 to rotateTank function in CheckForMovement function). Then translate along the new view vector, which is obtained in rotateTank function, by multiplying with a speed factor. Translation takes place in moveTank function which uses the new view vector obtained. y position becomes zero as expected. But x and z coordinates are not correct which creates the problem.Could you explain your code a little bit more in this respect? Thanks in advance.   