Matrix Structure

Language:

How Do I...?

Describes and manipulates a matrix.

Definition

Visual Basic Public Structure Matrix
C# public struct Matrix 
C++ public value class Matrix sealed 
JScript In JScript, you can use structures, but you cannot define your own.

Members Table

Field Description
M11 Retrieves or sets the element in the first row and the first column of the matrix.
M12 Retrieves or sets the element in the first row and the second column of the matrix.
M13 Retrieves or sets the element in the first row and the third column of the matrix.
M14 Retrieves or sets the element in the first row and the fourth column of the matrix.
M21 Retrieves or sets the element in the second row and the first column of the matrix.
M22 Retrieves or sets the element in the second row and the second column of the matrix.
M23 Retrieves or sets the element in the second row and the third column of the matrix.
M24 Retrieves or sets the element in the second row and the fourth column of the matrix.
M31 Retrieves or sets the element in the third row and the first column of the matrix.
M32 Retrieves or sets the element in the third row and the second column of the matrix.
M33 Retrieves or sets the element in the third row and the third column of the matrix.
M34 Retrieves or sets the element in the third row and the fourth column of the matrix.
M41 Retrieves or sets the element in the fourth row and the first column of the matrix.
M42 Retrieves or sets the element in the fourth row and the second column of the matrix.
M43 Retrieves or sets the element in the fourth row and the third column of the matrix.
M44 Retrieves or sets the element in the fourth row and the fourth column of the matrix.
Method Description
static (Shared in Visual Basic) Add Adds two matrices.
AffineTransformation Builds a 3-D affine transformation matrix.
static (Shared in Visual Basic) AffineTransformation2D Builds a 2-D affine transformation matrix in the xy plane.
Equals Returns a value that indicates whether the current instance is equal to a specified object.
GetHashCode Returns the hash code for the current instance.
Invert Calculates the inverse of a matrix.
static (Shared in Visual Basic) LookAtLH Builds a left-handed look-at matrix.
static (Shared in Visual Basic) LookAtRH Builds a right-handed look-at matrix.
Matrix Initializes a new instance of the Matrix class.
Multiply Determines the product of two matrices.
MultiplyTranspose Calculates the transposed product of two matrices.
static (Shared in Visual Basic) op_Addition Adds two instances of the Matrix structure.
static (Shared in Visual Basic) op_Equality Compares the current instance of a class to another instance to determine whether they are the same.
static (Shared in Visual Basic) op_Inequality Compares the current instance of a class to another instance to determine whether they are different.
static (Shared in Visual Basic) op_Multiply Determines the product of two matrices.
static (Shared in Visual Basic) op_Subtraction Subtracts two instances of the Matrix structure.
static (Shared in Visual Basic) OrthoLH Builds a left-handed orthogonal projection matrix.
static (Shared in Visual Basic) OrthoOffCenterLH Builds a customized, left-handed orthogonal projection matrix.
static (Shared in Visual Basic) OrthoOffCenterRH Builds a customized, right-handed orthogonal projection matrix.
static (Shared in Visual Basic) OrthoRH Builds a right-handed orthogonal projection matrix.
static (Shared in Visual Basic) PerspectiveFovLH Builds a left-handed perspective projection matrix based on a field of view.
static (Shared in Visual Basic) PerspectiveFovRH Builds a right-handed perspective projection matrix based on a field of view (FOV).
static (Shared in Visual Basic) PerspectiveLH Builds a left-handed perspective projection matrix.
static (Shared in Visual Basic) PerspectiveOffCenterLH Builds a customized, left-handed perspective projection matrix.
static (Shared in Visual Basic) PerspectiveOffCenterRH Builds a customized, right-handed perspective projection matrix.
static (Shared in Visual Basic) PerspectiveRH Builds a right-handed perspective projection matrix.
Reflect Builds a matrix that reflects the coordinate system about a plane.
RotateAxis Rotates the matrix around an arbitrary axis.
RotateQuaternion Rotates a matrix from a quaternion.
RotateX Rotates a matrix around the x-axis.
RotateY Rotates a matrix around the y-axis.
RotateYawPitchRoll Rotates a matrix with a specified yaw, pitch, and roll.
RotateZ Rotates the matrix around the z-axis.
static (Shared in Visual Basic) RotationAxis Builds a matrix that rotates around an arbitrary axis.
static (Shared in Visual Basic) RotationQuaternion Builds a matrix from a quaternion.
static (Shared in Visual Basic) RotationX Builds a matrix that rotates around the x-axis.
static (Shared in Visual Basic) RotationY Builds a matrix that rotates around the y-axis.
static (Shared in Visual Basic) RotationYawPitchRoll Builds a matrix with a specified yaw, pitch, and roll.
static (Shared in Visual Basic) RotationZ Builds a matrix that rotates around the z-axis.
Scale Scales the matrix along the x-axis, y-axis, and z-axis.
static (Shared in Visual Basic) Scaling Builds a matrix that scales along the x-axis, y-axis, and z-axis.
Shadow Builds a matrix that flattens geometry into a plane.
static (Shared in Visual Basic) Subtract Subtracts one matrix from another.
ToString Obtains a string representation of the current instance.
Transform Transforms the matrix.
static (Shared in Visual Basic) Transformation Builds a transformation matrix.
static (Shared in Visual Basic) Transformation2D Builds a 2-D transformation matrix in the xy plane.
Translate Translates the matrix using specified offsets.
static (Shared in Visual Basic) Translation Builds a matrix using specified offsets.
Transpose Transposes the matrix using a source matrix.
static (Shared in Visual Basic) TransposeMatrix Returns the matrix transpose of a given matrix.
Property Description
Determinant Retrieves the determinant of the matrix.
static (Shared in Visual Basic) Identity Retrieves the identity of the matrix.
static (Shared in Visual Basic) Zero Retrieves an empty matrix.

Remarks

This structure represents a 4x4 matrix of Single Leave Site values. The fields of this structure are named with the row number first, then the column number.

In Microsoft Direct3D, the M34 element of a projection matrix cannot be a negative number. If an application needs to use a negative value in this location, it should scale the entire projection matrix by -1 instead.

How Do I...?

Set Up a Projection Matrix

This example demonstrates how to set up the projection transformation matrix, which transforms 3-D camera or view space coordinates into 2-D screen coordinates.

See the following C# code example, the Projection transformation matrix is set to be equal to the left-handed (LH) PerspectiveFovLH matrix. Input arguments to PerspectiveFovLH are as follows.

  1. Field of view in radians: pi/4.
  2. Aspect ratio, or view-space height divided by width: 1, for a square window.
  3. Near clipping plane distance: 1 unit.
  4. Far clipping plane distance: 100 units.

              [C#]
              
using Microsoft.DirectX; Direct3D.Device device = null; // Create rendering device. // For the projection matrix, you set up a perspective transform (which // transforms geometry from 3-D view space to 2-D viewport space, with // a perspective divide making objects smaller in the distance). To build // a perspective transform, you need the field of view (1/4 pi is common), // the aspect ratio, and the near and far clipping planes (which define // the distances at which geometry should no longer be rendered). device.Transform.Projection = Matrix.PerspectiveFovLH( (float)Math.PI / 4, 1.0f, 1.0f, 100.0f );

Structure Information

Namespace Microsoft.DirectX
Assembly Microsoft.DirectX (microsoft.directx.dll)
Strong Name Microsoft.DirectX,  Version=1.0.900.0,  Culture=neutral,  PublicKeyToken=d3231b57b74a1492

See Also


Send comments about this topic to Microsoft. © Microsoft Corporation. All rights reserved.

Feedback? Please provide us with your comments on this topic.
For more help, visit the DirectX Developer Center