图形几何——计算几何:坐标系变换

坐标系变换

二维坐标系转换

旋转变换

假设已知基坐标系 X O Y XOY XOY中的一点 P ( x , y ) P(x,y) P(x,y),坐标原点为 O O O,绕点 O O O旋转 θ \theta θ(逆时针旋转为正值,顺时针旋转为负值),旋转后 P P P在新坐标系 X ′ O Y ′ X'OY' XOY中的坐标值为 ( x ′ , y ′ ) (x',y') (x,y),如下图所示:

在这里插入图片描述

如何求取P在旋转变换后的坐标轴X'OY'中的坐标?

旋转前后的坐标关系可表示如下
x = O A ⇒ x ′ = O F y = A P ⇒ x ′ = P F x = OA \hspace{1cm} \Rightarrow \hspace{1cm} x' = OF \\ y = AP \hspace{1cm} \Rightarrow \hspace{1cm} x' = PF x=OAx=OFy=APx=PF

  • x ′ x' x坐标的求解
    根据投影关系,可以将 O F OF OF分解为 Δ A O D \Delta AOD ΔAOD中的 O D OD OD以及 Δ P A C \Delta PAC ΔPAC中的 A C AC AC,根据三角形几何关系,有
    O F = O D + D F = A O cos ⁡ θ + A P sin ⁡ θ = x cos ⁡ θ + y sin ⁡ θ \begin{split} OF &= OD + DF \\ &= AO\cos\theta + AP\sin\theta \\ &= x\cos\theta + y\sin\theta \end{split} OF=OD+DF=AOcosθ+APsinθ=xcosθ+ysinθ

  • y ′ y' y坐标的求解
    根据投影关系,旋转后的 y ′ y' y坐标为 P F PF PF,根据三角形几何关系,有
    P F = C P − C F = C P − A D = A P cos ⁡ θ − A O sin ⁡ θ = y cos ⁡ θ − x sin ⁡ θ \begin{split} PF &= CP - CF \\ &= CP - AD \\ &= AP\cos\theta - AO\sin\theta\\ &= y\cos\theta - x\sin\theta \end{split} PF=CPCF=CPAD=APcosθAOsinθ=ycosθxsinθ
    汇总表示为
    { x ′ = x cos ⁡ θ + y sin ⁡ θ y ′ = y cos ⁡ θ − x sin ⁡ θ \begin{cases} x' = x\cos\theta + y\sin\theta \\ y' = y\cos\theta - x\sin\theta \end{cases} {x=xcosθ+ysinθy=ycosθxsinθ
    写成矩阵形式为
    [ x ′ y ′ ] = [ cos ⁡ θ sin ⁡ θ − sin ⁡ θ cos ⁡ θ ] [ x y ] \begin{bmatrix} x' \\ y' \end{bmatrix} = \begin{bmatrix} \cos\theta & \sin\theta \\ -\sin\theta & \cos\theta \end{bmatrix} \begin{bmatrix} x \\ y \end{bmatrix} [xy]=[cosθsinθsinθcosθ][xy]
    如果是在机器人相关领域,也习惯简写为如下形式
    [ x ′ y ′ ] = [ c θ s θ − s θ c θ ] [ x y ] \begin{bmatrix} x' \\ y' \end{bmatrix} = \begin{bmatrix} c\theta & s\theta \\ -s\theta & c\theta \end{bmatrix} \begin{bmatrix} x \\ y \end{bmatrix} [xy]=[cθsθsθcθ][xy]

平移变换

假设已知基坐标系 X O Y XOY XOY中的一点 P ( x , y ) P(x,y) P(x,y),坐标原点为 O O O,将坐标系整体平移,假设点 P P P随坐标系一起平移,平移后 P P P在新坐标系 X ′ O Y ′ X'OY' XOY中的坐标值为 ( x ′ , y ′ ) (x',y') (x,y),如下图所示:

在这里插入图片描述

如何求取 P ′ P' P在平移变换后在原坐标轴 X O Y XOY XOY中的坐标?

平移变化符合向量的加法,即
O P ′ = O P + P P ′ = O P + T ( a , b ) \begin{split} OP' &= OP + PP' \\ &= OP + T(a,b) \\ \end{split} OP=OP+PP=OP+T(a,b)
所以
{ x ′ = x + a y ′ = y + b \begin{cases} x' = x + a \\ y' = y + b \end{cases} {x=x+ay=y+b

写成矩阵形式为
[ x ′ y ′ ] = [ c θ s θ − s θ c θ ] [ x y ] + [ a b ] \begin{bmatrix} x' \\ y' \end{bmatrix} = \begin{bmatrix} c\theta & s\theta \\ -s\theta & c\theta \end{bmatrix} \begin{bmatrix} x \\ y \end{bmatrix} + \begin{bmatrix} a \\ b \end{bmatrix} [xy]=[cθsθsθcθ][xy]+[ab]

旋转-平移变换

旋转平移变换是以上两种情况的叠加,已知旋转平移后的坐标系 X ′ O ′ Y ′ X'O'Y' XOY中的一点 P ′ ( x ′ , y ′ ) P'(x',y') P(x,y),求 P ′ P' P在基坐标系中的坐标值

在这里插入图片描述

可以先求出 P ′ P' P在旋转后的坐标系 X ′ O Y ′ X'OY' XOY中的坐标值,然后坐标系 X ′ O Y ′ X'OY' XOY平移变换到 X O Y XOY XOY

{ x = x ′ cos ⁡ θ + y ′ sin ⁡ θ + a y = y ′ cos ⁡ θ − x ′ sin ⁡ θ + b \begin{cases} x = x'\cos\theta + y'\sin\theta + a\\ y = y'\cos\theta - x'\sin\theta + b \end{cases} {x=xcosθ+ysinθ+ay=ycosθxsinθ+b
写成矩阵形式为
[ x ′ y ′ ] = [ c θ s θ − s θ c θ ] [ x y ] + [ a b ] \begin{bmatrix} x' \\ y' \end{bmatrix} = \begin{bmatrix} c\theta & s\theta \\ -s\theta & c\theta \end{bmatrix} \begin{bmatrix} x \\ y \end{bmatrix} + \begin{bmatrix} a \\ b \end{bmatrix} [xy]=[cθsθsθcθ][xy]+[ab]

三维坐标系转换

旋转矩阵

  • 绕x轴旋转
    R ( x , θ ) = [ cos ⁡ θ − sin ⁡ θ 0 sin ⁡ θ cos ⁡ θ 0 0 0 1 ] = [ c θ − s θ 0 s θ c θ 0 0 0 1 ] R(x,\theta) = \begin{bmatrix} \cos\theta & -\sin \theta & 0 \\ \sin\theta & \cos\theta & 0 \\ 0 & 0 & 1 \end{bmatrix} = \begin{bmatrix} c\theta & -s\theta & 0 \\ s\theta & c\theta & 0 \\ 0 & 0 & 1 \end{bmatrix} R(x,θ)= cosθsinθ0sinθcosθ0001 = cθsθ0sθcθ0001
  • 绕y轴旋转
    R ( y , θ ) = [ 1 0 0 0 cos ⁡ θ − sin ⁡ θ 0 sin ⁡ θ cos ⁡ θ ] = [ 1 0 0 0 c θ − s θ 0 s θ c θ ] R(y,\theta) = \begin{bmatrix} 1 & 0 & 0 \\ 0 & \cos\theta & -\sin\theta \\ 0 & \sin\theta & \cos\theta \end{bmatrix} = \begin{bmatrix} 1 & 0 & 0 \\ 0 & c\theta & -s\theta \\ 0 & s\theta & c\theta \end{bmatrix} R(y,θ)= 1000cosθsinθ0sinθcosθ = 1000cθsθ0sθcθ
  • 绕z轴旋转
    R ( z , θ ) = [ cos ⁡ θ 0 sin ⁡ θ 0 1 0 − sin ⁡ θ 0 cos ⁡ θ ] = [ c θ 0 s θ 0 1 0 − s θ 0 c θ ] R(z,\theta) = \begin{bmatrix} \cos\theta & 0 & \sin\theta \\ 0 & 1 & 0 \\ -\sin\theta & 0 & \cos\theta \end{bmatrix} = \begin{bmatrix} c\theta & 0 & s\theta \\ 0 & 1 & 0 \\ -s\theta & 0 & c\theta \end{bmatrix} R(z,θ)= cosθ0sinθ010sinθ0cosθ = cθ0sθ010sθ0cθ
  • 23
    点赞
  • 12
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值