Struct Matrix
Represents the right-handed 4x4 floating point matrix, which can store translation, scale and rotation information.
[DataContract]
public struct Matrix : IEquatable<Matrix>
- Implements
- Inherited Members
Constructors
Matrix(Vector4, Vector4, Vector4, Vector4)
Constructs a matrix.
public Matrix(Vector4 row1, Vector4 row2, Vector4 row3, Vector4 row4)
Parameters
row1
Vector4A first row of the created matrix.
row2
Vector4A second row of the created matrix.
row3
Vector4A third row of the created matrix.
row4
Vector4A fourth row of the created matrix.
Matrix(float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float)
Constructs a matrix.
public Matrix(float m11, float m12, float m13, float m14, float m21, float m22, float m23, float m24, float m31, float m32, float m33, float m34, float m41, float m42, float m43, float m44)
Parameters
m11
floatA first row and first column value.
m12
floatA first row and second column value.
m13
floatA first row and third column value.
m14
floatA first row and fourth column value.
m21
floatA second row and first column value.
m22
floatA second row and second column value.
m23
floatA second row and third column value.
m24
floatA second row and fourth column value.
m31
floatA third row and first column value.
m32
floatA third row and second column value.
m33
floatA third row and third column value.
m34
floatA third row and fourth column value.
m41
floatA fourth row and first column value.
m42
floatA fourth row and second column value.
m43
floatA fourth row and third column value.
m44
floatA fourth row and fourth column value.
Fields
M11
A first row and first column value.
[DataMember]
public float M11
Field Value
M12
A first row and second column value.
[DataMember]
public float M12
Field Value
M13
A first row and third column value.
[DataMember]
public float M13
Field Value
M14
A first row and fourth column value.
[DataMember]
public float M14
Field Value
M21
A second row and first column value.
[DataMember]
public float M21
Field Value
M22
A second row and second column value.
[DataMember]
public float M22
Field Value
M23
A second row and third column value.
[DataMember]
public float M23
Field Value
M24
A second row and fourth column value.
[DataMember]
public float M24
Field Value
M31
A third row and first column value.
[DataMember]
public float M31
Field Value
M32
A third row and second column value.
[DataMember]
public float M32
Field Value
M33
A third row and third column value.
[DataMember]
public float M33
Field Value
M34
A third row and fourth column value.
[DataMember]
public float M34
Field Value
M41
A fourth row and first column value.
[DataMember]
public float M41
Field Value
M42
A fourth row and second column value.
[DataMember]
public float M42
Field Value
M43
A fourth row and third column value.
[DataMember]
public float M43
Field Value
M44
A fourth row and fourth column value.
[DataMember]
public float M44
Field Value
Properties
Backward
The backward vector formed from the third row M31, M32, M33 elements.
public Vector3 Backward { get; set; }
Property Value
Down
The down vector formed from the second row -M21, -M22, -M23 elements.
public Vector3 Down { get; set; }
Property Value
Forward
The forward vector formed from the third row -M31, -M32, -M33 elements.
public Vector3 Forward { get; set; }
Property Value
Identity
Returns the identity matrix.
public static Matrix Identity { get; }
Property Value
this[int]
Get or set the matrix element at the given index, indexed in row major order.
public float this[int index] { get; set; }
Parameters
index
intThe linearized, zero-based index of the matrix element.
Property Value
Exceptions
- ArgumentOutOfRangeException
If the index is less than
or larger than0
.15
this[int, int]
Get or set the value at the specified row and column (indices are zero-based).
public float this[int row, int column] { get; set; }
Parameters
Property Value
Exceptions
- ArgumentOutOfRangeException
If the row or column is less than
or larger than0
.3
Left
The left vector formed from the first row -M11, -M12, -M13 elements.
public Vector3 Left { get; set; }
Property Value
Right
The right vector formed from the first row M11, M12, M13 elements.
public Vector3 Right { get; set; }
Property Value
Translation
Position stored in this matrix.
public Vector3 Translation { get; set; }
Property Value
Up
The upper vector formed from the second row M21, M22, M23 elements.
public Vector3 Up { get; set; }
Property Value
Methods
Add(Matrix, Matrix)
Creates a new Matrix which contains sum of two matrixes.
public static Matrix Add(Matrix matrix1, Matrix matrix2)
Parameters
Returns
- Matrix
The result of the matrix addition.
Add(ref Matrix, ref Matrix, out Matrix)
Creates a new Matrix which contains sum of two matrixes.
public static void Add(ref Matrix matrix1, ref Matrix matrix2, out Matrix result)
Parameters
matrix1
MatrixThe first matrix to add.
matrix2
MatrixThe second matrix to add.
result
MatrixThe result of the matrix addition as an output parameter.
CreateBillboard(Vector3, Vector3, Vector3, Vector3?)
Creates a new Matrix for spherical billboarding that rotates around specified object position.
public static Matrix CreateBillboard(Vector3 objectPosition, Vector3 cameraPosition, Vector3 cameraUpVector, Vector3? cameraForwardVector)
Parameters
objectPosition
Vector3Position of billboard object. It will rotate around that vector.
cameraPosition
Vector3The camera position.
cameraUpVector
Vector3The camera up vector.
cameraForwardVector
Vector3?Optional camera forward vector.
Returns
CreateBillboard(ref Vector3, ref Vector3, ref Vector3, Vector3?, out Matrix)
Creates a new Matrix for spherical billboarding that rotates around specified object position.
public static void CreateBillboard(ref Vector3 objectPosition, ref Vector3 cameraPosition, ref Vector3 cameraUpVector, Vector3? cameraForwardVector, out Matrix result)
Parameters
objectPosition
Vector3Position of billboard object. It will rotate around that vector.
cameraPosition
Vector3The camera position.
cameraUpVector
Vector3The camera up vector.
cameraForwardVector
Vector3?Optional camera forward vector.
result
MatrixThe Matrix for spherical billboarding as an output parameter.
CreateConstrainedBillboard(Vector3, Vector3, Vector3, Vector3?, Vector3?)
Creates a new Matrix for cylindrical billboarding that rotates around specified axis.
public static Matrix CreateConstrainedBillboard(Vector3 objectPosition, Vector3 cameraPosition, Vector3 rotateAxis, Vector3? cameraForwardVector, Vector3? objectForwardVector)
Parameters
objectPosition
Vector3Object position the billboard will rotate around.
cameraPosition
Vector3Camera position.
rotateAxis
Vector3Axis of billboard for rotation.
cameraForwardVector
Vector3?Optional camera forward vector.
objectForwardVector
Vector3?Optional object forward vector.
Returns
CreateConstrainedBillboard(ref Vector3, ref Vector3, ref Vector3, Vector3?, Vector3?, out Matrix)
Creates a new Matrix for cylindrical billboarding that rotates around specified axis.
public static void CreateConstrainedBillboard(ref Vector3 objectPosition, ref Vector3 cameraPosition, ref Vector3 rotateAxis, Vector3? cameraForwardVector, Vector3? objectForwardVector, out Matrix result)
Parameters
objectPosition
Vector3Object position the billboard will rotate around.
cameraPosition
Vector3Camera position.
rotateAxis
Vector3Axis of billboard for rotation.
cameraForwardVector
Vector3?Optional camera forward vector.
objectForwardVector
Vector3?Optional object forward vector.
result
MatrixThe Matrix for cylindrical billboarding as an output parameter.
CreateFromAxisAngle(Vector3, float)
Creates a new Matrix which contains the rotation moment around specified axis.
public static Matrix CreateFromAxisAngle(Vector3 axis, float angle)
Parameters
Returns
CreateFromAxisAngle(ref Vector3, float, out Matrix)
Creates a new Matrix which contains the rotation moment around specified axis.
public static void CreateFromAxisAngle(ref Vector3 axis, float angle, out Matrix result)
Parameters
axis
Vector3The axis of rotation.
angle
floatThe angle of rotation in radians.
result
MatrixThe rotation Matrix as an output parameter.
CreateFromQuaternion(Quaternion)
Creates a new rotation Matrix from a Quaternion.
public static Matrix CreateFromQuaternion(Quaternion quaternion)
Parameters
quaternion
QuaternionQuaternion of rotation moment.
Returns
CreateFromQuaternion(ref Quaternion, out Matrix)
Creates a new rotation Matrix from a Quaternion.
public static void CreateFromQuaternion(ref Quaternion quaternion, out Matrix result)
Parameters
quaternion
QuaternionQuaternion of rotation moment.
result
MatrixThe rotation Matrix as an output parameter.
CreateFromYawPitchRoll(float, float, float)
Creates a new rotation Matrix from the specified yaw, pitch and roll values.
public static Matrix CreateFromYawPitchRoll(float yaw, float pitch, float roll)
Parameters
yaw
floatThe yaw rotation value in radians.
pitch
floatThe pitch rotation value in radians.
roll
floatThe roll rotation value in radians.
Returns
Remarks
For more information about yaw, pitch and roll visit http://en.wikipedia.org/wiki/Euler_angles.
CreateFromYawPitchRoll(float, float, float, out Matrix)
Creates a new rotation Matrix from the specified yaw, pitch and roll values.
public static void CreateFromYawPitchRoll(float yaw, float pitch, float roll, out Matrix result)
Parameters
yaw
floatThe yaw rotation value in radians.
pitch
floatThe pitch rotation value in radians.
roll
floatThe roll rotation value in radians.
result
MatrixThe rotation Matrix as an output parameter.
Remarks
For more information about yaw, pitch and roll visit http://en.wikipedia.org/wiki/Euler_angles.
CreateLookAt(Vector3, Vector3, Vector3)
Creates a new viewing Matrix.
public static Matrix CreateLookAt(Vector3 cameraPosition, Vector3 cameraTarget, Vector3 cameraUpVector)
Parameters
cameraPosition
Vector3Position of the camera.
cameraTarget
Vector3Lookup vector of the camera.
cameraUpVector
Vector3The direction of the upper edge of the camera.
Returns
CreateLookAt(ref Vector3, ref Vector3, ref Vector3, out Matrix)
Creates a new viewing Matrix.
public static void CreateLookAt(ref Vector3 cameraPosition, ref Vector3 cameraTarget, ref Vector3 cameraUpVector, out Matrix result)
Parameters
cameraPosition
Vector3Position of the camera.
cameraTarget
Vector3Lookup vector of the camera.
cameraUpVector
Vector3The direction of the upper edge of the camera.
result
MatrixThe viewing Matrix as an output parameter.
CreateOrthographic(float, float, float, float)
Creates a new projection Matrix for orthographic view.
public static Matrix CreateOrthographic(float width, float height, float zNearPlane, float zFarPlane)
Parameters
width
floatWidth of the viewing volume.
height
floatHeight of the viewing volume.
zNearPlane
floatDepth of the near plane.
zFarPlane
floatDepth of the far plane.
Returns
CreateOrthographic(float, float, float, float, out Matrix)
Creates a new projection Matrix for orthographic view.
public static void CreateOrthographic(float width, float height, float zNearPlane, float zFarPlane, out Matrix result)
Parameters
width
floatWidth of the viewing volume.
height
floatHeight of the viewing volume.
zNearPlane
floatDepth of the near plane.
zFarPlane
floatDepth of the far plane.
result
MatrixThe new projection Matrix for orthographic view as an output parameter.
CreateOrthographicOffCenter(Rectangle, float, float)
Creates a new projection Matrix for customized orthographic view.
public static Matrix CreateOrthographicOffCenter(Rectangle viewingVolume, float zNearPlane, float zFarPlane)
Parameters
viewingVolume
RectangleThe viewing volume.
zNearPlane
floatDepth of the near plane.
zFarPlane
floatDepth of the far plane.
Returns
CreateOrthographicOffCenter(float, float, float, float, float, float)
Creates a new projection Matrix for customized orthographic view.
public static Matrix CreateOrthographicOffCenter(float left, float right, float bottom, float top, float zNearPlane, float zFarPlane)
Parameters
left
floatLower x-value at the near plane.
right
floatUpper x-value at the near plane.
bottom
floatLower y-coordinate at the near plane.
top
floatUpper y-value at the near plane.
zNearPlane
floatDepth of the near plane.
zFarPlane
floatDepth of the far plane.
Returns
CreateOrthographicOffCenter(float, float, float, float, float, float, out Matrix)
Creates a new projection Matrix for customized orthographic view.
public static void CreateOrthographicOffCenter(float left, float right, float bottom, float top, float zNearPlane, float zFarPlane, out Matrix result)
Parameters
left
floatLower x-value at the near plane.
right
floatUpper x-value at the near plane.
bottom
floatLower y-coordinate at the near plane.
top
floatUpper y-value at the near plane.
zNearPlane
floatDepth of the near plane.
zFarPlane
floatDepth of the far plane.
result
MatrixThe new projection Matrix for customized orthographic view as an output parameter.
CreatePerspective(float, float, float, float)
Creates a new projection Matrix for perspective view.
public static Matrix CreatePerspective(float width, float height, float nearPlaneDistance, float farPlaneDistance)
Parameters
width
floatWidth of the viewing volume.
height
floatHeight of the viewing volume.
nearPlaneDistance
floatDistance to the near plane.
farPlaneDistance
floatDistance to the far plane.
Returns
CreatePerspective(float, float, float, float, out Matrix)
Creates a new projection Matrix for perspective view.
public static void CreatePerspective(float width, float height, float nearPlaneDistance, float farPlaneDistance, out Matrix result)
Parameters
width
floatWidth of the viewing volume.
height
floatHeight of the viewing volume.
nearPlaneDistance
floatDistance to the near plane.
farPlaneDistance
floatDistance to the far plane, or PositiveInfinity.
result
MatrixThe new projection Matrix for perspective view as an output parameter.
CreatePerspectiveFieldOfView(float, float, float, float)
Creates a new projection Matrix for perspective view with field of view.
public static Matrix CreatePerspectiveFieldOfView(float fieldOfView, float aspectRatio, float nearPlaneDistance, float farPlaneDistance)
Parameters
fieldOfView
floatField of view in the y direction in radians.
aspectRatio
floatWidth divided by height of the viewing volume.
nearPlaneDistance
floatDistance to the near plane.
farPlaneDistance
floatDistance to the far plane, or PositiveInfinity.
Returns
CreatePerspectiveFieldOfView(float, float, float, float, out Matrix)
Creates a new projection Matrix for perspective view with field of view.
public static void CreatePerspectiveFieldOfView(float fieldOfView, float aspectRatio, float nearPlaneDistance, float farPlaneDistance, out Matrix result)
Parameters
fieldOfView
floatField of view in the y direction in radians.
aspectRatio
floatWidth divided by height of the viewing volume.
nearPlaneDistance
floatDistance of the near plane.
farPlaneDistance
floatDistance of the far plane, or PositiveInfinity.
result
MatrixThe new projection Matrix for perspective view with FOV as an output parameter.
CreatePerspectiveOffCenter(Rectangle, float, float)
Creates a new projection Matrix for customized perspective view.
public static Matrix CreatePerspectiveOffCenter(Rectangle viewingVolume, float nearPlaneDistance, float farPlaneDistance)
Parameters
viewingVolume
RectangleThe viewing volume.
nearPlaneDistance
floatDistance to the near plane.
farPlaneDistance
floatDistance to the far plane.
Returns
CreatePerspectiveOffCenter(float, float, float, float, float, float)
Creates a new projection Matrix for customized perspective view.
public static Matrix CreatePerspectiveOffCenter(float left, float right, float bottom, float top, float nearPlaneDistance, float farPlaneDistance)
Parameters
left
floatLower x-value at the near plane.
right
floatUpper x-value at the near plane.
bottom
floatLower y-coordinate at the near plane.
top
floatUpper y-value at the near plane.
nearPlaneDistance
floatDistance to the near plane.
farPlaneDistance
floatDistance to the far plane.
Returns
CreatePerspectiveOffCenter(float, float, float, float, float, float, out Matrix)
Creates a new projection Matrix for customized perspective view.
public static void CreatePerspectiveOffCenter(float left, float right, float bottom, float top, float nearPlaneDistance, float farPlaneDistance, out Matrix result)
Parameters
left
floatLower x-value at the near plane.
right
floatUpper x-value at the near plane.
bottom
floatLower y-coordinate at the near plane.
top
floatUpper y-value at the near plane.
nearPlaneDistance
floatDistance to the near plane.
farPlaneDistance
floatDistance to the far plane.
result
MatrixThe new Matrix for customized perspective view as an output parameter.
CreateReflection(Plane)
Creates a new reflection Matrix.
public static Matrix CreateReflection(Plane value)
Parameters
value
PlaneThe plane that used for reflection calculation.
Returns
CreateReflection(ref Plane, out Matrix)
Creates a new reflection Matrix.
public static void CreateReflection(ref Plane value, out Matrix result)
Parameters
value
PlaneThe plane that used for reflection calculation.
result
MatrixThe reflection Matrix as an output parameter.
CreateRotationX(float)
Creates a new rotation Matrix around X axis.
public static Matrix CreateRotationX(float radians)
Parameters
radians
floatAngle in radians.
Returns
CreateRotationX(float, out Matrix)
Creates a new rotation Matrix around X axis.
public static void CreateRotationX(float radians, out Matrix result)
Parameters
radians
floatAngle in radians.
result
MatrixThe rotation Matrix around X axis as an output parameter.
CreateRotationY(float)
Creates a new rotation Matrix around Y axis.
public static Matrix CreateRotationY(float radians)
Parameters
radians
floatAngle in radians.
Returns
CreateRotationY(float, out Matrix)
Creates a new rotation Matrix around Y axis.
public static void CreateRotationY(float radians, out Matrix result)
Parameters
radians
floatAngle in radians.
result
MatrixThe rotation Matrix around Y axis as an output parameter.
CreateRotationZ(float)
Creates a new rotation Matrix around Z axis.
public static Matrix CreateRotationZ(float radians)
Parameters
radians
floatAngle in radians.
Returns
CreateRotationZ(float, out Matrix)
Creates a new rotation Matrix around Z axis.
public static void CreateRotationZ(float radians, out Matrix result)
Parameters
radians
floatAngle in radians.
result
MatrixThe rotation Matrix around Z axis as an output parameter.
CreateScale(Vector3)
Creates a new scaling Matrix.
public static Matrix CreateScale(Vector3 scales)
Parameters
Returns
CreateScale(ref Vector3, out Matrix)
Creates a new scaling Matrix.
public static void CreateScale(ref Vector3 scales, out Matrix result)
Parameters
scales
Vector3Vector3 representing x,y and z scale values.
result
MatrixThe scaling Matrix as an output parameter.
CreateScale(float)
Creates a new scaling Matrix.
public static Matrix CreateScale(float scale)
Parameters
scale
floatScale value for all three axises.
Returns
CreateScale(float, out Matrix)
Creates a new scaling Matrix.
public static void CreateScale(float scale, out Matrix result)
Parameters
scale
floatScale value for all three axises.
result
MatrixThe scaling Matrix as an output parameter.
CreateScale(float, float, float)
Creates a new scaling Matrix.
public static Matrix CreateScale(float xScale, float yScale, float zScale)
Parameters
xScale
floatScale value for X axis.
yScale
floatScale value for Y axis.
zScale
floatScale value for Z axis.
Returns
CreateScale(float, float, float, out Matrix)
Creates a new scaling Matrix.
public static void CreateScale(float xScale, float yScale, float zScale, out Matrix result)
Parameters
xScale
floatScale value for X axis.
yScale
floatScale value for Y axis.
zScale
floatScale value for Z axis.
result
MatrixThe scaling Matrix as an output parameter.
CreateShadow(Vector3, Plane)
Creates a new Matrix that flattens geometry into a specified Plane as if casting a shadow from a specified light source.
public static Matrix CreateShadow(Vector3 lightDirection, Plane plane)
Parameters
lightDirection
Vector3A vector specifying the direction from which the light that will cast the shadow is coming.
plane
PlaneThe plane onto which the new matrix should flatten geometry so as to cast a shadow.
Returns
- Matrix
A Matrix that can be used to flatten geometry onto the specified plane from the specified direction.
CreateShadow(ref Vector3, ref Plane, out Matrix)
Creates a new Matrix that flattens geometry into a specified Plane as if casting a shadow from a specified light source.
public static void CreateShadow(ref Vector3 lightDirection, ref Plane plane, out Matrix result)
Parameters
lightDirection
Vector3A vector specifying the direction from which the light that will cast the shadow is coming.
plane
PlaneThe plane onto which the new matrix should flatten geometry so as to cast a shadow.
result
MatrixA Matrix that can be used to flatten geometry onto the specified plane from the specified direction as an output parameter.
CreateTranslation(Vector3)
Creates a new translation Matrix.
public static Matrix CreateTranslation(Vector3 position)
Parameters
position
Vector3X,Y and Z coordinates of translation.
Returns
CreateTranslation(ref Vector3, out Matrix)
Creates a new translation Matrix.
public static void CreateTranslation(ref Vector3 position, out Matrix result)
Parameters
position
Vector3X,Y and Z coordinates of translation.
result
MatrixThe translation Matrix as an output parameter.
CreateTranslation(float, float, float)
Creates a new translation Matrix.
public static Matrix CreateTranslation(float xPosition, float yPosition, float zPosition)
Parameters
xPosition
floatX coordinate of translation.
yPosition
floatY coordinate of translation.
zPosition
floatZ coordinate of translation.
Returns
CreateTranslation(float, float, float, out Matrix)
Creates a new translation Matrix.
public static void CreateTranslation(float xPosition, float yPosition, float zPosition, out Matrix result)
Parameters
xPosition
floatX coordinate of translation.
yPosition
floatY coordinate of translation.
zPosition
floatZ coordinate of translation.
result
MatrixThe translation Matrix as an output parameter.
CreateWorld(Vector3, Vector3, Vector3)
Creates a new world Matrix.
public static Matrix CreateWorld(Vector3 position, Vector3 forward, Vector3 up)
Parameters
position
Vector3The position vector.
forward
Vector3The forward direction vector.
up
Vector3The upward direction vector. Usually Up.
Returns
CreateWorld(ref Vector3, ref Vector3, ref Vector3, out Matrix)
Creates a new world Matrix.
public static void CreateWorld(ref Vector3 position, ref Vector3 forward, ref Vector3 up, out Matrix result)
Parameters
position
Vector3The position vector.
forward
Vector3The forward direction vector.
up
Vector3The upward direction vector. Usually Up.
result
MatrixThe world Matrix as an output parameter.
Decompose(out Vector3, out Quaternion, out Vector3)
Decomposes this matrix to translation, rotation and scale elements. Returns true
if matrix can be decomposed; false
otherwise.
public bool Decompose(out Vector3 scale, out Quaternion rotation, out Vector3 translation)
Parameters
scale
Vector3Scale vector as an output parameter.
rotation
QuaternionRotation quaternion as an output parameter.
translation
Vector3Translation vector as an output parameter.
Returns
- bool
true
if matrix can be decomposed;false
otherwise.
Determinant()
Returns a determinant of this Matrix.
public float Determinant()
Returns
Remarks
See more about determinant here - http://en.wikipedia.org/wiki/Determinant.
Divide(Matrix, Matrix)
Divides the elements of a Matrix by the elements of another matrix.
public static Matrix Divide(Matrix matrix1, Matrix matrix2)
Parameters
Returns
- Matrix
The result of dividing the matrix.
Divide(Matrix, float)
Divides the elements of a Matrix by a scalar.
public static Matrix Divide(Matrix matrix1, float divider)
Parameters
Returns
- Matrix
The result of dividing a matrix by a scalar.
Divide(ref Matrix, ref Matrix, out Matrix)
Divides the elements of a Matrix by the elements of another matrix.
public static void Divide(ref Matrix matrix1, ref Matrix matrix2, out Matrix result)
Parameters
matrix1
MatrixSource Matrix.
matrix2
MatrixDivisor Matrix.
result
MatrixThe result of dividing the matrix as an output parameter.
Divide(ref Matrix, float, out Matrix)
Divides the elements of a Matrix by a scalar.
public static void Divide(ref Matrix matrix1, float divider, out Matrix result)
Parameters
matrix1
MatrixSource Matrix.
divider
floatDivisor scalar.
result
MatrixThe result of dividing a matrix by a scalar as an output parameter.
Equals(Matrix)
Compares whether current instance is equal to specified Matrix without any tolerance.
public bool Equals(Matrix other)
Parameters
Returns
- bool
true
if the instances are equal;false
otherwise.
Equals(object)
Compares whether current instance is equal to specified object without any tolerance.
public override bool Equals(object obj)
Parameters
Returns
- bool
true
if the instances are equal;false
otherwise.
GetHashCode()
Gets the hash code of this Matrix.
public override int GetHashCode()
Returns
Invert(Matrix)
Creates a new Matrix which contains inversion of the specified matrix.
public static Matrix Invert(Matrix matrix)
Parameters
Returns
- Matrix
The inverted matrix.
Invert(ref Matrix, out Matrix)
Creates a new Matrix which contains inversion of the specified matrix.
public static void Invert(ref Matrix matrix, out Matrix result)
Parameters
Lerp(Matrix, Matrix, float)
Creates a new Matrix that contains linear interpolation of the values in specified matrixes.
public static Matrix Lerp(Matrix matrix1, Matrix matrix2, float amount)
Parameters
matrix1
MatrixThe first Matrix.
matrix2
MatrixThe second Vector2.
amount
floatWeighting value(between 0.0 and 1.0).
Returns
- Matrix
The result of linear interpolation of the specified matrixes.
Lerp(ref Matrix, ref Matrix, float, out Matrix)
Creates a new Matrix that contains linear interpolation of the values in specified matrixes.
public static void Lerp(ref Matrix matrix1, ref Matrix matrix2, float amount, out Matrix result)
Parameters
matrix1
MatrixThe first Matrix.
matrix2
MatrixThe second Vector2.
amount
floatWeighting value(between 0.0 and 1.0).
result
MatrixThe result of linear interpolation of the specified matrixes as an output parameter.
Multiply(Matrix, Matrix)
Creates a new Matrix that contains a multiplication of two matrix.
public static Matrix Multiply(Matrix matrix1, Matrix matrix2)
Parameters
Returns
- Matrix
Result of the matrix multiplication.
Multiply(Matrix, float)
public static Matrix Multiply(Matrix matrix1, float scaleFactor)
Parameters
Returns
- Matrix
Result of the matrix multiplication with a scalar.
Multiply(ref Matrix, ref Matrix, out Matrix)
Creates a new Matrix that contains a multiplication of two matrix.
public static void Multiply(ref Matrix matrix1, ref Matrix matrix2, out Matrix result)
Parameters
matrix1
MatrixSource Matrix.
matrix2
MatrixSource Matrix.
result
MatrixResult of the matrix multiplication as an output parameter.
Multiply(ref Matrix, float, out Matrix)
public static void Multiply(ref Matrix matrix1, float scaleFactor, out Matrix result)
Parameters
matrix1
MatrixSource Matrix.
scaleFactor
floatScalar value.
result
MatrixResult of the matrix multiplication with a scalar as an output parameter.
Negate(Matrix)
Returns a matrix with the all values negated.
public static Matrix Negate(Matrix matrix)
Parameters
Returns
- Matrix
Result of the matrix negation.
Negate(ref Matrix, out Matrix)
Returns a matrix with the all values negated.
public static void Negate(ref Matrix matrix, out Matrix result)
Parameters
Subtract(Matrix, Matrix)
Creates a new Matrix that contains subtraction of one matrix from another.
public static Matrix Subtract(Matrix matrix1, Matrix matrix2)
Parameters
Returns
- Matrix
The result of the matrix subtraction.
Subtract(ref Matrix, ref Matrix, out Matrix)
Creates a new Matrix that contains subtraction of one matrix from another.
public static void Subtract(ref Matrix matrix1, ref Matrix matrix2, out Matrix result)
Parameters
matrix1
MatrixThe first Matrix.
matrix2
MatrixThe second Matrix.
result
MatrixThe result of the matrix subtraction as an output parameter.
ToFloatArray(Matrix)
Copy the values of specified Matrix to the float array.
public static float[] ToFloatArray(Matrix matrix)
Parameters
Returns
- float[]
The array which matrix values will be stored.
Remarks
Required for OpenGL 2.0 projection matrix stuff.
ToNumerics()
Returns a Matrix4x4.
public Matrix4x4 ToNumerics()
Returns
ToString()
Returns a string representation of this Matrix in the format: {M11:[M11] M12:[M12] M13:[M13] M14:[M14]} {M21:[M21] M12:[M22] M13:[M23] M14:[M24]} {M31:[M31] M32:[M32] M33:[M33] M34:[M34]} {M41:[M41] M42:[M42] M43:[M43] M44:[M44]}
public override string ToString()
Returns
Transpose(Matrix)
Swap the matrix rows and columns.
public static Matrix Transpose(Matrix matrix)
Parameters
matrix
MatrixThe matrix for transposing operation.
Returns
Transpose(ref Matrix, out Matrix)
Swap the matrix rows and columns.
public static void Transpose(ref Matrix matrix, out Matrix result)
Parameters
matrix
MatrixThe matrix for transposing operation.
result
MatrixThe new Matrix which contains the transposing result as an output parameter.
Operators
operator +(Matrix, Matrix)
Adds two matrixes.
public static Matrix operator +(Matrix matrix1, Matrix matrix2)
Parameters
matrix1
MatrixSource Matrix on the left of the add sign.
matrix2
MatrixSource Matrix on the right of the add sign.
Returns
- Matrix
Sum of the matrixes.
operator /(Matrix, Matrix)
public static Matrix operator /(Matrix matrix1, Matrix matrix2)
Parameters
matrix1
MatrixSource Matrix on the left of the div sign.
matrix2
MatrixDivisor Matrix on the right of the div sign.
Returns
- Matrix
The result of dividing the matrixes.
operator /(Matrix, float)
Divides the elements of a Matrix by a scalar.
public static Matrix operator /(Matrix matrix, float divider)
Parameters
matrix
MatrixSource Matrix on the left of the div sign.
divider
floatDivisor scalar on the right of the div sign.
Returns
- Matrix
The result of dividing a matrix by a scalar.
operator ==(Matrix, Matrix)
Compares whether two Matrix instances are equal without any tolerance.
public static bool operator ==(Matrix matrix1, Matrix matrix2)
Parameters
matrix1
MatrixSource Matrix on the left of the equal sign.
matrix2
MatrixSource Matrix on the right of the equal sign.
Returns
- bool
true
if the instances are equal;false
otherwise.
implicit operator Matrix(Matrix4x4)
public static implicit operator Matrix(Matrix4x4 value)
Parameters
value
Matrix4x4The converted value.
Returns
operator !=(Matrix, Matrix)
Compares whether two Matrix instances are not equal without any tolerance.
public static bool operator !=(Matrix matrix1, Matrix matrix2)
Parameters
matrix1
MatrixSource Matrix on the left of the not equal sign.
matrix2
MatrixSource Matrix on the right of the not equal sign.
Returns
- bool
true
if the instances are not equal;false
otherwise.
operator *(Matrix, Matrix)
Multiplies two matrixes.
public static Matrix operator *(Matrix matrix1, Matrix matrix2)
Parameters
matrix1
MatrixSource Matrix on the left of the mul sign.
matrix2
MatrixSource Matrix on the right of the mul sign.
Returns
- Matrix
Result of the matrix multiplication.
Remarks
Using matrix multiplication algorithm - see http://en.wikipedia.org/wiki/Matrix_multiplication.
operator *(Matrix, float)
Multiplies the elements of matrix by a scalar.
public static Matrix operator *(Matrix matrix, float scaleFactor)
Parameters
matrix
MatrixSource Matrix on the left of the mul sign.
scaleFactor
floatScalar value on the right of the mul sign.
Returns
- Matrix
Result of the matrix multiplication with a scalar.
operator -(Matrix, Matrix)
public static Matrix operator -(Matrix matrix1, Matrix matrix2)
Parameters
matrix1
MatrixSource Matrix on the left of the sub sign.
matrix2
MatrixSource Matrix on the right of the sub sign.
Returns
- Matrix
Result of the matrix subtraction.
operator -(Matrix)
Inverts values in the specified Matrix.
public static Matrix operator -(Matrix matrix)
Parameters
Returns
- Matrix
Result of the inversion.