Show / Hide Table of Contents

Class Matrix3x3

Defines a matrix.

Inheritance
System.Object
Matrix3x3
Namespace: VRageMath
Assembly: VRage.Math.dll
Syntax
public sealed class Matrix3x3 : ValueType, IEquatable<Matrix3x3>

Constructors

Matrix3x3(Single, Single, Single, Single, Single, Single, Single, Single, Single)

Initializes a new instance of Matrix3x3.

Declaration
public Matrix3x3(float m11, float m12, float m13, float m21, float m22, float m23, float m31, float m32, float m33)
Parameters
Type Name Description
System.Single m11

Value to initialize m11 to.

System.Single m12

Value to initialize m12 to.

System.Single m13

Value to initialize m13 to.

System.Single m21

Value to initialize m21 to.

System.Single m22

Value to initialize m22 to.

System.Single m23

Value to initialize m23 to.

System.Single m31

Value to initialize m31 to.

System.Single m32

Value to initialize m32 to.

System.Single m33

Value to initialize m33 to.

Matrix3x3(Matrix3x3)

Declaration
public Matrix3x3(Matrix3x3 other)
Parameters
Type Name Description
Matrix3x3 other

Matrix3x3(MatrixD)

Declaration
public Matrix3x3(MatrixD other)
Parameters
Type Name Description
MatrixD other

Fields

Identity

Declaration
public static Matrix3x3 Identity
Field Value
Type Description
Matrix3x3

M11

Value at row 1 column 1 of the matrix.

Declaration
public float M11
Field Value
Type Description
System.Single

M12

Value at row 1 column 2 of the matrix.

Declaration
public float M12
Field Value
Type Description
System.Single

M13

Value at row 1 column 3 of the matrix.

Declaration
public float M13
Field Value
Type Description
System.Single

M21

Value at row 2 column 1 of the matrix.

Declaration
public float M21
Field Value
Type Description
System.Single

M22

Value at row 2 column 2 of the matrix.

Declaration
public float M22
Field Value
Type Description
System.Single

M23

Value at row 2 column 3 of the matrix.

Declaration
public float M23
Field Value
Type Description
System.Single

M31

Value at row 3 column 1 of the matrix.

Declaration
public float M31
Field Value
Type Description
System.Single

M32

Value at row 3 column 2 of the matrix.

Declaration
public float M32
Field Value
Type Description
System.Single

M33

Value at row 3 column 3 of the matrix.

Declaration
public float M33
Field Value
Type Description
System.Single

Zero

Declaration
public static Matrix3x3 Zero
Field Value
Type Description
Matrix3x3

Properties

Backward

Gets and sets the backward vector of the Matrix3x3.

Declaration
public Vector3 Backward { get; set; }
Property Value
Type Description
Vector3

Col0

Declaration
public Vector3 Col0 { get; }
Property Value
Type Description
Vector3

Col1

Declaration
public Vector3 Col1 { get; }
Property Value
Type Description
Vector3

Col2

Declaration
public Vector3 Col2 { get; }
Property Value
Type Description
Vector3

Down

Gets and sets the down vector of the Matrix3x3.

Declaration
public Vector3 Down { get; set; }
Property Value
Type Description
Vector3

Forward

Gets and sets the forward vector of the Matrix3x3.

Declaration
public Vector3 Forward { get; set; }
Property Value
Type Description
Vector3

Item[Int32, Int32]

Declaration
public float this[int row, int column] { get; set; }
Parameters
Type Name Description
System.Int32 row
System.Int32 column
Property Value
Type Description
System.Single

Left

Gets and sets the left vector of the Matrix3x3.

Declaration
public Vector3 Left { get; set; }
Property Value
Type Description
Vector3

Right

Gets and sets the right vector of the Matrix3x3.

Declaration
public Vector3 Right { get; set; }
Property Value
Type Description
Vector3

Scale

Declaration
public Vector3 Scale { get; }
Property Value
Type Description
Vector3

Up

Gets and sets the up vector of the Matrix3x3.

Declaration
public Vector3 Up { get; set; }
Property Value
Type Description
Vector3

Methods

Add(ref Matrix3x3, ref Matrix3x3, out Matrix3x3)

Adds a matrix to another matrix.

Declaration
public static void Add(ref Matrix3x3 matrix1, ref Matrix3x3 matrix2, out Matrix3x3 result)
Parameters
Type Name Description
Matrix3x3 matrix1

Source matrix.

Matrix3x3 matrix2

Source matrix.

Matrix3x3 result

[OutAttribute] Resulting matrix.

AlignRotationToAxes(ref Matrix3x3, ref Matrix3x3)

Declaration
public static Matrix3x3 AlignRotationToAxes(ref Matrix3x3 toAlign, ref Matrix3x3 axisDefinitionMatrix)
Parameters
Type Name Description
Matrix3x3 toAlign
Matrix3x3 axisDefinitionMatrix
Returns
Type Description
Matrix3x3

AssertIsValid()

Declaration
public void AssertIsValid()

CreateFromAxisAngle(Vector3, Single)

Creates a new Matrix3x3 that rotates around an arbitrary vector.

Declaration
public static Matrix3x3 CreateFromAxisAngle(Vector3 axis, float angle)
Parameters
Type Name Description
Vector3 axis

The axis to rotate around.

System.Single angle

The angle to rotate around the vector.

Returns
Type Description
Matrix3x3

CreateFromAxisAngle(ref Vector3, Single, out Matrix3x3)

Creates a new Matrix3x3 that rotates around an arbitrary vector.

Declaration
public static void CreateFromAxisAngle(ref Vector3 axis, float angle, out Matrix3x3 result)
Parameters
Type Name Description
Vector3 axis

The axis to rotate around.

System.Single angle

The angle to rotate around the vector.

Matrix3x3 result

[OutAttribute] The created Matrix3x3.

CreateFromDir(Vector3)

Declaration
public static Matrix3x3 CreateFromDir(Vector3 dir)
Parameters
Type Name Description
Vector3 dir
Returns
Type Description
Matrix3x3

CreateFromDir(Vector3, Vector3)

Declaration
public static Matrix3x3 CreateFromDir(Vector3 dir, Vector3 suggestedUp)
Parameters
Type Name Description
Vector3 dir
Vector3 suggestedUp
Returns
Type Description
Matrix3x3

CreateFromQuaternion(Quaternion)

Creates a rotation Matrix3x3 from a Quaternion.

Declaration
public static Matrix3x3 CreateFromQuaternion(Quaternion quaternion)
Parameters
Type Name Description
Quaternion quaternion

Quaternion to create the Matrix3x3 from.

Returns
Type Description
Matrix3x3

CreateFromQuaternion(ref Quaternion, out Matrix3x3)

Creates a rotation Matrix3x3 from a Quaternion.

Declaration
public static void CreateFromQuaternion(ref Quaternion quaternion, out Matrix3x3 result)
Parameters
Type Name Description
Quaternion quaternion

Quaternion to create the Matrix3x3 from.

Matrix3x3 result

[OutAttribute] The created Matrix3x3.

CreateFromYawPitchRoll(Single, Single, Single)

Creates a new rotation matrix from a specified yaw, pitch, and roll.

Declaration
public static Matrix3x3 CreateFromYawPitchRoll(float yaw, float pitch, float roll)
Parameters
Type Name Description
System.Single yaw

Angle of rotation, in radians, around the y-axis.

System.Single pitch

Angle of rotation, in radians, around the x-axis.

System.Single roll

Angle of rotation, in radians, around the z-axis.

Returns
Type Description
Matrix3x3

CreateFromYawPitchRoll(Single, Single, Single, out Matrix3x3)

Fills in a rotation matrix from a specified yaw, pitch, and roll.

Declaration
public static void CreateFromYawPitchRoll(float yaw, float pitch, float roll, out Matrix3x3 result)
Parameters
Type Name Description
System.Single yaw

Angle of rotation, in radians, around the y-axis.

System.Single pitch

Angle of rotation, in radians, around the x-axis.

System.Single roll

Angle of rotation, in radians, around the z-axis.

Matrix3x3 result

[OutAttribute] An existing matrix filled in to represent the specified yaw, pitch, and roll.

CreateRotationFromTwoVectors(ref Vector3, ref Vector3, out Matrix3x3)

Declaration
public static void CreateRotationFromTwoVectors(ref Vector3 fromVector, ref Vector3 toVector, out Matrix3x3 resultMatrix)
Parameters
Type Name Description
Vector3 fromVector
Vector3 toVector
Matrix3x3 resultMatrix

CreateRotationX(Single)

Returns a matrix that can be used to rotate a set of vertices around the x-axis.

Declaration
public static Matrix3x3 CreateRotationX(float radians)
Parameters
Type Name Description
System.Single radians

The amount, in radians, in which to rotate around the x-axis. Note that you can use ToRadians to convert degrees to radians.

Returns
Type Description
Matrix3x3

CreateRotationX(Single, out Matrix3x3)

Populates data into a user-specified matrix that can be used to rotate a set of vertices around the x-axis.

Declaration
public static void CreateRotationX(float radians, out Matrix3x3 result)
Parameters
Type Name Description
System.Single radians

The amount, in radians, in which to rotate around the x-axis. Note that you can use ToRadians to convert degrees to radians.

Matrix3x3 result

[OutAttribute] The matrix in which to place the calculated data.

CreateRotationY(Single)

Returns a matrix that can be used to rotate a set of vertices around the y-axis.

Declaration
public static Matrix3x3 CreateRotationY(float radians)
Parameters
Type Name Description
System.Single radians

The amount, in radians, in which to rotate around the y-axis. Note that you can use ToRadians to convert degrees to radians.

Returns
Type Description
Matrix3x3

CreateRotationY(Single, out Matrix3x3)

Populates data into a user-specified matrix that can be used to rotate a set of vertices around the y-axis.

Declaration
public static void CreateRotationY(float radians, out Matrix3x3 result)
Parameters
Type Name Description
System.Single radians

The amount, in radians, in which to rotate around the y-axis. Note that you can use ToRadians to convert degrees to radians.

Matrix3x3 result

[OutAttribute] The matrix in which to place the calculated data.

CreateRotationZ(Single)

Returns a matrix that can be used to rotate a set of vertices around the z-axis.

Declaration
public static Matrix3x3 CreateRotationZ(float radians)
Parameters
Type Name Description
System.Single radians

The amount, in radians, in which to rotate around the z-axis. Note that you can use ToRadians to convert degrees to radians.

Returns
Type Description
Matrix3x3

CreateRotationZ(Single, out Matrix3x3)

Populates data into a user-specified matrix that can be used to rotate a set of vertices around the z-axis.

Declaration
public static void CreateRotationZ(float radians, out Matrix3x3 result)
Parameters
Type Name Description
System.Single radians

The amount, in radians, in which to rotate around the z-axis. Note that you can use ToRadians to convert degrees to radians.

Matrix3x3 result

[OutAttribute] The rotation matrix.

CreateScale(Single)

Creates a scaling Matrix3x3.

Declaration
public static Matrix3x3 CreateScale(float scale)
Parameters
Type Name Description
System.Single scale

Amount to scale by.

Returns
Type Description
Matrix3x3

CreateScale(Single, Single, Single)

Creates a scaling Matrix3x3.

Declaration
public static Matrix3x3 CreateScale(float xScale, float yScale, float zScale)
Parameters
Type Name Description
System.Single xScale

Value to scale by on the x-axis.

System.Single yScale

Value to scale by on the y-axis.

System.Single zScale

Value to scale by on the z-axis.

Returns
Type Description
Matrix3x3

CreateScale(Single, Single, Single, out Matrix3x3)

Creates a scaling Matrix3x3.

Declaration
public static void CreateScale(float xScale, float yScale, float zScale, out Matrix3x3 result)
Parameters
Type Name Description
System.Single xScale

Value to scale by on the x-axis.

System.Single yScale

Value to scale by on the y-axis.

System.Single zScale

Value to scale by on the z-axis.

Matrix3x3 result

[OutAttribute] The created scaling Matrix3x3.

CreateScale(Single, out Matrix3x3)

Creates a scaling Matrix3x3.

Declaration
public static void CreateScale(float scale, out Matrix3x3 result)
Parameters
Type Name Description
System.Single scale

Value to scale by.

Matrix3x3 result

[OutAttribute] The created scaling Matrix3x3.

CreateScale(Vector3)

Creates a scaling Matrix3x3.

Declaration
public static Matrix3x3 CreateScale(Vector3 scales)
Parameters
Type Name Description
Vector3 scales

Amounts to scale by on the x, y, and z axes.

Returns
Type Description
Matrix3x3

CreateScale(ref Vector3, out Matrix3x3)

Creates a scaling Matrix3x3.

Declaration
public static void CreateScale(ref Vector3 scales, out Matrix3x3 result)
Parameters
Type Name Description
Vector3 scales

Amounts to scale by on the x, y, and z axes.

Matrix3x3 result

[OutAttribute] The created scaling Matrix3x3.

CreateWorld(ref Vector3, ref Vector3)

Creates a world matrix with the specified parameters.

Declaration
public static Matrix3x3 CreateWorld(ref Vector3 forward, ref Vector3 up)
Parameters
Type Name Description
Vector3 forward

Forward direction of the object.

Vector3 up

Upward direction of the object; usually [0, 1, 0].

Returns
Type Description
Matrix3x3

Determinant()

Declaration
public float Determinant()
Returns
Type Description
System.Single

Divide(ref Matrix3x3, Single, out Matrix3x3)

Divides the components of a matrix by a scalar.

Declaration
public static void Divide(ref Matrix3x3 matrix1, float divider, out Matrix3x3 result)
Parameters
Type Name Description
Matrix3x3 matrix1

Source matrix.

System.Single divider

The divisor.

Matrix3x3 result

[OutAttribute] Result of the division.

Divide(ref Matrix3x3, ref Matrix3x3, out Matrix3x3)

Divides the components of a matrix by the corresponding components of another matrix.

Declaration
public static void Divide(ref Matrix3x3 matrix1, ref Matrix3x3 matrix2, out Matrix3x3 result)
Parameters
Type Name Description
Matrix3x3 matrix1

Source matrix.

Matrix3x3 matrix2

The divisor.

Matrix3x3 result

[OutAttribute] Result of the division.

Equals(Object)

Returns a value that indicates whether the current instance is equal to a specified object.

Declaration
public override bool Equals(object obj)
Parameters
Type Name Description
System.Object obj

Object with which to make the comparison.

Returns
Type Description
System.Boolean

Equals(Matrix3x3)

Determines whether the specified Object is equal to the Matrix3x3.

Declaration
public bool Equals(Matrix3x3 other)
Parameters
Type Name Description
Matrix3x3 other

The Object to compare with the current Matrix3x3.

Returns
Type Description
System.Boolean

EqualsFast(ref Matrix3x3, Single)

Compares just position, forward and up

Declaration
public bool EqualsFast(ref Matrix3x3 other, float epsilon = 0.0001F)
Parameters
Type Name Description
Matrix3x3 other
System.Single epsilon
Returns
Type Description
System.Boolean

GetClosestDirection(Vector3)

Declaration
public Base6Directions.Direction GetClosestDirection(Vector3 referenceVector)
Parameters
Type Name Description
Vector3 referenceVector
Returns
Type Description
Base6Directions.Direction

GetClosestDirection(ref Vector3)

Declaration
public Base6Directions.Direction GetClosestDirection(ref Vector3 referenceVector)
Parameters
Type Name Description
Vector3 referenceVector
Returns
Type Description
Base6Directions.Direction

GetDirectionVector(Base6Directions.Direction)

Gets the base vector of the matrix, corresponding to the given direction

Declaration
public Vector3 GetDirectionVector(Base6Directions.Direction direction)
Parameters
Type Name Description
Base6Directions.Direction direction
Returns
Type Description
Vector3

GetEulerAnglesXYZ(ref Matrix3x3, out Vector3)

Declaration
public static bool GetEulerAnglesXYZ(ref Matrix3x3 mat, out Vector3 xyz)
Parameters
Type Name Description
Matrix3x3 mat
Vector3 xyz
Returns
Type Description
System.Boolean

GetHashCode()

Gets the hash code of this object.

Declaration
public override int GetHashCode()
Returns
Type Description
System.Int32

GetOrientation()

Gets the orientation.

Declaration
public Matrix3x3 GetOrientation()
Returns
Type Description
Matrix3x3

GetRow(Int32)

Declaration
public Vector3 GetRow(int row)
Parameters
Type Name Description
System.Int32 row
Returns
Type Description
Vector3

Invert(ref Matrix3x3, out Matrix3x3)

Calculates the inverse of a matrix.

Declaration
public static void Invert(ref Matrix3x3 matrix, out Matrix3x3 result)
Parameters
Type Name Description
Matrix3x3 matrix

The source matrix.

Matrix3x3 result

[OutAttribute] The inverse of matrix. The same matrix can be used for both arguments.

IsMirrored()

Declaration
public bool IsMirrored()
Returns
Type Description
System.Boolean

IsNan()

Declaration
public bool IsNan()
Returns
Type Description
System.Boolean

IsOrthogonal()

Declaration
public bool IsOrthogonal()
Returns
Type Description
System.Boolean

IsRotation()

Declaration
public bool IsRotation()
Returns
Type Description
System.Boolean

IsValid()

Declaration
public bool IsValid()
Returns
Type Description
System.Boolean

Lerp(ref Matrix3x3, ref Matrix3x3, Single, out Matrix3x3)

Linearly interpolates between the corresponding values of two matrices.

Declaration
public static void Lerp(ref Matrix3x3 matrix1, ref Matrix3x3 matrix2, float amount, out Matrix3x3 result)
Parameters
Type Name Description
Matrix3x3 matrix1

Source matrix.

Matrix3x3 matrix2

Source matrix.

System.Single amount

Interpolation value.

Matrix3x3 result

[OutAttribute] Resulting matrix.

Multiply(ref Matrix3x3, Single, out Matrix3x3)

Multiplies a matrix by a scalar value.

Declaration
public static void Multiply(ref Matrix3x3 matrix1, float scaleFactor, out Matrix3x3 result)
Parameters
Type Name Description
Matrix3x3 matrix1

Source matrix.

System.Single scaleFactor

Scalar value.

Matrix3x3 result

[OutAttribute] The result of the multiplication.

Multiply(ref Matrix3x3, ref Matrix3x3, out Matrix3x3)

Multiplies a matrix by another matrix.

Declaration
public static void Multiply(ref Matrix3x3 matrix1, ref Matrix3x3 matrix2, out Matrix3x3 result)
Parameters
Type Name Description
Matrix3x3 matrix1

Source matrix.

Matrix3x3 matrix2

Source matrix.

Matrix3x3 result

[OutAttribute] Result of the multiplication.

Negate(ref Matrix3x3, out Matrix3x3)

Negates individual elements of a matrix.

Declaration
public static void Negate(ref Matrix3x3 matrix, out Matrix3x3 result)
Parameters
Type Name Description
Matrix3x3 matrix

Source matrix.

Matrix3x3 result

[OutAttribute] Negated matrix.

Normalize(Matrix3x3)

Declaration
public static Matrix3x3 Normalize(Matrix3x3 matrix)
Parameters
Type Name Description
Matrix3x3 matrix
Returns
Type Description
Matrix3x3

Orthogonalize(Matrix3x3)

Declaration
public static Matrix3x3 Orthogonalize(Matrix3x3 rotationMatrix)
Parameters
Type Name Description
Matrix3x3 rotationMatrix
Returns
Type Description
Matrix3x3

Rescale(Matrix3x3, Single)

Declaration
public static Matrix3x3 Rescale(Matrix3x3 matrix, float scale)
Parameters
Type Name Description
Matrix3x3 matrix
System.Single scale
Returns
Type Description
Matrix3x3

Rescale(Matrix3x3, Vector3)

Declaration
public static Matrix3x3 Rescale(Matrix3x3 matrix, Vector3 scale)
Parameters
Type Name Description
Matrix3x3 matrix
Vector3 scale
Returns
Type Description
Matrix3x3

Rescale(ref Matrix3x3, Single)

Same result as Matrix3x3.CreateScale(scale) * matrix, but much faster

Declaration
public static void Rescale(ref Matrix3x3 matrix, float scale)
Parameters
Type Name Description
Matrix3x3 matrix
System.Single scale

Rescale(ref Matrix3x3, ref Vector3)

Same result as Matrix3x3.CreateScale(scale) * matrix, but much faster

Declaration
public static void Rescale(ref Matrix3x3 matrix, ref Vector3 scale)
Parameters
Type Name Description
Matrix3x3 matrix
Vector3 scale

Round(ref Matrix3x3)

Declaration
public static Matrix3x3 Round(ref Matrix3x3 matrix)
Parameters
Type Name Description
Matrix3x3 matrix
Returns
Type Description
Matrix3x3

SetDirectionVector(Base6Directions.Direction, Vector3)

Sets the base vector of the matrix, corresponding to the given direction

Declaration
public void SetDirectionVector(Base6Directions.Direction direction, Vector3 newValue)
Parameters
Type Name Description
Base6Directions.Direction direction
Vector3 newValue

SetRow(Int32, Vector3)

Declaration
public void SetRow(int row, Vector3 value)
Parameters
Type Name Description
System.Int32 row
Vector3 value

Slerp(ref Matrix3x3, ref Matrix3x3, Single, out Matrix3x3)

Performs spherical linear interpolation of position and rotation.

Declaration
public static void Slerp(ref Matrix3x3 matrix1, ref Matrix3x3 matrix2, float amount, out Matrix3x3 result)
Parameters
Type Name Description
Matrix3x3 matrix1
Matrix3x3 matrix2
System.Single amount
Matrix3x3 result

SlerpScale(ref Matrix3x3, ref Matrix3x3, Single, out Matrix3x3)

Performs spherical linear interpolation of position and rotation and scale.

Declaration
public static void SlerpScale(ref Matrix3x3 matrix1, ref Matrix3x3 matrix2, float amount, out Matrix3x3 result)
Parameters
Type Name Description
Matrix3x3 matrix1
Matrix3x3 matrix2
System.Single amount
Matrix3x3 result

Subtract(ref Matrix3x3, ref Matrix3x3, out Matrix3x3)

Subtracts matrices.

Declaration
public static void Subtract(ref Matrix3x3 matrix1, ref Matrix3x3 matrix2, out Matrix3x3 result)
Parameters
Type Name Description
Matrix3x3 matrix1

Source matrix.

Matrix3x3 matrix2

Source matrix.

Matrix3x3 result

[OutAttribute] Result of the subtraction.

ToString()

Retrieves a string representation of the current object.

Declaration
public override string ToString()
Returns
Type Description
System.String

Transform(ref Matrix3x3, ref Quaternion, out Matrix3x3)

Transforms a Matrix3x3 by applying a Quaternion rotation.

Declaration
public static void Transform(ref Matrix3x3 value, ref Quaternion rotation, out Matrix3x3 result)
Parameters
Type Name Description
Matrix3x3 value

The Matrix3x3 to transform.

Quaternion rotation

The rotation to apply, expressed as a Quaternion.

Matrix3x3 result

[OutAttribute] An existing Matrix3x3 filled in with the result of the transform.

Transpose()

Declaration
public void Transpose()

Transpose(ref Matrix3x3, out Matrix3x3)

Transposes the rows and columns of a matrix.

Declaration
public static void Transpose(ref Matrix3x3 matrix, out Matrix3x3 result)
Parameters
Type Name Description
Matrix3x3 matrix

Source matrix.

Matrix3x3 result

[OutAttribute] Transposed matrix.

☀
☾
In This Article
Back to top
Generated by DocFX
☀
☾