# Converting from Yaw,Pitch,Roll to Vector

I am currently trying to construct a vector in space given yaw, pitch, and roll with the assumption that my ray originates from (0,0,0).

I started by breaking up the problem into 3 sets of triangles by slicing space in 3 ways:

• In the X-Y plane, I concluded that x = sin(yaw) and y = cos(yaw)
• In the Y-Z plane, I determined that y = cos(pitch) and z = sin(pitch)
• In the X-Z plane, I found that x = cos(pitch) and z = sin(pitch)

From this, I arrived at

However, this doesn't seem to satisfy basic tests, such as <1,1,1>, where the Yaw = Pi/4 and the Pitch should be Pi/4, but the formula yields 0.5, 0.5, 0.7, which has a direction vector different than <1,1,1>. Can anyone spot where I messed up? I've been banging my head at this for a while, and I can't seem to resolve where I made an error.

The most obvious reason is that you only have pitch and yaw in your formula. I suppose the $x,z$ plane was supposed to be roll, not pitch.
The second reason is you applied your rotations to two different vectors: in the first two cases you yawed or pitched the vector $(0,1),$ but in the third case you turned the vector $(1,0).$