# Matrix Structure

Defines a matrix.

Namespace:  Microsoft.Xna.Framework
Assembly:  Microsoft.Xna.Framework.Math (in Microsoft.Xna.Framework.Math.dll)

## Syntax

'Declaration
Public Structure Matrix
public struct Matrix

The Matrix type exposes the following members.

## Constructors

Name Description
Matrix Initializes a new instance of Matrix.

Top

## Properties

Name Description
Backward Gets and sets the backward vector of the Matrix.
Down Gets and sets the down vector of the Matrix.
Forward Gets and sets the forward vector of the Matrix.
Identity Returns an instance of the identity matrix.
Left Gets and sets the left vector of the Matrix.
Right Gets and sets the right vector of the Matrix.
Translation Gets and sets the translation vector of the Matrix.
Up Gets and sets the up vector of the Matrix.

Top

## Methods

Name Description
CreateBillboard(Vector3, Vector3, Vector3, Nullable<Vector3>) Creates a spherical billboard that rotates around a specified object position.
CreateBillboard(Vector3%, Vector3%, Vector3%, Nullable<Vector3>, Matrix%) Creates a spherical billboard that rotates around a specified object position.
CreateConstrainedBillboard(Vector3, Vector3, Vector3, Nullable<Vector3>, Nullable<Vector3>) Creates a cylindrical billboard that rotates around a specified axis.
CreateConstrainedBillboard(Vector3%, Vector3%, Vector3%, Nullable<Vector3>, Nullable<Vector3>, Matrix%) Creates a cylindrical billboard that rotates around a specified axis.
CreateFromAxisAngle(Vector3, Single) Creates a new Matrix that rotates around an arbitrary vector.
CreateFromAxisAngle(Vector3%, Single, Matrix%) Creates a new Matrix that rotates around an arbitrary vector.
CreateFromQuaternion(Quaternion) Creates a rotation Matrix from a Quaternion.
CreateFromQuaternion(Quaternion%, Matrix%) Creates a rotation Matrix from a Quaternion.
CreateFromYawPitchRoll(Single, Single, Single) Creates a new rotation matrix from a specified yaw, pitch, and roll.
CreateFromYawPitchRoll(Single, Single, Single, Matrix%) Fills in a rotation matrix from a specified yaw, pitch, and roll.
CreateLookAt(Vector3, Vector3, Vector3) Creates a view matrix.
CreateLookAt(Vector3%, Vector3%, Vector3%, Matrix%) Creates a view matrix.
CreateOrthographic(Single, Single, Single, Single) Builds an orthogonal projection matrix.
CreateOrthographic(Single, Single, Single, Single, Matrix%) Builds an orthogonal projection matrix.
CreateOrthographicOffCenter(Single, Single, Single, Single, Single, Single) Builds a customized, orthogonal projection matrix.
CreateOrthographicOffCenter(Single, Single, Single, Single, Single, Single, Matrix%) Builds a customized, orthogonal projection matrix.
CreatePerspective(Single, Single, Single, Single) Builds a perspective projection matrix and returns the result by value.
CreatePerspective(Single, Single, Single, Single, Matrix%) Builds a perspective projection matrix and returns the result by reference.
CreatePerspectiveFieldOfView(Single, Single, Single, Single) Builds a perspective projection matrix based on a field of view and returns by value.
CreatePerspectiveFieldOfView(Single, Single, Single, Single, Matrix%) Builds a perspective projection matrix based on a field of view and returns by reference.
CreatePerspectiveOffCenter(Single, Single, Single, Single, Single, Single) Builds a customized, perspective projection matrix.
CreatePerspectiveOffCenter(Single, Single, Single, Single, Single, Single, Matrix%) Builds a customized, perspective projection matrix.
CreateReflection(Plane) Creates a Matrix that reflects the coordinate system about a specified Plane.
CreateReflection(Plane%, Matrix%) Fills in an existing Matrix so that it reflects the coordinate system about a specified Plane.
CreateRotationX(Single) Returns a matrix that can be used to rotate a set of vertices around the x-axis.
CreateRotationX(Single, Matrix%) Populates data into a user-specified matrix that can be used to rotate a set of vertices around the x-axis.
CreateRotationY(Single) Returns a matrix that can be used to rotate a set of vertices around the y-axis.
CreateRotationY(Single, Matrix%) Populates data into a user-specified matrix that can be used to rotate a set of vertices around the y-axis.
CreateRotationZ(Single) Returns a matrix that can be used to rotate a set of vertices around the z-axis.
CreateRotationZ(Single, Matrix%) Populates data into a user-specified matrix that can be used to rotate a set of vertices around the z-axis.
CreateScale(Single) Creates a scaling Matrix.
CreateScale(Vector3) Creates a scaling Matrix.
CreateScale(Single, Matrix%) Creates a scaling Matrix.
CreateScale(Vector3%, Matrix%) Creates a scaling Matrix.
CreateScale(Single, Single, Single) Creates a scaling Matrix.
CreateScale(Single, Single, Single, Matrix%) Creates a scaling Matrix.
CreateShadow(Vector3, Plane) Creates a Matrix that flattens geometry into a specified Plane as if casting a shadow from a specified light source.
CreateShadow(Vector3%, Plane%, Matrix%) Fills in a Matrix to flatten geometry into a specified Plane as if casting a shadow from a specified light source.
CreateTranslation(Vector3) Creates a translation Matrix.
CreateTranslation(Vector3%, Matrix%) Creates a translation Matrix.
CreateTranslation(Single, Single, Single) Creates a translation Matrix.
CreateTranslation(Single, Single, Single, Matrix%) Creates a translation Matrix.
CreateWorld(Vector3, Vector3, Vector3) Creates a world matrix with the specified parameters.
CreateWorld(Vector3%, Vector3%, Vector3%, Matrix%) Creates a world matrix with the specified parameters.
Decompose Extracts the scalar, translation, and rotation components from a 3D scale/rotate/translate (SRT) Matrix.
Determinant Calculates the determinant of the matrix.
Divide(Matrix, Matrix) Divides the components of a matrix by the corresponding components of another matrix.
Divide(Matrix, Single) Divides the components of a matrix by a scalar.
Divide(Matrix%, Matrix%, Matrix%) Divides the components of a matrix by the corresponding components of another matrix.
Divide(Matrix%, Single, Matrix%) Divides the components of a matrix by a scalar.
Equals(Object) Returns a value that indicates whether the current instance is equal to a specified object. (Overrides ValueType.Equals(Object).)
Equals(Matrix) Determines whether the specified Object is equal to the Matrix.
GetHashCode Gets the hash code of this object. (Overrides ValueType.GetHashCode().)
Invert(Matrix) Calculates the inverse of a matrix.
Invert(Matrix%, Matrix%) Calculates the inverse of a matrix.
Lerp(Matrix, Matrix, Single) Linearly interpolates between the corresponding values of two matrices.
Lerp(Matrix%, Matrix%, Single, Matrix%) Linearly interpolates between the corresponding values of two matrices.
Multiply(Matrix, Matrix) Multiplies a matrix by another matrix.
Multiply(Matrix, Single) Multiplies a matrix by a scalar value.
Multiply(Matrix%, Matrix%, Matrix%) Multiplies a matrix by another matrix.
Multiply(Matrix%, Single, Matrix%) Multiplies a matrix by a scalar value.
Negate(Matrix) Negates individual elements of a matrix.
Negate(Matrix%, Matrix%) Negates individual elements of a matrix.
Subtract(Matrix, Matrix) Subtracts matrices.
Subtract(Matrix%, Matrix%, Matrix%) Subtracts matrices.
ToString Retrieves a string representation of the current object. (Overrides ValueType.ToString().)
Transform(Matrix, Quaternion) Transforms a Matrix by applying a Quaternion rotation.
Transform(Matrix%, Quaternion%, Matrix%) Transforms a Matrix by applying a Quaternion rotation.
Transpose(Matrix) Transposes the rows and columns of a matrix.
Transpose(Matrix%, Matrix%) Transposes the rows and columns of a matrix.

Top

## Operators

Name Description
Division(Matrix, Matrix) Divides the components of a matrix by the corresponding components of another matrix.
Division(Matrix, Single) Divides the components of a matrix by a scalar.
Equality Compares a matrix for equality with another matrix.
Inequality Tests a matrix for inequality with another matrix.
Multiply(Single, Matrix) Multiplies a matrix by a scalar value.
Multiply(Matrix, Matrix) Multiplies a matrix by another matrix.
Multiply(Matrix, Single) Multiplies a matrix by a scalar value.
Subtraction Subtracts matrices.
UnaryNegation Negates individual elements of a matrix.

Top

## Fields

Name Description
M11 Value at row 1 column 1 of the matrix.
M12 Value at row 1 column 2 of the matrix.
M13 Value at row 1 column 3 of the matrix.
M14 Value at row 1 column 4 of the matrix.
M21 Value at row 2 column 1 of the matrix.
M22 Value at row 2 column 2 of the matrix.
M23 Value at row 2 column 3 of the matrix.
M24 Value at row 2 column 4 of the matrix.
M31 Value at row 3 column 1 of the matrix.
M32 Value at row 3 column 2 of the matrix.
M33 Value at row 3 column 3 of the matrix.
M34 Value at row 3 column 4 of the matrix.
M41 Value at row 4 column 1 of the matrix.
M42 Value at row 4 column 2 of the matrix.
M43 Value at row 4 column 3 of the matrix.
M44 Value at row 4 column 4 of the matrix.

Top

## Remarks

Matrices use a row vector layout in the XNA Framework. Matrices can be either row vector or column vector. Row vector matrices view vectors as a row from left to right, while column vector matrices view vectors as a column from top to bottom. For example, the x, y, and z of a matrix's translation vector in the XNA Framework would correspond to the fields M41, M42, M43.

Supported in: 5

## Platforms

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.