图形变换之旋转变换公式推导

齐次坐标1

齐次坐标表示法就是用 n+1 维向量表示一个 n 维向量。

n 维空间中的点的位置向量用非齐次坐标表示时, ( P 1 , P 2 , … , P n ) (P_1,P_2,…, P_n) (P1,P2,,Pn) 具有 n 个坐标分量,并且是唯一的。如果用齐次坐标表示时,该向量有 n+1 个坐标分量, ( h P 1 , h P 2 , … , h P n , h ) (hP_1, hP_2,…, hP_n, h) (hP1,hP2,,hPn,h) 并且是不唯一的。2

通常都使 h=1。如果 h≠0,就可以用除齐次坐标的各分量,这一方法称之为齐次坐标的规范化。经过规范化后的齐次坐标就是唯一的。

h = 0 时,该点表示一无穷远点3。三元组 (0, 0, 0) 不表示任何点。原点表示为 (0, 0, 1)

如二维点 (x,y) 的齐次坐标表示为 ( h x , h y , h ) (h_x,h_y,h) (hx,hy,h) ,则 ( h 1 x , h 1 y , h 1 ) , ( h 2 x , h 2 y , h 2 ) , … , ( h m x , h m y , h m ) (h_1x,h_1y,h_1) , (h_2x,h_2y,h_2) ,…, (h_mx,h_my,h_m) (h1x,h1y,h1)(h2x,h2y,h2)(hmx,hmy,hm) 都是表示二维空间中的同一个点三维空间中的坐标点的齐次坐标可表示为 (x,y,1) 。

应用齐次坐标可以有效地用矩阵运算把二维、三维甚至更高维空间中点集从一个坐标系转换到另一个坐标系中。

二维齐次坐标变换矩阵的形式为
T 2 D = [ a d g b e h c f i ] T_{2D} = \begin{bmatrix} a & d & g \\ b & e & h \\ c & f & i \\ \end{bmatrix} T2D=abcdefghi
在这里插入图片描述

三维齐次坐标变换矩阵的形式为
T 3 D = [ a 11 a 12 a 13 a 14 a 21 a 22 a 23 a 24 a 31 a 32 a 33 a 34 a 41 a 42 a 43 a 44 ] T_{3D} = \begin{bmatrix} a_{11} & a_{12} & a_{13} & a_{14} \\ a_{21} & a_{22} & a_{23} & a_{24} \\ a_{31} & a_{32} & a_{33} & a_{34} \\ a_{41} & a_{42} & a_{43} & a_{44} \\ \end{bmatrix} T3D=a11a21a31a41a12a22a32a42a13a23a33a43a14a24a34a44
在这里插入图片描述

二维旋转变换

下面是一个简单的绕原点旋转变换的图。
在这里插入图片描述
本文我们关注的是怎么得到变换之后的坐标,而对于变换后的坐标,很多教材上都只有一个简略的结果,并不会给出详细的推导过程。今天学习旋转变换的时候,对怎么得出变换后的坐标产生了疑惑,花了几分钟才想明白,特此记录一下。

在这里插入图片描述
我们不妨设变换前图形上任意一点的坐标为 P ( x , y ) P(x, y) P(x,y),变换后图形上对应点坐标为 P ′ ( x ′ , y ′ ) P'(x', y') P(x,y)

对于旋转变换来说,我们不妨设旋转角度为 θ,即 ∠ P O P ′ = θ \angle POP' = \theta POP=θ。我们现在就来推导一下 x ′ x' x y ′ y' y 关于 x, y 的表示法。(应该还有更好的证法)

由旋转的性质易知 O P = O P ′ = x 2 + y 2 = d OP = OP' = \sqrt{x^2 + y^2} = d OP=OP=x2+y2 =d

不妨设 ∠ P O x = α \angle POx = \alpha POx=α,有 s i n α = y d sin\alpha = \dfrac{y}{d} sinα=dy c o s α = x d cos\alpha = \dfrac{x}{d} cosα=dx。又有下面这两个方程:
s i n ( α + θ ) = y ′ d c o s ( α + θ ) =    x ′ d sin(\alpha + \theta) = \dfrac{y'}{d} \newline cos(\alpha + \theta) = \space \space \dfrac{x'}{d} sin(α+θ)=dycos(α+θ)=  dx
把这两个方程解出来就可以得到 x’ 和 y’ 的值了(把 sin(a+θ),cos(a+θ) 拆开后,sin a 和 cos a 都已知,把 d 乘过去就行,这里打方程不方便就不敲出具体拆解过程了):
x ′ = x c o s θ − y s i n θ y ′ = x s i n θ + y c o s θ x' = xcos\theta - ysin\theta \newline y' = xsin\theta + ycos\theta \newline x=xcosθysinθy=xsinθ+ycosθ

因此有如下推导

P ′ = [ x ′    y ′    1 ] = [ x c o s θ − y s i n θ    x s i n θ + y c o s θ    1 ] = [ x    y    1 ] [ c o s θ s i n θ 0 − s i n θ c o s θ 0 0 0 1 ] = P ・ R ( θ ) P' = [x'\space\space y'\space\space 1]=[xcos\theta - ysin\theta \space\space xsin\theta + ycos\theta \space\space 1]=[x\space\space y \space\space 1]\begin{bmatrix} cos\theta & sin\theta & 0 \\ -sin\theta & cos\theta & 0 \\ 0 & 0 & 1 \end{bmatrix}=P・R(\theta) P

  • 18
    点赞
  • 65
    收藏
    觉得还不错? 一键收藏
  • 6
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值