Garry's Mod Wiki

VMatrix

List of all possible functions to manipulate matrices.

This object can be created by Matrix.

Metamethod Second Operand Description
__add VMatrix Returns new VMatrix with the result of addition.
__eq any Compares 2 operands, if they both are VMatrix, compares each individual component.
__mul VMatrix or Vector Returns new VMatrix with the result of multiplication.
__sub VMatrix Returns new VMatrix with the result of subtraction.
__tostring Returns a string in format [%f,\t%f,\t%f,\t%f]\n[%f,\t%f,\t%f,\t%f]\n[%f,\t%f,\t%f,\t%f]\n[%f,\t%f,\t%f,\t%f].

Methods

Angle VMatrix:GetAngles()
Returns the absolute rotation of the matrix.
number VMatrix:GetField( number row, number column )
Returns a specific field in the matrix.
Vector VMatrix:GetForward()
Gets the forward direction of the matrix. ie. The first column of the matrix, excluding the w coordinate.
VMatrix VMatrix:GetInverse()
Returns an inverted matrix without modifying the original matrix. Inverting the matrix will fail if its determinant is 0 or close to 0. (ie. its "scale" in any direction is 0.) See also VMatrix:GetInverseTR.
VMatrix VMatrix:GetInverseTR()
Returns an inverted matrix without modifying the original matrix. This function will not fail, but only works correctly on matrices that contain only translation and/or rotation. Using this function on a matrix with modified scale may return an incorrect inverted matrix. To get the inverse of a matrix that contains other modifications, see VMatrix:GetInverse.
Vector VMatrix:GetRight()
Gets the right direction of the matrix. ie. The second column of the matrix, negated, excluding the w coordinate.
Vector VMatrix:GetScale()
Returns the absolute scale of the matrix.
Vector VMatrix:GetTranslation()
Returns the absolute translation of the matrix.
Vector VMatrix:GetUp()
Gets the up direction of the matrix. ie. The third column of the matrix, excluding the w coordinate.
VMatrix:Identity()
Initializes the matrix as Identity matrix.
boolean VMatrix:Invert()
Inverts the matrix. Inverting the matrix will fail if its determinant is 0 or close to 0. (ie. its "scale" in any direction is 0.) If the matrix cannot be inverted, it does not get modified. See also VMatrix:InvertTR.
VMatrix:InvertTR()
Inverts the matrix. This function will not fail, but only works correctly on matrices that contain only translation and/or rotation. Using this function on a matrix with modified scale may return an incorrect inverted matrix. To invert a matrix that contains other modifications, see VMatrix:Invert.
boolean VMatrix:IsIdentity()
Returns whether the matrix is equal to Identity matrix or not.
boolean VMatrix:IsRotationMatrix()
Returns whether the matrix is a rotation matrix or not. Technically it checks if the forward, right and up vectors are orthogonal and normalized.
boolean VMatrix:IsZero()
Checks whenever all fields of the matrix are 0, aka if this is a null matrix.
VMatrix:Rotate( Angle rotation )
Rotates the matrix by the given angle. Postmultiplies the matrix by a rotation matrix (A = AR).
VMatrix:Scale( Vector scale )
Scales the matrix by the given vector. Postmultiplies the matrix by a scaling matrix (A = AS).
VMatrix:ScaleTranslation( number scale )
Scales the absolute translation with the given value.
VMatrix:Set( VMatrix src )
Copies values from the given matrix object.
VMatrix:SetAngles( Angle angle )
Sets the absolute rotation of the matrix.
VMatrix:SetField( number row, number column, number value )
Sets a specific field in the matrix.
VMatrix:SetForward( Vector forward )
Sets the forward direction of the matrix. ie. The first column of the matrix, excluding the w coordinate.
VMatrix:SetRight( Vector forward )
Sets the right direction of the matrix. ie. The second column of the matrix, negated, excluding the w coordinate.
VMatrix:SetScale( Vector scale )
Modifies the scale of the matrix while preserving the rotation and translation.
VMatrix:SetTranslation( Vector translation )
Sets the absolute translation of the matrix.
VMatrix:SetUnpacked( number e11, number e12, number e13, number e14, number e21, number e22, number e23, number e24, number e31, number e32, number e33, number e34, number e41, number e42, number e43, number e44 )
Sets each component of the matrix.
VMatrix:SetUp( Vector forward )
Sets the up direction of the matrix. ie. The third column of the matrix, excluding the w coordinate.
table VMatrix:ToTable()
Converts the matrix to a 4x4 table. See Matrix function.
VMatrix:Translate( Vector translation )
Translates the matrix by the given vector aka. adds the vector to the translation. Postmultiplies the matrix by a translation matrix (A = AT).
number, number, number, number, number, number, number, number, number, number, number, number, number, number, number, number VMatrix:Unpack()
Returns each component of the matrix, expanding rows before columns.
VMatrix:Zero()
Sets all components of the matrix to 0, also known as a null matrix. This function is more efficient than setting each element manually.

Page Links


Special Pages


Wikis

?

Render Time: 46ms

DB GetPage 6
Generate Html 15
SaveChanges (1) 9
Render Body 0
Render Sidebar 12