@porfessor chaos
There's a 2d cartesian coordinate system in which 0 degrees is (1,0), 90 is (0,1) 180 is (-1,0) and 270 is (0,-1)
There's the 3d coordinate system that's a little bit different. If we look at the angles opening from 0 to 90 between axes, we have to look at each axis in it's + direction and in order.
So starting with +x in relation to +y, if you are looking straight into the screen, that's the right hand side moving towards the top of the screen. 0 to 90 from +x to +y would be a counter clockwise rotation, just like the 2d coordinate system. That is a rotation around the z axis so we'll consider it a z angle rotation.
Now let's look at +y to +z. Starting from the top of the screen (the y axis), you rotate forward into the screen (the z axis). 0 to 90 from +y to +z is a forward rotation into the screen from top to middle. That's a rotation around the x axis so that would be an xangle rotation.
So the last rotation is from +z and the only axis left is +x (starting over). That's from into the screen then moving to the right. If we looked down at from a birds eye view, that would be a clockwise rotation and opposite to what you'd expect like you describe in your post. So from 0 to 90 from +z to +x is a rotation from the middle to the right. That's a rotation around the y axis, so that is a y angle rotation.
Sin, cos, tan, all work fine. You just have to be sure about the relationship of the values you are supplying.
If you want the 3d angle between two points on the x & z plane for example, remember that the positive direction of the angle between these two axes is clockwise (or a y angle rotation to the right). If the first coordinate is (0,0,0) and the second coordinate is (10,0,5), then the yangle is
slope=(x2-x1)/(z2-z1) = 10/5 = 2
angle=atan(slope) = 63.4 degrees
or the faster way is
angle=atanfull((10-0),(5-0))
Understand the difference between the 3d and the 2d?
Enjoy your day.