齐次坐标

1 齐次坐标概念

概念:齐次坐标就是将一个原本是n维的向量用一个n+1维向量来表示,是指一个用于投影几何里的坐标系统
英文:homogeneous coordinates,其中:homogeneous(同质的)。
例如:
标准向量: [ x y z ] \left[\begin{matrix}x\\y\\z\end{matrix}\right] xyz,写为齐次向量形式: [ x y z 1 ] \left[\begin{matrix}x\\y\\z\\1\end{matrix}\right] xyz1

2 引入齐次坐标的目的

许多图形应用涉及到几何变换,主要包括平移、旋转、缩放。以矩阵表达式来计算这些变换时,平移是矩阵相加,旋转和缩放则是矩阵相乘,综合起来可以表示为
x = R ∗ X + t x=R*X+t x=RX+t
其中: R R R为旋转缩放矩阵, t t t为平移向量, X X X为原向量, x x x为变换后的向量。
以上的变换包含了两个部分,即一个乘项 R R R和一个加项 t t t,单次变换还好,如果多次组合变换,那么就非常不方便,能不能用一个统一的乘项矩阵 x = P ∗ X x=P*X x=PX形式来表达?
引入齐次坐标的目的就是合并矩阵运算中的乘法和加法,即它提供了用矩阵运算把二维、三维甚至高维空间中的一个点集从一个坐标系变换到另一个坐标系的有效方法。
例如:
标准的旋转和平移变换
[ X C Y C Z C ] = [ r 00 r 01 r 02 r 10 r 11 r 12 r 20 r 21 r 22 ] [ X Y Z ] + [ T x T y T z ] \left[ \begin{matrix} X_C\\Y_C\\Z_C \end{matrix} \right]= \left[ \begin{matrix} r_{00}&r_{01}&r_{02}\\ r_{10}&r_{11}&r_{12}\\ r_{20}&r_{21}&r_{22} \end{matrix} \right] \left[ \begin{matrix} X\\Y\\Z \end{matrix} \right]+ \left[ \begin{matrix} T_x\\T_y\\T_z \end{matrix} \right] XCYCZC=r00r10r20r01r11r21r02r12r22XYZ+TxTyTz
以齐次坐标表示
[ X C Y C Z C 1 ] = [ r 00 r 01 r 02 T x r 10 r 11 r 12 T y r 20 r 21 r 22 T z 0 0 0 1 ] [ X Y Z 1 ] \left[ \begin{matrix} X_C\\Y_C\\Z_C\\1 \end{matrix} \right]= \left[ \begin{matrix} r_{00}&r_{01}&r_{02}&T_x\\ r_{10}&r_{11}&r_{12}&T_y\\ r_{20}&r_{21}&r_{22}&T_z\\ 0&0&0&1 \end{matrix} \right] \left[ \begin{matrix} X\\Y\\Z\\1 \end{matrix} \right] XCYCZC1=r00r10r200r01r11r210r02r12r220TxTyTz1XYZ1
两者是完全等效的,即齐次坐标方式,可以把旋转(乘项)和平移(加项)合并表示为一个矩阵(乘项)。
反过来看,齐次变换矩阵同时包含了旋转矩阵和平移向量:
M = [ r 00 r 01 r 02 T x r 10 r 11 r 12 T y r 20 r 21 r 22 T z 0 0 0 1 ] = [ R T 0 1 × 3 1 ] M=\left[\begin{matrix} r_{00}&r_{01}&r_{02}&T_x\\ r_{10}&r_{11}&r_{12}&T_y\\ r_{20}&r_{21}&r_{22}&T_z\\ 0&0&0&1 \end{matrix}\right]= \left[\begin{matrix} R&T\\0_{1\times3}&1 \end{matrix}\right] M=r00r10r200r01r11r210r02r12r220TxTyTz1=[R01×3T1]
即左上角的 3 × 3 3\times3 3×3矩阵就是旋转矩阵,而右上角的 1 × 3 1\times3 1×3向量即为平移向量。
齐次坐标变换矩阵也可分解成为平移矩阵与旋转矩阵的乘积
[ R T 0 1 × 3 1 ] = [ I 3 × 3 T 0 1 × 3 1 ] [ R 0 3 × 1 0 1 × 3 1 ] \left[\begin{matrix} R&T\\0_{1\times3}&1 \end{matrix}\right]= \left[\begin{matrix} I_{3\times3}&T\\0_{1\times3}&1 \end{matrix}\right] \left[\begin{matrix} R&0_{3\times1}\\0_{1\times3}&1 \end{matrix}\right] [R01×3T1]=[I3×301×3T1][R01×303×11]
式中 I 3 × 3 I_{3\times3} I3×3为一个 3 × 3 3\times3 3×3单位阵。

3 基本齐次坐标变换矩阵

旋转和平移两种基本的变换,用齐次坐标表示,就有基本齐次坐标变换矩阵
绕X轴旋转: R ( X , θ ) = [ 1 0 0 0 0 c o s θ − s i n θ 0 0 s i n θ c o s θ 0 0 0 0 1 ] R(X,\theta)=\left[\begin{matrix} 1&0&0&0\\ 0&cos\theta&-sin\theta&0\\ 0&sin\theta&cos\theta&0\\ 0&0&0&1 \end{matrix}\right] R(X,θ)=10000cosθsinθ00sinθcosθ00001
绕Y轴旋转: R ( Y , θ ) = [ c o s θ 0 s i n θ 0 0 1 0 0 − s i n θ 0 c o s θ 0 0 0 0 1 ] R(Y,\theta)=\left[\begin{matrix} cos\theta&0&sin\theta&0\\ 0&1&0&0\\ -sin\theta&0&cos\theta&0\\ 0&0&0&1 \end{matrix}\right] R(Y,θ)=cosθ0sinθ00100sinθ0cosθ00001
绕Z轴旋转: R ( Z , θ ) = [ c o s θ − s i n θ 0 0 s i n θ c o s θ 0 0 0 0 1 0 0 0 0 1 ] R(Z,\theta)=\left[\begin{matrix} cos\theta&-sin\theta&0&0\\ sin\theta&cos\theta&0&0\\ 0&0&1&0\\ 0&0&0&1 \end{matrix}\right] R(Z,θ)=cosθsinθ00sinθcosθ0000100001
平移x,y,z: T r a n s ( x , y , z ) = [ 1 0 0 x 0 1 0 y 0 0 1 z 0 0 0 1 ] Trans(x,y,z)=\left[\begin{matrix} 1&0&0&x\\ 0&1&0&y\\ 0&0&1&z\\ 0&0&0&1 \end{matrix}\right] Trans(x,y,z)=100001000010xyz1

4 齐次坐标应该加1还是加0

现在给出一个代数分量表达 ( 1 , 4 , 7 ) (1,4,7) (1,4,7),那么你说它是个向量还是个点?
我们现在把这个表达式变为齐次形式,即再加一维,那么加0还是加1?
这里给出结论:
(1)从普通坐标转换成齐次坐标时
如果(x,y,z)是个点,则变为(x,y,z,1);
如果(x,y,z)是个向量,则变为(x,y,z,0)
(2)从齐次坐标转换成普通坐标时
如果是(x,y,z,1),则知道它是个点,变成(x,y,z);
如果是(x,y,z,0),则知道它是个向量,仍然变成(x,y,z)

参考文献

齐次坐标的理解

  • 5
    点赞
  • 32
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值