   Relative Rotation Problem - PLEASE HELP!
Hi - I have asked about this before, but it is REALLY ticking me off, and I need help.   My game engine at the moment can handle Quaternions or Eulers to do rotation, but no matter which system I use, I always run into a problem.   I am trying to make an ship that you fly in space. To pilot this ship, I need to change the rotation of the ship RELATIVE TO IT''S CURRENT ROTATION. That means that when I roll the ship, I want it to roll relative to the direction it is already travelling in.   So, if I am currently pointing (using Euler angles here) 90 degrees up on the X axis (eg. a Pitch of 90, looking straight up the Y axis) and then I try to roll/bank my ship by 20 degrees, I want it to roll AROUND THE CURRENT AXIS OF MY SHIP, not around the original X,Y & Z plane.    If I simply added the euler or quaternion for 0,0,20 (20 degrees around the z axis) then I would spin the wrong way. To make this work, I need to translate the 0,0,20 into something that works using the standard coordinate system. Given that I''m pitched up 90 degrees, to make it roll 20 degrees around RELATIVE TO THE PILOT OF THE SHIP, I actually need to apply this on the ''Y'' axis, not the ''Z''. (eg. 0,20,0).    Is there a way to translate my three angles by the rotation stored in the euler or quaternion? There MUST be a way - it would have to be required in almost every game in existance.    Thanks in advance!  
  opengl or d3d?no matter what, you need the vectors of your ship. the forward vector to roll, the right vector to pitch, the up vector to yaw.in d3d i think you have the matrix for your object anyway and reading one of the first three lines shouldnt be hard.in opengl i still suggest you drop storing angles and then applying all at once with rotate and translate. it wont work, you need the order in which they were applied and that means: input wont change angles, input has to directly change the orientation. im not familiar with quaternions (and as long as i dont have to interpolate rotations i dont see any reason to.. *cough* hope i didnt start a holy war about that).ill just copy a camera class.. drop the setView part and you will have the stuff you need to make a plane or spaceship fly...changed my mind.. to many files and comments.. ill just upload it here:http://festini.device-zero.de/downloads/camera.zip  ;  If you want to rotate around the relative X-axis, take the vector (1,0,0), transform it using the space ship''s worldspace matrix, then rotate around the resultant matrix.~BenDilts( void );  ;  First of all, if you are doing a space-flight sim, then dump the Euler angles now. It is very difficult to avoid gimbal lock if you are using euler angles and the ship is able to have any orientation. Use quaternions or matrices for all computation and convert to euler angles for display only.1. Decide on a base orientation -- for example, the Z axis is forward, the X axis is to the right, and the Y axis is up.2. Represent your orientation as a rotation from the base orientation using a matrix or quaternion. The identity matrix or quat means the base orientation and no rotation.3. To rotate your ship, you multiply the current orientation and the delta rotation to get the new orientation.a. If you transform vertices like this (D3D notation): v'' = vM, then your new orientation is Mnew = M*D because v'' = (vM)*D = v(M*D).b. If you transform vertices like this (OpenGL notation): v'' = Mv, then your new orientation is Mnew = D*M because v'' = D*(Mv) = (D*M)v.  