I'm not sure, but I think I've read somewhere that you should do this in 2 steps. First, rotate the vector to face the front. (atan2 x,z) That is the first angle. Then get the second angle (atan x,y)
Inversed you can so something similair to this:
x# = cos(ang1) * cos(ang2)
y# = cos(ang1) * sin(ang2)
z# = sin(ang1)
Inversed you can so something similair to this:
x# = cos(ang1) * cos(ang2)
y# = cos(ang1) * sin(ang2)
z# = sin(ang1)