Rotation a 3D frame of a reference to match the X-axis with the direction of a unite vector.

47 Views Asked by At

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.

enter image description here

2

There are 2 best solutions below

2
On

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)$

0
On

I found the correct answer. In reference [1].

It is almost what @of course answered earlier. But they forgot that we need to take an inverse problem:

Once the normal vector has been found, the angles ($\theta_y , \theta_z$) of the orientation are determined by:

\begin{equation} \boldsymbol{T}(\theta_y,\theta_z) \cdot \boldsymbol{n} = [1,0, 0, 0, 0,0]^T \end{equation} This can be rewritten as: \begin{equation} \boldsymbol{T}^{-1}(\theta_y,\theta_z) \cdot [1,0, 0, 0, 0,0]^T =\boldsymbol{n} \end{equation}

rearranging gives: \begin{align} \sin{\theta_y} &= n_z\\ \cos{\theta_y} &= \sqrt{1-\sin^2{\theta_y}}\\ \sin{\theta_z} &= \frac{n_y}{\cos{\theta_y}}\\ \cos{\theta_z} &= \frac{n_x}{\cos{\theta_y}} \end{align}

[1] S. J. Billett and E. F. Toro. Unsplit WAF–Type Schemes for Three Dimensional Hyperbolic Conservation Laws. In Numerical Methods for Wave Propagation. Toro, E. F. and Clarke, J. F. (Editors), pages 75–124. Kluwer Academic Publishers, 1998.