Class Matrix3x3D
- Namespace
- VirtualLabAPI.Core.Numerics
- Assembly
- VirtualLabAPI.dll
This class defines a 3x3 Matrix of double numbers.
Operators (\(a+b\), \(a-b\)). Operator (\(a*b\)) supports
\(b\) as double or Vector3D as well.
[Serializable]
public class Matrix3x3D : SerializableObjectBase, IEquatable<IObjectBase>, ICloneable
- Inheritance
-
ObjectBaseSerializableObjectBaseMatrix3x3D
- Implements
-
IEquatable<IObjectBase>
- Inherited Members
Constructors
Matrix3x3D()
Standard constructor, creates an empty matrix where all values are zero.
public Matrix3x3D()
Matrix3x3D(double)
Constructor to get a diagonal matrix having constant value \(c\) on all diagonal elements.
public Matrix3x3D(double c)
Parameters
cdoubleValue \(c\) used to initialize diagonal elements.
Matrix3x3D(double, double, double, double, double, double, double, double, double)
Constructor taking nine doubles to initialize a Matrix3x3D.
public Matrix3x3D(double m11, double m21, double m31, double m12, double m22, double m32, double m13, double m23, double m33)
Parameters
m11doubleFirst element of first column.
m21doubleSecond element of first column.
m31doubleThird element of first column.
m12doubleFirst element of second column.
m22doubleSecond element of second column.
m32doubleThird element of second column.
m13doubleFirst element of third column.
m23doubleSecond element of third column.
m33doubleThird element of third column.
Matrix3x3D(Matrix3x3D)
Copy constructor.
public Matrix3x3D(Matrix3x3D matC)
Parameters
matCMatrix3x3DMatrix3x3D to be copied.
Matrix3x3D(Vector3D, Vector3D, Vector3D)
Constructor taking three Vector3D to initialize a Matrix3x3D.
public Matrix3x3D(Vector3D firstCol, Vector3D secondCol, Vector3D thirdCol)
Parameters
Fields
Elements
The field in which the double elements are stored. Note that indices [1..9] are interpreted mathematical. [0] exists but contains no information. Mapping of rows [1..3] and columns [1..3] to one-dimensional index \(i\) is defined by: \(i := row + 3 * (column-1)\).
[Obsolete("Use the two-dimensional indexer instead.")]
public double[] Elements
Field Value
- double[]
Properties
Identity
Static property which gives the identity matrix.
public static Matrix3x3D Identity { get; }
Property Value
this[int, int]
Gets or sets a certain matrix element.
public double this[int row, int col] { get; set; }
Parameters
Property Value
- double
The selected matrix element.
Exceptions
- ArgumentOutOfRangeException
At least one of the two given indices is out of range.
Methods
Clone()
Creates a new object that is a copy of the current instance.
public override object Clone()
Returns
- object
A new object that is a copy of this instance.
Determinant()
Calculates the determinant of this matrix.
public double Determinant()
Returns
- double
The determinant of this matrix.
Equals(object, EqualityIntent)
Compares two matrices for equality.
public override bool Equals(object matrix, EqualityIntent equalityIntent)
Parameters
matrixobjectmatrix to compare with
equalityIntentEqualityIntentDefines what kind of equality you want to check when comparing two objects, for example all values or physical equality.
Returns
GetCol(int)
Returns the specified column of this Matrix3x3D as Vector3D.
public Vector3D GetCol(int index)
Parameters
indexintColumn to return (index is one-based!).
Returns
- Vector3D
Result of operation.
GetHashCode()
Returns a hash code for this instance.
public override int GetHashCode()
Returns
- int
A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table.
GetInverse()
Calculates the inverse matrix of this one.
public Matrix3x3D GetInverse()
Returns
- Matrix3x3D
The inverse matrix.
GetRow(int)
Returns the specified column of this Matrix3x3D as Vector3D.
public Vector3D GetRow(int index)
Parameters
indexintRow to return (index is one-based!).
Returns
- Vector3D
Result of operation.
GetTransposed()
Returns transposed matrix of this matrix.
public Matrix3x3D GetTransposed()
Returns
- Matrix3x3D
Result of operation..
InverseMatrix(Matrix3x3D)
Calculates inverse matrix of the given one.
public static Matrix3x3D InverseMatrix(Matrix3x3D mat)
Parameters
matMatrix3x3DMatrix3x3D to invert.
Returns
- Matrix3x3D
Result of operation.
IsIdentity()
Checks whether the matrix is the identity matrix.
public bool IsIdentity()
Returns
IsIdentityNumericalChecks()
Checks whether the matrix is the identity matrix.
public bool IsIdentityNumericalChecks()
Returns
IsOrthogonal()
Checks if matrix is orthogonal, i.e. if M * M^T is the identity matrix
public bool IsOrthogonal()
Returns
ToString()
Returns an output string representing this matrix.
public override string ToString()
Returns
- string
A string that represents this matrix.
TryParse(string, out Matrix3x3D)
Tries to parse a Matrix3x3D object from a string.
public static bool TryParse(string matrixText, out Matrix3x3D matrix3x3D)
Parameters
matrixTextstringString which has to be formatted according to the ToString() method.
matrix3x3DMatrix3x3DThe parsed matrix if parse has been possible. Null otherwise.
Returns
- bool
A flag indicating whether or not the parsing was successful.
Operators
operator +(Matrix3x3D, Matrix3x3D)
Adds the elements of two Matrix3x3D objects.
public static Matrix3x3D operator +(Matrix3x3D a, Matrix3x3D b)
Parameters
aMatrix3x3Dthe first matrix
bMatrix3x3Dthe second matrix
Returns
- Matrix3x3D
The sum of the two matrices.
operator ==(Matrix3x3D, Matrix3x3D)
Compares two matrices. Two matrices are equal when they are equal in all elements.
public static bool operator ==(Matrix3x3D a, Matrix3x3D b)
Parameters
aMatrix3x3DFirst matrix.
bMatrix3x3DSecond matrix.
Returns
operator !=(Matrix3x3D, Matrix3x3D)
Checks two matrices for inequality.
public static bool operator !=(Matrix3x3D a, Matrix3x3D b)
Parameters
aMatrix3x3Dfirst matrix
bMatrix3x3Dsecond matrix
Returns
operator *(double, Matrix3x3D)
Multiplies a Matrix3x3D with a scalar.
public static Matrix3x3D operator *(double b, Matrix3x3D a)
Parameters
bdoublescalar
aMatrix3x3Dmatrix
Returns
- Matrix3x3D
Result of operation.
operator *(Matrix3x3D, double)
Multiplies a Matrix3x3D with a scalar.
public static Matrix3x3D operator *(Matrix3x3D a, double b)
Parameters
aMatrix3x3Dmatrix
bdoublescalar
Returns
- Matrix3x3D
Result of operation.
operator *(Matrix3x3D, Matrix3x3D)
Multiplies the elements of two Matrix3x3D objects.
public static Matrix3x3D operator *(Matrix3x3D a, Matrix3x3D b)
Parameters
aMatrix3x3Dthe first matrix
bMatrix3x3Dthe second matrix
Returns
- Matrix3x3D
The product of the two matrices.
operator *(Matrix3x3D, Vector3C)
Multiplies a Matrix with an 3-dimensional complex Vector (A*Vec).
public static Vector3C operator *(Matrix3x3D a, Vector3C vec)
Parameters
aMatrix3x3D3x3 matrix
vecVector3CComplex vector.
Returns
- Vector3C
Result of operation.
operator *(Matrix3x3D, Vector3D)
Multiplies a Matrix with an 3-dimensional vector (A*Vec).
public static Vector3D operator *(Matrix3x3D a, Vector3D vec)
Parameters
aMatrix3x3D3x3 matrix
vecVector3Dvector
Returns
- Vector3D
Result of operation.
operator -(Matrix3x3D, Matrix3x3D)
Subtracts the elements of two Matrix3x3D objects.
public static Matrix3x3D operator -(Matrix3x3D a, Matrix3x3D b)
Parameters
aMatrix3x3Dthe first matrix
bMatrix3x3Dthe second matrix
Returns
- Matrix3x3D
The Difference of the two matrices.