Loading

3D空间绕过原点的轴逆时针旋转的矩阵推导

构建出绕轴旋转的情景。

向量v绕轴n 逆时针旋转θ角度后得到向量v',注:n为单位向量。

想要解v', 可以通过向量加法得到。易得v' 在向量n方向的投影 还需要构造一个经过v' 端点 垂直于法线n的平面,在这个平面内,v的端点绕向量n旋转了θ度后 就是v' 的端点 。n与平面的交点为O', 那么再求得V' 端点与O' 点构成的向量 就可以得到v' 了。

定义:

vv_{\bot}v在于n垂直的平面内的投影

vv_{\text{\textbardbl}}v'n上的投影,等价于vn上的投影

vv'_{\bot}v' 在于n垂直的平面内的投影

vv_{\bot}n旋转θ度后得到vv'_{\bot}

想要求得vv'_{\bot},只需要组成一个w,与 n 和 ****vv_{\bot}组成坐标系就可以

w=v×nw = v_{\bot} \times n

那么

v=vcosθ+wsinθv'_{\bot} = v_{\bot}\cos\theta + w\sin\theta

根据上面的定义,求出来vv_{\bot}w,带入公式。

v=(vn)nv_{\text{\textbardbl}} = (v \cdot n)n

v=vv=v(vn)nv_{\bot} = v - v_{\text{\textbardbl}} = v - (v \cdot n)n

w=v×n=(v(vn)n)×n=v×nw = v_{\bot} \times n = (v - (v \cdot n)n) \times n = v\times n

v=vcosθ+wsinθ=(v(vn)n)cosθ+(v×n)sinθv'_{\bot} = v_{\bot}\cos\theta + w\sin\theta = (v - (v \cdot n)n)\cos\theta + (v \times n) \sin \theta

v=v+v=(vn)n+(v(vn)n)cosθ+(v×n)sinθ=vcosθ+(vn)n(1cosθ)+(v×n)sinθv' = v_{\text{\textbardbl}} + v'_{\bot} = (v \cdot n) n + (v - (v \cdot n)n)\cos\theta + (v \times n) \sin \theta = v\cos\theta + (v\cdot n)n(1-\cos\theta) + (v\times n)\sin\theta

将基向量(1, 0, 0), (0, 1, 0), (0, 0 , 1)带入公式分别求得新的基向量,即得旋转矩阵。

v=[ 100]v = \begin {bmatrix}\ 1 \\ 0 \\ 0 \end{bmatrix} ,代入上式得

v=[ 100]cosθ+[ 100][ nxnynz][ nxnynz](1cosθ)+[ 100]×[ nxnynz]sinθv' = \begin {bmatrix}\ 1 \\ 0 \\ 0 \end{bmatrix} \cos\theta + \begin {bmatrix}\ 1& 0 & 0 \end{bmatrix}\begin {bmatrix}\ n_x \\ n_y \\ n_z \end{bmatrix} \begin {bmatrix}\ n_x \\ n_y \\ n_z \end{bmatrix} (1 - \cos \theta) + \begin {bmatrix}\ 1 \\ 0 \\ 0 \end{bmatrix} \times \begin {bmatrix}\ n_x \\ n_y \\ n_z \end{bmatrix} \sin \theta

=[ cosθ00]+[ nx2nxnynxnz](1cosθ)+[ 0nzny]sinθ= \begin {bmatrix}\ \cos\theta \\ 0 \\ 0 \end{bmatrix} + \begin {bmatrix}\ n_x^2 \\ n_xn_y \\ n_xn_z \end{bmatrix} (1 - \cos \theta) + \begin {bmatrix}\ 0 \\ -n_z \\ n_y \end{bmatrix} \sin \theta

=[ nx2(1cosθ)+cosθnxny(1cosθ)nzsinθnxnz(1cosθ)+nysinθ]= \begin {bmatrix}\ n_x^2(1-\cos\theta) + \cos\theta \\ n_xny_(1-\cos\theta) -n_z\sin\theta \\ n_xn_z(1-\cos\theta) + n_y\sin\theta \end{bmatrix}

v=[ 010]v = \begin {bmatrix}\ 0 \\ 1 \\ 0 \end{bmatrix} ,代入上式得

v=[ 010]cosθ+[ 010][ nxnynz][ nxnynz](1cosθ)+[ 010]×[ nxnynz]sinθv' = \begin {bmatrix}\ 0 \\ 1 \\ 0 \end{bmatrix} \cos\theta + \begin {bmatrix}\ 0& 1 & 0 \end{bmatrix}\begin {bmatrix}\ n_x \\ n_y \\ n_z \end{bmatrix} \begin {bmatrix}\ n_x \\ n_y \\ n_z \end{bmatrix} (1 - \cos \theta) + \begin {bmatrix}\ 0 \\ 1 \\ 0 \end{bmatrix} \times \begin {bmatrix}\ n_x \\ n_y \\ n_z \end{bmatrix} \sin \theta

=[ 0cosθ0]+[ nxnyny2nynz](1cosθ)+[ nz0nx]sinθ= \begin {bmatrix}\ 0 \\ \cos\theta \\ 0 \end{bmatrix} + \begin {bmatrix}\ n_xn_y \\ n_y^2 \\ n_yn_z \end{bmatrix} (1 - \cos \theta) + \begin {bmatrix}\ n_z \\ 0 \\ -n_x \end{bmatrix} \sin \theta

=[ nxnz(1cosθ)+nzsinθny2(1cosθ)+cosθnynz(1cosθ)nxsinθ]= \begin {bmatrix}\ n_xn_z(1-\cos\theta) + n_z\sin\theta \\ n_y^2(1-\cos\theta) + \cos\theta \\ n_yn_z(1-\cos\theta) -n_x \sin\theta \end{bmatrix}

v=[ 001]v = \begin {bmatrix}\ 0 \\ 0 \\ 1 \end{bmatrix} ,代入上式得

v=[ 001]cosθ+[ 001][ nxnynz][ nxnynz](1cosθ)+[ 001]×[ nxnynz]sinθv' = \begin {bmatrix}\ 0 \\ 0 \\ 1 \end{bmatrix} \cos\theta + \begin {bmatrix}\ 0& 0 & 1 \end{bmatrix}\begin {bmatrix}\ n_x \\ n_y \\ n_z \end{bmatrix} \begin {bmatrix}\ n_x \\ n_y \\ n_z \end{bmatrix} (1 - \cos \theta) + \begin {bmatrix}\ 0 \\ 0 \\ 1 \end{bmatrix} \times \begin {bmatrix}\ n_x \\ n_y \\ n_z \end{bmatrix} \sin \theta

=[ 00cosθ]+[ nxnznynznz2](1cosθ)+[ nynx0]sinθ= \begin {bmatrix}\ 0 \\ 0 \\ \cos\theta \end{bmatrix} + \begin {bmatrix}\ n_xn_z \\ n_yn_z \\ n_z^2\end{bmatrix} (1 - \cos \theta) + \begin {bmatrix}\ -n_y \\ n_x \\ 0 \end{bmatrix} \sin \theta

=[ nxnz(1cosθ)nysinθnynz(1cosθ)+nxsinθnz2(1cosθ)+cosθ]= \begin {bmatrix}\ n_xn_z(1-\cos\theta) - n_y\sin\theta \\ n_yn_z(1-\cos\theta) +n_x\sin\theta \\ n_z^2(1-\cos\theta) + \cos\theta \end{bmatrix}

所以,旋转矩阵

MR=[ nx2(1cosθ)+cosθnxnz(1cosθ)+nzsinθnxnz(1cosθ)nysinθnxny(1cosθ)nzsinθny2(1cosθ)+cosθnynz(1cosθ)+nxsinθnxnz(1cosθ)+nysinθnynz(1cosθ)nxsinθnz2(1cosθ)+cosθ]M_R = \begin {bmatrix}\ n_x^2(1-\cos\theta) + \cos\theta & n_xn_z(1-\cos\theta) + n_z\sin\theta & n_xn_z(1-\cos\theta) - n_y\sin\theta \\ n_xny_(1-\cos\theta) -n_z\sin\theta & n_y^2(1-\cos\theta) + \cos\theta & n_yn_z(1-\cos\theta) +n_x\sin\theta \\ n_xn_z(1-\cos\theta) + n_y\sin\theta & n_yn_z(1-\cos\theta) -n_x \sin\theta & n_z^2(1-\cos\theta) + \cos\theta \end{bmatrix}

参考

posted @ 2022-01-16 14:58  silence394  阅读(0)  评论(0)    收藏  举报  来源