Share via


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. For example, you can build a single matrix to translate and rotate a series of points. For more information, see Matrix Concatenation.

Matrices are written in row-column order. A matrix that evenly scales vertices along each axis, a process known as uniform scaling, is represented by the following matrix using mathematical notation.

Matrix

Microsoft Direct3D declares matrices as a two-dimensional array, using the Matrix structure. The following C# code example shows how to create a Matrix structure to act as a uniform scaling matrix.

          [C#]
          

// In this example, s is a variable of type float.
Matrix scale = new Matrix();
                    
scale.M11=s;    scale.M12=0.0f; scale.M13=0.0f; scale.M14=0.0f;
scale.M21=0.0f; scale.M22=s;    scale.M23=0.0f; scale.M24=0.0f;
scale.M31=0.0f; scale.M32=0.0f; scale.M33=s;    scale.M34=0.0f;
scale.M41=0.0f; scale.M42=0.0f; scale.M43=0.0f; scale.M44=1.0f;