当前位置:   article > 正文

坐标系统

坐标系统

    典型的3D图形应用程序使用两种类型的笛卡尔坐标系:左手坐标系和右手坐标系。在这两种坐标系中,X轴正方向指向右方,Y轴正方向指向上方。你可以通过让你的左手或者右手的指头沿着X轴的正方向并让它们向Y轴正方向弯曲来记住Z轴正方向朝哪,它就是你拇指指向的方向,远离你或者指向你,这个方向就是那个坐标系的Z轴正方向。下面的插图说明了这两个坐标系。

 

     图见相应DX文档
    
    Direct3D 使用左手坐标系,如果你正在移植一个基于右手坐标系的应用程序,那你必须对传给Direct3D的数据做2点变化。
    。翻转三角形定点的顺序以便于系统从头按顺时针方向遍历它们。换句话说,如果顶点是V0,V1,V2,把他们传给Direct3D时就得变成V0,V2,V1。
    。使视口矩阵以Z方向上的-1值去度量世界空间。要做到这一点,请翻转你的视口矩阵所使用的D3DMATRIX结构的标记为_31,_32,_33和_34的成员。
    为了完整显示右手坐标系世界,应使用D3DXMatrixPerspectiveRH和D3DXMatrixOrthoRH函数去定义投影变换,无论如何,应该小心地使用相应的D3DXMatrixLookAtRH函数,反转背面提出顺序,并订制出相应的立方体映射。
    尽管左手和右手坐标系是最常用的坐标系统,但是仍然有其他不同的坐标系被3D软件使用,例如,不同寻常的3D建模应用程序使用Y轴朝着或者远离观察者的坐标系,而且Z轴指向上方。
    严格来讲,一个坐标系的基本向量的方向可以通过被基本向量的详细设置定义过的矩阵的行列式计算被发现。如果行列式是正的,则这个坐标系被称为积极主导(或者右手坐标系),如果行列式是负的,则这个坐标系被称为消极主导(或者左手坐标系)。如果想知道什么是行列式,请看一些线性代数资料。
    一般来说,你可以用左/右手法则从左手坐标系或右手坐标系去判断一个给定的基本向量。
    被定义在3D坐标系中的对象的可执行操作有平移,旋转,缩放。你可以结合这些基本变换去创建一个变换矩阵,想了解详细资料,请看Transforms。
    当你结合一些操作,计算出来的结果不能互换的;你相乘矩阵的顺序至关重要。

 

原文

Coordinate Systems

Typically 3D graphics applications use two types of Cartesian coordinate systems: left-handed and right-handed. In both coordinate systems, the positive x-axis points to the right, and the positive y-axis points up. You can remember which direction the positive z-axis points by pointing the fingers of either your left or right hand in the positive x-direction and curling them into the positive y-direction. The direction your thumb points, either toward or away from you, is the direction that the positive z-axis points for that coordinate system. The following illustration shows these two coordinate systems.

 

    图见相应DX文档

 

Direct3D uses a left-handed coordinate system. If you are porting an application that is based on a right-handed coordinate system, you must make two changes to the data passed to Direct3D.

  • Flip the order of triangle vertices so that the system traverses them clockwise from the front. In other words, if the vertices are v0, v1, v2, pass them to Direct3D as v0, v2, v1.
  • Use the view matrix to scale world space by -1 in the z-direction. To do this, flip the sign of the _31, _32, _33, and _34 member of the D3DMATRIX structure that you use for your view matrix.

To obtain what amounts to a right-handed world, use the D3DXMatrixPerspectiveRH and D3DXMatrixOrthoRH functions to define the projection transform. However, be careful to use the corresponding D3DXMatrixLookAtRH function, reverse the backface-culling order, and lay out the cube maps accordingly.

Although left-handed and right-handed coordinates are the most common systems, there is a variety of other coordinate systems used in 3D software. For example, it is not unusual for 3D modeling applications to use a coordinate system in which the y-axis points toward or away from the viewer, and the z-axis points up.

Formally, the orientation of a set of basis vectors (i.e. a coordinate system) can be found by the computing the determinant of the matrix defined by the particular set of basis vectors. If the determinant is positive, the basis is said to be "positively" oriented (or right-handed). If the determinant is negative, the basis is said to be "negatively" oriented (or left-handed). For an explanation of what a determinant is, see any linear algebra resource.

Informally, you can use the "right/left hand rule" to determine if a given set of basis vectors form either a right or left handed coordinate system.

The essential operations performed on objects defined in a 3D coordinate system are translation, rotation, and scaling. You can combine these basic transformations to create a transform matrix. For details, see Transforms.

When you combine these operations, the results are not commutative; the order in which you multiply matrices is important.


    
    
   

   

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/weixin_40725706/article/detail/416028
推荐阅读
相关标签
  

闽ICP备14008679号