Struct Matrix3d
Represents a 3x3 matrix containing 3D rotation and scale with double-precision components.
Implements
Inherited Members
Namespace: OpenTK
Assembly: cs.temp.dll.dll
Syntax
[Serializable]
public struct Matrix3d : IEquatable<Matrix3d>
Constructors
Matrix3d(Matrix4d)
Constructs a new instance.
Declaration
public Matrix3d(Matrix4d matrix)
Parameters
Type | Name | Description |
---|---|---|
Matrix4d | matrix | A Matrix4d to take the upper-left 3x3 from. |
Matrix3d(Vector3d, Vector3d, Vector3d)
Constructs a new instance.
Declaration
public Matrix3d(Vector3d row0, Vector3d row1, Vector3d row2)
Parameters
Type | Name | Description |
---|---|---|
Vector3d | row0 | Top row of the matrix |
Vector3d | row1 | Second row of the matrix |
Vector3d | row2 | Bottom row of the matrix |
Matrix3d(Double, Double, Double, Double, Double, Double, Double, Double, Double)
Constructs a new instance.
Declaration
public Matrix3d(double m00, double m01, double m02, double m10, double m11, double m12, double m20, double m21, double m22)
Parameters
Type | Name | Description |
---|---|---|
System.Double | m00 | First item of the first row of the matrix. |
System.Double | m01 | Second item of the first row of the matrix. |
System.Double | m02 | Third item of the first row of the matrix. |
System.Double | m10 | First item of the second row of the matrix. |
System.Double | m11 | Second item of the second row of the matrix. |
System.Double | m12 | Third item of the second row of the matrix. |
System.Double | m20 | First item of the third row of the matrix. |
System.Double | m21 | Second item of the third row of the matrix. |
System.Double | m22 | Third item of the third row of the matrix. |
Fields
Identity
The identity matrix.
Declaration
public static Matrix3d Identity
Field Value
Type | Description |
---|---|
Matrix3d |
Row0
First row of the matrix.
Declaration
public Vector3d Row0
Field Value
Type | Description |
---|---|
Vector3d |
Row1
Second row of the matrix.
Declaration
public Vector3d Row1
Field Value
Type | Description |
---|---|
Vector3d |
Row2
Third row of the matrix.
Declaration
public Vector3d Row2
Field Value
Type | Description |
---|---|
Vector3d |
Properties
Column0
Gets the first column of this matrix.
Declaration
public Vector3d Column0 { get; }
Property Value
Type | Description |
---|---|
Vector3d |
Column1
Gets the second column of this matrix.
Declaration
public Vector3d Column1 { get; }
Property Value
Type | Description |
---|---|
Vector3d |
Column2
Gets the third column of this matrix.
Declaration
public Vector3d Column2 { get; }
Property Value
Type | Description |
---|---|
Vector3d |
Determinant
Gets the determinant of this matrix.
Declaration
public double Determinant { get; }
Property Value
Type | Description |
---|---|
System.Double |
Diagonal
Gets or sets the values along the main diagonal of the matrix.
Declaration
public Vector3d Diagonal { get; set; }
Property Value
Type | Description |
---|---|
Vector3d |
Item[Int32, Int32]
Gets or sets the value at a specified row and column.
Declaration
public double this[int rowIndex, int columnIndex] { get; set; }
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | rowIndex | |
System.Int32 | columnIndex |
Property Value
Type | Description |
---|---|
System.Double |
M11
Gets or sets the value at row 1, column 1 of this instance.
Declaration
public double M11 { get; set; }
Property Value
Type | Description |
---|---|
System.Double |
M12
Gets or sets the value at row 1, column 2 of this instance.
Declaration
public double M12 { get; set; }
Property Value
Type | Description |
---|---|
System.Double |
M13
Gets or sets the value at row 1, column 3 of this instance.
Declaration
public double M13 { get; set; }
Property Value
Type | Description |
---|---|
System.Double |
M21
Gets or sets the value at row 2, column 1 of this instance.
Declaration
public double M21 { get; set; }
Property Value
Type | Description |
---|---|
System.Double |
M22
Gets or sets the value at row 2, column 2 of this instance.
Declaration
public double M22 { get; set; }
Property Value
Type | Description |
---|---|
System.Double |
M23
Gets or sets the value at row 2, column 3 of this instance.
Declaration
public double M23 { get; set; }
Property Value
Type | Description |
---|---|
System.Double |
M31
Gets or sets the value at row 3, column 1 of this instance.
Declaration
public double M31 { get; set; }
Property Value
Type | Description |
---|---|
System.Double |
M32
Gets or sets the value at row 3, column 2 of this instance.
Declaration
public double M32 { get; set; }
Property Value
Type | Description |
---|---|
System.Double |
M33
Gets or sets the value at row 3, column 3 of this instance.
Declaration
public double M33 { get; set; }
Property Value
Type | Description |
---|---|
System.Double |
Trace
Gets the trace of the matrix, the sum of the values along the diagonal.
Declaration
public double Trace { get; }
Property Value
Type | Description |
---|---|
System.Double |
Methods
Add(Matrix3d, Matrix3d)
Adds two instances.
Declaration
public static Matrix3d Add(Matrix3d left, Matrix3d right)
Parameters
Type | Name | Description |
---|---|---|
Matrix3d | left | The left operand of the addition. |
Matrix3d | right | The right operand of the addition. |
Returns
Type | Description |
---|---|
Matrix3d | A new instance that is the result of the addition. |
Add(ref Matrix3d, ref Matrix3d, out Matrix3d)
Adds two instances.
Declaration
public static void Add(ref Matrix3d left, ref Matrix3d right, out Matrix3d result)
Parameters
Type | Name | Description |
---|---|---|
Matrix3d | left | The left operand of the addition. |
Matrix3d | right | The right operand of the addition. |
Matrix3d | result | A new instance that is the result of the addition. |
ClearRotation()
Returns a copy of this Matrix3 without rotation.
Declaration
public Matrix3d ClearRotation()
Returns
Type | Description |
---|---|
Matrix3d |
ClearScale()
Returns a copy of this Matrix3 without scale.
Declaration
public Matrix3d ClearScale()
Returns
Type | Description |
---|---|
Matrix3d |
CreateFromAxisAngle(Vector3d, Double)
Build a rotation matrix from the specified axis/angle rotation.
Declaration
public static Matrix3d CreateFromAxisAngle(Vector3d axis, double angle)
Parameters
Type | Name | Description |
---|---|---|
Vector3d | axis | The axis to rotate about. |
System.Double | angle | Angle in radians to rotate counter-clockwise (looking in the direction of the given axis). |
Returns
Type | Description |
---|---|
Matrix3d | A matrix instance. |
CreateFromAxisAngle(Vector3d, Double, out Matrix3d)
Build a rotation matrix from the specified axis/angle rotation.
Declaration
public static void CreateFromAxisAngle(Vector3d axis, double angle, out Matrix3d result)
Parameters
Type | Name | Description |
---|---|---|
Vector3d | axis | The axis to rotate about. |
System.Double | angle | Angle in radians to rotate counter-clockwise (looking in the direction of the given axis). |
Matrix3d | result | A matrix instance. |
CreateFromQuaternion(Quaterniond)
Build a rotation matrix from the specified quaternion.
Declaration
public static Matrix3d CreateFromQuaternion(Quaterniond q)
Parameters
Type | Name | Description |
---|---|---|
Quaterniond | q | Quaternion to translate. |
Returns
Type | Description |
---|---|
Matrix3d | A matrix instance. |
CreateFromQuaternion(ref Quaterniond, out Matrix3d)
Build a rotation matrix from the specified quaternion.
Declaration
public static void CreateFromQuaternion(ref Quaterniond q, out Matrix3d result)
Parameters
Type | Name | Description |
---|---|---|
Quaterniond | q | Quaternion to translate. |
Matrix3d | result | Matrix result. |
CreateRotationX(Double)
Builds a rotation matrix for a rotation around the x-axis.
Declaration
public static Matrix3d CreateRotationX(double angle)
Parameters
Type | Name | Description |
---|---|---|
System.Double | angle | The counter-clockwise angle in radians. |
Returns
Type | Description |
---|---|
Matrix3d | The resulting Matrix3d instance. |
CreateRotationX(Double, out Matrix3d)
Builds a rotation matrix for a rotation around the x-axis.
Declaration
public static void CreateRotationX(double angle, out Matrix3d result)
Parameters
Type | Name | Description |
---|---|---|
System.Double | angle | The counter-clockwise angle in radians. |
Matrix3d | result | The resulting Matrix3d instance. |
CreateRotationY(Double)
Builds a rotation matrix for a rotation around the y-axis.
Declaration
public static Matrix3d CreateRotationY(double angle)
Parameters
Type | Name | Description |
---|---|---|
System.Double | angle | The counter-clockwise angle in radians. |
Returns
Type | Description |
---|---|
Matrix3d | The resulting Matrix3d instance. |
CreateRotationY(Double, out Matrix3d)
Builds a rotation matrix for a rotation around the y-axis.
Declaration
public static void CreateRotationY(double angle, out Matrix3d result)
Parameters
Type | Name | Description |
---|---|---|
System.Double | angle | The counter-clockwise angle in radians. |
Matrix3d | result | The resulting Matrix3d instance. |
CreateRotationZ(Double)
Builds a rotation matrix for a rotation around the z-axis.
Declaration
public static Matrix3d CreateRotationZ(double angle)
Parameters
Type | Name | Description |
---|---|---|
System.Double | angle | The counter-clockwise angle in radians. |
Returns
Type | Description |
---|---|
Matrix3d | The resulting Matrix3d instance. |
CreateRotationZ(Double, out Matrix3d)
Builds a rotation matrix for a rotation around the z-axis.
Declaration
public static void CreateRotationZ(double angle, out Matrix3d result)
Parameters
Type | Name | Description |
---|---|---|
System.Double | angle | The counter-clockwise angle in radians. |
Matrix3d | result | The resulting Matrix3d instance. |
CreateScale(Vector3d)
Creates a scale matrix.
Declaration
public static Matrix3d CreateScale(Vector3d scale)
Parameters
Type | Name | Description |
---|---|---|
Vector3d | scale | Scale factors for the x, y, and z axes. |
Returns
Type | Description |
---|---|
Matrix3d | A scale matrix. |
CreateScale(ref Vector3d, out Matrix3d)
Creates a scale matrix.
Declaration
public static void CreateScale(ref Vector3d scale, out Matrix3d result)
Parameters
Type | Name | Description |
---|---|---|
Vector3d | scale | Scale factors for the x, y, and z axes. |
Matrix3d | result | A scale matrix. |
CreateScale(Double)
Creates a scale matrix.
Declaration
public static Matrix3d CreateScale(double scale)
Parameters
Type | Name | Description |
---|---|---|
System.Double | scale | Single scale factor for the x, y, and z axes. |
Returns
Type | Description |
---|---|
Matrix3d | A scale matrix. |
CreateScale(Double, out Matrix3d)
Creates a scale matrix.
Declaration
public static void CreateScale(double scale, out Matrix3d result)
Parameters
Type | Name | Description |
---|---|---|
System.Double | scale | Single scale factor for the x, y, and z axes. |
Matrix3d | result | A scale matrix. |
CreateScale(Double, Double, Double)
Creates a scale matrix.
Declaration
public static Matrix3d CreateScale(double x, double y, double z)
Parameters
Type | Name | Description |
---|---|---|
System.Double | x | Scale factor for the x axis. |
System.Double | y | Scale factor for the y axis. |
System.Double | z | Scale factor for the z axis. |
Returns
Type | Description |
---|---|
Matrix3d | A scale matrix. |
CreateScale(Double, Double, Double, out Matrix3d)
Creates a scale matrix.
Declaration
public static void CreateScale(double x, double y, double z, out Matrix3d result)
Parameters
Type | Name | Description |
---|---|---|
System.Double | x | Scale factor for the x axis. |
System.Double | y | Scale factor for the y axis. |
System.Double | z | Scale factor for the z axis. |
Matrix3d | result | A scale matrix. |
Equals(Matrix3d)
Indicates whether the current matrix is equal to another matrix.
Declaration
public bool Equals(Matrix3d other)
Parameters
Type | Name | Description |
---|---|---|
Matrix3d | other | A matrix to compare with this matrix. |
Returns
Type | Description |
---|---|
System.Boolean | true if the current matrix is equal to the matrix parameter; otherwise, false. |
Equals(Object)
Indicates whether this instance and a specified object are equal.
Declaration
public override bool Equals(object obj)
Parameters
Type | Name | Description |
---|---|---|
System.Object | obj | The object to compare to. |
Returns
Type | Description |
---|---|
System.Boolean | True if the instances are equal; false otherwise. |
Overrides
ExtractRotation(Boolean)
Returns the rotation component of this instance. Quite slow.
Declaration
public Quaterniond ExtractRotation(bool row_normalise = true)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | row_normalise | Whether the method should row-normalise (i.e. remove scale from) the Matrix. Pass false if you know it's already normalised. |
Returns
Type | Description |
---|---|
Quaterniond |
ExtractScale()
Returns the scale component of this instance.
Declaration
public Vector3d ExtractScale()
Returns
Type | Description |
---|---|
Vector3d |
GetHashCode()
Returns the hashcode for this instance.
Declaration
public override int GetHashCode()
Returns
Type | Description |
---|---|
System.Int32 | A System.Int32 containing the unique hashcode for this instance. |
Overrides
Invert()
Converts this instance into its inverse.
Declaration
public void Invert()
Invert(Matrix3d)
Calculate the inverse of the given matrix
Declaration
public static Matrix3d Invert(Matrix3d mat)
Parameters
Type | Name | Description |
---|---|---|
Matrix3d | mat | The matrix to invert |
Returns
Type | Description |
---|---|
Matrix3d | The inverse of the given matrix if it has one, or the input if it is singular |
Exceptions
Type | Condition |
---|---|
System.InvalidOperationException | Thrown if the Matrix4 is singular. |
Invert(ref Matrix3d, out Matrix3d)
Calculate the inverse of the given matrix
Declaration
public static void Invert(ref Matrix3d mat, out Matrix3d result)
Parameters
Type | Name | Description |
---|---|---|
Matrix3d | mat | The matrix to invert |
Matrix3d | result | The inverse of the given matrix if it has one, or the input if it is singular |
Exceptions
Type | Condition |
---|---|
System.InvalidOperationException | Thrown if the Matrix3d is singular. |
Inverted()
Returns an inverted copy of this instance.
Declaration
public Matrix3d Inverted()
Returns
Type | Description |
---|---|
Matrix3d |
Mult(Matrix3d, Matrix3d)
Multiplies two instances.
Declaration
public static Matrix3d Mult(Matrix3d left, Matrix3d right)
Parameters
Type | Name | Description |
---|---|---|
Matrix3d | left | The left operand of the multiplication. |
Matrix3d | right | The right operand of the multiplication. |
Returns
Type | Description |
---|---|
Matrix3d | A new instance that is the result of the multiplication |
Mult(ref Matrix3d, ref Matrix3d, out Matrix3d)
Multiplies two instances.
Declaration
public static void Mult(ref Matrix3d left, ref Matrix3d right, out Matrix3d result)
Parameters
Type | Name | Description |
---|---|---|
Matrix3d | left | The left operand of the multiplication. |
Matrix3d | right | The right operand of the multiplication. |
Matrix3d | result | A new instance that is the result of the multiplication |
Normalize()
Divides each element in the Matrix by the Determinant.
Declaration
public void Normalize()
Normalized()
Returns a normalised copy of this instance.
Declaration
public Matrix3d Normalized()
Returns
Type | Description |
---|---|
Matrix3d |
ToString()
Returns a System.String that represents the current Matrix3d.
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
System.String | The string representation of the matrix. |
Overrides
Transpose()
Converts this instance into its transpose.
Declaration
public void Transpose()
Transpose(Matrix3d)
Calculate the transpose of the given matrix
Declaration
public static Matrix3d Transpose(Matrix3d mat)
Parameters
Type | Name | Description |
---|---|---|
Matrix3d | mat | The matrix to transpose |
Returns
Type | Description |
---|---|
Matrix3d | The transpose of the given matrix |
Transpose(ref Matrix3d, out Matrix3d)
Calculate the transpose of the given matrix
Declaration
public static void Transpose(ref Matrix3d mat, out Matrix3d result)
Parameters
Type | Name | Description |
---|---|---|
Matrix3d | mat | The matrix to transpose |
Matrix3d | result | The result of the calculation |
Operators
Equality(Matrix3d, Matrix3d)
Compares two instances for equality.
Declaration
public static bool operator ==(Matrix3d left, Matrix3d right)
Parameters
Type | Name | Description |
---|---|---|
Matrix3d | left | The first instance. |
Matrix3d | right | The second instance. |
Returns
Type | Description |
---|---|
System.Boolean | True, if left equals right; false otherwise. |
Inequality(Matrix3d, Matrix3d)
Compares two instances for inequality.
Declaration
public static bool operator !=(Matrix3d left, Matrix3d right)
Parameters
Type | Name | Description |
---|---|---|
Matrix3d | left | The first instance. |
Matrix3d | right | The second instance. |
Returns
Type | Description |
---|---|
System.Boolean | True, if left does not equal right; false otherwise. |
Multiply(Matrix3d, Matrix3d)
Matrix multiplication
Declaration
public static Matrix3d operator *(Matrix3d left, Matrix3d right)
Parameters
Type | Name | Description |
---|---|---|
Matrix3d | left | left-hand operand |
Matrix3d | right | right-hand operand |
Returns
Type | Description |
---|---|
Matrix3d | A new Matrix3d which holds the result of the multiplication |