I previously asked this question the other way around (given the angles of rotation, what are the resulting angles of azimuth and elevation), thinking that it would be simple to reverse it, but it's not. So now my question is what are the angles of rotation needed so that the vector normal to the surface points to a target azimuth and target elevation? It is similar to another question asked, but in my case the first rotation is about the y-axis and the second rotation is about the beam's own axis, as shown in the picture. 
2026-03-27 16:26:55.1774628815
Equation for 2-Axis Rotation to Point to Target Azimuth & Elevation
55 Views Asked by Bumbble Comm https://math.techqa.club/user/bumbble-comm/detail At
1
The first step is to attach a local coordinate frame $O x'y'z'$ to the beam. This coordinate frame and the world coordinate frame share the same origin $O$.
The $Ox'$ axis extends along the length of the beam, and is shown in red, keeping the convention that you used. Similarly the $Oy'$ axis extends in a transverse direction along the width of the beam, and is shown in green as shown in the figure, and finally the $Oz'$ is perpendicular to the surface of the beam, and is shown in blue.
We can assume that initially, before any rotations, the beam's own coordinate frame was oriented along the world coordinate frame. Then three rotations take place. First the beam is rotated about the $z$ axis to a certain angle $\phi$. Secondly the beam is rotated about its own $Oy'$ axis by a negative angle of $(-\theta)$. This will raise its tip. And thirdly and finally, it is rotated about its own $Ox'$ axis by an angle $\Omega$.
The combinations of the three rotations results in the following combinated rotation matrix
$ R = R_{z}(\phi) R_{y}(- \theta) R_{x}(\Omega) $
Plugging in the expressions for $R_z, R_y$ and $R_x$ this becomes
$ R = \begin{bmatrix} c_1 && - s_1 && 0 \\ s_1 && c_1 && 0 \\ 0 && 0 && 1 \end{bmatrix} \begin{bmatrix} c_2 && 0 && - s_2 \\ 0 && 1 && 0 \\ s_2 && 0 && c_2 \end{bmatrix} \begin{bmatrix} 1 && 0 && 0 \\ 0 && c_3 && -s_3 \\ 0 && s_3 && c_3 \end{bmatrix} $
where $c_1 = \cos \phi , s_1 = \sin \phi, c_2 = \cos \theta , s_2 = \sin \theta, c_3 = \cos \Omega , s_3 = \sin \Omega $
Multiplying out these matrices, gives the combined rotation matrix $R$ as
$ R = \begin{bmatrix} c_1 c_2 && -c_1 s_3 s_2 - s_1 c_3 && -c_1 c_3 s_2 + s_1 s_3 \\ s_1 c_2 && -s_1 s_3 s_2 + c_1 c_3 && -s_1 c_3 s_2 - c_1 s_3 \\ s_2 && s_3 c_2 && c_2 c_3 \end{bmatrix} $
The direction of the normal vector to the beam's surface is along its $Oz'$ axis, which in the world coordinates is the third column of the above matrix, i.e.
$ n = \begin{bmatrix} - c_1 c_3 s_2 + s_1 s_3 \\ - s_1 c_3 s_2 - c_1 c_3 \\ c_2 c_3 \end{bmatrix} $
The target angles are an azimuth of $\alpha$ and an elevation of $\varepsilon$, i.e. $n$ is given as follows
$ n = \begin{bmatrix} \cos \varepsilon \cos \alpha \\ \cos \varepsilon \sin \alpha \\ \sin \varepsilon \end{bmatrix} = \begin{bmatrix} n_1 \\ n_2 \\ n_3 \end{bmatrix}$
Therefore, we want to solve the following equations
$ - \cos(\phi) \cos(\Omega) \sin(\theta) + \sin(\phi) \sin(\Omega) = n_1 \tag{1}$
$ - \sin(\phi) \cos(\Omega) \sin(\theta) - \cos(\phi) \cos(\Omega) = n_2 \tag{2}$
$ \cos(\theta) \cos(\Omega) = n_3 \tag{3}$
And it is assumed that $\phi$ is given.
Dividing the last two equations gives us
$ \dfrac{ - \sin(\phi) \sin(\theta) - \cos(\phi) }{\cos( \theta)} = \dfrac{n_2}{n_3} $
Cross-multiplying, we get,
$ - n_3 \sin(\phi) \sin(\theta) - n_3 \cos(\phi) = n_2 \cos(\theta)$
Since $\phi$ is already known, then this equation is of the form
$ A \cos(\theta) + B \sin(\theta) = C $
where
$ A = n_2 $
$ B = n_3 \sin(\phi) $
$ C = - n_3 \cos(\phi) $
And this trigonometric can be easily solved for $\theta$, in closed form.
Once $\theta$ is determined (there can be up to two solutions). Then $\Omega$ can be determined from equation $(3)$.
Appendix:
The two solutions of
$ A \cos(\theta) + B \sin(\theta) = C $
are
$ \theta = \theta_1 \pm \theta_2 $
where
$ \theta_1 = \text{Atan2}( A, B ) $
where $\text{Atan2}$ is the arctangent function with two inputs, it returns the angle $\theta_1$ such that $\cos(\theta_1) = \dfrac{A}{\sqrt{A^2 + B^2}}$ and $\sin(\theta_1) = \dfrac{B}{\sqrt{A^2+B^2}} $. In some implementations, in the various computer languages, the order of the parameter in the parameter list is reversed.
And
$ \theta_2 = \cos^{-1}\left( \dfrac{ C }{\sqrt{A^2 +B^2}}\right) $