Matrix Structure

Microsoft Silverlight will reach end of support after October 2021. Learn more.

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
Public method Matrix Initializes a new instance of Matrix.

Top

Properties

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

Top

Methods

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

Top

Operators

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

Top

Fields

  Name Description
Public field M11 Value at row 1 column 1 of the matrix.
Public field M12 Value at row 1 column 2 of the matrix.
Public field M13 Value at row 1 column 3 of the matrix.
Public field M14 Value at row 1 column 4 of the matrix.
Public field M21 Value at row 2 column 1 of the matrix.
Public field M22 Value at row 2 column 2 of the matrix.
Public field M23 Value at row 2 column 3 of the matrix.
Public field M24 Value at row 2 column 4 of the matrix.
Public field M31 Value at row 3 column 1 of the matrix.
Public field M32 Value at row 3 column 2 of the matrix.
Public field M33 Value at row 3 column 3 of the matrix.
Public field M34 Value at row 3 column 4 of the matrix.
Public field M41 Value at row 4 column 1 of the matrix.
Public field M42 Value at row 4 column 2 of the matrix.
Public field M43 Value at row 4 column 3 of the matrix.
Public field 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.

Version Information

Silverlight

Supported in: 5

Platforms

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

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.