Convert direction vector to euler angles How do I convert a direction vector to euler angles?
I need to change the position of a character's head in a Java program that I'm writing. The pose of the head uses euler angles. I know the direction vector that it needs to face to.
 A: You need to know not just the direction you want the nose to point, but also the direction you want the ear to point (and I'm assuming you have typical orthonormal right-handed coordinate systems so that the third desired vector would be along the first cross product with the second). That will fully define the desired orientation of the head. With its direction vectors known, construct the rotation matrix by using the direction vectors as columns and then follow the formula here to extract your needed set of Euler angles from that matrix.
A lot of these steps, to be done precisely, require exactly knowing the coordinate conventions of your program, so I cannot provide a detailed list of steps. Regardless, if you are working with 3D graphics, I can't stress enough how important it is for you to learn and understand how rotations are represented in mathematics.
A: Euler angles would traditionally be used to determine the rotations needed to establish the orientation of a three axis local coordinate system. For a single vector, the initial or un-rotated axis needs to be stated. The pose would have associated intrinsic vectors for its local coordinate system. One of them likely establishes the direction that the object is pointing.  If it is the the X axis, then Euler rotations would rotate the X axis in the direction of the desired vector.
Euler single axis-angle data can be determined from a cross product and angle between the two vectors.
Three rotations are not required for a vector. Two rotations, one that establishes a pitch (or altitude) elevation angle, and another to rotate to an azimuth angle (or set a heading), can rotate vector and point it in the direction of another vector. Describing a direction with altitude elevation angle and azimuth is called "horizontal coordinates".
A: Since rotations do not commute, the order of the three rotations matters.  
Two may suffice, but in general three will be given, based on rotating the neck around each of the three coordinate axes.  
Are you sure that the Euler angles show the position of the head in global coordinates?  Or (more common) merely in relation to the next joint down, which is in turn given relative to the joint before that, and so on?
