第六章 图形变换 (二维\三维的平移\缩放\旋转\错切\对称变换, 齐次坐标, 坐标系的变换)

2025-10-22 11:44:42

第六章 图形变换

掌握矢量、矩阵以及它们的运算掌握二维平移变换、放缩变换、旋转变换、错切变换及对称变换了解变换的两种模式:固定坐标系模式与活动坐标系模式掌握坐标系的概念:世界坐标系、用户坐标系、设备(屏幕)坐标系与局部坐标系掌握什么是裁剪窗口与视区以及它们各自的作用掌握齐次坐标的概念,二维(三维)变换在齐次坐标下的表示了解二维图形的显示过程,掌握窗口到视区的变换掌握三维平移变换、放缩变换、旋转变换掌握坐标系之间的变换

矢量、矩阵以及它们的运算

数学基础不做介绍

二维基本变换

平移变换

点 P(x,y)在 x 轴方向, y 轴方向分别平移距离 tx,ty,得到点 P’(x’,y’), 有

[x′y′]=[xy]+[ΔxΔy]

\begin{bmatrix} x' \\ y' \end{bmatrix}=

\begin{bmatrix} x \\ y \end{bmatrix}+

\begin{bmatrix} \Delta x \\ \Delta y \end{bmatrix}

[x′y′​]=[xy​]+[ΔxΔy​]

旋转变换

点 P 绕坐标原点旋转角度 θ (逆时针为正,顺时针为负),得到 P’(x’,y’), 有

[x′y′]=[cosθ−sinθsinθcosθ]⋅[xy]

\begin{bmatrix} x' \\ y' \end{bmatrix}=

\begin{bmatrix} cos\theta & -sin\theta \\ sin\theta & cos\theta \end{bmatrix} \cdot

\begin{bmatrix} x \\ y \end{bmatrix}

[x′y′​]=[cosθsinθ​−sinθcosθ​]⋅[xy​]

缩放变换

点 P 在 x,y 方向分别放缩 sx 和 sy 倍,得到点 P’(x’,y’), 有

[x′y′]=[sx00sy]⋅[xy]

\begin{bmatrix} x' \\ y' \end{bmatrix}=

\begin{bmatrix} s_x & 0 \\ 0 & s_y \end{bmatrix} \cdot

\begin{bmatrix} x \\ y \end{bmatrix}

[x′y′​]=[sx​0​0sy​​]⋅[xy​]

齐次坐标与二维变换的矩阵表示

经常要对图形对象做连续多个变换,希望这些多个变换可以合成为一个大的复合变换

旋转和缩放变换都是矩阵乘法,根据结合律,可以复合

例如:一个先旋转再缩放的复合P’’=S·P’=S·(R·P)=(S·R)·P=A·P, 其中A=S·R

平移变换不能复合

齐次坐标

使各种转换的表示形式一致,使变换合成更加容易

齐次坐标定义

点 (x,y) 对应的齐次坐标为

(xh, yh, h),其中 xh=hx,yh=hy,h≠0

(x_h,\ y_h,\ h), \text{其中 }x_h=hx,y_h=hy, h\neq 0

(xh​, yh​, h),其中 xh​=hx,yh​=hy,h=0

点 (x,y) 对应的齐次坐标为三维空间的一条直线

为使运算简单,引入标准齐次坐标 (x,y,1)

二维齐次坐标变换的矩阵形式

[abcdefghi]

\begin{bmatrix}

a&b&c \\

d&e&f \\

g&h&i

\end{bmatrix}

​adg​beh​cfi​​

每一个元素都有其对应含义

a,b,d,e 可以对图形做 缩放 \ 旋转 \ 对称 \ 错切 等变换c,f 可以对图形做 平移 变换g,h 可以对图形做 投影 变换i 可以对图形整体做缩放变换

平移变换

[x′y′1]=[10tx01ty001]⋅[xy1]=T(tx,ty)[xy1]

\begin{bmatrix} x' \\ y' \\ 1 \end{bmatrix}=

\begin{bmatrix} 1 & 0 & t_x\\ 0 & 1 & t_y \\ 0 & 0 & 1\end{bmatrix} \cdot

\begin{bmatrix} x \\ y \\ 1 \end{bmatrix}

=T(t_x,t_y)

\begin{bmatrix} x \\ y \\ 1 \end{bmatrix}

​x′y′1​​=​100​010​tx​ty​1​​⋅​xy1​​=T(tx​,ty​)​xy1​​

旋转变换

[x′y′1]=[cosθ−sinθ0sinθcosθ0001]⋅[xy1]=R(θ)[xy1]

\begin{bmatrix} x' \\ y' \\ 1 \end{bmatrix}=

\begin{bmatrix} cos\theta & -sin\theta & 0 \\

sin\theta & cos\theta & 0 \\ 0 & 0 & 1\end{bmatrix} \cdot

\begin{bmatrix} x \\ y \\ 1 \end{bmatrix}

=R(\theta)

\begin{bmatrix} x \\ y \\ 1 \end{bmatrix}

​x′y′1​​=​cosθsinθ0​−sinθcosθ0​001​​⋅​xy1​​=R(θ)​xy1​​

缩放变换

[x′y′1]=[sx000sy0001]⋅[xy1]=S(sx,sy)[xy1]

\begin{bmatrix} x' \\ y' \\ 1 \end{bmatrix}=

\begin{bmatrix} s_x & 0 & 0\\ 0 & s_y & 0 \\ 0 & 0 & 1\end{bmatrix} \cdot

\begin{bmatrix} x \\ y \\ 1 \end{bmatrix}

=S(s_x,s_y)

\begin{bmatrix} x \\ y \\ 1 \end{bmatrix}

​x′y′1​​=​sx​00​0sy​0​001​​⋅​xy1​​=S(sx​,sy​)​xy1​​

对称变换

关于 x 轴的对称变换

[x′y′1]=[−100010001]⋅[xy1]=SYx[xy1]

\begin{bmatrix} x' \\ y' \\ 1 \end{bmatrix}=

\begin{bmatrix} -1 & 0 & 0\\ 0 & 1 & 0 \\ 0 & 0 & 1\end{bmatrix} \cdot

\begin{bmatrix} x \\ y \\ 1 \end{bmatrix}

=SY_x

\begin{bmatrix} x \\ y \\ 1 \end{bmatrix}

​x′y′1​​=​−100​010​001​​⋅​xy1​​=SYx​​xy1​​

关于 y 轴的对称变换

[x′y′1]=[1000−10001]⋅[xy1]=SYy[xy1]

\begin{bmatrix} x' \\ y' \\ 1 \end{bmatrix}=

\begin{bmatrix} 1 & 0 & 0\\ 0 & -1 & 0 \\ 0 & 0 & 1\end{bmatrix} \cdot

\begin{bmatrix} x \\ y \\ 1 \end{bmatrix}

=SY_y

\begin{bmatrix} x \\ y \\ 1 \end{bmatrix}

​x′y′1​​=​100​0−10​001​​⋅​xy1​​=SYy​​xy1​​

错切变换

错切变换(Shear Transformation)是一种线性变换,它将物体沿某个方向“倾斜”,而不改变该方向上的尺寸

可以发生在 x 轴方向、y 轴方向,或者同时在两个方向上进行

错切变换的特点是图形会发生形状的倾斜,但不会改变图形的面积和直线的平行性

以 y 轴为依赖轴 ( 方向轴 ) 的错切变换, 即

{x′=x+shx⋅yy′=y

\begin{cases}

x'=x+sh_x \cdot y\\

y'=y

\end{cases}

{x′=x+shx​⋅yy′=y​

因为 y = 0上的点位置不变, 因此称 y=0 为参考轴

[x′y′1]=[1shx0010001]⋅[xy1]=SH(shx)[xy1],shx=tan⁡(α)

\begin{bmatrix} x' \\ y' \\ 1 \end{bmatrix}=

\begin{bmatrix} 1 & sh_x & 0\\ 0 & 1 & 0 \\ 0 & 0 & 1\end{bmatrix} \cdot

\begin{bmatrix} x \\ y \\ 1 \end{bmatrix}

=SH(sh_x)

\begin{bmatrix} x \\ y \\ 1 \end{bmatrix},

sh_x=\tan (\alpha)

​x′y′1​​=​100​shx​10​001​​⋅​xy1​​=SH(shx​)​xy1​​,shx​=tan(α)

以 y = yref 为参考轴的错切变换

{x′=x+shx⋅(y−yref)y′=y

\begin{cases}

x'=x+sh_x \cdot (y-y_{ref})\\

y'=y

\end{cases}

{x′=x+shx​⋅(y−yref​)y′=y​

[x′y′1]=[1shx−shx⋅yref010001]⋅[xy1]=SH(shx)[xy1],shx=tan⁡(α)

\begin{bmatrix} x' \\ y' \\ 1 \end{bmatrix}=

\begin{bmatrix} 1 & sh_x & -sh_x \cdot y_{ref}\\ 0 & 1 & 0 \\ 0 & 0 & 1\end{bmatrix} \cdot

\begin{bmatrix} x \\ y \\ 1 \end{bmatrix}

=SH(sh_x)

\begin{bmatrix} x \\ y \\ 1 \end{bmatrix},

sh_x=\tan (\alpha)

​x′y′1​​=​100​shx​10​−shx​⋅yref​01​​⋅​xy1​​=SH(shx​)​xy1​​,shx​=tan(α)

以 x 轴为依赖轴 ( 方向轴 ) 的错切变换, 即

{x′=xy′=y+shy⋅x

\begin{cases}

x'=x\\

y'=y+sh_y \cdot x

\end{cases}

{x′=xy′=y+shy​⋅x​

[x′y′1]=[100shy10001]⋅[xy1]=SH(shy)[xy1],shy=tan⁡(β)

\begin{bmatrix} x' \\ y' \\ 1 \end{bmatrix}=

\begin{bmatrix} 1 & 0 & 0\\ sh_y & 1 & 0 \\ 0 & 0 & 1\end{bmatrix} \cdot

\begin{bmatrix} x \\ y \\ 1 \end{bmatrix}

=SH(sh_y)

\begin{bmatrix} x \\ y \\ 1 \end{bmatrix},

sh_y=\tan (\beta)

​x′y′1​​=​1shy​0​010​001​​⋅​xy1​​=SH(shy​)​xy1​​,shy​=tan(β)

以 x = xref 为参考轴的错切变换

{x′=xy′=y+shy⋅(x−xref)

\begin{cases}

x'=x\\

y'=y+sh_y \cdot (x-x_{ref})

\end{cases}

{x′=xy′=y+shy​⋅(x−xref​)​

[x′y′1]=[100shy1−shy⋅xref001]⋅[xy1]=SH(shx)[xy1],shx=tan⁡(α)

\begin{bmatrix} x' \\ y' \\ 1 \end{bmatrix}=

\begin{bmatrix} 1 & 0 & 0\\ sh_y & 1 & -sh_y \cdot x_{ref} \\ 0 & 0 & 1\end{bmatrix} \cdot

\begin{bmatrix} x \\ y \\ 1 \end{bmatrix}

=SH(sh_x)

\begin{bmatrix} x \\ y \\ 1 \end{bmatrix},

sh_x=\tan (\alpha)

​x′y′1​​=​1shy​0​010​0−shy​⋅xref​1​​⋅​xy1​​=SH(shx​)​xy1​​,shx​=tan(α)

复合操作

复合平移相当于多次平移 相加

复合缩放相当于多次缩放 相乘

复合旋转相当于多次旋转 角度相加

当进行连续的几何操作时,需要将对应的变换矩阵按从右向左顺序相乘

操作顺序会影响最终结果, 因为矩阵乘法不可交换

关于任意参照点 P(xr,yr) 的旋转变换, 缩放变换

旋转变换

先平移 (-xr,-yr), 再旋转角 θ, 最后平移 (xr,yr), 即变换矩阵

M(xr,yr;θ)=T(−xr,−yr)⋅R(θ)⋅T(xr,yr)=[10xr01yr001]⋅[cosθ−sinθ0sinθcosθ0001]⋅[10−xr01−yr001]=[cosθ−sinθxr(1−cosθ)+yrsinθsinθcosθyr(1−cosθ)−xrsinθ001]

M(x_r,y_r;\theta)=T(-x_r,-y_r) \cdot R(\theta) \cdot T(x_r,y_r)

\\=

\begin{bmatrix}1 & 0 & x_r \\ 0 & 1 & y_r \\ 0 & 0 & 1 \end{bmatrix} \cdot

\begin{bmatrix} cos\theta & -sin\theta & 0 \\ sin\theta & cos\theta & 0 \\ 0 & 0 & 1\end{bmatrix} \cdot

\begin{bmatrix}1 & 0 & -x_r \\ 0 & 1 & -y_r \\ 0 & 0 & 1 \end{bmatrix}

\\=

\begin{bmatrix} cos\theta & -sin\theta & x_r(1-cos\theta)+y_rsin\theta

\\ sin\theta & cos\theta & y_r(1-cos\theta)-x_rsin\theta

\\ 0 & 0 & 1\end{bmatrix}

M(xr​,yr​;θ)=T(−xr​,−yr​)⋅R(θ)⋅T(xr​,yr​)=​100​010​xr​yr​1​​⋅​cosθsinθ0​−sinθcosθ0​001​​⋅​100​010​−xr​−yr​1​​=​cosθsinθ0​−sinθcosθ0​xr​(1−cosθ)+yr​sinθyr​(1−cosθ)−xr​sinθ1​​

同理, 缩放变换

先平移 (-xr,-yr), 再缩放 (sx,sy) 倍, 最后平移 (xr,yr), 即变换矩阵

M(xr,yr;sx,sy)=T(−xr,−yr)⋅S(sx,sy)⋅T(xr,yr)=[10xr01yr001]⋅[sx000sy0001]⋅[10−xr01−yr001]=[sx0xr(1−sx)0syyr(1−sy)001]M(x_r,y_r;s_x,s_y)=T(-x_r,-y_r) \cdot S(s_x,s_y) \cdot T(x_r,y_r)\\=\begin{bmatrix}1 & 0 & x_r \\ 0 & 1 & y_r \\ 0 & 0 & 1 \end{bmatrix} \cdot\begin{bmatrix} s_x & 0 & 0\\ 0 & s_y & 0 \\ 0 & 0 & 1\end{bmatrix} \cdot\begin{bmatrix}1 & 0 & -x_r \\ 0 & 1 & -y_r \\ 0 & 0 & 1 \end{bmatrix}=\begin{bmatrix} s_x & 0 & x_r(1-s_x)\\ 0 & s_y & y_r(1-s_y)\\ 0 & 0 & 1\end{bmatrix}

M(xr​,yr​;sx​,sy​)=T(−xr​,−yr​)⋅S(sx​,sy​)⋅T(xr​,yr​)=​100​010​xr​yr​1​​⋅​sx​00​0sy​0​001​​⋅​100​010​−xr​−yr​1​​=​sx​00​0sy​0​xr​(1−sx​)yr​(1−sy​)1​​

关于任意轴 (直线 L) 的对称变换

平移使 L 过坐标原点 (T1)旋转 θ 使 L 与横坐标重合 (R1)求关于 x 轴的对称图形 (SY)旋转 -θ (R2)平移使 L 回到原先位置 (T2)θ旋转=−tan−1(k)

即总变换

M=T2⋅R2⋅SYx⋅R1⋅T1=T(0,−b)⋅R(−θ)⋅SYx⋅R(θ)⋅T(0,b),L:y=kx+b,θ=tan⁡−1(k)

M=T_2 \cdot R_2 \cdot SY_x \cdot R_1 \cdot T_1=

T(0,-b) \cdot R(-\theta) \cdot SY_x \cdot R(\theta) \cdot T(0,b)

\\,

L: y=kx+b,\theta = \tan^{-1}(k)

M=T2​⋅R2​⋅SYx​⋅R1​⋅T1​=T(0,−b)⋅R(−θ)⋅SYx​⋅R(θ)⋅T(0,b),L:y=kx+b,θ=tan−1(k)

仿射变换

变换前后,能保持平行直线的关系

{x′=ax+by+ey′=cy+dx+f

\begin{cases}

x'=ax+by+e\\

y'=cy+dx+f

\end{cases}

{x′=ax+by+ey′=cy+dx+f​

变换矩阵为

Af=[abecdf001]

A_f=

\begin{bmatrix}

a&b&e\\c&d&f\\0&0&1

\end{bmatrix}

Af​=​ac0​bd0​ef1​​

固定坐标系模式和活动坐标系模式

之前讲的都是基于固定坐标系模式下的变换, 还有一种活动坐标系模式下的变换

在固定坐标系模式下,每个变换都是相对于固定的全局坐标系(即世界坐标系)进行的

变换的顺序非常重要,后面的操作不会影响前面操作的坐标系

在活动坐标系模式下,每次变换都会基于图形自身的坐标系进行

每次操作完成后,图形的坐标系随之变化,后续操作都是在新坐标系下进行的

以以下操作顺序为为例

平移 (1, 1)缩放 2 倍旋转 90 度平移 (5, 4)

在固定坐标系模式下,变换矩阵按照顺序从右向左相乘:

M固=T2⋅R⋅S⋅T1

M_固 = T_2 \cdot R \cdot S \cdot T_1

M固​=T2​⋅R⋅S⋅T1​

在活动坐标系模式下,矩阵相乘的顺序是从左到右:

M活=T1⋅S⋅R⋅T2

M_活 = T_1 \cdot S \cdot R \cdot T_2

M活​=T1​⋅S⋅R⋅T2​

二维图形的显示流程

三种坐标系

世界坐标系

相对于物体所在的整个空间

局部坐标系

相对于物体

屏幕坐标系 (设备坐标系)

在显示区域绘制图形的坐标系坐标轴方向可能根据不同的设备而不同

窗口与视区

窗口

在世界坐标系中指定的一个矩形区域来指定需要显示的图形

视区

在设备坐标系中指定的矩形区域, 来指定窗口内的图形在屏幕上显示的大小及位置

窗口到视区的变换

窗口与视区在不同坐标系, 物体坐标必须进行变换后才能在视区显示

设世界坐标系中窗口左下角 (xmin,ymin),两边长 Ex,Ey

设设备坐标系中视区左下角 (umin,vmin),两边长 Eu,Ev

变换步骤:

世界坐标系中平移使 (xmin,ymin) 至原点旋转使窗口边与坐标重合

若窗口边与视区边平行, 则旋转角 α = 0

放缩使窗口大小与视区相等设备坐标系中平移窗口与视图重合

变换矩阵为

Mwv=T(umin,vmin)⋅S(EuEx,EvEy)⋅R(−α)⋅T(−xmin,−ymin)

M_{wv}=T(u_{min},v_{min}) \cdot

S(\frac {E_u} {E_x},\frac {E_v} {E_y}) \cdot

R(-\alpha) \cdot

T(-x_{min},-y_{min})

Mwv​=T(umin​,vmin​)⋅S(Ex​Eu​​,Ey​Ev​​)⋅R(−α)⋅T(−xmin​,−ymin​)

三维几何变换

一下内容均基于右手坐标系

三维齐次坐标

点 (x,y,z) 对应的齐次坐标为

(xh,yh,zh,h),其中 xh=hx,yh=hy,zh=hz,h≠0

(x_h,y_h,z_h,h), \text{其中 }x_h=hx,y_h=hy,z_h=hz,h\neq 0

(xh​,yh​,zh​,h),其中 xh​=hx,yh​=hy,zh​=hz,h=0

标准齐次坐标 (x,y,z,1)

平移变换

[x′y′z′1]=[100tx010ty001tz0001]⋅[xyz1]=T(tx,ty,tz)[xyz1]

\begin{bmatrix} x' \\ y' \\ z' \\ 1 \end{bmatrix}=

\begin{bmatrix}

1 & 0 & 0 & t_x \\

0 & 1 & 0 & t_y \\

0 & 0 & 1 & t_z \\

0 & 0 & 0 & 1

\end{bmatrix} \cdot

\begin{bmatrix} x \\ y \\ z \\ 1 \end{bmatrix}

=T(t_x,t_y,t_z)

\begin{bmatrix} x \\ y \\ z \\ 1 \end{bmatrix}

​x′y′z′1​​=​1000​0100​0010​tx​ty​tz​1​​⋅​xyz1​​=T(tx​,ty​,tz​)​xyz1​​

旋转变换

旋转变换分为

绕 x 轴

[x′y′z′1]=[10000cosθ−sinθ00sinθcosθ00001]⋅[xyz1]=Rx(θ)[xyz1]

\begin{bmatrix} x' \\ y' \\ z' \\ 1 \end{bmatrix}=

\begin{bmatrix}

1 & 0 & 0 & 0 \\

0 & cos\theta & -sin\theta & 0 \\

0 & sin\theta & cos\theta & 0 \\

0 & 0 & 0 & 1

\end{bmatrix} \cdot

\begin{bmatrix} x \\ y \\ z \\ 1 \end{bmatrix}

=R_x(\theta)

\begin{bmatrix} x \\ y \\ z \\ 1 \end{bmatrix}

​x′y′z′1​​=​1000​0cosθsinθ0​0−sinθcosθ0​0001​​⋅​xyz1​​=Rx​(θ)​xyz1​​

绕 y 轴

[x′y′z′1]=[cosθ0−sinθ00100sinθ0cosθ00001]⋅[xyz1]=Ry(θ)[xyz1]

\begin{bmatrix} x' \\ y' \\ z' \\ 1 \end{bmatrix}=

\begin{bmatrix}

cos\theta & 0 & -sin\theta & 0 \\

0 & 1 & 0 & 0 \\

sin\theta & 0 & cos\theta & 0 \\

0 & 0 & 0 & 1

\end{bmatrix} \cdot

\begin{bmatrix} x \\ y \\ z \\ 1 \end{bmatrix}

=R_y(\theta)

\begin{bmatrix} x \\ y \\ z \\ 1 \end{bmatrix}

​x′y′z′1​​=​cosθ0sinθ0​0100​−sinθ0cosθ0​0001​​⋅​xyz1​​=Ry​(θ)​xyz1​​

绕 z 轴

[x′y′z′1]=[cosθ−sinθ00sinθcosθ0000100001]⋅[xyz1]=Rz(θ)[xyz1]

\begin{bmatrix} x' \\ y' \\ z' \\ 1 \end{bmatrix}=

\begin{bmatrix}

cos\theta & -sin\theta & 0 & 0 \\

sin\theta & cos\theta & 0 & 0 \\

0 & 0 & 1 & 0 \\

0 & 0 & 0 & 1

\end{bmatrix} \cdot

\begin{bmatrix} x \\ y \\ z \\ 1 \end{bmatrix}

=R_z(\theta)

\begin{bmatrix} x \\ y \\ z \\ 1 \end{bmatrix}

​x′y′z′1​​=​cosθsinθ00​−sinθcosθ00​0010​0001​​⋅​xyz1​​=Rz​(θ)​xyz1​​

缩放变换

[x′y′z′1]=[sx0000sy0000sz00001]⋅[xyz1]=S(sx,sy,sz)[xyz1]

\begin{bmatrix} x' \\ y' \\ z' \\ 1 \end{bmatrix}=

\begin{bmatrix}

s_x & 0 & 0 & 0 \\

0 & s_y & 0 & 0 \\

0 & 0 & s_z & 0 \\

0 & 0 & 0 & 1

\end{bmatrix} \cdot

\begin{bmatrix} x \\ y \\ z \\ 1 \end{bmatrix}

=S(s_x,s_y,s_z)

\begin{bmatrix} x \\ y \\ z \\ 1 \end{bmatrix}

​x′y′z′1​​=​sx​000​0sy​00​00sz​0​0001​​⋅​xyz1​​=S(sx​,sy​,sz​)​xyz1​​

错切变换

错切按照依赖轴不同可以分为以下:

x 轴为依赖轴

[x′y′z′1]=[1000shy100shz0100001]⋅[xyz1]=SHx(shy,shz)[xyz1]

\begin{bmatrix} x' \\ y' \\ z' \\ 1 \end{bmatrix}=

\begin{bmatrix}

1 & 0 & 0 & 0 \\

sh_y & 1 & 0 & 0 \\

sh_z & 0 & 1 & 0 \\

0 & 0 & 0 & 1

\end{bmatrix} \cdot

\begin{bmatrix} x \\ y \\ z \\ 1 \end{bmatrix}

=SH_x(sh_y,sh_z)

\begin{bmatrix} x \\ y \\ z \\ 1 \end{bmatrix}

​x′y′z′1​​=​1shy​shz​0​0100​0010​0001​​⋅​xyz1​​=SHx​(shy​,shz​)​xyz1​​

y 轴为依赖轴

[x′y′z′1]=[1shx0001000shz100001]⋅[xyz1]=SHy(shx,shz)[xyz1]

\begin{bmatrix} x' \\ y' \\ z' \\ 1 \end{bmatrix}=

\begin{bmatrix}

1 & sh_x & 0 & 0 \\

0 & 1 & 0 & 0 \\

0 & sh_z & 1 & 0 \\

0 & 0 & 0 & 1

\end{bmatrix} \cdot

\begin{bmatrix} x \\ y \\ z \\ 1 \end{bmatrix}

=SH_y(sh_x,sh_z)

\begin{bmatrix} x \\ y \\ z \\ 1 \end{bmatrix}

​x′y′z′1​​=​1000​shx​1shz​0​0010​0001​​⋅​xyz1​​=SHy​(shx​,shz​)​xyz1​​

z 轴为依赖轴

[x′y′z′1]=[10shx001shy000100001]⋅[xyz1]=SHz(shx,shy)[xyz1]

\begin{bmatrix} x' \\ y' \\ z' \\ 1 \end{bmatrix}=

\begin{bmatrix}

1 & 0 & sh_x & 0 \\

0 & 1 & sh_y & 0 \\

0 & 0 & 1 & 0 \\

0 & 0 & 0 & 1

\end{bmatrix} \cdot

\begin{bmatrix} x \\ y \\ z \\ 1 \end{bmatrix}

=SH_z(sh_x,sh_y)

\begin{bmatrix} x \\ y \\ z \\ 1 \end{bmatrix}

​x′y′z′1​​=​1000​0100​shx​shy​10​0001​​⋅​xyz1​​=SHz​(shx​,shy​)​xyz1​​

对称变换

分别关于 x 轴对称, y 轴对称, z 轴对称

SYyz=[−1000010000100001],SYxz=[10000−10000100001],SYxy=[1000010000−100001]

SY_{yz}=\begin{bmatrix}

-1 & 0 & 0 & 0 \\

0 & 1 & 0 & 0 \\

0 & 0 & 1 & 0 \\

0 & 0 & 0 & 1

\end{bmatrix},

SY_{xz}=\begin{bmatrix}

1 & 0 & 0 & 0 \\

0 & -1 & 0 & 0 \\

0 & 0 & 1 & 0 \\

0 & 0 & 0 & 1

\end{bmatrix},

SY_{xy}=\begin{bmatrix}

1 & 0 & 0 & 0 \\

0 & 1 & 0 & 0 \\

0 & 0 & -1 & 0 \\

0 & 0 & 0 & 1

\end{bmatrix}

SYyz​=​−1000​0100​0010​0001​​,SYxz​=​1000​0−100​0010​0001​​,SYxy​=​1000​0100​00−10​0001​​

关于绕空间任意轴的旋转

设旋转轴 AB 由任意一点 A(xa,ya,za) 及其方向向量 (a,b,c) 定义

空间一点 P(xp,yp,zp) 绕 AB 轴旋转到 P’(xp’,yp’,zp’),转角为 θ

旋转步骤

将 A 点移到坐标原点使 AB 分别绕 x 轴、y 轴旋转适当角度与 z 轴重合将点 P 绕 z 轴旋转 θ 角作上述变换的逆操作,使 AB 回到原来位置

变换矩阵

RAB(θ)=T(xa,ya,za)⋅Rx(−α)⋅Ry(−β)⋅R(θ)⋅Ry(β)⋅Rx(α)⋅T(−xa,−ya,−za),其中 α=tan⁡−1(bc),β=tan⁡−1(ab2+c2)

R_{AB}(\theta)=T(x_a,y_a,z_a) \cdot R_x(-\alpha) \cdot R_y(-\beta)

\cdot R(\theta) \cdot

R_y(\beta) \cdot R_x(\alpha) \cdot T(-x_a,-y_a,-z_a) \\

,其中\ \alpha=\tan^{-1}(\frac{b}{c}),\beta=\tan^{-1}(\frac{a}{\sqrt{b^2+c^2}})

RAB​(θ)=T(xa​,ya​,za​)⋅Rx​(−α)⋅Ry​(−β)⋅R(θ)⋅Ry​(β)⋅Rx​(α)⋅T(−xa​,−ya​,−za​),其中 α=tan−1(cb​),β=tan−1(b2+c2​a​)

坐标系之间的变换

设有两个坐标系:OXYZ 和 O’UVN

点 O’ 在 OXYZ 中的坐标为 (Ox,Oy,Oz)单位向量 O’U,O‘V,O’N 在 OXYZ 中分别为 (Ux,Uy,Uz), (Vx,Vy,Vz), (Nx,Ny,Nz)现要将坐标系 OXYZ 中的图形变换到坐标系 O‘UVN 中去,记变换为 Mxyz→uvn

将坐标系平移对齐, 再由线性代数知识可以求得这两个坐标系之间的正交变换即可

Mxyz→uvn=R⋅T(−Ox,−Oy,−Oz), R=[uxuyuz0vxvyvz0wxwywz00001]

M_{\text{xyz} \to \text{uvn}} = R \cdot T(-Ox, -Oy, -Oz),\

R=\begin{bmatrix}

u_x & u_y & u_z & 0 \\

v_x & v_y & v_z & 0 \\

w_x & w_y & w_z & 0 \\

0 & 0 & 0 & 1

\end{bmatrix}

Mxyz→uvn​=R⋅T(−Ox,−Oy,−Oz), R=​ux​vx​wx​0​uy​vy​wy​0​uz​vz​wz​0​0001​​

或使用变换合成先平移后旋转对齐

Copyright © 2022 世界杯预选赛欧洲区_世界杯在哪个国家举行 - kd896.com All Rights Reserved.