Struct Matrix4
Represents a 4x4 matrix containing 3D rotation, scale, transform, and projection.
Inherited Members
Namespace: OpenTK.Mathematics
Assembly: OpenTK.Mathematics.dll
Syntax
[Serializable]
public struct Matrix4 : IEquatable<Matrix4>, IFormattable
Constructors
Matrix4(Matrix3)
Initializes a new instance of the Matrix4 struct.
Declaration
public Matrix4(Matrix3 topLeft)
Parameters
Type | Name | Description |
---|---|---|
Matrix3 | topLeft | The top left 3x3 of the matrix. |
See Also
Matrix4(Vector4, Vector4, Vector4, Vector4)
Initializes a new instance of the Matrix4 struct.
Declaration
public Matrix4(Vector4 row0, Vector4 row1, Vector4 row2, Vector4 row3)
Parameters
Type | Name | Description |
---|---|---|
Vector4 | row0 | Top row of the matrix. |
Vector4 | row1 | Second row of the matrix. |
Vector4 | row2 | Third row of the matrix. |
Vector4 | row3 | Bottom row of the matrix. |
See Also
Matrix4(float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float)
Initializes a new instance of the Matrix4 struct.
Declaration
public Matrix4(float m00, float m01, float m02, float m03, float m10, float m11, float m12, float m13, float m20, float m21, float m22, float m23, float m30, float m31, float m32, float m33)
Parameters
Type | Name | Description |
---|---|---|
float | m00 | First item of the first row of the matrix. |
float | m01 | Second item of the first row of the matrix. |
float | m02 | Third item of the first row of the matrix. |
float | m03 | Fourth item of the first row of the matrix. |
float | m10 | First item of the second row of the matrix. |
float | m11 | Second item of the second row of the matrix. |
float | m12 | Third item of the second row of the matrix. |
float | m13 | Fourth item of the second row of the matrix. |
float | m20 | First item of the third row of the matrix. |
float | m21 | Second item of the third row of the matrix. |
float | m22 | Third item of the third row of the matrix. |
float | m23 | Fourth item of the third row of the matrix. |
float | m30 | First item of the fourth row of the matrix. |
float | m31 | Second item of the fourth row of the matrix. |
float | m32 | Third item of the fourth row of the matrix. |
float | m33 | Fourth item of the fourth row of the matrix. |
See Also
Fields
Identity
The identity matrix.
Declaration
public static readonly Matrix4 Identity
Field Value
Type | Description |
---|---|
Matrix4 |
See Also
Row0
Top row of the matrix.
Declaration
public Vector4 Row0
Field Value
Type | Description |
---|---|
Vector4 |
See Also
Row1
2nd row of the matrix.
Declaration
public Vector4 Row1
Field Value
Type | Description |
---|---|
Vector4 |
See Also
Row2
3rd row of the matrix.
Declaration
public Vector4 Row2
Field Value
Type | Description |
---|---|
Vector4 |
See Also
Row3
Bottom row of the matrix.
Declaration
public Vector4 Row3
Field Value
Type | Description |
---|---|
Vector4 |
See Also
Zero
The zero matrix.
Declaration
public static readonly Matrix4 Zero
Field Value
Type | Description |
---|---|
Matrix4 |
See Also
Properties
Column0
Gets or sets the first column of this matrix.
Declaration
public Vector4 Column0 { get; set; }
Property Value
Type | Description |
---|---|
Vector4 |
See Also
Column1
Gets or sets the second column of this matrix.
Declaration
public Vector4 Column1 { get; set; }
Property Value
Type | Description |
---|---|
Vector4 |
See Also
Column2
Gets or sets the third column of this matrix.
Declaration
public Vector4 Column2 { get; set; }
Property Value
Type | Description |
---|---|
Vector4 |
See Also
Column3
Gets or sets the fourth column of this matrix.
Declaration
public Vector4 Column3 { get; set; }
Property Value
Type | Description |
---|---|
Vector4 |
See Also
Determinant
Gets the determinant of this matrix.
Declaration
public float Determinant { get; }
Property Value
Type | Description |
---|---|
float |
See Also
Diagonal
Gets or sets the values along the main diagonal of the matrix.
Declaration
public Vector4 Diagonal { get; set; }
Property Value
Type | Description |
---|---|
Vector4 |
See Also
this[int, int]
Gets or sets the value at a specified row and column.
Declaration
public float this[int rowIndex, int columnIndex] { get; set; }
Parameters
Type | Name | Description |
---|---|---|
int | rowIndex | The index of the row. |
int | columnIndex | The index of the column. |
Property Value
Type | Description |
---|---|
float | The element at the given row and column index. |
See Also
M11
Gets or sets the value at row 1, column 1 of this instance.
Declaration
public float M11 { get; set; }
Property Value
Type | Description |
---|---|
float |
See Also
M12
Gets or sets the value at row 1, column 2 of this instance.
Declaration
public float M12 { get; set; }
Property Value
Type | Description |
---|---|
float |
See Also
M13
Gets or sets the value at row 1, column 3 of this instance.
Declaration
public float M13 { get; set; }
Property Value
Type | Description |
---|---|
float |
See Also
M14
Gets or sets the value at row 1, column 4 of this instance.
Declaration
public float M14 { get; set; }
Property Value
Type | Description |
---|---|
float |
See Also
M21
Gets or sets the value at row 2, column 1 of this instance.
Declaration
public float M21 { get; set; }
Property Value
Type | Description |
---|---|
float |
See Also
M22
Gets or sets the value at row 2, column 2 of this instance.
Declaration
public float M22 { get; set; }
Property Value
Type | Description |
---|---|
float |
See Also
M23
Gets or sets the value at row 2, column 3 of this instance.
Declaration
public float M23 { get; set; }
Property Value
Type | Description |
---|---|
float |
See Also
M24
Gets or sets the value at row 2, column 4 of this instance.
Declaration
public float M24 { get; set; }
Property Value
Type | Description |
---|---|
float |
See Also
M31
Gets or sets the value at row 3, column 1 of this instance.
Declaration
public float M31 { get; set; }
Property Value
Type | Description |
---|---|
float |
See Also
M32
Gets or sets the value at row 3, column 2 of this instance.
Declaration
public float M32 { get; set; }
Property Value
Type | Description |
---|---|
float |
See Also
M33
Gets or sets the value at row 3, column 3 of this instance.
Declaration
public float M33 { get; set; }
Property Value
Type | Description |
---|---|
float |
See Also
M34
Gets or sets the value at row 3, column 4 of this instance.
Declaration
public float M34 { get; set; }
Property Value
Type | Description |
---|---|
float |
See Also
M41
Gets or sets the value at row 4, column 1 of this instance.
Declaration
public float M41 { get; set; }
Property Value
Type | Description |
---|---|
float |
See Also
M42
Gets or sets the value at row 4, column 2 of this instance.
Declaration
public float M42 { get; set; }
Property Value
Type | Description |
---|---|
float |
See Also
M43
Gets or sets the value at row 4, column 3 of this instance.
Declaration
public float M43 { get; set; }
Property Value
Type | Description |
---|---|
float |
See Also
M44
Gets or sets the value at row 4, column 4 of this instance.
Declaration
public float M44 { get; set; }
Property Value
Type | Description |
---|---|
float |
See Also
Trace
Gets the trace of the matrix, the sum of the values along the diagonal.
Declaration
public float Trace { get; }
Property Value
Type | Description |
---|---|
float |
See Also
Methods
Add(Matrix4, Matrix4)
Adds two instances.
Declaration
[Pure]
public static Matrix4 Add(Matrix4 left, Matrix4 right)
Parameters
Type | Name | Description |
---|---|---|
Matrix4 | left | The left operand of the addition. |
Matrix4 | right | The right operand of the addition. |
Returns
Type | Description |
---|---|
Matrix4 | A new instance that is the result of the addition. |
See Also
Add(in Matrix4, in Matrix4, out Matrix4)
Adds two instances.
Declaration
public static void Add(in Matrix4 left, in Matrix4 right, out Matrix4 result)
Parameters
Type | Name | Description |
---|---|---|
Matrix4 | left | The left operand of the addition. |
Matrix4 | right | The right operand of the addition. |
Matrix4 | result | A new instance that is the result of the addition. |
See Also
ClearProjection()
Returns a copy of this Matrix4 without projection.
Declaration
public Matrix4 ClearProjection()
Returns
Type | Description |
---|---|
Matrix4 | The matrix without projection. |
See Also
ClearRotation()
Returns a copy of this Matrix4 without rotation.
Declaration
public Matrix4 ClearRotation()
Returns
Type | Description |
---|---|
Matrix4 | The matrix without rotation. |
See Also
ClearScale()
Returns a copy of this Matrix4 without scale.
Declaration
public Matrix4 ClearScale()
Returns
Type | Description |
---|---|
Matrix4 | The matrix without scaling. |
See Also
ClearTranslation()
Returns a copy of this Matrix4 without translation.
Declaration
public Matrix4 ClearTranslation()
Returns
Type | Description |
---|---|
Matrix4 | The matrix without translation. |
See Also
CreateFromAxisAngle(Vector3, float, out Matrix4)
Build a rotation matrix from the specified axis/angle rotation.
Declaration
public static void CreateFromAxisAngle(Vector3 axis, float angle, out Matrix4 result)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | axis | The axis to rotate about. |
float | angle | Angle in radians to rotate counter-clockwise (looking in the direction of the given axis). |
Matrix4 | result | A matrix instance. |
See Also
CreateFromAxisAngle(Vector3, float)
Build a rotation matrix from the specified axis/angle rotation.
Declaration
[Pure]
public static Matrix4 CreateFromAxisAngle(Vector3 axis, float angle)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | axis | The axis to rotate about. |
float | angle | Angle in radians to rotate counter-clockwise (looking in the direction of the given axis). |
Returns
Type | Description |
---|---|
Matrix4 | A matrix instance. |
See Also
CreateFromQuaternion(Quaternion)
Builds a rotation matrix from a quaternion.
Declaration
[Pure]
public static Matrix4 CreateFromQuaternion(Quaternion q)
Parameters
Type | Name | Description |
---|---|---|
Quaternion | q | The quaternion to rotate by. |
Returns
Type | Description |
---|---|
Matrix4 | A matrix instance. |
See Also
CreateFromQuaternion(in Quaternion, out Matrix4)
Builds a rotation matrix from a quaternion.
Declaration
public static void CreateFromQuaternion(in Quaternion q, out Matrix4 result)
Parameters
Type | Name | Description |
---|---|---|
Quaternion | q | The quaternion to rotate by. |
Matrix4 | result | A matrix instance. |
See Also
CreateOrthographic(float, float, float, float, out Matrix4)
Creates an orthographic projection matrix.
Declaration
public static void CreateOrthographic(float width, float height, float depthNear, float depthFar, out Matrix4 result)
Parameters
Type | Name | Description |
---|---|---|
float | width | The width of the projection volume. |
float | height | The height of the projection volume. |
float | depthNear | The near edge of the projection volume. |
float | depthFar | The far edge of the projection volume. |
Matrix4 | result | The resulting Matrix4 instance. |
See Also
CreateOrthographic(float, float, float, float)
Creates an orthographic projection matrix.
Declaration
[Pure]
public static Matrix4 CreateOrthographic(float width, float height, float depthNear, float depthFar)
Parameters
Type | Name | Description |
---|---|---|
float | width | The width of the projection volume. |
float | height | The height of the projection volume. |
float | depthNear | The near edge of the projection volume. |
float | depthFar | The far edge of the projection volume. |
Returns
Type | Description |
---|---|
Matrix4 | The resulting Matrix4 instance. |
See Also
CreateOrthographicOffCenter(float, float, float, float, float, float, out Matrix4)
Creates an orthographic projection matrix.
Declaration
public static void CreateOrthographicOffCenter(float left, float right, float bottom, float top, float depthNear, float depthFar, out Matrix4 result)
Parameters
Type | Name | Description |
---|---|---|
float | left | The left edge of the projection volume. |
float | right | The right edge of the projection volume. |
float | bottom | The bottom edge of the projection volume. |
float | top | The top edge of the projection volume. |
float | depthNear | The near edge of the projection volume. |
float | depthFar | The far edge of the projection volume. |
Matrix4 | result | The resulting Matrix4 instance. |
See Also
CreateOrthographicOffCenter(float, float, float, float, float, float)
Creates an orthographic projection matrix.
Declaration
[Pure]
public static Matrix4 CreateOrthographicOffCenter(float left, float right, float bottom, float top, float depthNear, float depthFar)
Parameters
Type | Name | Description |
---|---|---|
float | left | The left edge of the projection volume. |
float | right | The right edge of the projection volume. |
float | bottom | The bottom edge of the projection volume. |
float | top | The top edge of the projection volume. |
float | depthNear | The near edge of the projection volume. |
float | depthFar | The far edge of the projection volume. |
Returns
Type | Description |
---|---|
Matrix4 | The resulting Matrix4 instance. |
See Also
CreatePerspectiveFieldOfView(float, float, float, float, out Matrix4)
Creates a perspective projection matrix.
Declaration
public static void CreatePerspectiveFieldOfView(float fovy, float aspect, float depthNear, float depthFar, out Matrix4 result)
Parameters
Type | Name | Description |
---|---|---|
float | fovy | Angle of the field of view in the y direction (in radians). |
float | aspect | Aspect ratio of the view (width / height). |
float | depthNear | Distance to the near clip plane. |
float | depthFar | Distance to the far clip plane. |
Matrix4 | result | A projection matrix that transforms camera space to raster space. |
Exceptions
Type | Condition |
---|---|
ArgumentOutOfRangeException | Thrown under the following conditions:
|
See Also
CreatePerspectiveFieldOfView(float, float, float, float)
Creates a perspective projection matrix.
Declaration
[Pure]
public static Matrix4 CreatePerspectiveFieldOfView(float fovy, float aspect, float depthNear, float depthFar)
Parameters
Type | Name | Description |
---|---|---|
float | fovy | Angle of the field of view in the y direction (in radians). |
float | aspect | Aspect ratio of the view (width / height). |
float | depthNear | Distance to the near clip plane. |
float | depthFar | Distance to the far clip plane. |
Returns
Type | Description |
---|---|
Matrix4 | A projection matrix that transforms camera space to raster space. |
Exceptions
Type | Condition |
---|---|
ArgumentOutOfRangeException | Thrown under the following conditions:
|
See Also
CreatePerspectiveOffCenter(float, float, float, float, float, float, out Matrix4)
Creates an perspective projection matrix.
Declaration
public static void CreatePerspectiveOffCenter(float left, float right, float bottom, float top, float depthNear, float depthFar, out Matrix4 result)
Parameters
Type | Name | Description |
---|---|---|
float | left | Left edge of the view frustum. |
float | right | Right edge of the view frustum. |
float | bottom | Bottom edge of the view frustum. |
float | top | Top edge of the view frustum. |
float | depthNear | Distance to the near clip plane. |
float | depthFar | Distance to the far clip plane. |
Matrix4 | result | A projection matrix that transforms camera space to raster space. |
Exceptions
Type | Condition |
---|---|
ArgumentOutOfRangeException | Thrown under the following conditions:
|
See Also
CreatePerspectiveOffCenter(float, float, float, float, float, float)
Creates an perspective projection matrix.
Declaration
[Pure]
public static Matrix4 CreatePerspectiveOffCenter(float left, float right, float bottom, float top, float depthNear, float depthFar)
Parameters
Type | Name | Description |
---|---|---|
float | left | Left edge of the view frustum. |
float | right | Right edge of the view frustum. |
float | bottom | Bottom edge of the view frustum. |
float | top | Top edge of the view frustum. |
float | depthNear | Distance to the near clip plane. |
float | depthFar | Distance to the far clip plane. |
Returns
Type | Description |
---|---|
Matrix4 | A projection matrix that transforms camera space to raster space. |
Exceptions
Type | Condition |
---|---|
ArgumentOutOfRangeException | Thrown under the following conditions:
|
See Also
CreateRotationX(float, out Matrix4)
Builds a rotation matrix for a rotation around the x-axis.
Declaration
public static void CreateRotationX(float angle, out Matrix4 result)
Parameters
Type | Name | Description |
---|---|---|
float | angle | The counter-clockwise angle in radians. |
Matrix4 | result | The resulting Matrix4 instance. |
See Also
CreateRotationX(float)
Builds a rotation matrix for a rotation around the x-axis.
Declaration
[Pure]
public static Matrix4 CreateRotationX(float angle)
Parameters
Type | Name | Description |
---|---|---|
float | angle | The counter-clockwise angle in radians. |
Returns
Type | Description |
---|---|
Matrix4 | The resulting Matrix4 instance. |
See Also
CreateRotationY(float, out Matrix4)
Builds a rotation matrix for a rotation around the y-axis.
Declaration
public static void CreateRotationY(float angle, out Matrix4 result)
Parameters
Type | Name | Description |
---|---|---|
float | angle | The counter-clockwise angle in radians. |
Matrix4 | result | The resulting Matrix4 instance. |
See Also
CreateRotationY(float)
Builds a rotation matrix for a rotation around the y-axis.
Declaration
[Pure]
public static Matrix4 CreateRotationY(float angle)
Parameters
Type | Name | Description |
---|---|---|
float | angle | The counter-clockwise angle in radians. |
Returns
Type | Description |
---|---|
Matrix4 | The resulting Matrix4 instance. |
See Also
CreateRotationZ(float, out Matrix4)
Builds a rotation matrix for a rotation around the z-axis.
Declaration
public static void CreateRotationZ(float angle, out Matrix4 result)
Parameters
Type | Name | Description |
---|---|---|
float | angle | The counter-clockwise angle in radians. |
Matrix4 | result | The resulting Matrix4 instance. |
See Also
CreateRotationZ(float)
Builds a rotation matrix for a rotation around the z-axis.
Declaration
[Pure]
public static Matrix4 CreateRotationZ(float angle)
Parameters
Type | Name | Description |
---|---|---|
float | angle | The counter-clockwise angle in radians. |
Returns
Type | Description |
---|---|
Matrix4 | The resulting Matrix4 instance. |
See Also
CreateScale(Vector3)
Creates a scale matrix.
Declaration
[Pure]
public static Matrix4 CreateScale(Vector3 scale)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | scale | Scale factors for the x, y, and z axes. |
Returns
Type | Description |
---|---|
Matrix4 | A scale matrix. |
See Also
CreateScale(in Vector3, out Matrix4)
Creates a scale matrix.
Declaration
public static void CreateScale(in Vector3 scale, out Matrix4 result)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | scale | Scale factors for the x, y, and z axes. |
Matrix4 | result | A scale matrix. |
See Also
CreateScale(float, out Matrix4)
Creates a scale matrix.
Declaration
public static void CreateScale(float scale, out Matrix4 result)
Parameters
Type | Name | Description |
---|---|---|
float | scale | Single scale factor for the x, y, and z axes. |
Matrix4 | result | A scale matrix. |
See Also
CreateScale(float, float, float, out Matrix4)
Creates a scale matrix.
Declaration
public static void CreateScale(float x, float y, float z, out Matrix4 result)
Parameters
Type | Name | Description |
---|---|---|
float | x | Scale factor for the x axis. |
float | y | Scale factor for the y axis. |
float | z | Scale factor for the z axis. |
Matrix4 | result | A scale matrix. |
See Also
CreateScale(float, float, float)
Creates a scale matrix.
Declaration
[Pure]
public static Matrix4 CreateScale(float x, float y, float z)
Parameters
Type | Name | Description |
---|---|---|
float | x | Scale factor for the x axis. |
float | y | Scale factor for the y axis. |
float | z | Scale factor for the z axis. |
Returns
Type | Description |
---|---|
Matrix4 | A scale matrix. |
See Also
CreateScale(float)
Creates a scale matrix.
Declaration
[Pure]
public static Matrix4 CreateScale(float scale)
Parameters
Type | Name | Description |
---|---|---|
float | scale | Single scale factor for the x, y, and z axes. |
Returns
Type | Description |
---|---|
Matrix4 | A scale matrix. |
See Also
CreateTranslation(Vector3)
Creates a translation matrix.
Declaration
[Pure]
public static Matrix4 CreateTranslation(Vector3 vector)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | vector | The translation vector. |
Returns
Type | Description |
---|---|
Matrix4 | The resulting Matrix4 instance. |
See Also
CreateTranslation(in Vector3, out Matrix4)
Creates a translation matrix.
Declaration
public static void CreateTranslation(in Vector3 vector, out Matrix4 result)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | vector | The translation vector. |
Matrix4 | result | The resulting Matrix4 instance. |
See Also
CreateTranslation(float, float, float, out Matrix4)
Creates a translation matrix.
Declaration
public static void CreateTranslation(float x, float y, float z, out Matrix4 result)
Parameters
Type | Name | Description |
---|---|---|
float | x | X translation. |
float | y | Y translation. |
float | z | Z translation. |
Matrix4 | result | The resulting Matrix4 instance. |
See Also
CreateTranslation(float, float, float)
Creates a translation matrix.
Declaration
[Pure]
public static Matrix4 CreateTranslation(float x, float y, float z)
Parameters
Type | Name | Description |
---|---|---|
float | x | X translation. |
float | y | Y translation. |
float | z | Z translation. |
Returns
Type | Description |
---|---|
Matrix4 | The resulting Matrix4 instance. |
See Also
Equals(Matrix4)
Indicates whether the current matrix is equal to another matrix.
Declaration
[Pure]
public bool Equals(Matrix4 other)
Parameters
Type | Name | Description |
---|---|---|
Matrix4 | other | An matrix to compare with this matrix. |
Returns
Type | Description |
---|---|
bool | true if the current matrix is equal to the matrix parameter; otherwise, false. |
See Also
Equals(object)
Indicates whether this instance and a specified object are equal.
Declaration
[Pure]
public override bool Equals(object obj)
Parameters
Type | Name | Description |
---|---|---|
object | obj | The object to compare tresult. |
Returns
Type | Description |
---|---|
bool | True if the instances are equal; false otherwise. |
Overrides
See Also
ExtractProjection()
Returns the projection component of this instance.
Declaration
public Vector4 ExtractProjection()
Returns
Type | Description |
---|---|
Vector4 | The projection. |
See Also
ExtractRotation(bool)
Returns the rotation component of this instance. Quite slow.
Declaration
[Pure]
public Quaternion ExtractRotation(bool rowNormalize = true)
Parameters
Type | Name | Description |
---|---|---|
bool | rowNormalize | Whether the method should row-normalize (i.e. remove scale from) the Matrix. Pass false if you know it's already normalized. |
Returns
Type | Description |
---|---|
Quaternion | The rotation. |
See Also
ExtractScale()
Returns the scale component of this instance.
Declaration
public Vector3 ExtractScale()
Returns
Type | Description |
---|---|
Vector3 | The scale. |
See Also
ExtractTranslation()
Returns the translation component of this instance.
Declaration
public Vector3 ExtractTranslation()
Returns
Type | Description |
---|---|
Vector3 | The translation. |
See Also
GetHashCode()
Returns the hashcode for this instance.
Declaration
public override int GetHashCode()
Returns
Type | Description |
---|---|
int | A System.Int32 containing the unique hashcode for this instance. |
Overrides
See Also
Invert()
Converts this instance into its inverse.
Declaration
public void Invert()
See Also
Invert(Matrix4)
Calculate the inverse of the given matrix.
Declaration
[Pure]
public static Matrix4 Invert(Matrix4 mat)
Parameters
Type | Name | Description |
---|---|---|
Matrix4 | mat | The matrix to invert. |
Returns
Type | Description |
---|---|
Matrix4 | The inverse of the given matrix. |
Exceptions
Type | Condition |
---|---|
InvalidOperationException | Thrown if the Matrix4 is singular. |
See Also
Invert(in Matrix4, out Matrix4)
Calculate the inverse of the given matrix.
Declaration
public static void Invert(in Matrix4 mat, out Matrix4 result)
Parameters
Type | Name | Description |
---|---|---|
Matrix4 | mat | The matrix to invert. |
Matrix4 | result | The inverse of the given matrix if it has one, or the input if it is singular. |
Exceptions
Type | Condition |
---|---|
InvalidOperationException | Thrown if the Matrix4 is singular. |
See Also
Inverted()
Returns an inverted copy of this instance.
Declaration
public Matrix4 Inverted()
Returns
Type | Description |
---|---|
Matrix4 | The inverted copy. |
See Also
LookAt(Vector3, Vector3, Vector3)
Build a world space to camera space matrix.
Declaration
[Pure]
public static Matrix4 LookAt(Vector3 eye, Vector3 target, Vector3 up)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | eye | Eye (camera) position in world space. |
Vector3 | target | Target position in world space. |
Vector3 | up | Up vector in world space (should not be parallel to the camera direction, that is target - eye). |
Returns
Type | Description |
---|---|
Matrix4 | A Matrix4 that transforms world space to camera space. |
See Also
LookAt(float, float, float, float, float, float, float, float, float)
Build a world space to camera space matrix.
Declaration
[Pure]
public static Matrix4 LookAt(float eyeX, float eyeY, float eyeZ, float targetX, float targetY, float targetZ, float upX, float upY, float upZ)
Parameters
Type | Name | Description |
---|---|---|
float | eyeX | Eye (camera) X-position in world space. |
float | eyeY | Eye (camera) Y-position in world space. |
float | eyeZ | Eye (camera) Z-position in world space. |
float | targetX | Target X-position in world space. |
float | targetY | Target Y-position in world space. |
float | targetZ | Target Z-position in world space. |
float | upX | X of the up vector in world space (should not be parallel to the camera direction, that is target - eye). |
float | upY | Y of the up vector in world space (should not be parallel to the camera direction, that is target - eye). |
float | upZ | Z of the up vector in world space (should not be parallel to the camera direction, that is target - eye). |
Returns
Type | Description |
---|---|
Matrix4 | A Matrix4 that transforms world space to camera space. |
See Also
Mult(Matrix4, Matrix4)
Multiplies two instances.
Declaration
[Pure]
public static Matrix4 Mult(Matrix4 left, Matrix4 right)
Parameters
Type | Name | Description |
---|---|---|
Matrix4 | left | The left operand of the multiplication. |
Matrix4 | right | The right operand of the multiplication. |
Returns
Type | Description |
---|---|
Matrix4 | A new instance that is the result of the multiplication. |
See Also
Mult(Matrix4, float)
Multiplies an instance by a scalar.
Declaration
[Pure]
public static Matrix4 Mult(Matrix4 left, float right)
Parameters
Type | Name | Description |
---|---|---|
Matrix4 | left | The left operand of the multiplication. |
float | right | The right operand of the multiplication. |
Returns
Type | Description |
---|---|
Matrix4 | A new instance that is the result of the multiplication. |
See Also
Mult(in Matrix4, in Matrix4, out Matrix4)
Multiplies two instances.
Declaration
public static void Mult(in Matrix4 left, in Matrix4 right, out Matrix4 result)
Parameters
Type | Name | Description |
---|---|---|
Matrix4 | left | The left operand of the multiplication. |
Matrix4 | right | The right operand of the multiplication. |
Matrix4 | result | A new instance that is the result of the multiplication. |
See Also
Mult(in Matrix4, float, out Matrix4)
Multiplies an instance by a scalar.
Declaration
public static void Mult(in Matrix4 left, float right, out Matrix4 result)
Parameters
Type | Name | Description |
---|---|---|
Matrix4 | left | The left operand of the multiplication. |
float | right | The right operand of the multiplication. |
Matrix4 | result | A new instance that is the result of the multiplication. |
See Also
Normalize()
Divides each element in the Matrix by the Determinant.
Declaration
public void Normalize()
See Also
Normalized()
Returns a normalized copy of this instance.
Declaration
public Matrix4 Normalized()
Returns
Type | Description |
---|---|
Matrix4 | The normalized copy. |
See Also
Subtract(Matrix4, Matrix4)
Subtracts one instance from another.
Declaration
[Pure]
public static Matrix4 Subtract(Matrix4 left, Matrix4 right)
Parameters
Type | Name | Description |
---|---|---|
Matrix4 | left | The left operand of the subraction. |
Matrix4 | right | The right operand of the subraction. |
Returns
Type | Description |
---|---|
Matrix4 | A new instance that is the result of the subraction. |
See Also
Subtract(in Matrix4, in Matrix4, out Matrix4)
Subtracts one instance from another.
Declaration
public static void Subtract(in Matrix4 left, in Matrix4 right, out Matrix4 result)
Parameters
Type | Name | Description |
---|---|---|
Matrix4 | left | The left operand of the subraction. |
Matrix4 | right | The right operand of the subraction. |
Matrix4 | result | A new instance that is the result of the subraction. |
See Also
ToString()
Returns a System.String that represents the current Matrix4.
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
string | The string representation of the matrix. |
Overrides
See Also
ToString(IFormatProvider)
Declaration
public string ToString(IFormatProvider formatProvider)
Parameters
Type | Name | Description |
---|---|---|
IFormatProvider | formatProvider |
Returns
Type | Description |
---|---|
string |
See Also
ToString(string, IFormatProvider)
Declaration
public string ToString(string format, IFormatProvider formatProvider)
Parameters
Type | Name | Description |
---|---|---|
string | format | |
IFormatProvider | formatProvider |
Returns
Type | Description |
---|---|
string |
See Also
ToString(string)
Declaration
public string ToString(string format)
Parameters
Type | Name | Description |
---|---|---|
string | format |
Returns
Type | Description |
---|---|
string |
See Also
Transpose()
Converts this instance into its transpose.
Declaration
public void Transpose()
See Also
Transpose(Matrix4)
Calculate the transpose of the given matrix.
Declaration
[Pure]
public static Matrix4 Transpose(Matrix4 mat)
Parameters
Type | Name | Description |
---|---|---|
Matrix4 | mat | The matrix to transpose. |
Returns
Type | Description |
---|---|
Matrix4 | The transpose of the given matrix. |
See Also
Transpose(in Matrix4, out Matrix4)
Calculate the transpose of the given matrix.
Declaration
public static void Transpose(in Matrix4 mat, out Matrix4 result)
Parameters
Type | Name | Description |
---|---|---|
Matrix4 | mat | The matrix to transpose. |
Matrix4 | result | The result of the calculation. |
See Also
Operators
operator +(Matrix4, Matrix4)
Matrix addition.
Declaration
[Pure]
public static Matrix4 operator +(Matrix4 left, Matrix4 right)
Parameters
Type | Name | Description |
---|---|---|
Matrix4 | left | left-hand operand. |
Matrix4 | right | right-hand operand. |
Returns
Type | Description |
---|---|
Matrix4 | A new Matrix4 which holds the result of the addition. |
See Also
operator ==(Matrix4, Matrix4)
Compares two instances for equality.
Declaration
[Pure]
public static bool operator ==(Matrix4 left, Matrix4 right)
Parameters
Type | Name | Description |
---|---|---|
Matrix4 | left | The first instance. |
Matrix4 | right | The second instance. |
Returns
Type | Description |
---|---|
bool | True, if left equals right; false otherwise. |
See Also
operator !=(Matrix4, Matrix4)
Compares two instances for inequality.
Declaration
[Pure]
public static bool operator !=(Matrix4 left, Matrix4 right)
Parameters
Type | Name | Description |
---|---|---|
Matrix4 | left | The first instance. |
Matrix4 | right | The second instance. |
Returns
Type | Description |
---|---|
bool | True, if left does not equal right; false otherwise. |
See Also
operator *(Matrix4, Matrix4)
Matrix multiplication.
Declaration
[Pure]
public static Matrix4 operator *(Matrix4 left, Matrix4 right)
Parameters
Type | Name | Description |
---|---|---|
Matrix4 | left | left-hand operand. |
Matrix4 | right | right-hand operand. |
Returns
Type | Description |
---|---|
Matrix4 | A new Matrix4 which holds the result of the multiplication. |
See Also
operator *(Matrix4, float)
Matrix-scalar multiplication.
Declaration
[Pure]
public static Matrix4 operator *(Matrix4 left, float right)
Parameters
Type | Name | Description |
---|---|---|
Matrix4 | left | left-hand operand. |
float | right | right-hand operand. |
Returns
Type | Description |
---|---|
Matrix4 | A new Matrix4 which holds the result of the multiplication. |
See Also
operator -(Matrix4, Matrix4)
Matrix subtraction.
Declaration
[Pure]
public static Matrix4 operator -(Matrix4 left, Matrix4 right)
Parameters
Type | Name | Description |
---|---|---|
Matrix4 | left | left-hand operand. |
Matrix4 | right | right-hand operand. |
Returns
Type | Description |
---|---|
Matrix4 | A new Matrix4 which holds the result of the subtraction. |