• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            C++ Programmer's Cookbook

            {C++ 基礎(chǔ)} {C++ 高級(jí)} {C#界面,C++核心算法} {設(shè)計(jì)模式} {C#基礎(chǔ)}

            Managed DirectX --- Matrix&Transform(Translation and Scaling and Rotation)

            • 一 Translation

            The following transformation translates the point (x, y, z) to a new point (x', y', z').

            Translate 18

            You can manually create a translation matrix in managed code. The following C# code example shows the source code for a function that creates a matrix to translate vertices.

            						[C#]
            						
            private Matrix TranslateMatrix(float dx, float dy, float dz) { Matrix ret; ret = Matrix.Identity; ret.M41 = dx; ret.M42 = dy; ret.M43 = dz; return ret; }

            For convenience, managed the Microsoft Direct3D supplies the Translation method.

            • 二 Scaling

            The following transformation scales the point (x, y, z) by arbitrary values in the x-, y-, and z-directions to a new point (x', y', z').

            Matrix scale?


            • 三?? Rotation

            ?

            The transformations described here are for left-handed coordinate systems, and so might be different from transformation matrices that you have seen elsewhere. For more information, see 3-D Coordinate Systems.

            The following transformation rotates the point (x, y, z) around the x-axis, producing a new point (x', y', z').

            Matrix x rotation

            The following transformation rotates the point around the y-axis.

            Matrix y rotation

            The following transformation rotates the point around the z-axis.

            Matrix z rotation

            In these example matrices, the Greek letter theta (?) stands for the angle of rotation, in radians. Angles are measured clockwise when looking along the rotation axis toward the origin.

            In a managed application, use the Matrix.RotationX, Matrix.RotationY, and Matrix.RotationZ methods to create rotation matrices. The following C# code example demonstrates how the Matrix.RotationX method performs a rotation.

            				[C#]
            				
            private Matrix MatrixRotationX(float angle) { double sin, cos; sin = Math.Sin(angle); cos = Math.Cos(angle); Matrix ret; ret.M11 = 1.0f; ret.M12 = 0.0f; ret.M13 = 0.0f; ret.M14 = 0.0f; ret.M21 = 0.0f; ret.M22 = (float)cos; ret.M23 = (float)sin; ret.M24 = 0.0f; ret.M31 = 0.0f; ret.M32 = (float)-sin; ret.M33 = (float)cos; ret.M34 = 0.0f; ret.M41 = 0.0f; ret.M42 = 0.0f; ret.M43 = 0.0f; ret.M44 = 1.0f; return ret; }

            • 四? Matrix Concatenation

            One advantage of using matrices is that you can combine the effects of two or more matrices by multiplying them. This means that, to rotate a model and then translate it to some location, you do not need to apply two matrices. Instead, you multiply the rotation and translation matrices to produce a composite matrix that contains all of their effects. This process, called matrix concatenation, can be written with the following formula.

            Matrix concatination

            In this formula, C is the composite matrix being created, and M1 through Mn are the individual transformations that matrix C contains. In most cases, only two or three matrices are concatenated, but there is no limit.

            Use the Matrix.Multiply method to perform matrix multiplication.

            The order in which the matrix multiplication is performed is crucial. The preceding formula reflects the left-to-right rule of matrix concatenation. That is, the visible effects of the matrices that you use to create a composite matrix occur in left-to-right order. A typical world transformation matrix is shown in the following example. Imagine that you are creating the world transformation matrix for a stereotypical flying saucer. You would probably want to spin the flying saucer around its center - the y-axis of model space - and translate it to some other location in your scene. To accomplish this effect, you first create a rotation matrix, and then multiply it by a translation matrix, as shown in the following formula.

            World Space explanation

            In this formula, Ry is a matrix for rotation about the y-axis, and Tw is a translation to some position in world coordinates.

            The order in which you multiply the matrices is important because, unlike multiplying two scalar values, matrix multiplication is not commutative. Multiplying the matrices in the opposite order has the visual effect of translating the flying saucer to its world space position, and then rotating it around the world origin.

            No matter what type of matrix you are creating, remember the left-to-right rule to ensure that you achieve the expected effects.

            到底什么時(shí)候在左邊什么時(shí)候在右邊?


            總結(jié):

            • 五 3-D Transformations


            In applications that work with 3-D graphics, geometrical transformations can be used to do the following.

            • Express the location of an object relative to another object.
            • Rotate and size objects.
            • Change viewing positions, directions, and perspectives.

            You can transform any point (x,y,z) into another point (x', y', z') using a 4 x 4 matrix.

            Matrix multiply

            Perform the following operations on (x, y, z) and the matrix to produce the point (x', y', z').

            Matrix expanded

            The most common transformations are translation, rotation, and scaling. You can combine the matrices that produce these effects into a single matrix to calculate several transformations at once.

            posted on 2006-05-09 16:10 夢在天涯 閱讀(1392) 評(píng)論(0)  編輯 收藏 引用 所屬分類: DirectX

            公告

            EMail:itech001#126.com

            導(dǎo)航

            統(tǒng)計(jì)

            • 隨筆 - 461
            • 文章 - 4
            • 評(píng)論 - 746
            • 引用 - 0

            常用鏈接

            隨筆分類

            隨筆檔案

            收藏夾

            Blogs

            c#(csharp)

            C++(cpp)

            Enlish

            Forums(bbs)

            My self

            Often go

            Useful Webs

            Xml/Uml/html

            搜索

            •  

            積分與排名

            • 積分 - 1807518
            • 排名 - 5

            最新評(píng)論

            閱讀排行榜

            婷婷久久精品国产| 国产精品欧美久久久天天影视| 亚洲综合精品香蕉久久网97| 久久青草国产手机看片福利盒子| 91精品免费久久久久久久久| 久久久免费观成人影院| 精品国产乱码久久久久软件| 99久久人妻无码精品系列| 国产精品久久久久久久午夜片| 久久久久国产精品人妻| 久久婷婷综合中文字幕| 久久这里只有精品首页| 亚洲天堂久久精品| 久久天天躁狠狠躁夜夜avapp | 久久婷婷人人澡人人爽人人爱| 久久午夜无码鲁丝片| 日本久久久久久久久久| 久久久无码一区二区三区 | 欧美黑人又粗又大久久久| 精品欧美一区二区三区久久久| 久久久久亚洲AV成人网人人网站| 97精品国产91久久久久久| av色综合久久天堂av色综合在| 国内精品久久久久久久亚洲| 国产综合久久久久| 亚洲色婷婷综合久久| 久久天天躁狠狠躁夜夜不卡| 午夜视频久久久久一区 | 久久亚洲国产成人精品性色| 午夜精品久久久久久久无码| 久久99精品久久久久久野外| 色综合色天天久久婷婷基地| 91精品国产乱码久久久久久| 久久er99热精品一区二区| 国内精品伊人久久久久妇| 国产69精品久久久久观看软件 | 久久精品国产精品亚洲艾草网美妙| 久久精品亚洲中文字幕无码麻豆| 日日噜噜夜夜狠狠久久丁香五月| 亚洲AV日韩精品久久久久| 看久久久久久a级毛片|