关于任意角度旋转

参考:http://www.brainm.com/software/pubs/math/Rotation_matrix.pdf

http://ksuweb.kennesaw.edu/~plaval/math4490/rotgen.pdf

二维坐标系旋转

关于任意角度旋转_第1张图片

R\left ( \theta \right )=\begin{bmatrix} cos\theta & -sin\theta \\ sin\theta & cos\theta \end{bmatrix}对应的变换\begin{bmatrix} {x}'\\{y}' \end{bmatrix} = \begin{bmatrix} cos\theta & -sin\theta \\ sin\theta & cos\theta \end{bmatrix} \begin{bmatrix} x\\y \end{bmatrix}

 

 

假定点P是给定的齐次坐标点homogeneous coordinate P=\left ( x, y, z \right ),而关于任一坐标轴旋转得到对应的{P}'=\left ( {x}', {y}', {z}' \right )

1、绕x轴逆时针(沿着x轴看向原点)旋转角度\theta_x{P}'=R_xP,该旋转矩阵R_x为:

R_x = \begin{bmatrix} 1 & 0 & 0 \\0& cos\theta_x & -sin\theta_x \\ 0 & sin\theta_x & cos\theta_x \end{bmatrix}

2、绕y轴逆时针(沿着y轴看向原点)旋转角度\theta_y{P}'=R_yP,该旋转矩阵R_y为:

R_y = \begin{bmatrix} cos\theta_y & 0 & sin\theta_y \\ 0 & 1 & 0 \\ -sin\theta_y & 0 & cos\theta_y \end{bmatrix}

3、绕z轴逆时针(沿着z轴看向原点)旋转角度\theta_z{P}'=R_zP,该旋转矩阵R_z为:

R_z = \begin{bmatrix} cos\theta_z & -sin\theta_z & 0 \\ sin\theta_z & cos\theta_z & 0 \\0 & 0 & 1 \end{bmatrix}

通过原点的任意坐标轴旋转

v=\left ( x,y,z \right )是一个向量

\hat{r}是一个方向向量,也是单位向量,如果不是,就进行归一化

\theta是一个旋转角度

我们把向量v分解成两个分量:一个平行于\hat{r}v_{\parallel },一个垂直于\hat{r}v_{\perp }

v_{\parallel }=comp_{\hat{r}}v=\frac{v\cdot \hat{r}}{\left \| \hat{r} \right \|^2}\hat{r}=\left (v\cdot \hat{r} \right )\hat{r}

v_{\perp }=orth_{\hat{r}}v=v - \left (v\cdot \hat{r} \right )\hat{r}

v = v_{\parallel }+v_{\perp }

对向量v旋转,旋转轴通过原点

T\left ( v \right ) =T\left ( v_{\parallel } + v_{\perp } \right )=T\left ( v_{\parallel } \right )+T\left ( v_{\perp } \right )

T\left ( v_{\parallel} \right ) =v_{\parallel}

T\left ( v \right ) = v_{\parallel }+T\left ( v_{\perp } \right )

在旋转平面的二维基v_{\perp }w

w=\hat{r}\times v_{\perp } =\hat{r}\times v向量叉乘就是垂直于r和v平面的w

T\left ( v_{\perp } \right )=cos\theta v_{\perp } + sin\theta w =cos\theta v_{\perp } + sin\theta \left (\hat{r}\times v \right )

 

T\left ( v \right ) = v_{\parallel }+T\left ( v_{\perp } \right )=\left (v\cdot \hat{r} \right )\hat{r}+cos\theta v_{\perp } + sin\theta \left (\hat{r}\times v \right )=\left (v\cdot \hat{r} \right )\hat{r}+cos\theta \left [ v-\left ( v\cdot \hat{r} \right )\hat{r} \right ] + sin\theta \left (\hat{r}\times v \right )=\left (v\cdot \hat{r} \right )\hat{r}+cos\theta v - cos\theta \left ( v\cdot \hat{r} \right )\hat{r}+ sin\theta \left (\hat{r}\times v \right )=\left (1 - cos\theta \right )\left ( v\cdot \hat{r} \right )\hat{r}+cos\theta v+ sin\theta \left (\hat{r}\times v \right )

我们期望找到变换矩阵的表达式T\left ( v \right )=Rv

如果u=\left ( u_x, u_y, u_z \right )v=\left ( v_x, v_y, v_z \right )

u\times v=\begin{vmatrix} i & j & k\\ u_x & u_y & u_z\\ v_x & v_y & v_z \end{vmatrix} =\begin{bmatrix} u_yv_z -u_zv_y\\u_zv_x -u_xv_z \\ u_xv_y - u_yv_x \end{bmatrix} =\begin{bmatrix} 0 & -u_z & u_y\\ u_z & 0 & -u_x\\ -u_y & u_x & 0 \end{bmatrix}v

u\cdot v=u_xv_x+u_yv_y+u_zv_z

\left (u\cdot v \right )u=\left (u_xv_x+u_yv_y+u_zv_z \right )u =\left (u_xv_x+u_yv_y+u_zv_z \right )\begin{bmatrix} u_x\\ u_y\\ u_z \end{bmatrix}=\begin{bmatrix} u_x^2 & u_xv_y & u_xu_z\\ u_xv_y & u_y^2 &u_yu_z \\ u_xu_z& u_yu_z & u_z^2 \end{bmatrix}v

求解变换矩阵

T\left ( v \right ) =\left (1 - cos\theta \right )\left ( v\cdot \hat{r} \right )\hat{r}+cos\theta v+ sin\theta \left (\hat{r}\times v \right )=\left (1 - cos\theta \right )\begin{bmatrix} u_x^2 & u_xv_y & u_xu_z\\ u_xv_y & u_y^2 &u_yu_z \\ u_xu_z& u_yu_z & u_z^2 \end{bmatrix}v+\begin{bmatrix} 1 & 0 & 0\\ 0 & 1 &0 \\ 0 & 0 & 1 \end{bmatrix} cos\theta v + sin\theta \begin{bmatrix} 0 & -u_z & u_y\\ u_z & 0 & -u_x\\ -u_y & u_x & 0 \end{bmatrix}v= \left \{ \left (1 - cos\theta \right )\begin{bmatrix} u_x^2 & u_xv_y & u_xu_z\\ u_xv_y & u_y^2 &u_yu_z \\ u_xu_z& u_yu_z & u_z^2 \end{bmatrix}+\begin{bmatrix} 1 & 0 & 0\\ 0 & 1 &0 \\ 0 & 0 & 1 \end{bmatrix} cos\theta + sin\theta \begin{bmatrix} 0 & -u_z & u_y\\ u_z & 0 & -u_x\\ -u_y & u_x & 0 \end{bmatrix}\right \}v=\begin{bmatrix} tu_x^2+C & tu_xu_y-Su_z & tu_xu_z+Su_y\\ tu_xu_y+Su_z & tu_y^2+C & tu_yu_z-Su_x \\ tu_xu_z-Su_y &tu_yu_z+Su_x & tu_z^2+C \end{bmatrix}v其中:

\hat{r}=\left ( u_x,u_y,u_z \right )

C=cos\theta

S=sin\theta

t=1-cos\theta

你可能感兴趣的:(rigid,registration,rotation)