Class MatrixHelper
- Namespace
- HelixToolkit.Maths
- Assembly
- HelixToolkit.Maths.dll
Represents a 4x4 mathematical matrix.
public static class MatrixHelper
- Inheritance
-
MatrixHelper
- Inherited Members
Fields
Identity
The identity Matrix4x4.
public static readonly Matrix4x4 Identity
Field Value
SizeInBytes
The size of the Matrix4x4 type, in bytes.
public static readonly uint SizeInBytes
Field Value
Zero
A Matrix4x4 with all of its components set to zero.
public static readonly Matrix4x4 Zero
Field Value
Methods
AffineTransformation(float, Quaternion, Vector3)
Creates a 3D affine transformation matrix.
public static Matrix4x4 AffineTransformation(float scaling, Quaternion rotation, Vector3 translation)
Parameters
scalingfloatScaling factor.
rotationQuaternionThe rotation of the transformation.
translationVector3The translation factor of the transformation.
Returns
- Matrix4x4
The created affine transformation matrix.
AffineTransformation(float, ref Quaternion, ref Vector3, out Matrix4x4)
Creates a 3D affine transformation matrix.
public static void AffineTransformation(float scaling, ref Quaternion rotation, ref Vector3 translation, out Matrix4x4 result)
Parameters
scalingfloatScaling factor.
rotationQuaternionThe rotation of the transformation.
translationVector3The translation factor of the transformation.
resultMatrix4x4When the method completes, contains the created affine transformation matrix.
AffineTransformation(float, Vector3, Quaternion, Vector3)
Creates a 3D affine transformation matrix.
public static Matrix4x4 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
- Matrix4x4
The created affine transformation matrix.
AffineTransformation(float, ref Vector3, ref Quaternion, ref Vector3, out Matrix4x4)
Creates a 3D affine transformation matrix.
public static void AffineTransformation(float scaling, ref Vector3 rotationCenter, ref Quaternion rotation, ref Vector3 translation, out Matrix4x4 result)
Parameters
scalingfloatScaling factor.
rotationCenterVector3The center of the rotation.
rotationQuaternionThe rotation of the transformation.
translationVector3The translation factor of the transformation.
resultMatrix4x4When the method completes, contains the created affine transformation matrix.
AffineTransformation2D(float, Vector2, float, Vector2)
Creates a 2D affine transformation matrix.
public static Matrix4x4 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
- Matrix4x4
The created affine transformation matrix.
AffineTransformation2D(float, ref Vector2, float, ref Vector2, out Matrix4x4)
Creates a 2D affine transformation matrix.
public static void AffineTransformation2D(float scaling, ref Vector2 rotationCenter, float rotation, ref Vector2 translation, out Matrix4x4 result)
Parameters
scalingfloatScaling factor.
rotationCenterVector2The center of the rotation.
rotationfloatThe rotation of the transformation.
translationVector2The translation factor of the transformation.
resultMatrix4x4When the method completes, contains the created affine transformation matrix.
AffineTransformation2D(float, float, Vector2)
Creates a 2D affine transformation matrix.
public static Matrix4x4 AffineTransformation2D(float scaling, float rotation, Vector2 translation)
Parameters
scalingfloatScaling factor.
rotationfloatThe rotation of the transformation.
translationVector2The translation factor of the transformation.
Returns
- Matrix4x4
The created affine transformation matrix.
AffineTransformation2D(float, float, ref Vector2, out Matrix4x4)
Creates a 2D affine transformation matrix.
public static void AffineTransformation2D(float scaling, float rotation, ref Vector2 translation, out Matrix4x4 result)
Parameters
scalingfloatScaling factor.
rotationfloatThe rotation of the transformation.
translationVector2The translation factor of the transformation.
resultMatrix4x4When the method completes, contains the created affine transformation matrix.
Backward(Matrix4x4)
Gets or sets the backward Vector3 of the matrix; that is M31, M32, and M33.
public static Vector3 Backward(this Matrix4x4 m)
Parameters
Returns
BillboardLH(Vector3, Vector3, Vector3, Vector3)
Creates a left-handed spherical billboard that rotates around a specified object position.
public static Matrix4x4 BillboardLH(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
- Matrix4x4
The created billboard matrix.
BillboardLH(ref Vector3, ref Vector3, ref Vector3, ref Vector3, out Matrix4x4)
Creates a left-handed spherical billboard that rotates around a specified object position.
public static void BillboardLH(ref Vector3 objectPosition, ref Vector3 cameraPosition, ref Vector3 cameraUpVector, ref Vector3 cameraForwardVector, out Matrix4x4 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.
resultMatrix4x4When the method completes, contains the created billboard matrix.
BillboardRH(Vector3, Vector3, Vector3, Vector3)
Creates a right-handed spherical billboard that rotates around a specified object position.
public static Matrix4x4 BillboardRH(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
- Matrix4x4
The created billboard matrix.
BillboardRH(ref Vector3, ref Vector3, ref Vector3, ref Vector3, out Matrix4x4)
Creates a right-handed spherical billboard that rotates around a specified object position.
public static void BillboardRH(ref Vector3 objectPosition, ref Vector3 cameraPosition, ref Vector3 cameraUpVector, ref Vector3 cameraForwardVector, out Matrix4x4 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.
resultMatrix4x4When the method completes, contains the created billboard matrix.
Column1(Matrix4x4)
Gets or sets the first column in the matrix; that is M11, M21, M31, and M41.
public static Vector4 Column1(this Matrix4x4 m)
Parameters
Returns
Column2(Matrix4x4)
Gets or sets the second column in the matrix; that is M12, M22, M32, and M42.
public static Vector4 Column2(this Matrix4x4 m)
Parameters
Returns
Column3(Matrix4x4)
Gets or sets the third column in the matrix; that is M13, M23, M33, and M43.
public static Vector4 Column3(this Matrix4x4 m)
Parameters
Returns
Column4(Matrix4x4)
Gets or sets the fourth column in the matrix; that is M14, M24, M34, and M44.
public static Vector4 Column4(this Matrix4x4 m)
Parameters
Returns
DecomposeLQ(Matrix4x4, out Matrix4x4, out Matrix4x4)
Decomposes a matrix into a lower triangular matrix L and an orthonormalized matrix Q.
public static void DecomposeLQ(this Matrix4x4 m, out Matrix4x4 L, out Matrix4x4 Q)
Parameters
mMatrix4x4LMatrix4x4When the method completes, contains the lower triangular matrix of the decomposition.
QMatrix4x4When the method completes, contains the orthonormalized matrix of the decomposition.
DecomposeQR(Matrix4x4, out Matrix4x4, out Matrix4x4)
Decomposes a matrix into an orthonormalized matrix Q and a right triangular matrix R.
public static void DecomposeQR(this Matrix4x4 m, out Matrix4x4 Q, out Matrix4x4 R)
Parameters
mMatrix4x4QMatrix4x4When the method completes, contains the orthonormalized matrix of the decomposition.
RMatrix4x4When the method completes, contains the right triangular matrix of the decomposition.
DecomposeUniformScale(Matrix4x4, out float, out Quaternion, out Vector3)
Decomposes a uniform scale matrix into a scale, rotation, and translation. A uniform scale matrix has the same scale in every axis.
public static bool DecomposeUniformScale(this Matrix4x4 m, out float scale, out Quaternion rotation, out Vector3 translation)
Parameters
mMatrix4x4scalefloatWhen 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 only an SRT transformation matrix that has the same scale in every axis.
Down(Matrix4x4)
Gets or sets the down Vector3 of the matrix; that is -M21, -M22, and -M23.
public static Vector3 Down(this Matrix4x4 m)
Parameters
Returns
ExchangeColumns(ref Matrix4x4, int, int)
Exchanges two columns in the matrix.
public static void ExchangeColumns(ref Matrix4x4 m, int firstColumn, int secondColumn)
Parameters
mMatrix4x4firstColumnintThe first column to exchange. This is an index of the column starting at zero.
secondColumnintThe second column to exchange. This is an index of the column starting at zero.
ExchangeRows(ref Matrix4x4, int, int)
Exchanges two rows in the matrix.
public static void ExchangeRows(ref Matrix4x4 m, int firstRow, int secondRow)
Parameters
mMatrix4x4firstRowintThe 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(Matrix4x4, int)
Performs the exponential operation on a matrix.
public static Matrix4x4 Exponent(Matrix4x4 value, int exponent)
Parameters
valueMatrix4x4The matrix to perform the operation on.
exponentintThe exponent to raise the matrix to.
Returns
- Matrix4x4
The exponential matrix.
Exceptions
- ArgumentOutOfRangeException
Thrown when the
exponentis negative.
Exponent(ref Matrix4x4, int, out Matrix4x4)
Performs the exponential operation on a matrix.
public static void Exponent(ref Matrix4x4 value, int exponent, out Matrix4x4 result)
Parameters
valueMatrix4x4The matrix to perform the operation on.
exponentintThe exponent to raise the matrix to.
resultMatrix4x4When the method completes, contains the exponential matrix.
Exceptions
- ArgumentOutOfRangeException
Thrown when the
exponentis negative.
Forward(Matrix4x4)
Gets or sets the forward Vector3 of the matrix; that is -M31, -M32, and -M33.
public static Vector3 Forward(this Matrix4x4 m)
Parameters
Returns
Get(Matrix4x4, int)
Gets or sets the component at the specified index.
public static float Get(this Matrix4x4 m, int index)
Parameters
Returns
- float
The value of the matrix component, depending on the index.
Exceptions
- ArgumentOutOfRangeException
Thrown when the
indexis out of the range [0, 15].
Get(Matrix4x4, int, int)
Gets or sets the component at the specified index.
public static float Get(this Matrix4x4 m, int row, int column)
Parameters
Returns
- float
The value of the matrix component, depending on the index.
Exceptions
- ArgumentOutOfRangeException
Thrown when the
roworcolumnis out of the range [0, 3].
GetColumn(Matrix4x4, int)
Gets the column. Zero based index. column Index = 0 will get column 1.
public static Vector4 GetColumn(this Matrix4x4 m, int columnIdx)
Parameters
Returns
Exceptions
- ArgumentException
Column Index out of bound.
GetRow(Matrix4x4, int)
Gets the row. Zero based index. Row Index = 0 will get row 1.
public static Vector4 GetRow(this Matrix4x4 m, int rowIdx)
Parameters
Returns
Exceptions
- ArgumentException
Row Index out of bound.
Inverted(Matrix4x4)
Return inverted matrix if the operation succeeded. Otherwise, return Identity
public static Matrix4x4 Inverted(this Matrix4x4 matrix)
Parameters
matrixMatrix4x4
Returns
Left(Matrix4x4)
Gets or sets the left Vector3 of the matrix; that is -M11, -M12, and -M13.
public static Vector3 Left(this Matrix4x4 m)
Parameters
Returns
LookAtLH(Vector3, Vector3, Vector3)
Creates a left-handed, look-at matrix.
public static Matrix4x4 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
- Matrix4x4
The created look-at matrix.
LookAtLH(ref Vector3, ref Vector3, ref Vector3, out Matrix4x4)
Creates a left-handed, look-at matrix.
public static void LookAtLH(ref Vector3 eye, ref Vector3 target, ref Vector3 up, out Matrix4x4 result)
Parameters
eyeVector3The position of the viewer's eye.
targetVector3The camera look-at target.
upVector3The camera's up vector.
resultMatrix4x4When the method completes, contains the created look-at matrix.
LookAtRH(Vector3, Vector3, Vector3)
Creates a right-handed, look-at matrix.
public static Matrix4x4 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
- Matrix4x4
The created look-at matrix.
LookAtRH(ref Vector3, ref Vector3, ref Vector3, out Matrix4x4)
Creates a right-handed, look-at matrix.
public static void LookAtRH(ref Vector3 eye, ref Vector3 target, ref Vector3 up, out Matrix4x4 result)
Parameters
eyeVector3The position of the viewer's eye.
targetVector3The camera look-at target.
upVector3The camera's up vector.
resultMatrix4x4When the method completes, contains the created look-at matrix.
LowerTriangularForm(Matrix4x4)
Brings the matrix into lower triangular form using elementary row operations.
public static Matrix4x4 LowerTriangularForm(Matrix4x4 value)
Parameters
valueMatrix4x4The matrix to put into lower triangular form.
Returns
- Matrix4x4
The lower triangular matrix.
Remarks
If the matrix is not invertible (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 Matrix4x4, out Matrix4x4)
Brings the matrix into lower triangular form using elementary row operations.
public static void LowerTriangularForm(ref Matrix4x4 value, out Matrix4x4 result)
Parameters
valueMatrix4x4The matrix to put into lower triangular form.
resultMatrix4x4When the method completes, contains the lower triangular matrix.
Remarks
If the matrix is not invertible (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.
Negate(ref Matrix4x4, out Matrix4x4)
Negates a matrix.
public static void Negate(ref Matrix4x4 value, out Matrix4x4 result)
Parameters
valueMatrix4x4The matrix to be negated.
resultMatrix4x4When the method completes, contains the negated matrix.
OrthoLH(float, float, float, float)
Creates a left-handed, orthographic projection matrix.
public static Matrix4x4 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
- Matrix4x4
The created projection matrix.
OrthoLH(float, float, float, float, out Matrix4x4)
Creates a left-handed, orthographic projection matrix.
public static void OrthoLH(float width, float height, float znear, float zfar, out Matrix4x4 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.
resultMatrix4x4When 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 Matrix4x4 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
- Matrix4x4
The created projection matrix.
OrthoOffCenterLH(float, float, float, float, float, float, out Matrix4x4)
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 Matrix4x4 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.
resultMatrix4x4When 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 Matrix4x4 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
- Matrix4x4
The created projection matrix.
OrthoOffCenterRH(float, float, float, float, float, float, out Matrix4x4)
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 Matrix4x4 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.
resultMatrix4x4When the method completes, contains the created projection matrix.
OrthoRH(float, float, float, float)
Creates a right-handed, orthographic projection matrix.
public static Matrix4x4 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
- Matrix4x4
The created projection matrix.
OrthoRH(float, float, float, float, out Matrix4x4)
Creates a right-handed, orthographic projection matrix.
public static void OrthoRH(float width, float height, float znear, float zfar, out Matrix4x4 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.
resultMatrix4x4When the method completes, contains the created projection matrix.
Orthogonalize(Matrix4x4)
Orthogonalizes the specified matrix.
public static Matrix4x4 Orthogonalize(Matrix4x4 value)
Parameters
valueMatrix4x4The matrix to orthogonalize.
Returns
- Matrix4x4
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 Matrix4x4)
Orthogonalizes the specified matrix.
public static void Orthogonalize(ref Matrix4x4 m)
Parameters
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 Matrix4x4, out Matrix4x4)
Orthogonalizes the specified matrix.
public static void Orthogonalize(ref Matrix4x4 value, out Matrix4x4 result)
Parameters
valueMatrix4x4The matrix to orthogonalize.
resultMatrix4x4When 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(Matrix4x4)
Orthonormalizes the specified matrix.
public static Matrix4x4 Orthonormalize(Matrix4x4 value)
Parameters
valueMatrix4x4The matrix to orthonormalize.
Returns
- Matrix4x4
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 Matrix4x4)
Orthonormalizes the specified matrix.
public static void Orthonormalize(ref Matrix4x4 m)
Parameters
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 Matrix4x4, out Matrix4x4)
Orthonormalizes the specified matrix.
public static void Orthonormalize(ref Matrix4x4 value, out Matrix4x4 result)
Parameters
valueMatrix4x4The matrix to orthonormalize.
resultMatrix4x4When 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 Matrix4x4 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
- Matrix4x4
The created projection matrix.
PerspectiveFovLH(float, float, float, float, out Matrix4x4)
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 Matrix4x4 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.
resultMatrix4x4When 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 Matrix4x4 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
- Matrix4x4
The created projection matrix.
PerspectiveFovRH(float, float, float, float, out Matrix4x4)
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 Matrix4x4 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.
resultMatrix4x4When the method completes, contains the created projection matrix.
PerspectiveLH(float, float, float, float)
Creates a left-handed, perspective projection matrix.
public static Matrix4x4 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
- Matrix4x4
The created projection matrix.
PerspectiveLH(float, float, float, float, out Matrix4x4)
Creates a left-handed, perspective projection matrix.
public static void PerspectiveLH(float width, float height, float znear, float zfar, out Matrix4x4 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.
resultMatrix4x4When 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 Matrix4x4 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
- Matrix4x4
The created projection matrix.
PerspectiveOffCenterLH(float, float, float, float, float, float, out Matrix4x4)
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 Matrix4x4 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.
resultMatrix4x4When 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 Matrix4x4 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
- Matrix4x4
The created projection matrix.
PerspectiveOffCenterRH(float, float, float, float, float, float, out Matrix4x4)
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 Matrix4x4 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.
resultMatrix4x4When the method completes, contains the created projection matrix.
PerspectiveRH(float, float, float, float)
Creates a right-handed, perspective projection matrix.
public static Matrix4x4 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
- Matrix4x4
The created projection matrix.
PerspectiveRH(float, float, float, float, out Matrix4x4)
Creates a right-handed, perspective projection matrix.
public static void PerspectiveRH(float width, float height, float znear, float zfar, out Matrix4x4 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.
resultMatrix4x4When the method completes, contains the created projection matrix.
PsudoInvert(Matrix4x4)
Pseudo inversion. Usually use to perform fast view matrix inversion.
public static Matrix4x4 PsudoInvert(this Matrix4x4 viewMatrix)
Parameters
viewMatrixMatrix4x4
Returns
PsudoInvert(ref Matrix4x4)
Pseudo inversion. Usually use to perform fast view matrix inversion.
public static Matrix4x4 PsudoInvert(ref Matrix4x4 viewMatrix)
Parameters
viewMatrixMatrix4x4
Returns
ReducedRowEchelonForm(ref Matrix4x4, ref Vector4, out Matrix4x4, out Vector4)
Brings the matrix into reduced row echelon form using elementary row operations.
public static void ReducedRowEchelonForm(ref Matrix4x4 value, ref Vector4 augment, out Matrix4x4 result, out Vector4 augmentResult)
Parameters
valueMatrix4x4The matrix to put into reduced row echelon form.
augmentVector4The fifth column of the matrix.
resultMatrix4x4When 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 augmented 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.
Right(Matrix4x4)
Gets or sets the right Vector3 of the matrix; that is M11, M12, and M13.
public static Vector3 Right(this Matrix4x4 m)
Parameters
Returns
RotationAxis(Vector3, float)
Rotations the axis. Angle is radian.
public static Matrix4x4 RotationAxis(Vector3 axis, float angle)
Parameters
Returns
RotationX(float)
Rotations the x.Angle is radian.
public static Matrix4x4 RotationX(float angle)
Parameters
anglefloatThe radian.
Returns
RotationY(float)
Rotations the y.Angle is radian.
public static Matrix4x4 RotationY(float angle)
Parameters
anglefloatThe radian.
Returns
RotationZ(float)
Rotations the z.Angle is radian.
public static Matrix4x4 RotationZ(float angle)
Parameters
anglefloatThe radian.
Returns
Row1(Matrix4x4)
Gets or sets the first row in the matrix; that is M11, M12, M13, and M14.
public static Vector4 Row1(this Matrix4x4 m)
Parameters
Returns
Row2(Matrix4x4)
Gets or sets the second row in the matrix; that is M21, M22, M23, and M24.
public static Vector4 Row2(this Matrix4x4 m)
Parameters
Returns
Row3(Matrix4x4)
Gets or sets the third row in the matrix; that is M31, M32, M33, and M34.
public static Vector4 Row3(this Matrix4x4 m)
Parameters
Returns
Row4(Matrix4x4)
Gets or sets the fourth row in the matrix; that is M41, M42, M43, and M44.
public static Vector4 Row4(this Matrix4x4 m)
Parameters
Returns
RowEchelonForm(Matrix4x4)
Brings the matrix into row echelon form using elementary row operations;
public static Matrix4x4 RowEchelonForm(Matrix4x4 value)
Parameters
valueMatrix4x4The matrix to put into row echelon form.
Returns
- Matrix4x4
When the method completes, contains the row echelon form of the matrix.
RowEchelonForm(ref Matrix4x4, out Matrix4x4)
Brings the matrix into row echelon form using elementary row operations;
public static void RowEchelonForm(ref Matrix4x4 value, out Matrix4x4 result)
Parameters
valueMatrix4x4The matrix to put into row echelon form.
resultMatrix4x4When the method completes, contains the row echelon form of the matrix.
ScaleVector(Matrix4x4)
Gets or sets the scale of the matrix; that is M11, M22, and M33.
public static Vector3 ScaleVector(this Matrix4x4 m)
Parameters
Returns
Scaling(Vector3)
Scalings the specified v.
public static Matrix4x4 Scaling(Vector3 v)
Parameters
vVector3The v.
Returns
Scaling(Vector3, Vector3)
Scalings the specified v.
public static Matrix4x4 Scaling(Vector3 v, Vector3 center)
Parameters
Returns
Scaling(float)
Scalings the specified scaling.
public static Matrix4x4 Scaling(float scaling)
Parameters
scalingfloatThe scaling.
Returns
Scaling(float, float, float)
Scalings the specified x.
public static Matrix4x4 Scaling(float x, float y, float z)
Parameters
Returns
Set(ref Matrix4x4, int, int, float)
public static void Set(ref Matrix4x4 m, int row, int column, float value)
Parameters
Set(ref Matrix4x4, int, float)
public static void Set(ref Matrix4x4 m, int index, float value)
Parameters
SetBackward(ref Matrix4x4, ref Vector3)
public static void SetBackward(ref Matrix4x4 m, ref Vector3 value)
Parameters
SetColumn(ref Matrix4x4, int, Vector4)
Sets the column by index. Index 0 sets column 1;
public static void SetColumn(ref Matrix4x4 m, int columnIdx, Vector4 value)
Parameters
Exceptions
- ArgumentException
Column Index out of bound.
SetColumn1(ref Matrix4x4, Vector4)
public static void SetColumn1(ref Matrix4x4 m, Vector4 value)
Parameters
SetColumn1(ref Matrix4x4, ref Vector4)
public static void SetColumn1(ref Matrix4x4 m, ref Vector4 value)
Parameters
SetColumn2(ref Matrix4x4, Vector4)
public static void SetColumn2(ref Matrix4x4 m, Vector4 value)
Parameters
SetColumn2(ref Matrix4x4, ref Vector4)
public static void SetColumn2(ref Matrix4x4 m, ref Vector4 value)
Parameters
SetColumn3(ref Matrix4x4, Vector4)
public static void SetColumn3(ref Matrix4x4 m, Vector4 value)
Parameters
SetColumn3(ref Matrix4x4, ref Vector4)
public static void SetColumn3(ref Matrix4x4 m, ref Vector4 value)
Parameters
SetColumn4(ref Matrix4x4, Vector4)
public static void SetColumn4(ref Matrix4x4 m, Vector4 value)
Parameters
SetColumn4(ref Matrix4x4, ref Vector4)
public static void SetColumn4(ref Matrix4x4 m, ref Vector4 value)
Parameters
SetDown(ref Matrix4x4, ref Vector3)
public static void SetDown(ref Matrix4x4 m, ref Vector3 value)
Parameters
SetForward(ref Matrix4x4, ref Vector3)
public static void SetForward(ref Matrix4x4 m, ref Vector3 value)
Parameters
SetLeft(ref Matrix4x4, ref Vector3)
public static void SetLeft(ref Matrix4x4 m, ref Vector3 value)
Parameters
SetRight(ref Matrix4x4, ref Vector3)
public static void SetRight(ref Matrix4x4 m, ref Vector3 value)
Parameters
SetRow(ref Matrix4x4, int, Vector4)
Sets the row by index. Index 0 sets row 1.
public static void SetRow(ref Matrix4x4 m, int rowIdx, Vector4 value)
Parameters
Exceptions
- ArgumentException
Row Index out of bound.
SetRow1(ref Matrix4x4, Vector4)
public static void SetRow1(ref Matrix4x4 m, Vector4 value)
Parameters
SetRow1(ref Matrix4x4, ref Vector4)
public static void SetRow1(ref Matrix4x4 m, ref Vector4 value)
Parameters
SetRow2(ref Matrix4x4, Vector4)
public static void SetRow2(ref Matrix4x4 m, Vector4 value)
Parameters
SetRow2(ref Matrix4x4, ref Vector4)
public static void SetRow2(ref Matrix4x4 m, ref Vector4 value)
Parameters
SetRow3(ref Matrix4x4, Vector4)
public static void SetRow3(ref Matrix4x4 m, Vector4 value)
Parameters
SetRow3(ref Matrix4x4, ref Vector4)
public static void SetRow3(ref Matrix4x4 m, ref Vector4 value)
Parameters
SetRow4(ref Matrix4x4, Vector4)
public static void SetRow4(ref Matrix4x4 m, Vector4 value)
Parameters
SetRow4(ref Matrix4x4, ref Vector4)
public static void SetRow4(ref Matrix4x4 m, ref Vector4 value)
Parameters
SetScaleVector(ref Matrix4x4, ref Vector3)
public static void SetScaleVector(ref Matrix4x4 m, ref Vector3 value)
Parameters
SetUp(ref Matrix4x4, ref Vector3)
public static void SetUp(ref Matrix4x4 m, ref Vector3 up)
Parameters
Skew(float, ref Vector3, ref Vector3, out Matrix4x4)
Creates a skew/shear matrix by means of a translation vector, a rotation vector, and a rotation angle. shearing is performed in the direction of translation vector, where translation vector and rotation vector define the shearing plane. The effect is such that the skewed rotation vector has the specified angle with rotation itself.
public static void Skew(float angle, ref Vector3 rotationVec, ref Vector3 transVec, out Matrix4x4 matrix)
Parameters
anglefloatThe rotation angle.
rotationVecVector3The rotation vector
transVecVector3The translation vector
matrixMatrix4x4Contains the created skew/shear matrix.
SmoothStep(Matrix4x4, Matrix4x4, float)
Performs a cubic interpolation between two matrices.
public static Matrix4x4 SmoothStep(Matrix4x4 start, Matrix4x4 end, float amount)
Parameters
startMatrix4x4Start matrix.
endMatrix4x4End matrix.
amountfloatValue between 0 and 1 indicating the weight of
end.
Returns
- Matrix4x4
The cubic interpolation of the two matrices.
SmoothStep(ref Matrix4x4, ref Matrix4x4, float, out Matrix4x4)
Performs a cubic interpolation between two matrices.
public static void SmoothStep(ref Matrix4x4 start, ref Matrix4x4 end, float amount, out Matrix4x4 result)
Parameters
startMatrix4x4Start matrix.
endMatrix4x4End matrix.
amountfloatValue between 0 and 1 indicating the weight of
end.resultMatrix4x4When the method completes, contains the cubic interpolation of the two matrices.
ToArray(Matrix4x4)
Creates an array containing the elements of the matrix.
public static float[] ToArray(this Matrix4x4 m)
Parameters
Returns
- float[]
A sixteen-element array containing the components of the matrix.
Transformation(Vector3, Quaternion, Vector3, Vector3, Quaternion, Vector3)
Creates a transformation matrix.
public static Matrix4x4 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
- Matrix4x4
The created transformation matrix.
Transformation(ref Vector3, ref Quaternion, ref Vector3, ref Vector3, ref Quaternion, ref Vector3, out Matrix4x4)
Creates a transformation matrix.
public static void Transformation(ref Vector3 scalingCenter, ref Quaternion scalingRotation, ref Vector3 scaling, ref Vector3 rotationCenter, ref Quaternion rotation, ref Vector3 translation, out Matrix4x4 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.
resultMatrix4x4When the method completes, contains the created transformation matrix.
Transformation2D(Vector2, float, Vector2, Vector2, float, Vector2)
Creates a 2D transformation matrix.
public static Matrix4x4 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
- Matrix4x4
The created transformation matrix.
Transformation2D(ref Vector2, float, ref Vector2, ref Vector2, float, ref Vector2, out Matrix4x4)
Creates a 2D transformation matrix.
public static void Transformation2D(ref Vector2 scalingCenter, float scalingRotation, ref Vector2 scaling, ref Vector2 rotationCenter, float rotation, ref Vector2 translation, out Matrix4x4 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.
resultMatrix4x4When the method completes, contains the created transformation matrix.
Translation(Vector3)
Translations the specified v.
public static Matrix4x4 Translation(Vector3 v)
Parameters
vVector3The v.
Returns
Translation(float, float, float)
Translations the specified x.
public static Matrix4x4 Translation(float x, float y, float z)
Parameters
Returns
Up(Matrix4x4)
Gets or sets the up Vector3 of the matrix; that is M21, M22, and M23.
public static Vector3 Up(this Matrix4x4 m)
Parameters
Returns
UpperTriangularForm(Matrix4x4)
Brings the matrix into upper triangular form using elementary row operations.
public static Matrix4x4 UpperTriangularForm(Matrix4x4 value)
Parameters
valueMatrix4x4The matrix to put into upper triangular form.
Returns
- Matrix4x4
The upper triangular matrix.
Remarks
If the matrix is not invertible (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 Matrix4x4, out Matrix4x4)
Brings the matrix into upper triangular form using elementary row operations.
public static void UpperTriangularForm(ref Matrix4x4 value, out Matrix4x4 result)
Parameters
valueMatrix4x4The matrix to put into upper triangular form.
resultMatrix4x4When the method completes, contains the upper triangular matrix.
Remarks
If the matrix is not invertible (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.