Overview
對於任意座標\(S_1=(S_x,S_y,S_z)^T\),繞任意軸線\(\vec{n}=(n_x,n_y,n_z)^T\)旋轉\(\alpha\)度,推導變換矩陣\(R(\vec{n},\alpha)\),使得變換後的座標\(S_2=R(\vec{n},\alpha) \cdot S_1\)
本文使用向量運算,推導該變換矩陣。 注意:軸線經過座標系原點
基本公式
以列向量表示座標,將向量乘法轉換為矩陣乘法:
對於兩個向量點乘:
\[\vec{a} \cdot \vec{b}=a_x\cdot b_x +a_y\cdot b_y +a_z\cdot b_z=\begin{bmatrix}
a_x & a_y & a_z \\
\end{bmatrix} \cdot \begin{bmatrix}
b_x \\
b_y \\
b_z
\end{bmatrix} =A^T \cdot B
\]
對於三個向量點乘:
\[\vec{a} \cdot \vec{b} \cdot \vec{c}=
\begin{bmatrix}
(a_xb_x+a_yb_y+a_zb_z)c_x \\
(a_xb_x+a_yb_y+a_zb_z)c_y \\
(a_xb_x+a_yb_y+a_zb_z)c_z
\end{bmatrix}=\begin{bmatrix}
b_xc_x & b_yc_x & b_zc_x \\
b_xc_y & b_yc_y & b_zc_y \\
b_xc_z & b_yc_z & b_zc_z
\end{bmatrix} \cdot \begin{bmatrix}
a_x \\
a_y \\
a_z
\end{bmatrix}=
\begin{bmatrix}
c_x \\
c_y \\
c_z
\end{bmatrix} \cdot
\begin{bmatrix}
b_x & b_y & b_z \\
\end{bmatrix} \cdot
\begin{bmatrix}
a_x \\
a_y \\
a_z
\end{bmatrix}=CB^TA
\]
對於兩個向量叉乘:
\[\vec{a} \times \vec{b}=
\begin{bmatrix}
\vec{i} & \vec{j} & \vec{k} \\
a_x & a_y & a_z \\
b_x & b_y & b_z \\
\end{bmatrix}=
\begin{bmatrix}
a_y \cdot b_z -a_z \cdot b_y \\
a_z \cdot b_x -a_x \cdot b_z \\
a_x \cdot b_y -a_y \cdot b_x \\
\end{bmatrix} =
\begin{bmatrix}
0 & -a_z & a_y \\
a_z & 0 & -a_x \\
-a_y & a_x & 0 \\
\end{bmatrix} \cdot
\begin{bmatrix}
b_x \\
b_y \\
b_z \\
\end{bmatrix} =A_T \cdot B
\]
對於三個向量叉乘(參考Triple_product):
\[\vec{a} \times \vec{b} \times \vec{c}=\vec{b} \cdot (\vec{a} \cdot \vec{c})-\vec{a} \cdot(\vec{b} \cdot \vec{c})
\]
推導公式
對於原點\(O\)和座標點\(S_2,S_1\),記:
\[\begin{split}
\large \vec{s_1}=S_1-O \\
\large \vec{s_2}=S_2-O
\end{split}
\]
以\(\vec{s_1},\vec{n}\)向量構成平面not, 建立座標系ontb ,分解原向量\(\vec{s_1}=\vec{s_n}+\vec{s_t}\),如下圖:
可以推導基本等式:
\[\large \vec{n} \times \vec{s_1}=\vec{n} \times (\vec{s_n}+\vec{s_t})=\vec{n} \times \vec{s_n}+\vec{n} \times \vec{s_t}=\vec{n} \times \vec{s_t}
\]
\[\large\vec{b}=\frac{\vec{n} \times \vec{s_t}}{\left| {n} \right| \cdot \left| \vec{s_t} \right|} =\frac{\vec{n} \times \vec{s_t}}{\left| \vec{s_t} \right|}
\]
\[\large\vec{t}=\vec{b} \times \vec{n}=\frac{\vec{n} \times \vec{s_t}}{\left| \vec{s_t} \right|} \times \vec{n}
\]
繞軸線\(\vec{n}\)旋轉\(\alpha\)度之後向量\(\vec{s_2}=\vec{s_n}+\vec{s_r}\), 其中\(\vec{s_r}\)為\(\vec{s_t}\)繞旋轉\(\alpha\)度(即$ \left| \vec{s_r} \right| = \left| \vec{s_t} \right| $)
\[\large \vec{s_n}= \left| \vec{s_1} \right| \cdot cos(\theta) \cdot \vec{n}= \frac{\vec{s_1} \cdot \vec{n}}{\left| \vec{n} \right|} \cdot \vec{n}= \vec{s_1} \cdot \vec{n} \cdot \vec{n}
\]
\[\begin{align}
\begin{split}
\large\vec{s_r} &= \left| \vec{s_r} \right| \cdot cos(\alpha) \cdot \vec{t}+\left| \vec{s_r} \right| \cdot sin(\alpha) \cdot \vec{b}\\
\large &= \left| \vec{s_t} \right| \cdot cos(\alpha) \cdot \vec{t}+\left| \vec{s_t} \right| \cdot sin(\alpha) \cdot \vec{b} \\
\large &=\left| \vec{s_t} \right| \cdot cos(\alpha) \cdot \frac{\vec{n} \times \vec{s_t}}{\left| \vec{s_t} \right|} \times \vec{n}+\left| \vec{s_t} \right| \cdot sin(\alpha) \cdot \frac{\vec{n} \times \vec{s_t}}{\left| \vec{s_t} \right|} \\
\large &= cos(\alpha) \cdot\vec{n} \times \vec{s_t} \times \vec{n}+ sin(\alpha) \cdot \vec{n} \times \vec{s_t} \\
\large &= cos(\alpha) \cdot\vec{n} \times \vec{s_1} \times \vec{n}+ sin(\alpha) \cdot \vec{n} \times \vec{s_1} \\
\large &=cos(\alpha) \cdot(\vec{s_1} \cdot(\vec{n} \cdot \vec{n})-\vec{n} \cdot(\vec{s} \cdot \vec{n}))+ sin(\alpha) \cdot \vec{n} \times \vec{s_1} \\
\large &=cos(\alpha) \cdot(\vec{s_1} -\vec{n} \cdot(\vec{s} \cdot \vec{n}))+ sin(\alpha) \cdot \vec{n} \times \vec{s_1} \\
\large &=cos(\alpha) \cdot(\vec{s_1} -\vec{s} \cdot \vec{n}\cdot \vec{n} )+ sin(\alpha) \cdot \vec{n} \times \vec{s_1}
\end{split}
\end{align}
\]
故:
\[\begin{align}
\begin{split}
\large \vec{s_2}=\vec{s_n}+\vec{s_r} &=\vec{s_1} \cdot \vec{n} \cdot \vec{n}+cos(\alpha) \cdot(\vec{s_1} -\large \vec{s} \cdot \vec{n}\cdot \vec{n} )+sin(\alpha) \cdot \vec{n} \times \vec{s_1} \\
\large &=cos(\alpha) \cdot \vec{s_1}+(1-cos(\alpha))(\vec{s} \cdot \vec{n}\cdot \vec{n}) +sin(\alpha) \cdot \vec{n} \times \vec{s_1}\\
\end{split}
\end{align}
\]
將以上向量變換為座標,可以得到等式:
\[\begin{align}
\begin{split}
\large S_2 &=cos(\alpha) \cdot S_1+ (1-cos(\alpha))NN^TS_1+ sin(\alpha) \cdot N_TS_1\\
\large &=(cos(\alpha)I+(1-cos(\alpha)NN^T+sin(\alpha) \cdot N_T)S_1
\end{split}
\end{align}
\]
故:
\[\large R(\vec{n},\alpha)=cos(\alpha)I+(1-cos(\alpha))NN^T+sin(\alpha) \cdot N_T
\]