Homogeneous Coordinates

原文地址: http://sobuhu.com/math/ml/2013/04/27/homo-coord.html


Homogeneous Coordinates

Problem: Two parallel lines can intersect.

 
Railroad gets narrower and meets at horizon.

In Euclidean space (geometry), two parallel lines on the same plane cannot intersect, or cannot meet each other forever. It is a common sense that everyone is familiar with. 

However, it is not true any more in projective space, for example, the train railroad on the side picture becomes narrower while it moves far away from eyes. Finally, the two parallel rails meet at the horizon, which is a point at infinity. 

Euclidean space (or Cartesian space) describe our 2D/3D geometry so well, but they are not sufficient to handle the projective space (Actually, Euclidean geometry is a subset of projective geometry). The Cartesian coordinates of a 2D point can be expressed as (x, y)

What if this point goes far away to infinity? The point at infinity would be (∞,∞), and it becomes meaningless in Euclidean space. The parallel lines should meet at infinity in projective space, but cannot do in Euclidean space. Mathematicians have discoverd a way to solve this issue.

Solution: Homogeneous Coordinates

Homogeneous coordinates, introduced by August Ferdinand Möbius, make calculations of graphics and geometry possible in projective space. Homogeneous coordinates are a way of representing N-dimensional coordinates with N+1 numbers. 

To make 2D Homogeneous coordinates, we simply add an additional variable, w, into existing coordinates. Therefore, a point in Cartesian coordinates, (X, Y) becomes (x, y, w) in Homogeneous coordinates. And X and Y in Cartesian are re-expressed with x, y and w in Homogeneous as; 
X = x/w 
Y = y/w
 

For instance, a point in Cartesian (1, 2) becomes (1, 2, 1) in Homogeneous. If a point, (1, 2), moves toward infinity, it becomes (∞,∞) in Cartesian coordinates. And it becomes (1, 2, 0) in Homogeneous coordinates, because of (1/0, 2/0) ≈ (∞,∞). Notice that we can express the point at infinity without using "∞".

Why is it called "homogeneous"?

As mentioned before, in order to convert from Homogeneous coordinates (x, y, w) to Cartesian coordinates, we simply divide x and y by w
 

Converting Homogeneous to Cartesian, we can find an important fact. Let's see the following example; 
 
As you can see, the points (1, 2, 3), (2, 4, 6) and (4, 8, 12) correspond to the same Euclidean point (1/3, 2/3). And any scalar product, (1a, 2a, 3a) is the same point as (1/3, 2/3) in Euclidean space. Therefore, these points are "homogeneous" because they represent the same point in Euclidean space (or Cartesian space). In other words, Homogeneous coordinates are scale invariant.

Proof: Two parallel lines can intersect.

Consider the following linear system in Euclidean space; 
 
And we know that there is no solution for above equations because of C ≠ D
If C = D, then two lines are identical (overlapped).

Let's rewrite the equations for projective space by replacing x and y to x/w, y/w respectively. 
 
Now, we have a solution, (x, y, 0) since (C - D)w = 0, ∴ w = 0. Therefore, two parallel lines meet at (x, y, 0), which is the point at infinity. 

Homogeneous coordinates are very useful and fundamental concept in computer graphics, such as projecting a 3D scene onto a 2D plane.

关于图形 的二次图形消隐和相关文档 长方体的自隐藏线消隐上机指导 1. 实验目的与要求:掌握长方体的表面模型的建立;掌握三维图形的显示流程;掌握长方体自消隐的算法。 2. 实验步骤: (1)长方体表面模型的定义 三维齐次坐标结构的定义,面结构的定义,面结构中添加可见性属性;顶点表的定义,面表、与顶点表的关系。 (2)几何变换的实现 分别对顶点进行绕X轴旋转和绕Y轴旋转,旋转角度为参数,以实现轴测投影。 (3)消隐 计算每个面的外法向量,与视向量进行点积,给该面的可见性属性赋值。 (4)投影变换的实现 平行投影中正投影的投影变换公式及矩阵,要求以XOY平面为投影平面,Z轴正方向为视线方向。 (3)窗口-视区变换的实现 窗口大小的选取——一般将所有图形都取在窗口内;注意投影变换时投影平面的选取,投影平面上的坐标与视区坐标x,y的对应。 (4)图形显示 显示面表中的每一个面,对于不可见面用虚线绘制该面各边,对于可见面用实线绘制各边。 3. 具体任务 在已给出程序Draw3D2中,在视图类中分别添加绕X轴旋转和绕Y轴旋转的函数void RotateX(int angle)和void RotateY(int angle);在视图类中添加计算外法向量的函数HOMOCOORD GetN(HOMOCOORD p1, HOMOCOORD p2, HOMOCOORD p3),其返回值为外法向量。注意面结构中添加的可见性属性,注意显示图形时对于不可见和可见面的处理。 4. 说明 绕X轴的旋转变化的公式实现: 考虑到旋转变化不影响w分量,可得 其他变换类似。对顶点表每个顶点进行更新。 计算外法向量函数的: P1,p2,p3为面上逆时针依次相连的三个顶点,由此外法向量N=(p2-p1)×(p3-p2); 若令x1=p2.x-p1.x, y1=p2.y-p1.y, z1=p2.z-p1.z; x2=p3.x-p2.x, y2=p3.x-p2.x, z2=p3.x-p2.x; 则外法向量可以由下列行列式求出 即
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值