回転行列(3次元)

3次元回転行列も,以下の2次元回転行列と全く同じ方法で導出できます.
【関連記事】

座標軸周りの回転

3次元回転行列($x,y,z$軸周り)
\begin{aligned}
\begin{cases}
\, x\text{軸回り:} &
\begin{pmatrix}
1&0&0\\
0&\cos\theta&-\sin\theta\\
0&\sin\theta&\cos\theta
\end{pmatrix} \\[20pt]
\, y\text{軸回り:} &
\begin{pmatrix}
\cos\theta&0&\sin\theta\\
0&1&0\\
-\sin\theta&0&\cos\theta
\end{pmatrix} \\[20pt]
\, z\text{軸回り:} &
\begin{pmatrix}
\cos\theta&-\sin\theta&0\\
\sin\theta&\cos\theta&0\\
0&0&1
\end{pmatrix}
\end{cases}
\end{aligned}
【導出】
$z$軸周りに$\theta$回転させる場合を考えると,単位ベクトルはそれぞれ以下のように変換されます:
\begin{aligned}
\begin{pmatrix}
1\\
0\\
0
\end{pmatrix}
%
&\overset{\theta\text{回転}}{\longrightarrow}
%
\textcolor{blue}{
\begin{pmatrix}
\cos\theta\\
\sin\theta\\
0
\end{pmatrix}
},\\
%%%%%%%%
\begin{pmatrix}
0\\
1\\
0
\end{pmatrix}
%
&\overset{\theta\text{回転}}{\longrightarrow}
%
\textcolor{red}{
\begin{pmatrix}
-\sin\theta\\
\cos\theta\\
0
\end{pmatrix}
},\\
%%%%%%%%
\begin{pmatrix}
0\\
0\\
1
\end{pmatrix}
%
&\overset{\theta\text{回転}}{\longrightarrow}
%
\textcolor{green}{
\begin{pmatrix}
0\\
0\\
1
\end{pmatrix}
}.
\end{aligned}

したがって,$z$軸周りに$\theta$回転させる3次元回転行列がわかります:

\begin{aligned}
\begin{pmatrix}
\textcolor{blue}{\cos\theta}&\textcolor{red}{-\sin\theta}&\textcolor{green}{0}\\
\textcolor{blue}{\sin\theta}&\textcolor{red}{\cos\theta}&\textcolor{green}{0}\\
\textcolor{blue}{0}&\textcolor{red}{0}&\textcolor{green}{1}
\end{pmatrix}
\end{aligned}

$x$軸,$y$軸周りの回転行列も同じ方法で導出できます.//

任意軸周りの回転(ロドリゲスの回転公式)

任意の軸周りの3次元回転行列(ロドリゲスの回転公式)を導いてみましょう.ベクトル$\boldsymbol{n}$の周りに角度$\theta$回転させる行列は次で与えられます:
ロドリゲスの回転公式(隠れている場合はスクロールで表示)
\begin{aligned}
\begin{pmatrix}
\textcolor{blue}{ \cos\theta+n_x^2(1-\cos\theta)}&\textcolor{red}{n_x n_y(1-\cos\theta)-n_z\sin\theta}&\textcolor{green}{n_z n_x(1-\cos\theta)+n_y\sin\theta}\\
\textcolor{blue}{ n_x n_y(1-\cos\theta)+n_z\sin\theta}&\textcolor{red}{ \cos\theta+n_y^2(1-\cos\theta)}&\textcolor{green}{n_y n_z(1-\cos\theta)-n_x\sin\theta}\\
\textcolor{blue}{ n_z n_x(1-\cos\theta)-n_y\sin\theta}&\textcolor{red}{ n_y n_z(1-\cos\theta)+n_x\sin\theta}&\textcolor{green}{\cos\theta+n_z^2(1-\cos\theta)}
\end{pmatrix}
\end{aligned}
【導出】
任意軸周りの3次元回転(ロドリゲスの回転公式)
任意軸周りの3次元回転(ロドリゲスの回転公式)
上図からベクトル$\boldsymbol{r}$を$\boldsymbol{n}$の周りに$\theta$回転させたベクトルは
\begin{aligned}
\boldsymbol{r}^\prime
=& (\boldsymbol{r}\cdot\boldsymbol{n})\boldsymbol{n}
+\left[\boldsymbol{r}-(\boldsymbol{r}\cdot\boldsymbol{n})\boldsymbol{n}\right]\cos\theta \\
&+\left(\boldsymbol{n}\times\boldsymbol{r}\right)\sin\theta\\
=&\boldsymbol{r}\cos\theta
+\boldsymbol{n}(\boldsymbol{r}\cdot\boldsymbol{n})\left(1-\cos\theta\right) \\
&+\left(\boldsymbol{n}\times\boldsymbol{r}\right)\sin\theta
\end{aligned}
となります.この式で$\boldsymbol{r}=\boldsymbol{e}_x,\boldsymbol{e}_y,\boldsymbol{e}_z$とすれば,単位ベクトルを回転させたベクトルを求めることができます.

ここでは,計算方法の一例を示します.上式の各項は

\begin{aligned}
(\boldsymbol{e}_i\cdot\boldsymbol{n})\boldsymbol{n}
&=n_i\boldsymbol{n}\\
\left(\boldsymbol{n}\times\boldsymbol{e}_l\right)_i
&=\sum_{j,k=1}^3\epsilon_{ijk}n_j\left(\boldsymbol{e}_l\right)_k
=\sum_{j=1}^3\epsilon_{ijl}n_j
\end{aligned}
を用いて計算することができます($\epsilon_{ijk}$は完全反対称テンソル(レビ・チビタ記号)).したがって,$\boldsymbol{r}=\boldsymbol{e}_l$を回転させたベクトルの$i$成分は
\begin{aligned}
&\left[\boldsymbol{e}_l\cos\theta
+\boldsymbol{n}n_l\left(1-\cos\theta\right)
+\left(\boldsymbol{n}\times\boldsymbol{e}_l\right)\sin\theta
\right]_i \\
&=\delta_{il}\cos\theta
+n_in_l\left(1-\cos\theta\right) \\
&\qquad +\sum_{j=1}^3\epsilon_{ijl}n_j \sin\theta
\end{aligned}
となります.これを$\boldsymbol{r}=\boldsymbol{e}_x,\boldsymbol{e}_y,\boldsymbol{e}_z$に対して具体的に書き下せば
\begin{aligned}
\begin{pmatrix}
1\\
0\\
0
\end{pmatrix}
%
&\overset{\theta\text{回転}}{\longrightarrow}
%
\textcolor{blue}{
\begin{pmatrix}
\cos\theta+n_x^2(1-\cos\theta)\\
n_x n_y(1-\cos\theta)+n_z\sin\theta\\
n_z n_x(1-\cos\theta)-n_y\sin\theta
\end{pmatrix}
}\\
%%%%%%%%%%%%%%
\begin{pmatrix}
0\\
1\\
0
\end{pmatrix}
%
&\overset{\theta\text{回転}}{\longrightarrow}
%
\textcolor{red}{
\begin{pmatrix}
n_x n_y(1-\cos\theta)-n_z\sin\theta\\\
\cos\theta+n_y^2(1-\cos\theta)\\
n_y n_z(1-\cos\theta)+n_x\sin\theta
\end{pmatrix}
}\\
%%%%%%%%%%%%%%
\begin{pmatrix}
0\\
0\\
1
\end{pmatrix}
%
&\overset{\theta\text{回転}}{\longrightarrow}
%
\textcolor{green}{
\begin{pmatrix}
n_z n_x(1-\cos\theta)+n_y\sin\theta\\
n_y n_z(1-\cos\theta)-n_x\sin\theta\\
\cos\theta+n_z^2(1-\cos\theta)
\end{pmatrix}
}.
\end{aligned}

こうして計算したベクトルを順に並べると「ロドリゲスの回転公式」が得られます.//