现在的位置: 首页 > 综合 > 正文

图形学的坐标转换问题(局部到世界坐标系,世界到观察坐标系)

2013年10月10日 ⁄ 综合 ⁄ 共 2232字 ⁄ 字号 评论关闭

3D图形学的坐标系转换偶感觉比较琐碎的问题。看了后几个月又忘记了。决定又重新看遍,记录下来以增加记忆。但偶太懒了,加上某些描述《Introduction to d3d9c》这本书原著描述的很好了,偶都不敢翻译,就直接粘过来了。

    3D图形的表示要经过几个经典的坐标转换,首先从局部到世界坐标系,再从世界坐标系到观察坐标系。下面从数学推导上分别来讲明,概念就百度下了。

   首先注意的是这里我们的d3d的坐标系是左手坐标系(d3d也可以有右手的,这里以左手为例)

    6.4.1 Local Space and World Space

    将物体从局部坐标系转换到世界坐标系

    公式 ,其中局部坐标系中点v的坐标值,为的v点在世界坐标系的坐标值,

 为转换矩阵,其中 Letbe the origin and let , and be the basis vectors of the camera's local system relative to the world system。即上面的r轴对应局部坐标系通常理解的x轴,u为y轴,f为z轴。

   而,


 

   则

   

   (6.1)

其几何意义可以通过举一个例子来理解,假设在局部坐标系中的r轴的坐标为: =。那么求在世界坐标系下的坐标,如下:

=*R*T=
= 

即它在世界坐标系中的坐标等于其局部坐标系的原点加上局部坐标系的轴(可以理解为局部坐标系的x轴)的单位法向量

 

6.4.2 将对象描述从世界坐标系变换到观察坐标系。《introduction to d3d9c》中英文描述的很好了,偶不敢翻译,直接粘过来好了。

  We can think of the camera as an object in the world as well, and we can choose to make the camera the frame of reference in which we describe vertices relative to instead of the world coordinate system. Let the camera be centered about its own local coordinate system (called view space or the camera coordinate system) looking down the positive z-axis. Moreover,Letbe the origin and let , and be the basis vectors of the camera's local system relative to the world system. Then the world transformation matrix(equation6.1) transforms the camera from its local coordinate system to the world space. However, this is not what we want, as projection and other operations are difficult or less efficient when the camera is at an arbitrary position and orientation in the world. To make things easier, we actually want the camera to be the center of the scene (i.e., we describe the objects' vertices relative to the camera coordinate system). Thus, we actually want the reverse transformation; that is, we want to transform all of the objects in world space to view space. But recall from
chapter2 
that the reverse transformation is just given by the inverse. Thus,  transforms from world space to view space.Now observe that a change of frame matrix really does a rotation and translation transformation on the vertices. Thus, we can write

 , where R is purely a rotation matrix and T is purely a translation matrix. we have:

 

 

 

    所以有,注意左边的向量为相应向量在世界坐标系中的坐标,而

 是相应向量在观察局部坐标系下的坐标。

    从几何上直观的描述可以理解为将观察局部坐标系经过平移,旋转到与世界坐标系重合(没弄错,是从观察坐标系平移旋转到世界坐标系)。

抱歉!评论已关闭.