I've been looking around for a specific formula to create a Unit Vector representing the direction created by a given Pitch/Yaw.

The formula I see commonly is:

Code:

v = [ cos(y)*cos(p), sin(y), cos(y)*sin(p) ]

Where v is the resulting unit vector, y is the yaw and p is the pitch.

However, when plugging in the most simple test angles to make sure it's legitimate, I get a discrepancy. For example:

Code:

pitch = 45.0
yaw = 45.0
v = [ cos(45.0)*cos(45.0), sin(45.0), cos(45.0)*sin(45.0) ]
v = [ 0.7071*0.7071, 0.7071, 0.7071*0.7071 ]
v = [0.5, 0.7071, 0.5]

Obviously the unit vector [0.5, 0.7071, 0.5] does not represent the pitch/yaw of 45.0/45.0 because any vector with orientations of 45 have matching values (i.e [3, 3, 3]).

Is there a standard formula to convert Pitch/Yaw values into a Unit Vector? Am I doing something wrong with the formula above?