图形学的坐标转换问题(局部到世界坐标系,世界到观察坐标系)
2011-01-04 20:22
435 查看
3D图形学的坐标系转换偶感觉比较琐碎的问题。看了后几个月又忘记了。决定又重新看遍,记录下来以增加记忆。但偶太懒了,加上某些描述《Introduction to d3d9c》这本书原著描述的很好了,偶都不敢翻译,就直接粘过来了。
3D图形的表示要经过几个经典的坐标转换,首先从局部到世界坐标系,再从世界坐标系到观察坐标系。下面从数学推导上分别来讲明,概念就百度下了。
首先注意的是这里我们的d3d的坐标系是左手坐标系(d3d也可以有右手的,这里以左手为例)。
6.4.1 Local Space and World Space
将物体从局部坐标系转换到世界坐标系
公式
: ,其中
为局部坐标系中点v的坐标值,
为的v点在世界坐标系的坐标值,
为转换矩阵,其中
。 Let
be 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,Let
be 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:
所以有
,注意
左边的向量
为相应向量在世界坐标系中的坐标,而
是相应向量在观察局部坐标系下的坐标。
从几何上直观的描述可以理解为将观察局部坐标系经过平移,旋转到与世界坐标系重合(没弄错,是从观察坐标系平移旋转到世界坐标系)。
3D图形的表示要经过几个经典的坐标转换,首先从局部到世界坐标系,再从世界坐标系到观察坐标系。下面从数学推导上分别来讲明,概念就百度下了。
首先注意的是这里我们的d3d的坐标系是左手坐标系(d3d也可以有右手的,这里以左手为例)。
6.4.1 Local Space and World Space
将物体从局部坐标系转换到世界坐标系
公式
: ,其中
为局部坐标系中点v的坐标值,
为的v点在世界坐标系的坐标值,
为转换矩阵,其中
。 Let
be 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,Let
be 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:
所以有
,注意
左边的向量
为相应向量在世界坐标系中的坐标,而
是相应向量在观察局部坐标系下的坐标。
从几何上直观的描述可以理解为将观察局部坐标系经过平移,旋转到与世界坐标系重合(没弄错,是从观察坐标系平移旋转到世界坐标系)。
相关文章推荐
- 图形学的坐标转换问题(局部到世界坐标系,世界到观察坐标系)
- DirectX 3D_基础之模型表示 顶点格式 三角形 索引 虚拟摄像机 投影窗口 绘制流水线 局部坐标系 观察坐标系 世界坐标系 背面消隐 光照 裁剪 投影 视口变换 光栅化
- [图形学] 坐标系变换——从世界坐标系到相机坐标系
- 局部坐标系、世界坐标系、矩阵、向量
- OpenCV局部坐标系和世界坐标系转换
- 父子物体中,局部坐标系与世界坐标系的区别
- 3ds max中的对象绕局部坐标系旋转的动画
- opencv坐标系问题
- 世界数学难题之哥尼斯堡七桥问题
- 世界名画陈列馆问题(分支限界法)
- 中缀转后缀问题代码(水数据改变世界=。=)
- [kuangbin带你飞]专题二 搜索进阶 C - 哈密顿绕行世界问题(HDU 2181)
- 坐标系空间转换问题
- 返回函数局部变量的问题
- 白话计算机图形学初步-由一个小问题引发的故事
- 2.1.4 Shading in World Space (about uniforms) 在世界坐标系里着色(关于uniforms参数)
- 【HDU 2181】哈密顿绕行世界问题(DFS)
- 中国国测局地理坐标(GCJ-02)、世界标准地理坐标(WGS-84) 、百度地理坐标(BD-09)坐标系转换
- 函数中返回局部变量的问题
- HDU 2181 哈密顿绕行世界问题