I am trying to solve a problem related to computational fluid dynamics. However, I got stuck on a mathematical operation and am unsure how to tackle it. Here is it.
Let $\boldsymbol{n}$ be a unit vector in 3D space with known components. Given the following rotational matrix:
$$ \begin{equation}\begin{gathered} \mathbf{T}=\mathbf{T}(\theta^{(y)},\theta^{(z)})=\mathbf{T}^{(y)}\mathbf{T}^{(z)},\\ \mathbf{T}^{(y)}\equiv\mathbf{T}^{(y)}(\theta^{(y)}) =\begin{bmatrix}\cos\theta^{(y)}&0&\sin\theta^{(y)}\\0&1&0\\-\sin\theta^{(y)}&0&\cos\theta^{(y)}\end{bmatrix},\\ \mathbf{T}^{(z)}\equiv\mathbf{T}^{(z)}(\theta^{(z)}) =\begin{bmatrix}\cos\theta^{(z)}&\sin\theta^{(z)}&0\\-\sin\theta^{(z)}&\cos\theta^{(z)}&0\\0&0&1\end{bmatrix}. \end{gathered}\end{equation} $$
The goal is to find the angles of rotation such that the x-axis of the rotated frame of reference matches the direction of the normal vector.
My question is: How do we define the angles of rotation given only the components of the normal vector?
My trials: I understand this problem in 2D as follows: given the unit vector $\boldsymbol{n} = [n_x, n_y]^T$. to rotate the frame of reference such that the x-axis matches the unit normal vector direction (check the image bellow), we use the following rotational matrix : $$ \begin{equation}\mathbf{T}^{(z)}\equiv\mathbf{T}^{(z)}(\theta^{(z)}) =\begin{bmatrix}\cos\theta^{(z)}&\sin\theta^{(z)}\\-\sin\theta^{(z)}&\cos\theta^{(z)}\end{bmatrix}. \end{equation} $$ It is easy to find in 2d that: $$\boldsymbol{n} = [n_x, n_y]^T = [\cos{\theta}, \sin{\theta}]^T$$
The new frame of reference is now:
\begin{equation}\begin{bmatrix}\hat{x}\\\hat{y}\end{bmatrix} =\begin{bmatrix}n_x&n_y\\-n_y&n_x\end{bmatrix} \, \begin{bmatrix}x\\y\end{bmatrix} \end{equation}
However, I could not find the relation between the component of the normal vector and the rotation angle in 3D.

Let
$T_y = \begin{bmatrix} c_1 && 0 && s_1 \\ 0 && 1 && 0 \\ -s_1 && 0 && c_1 \end{bmatrix} $
where $c_1 = \cos(\theta_y) , s_1 = \sin(\theta_y) $ And let
$T_z = \begin{bmatrix} c_2 && -s_2 && 0 \\ s_2 && c_2 && 0 \\ 0 && 0 && 1 \end{bmatrix} $
where $c_2 = \cos(\theta_z) , s_2 = \sin(\theta_z) $
Then
$T = T_y T_z = \begin{bmatrix} c_1 c_2 && - c_1 s_2&& s_1 \\s_2 && c_2 && 0 \\ -s_1 c_2 && s_1 s_2 && c_1 \end{bmatrix} $
And now given the the unit vector $n = [n_x, n_y, n_z]^T $ , we want
$ \begin{bmatrix} c_1 c_2 \\ s_2 \\ -s_1 c_2 \end{bmatrix} = \begin{bmatrix} n_x \\ n_y \\ n_z \end{bmatrix} $
For the $y$-component of both vectors, we have
$ sin(\theta_z) = n_y $
Hence
$ \theta_z = \sin^{-1}(n_y) $ or $\theta_z = \pi - \sin^{-1}(n_y) $
And from the first and third components, we have
$ \theta_y = \text{atan2} \left( \dfrac{n_x}{\cos(\theta_z) } \ , - \ \dfrac{n_z}{\cos(\theta_z) } \right)$