Struct Matrix2
Represents a 2x2 double precision matrix.
Implements
Inherited Members
Namespace: netDxf
Assembly: CADability.dll
Syntax
public struct Matrix2 : IEquatable<Matrix2>
Constructors
| Improve this Doc View SourceMatrix2(Double, Double, Double, Double)
Initializes a new instance of Matrix2.
Declaration
public Matrix2(double m11, double m12, double m21, double m22)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Double | m11 | Element [0,0]. |
| System.Double | m12 | Element [0,1]. |
| System.Double | m21 | Element [1,0]. |
| System.Double | m22 | Element [1,1]. |
Properties
| Improve this Doc View SourceIdentity
Gets the identity matrix.
Declaration
public static Matrix2 Identity { get; }
Property Value
| Type | Description |
|---|---|
| Matrix2 |
IsIdentity
Gets if the actual matrix is the identity.
Declaration
public bool IsIdentity { get; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
Remarks
The checks to see if the matrix is the identity uses the MathHelper.Epsilon as a the threshold for testing values close to one and zero.
Item[Int32, Int32]
Gets or sets the component at the given row and column index in the matrix.
Declaration
public double this[int row, int column] { get; set; }
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int32 | row | The row index of the matrix. |
| System.Int32 | column | The column index of the matrix. |
Property Value
| Type | Description |
|---|---|
| System.Double | The component at the given row and column index in the matrix. |
M11
Gets or sets the matrix element [0,0].
Declaration
public double M11 { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Double |
M12
Gets or sets the matrix element [0,1].
Declaration
public double M12 { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Double |
M21
Gets or sets the matrix element [1,0].
Declaration
public double M21 { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Double |
M22
Gets or sets the matrix element [1,1].
Declaration
public double M22 { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Double |
Zero
Gets the zero matrix.
Declaration
public static Matrix2 Zero { get; }
Property Value
| Type | Description |
|---|---|
| Matrix2 |
Methods
| Improve this Doc View SourceAdd(Matrix2, Matrix2)
Matrix addition.
Declaration
public static Matrix2 Add(Matrix2 a, Matrix2 b)
Parameters
| Type | Name | Description |
|---|---|---|
| Matrix2 | a | Matrix2. |
| Matrix2 | b | Matrix2. |
Returns
| Type | Description |
|---|---|
| Matrix2 | Matrix2. |
Determinant()
Calculate the determinant of the actual matrix.
Declaration
public double Determinant()
Returns
| Type | Description |
|---|---|
| System.Double | Determinant. |
Equals(Matrix2)
Check if the components of two matrices are approximate equal.
Declaration
public bool Equals(Matrix2 other)
Parameters
| Type | Name | Description |
|---|---|---|
| Matrix2 | other | Matrix2. |
Returns
| Type | Description |
|---|---|
| System.Boolean | True if the matrix components are almost equal or false in any other case. |
Equals(Matrix2, Matrix2)
Check if the components of two matrices are approximate equal.
Declaration
public static bool Equals(Matrix2 a, Matrix2 b)
Parameters
| Type | Name | Description |
|---|---|---|
| Matrix2 | a | Matrix2. |
| Matrix2 | b | Matrix2. |
Returns
| Type | Description |
|---|---|
| System.Boolean | True if the matrix components are almost equal or false in any other case. |
Equals(Matrix2, Matrix2, Double)
Check if the components of two matrices are approximate equal.
Declaration
public static bool Equals(Matrix2 a, Matrix2 b, double threshold)
Parameters
| Type | Name | Description |
|---|---|---|
| Matrix2 | a | Matrix2. |
| Matrix2 | b | Matrix2. |
| System.Double | threshold | Maximum tolerance. |
Returns
| Type | Description |
|---|---|
| System.Boolean | True if the matrix components are almost equal or false in any other case. |
Equals(Matrix2, Double)
Check if the components of two matrices are approximate equal.
Declaration
public bool Equals(Matrix2 obj, double threshold)
Parameters
| Type | Name | Description |
|---|---|---|
| Matrix2 | obj | Matrix2. |
| System.Double | threshold | Maximum tolerance. |
Returns
| Type | Description |
|---|---|
| System.Boolean | True if the matrix components are almost equal or false in any other case. |
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 | Another object to compare to. |
Returns
| Type | Description |
|---|---|
| System.Boolean | True if obj and this instance are the same type and represent the same value; otherwise, false. |
Overrides
GetHashCode()
Returns the hash code for this instance.
Declaration
public override int GetHashCode()
Returns
| Type | Description |
|---|---|
| System.Int32 | A 32-bit signed integer that is the hash code for this instance. |
Overrides
Inverse()
Calculates the inverse matrix.
Declaration
public Matrix2 Inverse()
Returns
| Type | Description |
|---|---|
| Matrix2 | Inverse Matrix2. |
Multiply(Matrix2, Matrix2)
Product of two matrices.
Declaration
public static Matrix2 Multiply(Matrix2 a, Matrix2 b)
Parameters
| Type | Name | Description |
|---|---|---|
| Matrix2 | a | Matrix2. |
| Matrix2 | b | Matrix2. |
Returns
| Type | Description |
|---|---|
| Matrix2 | Matrix2. |
Multiply(Matrix2, Vector2)
Product of a matrix with a vector.
Declaration
public static Vector2 Multiply(Matrix2 a, Vector2 u)
Parameters
| Type | Name | Description |
|---|---|---|
| Matrix2 | a | Matrix2. |
| Vector2 | u | Vector2. |
Returns
| Type | Description |
|---|---|
| Vector2 | Matrix2. |
Remarks
Matrix2 adopts the convention of using column vectors.
Multiply(Matrix2, Double)
Product of a matrix with a scalar.
Declaration
public static Matrix2 Multiply(Matrix2 m, double a)
Parameters
| Type | Name | Description |
|---|---|---|
| Matrix2 | m | Matrix2. |
| System.Double | a | Scalar. |
Returns
| Type | Description |
|---|---|
| Matrix2 | Matrix2. |
Rotation(Double)
Builds a rotation matrix for a rotation.
Declaration
public static Matrix2 Rotation(double angle)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Double | angle | The counter-clockwise angle in radians. |
Returns
| Type | Description |
|---|---|
| Matrix2 | The resulting Matrix2 instance. |
Remarks
Matrix2 adopts the convention of using column vectors to represent a transformation matrix.
Scale(Vector2)
Build a scaling matrix.
Declaration
public static Matrix2 Scale(Vector2 value)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | value | Scale factors for x and y axis. |
Returns
| Type | Description |
|---|---|
| Matrix2 | A scaling matrix. |
Scale(Double)
Build a scaling matrix.
Declaration
public static Matrix2 Scale(double value)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Double | value | Single scale factor for x and y axis. |
Returns
| Type | Description |
|---|---|
| Matrix2 | A scaling matrix. |
Scale(Double, Double)
Build a scaling matrix.
Declaration
public static Matrix2 Scale(double x, double y)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Double | x | Scale factor for x-axis. |
| System.Double | y | Scale factor for y-axis. |
Returns
| Type | Description |
|---|---|
| Matrix2 | A scaling matrix. |
Subtract(Matrix2, Matrix2)
Matrix subtraction.
Declaration
public static Matrix2 Subtract(Matrix2 a, Matrix2 b)
Parameters
| Type | Name | Description |
|---|---|---|
| Matrix2 | a | Matrix2. |
| Matrix2 | b | Matrix2. |
Returns
| Type | Description |
|---|---|
| Matrix2 | Matrix2. |
ToString()
Obtains a string that represents the matrix.
Declaration
public override string ToString()
Returns
| Type | Description |
|---|---|
| System.String | A string text. |
Overrides
ToString(IFormatProvider)
Obtains a string that represents the matrix.
Declaration
public string ToString(IFormatProvider provider)
Parameters
| Type | Name | Description |
|---|---|---|
| System.IFormatProvider | provider | An IFormatProvider interface implementation that supplies culture-specific formatting information. |
Returns
| Type | Description |
|---|---|
| System.String | A string text. |
Transpose()
Obtains the transpose matrix.
Declaration
public Matrix2 Transpose()
Returns
| Type | Description |
|---|---|
| Matrix2 | Transpose matrix. |
Operators
| Improve this Doc View SourceAddition(Matrix2, Matrix2)
Matrix addition.
Declaration
public static Matrix2 operator +(Matrix2 a, Matrix2 b)
Parameters
| Type | Name | Description |
|---|---|---|
| Matrix2 | a | Matrix2. |
| Matrix2 | b | Matrix2. |
Returns
| Type | Description |
|---|---|
| Matrix2 | Matrix2. |
Equality(Matrix2, Matrix2)
Check if the components of two matrices are equal.
Declaration
public static bool operator ==(Matrix2 u, Matrix2 v)
Parameters
| Type | Name | Description |
|---|---|---|
| Matrix2 | u | Matrix2. |
| Matrix2 | v | Matrix2. |
Returns
| Type | Description |
|---|---|
| System.Boolean | True if the matrix components are equal or false in any other case. |
Inequality(Matrix2, Matrix2)
Check if the components of two matrices are different.
Declaration
public static bool operator !=(Matrix2 u, Matrix2 v)
Parameters
| Type | Name | Description |
|---|---|---|
| Matrix2 | u | Matrix2. |
| Matrix2 | v | Matrix2. |
Returns
| Type | Description |
|---|---|
| System.Boolean | True if the matrix components are different or false in any other case. |
Multiply(Matrix2, Matrix2)
Product of two matrices.
Declaration
public static Matrix2 operator *(Matrix2 a, Matrix2 b)
Parameters
| Type | Name | Description |
|---|---|---|
| Matrix2 | a | Matrix2. |
| Matrix2 | b | Matrix2. |
Returns
| Type | Description |
|---|---|
| Matrix2 | Matrix2. |
Multiply(Matrix2, Vector2)
Product of a matrix with a vector.
Declaration
public static Vector2 operator *(Matrix2 a, Vector2 u)
Parameters
| Type | Name | Description |
|---|---|---|
| Matrix2 | a | Matrix2. |
| Vector2 | u | Vector2. |
Returns
| Type | Description |
|---|---|
| Vector2 | Matrix2. |
Remarks
Matrix2 adopts the convention of using column vectors.
Multiply(Matrix2, Double)
Product of a matrix with a scalar.
Declaration
public static Matrix2 operator *(Matrix2 m, double a)
Parameters
| Type | Name | Description |
|---|---|---|
| Matrix2 | m | Matrix2. |
| System.Double | a | Scalar. |
Returns
| Type | Description |
|---|---|
| Matrix2 | Matrix2. |
Subtraction(Matrix2, Matrix2)
Matrix subtraction.
Declaration
public static Matrix2 operator -(Matrix2 a, Matrix2 b)
Parameters
| Type | Name | Description |
|---|---|---|
| Matrix2 | a | Matrix2. |
| Matrix2 | b | Matrix2. |
Returns
| Type | Description |
|---|---|
| Matrix2 | Matrix2. |