Table of Contents

Struct Matrix

Namespace
Microsoft.Xna.Framework
Assembly
MonoGame.Framework.dll

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

[DataContract]
public struct Matrix : IEquatable<Matrix>
Implements
Inherited Members

Constructors

Matrix(Vector4, Vector4, Vector4, Vector4)

Constructs a matrix.

public Matrix(Vector4 row1, Vector4 row2, Vector4 row3, Vector4 row4)

Parameters

row1 Vector4

A first row of the created matrix.

row2 Vector4

A second row of the created matrix.

row3 Vector4

A third row of the created matrix.

row4 Vector4

A fourth row of the created matrix.

Matrix(float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float)

Constructs a matrix.

public Matrix(float m11, float m12, float m13, float m14, float m21, float m22, float m23, float m24, float m31, float m32, float m33, float m34, float m41, float m42, float m43, float m44)

Parameters

m11 float

A first row and first column value.

m12 float

A first row and second column value.

m13 float

A first row and third column value.

m14 float

A first row and fourth column value.

m21 float

A second row and first column value.

m22 float

A second row and second column value.

m23 float

A second row and third column value.

m24 float

A second row and fourth column value.

m31 float

A third row and first column value.

m32 float

A third row and second column value.

m33 float

A third row and third column value.

m34 float

A third row and fourth column value.

m41 float

A fourth row and first column value.

m42 float

A fourth row and second column value.

m43 float

A fourth row and third column value.

m44 float

A fourth row and fourth column value.

Fields

M11

A first row and first column value.

[DataMember]
public float M11

Field Value

float

M12

A first row and second column value.

[DataMember]
public float M12

Field Value

float

M13

A first row and third column value.

[DataMember]
public float M13

Field Value

float

M14

A first row and fourth column value.

[DataMember]
public float M14

Field Value

float

M21

A second row and first column value.

[DataMember]
public float M21

Field Value

float

M22

A second row and second column value.

[DataMember]
public float M22

Field Value

float

M23

A second row and third column value.

[DataMember]
public float M23

Field Value

float

M24

A second row and fourth column value.

[DataMember]
public float M24

Field Value

float

M31

A third row and first column value.

[DataMember]
public float M31

Field Value

float

M32

A third row and second column value.

[DataMember]
public float M32

Field Value

float

M33

A third row and third column value.

[DataMember]
public float M33

Field Value

float

M34

A third row and fourth column value.

[DataMember]
public float M34

Field Value

float

M41

A fourth row and first column value.

[DataMember]
public float M41

Field Value

float

M42

A fourth row and second column value.

[DataMember]
public float M42

Field Value

float

M43

A fourth row and third column value.

[DataMember]
public float M43

Field Value

float

M44

A fourth row and fourth column value.

[DataMember]
public float M44

Field Value

float

Properties

Backward

The backward vector formed from the third row M31, M32, M33 elements.

public Vector3 Backward { get; set; }

Property Value

Vector3

Down

The down vector formed from the second row -M21, -M22, -M23 elements.

public Vector3 Down { get; set; }

Property Value

Vector3

Forward

The forward vector formed from the third row -M31, -M32, -M33 elements.

public Vector3 Forward { get; set; }

Property Value

Vector3

Identity

Returns the identity matrix.

public static Matrix Identity { get; }

Property Value

Matrix

this[int]

Get or set the matrix element at the given index, indexed in row major order.

public float this[int index] { get; set; }

Parameters

index int

The linearized, zero-based index of the matrix element.

Property Value

float

Exceptions

ArgumentOutOfRangeException

If the index is less than

0
or larger than
15
.

this[int, int]

Get or set the value at the specified row and column (indices are zero-based).

public float this[int row, int column] { get; set; }

Parameters

row int

The row of the element.

column int

The column of the element.

Property Value

float

Exceptions

ArgumentOutOfRangeException

If the row or column is less than

0
or larger than
3
.

Left

The left vector formed from the first row -M11, -M12, -M13 elements.

public Vector3 Left { get; set; }

Property Value

Vector3

Right

The right vector formed from the first row M11, M12, M13 elements.

public Vector3 Right { get; set; }

Property Value

Vector3

Translation

Position stored in this matrix.

public Vector3 Translation { get; set; }

Property Value

Vector3

Up

The upper vector formed from the second row M21, M22, M23 elements.

public Vector3 Up { get; set; }

Property Value

Vector3

Methods

Add(Matrix, Matrix)

Creates a new Matrix which contains sum of two matrixes.

public static Matrix Add(Matrix matrix1, Matrix matrix2)

Parameters

matrix1 Matrix

The first matrix to add.

matrix2 Matrix

The second matrix to add.

Returns

Matrix

The result of the matrix addition.

Add(ref Matrix, ref Matrix, out Matrix)

Creates a new Matrix which contains sum of two matrixes.

public static void Add(ref Matrix matrix1, ref Matrix matrix2, out Matrix result)

Parameters

matrix1 Matrix

The first matrix to add.

matrix2 Matrix

The second matrix to add.

result Matrix

The result of the matrix addition as an output parameter.

CreateBillboard(Vector3, Vector3, Vector3, Vector3?)

Creates a new Matrix for spherical billboarding that rotates around specified object position.

public static Matrix CreateBillboard(Vector3 objectPosition, Vector3 cameraPosition, Vector3 cameraUpVector, Vector3? cameraForwardVector)

Parameters

objectPosition Vector3

Position of billboard object. It will rotate around that vector.

cameraPosition Vector3

The camera position.

cameraUpVector Vector3

The camera up vector.

cameraForwardVector Vector3?

Optional camera forward vector.

Returns

Matrix

The Matrix for spherical billboarding.

CreateBillboard(ref Vector3, ref Vector3, ref Vector3, Vector3?, out Matrix)

Creates a new Matrix for spherical billboarding that rotates around specified object position.

public static void CreateBillboard(ref Vector3 objectPosition, ref Vector3 cameraPosition, ref Vector3 cameraUpVector, Vector3? cameraForwardVector, out Matrix result)

Parameters

objectPosition Vector3

Position of billboard object. It will rotate around that vector.

cameraPosition Vector3

The camera position.

cameraUpVector Vector3

The camera up vector.

cameraForwardVector Vector3?

Optional camera forward vector.

result Matrix

The Matrix for spherical billboarding as an output parameter.

CreateConstrainedBillboard(Vector3, Vector3, Vector3, Vector3?, Vector3?)

Creates a new Matrix for cylindrical billboarding that rotates around specified axis.

public static Matrix CreateConstrainedBillboard(Vector3 objectPosition, Vector3 cameraPosition, Vector3 rotateAxis, Vector3? cameraForwardVector, Vector3? objectForwardVector)

Parameters

objectPosition Vector3

Object position the billboard will rotate around.

cameraPosition Vector3

Camera position.

rotateAxis Vector3

Axis of billboard for rotation.

cameraForwardVector Vector3?

Optional camera forward vector.

objectForwardVector Vector3?

Optional object forward vector.

Returns

Matrix

The Matrix for cylindrical billboarding.

CreateConstrainedBillboard(ref Vector3, ref Vector3, ref Vector3, Vector3?, Vector3?, out Matrix)

Creates a new Matrix for cylindrical billboarding that rotates around specified axis.

public static void CreateConstrainedBillboard(ref Vector3 objectPosition, ref Vector3 cameraPosition, ref Vector3 rotateAxis, Vector3? cameraForwardVector, Vector3? objectForwardVector, out Matrix result)

Parameters

objectPosition Vector3

Object position the billboard will rotate around.

cameraPosition Vector3

Camera position.

rotateAxis Vector3

Axis of billboard for rotation.

cameraForwardVector Vector3?

Optional camera forward vector.

objectForwardVector Vector3?

Optional object forward vector.

result Matrix

The Matrix for cylindrical billboarding as an output parameter.

CreateFromAxisAngle(Vector3, float)

Creates a new Matrix which contains the rotation moment around specified axis.

public static Matrix CreateFromAxisAngle(Vector3 axis, float angle)

Parameters

axis Vector3

The axis of rotation.

angle float

The angle of rotation in radians.

Returns

Matrix

The rotation Matrix.

CreateFromAxisAngle(ref Vector3, float, out Matrix)

Creates a new Matrix which contains the rotation moment around specified axis.

public static void CreateFromAxisAngle(ref Vector3 axis, float angle, out Matrix result)

Parameters

axis Vector3

The axis of rotation.

angle float

The angle of rotation in radians.

result Matrix

The rotation Matrix as an output parameter.

CreateFromQuaternion(Quaternion)

Creates a new rotation Matrix from a Quaternion.

public static Matrix CreateFromQuaternion(Quaternion quaternion)

Parameters

quaternion Quaternion

Quaternion of rotation moment.

Returns

Matrix

The rotation Matrix.

CreateFromQuaternion(ref Quaternion, out Matrix)

Creates a new rotation Matrix from a Quaternion.

public static void CreateFromQuaternion(ref Quaternion quaternion, out Matrix result)

Parameters

quaternion Quaternion

Quaternion of rotation moment.

result Matrix

The rotation Matrix as an output parameter.

CreateFromYawPitchRoll(float, float, float)

Creates a new rotation Matrix from the specified yaw, pitch and roll values.

public static Matrix CreateFromYawPitchRoll(float yaw, float pitch, float roll)

Parameters

yaw float

The yaw rotation value in radians.

pitch float

The pitch rotation value in radians.

roll float

The roll rotation value in radians.

Returns

Matrix

The rotation Matrix.

Remarks

For more information about yaw, pitch and roll visit http://en.wikipedia.org/wiki/Euler_angles.

CreateFromYawPitchRoll(float, float, float, out Matrix)

Creates a new rotation Matrix from the specified yaw, pitch and roll values.

public static void CreateFromYawPitchRoll(float yaw, float pitch, float roll, out Matrix result)

Parameters

yaw float

The yaw rotation value in radians.

pitch float

The pitch rotation value in radians.

roll float

The roll rotation value in radians.

result Matrix

The rotation Matrix as an output parameter.

Remarks

For more information about yaw, pitch and roll visit http://en.wikipedia.org/wiki/Euler_angles.

CreateLookAt(Vector3, Vector3, Vector3)

Creates a new viewing Matrix.

public static Matrix CreateLookAt(Vector3 cameraPosition, Vector3 cameraTarget, Vector3 cameraUpVector)

Parameters

cameraPosition Vector3

Position of the camera.

cameraTarget Vector3

Lookup vector of the camera.

cameraUpVector Vector3

The direction of the upper edge of the camera.

Returns

Matrix

The viewing Matrix.

CreateLookAt(ref Vector3, ref Vector3, ref Vector3, out Matrix)

Creates a new viewing Matrix.

public static void CreateLookAt(ref Vector3 cameraPosition, ref Vector3 cameraTarget, ref Vector3 cameraUpVector, out Matrix result)

Parameters

cameraPosition Vector3

Position of the camera.

cameraTarget Vector3

Lookup vector of the camera.

cameraUpVector Vector3

The direction of the upper edge of the camera.

result Matrix

The viewing Matrix as an output parameter.

CreateOrthographic(float, float, float, float)

Creates a new projection Matrix for orthographic view.

public static Matrix CreateOrthographic(float width, float height, float zNearPlane, float zFarPlane)

Parameters

width float

Width of the viewing volume.

height float

Height of the viewing volume.

zNearPlane float

Depth of the near plane.

zFarPlane float

Depth of the far plane.

Returns

Matrix

The new projection Matrix for orthographic view.

CreateOrthographic(float, float, float, float, out Matrix)

Creates a new projection Matrix for orthographic view.

public static void CreateOrthographic(float width, float height, float zNearPlane, float zFarPlane, out Matrix result)

Parameters

width float

Width of the viewing volume.

height float

Height of the viewing volume.

zNearPlane float

Depth of the near plane.

zFarPlane float

Depth of the far plane.

result Matrix

The new projection Matrix for orthographic view as an output parameter.

CreateOrthographicOffCenter(Rectangle, float, float)

Creates a new projection Matrix for customized orthographic view.

public static Matrix CreateOrthographicOffCenter(Rectangle viewingVolume, float zNearPlane, float zFarPlane)

Parameters

viewingVolume Rectangle

The viewing volume.

zNearPlane float

Depth of the near plane.

zFarPlane float

Depth of the far plane.

Returns

Matrix

The new projection Matrix for customized orthographic view.

CreateOrthographicOffCenter(float, float, float, float, float, float)

Creates a new projection Matrix for customized orthographic view.

public static Matrix CreateOrthographicOffCenter(float left, float right, float bottom, float top, float zNearPlane, float zFarPlane)

Parameters

left float

Lower x-value at the near plane.

right float

Upper x-value at the near plane.

bottom float

Lower y-coordinate at the near plane.

top float

Upper y-value at the near plane.

zNearPlane float

Depth of the near plane.

zFarPlane float

Depth of the far plane.

Returns

Matrix

The 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.

public static void CreateOrthographicOffCenter(float left, float right, float bottom, float top, float zNearPlane, float zFarPlane, out Matrix result)

Parameters

left float

Lower x-value at the near plane.

right float

Upper x-value at the near plane.

bottom float

Lower y-coordinate at the near plane.

top float

Upper y-value at the near plane.

zNearPlane float

Depth of the near plane.

zFarPlane float

Depth of the far plane.

result Matrix

The new projection Matrix for customized orthographic view as an output parameter.

CreatePerspective(float, float, float, float)

Creates a new projection Matrix for perspective view.

public static Matrix CreatePerspective(float width, float height, float nearPlaneDistance, float farPlaneDistance)

Parameters

width float

Width of the viewing volume.

height float

Height of the viewing volume.

nearPlaneDistance float

Distance to the near plane.

farPlaneDistance float

Distance to the far plane.

Returns

Matrix

The new projection Matrix for perspective view.

CreatePerspective(float, float, float, float, out Matrix)

Creates a new projection Matrix for perspective view.

public static void CreatePerspective(float width, float height, float nearPlaneDistance, float farPlaneDistance, out Matrix result)

Parameters

width float

Width of the viewing volume.

height float

Height of the viewing volume.

nearPlaneDistance float

Distance to the near plane.

farPlaneDistance float

Distance to the far plane, or PositiveInfinity.

result Matrix

The new projection Matrix for perspective view as an output parameter.

CreatePerspectiveFieldOfView(float, float, float, float)

Creates a new projection Matrix for perspective view with field of view.

public static Matrix CreatePerspectiveFieldOfView(float fieldOfView, float aspectRatio, float nearPlaneDistance, float farPlaneDistance)

Parameters

fieldOfView float

Field of view in the y direction in radians.

aspectRatio float

Width divided by height of the viewing volume.

nearPlaneDistance float

Distance to the near plane.

farPlaneDistance float

Distance to the far plane, or PositiveInfinity.

Returns

Matrix

The new projection Matrix for perspective view with FOV.

CreatePerspectiveFieldOfView(float, float, float, float, out Matrix)

Creates a new projection Matrix for perspective view with field of view.

public static void CreatePerspectiveFieldOfView(float fieldOfView, float aspectRatio, float nearPlaneDistance, float farPlaneDistance, out Matrix result)

Parameters

fieldOfView float

Field of view in the y direction in radians.

aspectRatio float

Width divided by height of the viewing volume.

nearPlaneDistance float

Distance of the near plane.

farPlaneDistance float

Distance of the far plane, or PositiveInfinity.

result Matrix

The new projection Matrix for perspective view with FOV as an output parameter.

CreatePerspectiveOffCenter(Rectangle, float, float)

Creates a new projection Matrix for customized perspective view.

public static Matrix CreatePerspectiveOffCenter(Rectangle viewingVolume, float nearPlaneDistance, float farPlaneDistance)

Parameters

viewingVolume Rectangle

The viewing volume.

nearPlaneDistance float

Distance to the near plane.

farPlaneDistance float

Distance to the far plane.

Returns

Matrix

The new Matrix for customized perspective view.

CreatePerspectiveOffCenter(float, float, float, float, float, float)

Creates a new projection Matrix for customized perspective view.

public static Matrix CreatePerspectiveOffCenter(float left, float right, float bottom, float top, float nearPlaneDistance, float farPlaneDistance)

Parameters

left float

Lower x-value at the near plane.

right float

Upper x-value at the near plane.

bottom float

Lower y-coordinate at the near plane.

top float

Upper y-value at the near plane.

nearPlaneDistance float

Distance to the near plane.

farPlaneDistance float

Distance to the far plane.

Returns

Matrix

The new Matrix for customized perspective view.

CreatePerspectiveOffCenter(float, float, float, float, float, float, out Matrix)

Creates a new projection Matrix for customized perspective view.

public static void CreatePerspectiveOffCenter(float left, float right, float bottom, float top, float nearPlaneDistance, float farPlaneDistance, out Matrix result)

Parameters

left float

Lower x-value at the near plane.

right float

Upper x-value at the near plane.

bottom float

Lower y-coordinate at the near plane.

top float

Upper y-value at the near plane.

nearPlaneDistance float

Distance to the near plane.

farPlaneDistance float

Distance to the far plane.

result Matrix

The new Matrix for customized perspective view as an output parameter.

CreateReflection(Plane)

Creates a new reflection Matrix.

public static Matrix CreateReflection(Plane value)

Parameters

value Plane

The plane that used for reflection calculation.

Returns

Matrix

The reflection Matrix.

CreateReflection(ref Plane, out Matrix)

Creates a new reflection Matrix.

public static void CreateReflection(ref Plane value, out Matrix result)

Parameters

value Plane

The plane that used for reflection calculation.

result Matrix

The reflection Matrix as an output parameter.

CreateRotationX(float)

Creates a new rotation Matrix around X axis.

public static Matrix CreateRotationX(float radians)

Parameters

radians float

Angle in radians.

Returns

Matrix

The rotation Matrix around X axis.

CreateRotationX(float, out Matrix)

Creates a new rotation Matrix around X axis.

public static void CreateRotationX(float radians, out Matrix result)

Parameters

radians float

Angle in radians.

result Matrix

The rotation Matrix around X axis as an output parameter.

CreateRotationY(float)

Creates a new rotation Matrix around Y axis.

public static Matrix CreateRotationY(float radians)

Parameters

radians float

Angle in radians.

Returns

Matrix

The rotation Matrix around Y axis.

CreateRotationY(float, out Matrix)

Creates a new rotation Matrix around Y axis.

public static void CreateRotationY(float radians, out Matrix result)

Parameters

radians float

Angle in radians.

result Matrix

The rotation Matrix around Y axis as an output parameter.

CreateRotationZ(float)

Creates a new rotation Matrix around Z axis.

public static Matrix CreateRotationZ(float radians)

Parameters

radians float

Angle in radians.

Returns

Matrix

The rotation Matrix around Z axis.

CreateRotationZ(float, out Matrix)

Creates a new rotation Matrix around Z axis.

public static void CreateRotationZ(float radians, out Matrix result)

Parameters

radians float

Angle in radians.

result Matrix

The rotation Matrix around Z axis as an output parameter.

CreateScale(Vector3)

Creates a new scaling Matrix.

public static Matrix CreateScale(Vector3 scales)

Parameters

scales Vector3

Vector3 representing x,y and z scale values.

Returns

Matrix

The scaling Matrix.

CreateScale(ref Vector3, out Matrix)

Creates a new scaling Matrix.

public static void CreateScale(ref Vector3 scales, out Matrix result)

Parameters

scales Vector3

Vector3 representing x,y and z scale values.

result Matrix

The scaling Matrix as an output parameter.

CreateScale(float)

Creates a new scaling Matrix.

public static Matrix CreateScale(float scale)

Parameters

scale float

Scale value for all three axises.

Returns

Matrix

The scaling Matrix.

CreateScale(float, out Matrix)

Creates a new scaling Matrix.

public static void CreateScale(float scale, out Matrix result)

Parameters

scale float

Scale value for all three axises.

result Matrix

The scaling Matrix as an output parameter.

CreateScale(float, float, float)

Creates a new scaling Matrix.

public static Matrix CreateScale(float xScale, float yScale, float zScale)

Parameters

xScale float

Scale value for X axis.

yScale float

Scale value for Y axis.

zScale float

Scale value for Z axis.

Returns

Matrix

The scaling Matrix.

CreateScale(float, float, float, out Matrix)

Creates a new scaling Matrix.

public static void CreateScale(float xScale, float yScale, float zScale, out Matrix result)

Parameters

xScale float

Scale value for X axis.

yScale float

Scale value for Y axis.

zScale float

Scale value for Z axis.

result Matrix

The scaling Matrix as an output parameter.

CreateShadow(Vector3, Plane)

Creates a new Matrix that flattens geometry into a specified Plane as if casting a shadow from a specified light source.

public static Matrix CreateShadow(Vector3 lightDirection, Plane plane)

Parameters

lightDirection Vector3

A vector specifying the direction from which the light that will cast the shadow is coming.

plane Plane

The plane onto which the new matrix should flatten geometry so as to cast a shadow.

Returns

Matrix

A Matrix that can be used to flatten geometry onto the specified plane from the specified direction.

CreateShadow(ref Vector3, ref Plane, out Matrix)

Creates a new Matrix that flattens geometry into a specified Plane as if casting a shadow from a specified light source.

public static void CreateShadow(ref Vector3 lightDirection, ref Plane plane, out Matrix result)

Parameters

lightDirection Vector3

A vector specifying the direction from which the light that will cast the shadow is coming.

plane Plane

The plane onto which the new matrix should flatten geometry so as to cast a shadow.

result Matrix

A Matrix that can be used to flatten geometry onto the specified plane from the specified direction as an output parameter.

CreateTranslation(Vector3)

Creates a new translation Matrix.

public static Matrix CreateTranslation(Vector3 position)

Parameters

position Vector3

X,Y and Z coordinates of translation.

Returns

Matrix

The translation Matrix.

CreateTranslation(ref Vector3, out Matrix)

Creates a new translation Matrix.

public static void CreateTranslation(ref Vector3 position, out Matrix result)

Parameters

position Vector3

X,Y and Z coordinates of translation.

result Matrix

The translation Matrix as an output parameter.

CreateTranslation(float, float, float)

Creates a new translation Matrix.

public static Matrix CreateTranslation(float xPosition, float yPosition, float zPosition)

Parameters

xPosition float

X coordinate of translation.

yPosition float

Y coordinate of translation.

zPosition float

Z coordinate of translation.

Returns

Matrix

The translation Matrix.

CreateTranslation(float, float, float, out Matrix)

Creates a new translation Matrix.

public static void CreateTranslation(float xPosition, float yPosition, float zPosition, out Matrix result)

Parameters

xPosition float

X coordinate of translation.

yPosition float

Y coordinate of translation.

zPosition float

Z coordinate of translation.

result Matrix

The translation Matrix as an output parameter.

CreateWorld(Vector3, Vector3, Vector3)

Creates a new world Matrix.

public static Matrix CreateWorld(Vector3 position, Vector3 forward, Vector3 up)

Parameters

position Vector3

The position vector.

forward Vector3

The forward direction vector.

up Vector3

The upward direction vector. Usually Up.

Returns

Matrix

The world Matrix.

CreateWorld(ref Vector3, ref Vector3, ref Vector3, out Matrix)

Creates a new world Matrix.

public static void CreateWorld(ref Vector3 position, ref Vector3 forward, ref Vector3 up, out Matrix result)

Parameters

position Vector3

The position vector.

forward Vector3

The forward direction vector.

up Vector3

The upward direction vector. Usually Up.

result Matrix

The world Matrix as an output parameter.

Decompose(out Vector3, out Quaternion, out Vector3)

Decomposes this matrix to translation, rotation and scale elements. Returns true if matrix can be decomposed; false otherwise.

public bool Decompose(out Vector3 scale, out Quaternion rotation, out Vector3 translation)

Parameters

scale Vector3

Scale vector as an output parameter.

rotation Quaternion

Rotation quaternion as an output parameter.

translation Vector3

Translation vector as an output parameter.

Returns

bool

true if matrix can be decomposed; false otherwise.

Determinant()

Returns a determinant of this Matrix.

public float Determinant()

Returns

float

Determinant of this Matrix

Remarks

See more about determinant here - http://en.wikipedia.org/wiki/Determinant.

Divide(Matrix, Matrix)

Divides the elements of a Matrix by the elements of another matrix.

public static Matrix Divide(Matrix matrix1, Matrix matrix2)

Parameters

matrix1 Matrix

Source Matrix.

matrix2 Matrix

Divisor Matrix.

Returns

Matrix

The result of dividing the matrix.

Divide(Matrix, float)

Divides the elements of a Matrix by a scalar.

public static Matrix Divide(Matrix matrix1, float divider)

Parameters

matrix1 Matrix

Source Matrix.

divider float

Divisor scalar.

Returns

Matrix

The result of dividing a matrix by a scalar.

Divide(ref Matrix, ref Matrix, out Matrix)

Divides the elements of a Matrix by the elements of another matrix.

public static void Divide(ref Matrix matrix1, ref Matrix matrix2, out Matrix result)

Parameters

matrix1 Matrix

Source Matrix.

matrix2 Matrix

Divisor Matrix.

result Matrix

The result of dividing the matrix as an output parameter.

Divide(ref Matrix, float, out Matrix)

Divides the elements of a Matrix by a scalar.

public static void Divide(ref Matrix matrix1, float divider, out Matrix result)

Parameters

matrix1 Matrix

Source Matrix.

divider float

Divisor scalar.

result Matrix

The result of dividing a matrix by a scalar as an output parameter.

Equals(Matrix)

Compares whether current instance is equal to specified Matrix without any tolerance.

public bool Equals(Matrix other)

Parameters

other Matrix

The Matrix to compare.

Returns

bool

true if the instances are equal; false otherwise.

Equals(object)

Compares whether current instance is equal to specified object without any tolerance.

public override bool Equals(object obj)

Parameters

obj object

The object to compare.

Returns

bool

true if the instances are equal; false otherwise.

GetHashCode()

Gets the hash code of this Matrix.

public override int GetHashCode()

Returns

int

Hash code of this Matrix.

Invert(Matrix)

Creates a new Matrix which contains inversion of the specified matrix.

public static Matrix Invert(Matrix matrix)

Parameters

matrix Matrix

Source Matrix.

Returns

Matrix

The inverted matrix.

Invert(ref Matrix, out Matrix)

Creates a new Matrix which contains inversion of the specified matrix.

public static void Invert(ref Matrix matrix, out Matrix result)

Parameters

matrix Matrix

Source Matrix.

result Matrix

The inverted matrix as output parameter.

Lerp(Matrix, Matrix, float)

Creates a new Matrix that contains linear interpolation of the values in specified matrixes.

public static Matrix Lerp(Matrix matrix1, Matrix matrix2, float amount)

Parameters

matrix1 Matrix

The first Matrix.

matrix2 Matrix

The second Vector2.

amount float

Weighting value(between 0.0 and 1.0).

Returns

Matrix

The result of linear interpolation of the specified matrixes.

Lerp(ref Matrix, ref Matrix, float, out Matrix)

Creates a new Matrix that contains linear interpolation of the values in specified matrixes.

public static void Lerp(ref Matrix matrix1, ref Matrix matrix2, float amount, out Matrix result)

Parameters

matrix1 Matrix

The first Matrix.

matrix2 Matrix

The second Vector2.

amount float

Weighting value(between 0.0 and 1.0).

result Matrix

The result of linear interpolation of the specified matrixes as an output parameter.

Multiply(Matrix, Matrix)

Creates a new Matrix that contains a multiplication of two matrix.

public static Matrix Multiply(Matrix matrix1, Matrix matrix2)

Parameters

matrix1 Matrix

Source Matrix.

matrix2 Matrix

Source Matrix.

Returns

Matrix

Result of the matrix multiplication.

Multiply(Matrix, float)

Creates a new Matrix that contains a multiplication of Matrix and a scalar.

public static Matrix Multiply(Matrix matrix1, float scaleFactor)

Parameters

matrix1 Matrix

Source Matrix.

scaleFactor float

Scalar value.

Returns

Matrix

Result of the matrix multiplication with a scalar.

Multiply(ref Matrix, ref Matrix, out Matrix)

Creates a new Matrix that contains a multiplication of two matrix.

public static void Multiply(ref Matrix matrix1, ref Matrix matrix2, out Matrix result)

Parameters

matrix1 Matrix

Source Matrix.

matrix2 Matrix

Source Matrix.

result Matrix

Result of the matrix multiplication as an output parameter.

Multiply(ref Matrix, float, out Matrix)

Creates a new Matrix that contains a multiplication of Matrix and a scalar.

public static void Multiply(ref Matrix matrix1, float scaleFactor, out Matrix result)

Parameters

matrix1 Matrix

Source Matrix.

scaleFactor float

Scalar value.

result Matrix

Result of the matrix multiplication with a scalar as an output parameter.

Negate(Matrix)

Returns a matrix with the all values negated.

public static Matrix Negate(Matrix matrix)

Parameters

matrix Matrix

Source Matrix.

Returns

Matrix

Result of the matrix negation.

Negate(ref Matrix, out Matrix)

Returns a matrix with the all values negated.

public static void Negate(ref Matrix matrix, out Matrix result)

Parameters

matrix Matrix

Source Matrix.

result Matrix

Result of the matrix negation as an output parameter.

Subtract(Matrix, Matrix)

Creates a new Matrix that contains subtraction of one matrix from another.

public static Matrix Subtract(Matrix matrix1, Matrix matrix2)

Parameters

matrix1 Matrix

The first Matrix.

matrix2 Matrix

The second Matrix.

Returns

Matrix

The result of the matrix subtraction.

Subtract(ref Matrix, ref Matrix, out Matrix)

Creates a new Matrix that contains subtraction of one matrix from another.

public static void Subtract(ref Matrix matrix1, ref Matrix matrix2, out Matrix result)

Parameters

matrix1 Matrix

The first Matrix.

matrix2 Matrix

The second Matrix.

result Matrix

The result of the matrix subtraction as an output parameter.

ToFloatArray(Matrix)

Copy the values of specified Matrix to the float array.

public static float[] ToFloatArray(Matrix matrix)

Parameters

matrix Matrix

The source Matrix.

Returns

float[]

The array which matrix values will be stored.

Remarks

Required for OpenGL 2.0 projection matrix stuff.

ToNumerics()

Returns a Matrix4x4.

public Matrix4x4 ToNumerics()

Returns

Matrix4x4

ToString()

Returns a 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]}

public override string ToString()

Returns

string

A string representation of this Matrix.

Transpose(Matrix)

Swap the matrix rows and columns.

public static Matrix Transpose(Matrix matrix)

Parameters

matrix Matrix

The matrix for transposing operation.

Returns

Matrix

The new Matrix which contains the transposing result.

Transpose(ref Matrix, out Matrix)

Swap the matrix rows and columns.

public static void Transpose(ref Matrix matrix, out Matrix result)

Parameters

matrix Matrix

The matrix for transposing operation.

result Matrix

The new Matrix which contains the transposing result as an output parameter.

Operators

operator +(Matrix, Matrix)

Adds two matrixes.

public static Matrix operator +(Matrix matrix1, Matrix matrix2)

Parameters

matrix1 Matrix

Source Matrix on the left of the add sign.

matrix2 Matrix

Source Matrix on the right of the add sign.

Returns

Matrix

Sum of the matrixes.

operator /(Matrix, Matrix)

Divides the elements of a Matrix by the elements of another Matrix.

public static Matrix operator /(Matrix matrix1, Matrix matrix2)

Parameters

matrix1 Matrix

Source Matrix on the left of the div sign.

matrix2 Matrix

Divisor Matrix on the right of the div sign.

Returns

Matrix

The result of dividing the matrixes.

operator /(Matrix, float)

Divides the elements of a Matrix by a scalar.

public static Matrix operator /(Matrix matrix, float divider)

Parameters

matrix Matrix

Source Matrix on the left of the div sign.

divider float

Divisor scalar on the right of the div sign.

Returns

Matrix

The result of dividing a matrix by a scalar.

operator ==(Matrix, Matrix)

Compares whether two Matrix instances are equal without any tolerance.

public static bool operator ==(Matrix matrix1, Matrix matrix2)

Parameters

matrix1 Matrix

Source Matrix on the left of the equal sign.

matrix2 Matrix

Source Matrix on the right of the equal sign.

Returns

bool

true if the instances are equal; false otherwise.

implicit operator Matrix(Matrix4x4)

Converts a Matrix4x4 to a Matrix.

public static implicit operator Matrix(Matrix4x4 value)

Parameters

value Matrix4x4

The converted value.

Returns

Matrix

operator !=(Matrix, Matrix)

Compares whether two Matrix instances are not equal without any tolerance.

public static bool operator !=(Matrix matrix1, Matrix matrix2)

Parameters

matrix1 Matrix

Source Matrix on the left of the not equal sign.

matrix2 Matrix

Source Matrix on the right of the not equal sign.

Returns

bool

true if the instances are not equal; false otherwise.

operator *(Matrix, Matrix)

Multiplies two matrixes.

public static Matrix operator *(Matrix matrix1, Matrix matrix2)

Parameters

matrix1 Matrix

Source Matrix on the left of the mul sign.

matrix2 Matrix

Source Matrix on the right of the mul sign.

Returns

Matrix

Result of the matrix multiplication.

Remarks

Using matrix multiplication algorithm - see http://en.wikipedia.org/wiki/Matrix_multiplication.

operator *(Matrix, float)

Multiplies the elements of matrix by a scalar.

public static Matrix operator *(Matrix matrix, float scaleFactor)

Parameters

matrix Matrix

Source Matrix on the left of the mul sign.

scaleFactor float

Scalar value on the right of the mul sign.

Returns

Matrix

Result of the matrix multiplication with a scalar.

operator -(Matrix, Matrix)

Subtracts the values of one Matrix from another Matrix.

public static Matrix operator -(Matrix matrix1, Matrix matrix2)

Parameters

matrix1 Matrix

Source Matrix on the left of the sub sign.

matrix2 Matrix

Source Matrix on the right of the sub sign.

Returns

Matrix

Result of the matrix subtraction.

operator -(Matrix)

Inverts values in the specified Matrix.

public static Matrix operator -(Matrix matrix)

Parameters

matrix Matrix

Source Matrix on the right of the sub sign.

Returns

Matrix

Result of the inversion.