VMatrix
A 4x4 matrix.
This page lists 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 or Vector 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] . |
|
__unm |
Returns new VMatrix with the result of negation. |
Methods
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.
Gets the right direction of the matrix.
ie. The second column of the matrix, negated, excluding the w coordinate.
Vector VMatrix:GetTranslation()
Returns the absolute translation of the matrix.
VMatrix VMatrix:GetTransposed()
Returns the transpose (each row becomes a column) of this matrix.
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.
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.
Checks whenever all fields of the matrix are 0, aka if this is a null matrix.
Rotates the matrix by the given angle.
Postmultiplies the matrix by a rotation matrix (A = AR).
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:SetForward( Vector forward )
Sets the forward direction of the matrix.
ie. The first column of the matrix, excluding the w coordinate.
Sets the right direction of the matrix.
ie. The second column of the matrix, negated, excluding the w coordinate.
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.
Sets the up direction of the matrix.
ie. The third column of the matrix, excluding the w coordinate.
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.