Struct Matrix
- Namespace
- Stride.Core.Mathematics
- Assembly
- Stride.Core.Mathematics.dll
Represents a 4x4 mathematical matrix.
[DataContract("float4x4")]
[DataStyle(DataStyle.Compact)]
public struct Matrix : IEquatable<Matrix>, ISpanFormattable, IFormattable
- Implements
Constructors
Matrix(float)
Initializes a new instance of the Matrix struct.
public Matrix(float value)
Parameters
valuefloatThe value that will be assigned to all components.
Matrix(float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float)
Initializes a new instance of the Matrix struct.
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
M11floatThe value to assign at row 1 column 1 of the matrix.
M12floatThe value to assign at row 1 column 2 of the matrix.
M13floatThe value to assign at row 1 column 3 of the matrix.
M14floatThe value to assign at row 1 column 4 of the matrix.
M21floatThe value to assign at row 2 column 1 of the matrix.
M22floatThe value to assign at row 2 column 2 of the matrix.
M23floatThe value to assign at row 2 column 3 of the matrix.
M24floatThe value to assign at row 2 column 4 of the matrix.
M31floatThe value to assign at row 3 column 1 of the matrix.
M32floatThe value to assign at row 3 column 2 of the matrix.
M33floatThe value to assign at row 3 column 3 of the matrix.
M34floatThe value to assign at row 3 column 4 of the matrix.
M41floatThe value to assign at row 4 column 1 of the matrix.
M42floatThe value to assign at row 4 column 2 of the matrix.
M43floatThe value to assign at row 4 column 3 of the matrix.
M44floatThe value to assign at row 4 column 4 of the matrix.
Matrix(float[])
Initializes a new instance of the Matrix struct.
public Matrix(float[] values)
Parameters
valuesfloat[]The values to assign to the components of the matrix. This must be an array with sixteen elements.
Exceptions
- ArgumentNullException
Thrown when
valuesisnull.- ArgumentOutOfRangeException
Thrown when
valuescontains more or less than sixteen elements.
Fields
Identity
The identity Matrix.
public static readonly Matrix Identity
Field Value
LayoutIsRowMajor
Are matrix row or column major
public const bool LayoutIsRowMajor = false
Field Value
Remarks
Dotnet's Matrix4x4 are row major.
M11
Value at row 1 column 1 of the matrix.
public float M11
Field Value
M12
Value at row 1 column 2 of the matrix.
public float M12
Field Value
M13
Value at row 1 column 3 of the matrix.
public float M13
Field Value
M14
Value at row 1 column 4 of the matrix.
public float M14
Field Value
M21
Value at row 2 column 1 of the matrix.
public float M21
Field Value
M22
Value at row 2 column 2 of the matrix.
public float M22
Field Value
M23
Value at row 2 column 3 of the matrix.
public float M23
Field Value
M24
Value at row 2 column 4 of the matrix.
public float M24
Field Value
M31
Value at row 3 column 1 of the matrix.
public float M31
Field Value
M32
Value at row 3 column 2 of the matrix.
public float M32
Field Value
M33
Value at row 3 column 3 of the matrix.
public float M33
Field Value
M34
Value at row 3 column 4 of the matrix.
public float M34
Field Value
M41
Value at row 4 column 1 of the matrix.
public float M41
Field Value
M42
Value at row 4 column 2 of the matrix.
public float M42
Field Value
M43
Value at row 4 column 3 of the matrix.
public float M43
Field Value
M44
Value at row 4 column 4 of the matrix.
public float M44
Field Value
SizeInBytes
The size of the Matrix type, in bytes.
public static readonly int SizeInBytes
Field Value
Zero
A Matrix with all of its components set to zero.
public static readonly Matrix Zero
Field Value
Properties
Backward
Gets or sets the backward Vector3 of the matrix; that is M31, M32, and M33.
public Vector3 Backward { readonly get; set; }
Property Value
Column1
Gets or sets the first column in the matrix; that is M11, M21, M31, and M41.
public Vector4 Column1 { readonly get; set; }
Property Value
Column2
Gets or sets the second column in the matrix; that is M12, M22, M32, and M42.
public Vector4 Column2 { readonly get; set; }
Property Value
Column3
Gets or sets the third column in the matrix; that is M13, M23, M33, and M43.
public Vector4 Column3 { readonly get; set; }
Property Value
Column4
Gets or sets the fourth column in the matrix; that is M14, M24, M34, and M44.
public Vector4 Column4 { readonly get; set; }
Property Value
Down
Gets or sets the down Vector3 of the matrix; that is -M21, -M22, and -M23.
public Vector3 Down { readonly get; set; }
Property Value
Forward
Gets or sets the forward Vector3 of the matrix; that is -M31, -M32, and -M33.
public Vector3 Forward { readonly get; set; }
Property Value
IsIdentity
Gets a value indicating whether this instance is an identity matrix.
public readonly bool IsIdentity { get; }
Property Value
- bool
trueif this instance is an identity matrix; otherwise,false.
this[int]
Gets or sets the component at the specified index.
public float this[int index] { readonly get; set; }
Parameters
indexintThe zero-based index of the component to access.
Property Value
- float
The value of the matrix component, depending on the index.
Exceptions
- ArgumentOutOfRangeException
Thrown when the
indexis out of the range [0, 15].
this[int, int]
Gets or sets the component at the specified index.
public float this[int row, int column] { readonly get; set; }
Parameters
Property Value
- float
The value of the matrix component, depending on the index.
Exceptions
- ArgumentOutOfRangeException
Thrown when the
roworcolumnis out of the range [0, 3].
Left
Gets or sets the left Vector3 of the matrix; that is -M11, -M12, and -M13.
public Vector3 Left { readonly get; set; }
Property Value
Right
Gets or sets the right Vector3 of the matrix; that is M11, M12, and M13.
public Vector3 Right { readonly get; set; }
Property Value
Row1
Gets or sets the first row in the matrix; that is M11, M12, M13, and M14.
public Vector4 Row1 { readonly get; set; }
Property Value
Row2
Gets or sets the second row in the matrix; that is M21, M22, M23, and M24.
public Vector4 Row2 { readonly get; set; }
Property Value
Row3
Gets or sets the third row in the matrix; that is M31, M32, M33, and M34.
public Vector4 Row3 { readonly get; set; }
Property Value
Row4
Gets or sets the fourth row in the matrix; that is M41, M42, M43, and M44.
public Vector4 Row4 { readonly get; set; }
Property Value
ScaleVector
Gets or sets the scale of the matrix; that is M11, M22, and M33.
public Vector3 ScaleVector { readonly get; set; }
Property Value
Remarks
This property does not do any computation and will return a correct scale vector only if the matrix is a scale matrix.
TranslationVector
Gets or sets the translation of the matrix; that is M41, M42, and M43.
public Vector3 TranslationVector { readonly get; set; }
Property Value
Up
Gets or sets the up Vector3 of the matrix; that is M21, M22, and M23.
public Vector3 Up { readonly get; set; }
Property Value
Methods
Add(Matrix, Matrix)
Determines the sum of two matrices.
public static Matrix Add(Matrix left, Matrix right)
Parameters
Returns
- Matrix
The sum of the two matrices.
Add(ref readonly Matrix, ref readonly Matrix, out Matrix)
Determines the sum of two matrices.
public static void Add(ref readonly Matrix left, ref readonly Matrix right, out Matrix result)
Parameters
leftMatrixThe first matrix to add.
rightMatrixThe second matrix to add.
resultMatrixWhen the method completes, contains the sum of the two matrices.
AffineTransformation(float, Quaternion, Vector3)
Creates a 3D affine transformation matrix.
public static Matrix AffineTransformation(float scaling, Quaternion rotation, Vector3 translation)
Parameters
scalingfloatScaling factor.
rotationQuaternionThe rotation of the transformation.
translationVector3The translation factor of the transformation.
Returns
- Matrix
The created affine transformation matrix.
AffineTransformation(float, ref readonly Quaternion, ref readonly Vector3, out Matrix)
Creates a 3D affine transformation matrix.
public static void AffineTransformation(float scaling, ref readonly Quaternion rotation, ref readonly Vector3 translation, out Matrix result)
Parameters
scalingfloatScaling factor.
rotationQuaternionThe rotation of the transformation.
translationVector3The translation factor of the transformation.
resultMatrixWhen the method completes, contains the created affine transformation matrix.
AffineTransformation(float, Vector3, Quaternion, Vector3)
Creates a 3D affine transformation matrix.
public static Matrix AffineTransformation(float scaling, Vector3 rotationCenter, Quaternion rotation, Vector3 translation)
Parameters
scalingfloatScaling factor.
rotationCenterVector3The center of the rotation.
rotationQuaternionThe rotation of the transformation.
translationVector3The translation factor of the transformation.
Returns
- Matrix
The created affine transformation matrix.
AffineTransformation(float, ref readonly Vector3, ref readonly Quaternion, ref readonly Vector3, out Matrix)
Creates a 3D affine transformation matrix.
public static void AffineTransformation(float scaling, ref readonly Vector3 rotationCenter, ref readonly Quaternion rotation, ref readonly Vector3 translation, out Matrix result)
Parameters
scalingfloatScaling factor.
rotationCenterVector3The center of the rotation.
rotationQuaternionThe rotation of the transformation.
translationVector3The translation factor of the transformation.
resultMatrixWhen the method completes, contains the created affine transformation matrix.
AffineTransformation2D(float, Vector2, float, Vector2)
Creates a 2D affine transformation matrix.
public static Matrix AffineTransformation2D(float scaling, Vector2 rotationCenter, float rotation, Vector2 translation)
Parameters
scalingfloatScaling factor.
rotationCenterVector2The center of the rotation.
rotationfloatThe rotation of the transformation.
translationVector2The translation factor of the transformation.
Returns
- Matrix
The created affine transformation matrix.
AffineTransformation2D(float, ref readonly Vector2, float, ref readonly Vector2, out Matrix)
Creates a 2D affine transformation matrix.
public static void AffineTransformation2D(float scaling, ref readonly Vector2 rotationCenter, float rotation, ref readonly Vector2 translation, out Matrix result)
Parameters
scalingfloatScaling factor.
rotationCenterVector2The center of the rotation.
rotationfloatThe rotation of the transformation.
translationVector2The translation factor of the transformation.
resultMatrixWhen the method completes, contains the created affine transformation matrix.
AffineTransformation2D(float, float, Vector2)
Creates a 2D affine transformation matrix.
public static Matrix AffineTransformation2D(float scaling, float rotation, Vector2 translation)
Parameters
scalingfloatScaling factor.
rotationfloatThe rotation of the transformation.
translationVector2The translation factor of the transformation.
Returns
- Matrix
The created affine transformation matrix.
AffineTransformation2D(float, float, ref readonly Vector2, out Matrix)
Creates a 2D affine transformation matrix.
public static void AffineTransformation2D(float scaling, float rotation, ref readonly Vector2 translation, out Matrix result)
Parameters
scalingfloatScaling factor.
rotationfloatThe rotation of the transformation.
translationVector2The translation factor of the transformation.
resultMatrixWhen the method completes, contains the created affine transformation matrix.
Billboard(Vector3, Vector3, Vector3, Vector3)
Creates a spherical billboard that rotates around a specified object position.
public static Matrix Billboard(Vector3 objectPosition, Vector3 cameraPosition, Vector3 cameraUpVector, Vector3 cameraForwardVector)
Parameters
objectPositionVector3The position of the object around which the billboard will rotate.
cameraPositionVector3The position of the camera.
cameraUpVectorVector3The up vector of the camera.
cameraForwardVectorVector3The forward vector of the camera.
Returns
- Matrix
The created billboard matrix.
Billboard(ref readonly Vector3, ref readonly Vector3, ref readonly Vector3, ref readonly Vector3, out Matrix)
Creates a spherical billboard that rotates around a specified object position.
public static void Billboard(ref readonly Vector3 objectPosition, ref readonly Vector3 cameraPosition, ref readonly Vector3 cameraUpVector, ref readonly Vector3 cameraForwardVector, out Matrix result)
Parameters
objectPositionVector3The position of the object around which the billboard will rotate.
cameraPositionVector3The position of the camera.
cameraUpVectorVector3The up vector of the camera.
cameraForwardVectorVector3The forward vector of the camera.
resultMatrixWhen the method completes, contains the created billboard matrix.
CopyMatrixFrom(float*, int, int)
Copies a nxm matrix to this instance.
public void CopyMatrixFrom(float* src, int columns, int rows)
Parameters
Decompose(out Vector3, out Matrix, out Vector3)
Decomposes a matrix into a scale, rotation, and translation.
public readonly bool Decompose(out Vector3 scale, out Matrix rotation, out Vector3 translation)
Parameters
scaleVector3When the method completes, contains the scaling component of the decomposed matrix.
rotationMatrixWhen the method completes, contains the rotation component of the decomposed matrix.
translationVector3When the method completes, contains the translation component of the decomposed matrix.
Returns
Remarks
This method is designed to decompose an SRT transformation matrix only.
Decompose(out Vector3, out Quaternion, out Vector3)
Decomposes a matrix into a scale, rotation, and translation.
public readonly bool Decompose(out Vector3 scale, out Quaternion rotation, out Vector3 translation)
Parameters
scaleVector3When the method completes, contains the scaling component of the decomposed matrix.
rotationQuaternionWhen the method completes, contains the rotation component of the decomposed matrix.
translationVector3When the method completes, contains the translation component of the decomposed matrix.
Returns
Remarks
This method is designed to decompose an SRT transformation matrix only.
Decompose(out Vector3, out Vector3)
Decomposes a matrix into a scale, rotation, and translation.
public readonly bool Decompose(out Vector3 scale, out Vector3 translation)
Parameters
scaleVector3When the method completes, contains the scaling component of the decomposed matrix.
translationVector3When the method completes, contains the translation component of the decomposed matrix.
Returns
- bool
trueif a rotation exist for this matrix,falseotherwise.
Remarks
This method is designed to decompose an SRT transformation matrix only.
Decompose(out float, out float, out float)
Decomposes a rotation matrix with the specified yaw, pitch, roll value (angles in radians).
public readonly void Decompose(out float yaw, out float pitch, out float roll)
Parameters
yawfloatThe yaw component in radians.
pitchfloatThe pitch component in radians.
rollfloatThe roll component in radians.
Remarks
This rotation matrix can be represented by intrinsic rotations in the order yaw, pitch, then roll.
Therefore, the extrinsic rotations to achieve this matrix is the reversed order of operations,
i.e. Matrix.RotationZ(roll) * Matrix.RotationX(pitch) * Matrix.RotationY(yaw)
DecomposeLQ(out Matrix, out Matrix)
Decomposes a matrix into a lower triangular matrix L and an orthonormalized matrix Q.
public void DecomposeLQ(out Matrix L, out Matrix Q)
Parameters
LMatrixWhen the method completes, contains the lower triangular matrix of the decomposition.
QMatrixWhen the method completes, contains the orthonormalized matrix of the decomposition.
DecomposeQR(out Matrix, out Matrix)
Decomposes a matrix into an orthonormalized matrix Q and a right triangular matrix R.
public readonly void DecomposeQR(out Matrix Q, out Matrix R)
Parameters
QMatrixWhen the method completes, contains the orthonormalized matrix of the decomposition.
RMatrixWhen the method completes, contains the right triangular matrix of the decomposition.
DecomposeXYZ(out Vector3)
Decomposes a rotation matrix with the specified X, Y and Z euler angles in radians. Matrix.RotationX(rotation.X) * Matrix.RotationY(rotation.Y) * Matrix.RotationZ(rotation.Z) should represent the same rotation.
public readonly void DecomposeXYZ(out Vector3 rotation)
Parameters
rotationVector3The vector containing the 3 rotations angles to be applied in order.
Determinant()
Calculates the determinant of the matrix.
public readonly float Determinant()
Returns
- float
The determinant of the matrix.
Divide(Matrix, Matrix)
Determines the quotient of two matrices.
public static Matrix Divide(Matrix left, Matrix right)
Parameters
Returns
- Matrix
The quotient of the two matrices.
Divide(Matrix, float)
Scales a matrix by the given value.
public static Matrix Divide(Matrix left, float right)
Parameters
Returns
- Matrix
The scaled matrix.
Divide(ref readonly Matrix, ref readonly Matrix, out Matrix)
Determines the quotient of two matrices.
public static void Divide(ref readonly Matrix left, ref readonly Matrix right, out Matrix result)
Parameters
leftMatrixThe first matrix to divide.
rightMatrixThe second matrix to divide.
resultMatrixWhen the method completes, contains the quotient of the two matrices.
Divide(ref readonly Matrix, float, out Matrix)
Scales a matrix by the given value.
public static void Divide(ref readonly Matrix left, float right, out Matrix result)
Parameters
leftMatrixThe matrix to scale.
rightfloatThe amount by which to scale.
resultMatrixWhen the method completes, contains the scaled matrix.
Equals(Matrix)
Determines whether the specified Matrix is equal to this instance.
public readonly bool Equals(Matrix other)
Parameters
Returns
Equals(object?)
Determines whether the specified object is equal to this instance.
public override readonly bool Equals(object? value)
Parameters
valueobjectThe object to compare with this instance.
Returns
- bool
trueif the specified object is equal to this instance; otherwise,false.
ExchangeColumns(int, int)
Exchange columns.
public void ExchangeColumns(int firstColumn, int secondColumn)
Parameters
ExchangeRows(int, int)
Exchanges two rows in the matrix.
public void ExchangeRows(int firstRow, int secondRow)
Parameters
firstRowintThe first row to exchange. This is an index of the row starting at zero.
secondRowintThe second row to exchange. This is an index of the row starting at zero.
Exponent(Matrix, int)
Performs the exponential operation on a matrix.
public static Matrix Exponent(Matrix value, int exponent)
Parameters
valueMatrixThe matrix to perform the operation on.
exponentintThe exponent to raise the matrix to.
Returns
- Matrix
The exponential matrix.
Exceptions
- ArgumentOutOfRangeException
Thrown when the
exponentis negative.
Exponent(ref readonly Matrix, int, out Matrix)
Performs the exponential operation on a matrix.
public static void Exponent(ref readonly Matrix value, int exponent, out Matrix result)
Parameters
valueMatrixThe matrix to perform the operation on.
exponentintThe exponent to raise the matrix to.
resultMatrixWhen the method completes, contains the exponential matrix.
Exceptions
- ArgumentOutOfRangeException
Thrown when the
exponentis negative.
GetHashCode()
Returns a hash code for this instance.
public override readonly int GetHashCode()
Returns
- int
A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table.
Invert()
Inverts the matrix. If the matrix cannot be inverted (eg. Determinant was zero), then the matrix will be set equivalent to Zero.
public void Invert()
Invert(Matrix)
Calculates the inverse of the specified matrix. If the matrix cannot be inverted (eg. Determinant was zero), then the returning matrix will be Zero.
public static Matrix Invert(Matrix value)
Parameters
valueMatrixThe matrix whose inverse is to be calculated.
Returns
- Matrix
The inverse of the specified matrix.
Invert(ref readonly Matrix, out Matrix)
Calculates the inverse of the specified matrix.
If the matrix cannot be inverted (eg. Determinant was zero), then result will be Zero.
public static void Invert(ref readonly Matrix value, out Matrix result)
Parameters
valueMatrixThe matrix whose inverse is to be calculated.
resultMatrixWhen the method completes, contains the inverse of the specified matrix.
Lerp(Matrix, Matrix, float)
Performs a linear interpolation between two matrices.
public static Matrix Lerp(Matrix start, Matrix end, float amount)
Parameters
startMatrixStart matrix.
endMatrixEnd matrix.
amountfloatValue between 0 and 1 indicating the weight of
end.
Returns
- Matrix
The linear interpolation of the two matrices.
Remarks
This method performs the linear interpolation based on the following formula.
start + (end - start) * amount
Passing amount a value of 0 will cause start to be returned; a value of 1 will cause end to be returned.
Lerp(ref readonly Matrix, ref readonly Matrix, float, out Matrix)
Performs a linear interpolation between two matrices.
public static void Lerp(ref readonly Matrix start, ref readonly Matrix end, float amount, out Matrix result)
Parameters
startMatrixStart matrix.
endMatrixEnd matrix.
amountfloatValue between 0 and 1 indicating the weight of
end.resultMatrixWhen the method completes, contains the linear interpolation of the two matrices.
Remarks
This method performs the linear interpolation based on the following formula.
start + (end - start) * amount
Passing amount a value of 0 will cause start to be returned; a value of 1 will cause end to be returned.
LookAtLH(Vector3, Vector3, Vector3)
Creates a left-handed, look-at matrix.
public static Matrix LookAtLH(Vector3 eye, Vector3 target, Vector3 up)
Parameters
eyeVector3The position of the viewer's eye.
targetVector3The camera look-at target.
upVector3The camera's up vector.
Returns
- Matrix
The created look-at matrix.
LookAtLH(ref readonly Vector3, ref readonly Vector3, ref readonly Vector3, out Matrix)
Creates a left-handed, look-at matrix.
public static void LookAtLH(ref readonly Vector3 eye, ref readonly Vector3 target, ref readonly Vector3 up, out Matrix result)
Parameters
eyeVector3The position of the viewer's eye.
targetVector3The camera look-at target.
upVector3The camera's up vector.
resultMatrixWhen the method completes, contains the created look-at matrix.
LookAtRH(Vector3, Vector3, Vector3)
Creates a right-handed, look-at matrix.
public static Matrix LookAtRH(Vector3 eye, Vector3 target, Vector3 up)
Parameters
eyeVector3The position of the viewer's eye.
targetVector3The camera look-at target.
upVector3The camera's up vector.
Returns
- Matrix
The created look-at matrix.
LookAtRH(ref readonly Vector3, ref readonly Vector3, ref readonly Vector3, out Matrix)
Creates a right-handed, look-at matrix.
public static void LookAtRH(ref readonly Vector3 eye, ref readonly Vector3 target, ref readonly Vector3 up, out Matrix result)
Parameters
eyeVector3The position of the viewer's eye.
targetVector3The camera look-at target.
upVector3The camera's up vector.
resultMatrixWhen the method completes, contains the created look-at matrix.
LowerTriangularForm(Matrix)
Brings the matrix into lower triangular form using elementry row operations.
public static Matrix LowerTriangularForm(Matrix value)
Parameters
valueMatrixThe matrix to put into lower triangular form.
Returns
- Matrix
The lower triangular matrix.
Remarks
If the matrix is not invertable (i.e. its determinant is zero) than the result of this method may produce Single.Nan and Single.Inf values. When the matrix represents a system of linear equations, than this often means that either no solution exists or an infinite number of solutions exist.
LowerTriangularForm(ref readonly Matrix, out Matrix)
Brings the matrix into lower triangular form using elementry row operations.
public static void LowerTriangularForm(ref readonly Matrix value, out Matrix result)
Parameters
valueMatrixThe matrix to put into lower triangular form.
resultMatrixWhen the method completes, contains the lower triangular matrix.
Remarks
If the matrix is not invertable (i.e. its determinant is zero) than the result of this method may produce Single.Nan and Single.Inf values. When the matrix represents a system of linear equations, than this often means that either no solution exists or an infinite number of solutions exist.
Multiply(Matrix, float)
Scales a matrix by the given value.
public static Matrix Multiply(Matrix left, float right)
Parameters
Returns
- Matrix
The scaled matrix.
Multiply(in Matrix, in Matrix)
Determines the product of two matrices, equivalent to the '*' operator.
public static Matrix Multiply(in Matrix left, in Matrix right)
Parameters
Returns
- Matrix
The product of the two matrices.
Multiply(ref readonly Matrix, ref readonly Matrix, out Matrix)
Determines the product of two matrices.
Variables passed as left or right must not be used as the out parameter
result, because result is calculated in-place.
public static void Multiply(ref readonly Matrix left, ref readonly Matrix right, out Matrix result)
Parameters
leftMatrixThe first matrix to multiply.
rightMatrixThe second matrix to multiply.
resultMatrixThe product of the two matrices.
Multiply(ref readonly Matrix, float, out Matrix)
Scales a matrix by the given value.
public static void Multiply(ref readonly Matrix left, float right, out Matrix result)
Parameters
leftMatrixThe matrix to scale.
rightfloatThe amount by which to scale.
resultMatrixWhen the method completes, contains the scaled matrix.
MultiplyIn(in Matrix, in Matrix, out Matrix)
Determines the product of two matrices.
Variables passed as left or right must not be used as the out parameter
result, because result is calculated in-place.
public static void MultiplyIn(in Matrix left, in Matrix right, out Matrix result)
Parameters
leftMatrixThe first matrix to multiply.
rightMatrixThe second matrix to multiply.
resultMatrixThe product of the two matrices.
Negate(Matrix)
Negates a matrix.
public static Matrix Negate(Matrix value)
Parameters
valueMatrixThe matrix to be negated.
Returns
- Matrix
The negated matrix.
Negate(ref readonly Matrix, out Matrix)
Negates a matrix.
public static void Negate(ref readonly Matrix value, out Matrix result)
Parameters
valueMatrixThe matrix to be negated.
resultMatrixWhen the method completes, contains the negated matrix.
OrthoLH(float, float, float, float)
Creates a left-handed, orthographic projection matrix.
public static Matrix OrthoLH(float width, float height, float znear, float zfar)
Parameters
widthfloatWidth of the viewing volume.
heightfloatHeight of the viewing volume.
znearfloatMinimum z-value of the viewing volume.
zfarfloatMaximum z-value of the viewing volume.
Returns
- Matrix
The created projection matrix.
OrthoLH(float, float, float, float, out Matrix)
Creates a left-handed, orthographic projection matrix.
public static void OrthoLH(float width, float height, float znear, float zfar, out Matrix result)
Parameters
widthfloatWidth of the viewing volume.
heightfloatHeight of the viewing volume.
znearfloatMinimum z-value of the viewing volume.
zfarfloatMaximum z-value of the viewing volume.
resultMatrixWhen the method completes, contains the created projection matrix.
OrthoOffCenterLH(float, float, float, float, float, float)
Creates a left-handed, customized orthographic projection matrix.
public static Matrix OrthoOffCenterLH(float left, float right, float bottom, float top, float znear, float zfar)
Parameters
leftfloatMinimum x-value of the viewing volume.
rightfloatMaximum x-value of the viewing volume.
bottomfloatMinimum y-value of the viewing volume.
topfloatMaximum y-value of the viewing volume.
znearfloatMinimum z-value of the viewing volume.
zfarfloatMaximum z-value of the viewing volume.
Returns
- Matrix
The created projection matrix.
OrthoOffCenterLH(float, float, float, float, float, float, out Matrix)
Creates a left-handed, customized orthographic projection matrix.
public static void OrthoOffCenterLH(float left, float right, float bottom, float top, float znear, float zfar, out Matrix result)
Parameters
leftfloatMinimum x-value of the viewing volume.
rightfloatMaximum x-value of the viewing volume.
bottomfloatMinimum y-value of the viewing volume.
topfloatMaximum y-value of the viewing volume.
znearfloatMinimum z-value of the viewing volume.
zfarfloatMaximum z-value of the viewing volume.
resultMatrixWhen the method completes, contains the created projection matrix.
OrthoOffCenterRH(float, float, float, float, float, float)
Creates a right-handed, customized orthographic projection matrix.
public static Matrix OrthoOffCenterRH(float left, float right, float bottom, float top, float znear, float zfar)
Parameters
leftfloatMinimum x-value of the viewing volume.
rightfloatMaximum x-value of the viewing volume.
bottomfloatMinimum y-value of the viewing volume.
topfloatMaximum y-value of the viewing volume.
znearfloatMinimum z-value of the viewing volume.
zfarfloatMaximum z-value of the viewing volume.
Returns
- Matrix
The created projection matrix.
OrthoOffCenterRH(float, float, float, float, float, float, out Matrix)
Creates a right-handed, customized orthographic projection matrix.
public static void OrthoOffCenterRH(float left, float right, float bottom, float top, float znear, float zfar, out Matrix result)
Parameters
leftfloatMinimum x-value of the viewing volume.
rightfloatMaximum x-value of the viewing volume.
bottomfloatMinimum y-value of the viewing volume.
topfloatMaximum y-value of the viewing volume.
znearfloatMinimum z-value of the viewing volume.
zfarfloatMaximum z-value of the viewing volume.
resultMatrixWhen the method completes, contains the created projection matrix.
OrthoRH(float, float, float, float)
Creates a right-handed, orthographic projection matrix.
public static Matrix OrthoRH(float width, float height, float znear, float zfar)
Parameters
widthfloatWidth of the viewing volume.
heightfloatHeight of the viewing volume.
znearfloatMinimum z-value of the viewing volume.
zfarfloatMaximum z-value of the viewing volume.
Returns
- Matrix
The created projection matrix.
OrthoRH(float, float, float, float, out Matrix)
Creates a right-handed, orthographic projection matrix.
public static void OrthoRH(float width, float height, float znear, float zfar, out Matrix result)
Parameters
widthfloatWidth of the viewing volume.
heightfloatHeight of the viewing volume.
znearfloatMinimum z-value of the viewing volume.
zfarfloatMaximum z-value of the viewing volume.
resultMatrixWhen the method completes, contains the created projection matrix.
Orthogonalize()
Orthogonalizes the specified matrix.
public void Orthogonalize()
Remarks
Orthogonalization is the process of making all rows orthogonal to each other. This means that any given row in the matrix will be orthogonal to any other given row in the matrix.
Because this method uses the modified Gram-Schmidt process, the resulting matrix tends to be numerically unstable. The numeric stability decreases according to the rows so that the first row is the most stable and the last row is the least stable.
This operation is performed on the rows of the matrix rather than the columns. If you wish for this operation to be performed on the columns, first transpose the input and then transpose the output.
Orthogonalize(Matrix)
Orthogonalizes the specified matrix.
public static Matrix Orthogonalize(Matrix value)
Parameters
valueMatrixThe matrix to orthogonalize.
Returns
- Matrix
The orthogonalized matrix.
Remarks
Orthogonalization is the process of making all rows orthogonal to each other. This means that any given row in the matrix will be orthogonal to any other given row in the matrix.
Because this method uses the modified Gram-Schmidt process, the resulting matrix tends to be numerically unstable. The numeric stability decreases according to the rows so that the first row is the most stable and the last row is the least stable.
This operation is performed on the rows of the matrix rather than the columns. If you wish for this operation to be performed on the columns, first transpose the input and than transpose the output.
Orthogonalize(ref readonly Matrix, out Matrix)
Orthogonalizes the specified matrix.
public static void Orthogonalize(ref readonly Matrix value, out Matrix result)
Parameters
valueMatrixThe matrix to orthogonalize.
resultMatrixWhen the method completes, contains the orthogonalized matrix.
Remarks
Orthogonalization is the process of making all rows orthogonal to each other. This means that any given row in the matrix will be orthogonal to any other given row in the matrix.
Because this method uses the modified Gram-Schmidt process, the resulting matrix tends to be numerically unstable. The numeric stability decreases according to the rows so that the first row is the most stable and the last row is the least stable.
This operation is performed on the rows of the matrix rather than the columns. If you wish for this operation to be performed on the columns, first transpose the input and than transpose the output.
Orthonormalize()
Orthonormalizes the specified matrix.
public void Orthonormalize()
Remarks
Orthonormalization is the process of making all rows and columns orthogonal to each other and making all rows and columns of unit length. This means that any given row will be orthogonal to any other given row and any given column will be orthogonal to any other given column. Any given row will not be orthogonal to any given column. Every row and every column will be of unit length.
Because this method uses the modified Gram-Schmidt process, the resulting matrix tends to be numerically unstable. The numeric stability decreases according to the rows so that the first row is the most stable and the last row is the least stable.
This operation is performed on the rows of the matrix rather than the columns. If you wish for this operation to be performed on the columns, first transpose the input and then transpose the output.
Orthonormalize(Matrix)
Orthonormalizes the specified matrix.
public static Matrix Orthonormalize(Matrix value)
Parameters
valueMatrixThe matrix to orthonormalize.
Returns
- Matrix
The orthonormalized matrix.
Remarks
Orthonormalization is the process of making all rows and columns orthogonal to each other and making all rows and columns of unit length. This means that any given row will be orthogonal to any other given row and any given column will be orthogonal to any other given column. Any given row will not be orthogonal to any given column. Every row and every column will be of unit length.
Because this method uses the modified Gram-Schmidt process, the resulting matrix tends to be numerically unstable. The numeric stability decreases according to the rows so that the first row is the most stable and the last row is the least stable.
This operation is performed on the rows of the matrix rather than the columns. If you wish for this operation to be performed on the columns, first transpose the input and than transpose the output.
Orthonormalize(ref readonly Matrix, out Matrix)
Orthonormalizes the specified matrix.
public static void Orthonormalize(ref readonly Matrix value, out Matrix result)
Parameters
valueMatrixThe matrix to orthonormalize.
resultMatrixWhen the method completes, contains the orthonormalized matrix.
Remarks
Orthonormalization is the process of making all rows and columns orthogonal to each other and making all rows and columns of unit length. This means that any given row will be orthogonal to any other given row and any given column will be orthogonal to any other given column. Any given row will not be orthogonal to any given column. Every row and every column will be of unit length.
Because this method uses the modified Gram-Schmidt process, the resulting matrix tends to be numerically unstable. The numeric stability decreases according to the rows so that the first row is the most stable and the last row is the least stable.
This operation is performed on the rows of the matrix rather than the columns. If you wish for this operation to be performed on the columns, first transpose the input and than transpose the output.
PerspectiveFovLH(float, float, float, float)
Creates a left-handed, perspective projection matrix based on a field of view.
public static Matrix PerspectiveFovLH(float fov, float aspect, float znear, float zfar)
Parameters
fovfloatField of view in the y direction, in radians.
aspectfloatAspect ratio, defined as view space width divided by height.
znearfloatMinimum z-value of the viewing volume.
zfarfloatMaximum z-value of the viewing volume.
Returns
- Matrix
The created projection matrix.
PerspectiveFovLH(float, float, float, float, out Matrix)
Creates a left-handed, perspective projection matrix based on a field of view.
public static void PerspectiveFovLH(float fov, float aspect, float znear, float zfar, out Matrix result)
Parameters
fovfloatField of view in the y direction, in radians.
aspectfloatAspect ratio, defined as view space width divided by height.
znearfloatMinimum z-value of the viewing volume.
zfarfloatMaximum z-value of the viewing volume.
resultMatrixWhen the method completes, contains the created projection matrix.
PerspectiveFovRH(float, float, float, float)
Creates a right-handed, perspective projection matrix based on a field of view.
public static Matrix PerspectiveFovRH(float fov, float aspect, float znear, float zfar)
Parameters
fovfloatField of view in the y direction, in radians.
aspectfloatAspect ratio, defined as view space width divided by height.
znearfloatMinimum z-value of the viewing volume.
zfarfloatMaximum z-value of the viewing volume.
Returns
- Matrix
The created projection matrix.
PerspectiveFovRH(float, float, float, float, out Matrix)
Creates a right-handed, perspective projection matrix based on a field of view.
public static void PerspectiveFovRH(float fov, float aspect, float znear, float zfar, out Matrix result)
Parameters
fovfloatField of view in the y direction, in radians.
aspectfloatAspect ratio, defined as view space width divided by height.
znearfloatMinimum z-value of the viewing volume.
zfarfloatMaximum z-value of the viewing volume.
resultMatrixWhen the method completes, contains the created projection matrix.
PerspectiveLH(float, float, float, float)
Creates a left-handed, perspective projection matrix.
public static Matrix PerspectiveLH(float width, float height, float znear, float zfar)
Parameters
widthfloatWidth of the viewing volume.
heightfloatHeight of the viewing volume.
znearfloatMinimum z-value of the viewing volume.
zfarfloatMaximum z-value of the viewing volume.
Returns
- Matrix
The created projection matrix.
PerspectiveLH(float, float, float, float, out Matrix)
Creates a left-handed, perspective projection matrix.
public static void PerspectiveLH(float width, float height, float znear, float zfar, out Matrix result)
Parameters
widthfloatWidth of the viewing volume.
heightfloatHeight of the viewing volume.
znearfloatMinimum z-value of the viewing volume.
zfarfloatMaximum z-value of the viewing volume.
resultMatrixWhen the method completes, contains the created projection matrix.
PerspectiveOffCenterLH(float, float, float, float, float, float)
Creates a left-handed, customized perspective projection matrix.
public static Matrix PerspectiveOffCenterLH(float left, float right, float bottom, float top, float znear, float zfar)
Parameters
leftfloatMinimum x-value of the viewing volume.
rightfloatMaximum x-value of the viewing volume.
bottomfloatMinimum y-value of the viewing volume.
topfloatMaximum y-value of the viewing volume.
znearfloatMinimum z-value of the viewing volume.
zfarfloatMaximum z-value of the viewing volume.
Returns
- Matrix
The created projection matrix.
PerspectiveOffCenterLH(float, float, float, float, float, float, out Matrix)
Creates a left-handed, customized perspective projection matrix.
public static void PerspectiveOffCenterLH(float left, float right, float bottom, float top, float znear, float zfar, out Matrix result)
Parameters
leftfloatMinimum x-value of the viewing volume.
rightfloatMaximum x-value of the viewing volume.
bottomfloatMinimum y-value of the viewing volume.
topfloatMaximum y-value of the viewing volume.
znearfloatMinimum z-value of the viewing volume.
zfarfloatMaximum z-value of the viewing volume.
resultMatrixWhen the method completes, contains the created projection matrix.
PerspectiveOffCenterRH(float, float, float, float, float, float)
Creates a right-handed, customized perspective projection matrix.
public static Matrix PerspectiveOffCenterRH(float left, float right, float bottom, float top, float znear, float zfar)
Parameters
leftfloatMinimum x-value of the viewing volume.
rightfloatMaximum x-value of the viewing volume.
bottomfloatMinimum y-value of the viewing volume.
topfloatMaximum y-value of the viewing volume.
znearfloatMinimum z-value of the viewing volume.
zfarfloatMaximum z-value of the viewing volume.
Returns
- Matrix
The created projection matrix.
PerspectiveOffCenterRH(float, float, float, float, float, float, out Matrix)
Creates a right-handed, customized perspective projection matrix.
public static void PerspectiveOffCenterRH(float left, float right, float bottom, float top, float znear, float zfar, out Matrix result)
Parameters
leftfloatMinimum x-value of the viewing volume.
rightfloatMaximum x-value of the viewing volume.
bottomfloatMinimum y-value of the viewing volume.
topfloatMaximum y-value of the viewing volume.
znearfloatMinimum z-value of the viewing volume.
zfarfloatMaximum z-value of the viewing volume.
resultMatrixWhen the method completes, contains the created projection matrix.
PerspectiveRH(float, float, float, float)
Creates a right-handed, perspective projection matrix.
public static Matrix PerspectiveRH(float width, float height, float znear, float zfar)
Parameters
widthfloatWidth of the viewing volume.
heightfloatHeight of the viewing volume.
znearfloatMinimum z-value of the viewing volume.
zfarfloatMaximum z-value of the viewing volume.
Returns
- Matrix
The created projection matrix.
PerspectiveRH(float, float, float, float, out Matrix)
Creates a right-handed, perspective projection matrix.
public static void PerspectiveRH(float width, float height, float znear, float zfar, out Matrix result)
Parameters
widthfloatWidth of the viewing volume.
heightfloatHeight of the viewing volume.
znearfloatMinimum z-value of the viewing volume.
zfarfloatMaximum z-value of the viewing volume.
resultMatrixWhen the method completes, contains the created projection matrix.
ReducedRowEchelonForm(ref readonly Matrix, ref readonly Vector4, out Matrix, out Vector4)
Brings the matrix into reduced row echelon form using elementry row operations.
public static void ReducedRowEchelonForm(ref readonly Matrix value, ref readonly Vector4 augment, out Matrix result, out Vector4 augmentResult)
Parameters
valueMatrixThe matrix to put into reduced row echelon form.
augmentVector4The fifth column of the matrix.
resultMatrixWhen the method completes, contains the resultant matrix after the operation.
augmentResultVector4When the method completes, contains the resultant fifth column of the matrix.
Remarks
The fifth column is often called the agumented part of the matrix. This is because the fifth column is really just an extension of the matrix so that there is a place to put all of the non-zero components after the operation is complete.
Often times the resultant matrix will the identity matrix or a matrix similar to the identity matrix. Sometimes, however, that is not possible and numbers other than zero and one may appear.
This method can be used to solve systems of linear equations. Upon completion of this method,
the augmentResult will contain the solution for the system. It is up to the user
to analyze both the input and the result to determine if a solution really exists.
Reflection(Plane)
Builds a matrix that can be used to reflect vectors about a plane.
public static Matrix Reflection(Plane plane)
Parameters
planePlaneThe plane for which the reflection occurs. This parameter is assumed to be normalized.
Returns
- Matrix
The reflection matrix.
Reflection(ref readonly Plane, out Matrix)
Builds a matrix that can be used to reflect vectors about a plane.
public static void Reflection(ref readonly Plane plane, out Matrix result)
Parameters
planePlaneThe plane for which the reflection occurs. This parameter is assumed to be normalized.
resultMatrixWhen the method completes, contains the reflection matrix.
RotationAxis(Vector3, float)
Creates a matrix that rotates around an arbitary axis.
public static Matrix RotationAxis(Vector3 axis, float angle)
Parameters
axisVector3The axis around which to rotate. This parameter is assumed to be normalized.
anglefloatAngle of rotation in radians. Angles are measured clockwise when looking along the rotation axis toward the origin.
Returns
- Matrix
The created rotation matrix.
RotationAxis(ref readonly Vector3, float, out Matrix)
Creates a matrix that rotates around an arbitary axis.
public static void RotationAxis(ref readonly Vector3 axis, float angle, out Matrix result)
Parameters
axisVector3The axis around which to rotate. This parameter is assumed to be normalized.
anglefloatAngle of rotation in radians. Angles are measured clockwise when looking along the rotation axis toward the origin.
resultMatrixWhen the method completes, contains the created rotation matrix.
RotationQuaternion(Quaternion)
Creates a rotation matrix from a quaternion.
public static Matrix RotationQuaternion(Quaternion rotation)
Parameters
rotationQuaternionThe quaternion to use to build the matrix.
Returns
- Matrix
The created rotation matrix.
RotationQuaternion(ref readonly Quaternion, out Matrix)
Creates a rotation matrix from a quaternion.
public static void RotationQuaternion(ref readonly Quaternion rotation, out Matrix result)
Parameters
rotationQuaternionThe quaternion to use to build the matrix.
resultMatrixThe created rotation matrix.
RotationX(float)
Creates a matrix that rotates around the x-axis.
public static Matrix RotationX(float angle)
Parameters
anglefloatAngle of rotation in radians. Angles are measured clockwise when looking along the rotation axis toward the origin.
Returns
- Matrix
The created rotation matrix.
RotationX(float, out Matrix)
Creates a matrix that rotates around the x-axis.
public static void RotationX(float angle, out Matrix result)
Parameters
anglefloatAngle of rotation in radians. Angles are measured clockwise when looking along the rotation axis toward the origin.
resultMatrixWhen the method completes, contains the created rotation matrix.
RotationY(float)
Creates a matrix that rotates around the y-axis.
public static Matrix RotationY(float angle)
Parameters
anglefloatAngle of rotation in radians. Angles are measured clockwise when looking along the rotation axis toward the origin.
Returns
- Matrix
The created rotation matrix.
RotationY(float, out Matrix)
Creates a matrix that rotates around the y-axis.
public static void RotationY(float angle, out Matrix result)
Parameters
anglefloatAngle of rotation in radians. Angles are measured clockwise when looking along the rotation axis toward the origin.
resultMatrixWhen the method completes, contains the created rotation matrix.
RotationYawPitchRoll(float, float, float)
Creates a rotation matrix with a specified yaw, pitch, and roll value (angles in radians).
public static Matrix RotationYawPitchRoll(float yaw, float pitch, float roll)
Parameters
yawfloatYaw around the y-axis, in radians.
pitchfloatPitch around the x-axis, in radians.
rollfloatRoll around the z-axis, in radians.
Returns
- Matrix
The created rotation matrix.
RotationYawPitchRoll(float, float, float, out Matrix)
Creates a rotation matrix with a specified yaw, pitch, and roll value (angles in radians).
public static void RotationYawPitchRoll(float yaw, float pitch, float roll, out Matrix result)
Parameters
yawfloatYaw around the y-axis, in radians.
pitchfloatPitch around the x-axis, in radians.
rollfloatRoll around the z-axis, in radians.
resultMatrixWhen the method completes, contains the created rotation matrix.
RotationZ(float)
Creates a matrix that rotates around the z-axis.
public static Matrix RotationZ(float angle)
Parameters
anglefloatAngle of rotation in radians. Angles are measured clockwise when looking along the rotation axis toward the origin.
Returns
- Matrix
The created rotation matrix.
RotationZ(float, out Matrix)
Creates a matrix that rotates around the z-axis.
public static void RotationZ(float angle, out Matrix result)
Parameters
anglefloatAngle of rotation in radians. Angles are measured clockwise when looking along the rotation axis toward the origin.
resultMatrixWhen the method completes, contains the created rotation matrix.
RowEchelonForm(Matrix)
Brings the matrix into row echelon form using elementry row operations;
public static Matrix RowEchelonForm(Matrix value)
Parameters
valueMatrixThe matrix to put into row echelon form.
Returns
- Matrix
When the method completes, contains the row echelon form of the matrix.
RowEchelonForm(ref readonly Matrix, out Matrix)
Brings the matrix into row echelon form using elementry row operations;
public static void RowEchelonForm(ref readonly Matrix value, out Matrix result)
Parameters
valueMatrixThe matrix to put into row echelon form.
resultMatrixWhen the method completes, contains the row echelon form of the matrix.
Scaling(Vector3)
Creates a matrix that scales along the x-axis, y-axis, and y-axis.
public static Matrix Scaling(Vector3 scale)
Parameters
scaleVector3Scaling factor for all three axes.
Returns
- Matrix
The created scaling matrix.
Scaling(ref readonly Vector3, out Matrix)
Creates a matrix that scales along the x-axis, y-axis, and y-axis.
public static void Scaling(ref readonly Vector3 scale, out Matrix result)
Parameters
scaleVector3Scaling factor for all three axes.
resultMatrixWhen the method completes, contains the created scaling matrix.
Scaling(float)
Creates a matrix that uniformally scales along all three axis.
public static Matrix Scaling(float scale)
Parameters
scalefloatThe uniform scale that is applied along all axis.
Returns
- Matrix
The created scaling matrix.
Scaling(float, out Matrix)
Creates a matrix that uniformally scales along all three axis.
public static void Scaling(float scale, out Matrix result)
Parameters
scalefloatThe uniform scale that is applied along all axis.
resultMatrixWhen the method completes, contains the created scaling matrix.
Scaling(float, float, float)
Creates a matrix that scales along the x-axis, y-axis, and y-axis.
public static Matrix Scaling(float x, float y, float z)
Parameters
xfloatScaling factor that is applied along the x-axis.
yfloatScaling factor that is applied along the y-axis.
zfloatScaling factor that is applied along the z-axis.
Returns
- Matrix
The created scaling matrix.
Scaling(float, float, float, out Matrix)
Creates a matrix that scales along the x-axis, y-axis, and y-axis.
public static void Scaling(float x, float y, float z, out Matrix result)
Parameters
xfloatScaling factor that is applied along the x-axis.
yfloatScaling factor that is applied along the y-axis.
zfloatScaling factor that is applied along the z-axis.
resultMatrixWhen the method completes, contains the created scaling matrix.
Shadow(Vector4, Plane)
Creates a matrix that flattens geometry into a shadow.
public static Matrix Shadow(Vector4 light, Plane plane)
Parameters
lightVector4The light direction. If the W component is 0, the light is directional light; if the W component is 1, the light is a point light.
planePlaneThe plane onto which to project the geometry as a shadow. This parameter is assumed to be normalized.
Returns
- Matrix
The shadow matrix.
Shadow(ref readonly Vector4, ref readonly Plane, out Matrix)
Creates a matrix that flattens geometry into a shadow.
public static void Shadow(ref readonly Vector4 light, ref readonly Plane plane, out Matrix result)
Parameters
lightVector4The light direction. If the W component is 0, the light is directional light; if the W component is 1, the light is a point light.
planePlaneThe plane onto which to project the geometry as a shadow. This parameter is assumed to be normalized.
resultMatrixWhen the method completes, contains the shadow matrix.
SmoothStep(Matrix, Matrix, float)
Performs a cubic interpolation between two matrices.
public static Matrix SmoothStep(Matrix start, Matrix end, float amount)
Parameters
startMatrixStart matrix.
endMatrixEnd matrix.
amountfloatValue between 0 and 1 indicating the weight of
end.
Returns
- Matrix
The cubic interpolation of the two matrices.
SmoothStep(ref readonly Matrix, ref readonly Matrix, float, out Matrix)
Performs a cubic interpolation between two matrices.
public static void SmoothStep(ref readonly Matrix start, ref readonly Matrix end, float amount, out Matrix result)
Parameters
startMatrixStart matrix.
endMatrixEnd matrix.
amountfloatValue between 0 and 1 indicating the weight of
end.resultMatrixWhen the method completes, contains the cubic interpolation of the two matrices.
Subtract(Matrix, Matrix)
Determines the difference between two matrices.
public static Matrix Subtract(Matrix left, Matrix right)
Parameters
Returns
- Matrix
The difference between the two matrices.
Subtract(ref readonly Matrix, ref readonly Matrix, out Matrix)
Determines the difference between two matrices.
public static void Subtract(ref readonly Matrix left, ref readonly Matrix right, out Matrix result)
Parameters
leftMatrixThe first matrix to subtract.
rightMatrixThe second matrix to subtract.
resultMatrixWhen the method completes, contains the difference between the two matrices.
ToArray()
Creates an array containing the elements of the matrix.
public readonly float[] ToArray()
Returns
- float[]
A sixteen-element array containing the components of the matrix.
ToString()
Returns a string that represents this instance.
public override readonly string ToString()
Returns
ToString(string?, IFormatProvider?)
Returns a string that represents this instance.
public readonly string ToString(string? format, IFormatProvider? formatProvider)
Parameters
formatstringThe format.
formatProviderIFormatProviderThe format provider.
Returns
Transformation(Vector3, Quaternion, Vector3, Vector3, Quaternion, Vector3)
Creates a transformation matrix.
public static Matrix Transformation(Vector3 scalingCenter, Quaternion scalingRotation, Vector3 scaling, Vector3 rotationCenter, Quaternion rotation, Vector3 translation)
Parameters
scalingCenterVector3Center point of the scaling operation.
scalingRotationQuaternionScaling rotation amount.
scalingVector3Scaling factor.
rotationCenterVector3The center of the rotation.
rotationQuaternionThe rotation of the transformation.
translationVector3The translation factor of the transformation.
Returns
- Matrix
The created transformation matrix.
Transformation(ref readonly Vector3, ref readonly Quaternion, ref readonly Vector3, out Matrix)
Creates a matrix that contains both the X, Y and Z rotation, as well as scaling and translation. Note: This function is NOT thead safe.
public static void Transformation(ref readonly Vector3 scaling, ref readonly Quaternion rotation, ref readonly Vector3 translation, out Matrix result)
Parameters
scalingVector3The scaling.
rotationQuaternionAngle of rotation in radians. Angles are measured clockwise when looking along the rotation axis toward the origin.
translationVector3The translation.
resultMatrixWhen the method completes, contains the created rotation matrix.
Transformation(ref readonly Vector3, ref readonly Quaternion, ref readonly Vector3, ref readonly Vector3, ref readonly Quaternion, ref readonly Vector3, out Matrix)
Creates a transformation matrix.
public static void Transformation(ref readonly Vector3 scalingCenter, ref readonly Quaternion scalingRotation, ref readonly Vector3 scaling, ref readonly Vector3 rotationCenter, ref readonly Quaternion rotation, ref readonly Vector3 translation, out Matrix result)
Parameters
scalingCenterVector3Center point of the scaling operation.
scalingRotationQuaternionScaling rotation amount.
scalingVector3Scaling factor.
rotationCenterVector3The center of the rotation.
rotationQuaternionThe rotation of the transformation.
translationVector3The translation factor of the transformation.
resultMatrixWhen the method completes, contains the created transformation matrix.
Transformation2D(Vector2, float, Vector2, Vector2, float, Vector2)
Creates a 2D transformation matrix.
public static Matrix Transformation2D(Vector2 scalingCenter, float scalingRotation, Vector2 scaling, Vector2 rotationCenter, float rotation, Vector2 translation)
Parameters
scalingCenterVector2Center point of the scaling operation.
scalingRotationfloatScaling rotation amount.
scalingVector2Scaling factor.
rotationCenterVector2The center of the rotation.
rotationfloatThe rotation of the transformation.
translationVector2The translation factor of the transformation.
Returns
- Matrix
The created transformation matrix.
Transformation2D(ref readonly Vector2, float, ref readonly Vector2, ref readonly Vector2, float, ref readonly Vector2, out Matrix)
Creates a 2D transformation matrix.
public static void Transformation2D(ref readonly Vector2 scalingCenter, float scalingRotation, ref readonly Vector2 scaling, ref readonly Vector2 rotationCenter, float rotation, ref readonly Vector2 translation, out Matrix result)
Parameters
scalingCenterVector2Center point of the scaling operation.
scalingRotationfloatScaling rotation amount.
scalingVector2Scaling factor.
rotationCenterVector2The center of the rotation.
rotationfloatThe rotation of the transformation.
translationVector2The translation factor of the transformation.
resultMatrixWhen the method completes, contains the created transformation matrix.
Translation(Vector3)
Creates a translation matrix using the specified offsets.
public static Matrix Translation(Vector3 value)
Parameters
valueVector3The offset for all three coordinate planes.
Returns
- Matrix
The created translation matrix.
Translation(ref readonly Vector3, out Matrix)
Creates a translation matrix using the specified offsets.
public static void Translation(ref readonly Vector3 value, out Matrix result)
Parameters
valueVector3The offset for all three coordinate planes.
resultMatrixWhen the method completes, contains the created translation matrix.
Translation(float, float, float)
Creates a translation matrix using the specified offsets.
public static Matrix Translation(float x, float y, float z)
Parameters
Returns
- Matrix
The created translation matrix.
Translation(float, float, float, out Matrix)
Creates a translation matrix using the specified offsets.
public static void Translation(float x, float y, float z, out Matrix result)
Parameters
xfloatX-coordinate offset.
yfloatY-coordinate offset.
zfloatZ-coordinate offset.
resultMatrixWhen the method completes, contains the created translation matrix.
Transpose()
Transposes the matrix.
public void Transpose()
Transpose(in Matrix)
Calculates the transpose of the specified matrix.
public static Matrix Transpose(in Matrix value)
Parameters
valueMatrixThe matrix whose transpose is to be calculated.
Returns
- Matrix
The transpose of the specified matrix.
Transpose(ref readonly Matrix, out Matrix)
Calculates the transpose of the specified matrix.
public static void Transpose(ref readonly Matrix value, out Matrix result)
Parameters
valueMatrixThe matrix whose transpose is to be calculated.
resultMatrixWhen the method completes, contains the transpose of the specified matrix.
TransposeMatrixFrom(float*, int, int)
Transposes a nmx matrix to this instance.
public void TransposeMatrixFrom(float* src, int columns, int rows)
Parameters
UpperTriangularForm(Matrix)
Brings the matrix into upper triangular form using elementry row operations.
public static Matrix UpperTriangularForm(Matrix value)
Parameters
valueMatrixThe matrix to put into upper triangular form.
Returns
- Matrix
The upper triangular matrix.
Remarks
If the matrix is not invertable (i.e. its determinant is zero) than the result of this method may produce Single.Nan and Single.Inf values. When the matrix represents a system of linear equations, than this often means that either no solution exists or an infinite number of solutions exist.
UpperTriangularForm(ref readonly Matrix, out Matrix)
Brings the matrix into upper triangular form using elementry row operations.
public static void UpperTriangularForm(ref readonly Matrix value, out Matrix result)
Parameters
valueMatrixThe matrix to put into upper triangular form.
resultMatrixWhen the method completes, contains the upper triangular matrix.
Remarks
If the matrix is not invertable (i.e. its determinant is zero) than the result of this method may produce Single.Nan and Single.Inf values. When the matrix represents a system of linear equations, than this often means that either no solution exists or an infinite number of solutions exist.
Operators
operator +(in Matrix, in Matrix)
Adds two matrices.
public static Matrix operator +(in Matrix left, in Matrix right)
Parameters
Returns
- Matrix
The sum of the two matrices.
operator /(in Matrix, in Matrix)
Divides two matrices.
public static Matrix operator /(in Matrix left, in Matrix right)
Parameters
Returns
- Matrix
The quotient of the two matrices.
operator /(in Matrix, in float)
Scales a matrix by a given value.
public static Matrix operator /(in Matrix left, in float right)
Parameters
Returns
- Matrix
The scaled matrix.
operator ==(in Matrix, in Matrix)
Tests for equality between two objects.
public static bool operator ==(in Matrix left, in Matrix right)
Parameters
Returns
- bool
trueiflefthas the same value asright; otherwise,false.
implicit operator Matrix4x4(Matrix)
Casts from Stride.Maths to System.Numerics matrix
public static implicit operator Matrix4x4(Matrix v)
Parameters
vMatrixValue to cast
Returns
implicit operator Matrix(Matrix4x4)
Casts from System.Numerics to Stride.Maths matrix
public static implicit operator Matrix(Matrix4x4 v)
Parameters
vMatrix4x4Value to cast
Returns
operator !=(in Matrix, in Matrix)
Tests for inequality between two objects.
public static bool operator !=(in Matrix left, in Matrix right)
Parameters
Returns
- bool
trueiflefthas a different value thanright; otherwise,false.
operator *(in Matrix, in Matrix)
Multiplies two matrices.
public static Matrix operator *(in Matrix left, in Matrix right)
Parameters
Returns
- Matrix
The product of the two matrices.
operator *(in Matrix, float)
Scales a matrix by a given value.
public static Matrix operator *(in Matrix left, float right)
Parameters
Returns
- Matrix
The scaled matrix.
operator *(float, in Matrix)
Scales a matrix by a given value.
public static Matrix operator *(float left, in Matrix right)
Parameters
Returns
- Matrix
The scaled matrix.
operator -(in Matrix, in Matrix)
Subtracts two matrices.
public static Matrix operator -(in Matrix left, in Matrix right)
Parameters
Returns
- Matrix
The difference between the two matrices.
operator -(in Matrix)
Negates a matrix.
public static Matrix operator -(in Matrix value)
Parameters
valueMatrixThe matrix to negate.
Returns
- Matrix
The negated matrix.
operator +(in Matrix)
Assert a matrix (return it unchanged).
public static Matrix operator +(in Matrix value)
Parameters
valueMatrixThe matrix to assert (unchange).
Returns
- Matrix
The asserted (unchanged) matrix.