齐次坐标

reference websites are:
http://www.songho.ca/math/homogeneous/homogeneous.html
https://learnopengl.com/Getting-started/Transformations

1、问题:两条平行线可用相交
在欧式空间(几何)中,在同一个平面内的两个平行线是不能相交的。
但是在透视空间中,这个就不成立了。比如下图中的火车轨道,离视野远的时候,两个轨道靠的更近了,而在无穷远的地方就会相较于一点。
这里写图片描述

欧式几何或者是笛卡尔能够胜任2D/3D的几何,但是却不能满足透视空间。事实上,欧式几何是透视几何的一个子集。在笛卡尔坐标系中,2D的点描述为(x,y)。
倘若这个点跑到了无穷远处了呢?无穷远处的点为(∞,∞),这个点在欧式空间中是没有意义的。两条平行线在透视空间中是可用相交的,但是在欧式空间中不行。数学家门已经发现一种方法来解决这个问题。
2、解决方法:齐次坐标
齐次坐标是由August Ferdinand Möbius提出的。用于计算透视空间中的图形学和几何。齐次坐标是用N+1个数来表示N维空间坐标。
用齐次坐标来描述2D空间的点,最简单的方法是增加一个变量w。因此笛卡尔坐标系中的点(X,Y)就变为了齐次坐标(x,y,w)。其中X和Y与x,y之间的对应关系为:
X = x/w
Y = y/w
举例,笛卡尔坐标系中的点(1,2)就变为了(1,2,1)。而如果点(1,2)移动到无穷远处,就变为了笛卡尔中的点(∞,∞)。那么在其次坐标中,然后由上面的对应关系,可以让w等于0,这样其其次坐标就为(1,2,0)。因为(1/0,2/0)=(∞,∞)。

3、为什么称之为“其次坐标”
由上面的介绍可以知道,我们可以将其次坐标中每个分量除以第三个分量w,就得到了笛卡尔中的坐标点:
(x,y,w) <=> (x/w, y/w)
把齐次坐标转换为笛卡尔坐标,举例:
(1,2,3)=>(1/3,2/3)
(2,4,6)=>(2/6,4/6)=>(1/3,2/3)
(4,8,12)=>(4/12,8/12)=>(1/3,2/3)
……
(1a,2a,3a)=>(1a/3a,2a/3a)=>(1/3,2/3)
由上面的推导可以看出(1,2,3)、(2,4,6)、(4,8,12)和(1a,2a,3a)转换成笛卡尔坐标之后都是(1/3,2/3)。从另外一个角度来看,其次坐标是从缩放做了变化的,只是缩放的系数不同罢了。

4、证明:两条平行线可以相交
如下面的方程:
这里写图片描述
如果C!=D,则上述方程没有解。
如果C=D,则两条线是重合的。
我们将上述的方程改写成其次坐标形式:
这里写图片描述
此时我们有了一个解,即(x,y,0),所以两条平行线交于无穷远(x,y,0),此时笛卡尔坐标系中的点为(∞,∞),代表无穷远的点。

========================================================
i will introduce homogenous coordiante in other way.
the first question we should pose is that why should we use 4x4 matrix to translate a vector in opengl.

an example, if we want translate a vector to some extend, x+dx, y+dy, z+dz
we should give a 4x4 matrix like this:
这里写图片描述

you will notice that the fourth comonent of vector is 1.
every translation values are mutiplied by this value.
if you take this value to 0. the vector can not be translated. this location, we call this vector is a direction vector.

now, do you have a new cognition of homogeneous coordinate.

at last, how to at a homogeneous coordinate if we have 4 dimension vector. in this scene, you should divide every components by the fourth component. so we should change the fourth component to 1.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值