三维旋转和平移矩阵

1. 平移矩阵

1.1 矩阵

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

1.2 用法

[ 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

2. 旋转矩阵

旋转的正方向: 右手坐标系下,从轴正方向看向原点,逆时针方向为旋转的正方向 右手坐标系下,从轴正方向看向原点,逆时针方向为旋转的正方向 右手坐标系下,从轴正方向看向原点,逆时针方向为旋转的正方向

2.1 绕x轴旋转

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

2.2 绕y轴旋转

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α00100sinα0cosα00001

2.3 绕z轴旋转

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

2.4 用法

[ 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

3. 绕任意旋转轴旋转

3.1 说明

绕任意旋转轴旋转的话,就包括经过原点和不经过原点,所以就包括旋转和平移
说明: 假设旋转轴的单位向量为 ( 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=1cosα,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αnxnyKnzsinαnxnzK+nysinα(x0nxM)K+(nzy0nyz0)sinαnxnyK+nzsinαny2K+cosαnynzKnxsinα(y0nyM)K+(nxz0nzx0)sinαnxnzKnysinαnynzK+nxsinαnz2K+cosα(z0nzM)K+(nyx0nxy0)sinα0001

3.2 用法

[ 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

  • 1
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值