In general, one can align a 3D vector $\vec A$ to another 3D vector $\vec B$ by rotating $\vec A$ around the axis $\| \vec A \times \vec B \|$ by the angle $\arccos{(\| \vec A \| \cdot \| \vec B \|)}$.
But what I want to find is the rotation axis and angle to align two (what I call) 3D oriented vectors.
Each oriented vector consists of a pair of regular normalized 3D vectors, describing the head direction and the face direction. Think about a person: the head direction would be the vector from ground towards head, and the face direction would be the vector from head towards the tip of the nose (the two vectors are always perpendicular). For example: (all vectors are direction vectors located around the origin; they're displaced here for better visualization)
^ (A's head)
|
+--> (A's face)
|
|
|
(B's head) <--+--------o
|
V (B's face)
If I rotate $\vec A$ around the axis perpendicular to the screen (as the above formula would, for the head vectors), their faces would not end up looking at the same direction (they'd be looking at opposite directions). But there is an axis that will align both upon rotation. (For the above case, it should be the vector coplanar with the screen, at a 45-degree angle between vectors $\vec A$ and $\vec B$.)
Now, I think there is always such an axis that will align any 3D oriented vector $\vec A$ with any 3D oriented vector $\vec B$ upon rotation. I want to know how to find such axis and the angle to rotate, as to build a rotation matrix or quaternion.