T r a n s l a t i o n t x , t y , t z = [ 1 0 0 0 0 1 0 0 0 0 1 0 t x t y t z 1 ] Translation_{tx,ty,tz}= \left[ \begin{array}{l} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 1 & 0 \\ tx & ty & tz & 1 \\ \end{array} \right] Translationtx,ty,tz=⎣ ⎡100tx010ty001tz0001⎦ ⎤
[ x , y , z , 1 ] n e w = [ x , y , z , 1 ] o l d × T r a n s l a t i o n t x , t y , t z {[x,y,z,1]}_{new}={[x,y,z,1]}_{old}\times Translation_{tx,ty,tz} [x,y,z,1]new=[x,y,z,1]old×Translationtx,ty,tz
旋转的正方向: 右手坐标系下,从轴正方向看向原点,逆时针方向为旋转的正方向 右手坐标系下,从轴正方向看向原点,逆时针方向为旋转的正方向 右手坐标系下,从轴正方向看向原点,逆时针方向为旋转的正方向
R o t a t i o n x = [ 1 0 0 0 0 c o s α s i n α 0 0 − s i n α c o s α 0 0 0 0 1 ] Rotation_x = \left[ \begin{array}{l} 1 & 0 & 0 & 0 \\ 0 & cos\alpha & sin\alpha & 0 \\ 0 & -sin\alpha & cos\alpha & 0 \\ 0 & 0 & 0 & 1 \end{array} \right] Rotationx=⎣ ⎡10000cosα−sinα00sinαcosα00001⎦ ⎤
R o t a t i o n y = [ c o s α 0 − s i n α 0 0 1 0 0 s i n α 0 c o s α 0 0 0 0 1 ] Rotation_y = \left[ \begin{array}{l} cos\alpha & 0 & -sin\alpha & 0 \\ 0 & 1 & 0 & 0 \\ sin\alpha & 0 & cos\alpha & 0 \\ 0 & 0 & 0 & 1 \end{array} \right] Rotationy=⎣ ⎡cosα0sinα00100−sinα0cosα00001⎦ ⎤
R o t a t i o n z = [ c o s α s i n α 0 0 − s i n α c o s α 0 0 0 0 1 0 0 0 0 1 ] Rotation_z = \left[ \begin{array}{l} cos\alpha & sin\alpha & 0 & 0 \\ -sin\alpha & cos\alpha & 0 & 0 \\ 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & 1 \end{array} \right] Rotationz=⎣ ⎡cosα−sinα00sinαcosα0000100001⎦ ⎤
[ x , y , z , 1 ] n e w = [ x , y , z , 1 ] o l d × R o t a t i o n m a t i r x {[x,y,z,1]}_{new}={[x,y,z,1]}_{old}\times Rotation_{matirx} [x,y,z,1]new=[x,y,z,1]old×Rotationmatirx
绕任意旋转轴旋转的话,就包括经过原点和不经过原点,所以就包括旋转和平移
说明: 假设旋转轴的单位向量为 ( n x , n y , n z ) (n_x,n_y,n_z) (nx,ny,nz), 旋转轴经过点 ( x 0 , y 0 , z 0 ) (x_0,y_0,z_0) (x0,y0,z0)。
则令: K = 1 − c o s α , M = n x x 0 + n y y 0 + n z z 0 K=1-cos\alpha,M=n_xx_0+n_yy_0+n_zz_0 K=1−cosα,M=nxx0+nyy0+nzz0
R o t a t i o n r a n d o m _ a x i s = [ n x 2 K + c o s α n x n y K + n z s i n α n x n z K − n y s i n α 0 n x n y K − n z s i n α n y 2 K + c o s α n y n z K + n x s i n α 0 n x n z K + n y s i n α n y n z K − n x s i n α n z 2 K + c o s α 0 ( x 0 − n x M ) K + ( n z y 0 − n y z 0 ) s i n α ( y 0 − n y M ) K + ( n x z 0 − n z x 0 ) s i n α ( z 0 − n z M ) K + ( n y x 0 − n x y 0 ) s i n α 1 ] Rotation_{random\_axis}= \left[ \begin{array}{r} n_x^2K+cos\alpha & n_xn_yK+n_zsin\alpha & n_xn_zK-n_ysin\alpha & 0 \\ n_xn_yK-n_zsin\alpha & n_y^2K+cos\alpha & n_yn_zK+n_xsin\alpha & 0 \\ n_xn_zK+n_ysin\alpha & n_yn_zK-n_xsin\alpha & n_z^2K+cos\alpha & 0 \\ (x_0-n_xM)K+(n_zy_0-n_yz_0)sin\alpha & (y_0-n_yM)K+(n_xz_0-n_zx_0)sin\alpha & (z_0-n_zM)K+(n_yx_0-n_xy_0)sin\alpha & 1 \end{array} \right] Rotationrandom_axis=⎣ ⎡nx2K+cosαnxnyK−nzsinαnxnzK+nysinα(x0−nxM)K+(nzy0−nyz0)sinαnxnyK+nzsinαny2K+cosαnynzK−nxsinα(y0−nyM)K+(nxz0−nzx0)sinαnxnzK−nysinαnynzK+nxsinαnz2K+cosα(z0−nzM)K+(nyx0−nxy0)sinα0001⎦ ⎤
[ x , y , z , 1 ] n e w = [ x , y , z , 1 ] o l d × R o t a t i o n r a n d o m _ a x i s {[x,y,z,1]}_{new}={[x,y,z,1]}_{old}\times Rotation_{random\_axis} [x,y,z,1]new=[x,y,z,1]old×Rotationrandom_axis