理解变换矩阵

相机(坐标系)的旋转

设相机从 o − x y z o-xyz oxyz坐标系经过旋转之后形成新的 o ′ − x ′ y ′ z ′ o'-x'y'z' oxyz坐标系,而 o − x y z o-xyz oxyz坐标系下的一组单位正交基 ( e ^ 1 , e ^ 2 , e ^ 3 ) (\hat{e}_1, \hat{e}_2, \hat{e}_3) (e^1,e^2,e^3)经过旋转之后变为 ( e ^ 1 ′ , e ^ 2 ′ , e ^ 3 ′ ) (\hat{e}^{\prime}_1, \hat{e}^{\prime}_2, \hat{e}^{\prime}_3) (e^1,e^2,e^3)。对于同一个向量 a ⃗ \vec{a} a ,它在两个坐标系下的坐标分别为 [ a 1 , a 2 , a 3 ] T {[a_1,a_2,a_3]}^T [a1,a2,a3]T [ a 1 ′ , a 2 ′ , a 3 ′ ] T {[a^{\prime}_1,a^{\prime}_2,a^{\prime}_3]}^T [a1,a2,a3]T。于是以下等式成立:
(1) [ e ^ 1 , e ^ 2 , e ^ 3 ] [ a 1 a 2 a 3 ] = [ e ^ 1 ′ , e ^ 2 ′ , e ^ 3 ′ ] [ a 1 ′ a 2 ′ a 3 ′ ] [\hat{e}_1, \hat{e}_2, \hat{e}_3]\left[\begin{matrix}a_1\\a_2\\a_3\end{matrix}\right]=[\hat{e}^{\prime}_1, \hat{e}^{\prime}_2, \hat{e}^{\prime}_3]\left[\begin{matrix}a^{\prime}_1\\a^{\prime}_2\\a^{\prime}_3\end{matrix}\right] \tag 1 [e^1,e^2,e^3]a1a2a3=[e^1,e^2,e^3]a1a2a3(1)

等式两边同时左乘 [ e ^ 1 T e ^ 2 T e ^ 3 T ] \left[\begin{matrix}\hat{e}^T_1\\\hat{e}^T_2\\\hat{e}^T_3\end{matrix}\right] e^1Te^2Te^3T,得到下式:
(2) [ a 1 a 2 a 3 ] = [ e ^ 1 T e ^ 1 ′ e ^ 1 T e ^ 2 ′ e ^ 1 T e ^ 3 ′ e ^ 2 T e ^ 1 ′ e ^ 2 T e ^ 2 ′ e ^ 2 T e ^ 3 ′ e ^ 3 T e ^ 1 ′ e ^ 3 T e ^ 2 ′ e ^ 3 T e ^ 3 ′ ] [ a 1 ′ a 2 ′ a 3 ′ ] ≜ R [ a 1 ′ a 2 ′ a 3 ′ ] \left[\begin{matrix}a_1\\a_2\\a_3\end{matrix}\right]=\left[\begin{matrix}\hat{e}^T_1 \hat{e}^{\prime}_1 & \hat{e}^T_1 \hat{e}^{\prime}_2 & \hat{e}^T_1 \hat{e}^{\prime}_3 \\ \hat{e}^T_2 \hat{e}^{\prime}_1 & \hat{e}^T_2 \hat{e}^{\prime}_2 & \hat{e}^T_2 \hat{e}^{\prime}_3 \\ \hat{e}^T_3 \hat{e}^{\prime}_1 & \hat{e}^T_3 \hat{e}^{\prime}_2 & \hat{e}^T_3 \hat{e}^{\prime}_3\end{matrix}\right]\left[\begin{matrix}a^{\prime}_1\\a^{\prime}_2\\a^{\prime}_3\end{matrix}\right]\triangleq{\mathbf{R}\left[\begin{matrix}a^{\prime}_1\\a^{\prime}_2\\a^{\prime}_3\end{matrix}\right]} \tag 2 a1a2a3=e^1Te^1e^2Te^1e^3Te^1e^1Te^2e^2Te^2e^3Te^2e^1Te^3e^2Te^3e^3Te^3a1a2a3Ra1a2a3(2)

矩阵 R \mathbf{R} R称为旋转矩阵,它描述了从 o − x y z o-xyz oxyz o ′ − x ′ y ′ z ′ o'-x'y'z' oxyz的旋转。
由于旋转矩阵为正交矩阵,故有:
(3) [ a 1 ′ a 2 ′ a 3 ′ ] = R − 1 [ a 1 a 2 a 3 ] = R T [ a 1 a 2 a 3 ] \left[\begin{matrix}a^{\prime}_1\\a^{\prime}_2\\a^{\prime}_3\end{matrix}\right]=\mathbf{R}^{-1}\left[\begin{matrix}a_1\\a_2\\a_3\end{matrix}\right]=\mathbf{R}^T\left[\begin{matrix}a_1\\a_2\\a_3\end{matrix}\right] \tag 3 a1a2a3=R1a1a2a3=RTa1a2a3(3)

旋转矩阵的例子:

坐标系绕z轴转 θ \theta θ角,对应的旋转矩阵为: R = [ c o s θ − s i n θ 0 s i n θ c o s θ 0 0 0 1 ] \mathbf{R}=\left[\begin{matrix}cos\theta & -sin\theta & 0 \\ sin\theta & cos\theta & 0 \\ 0 & 0 & 1\end{matrix}\right] R=cosθsinθ0sinθcosθ0001

相机(坐标系)的平移

相机的平移可用一个平移向量 t ⃗ \vec{t} t 表示。
设相机从 o − x y z o-xyz oxyz坐标系沿着向量 t ⃗ \vec{t} t (它在o-xyz坐标系下的坐标为 [ t 1 , t 2 , t 3 ] T {[t_1,t_2,t_3]}^T [t1,t2,t3]T)经过平移之后形成新的 o ′ − x ′ y ′ z ′ o'-x'y'z' oxyz坐标系。对于同一个点 P P P,它在两个坐标系下的坐标分别为 [ p 1 , p 2 , p 3 ] T {[p_1,p_2,p_3]}^T [p1,p2,p3]T [ p 1 ′ , p 2 ′ , p 3 ′ ] T {[p^{\prime}_1,p^{\prime}_2,p^{\prime}_3]}^T [p1,p2,p3]T,则有:
(4) p ⃗ = p ⃗ ′ + t ⃗ \vec{p}=\vec{p}^{\prime}+\vec{t} \tag 4 p =p +t (4)
即: [ p 1 , p 2 , p 3 ] T = [ p 1 ′ , p 2 ′ , p 3 ′ ] T + [ t 1 , t 2 , t 3 ] T {[p_1,p_2,p_3]}^T={[p^{\prime}_1,p^{\prime}_2,p^{\prime}_3]}^T+{[t_1,t_2,t_3]}^T [p1,p2,p3]T=[p1,p2,p3]T+[t1,t2,t3]T

旋转+平移

假设相机先后经过一次旋转 R \mathbf{R} R和一次平移 t ′ ⃗ \vec{t^{\prime}} t 之后,对应的坐标系由 o − x y z o-xyz oxyz变为 o ′ − x ′ y ′ z ′ o^{\prime}-x'y'z' oxyz再变为 o ′ ′ − x ′ ′ y ′ ′ z ′ ′ o''-x''y''z'' oxyz,向量 a ⃗ \vec{a} a 在各个坐标系下的坐标分别为 [ a 1 , a 2 , a 3 ] T {[a_1,a_2,a_3]}^T [a1,a2,a3]T [ a 1 ′ , a 2 ′ , a 3 ′ ] T {[a^{\prime}_1,a^{\prime}_2,a^{\prime}_3]}^T [a1,a2,a3]T [ a 1 ′ ′ , a 2 ′ ′ , a 3 ′ ′ ] T {[a^{\prime\prime}_1,a^{\prime\prime}_2,a^{\prime\prime}_3]}^T [a1,a2,a3]T,则有:
(5) [ a 1 a 2 a 3 ] = R o ′ o ( [ a 1 ′ ′ a 2 ′ ′ a 3 ′ ′ ] + [ t 1 ′ t 2 ′ t 3 ′ ] ) = R [ a 1 ′ ′ a 2 ′ ′ a 3 ′ ′ ] + [ t 1 t 2 t 3 ] \left[\begin{matrix}a_1\\a_2\\a_3\end{matrix}\right]=\mathbf{R_{o'o}}\left(\left[\begin{matrix}a^{\prime\prime}_1\\a^{\prime\prime}_2\\a^{\prime\prime}_3\end{matrix}\right]+\left[\begin{matrix}t^{\prime}_1\\t^{\prime}_2\\t^{\prime}_3\end{matrix}\right]\right)=\mathbf{R}\left[\begin{matrix}a^{\prime\prime}_1\\a^{\prime\prime}_2\\a^{\prime\prime}_3\end{matrix}\right]+\left[\begin{matrix}t_1\\t_2\\t_3\end{matrix}\right] \tag 5 a1a2a3=Rooa1a2a3+t1t2t3=Ra1a2a3+t1t2t3(5)
假设相机先平移 t ⃗ \vec{t} t 再旋转 R \mathbf{R} R,则向量 a ⃗ \vec{a} a 在变换前后的坐标之间的关系为:
(6) [ a 1 a 2 a 3 ] = R o ′ ′ o ′ [ a 1 ′ ′ a 2 ′ ′ a 3 ′ ′ ] + [ t 1 t 2 t 3 ] = R [ a 1 ′ ′ a 2 ′ ′ a 3 ′ ′ ] + [ t 1 t 2 t 3 ] \left[\begin{matrix}a_1\\a_2\\a_3\end{matrix}\right]=\mathbf{R_{o''o'}}\left[\begin{matrix}a^{\prime\prime}_1\\a^{\prime\prime}_2\\a^{\prime\prime}_3\end{matrix}\right]+\left[\begin{matrix}t_1\\t_2\\t_3\end{matrix}\right]=\mathbf{R}\left[\begin{matrix}a^{\prime\prime}_1\\a^{\prime\prime}_2\\a^{\prime\prime}_3\end{matrix}\right]+\left[\begin{matrix}t_1\\t_2\\t_3\end{matrix}\right] \tag 6 a1a2a3=Rooa1a2a3+t1t2t3=Ra1a2a3+t1t2t3(6)

齐次变换矩阵

引入齐次坐标,将旋转和平移写到一个矩阵里面:
(7) [ a 1 ] = [ R t 0 T 1 ] [ a ′ ′ 1 ] ≜ T [ a ′ ′ 1 ] \left[\begin{matrix}\mathbf{a} \\ 1\end{matrix}\right]=\left[\begin{matrix}R & \mathbf{t} \\ \mathbf{0}^T & 1\end{matrix}\right]\left[\begin{matrix}\mathbf{a''} \\ 1\end{matrix}\right]\triangleq{\mathbf{T}\left[\begin{matrix}\mathbf{a''} \\ 1\end{matrix}\right]} \tag 7 [a1]=[R0Tt1][a1]T[a1](7)
T \mathbf{T} T即为齐次坐标下的坐标变换矩阵。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值