一、图形变换数学基础(续1)

本文详细介绍了三维坐标系中的四种基本变换:平移、缩放、旋转变换(基于右手系),以及对称变换。对于每种变换,都提供了变换矩阵和变换公式。此外,还讲解了如何在不同三维坐标系之间进行转换,涉及平移矩阵和坐标旋转矩阵的使用。
摘要由CSDN通过智能技术生成


1. 三维坐标系变换

同二维坐标系变换类似,这里直接给出结论

二维坐标系变换link

1.1 平移变换

  1. T 表示平移变换矩阵, ( t x , t y , t z ) (tx,ty,tz) (tx,ty,tz)为平移分量。
    [ x ′ y ′ z ′ 1 ] = [ x + t x y + t y z + t z 1 ] = [ 1 0 0 t x 0 1 0 t y 0 0 1 t z 0 0 0 1 ] [ x y z 1 ] = T ⋅ P \left[\begin{array}{l} x^{\prime} \\ y^{\prime} \\ z^{\prime} \\ 1 \end{array}\right]=\left[\begin{array}{c} x+t x \\ y+t y \\ z+t z \\ 1 \end{array}\right]=\left[\begin{array}{cccc} 1 & 0 & 0 & t x \\ 0 & 1 & 0 & t y \\ 0 & 0 & 1 & t z \\ 0 & 0 & 0 & 1 \end{array}\right]\left[\begin{array}{c} x \\ y \\ z \\ 1 \end{array}\right] = T\cdot P xyz1 = x+txy+tyz+tz1 = 100001000010txtytz1 xyz1 =TP

1.2 缩放变换

  1. T 表示缩放变换矩阵, ( s x , s y , s z ) (sx,sy,sz) (sx,sy,sz)为缩放系数分量。
    [ x ′ y ′ z ′ 1 ] = [ x ⋅ s x y ⋅ s y z ⋅ s z 1 ] = [ s x 0 0 0 0 s y 0 0 0 0 s z 0 0 0 0 1 ] [ x y z 1 ] = S ⋅ P \left[\begin{array}{l} x^{\prime} \\ y^{\prime} \\ z^{\prime} \\ 1 \end{array}\right]=\left[\begin{array}{c} x \cdot s x \\ y \cdot s y \\ z \cdot s z \\ 1 \end{array}\right]=\left[\begin{array}{cccc} s x & 0 & 0 & 0 \\ 0 & s y & 0 & 0 \\ 0 & 0 & s z & 0 \\ 0 & 0 & 0 & 1 \end{array}\right]\left[\begin{array}{c} x \\ y \\ z \\ 1 \end{array}\right] = S \cdot P xyz1 = xsxysyzsz1 = sx0000sy0000sz00001 xyz1 =SP

1.3 旋转变换(旋转方向以右手系为标准)

右手坐标系

(1)绕x轴旋转 θ \theta θ
[ x ′ y ′ z ′ 1 ] = [ x y cos ⁡ θ − z sin ⁡ θ y sin ⁡ θ + z cos ⁡ θ 1 ] = [ 1 0 0 0 0 cos ⁡ θ − sin ⁡ θ 0 0 sin ⁡ θ cos ⁡ θ 0 0 0 0 1 ] [ x y z 1 ] = R x ⋅ P \left[\begin{array}{l} x^{\prime} \\ y^{\prime} \\ z^{\prime} \\ 1 \end{array}\right]=\left[\begin{array}{c} x \\ y \cos \theta-z \sin \theta \\ y \sin \theta+z \cos \theta \\ 1 \end{array}\right]=\left[\begin{array}{cccc} 1 & 0 & 0 & 0 \\ 0 & \cos \theta & -\sin \theta & 0 \\ 0 & \sin \theta & \cos \theta & 0 \\ 0 & 0 & 0 & 1 \end{array}\right]\left[\begin{array}{l} x \\ y \\ z \\ 1 \end{array}\right] =R_x \cdot P xyz1 = xycosθzsinθysinθ+zcosθ1 = 10000cosθsinθ00sinθcosθ00001 xyz1 =RxP
(2)绕y轴旋转 θ \theta θ
[ x ′ y ′ z ′ 1 ] = [ z sin ⁡ θ + x cos ⁡ θ y z cos ⁡ θ − x sin ⁡ θ 1 ] = [ cos ⁡ θ 0 sin ⁡ θ 0 0 1 0 0 − sin ⁡ θ 0 cos ⁡ θ 0 0 0 0 1 ] [ x y z 1 ] = R y ⋅ P \left[\begin{array}{l} x^{\prime} \\ y^{\prime} \\ z^{\prime} \\ 1 \end{array}\right]=\left[\begin{array}{c} z \sin \theta+x \cos \theta \\ y \\ z \cos \theta-x \sin \theta \\ 1 \end{array}\right]=\left[\begin{array}{cccc} \cos \theta & 0 & \sin \theta & 0 \\ 0 & 1 & 0 & 0 \\ -\sin \theta & 0 & \cos \theta & 0 \\ 0 & 0 & 0 & 1 \end{array}\right]\left[\begin{array}{l} x \\ y \\ z \\ 1 \end{array}\right] =R_y \cdot P xyz1 = zsinθ+xcosθyzcosθxsinθ1 = cosθ0sinθ00100sinθ0cosθ00001 xyz1 =RyP
(3)绕z轴旋转 θ \theta θ

[ x ′ y ′ z ′ 1 ] = [ x cos ⁡ θ − y sin ⁡ θ x sin ⁡ θ + y sin ⁡ θ z 1 ] = [ cos ⁡ θ − sin ⁡ θ 0 0 − sin ⁡ θ cos ⁡ θ 0 0 0 0 1 0 0 0 0 1 ] [ x y z 1 ] = R z ⋅ P \left[ \begin{array}{l} {{x}^{\prime }} \\ {{y}^{\prime }} \\ {{z}^{\prime }} \\ 1 \\ \end{array} \right]=\left[ \begin{array}{c} x\cos \theta -y\sin \theta \\ x\sin \theta +y\sin \theta \\ z \\ 1 \\ \end{array} \right]=\left[ \begin{array}{cccc} \cos \theta & -\sin \theta & 0 & 0 \\ -\sin \theta & \cos \theta & 0 & 0 \\ 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & 1 \\ \end{array} \right]\left[ \begin{array}{l} x \\ y \\ z \\ 1 \\ \end{array}\right]=R_z \cdot P xyz1 = xcosθysinθxsinθ+ysinθz1 = cosθsinθ00sinθcosθ0000100001 xyz1 =RzP
(4) P ( x , y , z ) P(x,y,z) P(x,y,z)绕空间任意轴线 l 1 : n l_1:n l1:n 旋转 θ \theta θ得到 P ′ ( x ′ , y ′ , z ′ ) P'(x',y',z') P(x,y,z)
思路

  • (a)先将直线 l 1 l_1 l1上一点 P 1 P_1 P1移动至原点,同时移动P点。
  • (b,c)然后分别绕x轴、y轴旋转使得A、B方向与z轴重合。
  • (d)最后让P点绕z轴旋转 θ \theta θ
  • (e)做(b)(a)步骤的逆变换。得到最后的结果 P ′ ( x ′ , y ′ , z ′ ) P'(x',y',z') P(x,y,z)
    变换矩阵
    (a)设 P 0 ( x 0 , y 0 , z 0 ) P_0(x_0,y_0,z_0) P0(x0,y0,z0)是直线 l 1 : 方向数 n → = ( A , B , C ) l_1:方向数\overrightarrow{n}=(A,B,C) l1:方向数n =(A,B,C)上一点,将其平移至坐标原点,平移矩阵为:
    T 1 = [ 1 0 0 − x 0 0 1 0 − y 0 0 0 1 − z 0 0 0 0 1 ] T_1=\left[ \begin{array}{} 1 & 0 & 0 & -x_0\\ 0 & 1 & 0 & -y_0\\ 0 & 0 & 1 & -z_0\\ 0 & 0 & 0 & 1\\ \end{array}\right] T1= 100001000010x0y0z01
    (b) 绕x轴旋转,使得直线 l 1 l_1 l1 x O y xOy xOy平面上,旋转角为 l 1 l_1 l1 y O z yOz yOz平面上的投影与z轴的夹角 β , c o s β = C B 2 + C 2 , s i n β = B B 2 + C 2 \beta, cos\beta=\frac{C}{ \sqrt{{{\text{B}}^{2}}+{{C}^{2}}}},sin\beta=\frac{B}{ \sqrt{{{\text{B}}^{2}}+{{C}^{2}}}} β,cosβ=B2+C2 C,sinβ=B2+C2 B。旋转矩阵为:
    T 2 = [ 1 0 0 − x 0 0 c o s β − s i n β 0 0 s i n β c o s β 0 0 0 0 1 ] T_2=\left[ \begin{array}{} 1 & 0 & 0 & -x_0\\ 0 & cos\beta & -sin\beta & 0\\ 0 & sin\beta & cos\beta & 0\\ 0 & 0 & 0 & 1\\ \end{array}\right] T2= 10000cosβsinβ00sinβcosβ0x0001
    (c) 绕y轴旋转,使得直线 l 1 l_1 l1与z轴重合,旋转角为 l 1 l_1 l1与z轴的夹角 γ , c o s γ = B 2 + C 2 A 2 + B 2 + C 2 , s i n γ = − A A 2 + B 2 + C 2 \gamma , cos\gamma =\frac{\sqrt{B^{2}+C^{2}}}{ \sqrt{A^{2}+B^{2}+C^{2}}},sin\gamma =-\frac{A}{ \sqrt{A^{2}+B^{2}+C^{2}}} γ,cosγ=A2+B2+C2 B2+C2 ,sinγ=A2+B2+C2 A。旋转矩阵为:
    T 3 = [ c o s γ 0 s i n γ 0 0 1 0 0 − s i n γ 0 c o s γ 0 0 0 0 1 ] T_3=\left[ \begin{array}{} cos\gamma & 0 & sin\gamma & 0\\ 0 & 1 & 0 & 0\\ -sin\gamma & 0 & cos\gamma & 0\\ 0 & 0 & 0 & 1\\ \end{array}\right] T3= cosγ0sinγ00100sinγ0cosγ00001
    (d) P点绕直线(即z轴旋转 θ \theta θ),旋转矩阵为:
    T 4 = [ c o s θ c o s θ 0 0 s i n θ c o s β 0 0 0 0 1 0 0 0 0 1 ] T_4=\left[ \begin{array}{} cos\theta & cos\theta & 0 & 0\\ sin\theta & cos\beta & 0 & 0\\ 0 & 0 & 1& 0\\ 0 & 0 & 0 & 1\\ \end{array}\right] T4= cosθsinθ00cosθcosβ0000100001
    (e)依次做(c),(b),(a)的逆变换,分别记为 T 5 , T 6 , T 7 T_5,T_6,T_7 T5,T6,T7,所以总的变换矩阵为: T = T 7 ⋅ T 6 ⋅ T 5 ⋅ T 4 ⋅ T 3 ⋅ T 2 ⋅ T 1 T=T_7 \cdot T_6\cdot T_5\cdot T_4\cdot T_3\cdot T_2\cdot T_1 T=T7T6T5T4T3T2T1

1.4 对称变换

  • 关于 x O y xOy xOy平面对称变换矩阵,x,y不变,z变为相反数:
    T x O y = [ 1 0 0 0 0 1 0 0 0 0 − 1 0 0 0 0 1 ] T_{xOy} = \left[ \begin{array}{} 1 & 0 & 0 & 0\\ 0 & 1 & 0 & 0\\ 0 & 0 & -1& 0\\ 0 & 0 & 0 & 1\\ \end{array}\right] TxOy= 1000010000100001
  • 同理可写出关于 x O z , z O y xOz,zOy xOzzOy的变换矩阵:
    T x O z = [ 1 0 0 0 0 − 1 0 0 0 0 1 0 0 0 0 1 ] , T z O y = [ − 1 0 0 0 0 1 0 0 0 0 − 1 0 0 0 0 1 ] T_{xOz} = \left[ \begin{array}{} 1 & 0 & 0 & 0\\ 0 & -1 & 0 & 0\\ 0 & 0 & 1& 0\\ 0 & 0 & 0 & 1\\ \end{array}\right],T_{zOy} = \left[ \begin{array}{} -1 & 0 & 0 & 0\\ 0 & 1 & 0 & 0\\ 0 & 0 & -1& 0\\ 0 & 0 & 0 & 1\\ \end{array}\right] TxOz= 1000010000100001 TzOy= 1000010000100001

2. 三维坐标系之间的转换

在这里插入图片描述

  • 将原坐标系 x y z xyz xyz下的坐标 ( x , y , z ) (x,y,z) (x,y,z)转换为新坐标系 u v n uvn uvn下的坐标 ( x ′ , y ′ , z ′ ) (x',y',z') (x,y,z)
  • 坐标系变换矩阵的R与rotation R 互为 inverse matrix.
    思路:1.平移坐标系原点和新坐标系的原点重合 2.利用单位坐标向量构造坐标旋转矩阵。
    (1)平移:
    T = [ 1 0 0 − u 0 0 1 0 − v 0 0 0 1 − n 0 0 0 0 1 ] T = \left[ \begin{array}{} 1 & 0 & 0 & -u_0\\ 0 & 1 & 0 & -v_0\\ 0 & 0 & 1& -n_0\\ 0 & 0 & 0 & 1\\ \end{array}\right] T= 100001000010u0v0n01
    (2) 坐标旋转矩阵( ( u x , u y , u z ) (u_x,u_y,u_z) (ux,uy,uz) is a norm vector for the global CSYS.)
    R = [ u x u y u z 0 v x v y v z 0 n x n y n z 0 0 0 0 1 ] R = \left[ \begin{array}{} u_x & u_y & u_z & 0\\ v_x & v_y & v_z & 0\\ n_x & n_y & n_z & 0\\ 0 & 0 & 0 & 1\\ \end{array}\right] R= uxvxnx0uyvyny0uzvznz00001
  • 所以坐标变换公式为:
    [ u ′ v ′ n ′ 1 ] = R ⋅ T ⋅ [ x y z 1 ] \left[ \begin{array}{} u' \\ v' \\ n' \\ 1\\ \end{array}\right]=R\cdot T\cdot \left[ \begin{array}{} x \\ y \\ z \\ 1\\ \end{array}\right] uvn1 =RT xyz1

R ⋅ T = [ u x u y u z u x ( − u 0 ) + u y ( − v 0 ) + u z ( − n 0 ) v x v y v z v x ( − u 0 ) + v y ( − v 0 ) + v z ( − n 0 ) n x n y n z n x ( − u 0 ) + n y ( − v 0 ) + n z ( − n 0 ) 0 0 0 1 ] R\cdot T= \left[ \begin{array}{} u_x & u_y & u_z & u_{x} (-u_0)+ u_{y} (-v_0) + u_{z} (-n_0)\\ v_x & v_y & v_z & v_{x} (-u_0)+ v_{y} (-v_0) + v_{z} (-n_0)\\ n_x & n_y & n_z & n_{x} (-u_0)+ n_{y} (-v_0) + n_{z} (-n_0)\\ 0 & 0 & 0 & 1\\ \end{array}\right] RT= uxvxnx0uyvyny0uzvznz0ux(u0)+uy(v0)+uz(n0)vx(u0)+vy(v0)+vz(n0)nx(u0)+ny(v0)+nz(n0)1

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值