I need some help with rotating vectors. I'm building a flight simulator and when the plane is rolling left or right I need to rotate the lift vector(up) around the thrust vector(straight out).
I think I have to do it using cos, sin and tan, but not sure how.

read this . the part that talks about “other ways to make a rotation matrix” describe a simple formula for creating a rotation matrix using an arbitrary axis and angle. in your case the axis is thrust. any vector you multiply by this matrix will be rotated accordingly. i’ve done some extra reading and this formula was derived from quaternions, but it’s very easy to use and wrap up into 1 function.

I was wondering if you could just do this with a call to glRotate*(…). I believe that it lets you rotate something around any given axis. So if you had a vector called a and another called b and you want to rotate a around b…can’t you just make the call:

Try using vector addition. Set up unit vectors for each axes x’, y’, z’. A change in roll or rotation about the z’ axes would result in an angular deflection of both x’ and y’ axes. Such that new x’ would have x’ vector + tan(angle) * y’ vector, and new y’ would have y’ vector + tan(angle) * x’ vector. This is for each axes of rotation so if you have rotation about many axes at same time you add them all up. The final normalized unit vectors would give you your transform matrix. In OpenGL the matrix would be:

Sorry for so many edits. Gave too much info the first time around. Angles for flight simulator can be easily derived from the vectors relative to global coordiantes.

[This message has been edited by shinpaughp (edited 01-09-2003).]