Matrix Structure (Microsoft.Xna.Framework)

Represents the right-handed 4x4 floating point matrix, which can store translation, scale and rotation information.

Namespace: Microsoft.Xna.Framework
Assembly: MonoGame.Framework (MonoGame.Framework.dll 3.8.0.398)
  • C#
  • VB
  • F#
[DefaultMemberAttribute("Item")]
[DebuggerDisplayAttribute("{DebugDisplayString,nq}")]
[DataContractAttribute]
[StructLayoutAttribute(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = -1, Size = -1)]
public struct Matrix : IEquatable<Matrix>

Syntax for VB is not yet implemented.

Syntax for F# is not yet implemented.

The Matrix type exposes the following members.

  Platforms Name Description
M11 A first row and first column value. 
M12 A first row and second column value. 
M13 A first row and third column value. 
M14 A first row and fourth column value. 
M21 A second row and first column value. 
M22 A second row and second column value. 
M23 A second row and third column value. 
M24 A second row and fourth column value. 
M31 A third row and first column value. 
M32 A third row and second column value. 
M33 A third row and third column value. 
M34 A third row and fourth column value. 
M41 A fourth row and first column value. 
M42 A fourth row and second column value. 
M43 A fourth row and third column value. 
M44 A fourth row and fourth column value. 
Top
  Platforms Name Description
Backward The backward vector formed from the third row M31, M32, M33 elements. 
Down The down vector formed from the second row -M21, -M22, -M23 elements. 
Forward The forward vector formed from the third row -M31, -M32, -M33 elements. 
Identity Returns the identity matrix. 
Item  
Item  
Left The left vector formed from the first row -M11, -M12, -M13 elements. 
Right The right vector formed from the first row M11, M12, M13 elements. 
Translation Position stored in this matrix. 
Up The upper vector formed from the second row M21, M22, M23 elements. 
Top
  Platforms Name Description
Add(Matrix, Matrix) Creates a new Matrix which contains sum of two matrixes. 
Add(Matrix, Matrix, out Matrix) Creates a new Matrix which contains sum of two matrixes. 
CreateBillboard(Vector3, Vector3, Vector3, Nullable<Vector3>) Creates a new Matrix for spherical billboarding that rotates around specified object position. 
CreateBillboard(Vector3, Vector3, Vector3, Nullable<Vector3>, out Matrix) Creates a new Matrix for spherical billboarding that rotates around specified object position. 
CreateConstrainedBillboard(Vector3, Vector3, Vector3, Nullable<Vector3>, Nullable<Vector3>) Creates a new Matrix for cylindrical billboarding that rotates around specified axis. 
CreateConstrainedBillboard(Vector3, Vector3, Vector3, Nullable<Vector3>, Nullable<Vector3>, out Matrix) Creates a new Matrix for cylindrical billboarding that rotates around specified axis. 
CreateFromAxisAngle(Vector3, float) Creates a new Matrix which contains the rotation moment around specified axis. 
CreateFromAxisAngle(Vector3, float, out Matrix) Creates a new Matrix which contains the rotation moment around specified axis. 
CreateFromQuaternion(Quaternion, out Matrix) Creates a new rotation Matrix from a Quaternion
CreateFromQuaternion(Quaternion) Creates a new rotation Matrix from a Quaternion
CreateFromYawPitchRoll(float, float, float) Creates a new rotation Matrix from the specified yaw, pitch and roll values. 
CreateFromYawPitchRoll(float, float, float, out Matrix) Creates a new rotation Matrix from the specified yaw, pitch and roll values. 
CreateLookAt(Vector3, Vector3, Vector3) Creates a new viewing Matrix
CreateLookAt(Vector3, Vector3, Vector3, out Matrix) Creates a new viewing Matrix
CreateOrthographic(float, float, float, float) Creates a new projection Matrix for orthographic view. 
CreateOrthographic(float, float, float, float, out Matrix) Creates a new projection Matrix for orthographic view. 
CreateOrthographicOffCenter(float, float, float, float, float, float) Creates a new projection Matrix for customized orthographic view. 
CreateOrthographicOffCenter(Rectangle, float, float) Creates a new projection Matrix for customized orthographic view. 
CreateOrthographicOffCenter(float, float, float, float, float, float, out Matrix) Creates a new projection Matrix for customized orthographic view. 
CreatePerspective(float, float, float, float, out Matrix) Creates a new projection Matrix for perspective view. 
CreatePerspective(float, float, float, float) Creates a new projection Matrix for perspective view. 
CreatePerspectiveFieldOfView(float, float, float, float) Creates a new projection Matrix for perspective view with field of view. 
CreatePerspectiveFieldOfView(float, float, float, float, out Matrix) Creates a new projection Matrix for perspective view with field of view. 
CreatePerspectiveOffCenter(Rectangle, float, float) Creates a new projection Matrix for customized perspective view. 
CreatePerspectiveOffCenter(float, float, float, float, float, float) Creates a new projection Matrix for customized perspective view. 
CreatePerspectiveOffCenter(float, float, float, float, float, float, out Matrix) Creates a new projection Matrix for customized perspective view. 
CreateReflection(Plane, out Matrix) Creates a new reflection Matrix
CreateReflection(Plane) Creates a new reflection Matrix
CreateRotationX(float) Creates a new rotation Matrix around X axis. 
CreateRotationX(float, out Matrix) Creates a new rotation Matrix around X axis. 
CreateRotationY(float) Creates a new rotation Matrix around Y axis. 
CreateRotationY(float, out Matrix) Creates a new rotation Matrix around Y axis. 
CreateRotationZ(float, out Matrix) Creates a new rotation Matrix around Z axis. 
CreateRotationZ(float) Creates a new rotation Matrix around Z axis. 
CreateScale(float, out Matrix) Creates a new scaling Matrix
CreateScale(float, float, float) Creates a new scaling Matrix
CreateScale(float, float, float, out Matrix) Creates a new scaling Matrix
CreateScale(Vector3) Creates a new scaling Matrix
CreateScale(Vector3, out Matrix) Creates a new scaling Matrix
CreateScale(float) Creates a new scaling Matrix
CreateShadow(Vector3, Plane) Creates a new Matrix that flattens geometry into a specified Plane as if casting a shadow from a specified light source. 
CreateShadow(Vector3, Plane, out Matrix) Creates a new Matrix that flattens geometry into a specified Plane as if casting a shadow from a specified light source. 
CreateTranslation(float, float, float, out Matrix) Creates a new translation Matrix
CreateTranslation(Vector3) Creates a new translation Matrix
CreateTranslation(float, float, float) Creates a new translation Matrix
CreateTranslation(Vector3, out Matrix) Creates a new translation Matrix
CreateWorld(Vector3, Vector3, Vector3) Creates a new world Matrix
CreateWorld(Vector3, Vector3, Vector3, out Matrix) Creates a new world Matrix
Decompose Decomposes this matrix to translation, rotation and scale elements. Returns true if matrix can be decomposed; false otherwise. 
Determinant Returns a determinant of this Matrix
Divide(Matrix, float, out Matrix) Divides the elements of a Matrix by a scalar. 
Divide(Matrix, float) Divides the elements of a Matrix by a scalar. 
Divide(Matrix, Matrix) Divides the elements of a Matrix by the elements of another matrix. 
Divide(Matrix, Matrix, out Matrix) Divides the elements of a Matrix by the elements of another matrix. 
Equals(Matrix) Compares whether current instance is equal to specified Matrix without any tolerance. (Implements IEquatable<T>.Equals().)
Equals(object) Compares whether current instance is equal to specified System.Object without any tolerance. (Overrides ValueType.Equals().)
GetHashCode Gets the hash code of this Matrix. (Overrides ValueType.GetHashCode().)
Invert(Matrix, out Matrix) Creates a new Matrix which contains inversion of the specified matrix. 
Invert(Matrix) Creates a new Matrix which contains inversion of the specified matrix. 
Lerp(Matrix, Matrix, float) Creates a new Matrix that contains linear interpolation of the values in specified matrixes. 
Lerp(Matrix, Matrix, float, out Matrix) Creates a new Matrix that contains linear interpolation of the values in specified matrixes. 
Multiply(Matrix, float, out Matrix) Creates a new Matrix that contains a multiplication of Matrix and a scalar. 
Multiply(Matrix, float) Creates a new Matrix that contains a multiplication of Matrix and a scalar. 
Multiply(Matrix, Matrix, out Matrix) Creates a new Matrix that contains a multiplication of two matrix. 
Multiply(Matrix, Matrix) Creates a new Matrix that contains a multiplication of two matrix. 
Negate(Matrix) Returns a matrix with the all values negated. 
Negate(Matrix, out Matrix) Returns a matrix with the all values negated. 
Subtract(Matrix, Matrix, out Matrix) Creates a new Matrix that contains subtraction of one matrix from another. 
Subtract(Matrix, Matrix) Creates a new Matrix that contains subtraction of one matrix from another. 
ToFloatArray Copy the values of specified Matrix to the float array. 
ToString Returns a System.String representation of this Matrix in the format: {M11:[M11] M12:[M12] M13:[M13] M14:[M14]} {M21:[M21] M12:[M22] M13:[M23] M14:[M24]} {M31:[M31] M32:[M32] M33:[M33] M34:[M34]} {M41:[M41] M42:[M42] M43:[M43] M44:[M44]} (Overrides ValueType.ToString().)
Transpose(Matrix) Swap the matrix rows and columns. 
Transpose(Matrix, out Matrix) Swap the matrix rows and columns. 
Top
  Platforms Name Description
Addition Adds two matrixes. 
Division(Matrix, Matrix) Divides the elements of a Matrix by the elements of another Matrix
Division(Matrix, float) Divides the elements of a Matrix by a scalar. 
Equality Compares whether two Matrix instances are equal without any tolerance. 
Inequality Compares whether two Matrix instances are not equal without any tolerance. 
Multiply(Matrix, Matrix) Multiplies two matrixes. 
Multiply(Matrix, float) Multiplies the elements of matrix by a scalar. 
Subtraction Subtracts the values of one Matrix from another Matrix
UnaryNegation Inverts values in the specified Matrix
Top
Supported in:

    
 Windows DirectX Desktop
    
 Linux Desktop
    
 Windows OpenGL Desktop
    
 Web