Struct Matrix4
Represents a 4x4 double precision matrix.
Implements
Inherited Members
Namespace: netDxf
Assembly: CADability.dll
Syntax
public struct Matrix4 : IEquatable<Matrix4>
Constructors
| Improve this Doc View SourceMatrix4(Double, Double, Double, Double, Double, Double, Double, Double, Double, Double, Double, Double, Double, Double, Double, Double)
Initializes a new instance of Matrix4.
Declaration
public Matrix4(double m11, double m12, double m13, double m14, double m21, double m22, double m23, double m24, double m31, double m32, double m33, double m34, double m41, double m42, double m43, double m44)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Double | m11 | Element [0,0]. |
| System.Double | m12 | Element [0,1]. |
| System.Double | m13 | Element [0,2]. |
| System.Double | m14 | Element [0,3]. |
| System.Double | m21 | Element [1,0]. |
| System.Double | m22 | Element [1,1]. |
| System.Double | m23 | Element [1,2]. |
| System.Double | m24 | Element [1,3]. |
| System.Double | m31 | Element [2,0]. |
| System.Double | m32 | Element [2,1]. |
| System.Double | m33 | Element [2,2]. |
| System.Double | m34 | Element [2,3]. |
| System.Double | m41 | Element [3,0]. |
| System.Double | m42 | Element [3,1]. |
| System.Double | m43 | Element [3,2]. |
| System.Double | m44 | Element [3,3]. |
Properties
| Improve this Doc View SourceIdentity
Gets the identity matrix.
Declaration
public static Matrix4 Identity { get; }
Property Value
| Type | Description |
|---|---|
| Matrix4 |
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 |
M13
Gets or sets the matrix element [0,2].
Declaration
public double M13 { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Double |
M14
Gets or sets the matrix element [0,3].
Declaration
public double M14 { 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 |
M23
Gets or sets the matrix element [1,2].
Declaration
public double M23 { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Double |
M24
Gets or sets the matrix element [1,3].
Declaration
public double M24 { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Double |
M31
Gets or sets the matrix element [2,0].
Declaration
public double M31 { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Double |
M32
Gets or sets the matrix element [2,1].
Declaration
public double M32 { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Double |
M33
Gets or sets the matrix element [2,2].
Declaration
public double M33 { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Double |
M34
Gets or sets the matrix element [2,3].
Declaration
public double M34 { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Double |
M41
Gets or sets the matrix element [3,0].
Declaration
public double M41 { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Double |
M42
Gets or sets the matrix element [3,1].
Declaration
public double M42 { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Double |
M43
Gets or sets the matrix element [3,2].
Declaration
public double M43 { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Double |
M44
Gets or sets the matrix element [3,3].
Declaration
public double M44 { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Double |
Zero
Gets the zero matrix.
Declaration
public static Matrix4 Zero { get; }
Property Value
| Type | Description |
|---|---|
| Matrix4 |
Methods
| Improve this Doc View SourceAdd(Matrix4, Matrix4)
Matrix addition.
Declaration
public static Matrix4 Add(Matrix4 a, Matrix4 b)
Parameters
| Type | Name | Description |
|---|---|---|
| Matrix4 | a | Matrix4. |
| Matrix4 | b | Matrix4. |
Returns
| Type | Description |
|---|---|
| Matrix4 | Matrix4. |
Determinant()
Calculate the determinant of the actual matrix.
Declaration
public double Determinant()
Returns
| Type | Description |
|---|---|
| System.Double | Determinant. |
Equals(Matrix4)
Check if the components of two matrices are approximate equal.
Declaration
public bool Equals(Matrix4 other)
Parameters
| Type | Name | Description |
|---|---|---|
| Matrix4 | other | Matrix4. |
Returns
| Type | Description |
|---|---|
| System.Boolean | True if the matrix components are almost equal or false in any other case. |
Equals(Matrix4, Matrix4)
Check if the components of two matrices are approximate equal.
Declaration
public static bool Equals(Matrix4 a, Matrix4 b)
Parameters
| Type | Name | Description |
|---|---|---|
| Matrix4 | a | Matrix4. |
| Matrix4 | b | Matrix4. |
Returns
| Type | Description |
|---|---|
| System.Boolean | True if the matrix components are almost equal or false in any other case. |
Equals(Matrix4, Matrix4, Double)
Check if the components of two matrices are approximate equal.
Declaration
public static bool Equals(Matrix4 a, Matrix4 b, double threshold)
Parameters
| Type | Name | Description |
|---|---|---|
| Matrix4 | a | Matrix4. |
| Matrix4 | b | Matrix4. |
| 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(Matrix4, Double)
Check if the components of two matrices are approximate equal.
Declaration
public bool Equals(Matrix4 obj, double threshold)
Parameters
| Type | Name | Description |
|---|---|---|
| Matrix4 | obj | Matrix4. |
| 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 Matrix4 Inverse()
Returns
| Type | Description |
|---|---|
| Matrix4 | Inverse Matrix3. |
Multiply(Matrix4, Matrix4)
Product of two matrices.
Declaration
public static Matrix4 Multiply(Matrix4 a, Matrix4 b)
Parameters
| Type | Name | Description |
|---|---|---|
| Matrix4 | a | Matrix4. |
| Matrix4 | b | Matrix4. |
Returns
| Type | Description |
|---|---|
| Matrix4 | Matrix4. |
Multiply(Matrix4, Vector4)
Product of a matrix with a vector.
Declaration
public static Vector4 Multiply(Matrix4 a, Vector4 u)
Parameters
| Type | Name | Description |
|---|---|---|
| Matrix4 | a | Matrix4. |
| Vector4 | u | Vector4. |
Returns
| Type | Description |
|---|---|
| Vector4 | Matrix4. |
Remarks
Matrix4 adopts the convention of using column vectors to represent three dimensional points.
Multiply(Matrix4, Double)
Product of a matrix with a scalar.
Declaration
public static Matrix4 Multiply(Matrix4 m, double a)
Parameters
| Type | Name | Description |
|---|---|---|
| Matrix4 | m | Matrix4. |
| System.Double | a | Scalar. |
Returns
| Type | Description |
|---|---|
| Matrix4 | Matrix4. |
RotationX(Double)
Builds a rotation matrix for a rotation around the x-axis.
Declaration
public static Matrix4 RotationX(double angle)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Double | angle | The counter-clockwise angle in radians. |
Returns
| Type | Description |
|---|---|
| Matrix4 | The resulting Matrix4 instance. |
Remarks
Matrix4 adopts the convention of using column vectors to represent a transformation matrix.
RotationY(Double)
Builds a rotation matrix for a rotation around the y-axis.
Declaration
public static Matrix4 RotationY(double angle)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Double | angle | The counter-clockwise angle in radians. |
Returns
| Type | Description |
|---|---|
| Matrix4 | The resulting Matrix4 instance. |
Remarks
Matrix4 adopts the convention of using column vectors to represent a transformation matrix.
RotationZ(Double)
Builds a rotation matrix for a rotation around the z-axis.
Declaration
public static Matrix4 RotationZ(double angle)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Double | angle | The counter-clockwise angle in radians. |
Returns
| Type | Description |
|---|---|
| Matrix4 | The resulting Matrix4 instance. |
Remarks
Matrix4 adopts the convention of using column vectors to represent a transformation matrix.
Scale(Vector3)
Build a scaling matrix.
Declaration
public static Matrix4 Scale(Vector3 value)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector3 | value | Scale factors for x, y, and z axis. |
Returns
| Type | Description |
|---|---|
| Matrix4 | A scaling matrix. |
Scale(Double)
Build a scaling matrix.
Declaration
public static Matrix4 Scale(double value)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Double | value | Single scale factor for x, y, and z axis. |
Returns
| Type | Description |
|---|---|
| Matrix4 | A scaling matrix. |
Scale(Double, Double, Double)
Build a scaling matrix.
Declaration
public static Matrix4 Scale(double x, double y, double z)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Double | x | Scale factor for x-axis. |
| System.Double | y | Scale factor for y-axis. |
| System.Double | z | Scale factor for z-axis. |
Returns
| Type | Description |
|---|---|
| Matrix4 | A scaling matrix. |
Subtract(Matrix4, Matrix4)
Matrix subtraction.
Declaration
public static Matrix4 Subtract(Matrix4 a, Matrix4 b)
Parameters
| Type | Name | Description |
|---|---|---|
| Matrix4 | a | Matrix4. |
| Matrix4 | b | Matrix4. |
Returns
| Type | Description |
|---|---|
| Matrix4 | Matrix4. |
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. |
Translation(Vector3)
Build a translation matrix.
Declaration
public static Matrix4 Translation(Vector3 vector)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector3 | vector | Translation vector along the X, Y, and Z axis. |
Returns
| Type | Description |
|---|---|
| Matrix4 | A translation matrix. |
Remarks
Matrix4 adopts the convention of using column vectors to represent a transformation matrix.
Translation(Double, Double, Double)
Build a translation matrix.
Declaration
public static Matrix4 Translation(double x, double y, double z)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Double | x | Translation along the X axis. |
| System.Double | y | Translation along the Y axis. |
| System.Double | z | Translation along the Z axis. |
Returns
| Type | Description |
|---|---|
| Matrix4 | A translation matrix. |
Remarks
Matrix4 adopts the convention of using column vectors to represent a transformation matrix.
Transpose()
Obtains the transpose matrix.
Declaration
public Matrix4 Transpose()
Returns
| Type | Description |
|---|---|
| Matrix4 | Transpose matrix. |
Operators
| Improve this Doc View SourceAddition(Matrix4, Matrix4)
Matrix addition.
Declaration
public static Matrix4 operator +(Matrix4 a, Matrix4 b)
Parameters
| Type | Name | Description |
|---|---|---|
| Matrix4 | a | Matrix4. |
| Matrix4 | b | Matrix4. |
Returns
| Type | Description |
|---|---|
| Matrix4 | Matrix4. |
Equality(Matrix4, Matrix4)
Check if the components of two matrices are equal.
Declaration
public static bool operator ==(Matrix4 u, Matrix4 v)
Parameters
| Type | Name | Description |
|---|---|---|
| Matrix4 | u | Matrix4. |
| Matrix4 | v | Matrix4. |
Returns
| Type | Description |
|---|---|
| System.Boolean | True if the matrix components are equal or false in any other case. |
Inequality(Matrix4, Matrix4)
Check if the components of two matrices are different.
Declaration
public static bool operator !=(Matrix4 u, Matrix4 v)
Parameters
| Type | Name | Description |
|---|---|---|
| Matrix4 | u | Matrix4. |
| Matrix4 | v | Matrix4. |
Returns
| Type | Description |
|---|---|
| System.Boolean | True if the matrix components are different or false in any other case. |
Multiply(Matrix4, Matrix4)
Product of two matrices.
Declaration
public static Matrix4 operator *(Matrix4 a, Matrix4 b)
Parameters
| Type | Name | Description |
|---|---|---|
| Matrix4 | a | Matrix4. |
| Matrix4 | b | Matrix4. |
Returns
| Type | Description |
|---|---|
| Matrix4 | Matrix3. |
Multiply(Matrix4, Vector4)
Product of a matrix with a vector.
Declaration
public static Vector4 operator *(Matrix4 a, Vector4 u)
Parameters
| Type | Name | Description |
|---|---|---|
| Matrix4 | a | Matrix4. |
| Vector4 | u | Vector4. |
Returns
| Type | Description |
|---|---|
| Vector4 | Matrix4. |
Remarks
Matrix4 adopts the convention of using column vectors.
Multiply(Matrix4, Double)
Product of a matrix with a scalar.
Declaration
public static Matrix4 operator *(Matrix4 m, double a)
Parameters
| Type | Name | Description |
|---|---|---|
| Matrix4 | m | Matrix4. |
| System.Double | a | Scalar. |
Returns
| Type | Description |
|---|---|
| Matrix4 | Matrix3. |
Subtraction(Matrix4, Matrix4)
Matrix subtraction.
Declaration
public static Matrix4 operator -(Matrix4 a, Matrix4 b)
Parameters
| Type | Name | Description |
|---|---|---|
| Matrix4 | a | Matrix4. |
| Matrix4 | b | Matrix4. |
Returns
| Type | Description |
|---|---|
| Matrix4 | Matrix4. |