Type VMatrix

VMatrix

Methods

add( matrix ) Adds the given matrix component-wise to this matrix.
getAngles() Returns the matrix's angles
getField( row, column ) Returns the value in the given row and column.
getForward() Returns the forward direction of the matrix.
getInverse() Returns the inverse matrix of the given matrix.
getInverseTR() Returns the inverse matrix of the given matrix.
getRight() Returns the right direction of the matrix.
getScale() Returns the matrix's scale
getTranslation() Returns the matrix's translation
getTransposed() Returns a copy of the matrix with its rows tranposed (every row becomes a column).
getUp() Returns the up direction of the matrix.
identity() Resets the matrix's values to the identity matrix.
invert() Inverts the given matrix, modifying in-place.
invertTR() Inverts the given matrix, modifying in-place.
isIdentity() Returns whether the given matrix is the identity matrix.
isRotationMatrix() Returns whether the given matrix is a "rotation matrix".
mul( matrix ) Post-multiplies this matrix by the given matrix (i.e. self * matrix), setting this matrix's fields to the result.
rotate( ang ) Rotates the matrix by the given angle.
scale( scale ) Scales the matrix by the given vector scale.
scaleTranslation( scale ) Scales the absolute translation of the matrix by the given scale.
set( matrix ) Copies the values from the given matrix object to self.
setAngles( ang ) Sets the angles of the matrix.
setField( row, column, value ) Sets the value at the given row and column.
setForward( forward ) Sets the forward direction of the matrix.
setRight( right ) Sets the right direction of the matrix.
setScale( scale ) Sets the scale of the matrix (the 3 diagonal values).
setTranslation( translation ) Sets the translation (the first 3 rows of the 4th column).
setUnpacked( row1Column1, row1Column2, row1Column3, row1Column4, row2Column1, row2Column2, row2Column3, row2Column4, row3Column1, row3Column2, row3Column3, row3Column4, row4Column1, row4Column2, row4Column3, row4Column4 ) Sets the values of all fields in the matrix.
setUp( up ) Sets the up direction of the matrix.
sub( matrix ) Subtracts the given matrix component-wise from this matrix.
toTable() Returns a 4x4 table representing the values of the matrix.
translate( translation ) Translates the matrix by the given amount.
transpose() Tranposes the matrix (every row becomes a column), modifying in-place.
unpack() Returns all fields in the matrix.


Methods

VMatrix:add( matrix )
Adds the given matrix component-wise to this matrix.

Environment:

Shared

Parameters:

  • (VMatrix) matrix: The matrix to add to this matrix.

Return value:

    (VMatrix) This matrix.
VMatrix:getAngles()
Returns the matrix's angles

Environment:

Shared
VMatrix:getField( row, column )
Returns the value in the given row and column. There are 4 rows and 4 columns.

Environment:

Shared

Parameters:

  • (number) row: The row to retrieve the value from.
  • (number) column: The column to retrieve the value from.

Return value:

    (number) The number value at the given row and column.
VMatrix:getForward()
Returns the forward direction of the matrix. This is the first column of the matrix excluding the 4th component.

Environment:

Shared

Return value:

    (Vector) A vector representing the forward direction.
VMatrix:getInverse()
Returns the inverse matrix of the given matrix. This operation will fail for matrices with determinant close to or equal to 0.

Environment:

Shared

Return value:

    (VMatrix | nil) The matrix representing the inverse of the given matrix, or nil if the inverse could not be computed.
VMatrix:getInverseTR()
Returns the inverse matrix of the given matrix. This function will not fail, but only works correctly on matrices that contain only translation and/or rotation.

Environment:

Shared

Return value:

    (VMatrix) The matrix representing the inverse of the given matrix, assumming the matrix was not scaled.
VMatrix:getRight()
Returns the right direction of the matrix. This is the second column of the matrix excluding the 4th component.

Environment:

Shared

Return value:

    (Vector) A vector representing the right direction.
VMatrix:getScale()
Returns the matrix's scale

Environment:

Shared
VMatrix:getTranslation()
Returns the matrix's translation

Environment:

Shared
VMatrix:getTransposed()
Returns a copy of the matrix with its rows tranposed (every row becomes a column).

Environment:

Shared
VMatrix:getUp()
Returns the up direction of the matrix. This is the third column of the matrix excluding the 4th component.

Environment:

Shared

Return value:

    (Vector) A vector representing the up direction.
VMatrix:identity()
Resets the matrix's values to the identity matrix. Modifies the given matrix directly.

Environment:

Shared

Return value:

    (VMatrix) This matrix.
VMatrix:invert()
Inverts the given matrix, modifying in-place. This operation will fail for matrices with determinant close to or equal to 0. If it does fail, the matrix is not modified.

Environment:

Shared

Return value:

    (VMatrix) This matrix.
VMatrix:invertTR()
Inverts the given matrix, modifying in-place. This function will not fail, but only works correctly on matrices that contain only translation and/or rotation.

Environment:

Shared

Return value:

    (VMatrix) This matrix.
VMatrix:isIdentity()
Returns whether the given matrix is the identity matrix.

Environment:

Shared

Return value:

    (boolean) True if the matrix is the identity matrix, false otherwise.
VMatrix:isRotationMatrix()
Returns whether the given matrix is a "rotation matrix". This checks whether the forward, right and up directions are orthogonal and normalised to 1.

Environment:

Shared
VMatrix:mul( matrix )
Post-multiplies this matrix by the given matrix (i.e. self * matrix), setting this matrix's fields to the result.

Environment:

Shared

Parameters:

  • (VMatrix) matrix: The matrix to post-multiply by.

Return value:

    (VMatrix) This matrix.
VMatrix:rotate( ang )
Rotates the matrix by the given angle. This is equivalent to post-multiplying by a rotation matrix, but without creating a new matrix object.

Environment:

Shared

Parameters:

  • (Angle) ang: Angle to rotate by.

Return value:

    (VMatrix) This matrix.
VMatrix:scale( scale )
Scales the matrix by the given vector scale. This is equivalent to post-multiplying by a scaled matrix, but without creating a new matrix object.

Environment:

Shared

Parameters:

  • (Vector) scale: Scale vector.

Return value:

    (VMatrix) This matrix.
VMatrix:scaleTranslation( scale )
Scales the absolute translation of the matrix by the given scale.

Environment:

Shared

Parameters:

  • (number) scale: Amount to scale by.

Return value:

    (VMatrix) This matrix.
VMatrix:set( matrix )
Copies the values from the given matrix object to self.

Environment:

Shared

Parameters:

  • (VMatrix) matrix: The matrix to copy values from.

Return value:

    (VMatrix) This matrix.
VMatrix:setAngles( ang )
Sets the angles of the matrix.

Environment:

Shared

Parameters:

  • (Angle) ang: New angles.

Return value:

    (VMatrix) This matrix.
VMatrix:setField( row, column, value )
Sets the value at the given row and column.

Environment:

Shared

Parameters:

  • (number) row: The row to change the value of.
  • (number) column: The column to change the value of.
  • (number) value: The value to set.

Return value:

    (VMatrix) This matrix.
VMatrix:setForward( forward )
Sets the forward direction of the matrix. This changes the first 3 values in the first column of the matrix.

Environment:

Shared

Parameters:

  • (Vector) forward: The forward direction vector.

Return value:

    (VMatrix) This matrix.
VMatrix:setRight( right )
Sets the right direction of the matrix. This changes the first 3 values in the second column of the matrix.

Environment:

Shared

Parameters:

  • (Vector) right: The right direction vector.

Return value:

    (VMatrix) This matrix.
VMatrix:setScale( scale )
Sets the scale of the matrix (the 3 diagonal values).

Environment:

Shared

Parameters:

  • (Vector) scale: The new scale.

Return value:

    (VMatrix) This matrix.
VMatrix:setTranslation( translation )
Sets the translation (the first 3 rows of the 4th column).

Environment:

Shared

Parameters:

  • (Vector) translation: New translation

Return value:

    (VMatrix) This matrix.
VMatrix:setUnpacked( row1Column1, row1Column2, row1Column3, row1Column4, row2Column1, row2Column2, row2Column3, row2Column4, row3Column1, row3Column2, row3Column3, row3Column4, row4Column1, row4Column2, row4Column3, row4Column4 )
Sets the values of all fields in the matrix.

Environment:

Shared

Parameters:

  • (number) row1Column1: The value for row 1, column 1
  • (number) row1Column2: The value for row 1, column 2
  • (number) row1Column3: The value for row 1, column 3
  • (number) row1Column4: The value for row 1, column 4
  • (number) row2Column1: The value for row 2, column 1
  • (number) row2Column2: The value for row 2, column 2
  • (number) row2Column3: The value for row 2, column 3
  • (number) row2Column4: The value for row 2, column 4
  • (number) row3Column1: The value for row 3, column 1
  • (number) row3Column2: The value for row 3, column 2
  • (number) row3Column3: The value for row 3, column 3
  • (number) row3Column4: The value for row 3, column 4
  • (number) row4Column1: The value for row 4, column 1
  • (number) row4Column2: The value for row 4, column 2
  • (number) row4Column3: The value for row 4, column 3
  • (number) row4Column4: The value for row 4, column 4

Return value:

    (VMatrix) This matrix.
VMatrix:setUp( up )
Sets the up direction of the matrix. This changes the first 3 values in the third column of the matrix.

Environment:

Shared

Parameters:

  • (Vector) up: The up direction vector.

Return value:

    (VMatrix) This matrix.
VMatrix:sub( matrix )
Subtracts the given matrix component-wise from this matrix.

Environment:

Shared

Parameters:

  • (VMatrix) matrix: The matrix to subtract from this matrix.

Return value:

    (VMatrix) This matrix.
VMatrix:toTable()
Returns a 4x4 table representing the values of the matrix.

Environment:

Shared

Return value:

    (table>) Table containing 4 tables representing the rows of the matrix.
VMatrix:translate( translation )
Translates the matrix by the given amount. This is equivalent to post-multiplying by a translation matrix, but without creating a new matrix object.

Environment:

Shared

Parameters:

  • (Vector) translation: Vector to translate by.

Return value:

    (VMatrix) This matrix.
VMatrix:transpose()
Tranposes the matrix (every row becomes a column), modifying in-place.

Environment:

Shared

Return value:

    (VMatrix) This matrix.
VMatrix:unpack()
Returns all fields in the matrix.

Environment:

Shared

Return values:

  1. (number) Row 1, column 1
  2. (number) Row 1, column 2
  3. (number) Row 1, column 3
  4. (number) Row 1, column 4
  5. (number) Row 2, column 1
  6. (number) Row 2, column 2
  7. (number) Row 2, column 3
  8. (number) Row 2, column 4
  9. (number) Row 3, column 1
  10. (number) Row 3, column 2
  11. (number) Row 3, column 3
  12. (number) Row 3, column 4
  13. (number) Row 4, column 1
  14. (number) Row 4, column 2
  15. (number) Row 4, column 3
  16. (number) Row 4, column 4

Valid XHTML 1.0!