So, I have a Vector3 vector v and I need to get the angle phi (in degrees) between it and the horizon (x,z plane). Obviously the correct way to do it would be to get v projection in x,z plane (Vector2(v.x , v.z)) and then calculate the angle between those 2 vectors.
However, the way I do it right now is:
float phi = Mathf.Asin(v.y / v.magnitude) * Mathf.Rad2Deg;
Height of a right-angle triangle divided by its hypotenuse equals sin of angle at its base. So, the angle at its base equals arcsin of height divided by hypotenuse.
Of course it gives an error when v.magnitude = 0.
So, I am asking, is there any better method of doing this?