SHVDN  v3
An ASI plugin for Grand Theft Auto V, which allows running scripts written in any .NET language in-game. Developed by crosire https://github.com/crosire/scripthookvdotnet/
GTA.Math.Matrix Struct Reference

Defines a 4x4 matrix. More...

Inheritance diagram for GTA.Math.Matrix:

Public Member Functions

 Matrix (float[] values)
 Initializes a new instance of the Matrix structure. More...
 
float Determinant ()
 Calculates the determinant of the matrix. More...
 
float Det3x3 (float M11, float M12, float M13, float M21, float M22, float M23, float M31, float M32, float M33)
 
void Invert ()
 Inverts the matrix. More...
 
Vector3 TransformPoint (Vector3 point)
 Apply the transformation matrix to a point in world space More...
 
Vector3 InverseTransformPoint (Vector3 point)
 Calculates the position of a point before this transformation matrix gets applied More...
 
float[] ToArray ()
 Converts the matrix to an array of floats. More...
 
override string ToString ()
 Converts the value of the object to its equivalent string representation. More...
 
string ToString (string format)
 Converts the value of the object to its equivalent string representation. More...
 
override int GetHashCode ()
 Returns the hash code for this instance. More...
 
override bool Equals (object obj)
 Returns a value that indicates whether the current instance is equal to a specified object. More...
 
bool Equals (Matrix other)
 Returns a value that indicates whether the current instance is equal to the specified object. More...
 

Static Public Member Functions

static Matrix Add (Matrix left, Matrix right)
 Determines the sum of two matrices. More...
 
static Matrix Subtract (Matrix left, Matrix right)
 Determines the difference between two matrices. More...
 
static Matrix Multiply (Matrix left, Matrix right)
 Determines the product of two matrices. More...
 
static Matrix Multiply (Matrix left, float right)
 Scales a matrix by the given value. More...
 
static Matrix Divide (Matrix left, Matrix right)
 Determines the quotient of two matrices. More...
 
static Matrix Divide (Matrix left, float right)
 Scales a matrix by the given value. More...
 
static Matrix Negate (Matrix matrix)
 Negates a matrix. More...
 
static Matrix Invert (Matrix matrix)
 Calculates the inverse of a matrix if it exists. More...
 
static Matrix Lerp (Matrix start, Matrix end, float amount)
 Performs a linear interpolation between two matrices. More...
 
static Matrix RotationX (float angle)
 Creates a matrix that rotates around the x-axis. More...
 
static Matrix RotationY (float angle)
 Creates a matrix that rotates around the y-axis. More...
 
static Matrix RotationZ (float angle)
 Creates a matrix that rotates around the z-axis. More...
 
static Matrix RotationAxis (Vector3 axis, float angle)
 Creates a matrix that rotates around an arbitrary axis. More...
 
static Matrix RotationQuaternion (Quaternion rotation)
 Creates a rotation matrix from a rotation. More...
 
static Matrix RotationYawPitchRoll (float yaw, float pitch, float roll)
 Creates a rotation matrix with a specified yaw, pitch, and roll. More...
 
static Matrix Scaling (float x, float y, float z)
 Creates a matrix that scales along the x-axis, y-axis, and y-axis. More...
 
static Matrix Scaling (Vector3 scale)
 Creates a matrix that scales along the x-axis, y-axis, and y-axis. More...
 
static Matrix Translation (float x, float y, float z)
 Creates a translation matrix using the specified offsets. More...
 
static Matrix Translation (Vector3 amount)
 Creates a translation matrix using the specified offsets. More...
 
static Matrix Transpose (Matrix matrix)
 Calculates the transpose of the specified matrix. More...
 
static Matrix operator- (Matrix matrix)
 Negates a matrix. More...
 
static Matrix operator+ (Matrix left, Matrix right)
 Adds two matrices. More...
 
static Matrix operator- (Matrix left, Matrix right)
 Subtracts two matrices. More...
 
static Matrix operator/ (Matrix left, Matrix right)
 Divides two matrices. More...
 
static Matrix operator/ (Matrix left, float right)
 Scales a matrix by a given value. More...
 
static Matrix operator* (Matrix left, Matrix right)
 Multiplies two matrices. More...
 
static Matrix operator* (Matrix left, float right)
 Scales a matrix by a given value. More...
 
static Matrix operator* (float left, Matrix right)
 Scales a matrix by a given value. More...
 
static bool operator== (Matrix left, Matrix right)
 Tests for equality between two objects. More...
 
static bool operator!= (Matrix left, Matrix right)
 Tests for inequality between two objects. More...
 

Public Attributes

float M11
 Gets or sets the element of the matrix that exists in the first row and first column. More...
 
float M12
 Gets or sets the element of the matrix that exists in the first row and second column. More...
 
float M13
 Gets or sets the element of the matrix that exists in the first row and third column. More...
 
float M14
 Gets or sets the element of the matrix that exists in the first row and fourth column. More...
 
float M21
 Gets or sets the element of the matrix that exists in the second row and first column. More...
 
float M22
 Gets or sets the element of the matrix that exists in the second row and second column. More...
 
float M23
 Gets or sets the element of the matrix that exists in the second row and third column. More...
 
float M24
 Gets or sets the element of the matrix that exists in the second row and fourth column. More...
 
float M31
 Gets or sets the element of the matrix that exists in the third row and first column. More...
 
float M32
 Gets or sets the element of the matrix that exists in the third row and second column. More...
 
float M33
 Gets or sets the element of the matrix that exists in the third row and third column. More...
 
float M34
 Gets or sets the element of the matrix that exists in the third row and fourth column. More...
 
float M41
 Gets or sets the element of the matrix that exists in the fourth row and first column. More...
 
float M42
 Gets or sets the element of the matrix that exists in the fourth row and second column. More...
 
float M43
 Gets or sets the element of the matrix that exists in the fourth row and third column. More...
 
float M44
 Gets or sets the element of the matrix that exists in the fourth row and fourth column. More...
 
bool IsIdentity => Equals(Identity)
 Gets a value indicating whether this instance is an identity matrix. More...
 
bool HasInverse => Determinant() != 0.0f
 Gets a value indicating whether this instance has an inverse matrix. More...
 

Static Public Attributes

static Matrix Zero => new Matrix()
 A Matrix with all of its components set to zero. More...
 
static Matrix Identity => new Matrix() { M11 = 1.0f, M22 = 1.0f, M33 = 1.0f, M44 = 1.0f }
 The identity Matrix. More...
 

Properties

float this[int index] [get, set]
 Gets or sets the component at the specified index. More...
 
float this[int row, int column] [get, set]
 Gets or sets the component at the specified index. More...
 

Detailed Description

Defines a 4x4 matrix.

Constructor & Destructor Documentation

◆ Matrix()

GTA.Math.Matrix.Matrix ( float[]  values)

Initializes a new instance of the Matrix structure.

Parameters
valuesThe values to assign to the components of the matrix. This must be an array with sixteen elements.
Exceptions
ArgumentNullExceptionThrown when values is null.
ArgumentOutOfRangeExceptionThrown when values contains more or less than sixteen elements.

Member Function Documentation

◆ Add()

static Matrix GTA.Math.Matrix.Add ( Matrix  left,
Matrix  right 
)
static

Determines the sum of two matrices.

Parameters
leftThe first matrix to add.
rightThe second matrix to add.
Returns
The sum of the two matrices.

◆ Det3x3()

float GTA.Math.Matrix.Det3x3 ( float  M11,
float  M12,
float  M13,
float  M21,
float  M22,
float  M23,
float  M31,
float  M32,
float  M33 
)

◆ Determinant()

float GTA.Math.Matrix.Determinant ( )

Calculates the determinant of the matrix.

Returns
The determinant of the matrix.

◆ Divide() [1/2]

static Matrix GTA.Math.Matrix.Divide ( Matrix  left,
float  right 
)
static

Scales a matrix by the given value.

Parameters
leftThe matrix to scale.
rightThe amount by which to scale.
Returns
The scaled matrix.

◆ Divide() [2/2]

static Matrix GTA.Math.Matrix.Divide ( Matrix  left,
Matrix  right 
)
static

Determines the quotient of two matrices.

Parameters
leftThe first matrix to divide.
rightThe second matrix to divide.
Returns
The quotient of the two matrices.

◆ Equals() [1/2]

bool GTA.Math.Matrix.Equals ( Matrix  other)

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

Parameters
otherObject to make the comparison with.
Returns
true if the current instance is equal to the specified object; false otherwise.

◆ Equals() [2/2]

override bool GTA.Math.Matrix.Equals ( object  obj)

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

Parameters
objObject to make the comparison with.
Returns
true if the current instance is equal to the specified object; false otherwise.

◆ GetHashCode()

override int GTA.Math.Matrix.GetHashCode ( )

Returns the hash code for this instance.

Returns
A 32-bit signed integer hash code.

◆ InverseTransformPoint()

Vector3 GTA.Math.Matrix.InverseTransformPoint ( Vector3  point)

Calculates the position of a point before this transformation matrix gets applied

Parameters
pointThe transformed vertex location
Returns
The original vertex location before being transformed by the given Matrix

◆ Invert() [1/2]

void GTA.Math.Matrix.Invert ( )

Inverts the matrix.

◆ Invert() [2/2]

static Matrix GTA.Math.Matrix.Invert ( Matrix  matrix)
static

Calculates the inverse of a matrix if it exists.

Returns
The inverse of the matrix.

◆ Lerp()

static Matrix GTA.Math.Matrix.Lerp ( Matrix  start,
Matrix  end,
float  amount 
)
static

Performs a linear interpolation between two matrices.

Parameters
startStart matrix.
endEnd matrix.
amountValue between 0 and 1 indicating the weight of end .
Returns
The linear interpolation of the two matrices.

This method performs the linear interpolation based on the following formula.

start + (end - start) * amount

Passing amount a value of 0 will cause start to be returned; a value of 1 will cause end to be returned.

◆ Multiply() [1/2]

static Matrix GTA.Math.Matrix.Multiply ( Matrix  left,
float  right 
)
static

Scales a matrix by the given value.

Parameters
leftThe matrix to scale.
rightThe amount by which to scale.
Returns
The scaled matrix.

◆ Multiply() [2/2]

static Matrix GTA.Math.Matrix.Multiply ( Matrix  left,
Matrix  right 
)
static

Determines the product of two matrices.

Parameters
leftThe first matrix to multiply.
rightThe second matrix to multiply.
Returns
The product of the two matrices.

◆ Negate()

static Matrix GTA.Math.Matrix.Negate ( Matrix  matrix)
static

Negates a matrix.

Parameters
matrixThe matrix to be negated.
Returns
The negated matrix.

◆ operator!=()

static bool GTA.Math.Matrix.operator!= ( Matrix  left,
Matrix  right 
)
static

Tests for inequality between two objects.

Parameters
leftThe first value to compare.
rightThe second value to compare.
Returns
true if left has a different value than right ; otherwise, false.

◆ operator*() [1/3]

static Matrix GTA.Math.Matrix.operator* ( float  left,
Matrix  right 
)
static

Scales a matrix by a given value.

Parameters
rightThe matrix to scale.
leftThe amount by which to scale.
Returns
The scaled matrix.

◆ operator*() [2/3]

static Matrix GTA.Math.Matrix.operator* ( Matrix  left,
float  right 
)
static

Scales a matrix by a given value.

Parameters
leftThe matrix to scale.
rightThe amount by which to scale.
Returns
The scaled matrix.

◆ operator*() [3/3]

static Matrix GTA.Math.Matrix.operator* ( Matrix  left,
Matrix  right 
)
static

Multiplies two matrices.

Parameters
leftThe first matrix to multiply.
rightThe second matrix to multiply.
Returns
The product of the two matrices.

◆ operator+()

static Matrix GTA.Math.Matrix.operator+ ( Matrix  left,
Matrix  right 
)
static

Adds two matrices.

Parameters
leftThe first matrix to add.
rightThe second matrix to add.
Returns
The sum of the two matrices.

◆ operator-() [1/2]

static Matrix GTA.Math.Matrix.operator- ( Matrix  left,
Matrix  right 
)
static

Subtracts two matrices.

Parameters
leftThe first matrix to subtract.
rightThe second matrix to subtract.
Returns
The difference between the two matrices.

◆ operator-() [2/2]

static Matrix GTA.Math.Matrix.operator- ( Matrix  matrix)
static

Negates a matrix.

Parameters
matrixThe matrix to negate.
Returns
The negated matrix.

◆ operator/() [1/2]

static Matrix GTA.Math.Matrix.operator/ ( Matrix  left,
float  right 
)
static

Scales a matrix by a given value.

Parameters
leftThe matrix to scale.
rightThe amount by which to scale.
Returns
The scaled matrix.

◆ operator/() [2/2]

static Matrix GTA.Math.Matrix.operator/ ( Matrix  left,
Matrix  right 
)
static

Divides two matrices.

Parameters
leftThe first matrix to divide.
rightThe second matrix to divide.
Returns
The quotient of the two matrices.

◆ operator==()

static bool GTA.Math.Matrix.operator== ( Matrix  left,
Matrix  right 
)
static

Tests for equality between two objects.

Parameters
leftThe first value to compare.
rightThe second value to compare.
Returns
true if left has the same value as right ; otherwise, false.

◆ RotationAxis()

static Matrix GTA.Math.Matrix.RotationAxis ( Vector3  axis,
float  angle 
)
static

Creates a matrix that rotates around an arbitrary axis.

Parameters
axisThe axis around which to rotate.
angleAngle of rotation in radians. Angles are measured clockwise when looking along the rotation axis toward the origin.
Returns
The created rotation matrix.

◆ RotationQuaternion()

static Matrix GTA.Math.Matrix.RotationQuaternion ( Quaternion  rotation)
static

Creates a rotation matrix from a rotation.

Parameters
rotationThe quaternion to use to build the matrix.
Returns
The created rotation matrix.

◆ RotationX()

static Matrix GTA.Math.Matrix.RotationX ( float  angle)
static

Creates a matrix that rotates around the x-axis.

Parameters
angleAngle of rotation in radians. Angles are measured clockwise when looking along the rotation axis toward the origin.
Returns
The created rotation matrix.

◆ RotationY()

static Matrix GTA.Math.Matrix.RotationY ( float  angle)
static

Creates a matrix that rotates around the y-axis.

Parameters
angleAngle of rotation in radians. Angles are measured clockwise when looking along the rotation axis toward the origin.
Returns
The created rotation matrix.

◆ RotationYawPitchRoll()

static Matrix GTA.Math.Matrix.RotationYawPitchRoll ( float  yaw,
float  pitch,
float  roll 
)
static

Creates a rotation matrix with a specified yaw, pitch, and roll.

Parameters
yawYaw around the y-axis, in radians.
pitchPitch around the x-axis, in radians.
rollRoll around the z-axis, in radians.
Returns
The created rotation matrix.

◆ RotationZ()

static Matrix GTA.Math.Matrix.RotationZ ( float  angle)
static

Creates a matrix that rotates around the z-axis.

Parameters
angleAngle of rotation in radians. Angles are measured clockwise when looking along the rotation axis toward the origin.
Returns
The created rotation matrix.

◆ Scaling() [1/2]

static Matrix GTA.Math.Matrix.Scaling ( float  x,
float  y,
float  z 
)
static

Creates a matrix that scales along the x-axis, y-axis, and y-axis.

Parameters
xScaling factor that is applied along the x-axis.
yScaling factor that is applied along the y-axis.
zScaling factor that is applied along the z-axis.
Returns
The created scaling matrix.

◆ Scaling() [2/2]

static Matrix GTA.Math.Matrix.Scaling ( Vector3  scale)
static

Creates a matrix that scales along the x-axis, y-axis, and y-axis.

Parameters
scaleScaling factor for all three axes.
Returns
The created scaling matrix.

◆ Subtract()

static Matrix GTA.Math.Matrix.Subtract ( Matrix  left,
Matrix  right 
)
static

Determines the difference between two matrices.

Parameters
leftThe first matrix to subtract.
rightThe second matrix to subtract.
Returns
The difference between the two matrices.

◆ ToArray()

float [] GTA.Math.Matrix.ToArray ( )

Converts the matrix to an array of floats.

◆ ToString() [1/2]

override string GTA.Math.Matrix.ToString ( )

Converts the value of the object to its equivalent string representation.

Returns
The string representation of the value of this instance.

◆ ToString() [2/2]

string GTA.Math.Matrix.ToString ( string  format)

Converts the value of the object to its equivalent string representation.

Parameters
formatThe format.
Returns
The string representation of the value of this instance.

◆ TransformPoint()

Vector3 GTA.Math.Matrix.TransformPoint ( Vector3  point)

Apply the transformation matrix to a point in world space

Parameters
pointThe original vertex location
Returns
The vertex location transformed by the given Matrix

◆ Translation() [1/2]

static Matrix GTA.Math.Matrix.Translation ( float  x,
float  y,
float  z 
)
static

Creates a translation matrix using the specified offsets.

Parameters
xX-coordinate offset.
yY-coordinate offset.
zZ-coordinate offset.
Returns
The created translation matrix.

◆ Translation() [2/2]

static Matrix GTA.Math.Matrix.Translation ( Vector3  amount)
static

Creates a translation matrix using the specified offsets.

Parameters
amountThe offset for all three coordinate planes.
Returns
The created translation matrix.

◆ Transpose()

static Matrix GTA.Math.Matrix.Transpose ( Matrix  matrix)
static

Calculates the transpose of the specified matrix.

Parameters
matrixThe matrix whose transpose is to be calculated.
Returns
The transpose of the specified matrix.

Member Data Documentation

◆ HasInverse

bool GTA.Math.Matrix.HasInverse => Determinant() != 0.0f

Gets a value indicating whether this instance has an inverse matrix.

◆ Identity

Matrix GTA.Math.Matrix.Identity => new Matrix() { M11 = 1.0f, M22 = 1.0f, M33 = 1.0f, M44 = 1.0f }
static

The identity Matrix.

◆ IsIdentity

bool GTA.Math.Matrix.IsIdentity => Equals(Identity)

Gets a value indicating whether this instance is an identity matrix.

true if this instance is an identity matrix; otherwise, false.

◆ M11

float GTA.Math.Matrix.M11

Gets or sets the element of the matrix that exists in the first row and first column.

◆ M12

float GTA.Math.Matrix.M12

Gets or sets the element of the matrix that exists in the first row and second column.

◆ M13

float GTA.Math.Matrix.M13

Gets or sets the element of the matrix that exists in the first row and third column.

◆ M14

float GTA.Math.Matrix.M14

Gets or sets the element of the matrix that exists in the first row and fourth column.

◆ M21

float GTA.Math.Matrix.M21

Gets or sets the element of the matrix that exists in the second row and first column.

◆ M22

float GTA.Math.Matrix.M22

Gets or sets the element of the matrix that exists in the second row and second column.

◆ M23

float GTA.Math.Matrix.M23

Gets or sets the element of the matrix that exists in the second row and third column.

◆ M24

float GTA.Math.Matrix.M24

Gets or sets the element of the matrix that exists in the second row and fourth column.

◆ M31

float GTA.Math.Matrix.M31

Gets or sets the element of the matrix that exists in the third row and first column.

◆ M32

float GTA.Math.Matrix.M32

Gets or sets the element of the matrix that exists in the third row and second column.

◆ M33

float GTA.Math.Matrix.M33

Gets or sets the element of the matrix that exists in the third row and third column.

◆ M34

float GTA.Math.Matrix.M34

Gets or sets the element of the matrix that exists in the third row and fourth column.

◆ M41

float GTA.Math.Matrix.M41

Gets or sets the element of the matrix that exists in the fourth row and first column.

◆ M42

float GTA.Math.Matrix.M42

Gets or sets the element of the matrix that exists in the fourth row and second column.

◆ M43

float GTA.Math.Matrix.M43

Gets or sets the element of the matrix that exists in the fourth row and third column.

◆ M44

float GTA.Math.Matrix.M44

Gets or sets the element of the matrix that exists in the fourth row and fourth column.

◆ Zero

Matrix GTA.Math.Matrix.Zero => new Matrix()
static

A Matrix with all of its components set to zero.

Property Documentation

◆ this[int index]

float GTA.Math.Matrix.this[int index]
getset

Gets or sets the component at the specified index.

The value of the matrix component, depending on the index.

Parameters
indexThe zero-based index of the component to access.
Returns
The value of the component at the specified index.
Exceptions
System.ArgumentOutOfRangeExceptionThrown when the index is out of the range [0, 15].

◆ this[int row, int column]

float GTA.Math.Matrix.this[int row, int column]
getset

Gets or sets the component at the specified index.

The value of the matrix component, depending on the index.

Parameters
rowThe row of the matrix to access.
columnThe column of the matrix to access.
Returns
The value of the component at the specified index.
Exceptions
System.ArgumentOutOfRangeExceptionThrown when the row or column is out of the range [0, 3].

The documentation for this struct was generated from the following file: