Table of Contents

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

m11 float
m12 float
m13 float
m21 float
m22 float
m23 float
m31 float
m32 float
m33 float

Fields

Identity

The identity matrix.

public static readonly JMatrix Identity

Field Value

JMatrix

M11

public float M11

Field Value

float

M12

public float M12

Field Value

float

M13

public float M13

Field Value

float

M21

public float M21

Field Value

float

M22

public float M22

Field Value

float

M23

public float M23

Field Value

float

M31

public float M31

Field Value

float

M32

public float M32

Field Value

float

M33

public float M33

Field Value

float

Zero

The zero matrix.

public static readonly JMatrix Zero

Field Value

JMatrix

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

matrix JMatrix

The input matrix.

result JMatrix

Output: The absolute matrix.

Add(JMatrix, JMatrix)

Adds two matrices.

public static JMatrix Add(JMatrix matrix1, JMatrix matrix2)

Parameters

matrix1 JMatrix

The first matrix.

matrix2 JMatrix

The second matrix.

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

matrix1 JMatrix

The first matrix.

matrix2 JMatrix

The second matrix.

result JMatrix

Output: 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

vec JVector

The 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

quaternion JQuaternion

The 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

quaternion JQuaternion

The quaternion representing the rotation.

result JMatrix

Output: 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

axis JVector

The axis to rotate around.

angle float

The angle of rotation in radians.

Returns

JMatrix

The rotation matrix.

CreateRotationX(float)

Creates a rotation matrix around the X-axis.

public static JMatrix CreateRotationX(float radians)

Parameters

radians float

The 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

radians float

The 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

radians float

The 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

scale JVector

The 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

x float

Scaling factor on the X-axis.

y float

Scaling factor on the Y-axis.

z float

Scaling 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

other JMatrix

An object to compare with this object.

Returns

bool

true if the current object is equal to the other parameter; otherwise, false.

Equals(object?)

Indicates whether this instance and a specified object are equal.

public override readonly bool Equals(object? obj)

Parameters

obj object

The object to compare with the current instance.

Returns

bool

true if obj and 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

col1 JVector

The first column vector.

col2 JVector

The second column vector.

col3 JVector

The third column vector.

Returns

JMatrix

GetColumn(int)

Gets a column vector by index.

public JVector GetColumn(int index)

Parameters

index int

The zero-based index of the column (0, 1, or 2).

Returns

JVector

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

matrix JMatrix

The matrix to invert.

result JMatrix

Output: The inverted matrix, or a zero matrix if the determinant is zero.

Returns

bool

true if 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

matrix1 JMatrix

The matrix.

scaleFactor float

The scalar factor.

Returns

JMatrix

The scaled matrix.

Multiply(in JMatrix, in JMatrix)

Multiplies two matrices.

public static JMatrix Multiply(in JMatrix matrix1, in JMatrix matrix2)

Parameters

matrix1 JMatrix

The first matrix.

matrix2 JMatrix

The second matrix.

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

matrix1 JMatrix

The first matrix.

matrix2 JMatrix

The second matrix.

result JMatrix

Output: 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

matrix1 JMatrix

The matrix.

scaleFactor float

The scalar factor.

result JMatrix

Output: The scaled matrix.

MultiplyTransposed(in JMatrix, in JMatrix)

Calculates matrix1 * transpose(matrix2).

public static JMatrix MultiplyTransposed(in JMatrix matrix1, in JMatrix matrix2)

Parameters

matrix1 JMatrix

The first matrix.

matrix2 JMatrix

The 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

matrix1 JMatrix

The first matrix.

matrix2 JMatrix

The second matrix (transposed during operation).

result JMatrix

Output: 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

matrix1 JMatrix

The first matrix.

matrix2 JMatrix

The second matrix.

result JMatrix

Output: 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

matrix JMatrix

The 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

matrix1 JMatrix

The first matrix (which will be transposed during multiplication).

matrix2 JMatrix

The 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

matrix1 JMatrix

The first matrix (transposed during operation).

matrix2 JMatrix

The second matrix.

result JMatrix

Output: 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

index int

The zero-based index of the column (0, 1, or 2).

Returns

JVector

Operators

operator +(in JMatrix, in JMatrix)

Adds two matrices.

public static JMatrix operator +(in JMatrix value1, in JMatrix value2)

Parameters

value1 JMatrix
value2 JMatrix

Returns

JMatrix

operator ==(JMatrix, JMatrix)

public static bool operator ==(JMatrix left, JMatrix right)

Parameters

left JMatrix
right JMatrix

Returns

bool

operator !=(JMatrix, JMatrix)

public static bool operator !=(JMatrix left, JMatrix right)

Parameters

left JMatrix
right JMatrix

Returns

bool

operator *(in JMatrix, in JMatrix)

Multiplies two matrices.

public static JMatrix operator *(in JMatrix matrix1, in JMatrix matrix2)

Parameters

matrix1 JMatrix
matrix2 JMatrix

Returns

JMatrix

operator *(in JMatrix, float)

Scales a matrix by a factor.

public static JMatrix operator *(in JMatrix matrix, float factor)

Parameters

matrix JMatrix
factor float

Returns

JMatrix

operator *(float, in JMatrix)

Scales a matrix by a factor.

public static JMatrix operator *(float factor, in JMatrix matrix)

Parameters

factor float
matrix JMatrix

Returns

JMatrix

operator -(in JMatrix, in JMatrix)

Subtracts the second matrix from the first.

public static JMatrix operator -(in JMatrix value1, in JMatrix value2)

Parameters

value1 JMatrix
value2 JMatrix

Returns

JMatrix