Problem: Two parallel lines can intercept.
![](https://i-blog.csdnimg.cn/blog_migrate/86ddff3dcf76a0839e850079e548f679.jpeg)
Railroad gets narrower and meets at horizon.
In Euclidean space (geometry), two parallel lines on the same plane cannot intercept, 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.
在欧几里得几何空间里,两条平行线永远都不会相交。但是在投影空间中,如右图中的两条铁轨在地平线处却是会相交的,因为在无限远处它们看起来相交于一点。
在欧几里得(或称笛卡尔)空间里描述2D/3D 几何物体是很理想的,但在投影空间里面却并不见得。 我们用 (x, y) 表示笛卡尔空间中的一个 2D 点,而处于无限远处的点 (∞,∞) 在笛卡尔空间里是没有意义的。投影空间里的两条平行线会在无限远处相交于一点,但笛卡尔空间里面无法搞定这个问题(因为无限远处的点在笛卡尔空间里是没有意义的),因此数学家想出齐次坐标这个点子来了。
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 andY 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 "∞".
解决办法: 其次坐标由 August Ferdinand M?bius 提出的齐次坐标(Homogeneous coordinates)让我们能够在投影空间里进行图像和几何处理,齐次坐标用 N + 1个分量来描述 N 维坐标。比如,2D 齐次坐标是在笛卡尔坐标(X, Y)的基础上增加一个新分量 w,变成(x, y, w),其中笛卡尔坐标系中的大X,Y 与齐次坐标中的小x,y有如下对应关系:
X = x/w笛卡尔坐标中的点 (1, 2) 在齐次坐标中就是 (1, 2, 1) 。如果这点移动到无限远(∞,∞)处,在齐次坐标中就是 (1, 2, 0) ,这样我们就避免了用没意义的"∞" 来描述无限远处的点。
Y = y/w
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;
为什么叫齐次坐标?前面提到,我们分别用齐次坐标中的 x 和 y 除以 w 就得到笛卡尔坐标中的 x 和 x,如图所示:
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.
上图中,点 (1, 2, 3), (2, 4, 6) 和 (4, 8, 12) 对应笛卡尔坐标中的同一点 (1/3, 2/3)。 任意数量积的(1a, 2a, 3a) 始终对应于笛卡尔坐标中的同一点 (1/3, 2/3)。因此这些点是“齐次”的,因为他们始终对应于笛卡尔坐标中的同一点。换句话说,齐次坐标描述缩放不变性(scale invariant)。
Proof: Two parallel lines can intercept.
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.
如果 C ≠ D,以上方程组无解;如果 C = D,那这两条线就是同一条线了。
下面我们用 x/w, y/w 代替 x, y 放到投影空间里来求解:
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.
现在我们就可以在 C ≠ D 的情况得到一组解 (x, y, 0),代入得 (C - D)w = 0,因为 C ≠ D,所以 w = 0。因而,两条平行线相交于投影空间中无限远处的一点 (x, y, 0)。
齐次坐标在计算机图形学中是有用的,将 3D 场景投影到 2D 平面的过程中就用到它了。