Calculating the angle towards the z axis given the orthographical angles in the xz and yz planes Please forgive my limited vocabulary, I'm not a math guru (yet) but I'm trying to solve a practical real-life challenge in a 3D scene I'm creating with PovRay.
Given a line going through x=0,y=0,z=0 in 3D Cartesian space.
I know the angles the line has on the xz plane and the yz plane as they would be when viewing them orthographically.
I want to know the angle that the line makes towards the z axis.
I came up with some known points, and an assumption:


*

*When xz=90° and yz=90° then the angle should be 0° (or 180° or 360°).

*When xz=0° and yz=0° then the angle should be 90° (or 270°).

*When xz=-90° and yz=-90° then the angle should be 0° again...

*When xz=45° and yz=0° then the angle should be 45° etc...

*My intuition says that xz=45° and yz=45° should be more than 45°. Slicing a cube from corner to opposite corner, so probably 180 - (inverse tan(0.5/1)) = 153.43°. Not sure if I have that correct though.
I could lay out the known values in a spreadsheet and try to brew a formula averaging the two angles and using a sinus or cosinus to wobble between the extremes, but I'd never know if the intermediate answers would actually be correct. Things also get tricky when x and y go different, I'm not sure where to start, summing them, taking an average or what.
At this point my brain starts running into digression mode, where I cannot concentrate or remember the last step taken... I'm not sure if it's a subconscious panic reaction but it bothers me. Seems like a barrier that prevents me from being as smart as Pythagoras was... How did he overcome that, sorry...
For now I just need a formula, but if someone could add some enlightenment (enable me to reason the formula on my own) that would be super!
 A: I suppose that when you project your line orthographically on the $x,z$ plane and measure the angle in that plane, you are measuring that angle from the $x$ axis;
and likewise you measure the angle in the $y,z$ plane from the $y$ axis.
You know the 3D line goes through $(0,0,0).$
You can easily detect if the line is completely in the $x,y$ plane,
$90$ degrees from the $z$ axis, and in that case you have a solution.
So let's consider just the case where you have looked at the line
and determined it does not lie in the $x,y$ plane.
In that case the line passes through a point somewhere with the coordinates
$(x_1, y_1, 1).$
Projected on the $x,z$ plane, the line passes through $(0,0)$ and $(x_1,1),$
so by making a right triangle with vertices at those two points and
a third vertex at $(x_1,0),$ we can apply the definition of cotangent to this triangle to conclude that if $\theta_{xz}$ is the angle at $(0,0)$
then $\cot \theta_{xz} = x_1.$
Note that $\theta_{xz}$ is the angle you called "xz". So if you know that angle, you can just take its cotangent and you then know $x_1.$
For similar reasons, if $\theta_{yz}$ is the angle you called "yz" in the $y,z$ plane, then $\cot \theta_{yz} = y_1.$
Now that you know the coordinates $x_1$ and $y_1,$ you can construct a right triangle with vertices at $(0,0,0),$ $(x_1, y_1, 1),$ and $(0,0, 1).$
In this triangle, the angle at $(0,0, 1)$ is the right angle,
the side from $(0,0,0)$ to $(x_1, y_1, 1)$ lies along your 3D line,
and the side from $(0,0,0)$ to $(0,0, 1)$ lies along the $z$-axis.
So the angle between your line and the $z$-axis is the angle at $(0,0,0)$ in this triangle.
The two sides of this triangle that meet at $(0,0,0)$ have lengths $1$
(the adjacent side)
and $\sqrt{x_1^2 + y_1^2 + 1}$ (the hypotenuse).
The opposite side has length $\sqrt{x_1^2 + y_1^2}.$
You have several choices regarding which trigonometric formula to apply,
but since you like the inverse tangent, and the tangent is
"opposite divided by adjacent",
you can say that your angle is
$$ \arctan\left(\sqrt{x_1^2 + y_1^2}\right)
 = \arctan\left(\sqrt{\cot^2(\theta_{xz}) + \cot^2(\theta_{yz})}\right). $$
