I am assuming that what you want to know are the rotation angles that would be used to perform a Z-Y rotation sequence in order to align a general vector with the Z axis. I will assume that the general vector is defined by it's tail point, P1, and it's head point P2. This vector points from P1 to P2.
The first thing that needs to happen is to translate this vector to the origin. This is done by subtracting the tail from the head, i.e. V = P2 - P1.
We now have a vector V with it's tail at the origin. We will perform a Z rotation through the angle psi which will place the vector in the X-Z plane, as in the first figure, below. The angle of rotation is computed from the X and Y components of the vector using Tan(psi) = -Vy / Vx. Notice in the figure that using a positive value for Vy and the right-hand rule for vector rotation, the rotation angle in the figure is negative, therefore, we put a negative sign on Vy.
With the vector rotated to position (2), it is now in the X-Z plane. Now we want to rotate through the angle theta to align it with the Z axis. The angle theta is calculated according to cos(theta) = -Vz / mag(V). Once again, using the right-hand rule, this is a negative rotation angle.
Best Answer