Libraries.Compute.Matrix4 Documentation
Matrix4 is a class representing a 4x4 matrix.
Example Code
use Libraries.Compute.Matrix4
Matrix4 matrix
matrix:Set(2, 5, 0, 0, 1, 3, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)
matrix:Inverse()
number row0column0 = matrix:row0column0
number row0column1 = matrix:row0column1
number row0column2 = matrix:row0column2
number row0column3 = matrix:row0column3
number row1column0 = matrix:row1column0
number row1column1 = matrix:row1column1
number row1column2 = matrix:row1column2
number row1column3 = matrix:row1column3
number row2column0 = matrix:row2column0
number row2column1 = matrix:row2column1
number row2column2 = matrix:row2column2
number row2column3 = matrix:row2column3
number row3column0 = matrix:row3column0
number row3column1 = matrix:row3column1
number row3column2 = matrix:row3column2
number row3column3 = matrix:row3column3
output "The new matrix is:"
output "|" + row0column0 + ", " + row0column1 + ", " + row0column2 + ", " + row0column3 + "|"
output "|" + row1column0 + ", " + row1column1 + ", " + row1column2 + ", " + row1column3 + "|"
output "|" + row2column0 + ", " + row2column1 + ", " + row2column2 + ", " + row2column3 + "|"
output "|" + row3column0 + ", " + row3column1 + ", " + row3column2 + ", " + row3column3 + "|"
Inherits from: Libraries.Language.Object
Variables Table
Variables | Description |
---|---|
number row2column0 | |
number row0column3 | |
number row1column0 | |
number row3column1 | |
number row1column2 | |
number row3column2 | |
number row0column1 | |
number row3column3 | |
number row2column2 | |
number row2column1 | |
number row3column0 | |
number row0column2 | |
number row0column0 | |
number row1column3 | |
number row2column3 | |
number row1column1 |
Actions Documentation
Average(Libraries.Compute.Matrix4 other, number weight)
This action averages the matrix with the passed matrix. Translations and scales are done via a linear interpolation and rotations are done via a spherical linear interpolation.
Parameters
- Libraries.Compute.Matrix4: The other matrix to average
- number weight: The weight of this transformation matrix
Return
Libraries.Compute.Matrix4: The matrix after averaging
Example
use Libraries.Compute.Matrix4
Matrix4 matrix
Matrix4 other
matrix:Set(2, 0, 3, 1, 0, 2, 1, 1, 0, 0, 2, 1, 0, 0, 0, 1)
other:Set(4, 0, 6, 2, 0, 4, 2, 2, 0, 0, 4, 2, 0, 0, 0, 2)
matrix:Average(other, 0.5)
number row0column0 = matrix:row0column0
number row0column1 = matrix:row0column1
number row0column2 = matrix:row0column2
number row0column3 = matrix:row0column3
number row1column0 = matrix:row1column0
number row1column1 = matrix:row1column1
number row1column2 = matrix:row1column2
number row1column3 = matrix:row1column3
number row2column0 = matrix:row2column0
number row2column1 = matrix:row2column1
number row2column2 = matrix:row2column2
number row2column3 = matrix:row2column3
number row3column0 = matrix:row3column0
number row3column1 = matrix:row3column1
number row3column2 = matrix:row3column2
number row3column3 = matrix:row3column3
output "The new matrix is:"
output "|" + row0column0 + ", " + row0column1 + ", " + row0column2 + ", " + row0column3 + "|"
output "|" + row1column0 + ", " + row1column1 + ", " + row1column2 + ", " + row1column3 + "|"
output "|" + row2column0 + ", " + row2column1 + ", " + row2column2 + ", " + row2column3 + "|"
output "|" + row3column0 + ", " + row3column1 + ", " + row3column2 + ", " + row3column3 + "|"
Compare(Libraries.Language.Object object)
This action compares two object hash codes and returns an integer. The result is larger if this hash code is larger than the object passed as a parameter, smaller, or equal. In this case, -1 means smaller, 0 means equal, and 1 means larger. This action was changed in Quorum 7 to return an integer, instead of a CompareResult object, because the previous implementation was causing efficiency issues.
Parameters
- Libraries.Language.Object: The object to compare to.
Return
integer: The Compare result, Smaller, Equal, or Larger.
Example
Object o
Object t
integer result = o:Compare(t) //1 (larger), 0 (equal), or -1 (smaller)
Copy()
This action creates a new matrix that is a copy of this matrix.
Return
Libraries.Compute.Matrix4: A new matrix that is a copy of this matrix
Example
use Libraries.Compute.Matrix4
Matrix4 matrix
Matrix4 copyMatrix
copyMatrix:Set(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15)
matrix = copyMatrix:Copy()
number row0column0 = matrix:row0column0
number row0column1 = matrix:row0column1
number row0column2 = matrix:row0column2
number row0column3 = matrix:row0column3
number row1column0 = matrix:row1column0
number row1column1 = matrix:row1column1
number row1column2 = matrix:row1column2
number row1column3 = matrix:row1column3
number row2column0 = matrix:row2column0
number row2column1 = matrix:row2column1
number row2column2 = matrix:row2column2
number row2column3 = matrix:row2column3
number row3column0 = matrix:row3column0
number row3column1 = matrix:row3column1
number row3column2 = matrix:row3column2
number row3column3 = matrix:row3column3
output "The new matrix is:"
output "|" + row0column0 + ", " + row0column1 + ", " + row0column2 + ", " + row0column3 + "|"
output "|" + row1column0 + ", " + row1column1 + ", " + row1column2 + ", " + row1column3 + "|"
output "|" + row2column0 + ", " + row2column1 + ", " + row2column2 + ", " + row2column3 + "|"
output "|" + row3column0 + ", " + row3column1 + ", " + row3column2 + ", " + row3column3 + "|"
Determinant()
This action computes the determinant of the matrix.
Return
number: The determinant of the matrix
Example
use Libraries.Compute.Matrix4
Matrix4 matrix
matrix:Set(2, 5, 0, 0, 1, 3, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)
number determinant = matrix:Determinant()
output "The determinant is " + determinant
Determinant3x3()
This action computes the determinant of the 3x3 matrix composed of the first three rows and first three columns of the 4x4 matrix.
Return
number: The determinant of the 3x3 upper left matrix
Example
use Libraries.Compute.Matrix4
Matrix4 matrix
matrix:Set(2, 5, 0, 0, 1, 3, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)
number determinant3x3 = matrix:Determinant3x3()
output "The determinant of the 3x3 upper left matrix is " + determinant3x3
Equals(Libraries.Language.Object object)
This action determines if two objects are equal based on their hash code values.
Parameters
- Libraries.Language.Object: The to be compared.
Return
boolean: True if the hash codes are equal and false if they are not equal.
Example
use Libraries.Language.Object
use Libraries.Language.Types.Text
Object o
Text t
boolean result = o:Equals(t)
GetElement(integer row, integer column)
This action will multiply the provided vectors by the given Matrix4 (which can be this Matrix4 object or any other Matrix4). The results are stored in the array of Vector3 objects provided.
Parameters
- integer row
- integer column
Return
number:
Example
use Libraries.Compute.Matrix4
use Libraries.Compute.Vector3
use Libraries.Containers.Array
Vector3 vectorA
Vector3 vectorB
Array<Vector3> array
Matrix4 matrix
vectorA:Set(3.0, 4.0, 2.0)
vectorB:Set(-0.5, 2.0, 0)
array:Add(vectorA)
array:Add(vectorB)
matrix:row0column0 = 2 * 3 / (100 - 0)
matrix:row0column1 = 0
matrix:row0column2 = (100 + 0) / (100 - 0)
matrix:row0column3 = 0
matrix:row1column0 = 0
matrix:row1column1 = 2 * 3 / (100 - 0)
matrix:row1column2 = (100 + 0) / (100 - 0)
matrix:row1column3 = 0
matrix:row2column0 = 0
matrix:row2column1 = 0
matrix:row2column2 = -1 * (10 + 3) / (10 - 3)
matrix:row2column3 = -2 * 10 * 3 / (10 - 3)
matrix:row3column0 = 0
matrix:row3column1 = 0
matrix:row3column2 = -1
matrix:row3column3 = 0
matrix:Project(matrix, array)
integer counter = 0
repeat array:GetSize() times
Vector3 vector = array:Get(counter)
number newX = vector:GetX()
number newY = vector:GetY()
number newZ = vector:GetZ()
output "The vector at array position " + counter + " is: [" + newX + ", " + newY + ", " + newZ + "]"
counter = counter + 1
end
GetHashCode()
This action gets the hash code for an object.
Return
integer: The integer hash code of the object.
Example
Object o
integer hash = o:GetHashCode()
GetRotation(boolean normalizeAxes)
This action gets the rotation of the matrix and returns it as a Quaternion.