   How to obtain FRONT, UP vec from yaw pitch roll angles
  hello there,I want to create basic flight sim, but i have a problem with calculating vectors from pitch , roll, yaw angles[media][/media]I use a rotation formula from one of books For non zero CENTER_POINTvoid __fastcall TachoGLModel::RotateModel(int dimension, float angle){int i;t3dpoint p,addme;for (i = 0; i < VBO_V.Length; i++) {  p = vectors_add(VBO_V, reverse_point(CENTER_POINT));    //punkt przeniesiony na srodek bryly   addme = CENTER_POINT;   if (dimension == 0) { //XZ   addme.y = 0.0f;VBO_V.x = cos(angle*imopi)*p.x - sin(angle*imopi)*p.z;VBO_V.z = sin(angle*imopi)*p.x + cos(angle*imopi)*p.z;   }   if (dimension == 1) { //XY   addme.z = 0.0f;VBO_V.x = cos(angle*imopi)*p.x - sin(angle*imopi)*p.y;VBO_V.y = sin(angle*imopi)*p.x + cos(angle*imopi)*p.y;   }   if (dimension == 2) { //ZY   addme.x = 0.0f;VBO_V.z = cos(angle*imopi)*p.z - sin(angle*imopi)*p.y;VBO_V.y = sin(angle*imopi)*p.z + cos(angle*imopi)*p.y;   }VBO_V = vectors_add(VBO_V,addme);//dodaj aby to byla poprawna pozycja}}[/quote]And everything rotates correctly, but when i changed this code i cant calculate proper vectors, I don't know what i am doing wrong:if i rotate model with these angles by glRotate everything works fine - i use:/* XZ */glRotatef(PHYSIC_MODEL->superpointglop,0.0,1.0,0.0); //YAW angle/* ZY */glRotatef(PHYSIC_MODEL->heading,1.0,0.0,0.0);   // PITCH angle/* XY */   glRotatef(PHYSIC_MODEL->glop,0.0,0.0,1.0); // ROLL angleso i know that i must first rotate by ROLL ANGLE, then by PITCH angle and then by YAW angle but the calculations are wrong :Scan anyody help me with calculations?and i almost forgot imopi equals toconst float pi    = 3.1415926535897932384626433832795;const float imopi = 0.017453292519943295769236907684886; => pi / 180.0fvoid __fastcall WATEK_Z_RYSOWANIEM::Draw(){PHYSIC_MODEL->ProcessFrame();glPushMatrix();glLoadIdentity();gluLookAt(kold.x,kold.y,kold.z,kold.x+ksp.x,kold.y-ksp.y,kold.z-ksp.z,0,1,0); glTranslatef(PHYSIC_MODEL->pos.x,PHYSIC_MODEL->pos.y,PHYSIC_MODEL->pos.z); glPushMatrix();/* XZ */glRotatef(PHYSIC_MODEL->superpointglop,0.0,1.0,0.0); //YAW angle/* ZY */glRotatef(PHYSIC_MODEL->heading,1.0,0.0,0.0);   // PITCH angle/* XY */   glRotatef(PHYSIC_MODEL->glop,0.0,0.0,1.0); // ROLL anglePHYSIC_MODEL->FRONT.heading = 0.0f;PHYSIC_MODEL->FRONT.glop    = 0.0f;PHYSIC_MODEL->FRONT.CALCULATE_VEC();PHYSIC_MODEL->UP.heading = 90.0f;PHYSIC_MODEL->UP.glop    = 0.0f;PHYSIC_MODEL->UP.CALCULATE_VEC();PHYSIC_MODEL->RIGHT.heading = 0.0f;PHYSIC_MODEL->RIGHT.glop    = 90.0f;PHYSIC_MODEL->RIGHT.CALCULATE_VEC();//XY -> ZY -> XZfloat angle;//SO THERE IS A PROBLEM---SO THERE IS A PROBLEM---SO THERE IS A PROBLEM---SO THERE IS A PROBLEM---SO THERE IS A PROBLEM---SO THERE IS A PROBLEM- angle = PHYSIC_MODEL->glop;  //rollPHYSIC_MODEL->UP.vec.x = cos(angle*imopi)*PHYSIC_MODEL->UP.vec.x - sin(angle*imopi)*PHYSIC_MODEL->UP.vec.y;PHYSIC_MODEL->UP.vec.y = sin(angle*imopi)*PHYSIC_MODEL->UP.vec.x + cos(angle*imopi)*PHYSIC_MODEL->UP.vec.y;angle = PHYSIC_MODEL->heading; //pitchPHYSIC_MODEL->UP.vec.z = cos(angle*imopi)*PHYSIC_MODEL->UP.vec.z - sin(angle*imopi)*PHYSIC_MODEL->UP.vec.y;PHYSIC_MODEL->UP.vec.y = sin(angle*imopi)*PHYSIC_MODEL->UP.vec.z + cos(angle*imopi)*PHYSIC_MODEL->UP.vec.y;angle = PHYSIC_MODEL->superpointglop; //yawPHYSIC_MODEL->UP.vec.x = cos(angle*imopi)*PHYSIC_MODEL->UP.vec.x - sin(angle*imopi)*PHYSIC_MODEL->UP.vec.z;PHYSIC_MODEL->UP.vec.z = sin(angle*imopi)*PHYSIC_MODEL->UP.vec.x + cos(angle*imopi)*PHYSIC_MODEL->UP.vec.z; angle = PHYSIC_MODEL->glop;//rollPHYSIC_MODEL->FRONT.vec.x = cos(angle*imopi)*PHYSIC_MODEL->FRONT.vec.x - sin(angle*imopi)*PHYSIC_MODEL->FRONT.vec.y;PHYSIC_MODEL->FRONT.vec.y = sin(angle*imopi)*PHYSIC_MODEL->FRONT.vec.x + cos(angle*imopi)*PHYSIC_MODEL->FRONT.vec.y; angle = PHYSIC_MODEL->heading;//pitchPHYSIC_MODEL->FRONT.vec.z = cos(angle*imopi)*PHYSIC_MODEL->FRONT.vec.z - sin(angle*imopi)*PHYSIC_MODEL->FRONT.vec.y;PHYSIC_MODEL->FRONT.vec.y = sin(angle*imopi)*PHYSIC_MODEL->FRONT.vec.z + cos(angle*imopi)*PHYSIC_MODEL->FRONT.vec.y; angle = PHYSIC_MODEL->superpointglop;//yawPHYSIC_MODEL->FRONT.vec.x = cos(angle*imopi)*PHYSIC_MODEL->FRONT.vec.x - sin(angle*imopi)*PHYSIC_MODEL->FRONT.vec.z;PHYSIC_MODEL->FRONT.vec.z = sin(angle*imopi)*PHYSIC_MODEL->FRONT.vec.x + cos(angle*imopi)*PHYSIC_MODEL->FRONT.vec.z; angle = PHYSIC_MODEL->glop;//rollPHYSIC_MODEL->RIGHT.vec.x = cos(angle*imopi)*PHYSIC_MODEL->RIGHT.vec.x - sin(angle*imopi)*PHYSIC_MODEL->RIGHT.vec.y;PHYSIC_MODEL->RIGHT.vec.y = sin(angle*imopi)*PHYSIC_MODEL->RIGHT.vec.x + cos(angle*imopi)*PHYSIC_MODEL->RIGHT.vec.y; angle = PHYSIC_MODEL->heading;//pitchPHYSIC_MODEL->RIGHT.vec.z = cos(angle*imopi)*PHYSIC_MODEL->RIGHT.vec.z - sin(angle*imopi)*PHYSIC_MODEL->RIGHT.vec.y;PHYSIC_MODEL->RIGHT.vec.y = sin(angle*imopi)*PHYSIC_MODEL->RIGHT.vec.z + cos(angle*imopi)*PHYSIC_MODEL->RIGHT.vec.y; angle = PHYSIC_MODEL->superpointglop;//yawPHYSIC_MODEL->RIGHT.vec.x = cos(angle*imopi)*PHYSIC_MODEL->RIGHT.vec.x - sin(angle*imopi)*PHYSIC_MODEL->RIGHT.vec.z;PHYSIC_MODEL->RIGHT.vec.z = sin(angle*imopi)*PHYSIC_MODEL->RIGHT.vec.x + cos(angle*imopi)*PHYSIC_MODEL->RIGHT.vec.z;//SO THERE IS A PROBLEM---SO THERE IS A PROBLEM---SO THERE IS A PROBLEM---SO THERE IS A PROBLEM---SO THERE IS A PROBLEM---SO THERE IS A PROBLEM-glColor3f(1,1,1);model->DrawSimpleModel();glPopMatrix(); glPopMatrix(); glPopMatrix();glPushMatrix(); glBegin(GL_LINES); glColor3f(1.0f,0.0f,0.0f);glVertex3f(0.0f,0.0f,0.0f);    //front glVertex3f(PHYSIC_MODEL->FRONT.vec.x,PHYSIC_MODEL->FRONT.vec.y,PHYSIC_MODEL->FRONT.vec.z); //up glColor3f(0.0f,1.0f,0.0f);glVertex3f(0.0f,0.0f,0.0f);glVertex3f(PHYSIC_MODEL->UP.vec.x,PHYSIC_MODEL->UP.vec.y,PHYSIC_MODEL->UP.vec.z); //right glColor3f(0.0f,0.0f,1.0f);glVertex3f(0.0f,0.0f,0.0f);glVertex3f(PHYSIC_MODEL->RIGHT.vec.x,PHYSIC_MODEL->RIGHT.vec.y,PHYSIC_MODEL->RIGHT.vec.z);glEnd();glPopMatrix();  }[/quote]
  These vectors are just parts (the top-left 3x3 portion) of a rotation matrix for the respective angles, so calculate the rotation matrix and you can pull out the vectors from it.   ;  LOL  man! it works BIG THANKS heres a code for others float rotz[16]; angle = PHYSIC_MODEL->glop; // PITCHPHYSIC_MODEL->PITCH_MATRIX.pointer[0] = cos(angle*imopi);PHYSIC_MODEL->PITCH_MATRIX.pointer[1] = -sin(angle*imopi);PHYSIC_MODEL->PITCH_MATRIX.pointer[2] = 0.0f;PHYSIC_MODEL->PITCH_MATRIX.pointer[3] = 0.0f;PHYSIC_MODEL->PITCH_MATRIX.pointer[4] = sin(angle*imopi);PHYSIC_MODEL->PITCH_MATRIX.pointer[5] = cos(angle*imopi);PHYSIC_MODEL->PITCH_MATRIX.pointer[6] = 0.0f;PHYSIC_MODEL->PITCH_MATRIX.pointer[7] = 0.0f;PHYSIC_MODEL->PITCH_MATRIX.pointer[8] = 0.0f;PHYSIC_MODEL->PITCH_MATRIX.pointer[9] = 0.0f;PHYSIC_MODEL->PITCH_MATRIX.pointer[10] = 1.0f;PHYSIC_MODEL->PITCH_MATRIX.pointer[11] = 0.0f;PHYSIC_MODEL->PITCH_MATRIX.pointer[12] = 0.0f;PHYSIC_MODEL->PITCH_MATRIX.pointer[13] = 0.0f;PHYSIC_MODEL->PITCH_MATRIX.pointer[14] = 0.0f;PHYSIC_MODEL->PITCH_MATRIX.pointer[15] = 1.0f;angle = PHYSIC_MODEL->heading;  //ROLLPHYSIC_MODEL->ROLL_MATRIX.pointer[0] = 1.0f;PHYSIC_MODEL->ROLL_MATRIX.pointer[1] = 0.0f;PHYSIC_MODEL->ROLL_MATRIX.pointer[2] = 0.0f;PHYSIC_MODEL->ROLL_MATRIX.pointer[3] = 0.0f;PHYSIC_MODEL->ROLL_MATRIX.pointer[4] = 0.0f;PHYSIC_MODEL->ROLL_MATRIX.pointer[5] = cos(angle*imopi);PHYSIC_MODEL->ROLL_MATRIX.pointer[6] = -sin(angle*imopi);PHYSIC_MODEL->ROLL_MATRIX.pointer[7] = 0.0f;PHYSIC_MODEL->ROLL_MATRIX.pointer[8] = 0.0f;PHYSIC_MODEL->ROLL_MATRIX.pointer[9] = sin(angle*imopi);PHYSIC_MODEL->ROLL_MATRIX.pointer[10] = cos(angle*imopi);PHYSIC_MODEL->ROLL_MATRIX.pointer[11] = 0.0f;PHYSIC_MODEL->ROLL_MATRIX.pointer[12] = 0.0f;PHYSIC_MODEL->ROLL_MATRIX.pointer[13] = 0.0f;PHYSIC_MODEL->ROLL_MATRIX.pointer[14] = 0.0f;PHYSIC_MODEL->ROLL_MATRIX.pointer[15] = 1.0f;  angle = PHYSIC_MODEL->superpointglop; // YAWPHYSIC_MODEL->YAW_MATRIX.pointer[0] = cos(angle*imopi);PHYSIC_MODEL->YAW_MATRIX.pointer[1] = 0.0f;PHYSIC_MODEL->YAW_MATRIX.pointer[2] = sin(angle*imopi);PHYSIC_MODEL->YAW_MATRIX.pointer[3] = 0.0f;PHYSIC_MODEL->YAW_MATRIX.pointer[4] = 0.0f;PHYSIC_MODEL->YAW_MATRIX.pointer[5] = 1.0f;PHYSIC_MODEL->YAW_MATRIX.pointer[6] = 0.0;PHYSIC_MODEL->YAW_MATRIX.pointer[7] = 0.0f;PHYSIC_MODEL->YAW_MATRIX.pointer[8] = -sin(angle*imopi);PHYSIC_MODEL->YAW_MATRIX.pointer[9] = 0.0f;PHYSIC_MODEL->YAW_MATRIX.pointer[10] = cos(angle*imopi);PHYSIC_MODEL->YAW_MATRIX.pointer[11] = 0.0f;PHYSIC_MODEL->YAW_MATRIX.pointer[12] = 0.0f;PHYSIC_MODEL->YAW_MATRIX.pointer[13] = 0.0f;PHYSIC_MODEL->YAW_MATRIX.pointer[14] = 0.0f;PHYSIC_MODEL->YAW_MATRIX.pointer[15] = 1.0f;//    ZX Y //PITCH -> ROLL -> YAWMatrixMulti4x4(PHYSIC_MODEL->PITCH_MATRIX.pointer,PHYSIC_MODEL->ROLL_MATRIX.pointer,PHYSIC_MODEL->BASE_ROTATION_MATRIX2);MatrixMulti4x4(PHYSIC_MODEL->BASE_ROTATION_MATRIX2.pointer,PHYSIC_MODEL->YAW_MATRIX.pointer,PHYSIC_MODEL->BASE_ROTATION_MATRIX);//PHYSIC_MODEL->UP.vec.x =PHYSIC_MODEL->BASE_ROTATION_MATRIX.pointer[1];PHYSIC_MODEL->UP.vec.y =PHYSIC_MODEL->BASE_ROTATION_MATRIX.pointer[5];PHYSIC_MODEL->UP.vec.z =PHYSIC_MODEL->BASE_ROTATION_MATRIX.pointer[9];PHYSIC_MODEL->UP.vec = vector_multiple(PHYSIC_MODEL->UP.vec,10000.0f);[/quote]