Struct Matrix
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
row1Vector4A first row of the created matrix.
row2Vector4A second row of the created matrix.
row3Vector4A third row of the created matrix.
row4Vector4A 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
m11floatA first row and first column value.
m12floatA first row and second column value.
m13floatA first row and third column value.
m14floatA first row and fourth column value.
m21floatA second row and first column value.
m22floatA second row and second column value.
m23floatA second row and third column value.
m24floatA second row and fourth column value.
m31floatA third row and first column value.
m32floatA third row and second column value.
m33floatA third row and third column value.
m34floatA third row and fourth column value.
m41floatA fourth row and first column value.
m42floatA fourth row and second column value.
m43floatA fourth row and third column value.
m44floatA fourth row and fourth column value.
Fields
M11
A first row and first column value.
[DataMember]
public float M11
Field Value
M12
A first row and second column value.
[DataMember]
public float M12
Field Value
M13
A first row and third column value.
[DataMember]
public float M13
Field Value
M14
A first row and fourth column value.
[DataMember]
public float M14
Field Value
M21
A second row and first column value.
[DataMember]
public float M21
Field Value
M22
A second row and second column value.
[DataMember]
public float M22
Field Value
M23
A second row and third column value.
[DataMember]
public float M23
Field Value
M24
A second row and fourth column value.
[DataMember]
public float M24
Field Value
M31
A third row and first column value.
[DataMember]
public float M31
Field Value
M32
A third row and second column value.
[DataMember]
public float M32
Field Value
M33
A third row and third column value.
[DataMember]
public float M33
Field Value
M34
A third row and fourth column value.
[DataMember]
public float M34
Field Value
M41
A fourth row and first column value.
[DataMember]
public float M41
Field Value
M42
A fourth row and second column value.
[DataMember]
public float M42
Field Value
M43
A fourth row and third column value.
[DataMember]
public float M43
Field Value
M44
A fourth row and fourth column value.
[DataMember]
public float M44
Field Value
Properties
Backward
The backward vector formed from the third row M31, M32, M33 elements.
public Vector3 Backward { get; set; }
Property Value
Down
The down vector formed from the second row -M21, -M22, -M23 elements.
public Vector3 Down { get; set; }
Property Value
Forward
The forward vector formed from the third row -M31, -M32, -M33 elements.
public Vector3 Forward { get; set; }
Property Value
Identity
Returns the identity matrix.
public static Matrix Identity { get; }
Property Value
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
indexintThe linearized, zero-based index of the matrix element.
Property Value
Exceptions
- ArgumentOutOfRangeException
If the index is less than
or larger than0
.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
Property Value
Exceptions
- ArgumentOutOfRangeException
If the row or column is less than
or larger than0
.3
Left
The left vector formed from the first row -M11, -M12, -M13 elements.
public Vector3 Left { get; set; }
Property Value
Right
The right vector formed from the first row M11, M12, M13 elements.
public Vector3 Right { get; set; }
Property Value
Translation
Position stored in this matrix.
public Vector3 Translation { get; set; }
Property Value
Up
The upper vector formed from the second row M21, M22, M23 elements.
public Vector3 Up { get; set; }
Property Value
Methods
Add(Matrix, Matrix)
Creates a new Matrix which contains sum of two matrixes.
public static Matrix Add(Matrix matrix1, Matrix matrix2)
Parameters
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
matrix1MatrixThe first matrix to add.
matrix2MatrixThe second matrix to add.
resultMatrixThe 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
objectPositionVector3Position of billboard object. It will rotate around that vector.
cameraPositionVector3The camera position.
cameraUpVectorVector3The camera up vector.
cameraForwardVectorVector3?Optional camera forward vector.
Returns
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
objectPositionVector3Position of billboard object. It will rotate around that vector.
cameraPositionVector3The camera position.
cameraUpVectorVector3The camera up vector.
cameraForwardVectorVector3?Optional camera forward vector.
resultMatrixThe 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
objectPositionVector3Object position the billboard will rotate around.
cameraPositionVector3Camera position.
rotateAxisVector3Axis of billboard for rotation.
cameraForwardVectorVector3?Optional camera forward vector.
objectForwardVectorVector3?Optional object forward vector.
Returns
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
objectPositionVector3Object position the billboard will rotate around.
cameraPositionVector3Camera position.
rotateAxisVector3Axis of billboard for rotation.
cameraForwardVectorVector3?Optional camera forward vector.
objectForwardVectorVector3?Optional object forward vector.
resultMatrixThe 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
Returns
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
axisVector3The axis of rotation.
anglefloatThe angle of rotation in radians.
resultMatrixThe rotation Matrix as an output parameter.
CreateFromQuaternion(Quaternion)
Creates a new rotation Matrix from a Quaternion.
public static Matrix CreateFromQuaternion(Quaternion quaternion)
Parameters
quaternionQuaternionQuaternion of rotation moment.
Returns
CreateFromQuaternion(ref Quaternion, out Matrix)
Creates a new rotation Matrix from a Quaternion.
public static void CreateFromQuaternion(ref Quaternion quaternion, out Matrix result)
Parameters
quaternionQuaternionQuaternion of rotation moment.
resultMatrixThe 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
yawfloatThe yaw rotation value in radians.
pitchfloatThe pitch rotation value in radians.
rollfloatThe roll rotation value in radians.
Returns
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
yawfloatThe yaw rotation value in radians.
pitchfloatThe pitch rotation value in radians.
rollfloatThe roll rotation value in radians.
resultMatrixThe 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
cameraPositionVector3Position of the camera.
cameraTargetVector3Lookup vector of the camera.
cameraUpVectorVector3The direction of the upper edge of the camera.
Returns
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
cameraPositionVector3Position of the camera.
cameraTargetVector3Lookup vector of the camera.
cameraUpVectorVector3The direction of the upper edge of the camera.
resultMatrixThe 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
widthfloatWidth of the viewing volume.
heightfloatHeight of the viewing volume.
zNearPlanefloatDepth of the near plane.
zFarPlanefloatDepth of the far plane.
Returns
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
widthfloatWidth of the viewing volume.
heightfloatHeight of the viewing volume.
zNearPlanefloatDepth of the near plane.
zFarPlanefloatDepth of the far plane.
resultMatrixThe 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
viewingVolumeRectangleThe viewing volume.
zNearPlanefloatDepth of the near plane.
zFarPlanefloatDepth of the far plane.
Returns
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
leftfloatLower x-value at the near plane.
rightfloatUpper x-value at the near plane.
bottomfloatLower y-coordinate at the near plane.
topfloatUpper y-value at the near plane.
zNearPlanefloatDepth of the near plane.
zFarPlanefloatDepth of the far plane.
Returns
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
leftfloatLower x-value at the near plane.
rightfloatUpper x-value at the near plane.
bottomfloatLower y-coordinate at the near plane.
topfloatUpper y-value at the near plane.
zNearPlanefloatDepth of the near plane.
zFarPlanefloatDepth of the far plane.
resultMatrixThe 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
widthfloatWidth of the viewing volume.
heightfloatHeight of the viewing volume.
nearPlaneDistancefloatDistance to the near plane.
farPlaneDistancefloatDistance to the far plane.
Returns
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
widthfloatWidth of the viewing volume.
heightfloatHeight of the viewing volume.
nearPlaneDistancefloatDistance to the near plane.
farPlaneDistancefloatDistance to the far plane, or PositiveInfinity.
resultMatrixThe 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
fieldOfViewfloatField of view in the y direction in radians.
aspectRatiofloatWidth divided by height of the viewing volume.
nearPlaneDistancefloatDistance to the near plane.
farPlaneDistancefloatDistance to the far plane, or PositiveInfinity.
Returns
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
fieldOfViewfloatField of view in the y direction in radians.
aspectRatiofloatWidth divided by height of the viewing volume.
nearPlaneDistancefloatDistance of the near plane.
farPlaneDistancefloatDistance of the far plane, or PositiveInfinity.
resultMatrixThe 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
viewingVolumeRectangleThe viewing volume.
nearPlaneDistancefloatDistance to the near plane.
farPlaneDistancefloatDistance to the far plane.
Returns
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
leftfloatLower x-value at the near plane.
rightfloatUpper x-value at the near plane.
bottomfloatLower y-coordinate at the near plane.
topfloatUpper y-value at the near plane.
nearPlaneDistancefloatDistance to the near plane.
farPlaneDistancefloatDistance to the far plane.
Returns
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
leftfloatLower x-value at the near plane.
rightfloatUpper x-value at the near plane.
bottomfloatLower y-coordinate at the near plane.
topfloatUpper y-value at the near plane.
nearPlaneDistancefloatDistance to the near plane.
farPlaneDistancefloatDistance to the far plane.
resultMatrixThe new Matrix for customized perspective view as an output parameter.
CreateReflection(Plane)
Creates a new reflection Matrix.
public static Matrix CreateReflection(Plane value)
Parameters
valuePlaneThe plane that used for reflection calculation.
Returns
CreateReflection(ref Plane, out Matrix)
Creates a new reflection Matrix.
public static void CreateReflection(ref Plane value, out Matrix result)
Parameters
valuePlaneThe plane that used for reflection calculation.
resultMatrixThe reflection Matrix as an output parameter.
CreateRotationX(float)
Creates a new rotation Matrix around X axis.
public static Matrix CreateRotationX(float radians)
Parameters
radiansfloatAngle in radians.
Returns
CreateRotationX(float, out Matrix)
Creates a new rotation Matrix around X axis.
public static void CreateRotationX(float radians, out Matrix result)
Parameters
radiansfloatAngle in radians.
resultMatrixThe 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
radiansfloatAngle in radians.
Returns
CreateRotationY(float, out Matrix)
Creates a new rotation Matrix around Y axis.
public static void CreateRotationY(float radians, out Matrix result)
Parameters
radiansfloatAngle in radians.
resultMatrixThe 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
radiansfloatAngle in radians.
Returns
CreateRotationZ(float, out Matrix)
Creates a new rotation Matrix around Z axis.
public static void CreateRotationZ(float radians, out Matrix result)
Parameters
radiansfloatAngle in radians.
resultMatrixThe rotation Matrix around Z axis as an output parameter.
CreateScale(Vector3)
Creates a new scaling Matrix.
public static Matrix CreateScale(Vector3 scales)
Parameters
Returns
CreateScale(ref Vector3, out Matrix)
Creates a new scaling Matrix.
public static void CreateScale(ref Vector3 scales, out Matrix result)
Parameters
scalesVector3Vector3 representing x,y and z scale values.
resultMatrixThe scaling Matrix as an output parameter.
CreateScale(float)
Creates a new scaling Matrix.
public static Matrix CreateScale(float scale)
Parameters
scalefloatScale value for all three axises.
Returns
CreateScale(float, out Matrix)
Creates a new scaling Matrix.
public static void CreateScale(float scale, out Matrix result)
Parameters
scalefloatScale value for all three axises.
resultMatrixThe 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
xScalefloatScale value for X axis.
yScalefloatScale value for Y axis.
zScalefloatScale value for Z axis.
Returns
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
xScalefloatScale value for X axis.
yScalefloatScale value for Y axis.
zScalefloatScale value for Z axis.
resultMatrixThe 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
lightDirectionVector3A vector specifying the direction from which the light that will cast the shadow is coming.
planePlaneThe 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
lightDirectionVector3A vector specifying the direction from which the light that will cast the shadow is coming.
planePlaneThe plane onto which the new matrix should flatten geometry so as to cast a shadow.
resultMatrixA 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
positionVector3X,Y and Z coordinates of translation.
Returns
CreateTranslation(ref Vector3, out Matrix)
Creates a new translation Matrix.
public static void CreateTranslation(ref Vector3 position, out Matrix result)
Parameters
positionVector3X,Y and Z coordinates of translation.
resultMatrixThe 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
xPositionfloatX coordinate of translation.
yPositionfloatY coordinate of translation.
zPositionfloatZ coordinate of translation.
Returns
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
xPositionfloatX coordinate of translation.
yPositionfloatY coordinate of translation.
zPositionfloatZ coordinate of translation.
resultMatrixThe 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
positionVector3The position vector.
forwardVector3The forward direction vector.
upVector3The upward direction vector. Usually Up.
Returns
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
positionVector3The position vector.
forwardVector3The forward direction vector.
upVector3The upward direction vector. Usually Up.
resultMatrixThe 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
scaleVector3Scale vector as an output parameter.
rotationQuaternionRotation quaternion as an output parameter.
translationVector3Translation vector as an output parameter.
Returns
- bool
trueif matrix can be decomposed;falseotherwise.
Determinant()
Returns a determinant of this Matrix.
public float Determinant()
Returns
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
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
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
matrix1MatrixSource Matrix.
matrix2MatrixDivisor Matrix.
resultMatrixThe 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
matrix1MatrixSource Matrix.
dividerfloatDivisor scalar.
resultMatrixThe 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
Returns
- bool
trueif the instances are equal;falseotherwise.
Equals(object)
Compares whether current instance is equal to specified object without any tolerance.
public override bool Equals(object obj)
Parameters
Returns
- bool
trueif the instances are equal;falseotherwise.
GetHashCode()
Gets the hash code of this Matrix.
public override int GetHashCode()
Returns
Invert(Matrix)
Creates a new Matrix which contains inversion of the specified matrix.
public static Matrix Invert(Matrix matrix)
Parameters
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
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
matrix1MatrixThe first Matrix.
matrix2MatrixThe second Vector2.
amountfloatWeighting 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
matrix1MatrixThe first Matrix.
matrix2MatrixThe second Vector2.
amountfloatWeighting value(between 0.0 and 1.0).
resultMatrixThe 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
Returns
- Matrix
Result of the matrix multiplication.
Multiply(Matrix, float)
public static Matrix Multiply(Matrix matrix1, float scaleFactor)
Parameters
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
matrix1MatrixSource Matrix.
matrix2MatrixSource Matrix.
resultMatrixResult of the matrix multiplication as an output parameter.
Multiply(ref Matrix, float, out Matrix)
public static void Multiply(ref Matrix matrix1, float scaleFactor, out Matrix result)
Parameters
matrix1MatrixSource Matrix.
scaleFactorfloatScalar value.
resultMatrixResult 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
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
Subtract(Matrix, Matrix)
Creates a new Matrix that contains subtraction of one matrix from another.
public static Matrix Subtract(Matrix matrix1, Matrix matrix2)
Parameters
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
matrix1MatrixThe first Matrix.
matrix2MatrixThe second Matrix.
resultMatrixThe 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
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
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
Transpose(Matrix)
Swap the matrix rows and columns.
public static Matrix Transpose(Matrix matrix)
Parameters
matrixMatrixThe matrix for transposing operation.
Returns
Transpose(ref Matrix, out Matrix)
Swap the matrix rows and columns.
public static void Transpose(ref Matrix matrix, out Matrix result)
Parameters
matrixMatrixThe matrix for transposing operation.
resultMatrixThe 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
matrix1MatrixSource Matrix on the left of the add sign.
matrix2MatrixSource Matrix on the right of the add sign.
Returns
- Matrix
Sum of the matrixes.
operator /(Matrix, Matrix)
public static Matrix operator /(Matrix matrix1, Matrix matrix2)
Parameters
matrix1MatrixSource Matrix on the left of the div sign.
matrix2MatrixDivisor 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
matrixMatrixSource Matrix on the left of the div sign.
dividerfloatDivisor 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
matrix1MatrixSource Matrix on the left of the equal sign.
matrix2MatrixSource Matrix on the right of the equal sign.
Returns
- bool
trueif the instances are equal;falseotherwise.
implicit operator Matrix(Matrix4x4)
public static implicit operator Matrix(Matrix4x4 value)
Parameters
valueMatrix4x4The converted value.
Returns
operator !=(Matrix, Matrix)
Compares whether two Matrix instances are not equal without any tolerance.
public static bool operator !=(Matrix matrix1, Matrix matrix2)
Parameters
matrix1MatrixSource Matrix on the left of the not equal sign.
matrix2MatrixSource Matrix on the right of the not equal sign.
Returns
- bool
trueif the instances are not equal;falseotherwise.
operator *(Matrix, Matrix)
Multiplies two matrixes.
public static Matrix operator *(Matrix matrix1, Matrix matrix2)
Parameters
matrix1MatrixSource Matrix on the left of the mul sign.
matrix2MatrixSource 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
matrixMatrixSource Matrix on the left of the mul sign.
scaleFactorfloatScalar value on the right of the mul sign.
Returns
- Matrix
Result of the matrix multiplication with a scalar.
operator -(Matrix, Matrix)
public static Matrix operator -(Matrix matrix1, Matrix matrix2)
Parameters
matrix1MatrixSource Matrix on the left of the sub sign.
matrix2MatrixSource 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
Returns
- Matrix
Result of the inversion.