# Calculating the pitch and yaw from one vector to another

My co-ordinate system defines y as up and defines yaw as rotation from x in the xy plane.

I have a vector that defines a direction (my target's facing direction).

I have another direction (my camera direction) defined as a pitch and yaw. I can derive a direction vector from this information.

What different ways can I determine the change in yaw and pitch required to make the camera vector point in the same direction as the target vector?

I can project the target vector on the xz plane (in my system, y is up) by removing the y element. Then I can normalize and dot with the x unit vector to get the yaw, but I can't do something similar for pitch since pitch isn't relative to only x or z. (Is that right?)

-
"I have a 4x4 matrix that I derive a vector" is ungrammatical. Do you mean "I have a 4x4 matrix from which I derive a vector" or "I have a 4x4 matrix that I derive from a vector"? Also, why is this matrix $4\times4$? Does it represent an affine transformation? I suspect you'll get more helpful answers if you say more about how this matrix and your coordinate system are defined. –  joriki Oct 16 '11 at 5:32
@joriki: Honestly, I'm not sure. I believe that the matrix represents an affine transformation and the vector that I get from it defines one of the axes after transformation. I thought mentioning the matrix would get me more solutions, but I guess it just obscures my intent, so I've removed it. Are any other clarifications needed? –  idbrii Oct 17 '11 at 22:46