Rotating airplane

Hi,

I have a problem with drawing an airplane in my OpenGL application. I know the orientation of the airplane from two vectors: One vector that is parallell to the body of the airplane, pointing forward, and one vector pointing straight up through the “roof” of the airplane. To draw my airplane-model I want to rotate to match the object-space defined by the two vectors, but I don’t know how to do it. Any help would be appreciated.

Thanks.

Well, you have the perfect data for getting the orientation of your air plane. Basically you have 2 of 3 components of an orientation matrix. You have the Z and Y so you simply need to find the X by doing a cross product.

Z = Forward Normal
Y = Up Normal
X = Y cross Z

Where the actual cross product would look like…
X.x = Y.y * Z.z - Y.z * Z.y
X.y = Y.z * Z.x - Y.x * Z.z
X.z = Y.x * Z.y - Y.y * Z.x

Then to render the plane, you can simply call glMultMatrix in OpenGL and send it a pointer to your column major 4x4 matrix data.

If you have not already, I would invest some time in creating a reasonable vector library or finding an existing one.

That did the job! Thanks!