First, my apologies. This question may have been asked many times before but I do not know the correct terms to search on..... and my school trigonometry is many years ago. Pointing me to an appropriate already-answered question would be an ideal solution for me.
I am writing a program to do 3D view from an observer. I want to calculate motion based upon the direction the observer is looking. I currently define this as angle from directly ahead in two planes. Rotation about the x (left-right) axis gives me elevation (elevationRadians), and rotation about y (up-down) axis gives me left-right. Rotation about z never happens.
I need to calculate the change in cartesian coordinates caused by moving D units in the direction of view.
dx = D * cos(elevationRadians)
dy = D * sin(deflectionRadians)
But I now get two components for dz
dz = D * cos(deflectionRadians)
dz = D * sin(elevationRadians)
How should I combine these terms to give realistic movement? Should I add them, average them, or something else? Part of me thinks that simply adding them will give too large a dz. Could someone confirm, deny, or point me to a good resource for this please.......
Edit: rotation about y gives 'deflection..
My axes: x: left -> right, y: down -> up, z: behind -> in front.
Thanks to Andei's amswer which almost worked (I think our axes differed), I wound up with this:
dx = D cos(elevationRadians) cos(deflectionRadians) dy = D sin(elevationRadians) sin(deflectionRadians) dz = D sin(elevationRadians)
which seems to work a lot better than what I had.
What is the mathematical term for what I am trying to do? I need to read some theory preferably at the simple end of the scale.
I think you don't define your axes correctly. You have rotation around $z$, and in the next sentence you say it never happens.
I think you should use polar coordinates. If you call $\theta$ the angle from the vertical direction $z$, $\theta=\pi/2-\text{elevationRadians}$, and $\phi=\text{deflectionRadians}$ is the angle that the projection in the horizontal plane makes with the $x$ axis, you have:$$\begin{align}x&=D\sin\theta\cos\phi\\y&=D\sin\theta\sin\phi\\z&=D\cos\theta\end{align}$$