Struct JMatrix
- Namespace
- Jitter2.LinearMath
- Assembly
- Jitter2.dll
Represents a 3x3 matrix with components of type float.
public struct JMatrix : IEquatable<JMatrix>
- Implements
- Inherited Members
Constructors
JMatrix(float, float, float, float, float, float, float, float, float)
Represents a 3x3 matrix with components of type float.
public JMatrix(float m11, float m12, float m13, float m21, float m22, float m23, float m31, float m32, float m33)
Parameters
Fields
Identity
The identity matrix.
public static readonly JMatrix Identity
Field Value
M11
public float M11
Field Value
M12
public float M12
Field Value
M13
public float M13
Field Value
M21
public float M21
Field Value
M22
public float M22
Field Value
M23
public float M23
Field Value
M31
public float M31
Field Value
M32
public float M32
Field Value
M33
public float M33
Field Value
Zero
The zero matrix.
public static readonly JMatrix Zero
Field Value
Methods
Absolute(in JMatrix, out JMatrix)
Creates a matrix where each component is the absolute value of the input matrix component.
public static void Absolute(in JMatrix matrix, out JMatrix result)
Parameters
Add(JMatrix, JMatrix)
Adds two matrices.
public static JMatrix Add(JMatrix matrix1, JMatrix matrix2)
Parameters
Returns
- JMatrix
The sum of the two matrices.
Add(in JMatrix, in JMatrix, out JMatrix)
Adds two matrices component-wise.
public static void Add(in JMatrix matrix1, in JMatrix matrix2, out JMatrix result)
Parameters
matrix1JMatrixThe first matrix.
matrix2JMatrixThe second matrix.
resultJMatrixOutput: The sum of the two matrices.
CreateCrossProduct(in JVector)
Creates a skew-symmetric matrix from a vector, representing the cross product operation.
public static JMatrix CreateCrossProduct(in JVector vec)
Parameters
vecJVectorThe vector.
Returns
- JMatrix
The skew-symmetric matrix.
Remarks
Result is equivalent to:
[ 0 -z y ]
[ z 0 -x ]
[ -y x 0 ]
CreateFromQuaternion(JQuaternion)
Creates a rotation matrix from a quaternion.
public static JMatrix CreateFromQuaternion(JQuaternion quaternion)
Parameters
quaternionJQuaternionThe quaternion representing the rotation.
Returns
- JMatrix
The rotation matrix.
CreateFromQuaternion(in JQuaternion, out JMatrix)
Creates a rotation matrix from a quaternion.
public static void CreateFromQuaternion(in JQuaternion quaternion, out JMatrix result)
Parameters
quaternionJQuaternionThe quaternion representing the rotation.
resultJMatrixOutput: The rotation matrix.
CreateRotationMatrix(JVector, float)
Creates a rotation matrix from an axis and an angle.
public static JMatrix CreateRotationMatrix(JVector axis, float angle)
Parameters
Returns
- JMatrix
The rotation matrix.
CreateRotationX(float)
Creates a rotation matrix around the X-axis.
public static JMatrix CreateRotationX(float radians)
Parameters
radiansfloatThe angle of rotation in radians.
Returns
- JMatrix
The rotation matrix.
CreateRotationY(float)
Creates a rotation matrix around the Y-axis.
public static JMatrix CreateRotationY(float radians)
Parameters
radiansfloatThe angle of rotation in radians.
Returns
- JMatrix
The rotation matrix.
CreateRotationZ(float)
Creates a rotation matrix around the Z-axis.
public static JMatrix CreateRotationZ(float radians)
Parameters
radiansfloatThe angle of rotation in radians.
Returns
- JMatrix
The rotation matrix.
CreateScale(in JVector)
Creates a scaling matrix.
public static JMatrix CreateScale(in JVector scale)
Parameters
scaleJVectorThe scaling vector.
Returns
- JMatrix
The scaling matrix.
CreateScale(float, float, float)
Creates a scaling matrix.
public static JMatrix CreateScale(float x, float y, float z)
Parameters
xfloatScaling factor on the X-axis.
yfloatScaling factor on the Y-axis.
zfloatScaling factor on the Z-axis.
Returns
- JMatrix
The scaling matrix.
Determinant()
Calculates the determinant of the matrix.
public readonly float Determinant()
Returns
- float
The determinant.
Equals(JMatrix)
Indicates whether the current object is equal to another object of the same type.
public readonly bool Equals(JMatrix other)
Parameters
otherJMatrixAn object to compare with this object.
Returns
Equals(object?)
Indicates whether this instance and a specified object are equal.
public override readonly bool Equals(object? obj)
Parameters
objobjectThe object to compare with the current instance.
Returns
- bool
true if
objand this instance are the same type and represent the same value; otherwise, false.
FromColumns(in JVector, in JVector, in JVector)
Creates a matrix from three column vectors.
public static JMatrix FromColumns(in JVector col1, in JVector col2, in JVector col3)
Parameters
col1JVectorThe first column vector.
col2JVectorThe second column vector.
col3JVectorThe third column vector.
Returns
GetColumn(int)
Gets a column vector by index.
public JVector GetColumn(int index)
Parameters
indexintThe zero-based index of the column (0, 1, or 2).
Returns
GetHashCode()
Returns the hash code for this instance.
public override readonly int GetHashCode()
Returns
- int
A 32-bit signed integer that is the hash code for this instance.
Inverse(in JMatrix, out JMatrix)
Calculates the inverse of the matrix.
public static bool Inverse(in JMatrix matrix, out JMatrix result)
Parameters
matrixJMatrixThe matrix to invert.
resultJMatrixOutput: The inverted matrix, or a zero matrix if the determinant is zero.
Returns
- bool
trueif the matrix can be inverted; otherwise,false.
Multiply(JMatrix, float)
Multiplies a matrix by a scalar factor.
public static JMatrix Multiply(JMatrix matrix1, float scaleFactor)
Parameters
Returns
- JMatrix
The scaled matrix.
Multiply(in JMatrix, in JMatrix)
Multiplies two matrices.
public static JMatrix Multiply(in JMatrix matrix1, in JMatrix matrix2)
Parameters
Returns
- JMatrix
The product of the two matrices.
Multiply(in JMatrix, in JMatrix, out JMatrix)
Multiplies two matrices.
public static void Multiply(in JMatrix matrix1, in JMatrix matrix2, out JMatrix result)
Parameters
matrix1JMatrixThe first matrix.
matrix2JMatrixThe second matrix.
resultJMatrixOutput: The product of the two matrices.
Multiply(in JMatrix, float, out JMatrix)
Multiplies a matrix by a scalar factor.
public static void Multiply(in JMatrix matrix1, float scaleFactor, out JMatrix result)
Parameters
matrix1JMatrixThe matrix.
scaleFactorfloatThe scalar factor.
resultJMatrixOutput: The scaled matrix.
MultiplyTransposed(in JMatrix, in JMatrix)
Calculates matrix1 * transpose(matrix2).
public static JMatrix MultiplyTransposed(in JMatrix matrix1, in JMatrix matrix2)
Parameters
matrix1JMatrixThe first matrix.
matrix2JMatrixThe second matrix (which will be transposed during multiplication).
Returns
- JMatrix
The result of the multiplication.
MultiplyTransposed(in JMatrix, in JMatrix, out JMatrix)
Calculates matrix1 * matrix2ᵀ (multiplying matrix1 by the transpose of matrix2).
public static void MultiplyTransposed(in JMatrix matrix1, in JMatrix matrix2, out JMatrix result)
Parameters
matrix1JMatrixThe first matrix.
matrix2JMatrixThe second matrix (transposed during operation).
resultJMatrixOutput: The result of the multiplication.
Subtract(in JMatrix, in JMatrix, out JMatrix)
Subtracts the second matrix from the first component-wise.
public static void Subtract(in JMatrix matrix1, in JMatrix matrix2, out JMatrix result)
Parameters
matrix1JMatrixThe first matrix.
matrix2JMatrixThe second matrix.
resultJMatrixOutput: The difference of the two matrices.
ToString()
Returns the fully qualified type name of this instance.
public override readonly string ToString()
Returns
- string
The fully qualified type name.
Trace()
Calculates the trace (sum of diagonal elements) of the matrix.
public readonly float Trace()
Returns
- float
The trace of the matrix.
Transpose(in JMatrix)
Transposes a matrix.
public static JMatrix Transpose(in JMatrix matrix)
Parameters
matrixJMatrixThe matrix to transpose.
Returns
- JMatrix
The transposed matrix.
TransposedMultiply(in JMatrix, in JMatrix)
Calculates transpose(matrix1) * matrix2.
public static JMatrix TransposedMultiply(in JMatrix matrix1, in JMatrix matrix2)
Parameters
matrix1JMatrixThe first matrix (which will be transposed during multiplication).
matrix2JMatrixThe second matrix.
Returns
- JMatrix
The result of the multiplication.
TransposedMultiply(in JMatrix, in JMatrix, out JMatrix)
Calculates matrix1ᵀ * matrix2 (multiplying the transpose of matrix1 by matrix2).
public static void TransposedMultiply(in JMatrix matrix1, in JMatrix matrix2, out JMatrix result)
Parameters
matrix1JMatrixThe first matrix (transposed during operation).
matrix2JMatrixThe second matrix.
resultJMatrixOutput: The result of the multiplication.
UnsafeGet(int)
Gets a reference to a column vector by index using unsafe pointer arithmetic.
public ref JVector UnsafeGet(int index)
Parameters
indexintThe zero-based index of the column (0, 1, or 2).
Returns
Operators
operator +(in JMatrix, in JMatrix)
Adds two matrices.
public static JMatrix operator +(in JMatrix value1, in JMatrix value2)
Parameters
Returns
operator ==(JMatrix, JMatrix)
public static bool operator ==(JMatrix left, JMatrix right)
Parameters
Returns
operator !=(JMatrix, JMatrix)
public static bool operator !=(JMatrix left, JMatrix right)
Parameters
Returns
operator *(in JMatrix, in JMatrix)
Multiplies two matrices.
public static JMatrix operator *(in JMatrix matrix1, in JMatrix matrix2)
Parameters
Returns
operator *(in JMatrix, float)
Scales a matrix by a factor.
public static JMatrix operator *(in JMatrix matrix, float factor)
Parameters
Returns
operator *(float, in JMatrix)
Scales a matrix by a factor.
public static JMatrix operator *(float factor, in JMatrix matrix)
Parameters
Returns
operator -(in JMatrix, in JMatrix)
Subtracts the second matrix from the first.
public static JMatrix operator -(in JMatrix value1, in JMatrix value2)