Libraries.Compute.Matrix3 Documentation
Matrix3 is a class representing a 3x3 matrix.
Example Code
use Libraries.Compute.Matrix3
Matrix3 matrix
matrix:Set(2, 5, 0, 1, 3, 0, 0, 0, 1)
matrix:Inverse()
number row0column0 = matrix:row0column0
number row0column1 = matrix:row0column1
number row0column2 = matrix:row0column2
number row1column0 = matrix:row1column0
number row1column1 = matrix:row1column1
number row1column2 = matrix:row1column2
number row2column0 = matrix:row2column0
number row2column1 = matrix:row2column1
number row2column2 = matrix:row2column2
output "The new matrix is:"
output "|" + row0column0 + ", " + row0column1 + ", " + row0column2 + "|"
output "|" + row1column0 + ", " + row1column1 + ", " + row1column2 + "|"
output "|" + row2column0 + ", " + row2column1 + ", " + row2column2 + "|"
Inherits from: Libraries.Language.Object
Variables Table
Variables | Description |
---|---|
number row2column2 | |
number row0column1 | |
number row0column0 | |
number row2column0 | |
number row1column1 | |
number row1column2 | |
number row2column1 | |
number row1column0 | |
number row0column2 |
Actions Documentation
AddTranslationalComponent(number x, number y)
This action adds a translational component to the matrix. This action is mainly used in graphics programming to represent translations.
Parameters
- number x: The x component of the translation
- number y: The y component of the translation
Return
Libraries.Compute.Matrix3: The matrix with the translational component
Example
use Libraries.Compute.Matrix3
Matrix3 matrix
matrix:IdentityMatrix()
matrix:AddTranslationalComponent(4, 5)
number row0column0 = matrix:row0column0
number row0column1 = matrix:row0column1
number row0column2 = matrix:row0column2
number row1column0 = matrix:row1column0
number row1column1 = matrix:row1column1
number row1column2 = matrix:row1column2
number row2column0 = matrix:row2column0
number row2column1 = matrix:row2column1
number row2column2 = matrix:row2column2
output "The new matrix is:"
output "|" + row0column0 + ", " + row0column1 + ", " + row0column2 + "|"
output "|" + row1column0 + ", " + row1column1 + ", " + row1column2 + "|"
output "|" + row2column0 + ", " + row2column1 + ", " + row2column2 + "|"
AddTranslationalComponent(Libraries.Compute.Vector3 vector)
This action adds a translational component to the matrix. This action is mainly used in graphics programming to represent translations.
Parameters
- Libraries.Compute.Vector3: The vector to use as the translational component
Return
Libraries.Compute.Matrix3: The matrix with the translational component
Example
use Libraries.Compute.Matrix3
use Libraries.Compute.Vector2
Matrix3 matrix
Vector2 translation
matrix:IdentityMatrix()
translation:Set(4, 5)
matrix:AddTranslationalComponent(translation)
number row0column0 = matrix:row0column0
number row0column1 = matrix:row0column1
number row0column2 = matrix:row0column2
number row1column0 = matrix:row1column0
number row1column1 = matrix:row1column1
number row1column2 = matrix:row1column2
number row2column0 = matrix:row2column0
number row2column1 = matrix:row2column1
number row2column2 = matrix:row2column2
output "The new matrix is:"
output "|" + row0column0 + ", " + row0column1 + ", " + row0column2 + "|"
output "|" + row1column0 + ", " + row1column1 + ", " + row1column2 + "|"
output "|" + row2column0 + ", " + row2column1 + ", " + row2column2 + "|"
AddTranslationalComponent(Libraries.Compute.Vector2 vector)
This action adds a translational component to the matrix. This action is mainly used in graphics programming to represent translations.
Parameters
- Libraries.Compute.Vector2: The vector to use as the translational component
Return
Libraries.Compute.Matrix3: The matrix with the translational component
Example
use Libraries.Compute.Matrix3
use Libraries.Compute.Vector2
Matrix3 matrix
Vector2 translation
matrix:IdentityMatrix()
translation:Set(4, 5)
matrix:AddTranslationalComponent(translation)
number row0column0 = matrix:row0column0
number row0column1 = matrix:row0column1
number row0column2 = matrix:row0column2
number row1column0 = matrix:row1column0
number row1column1 = matrix:row1column1
number row1column2 = matrix:row1column2
number row2column0 = matrix:row2column0
number row2column1 = matrix:row2column1
number row2column2 = matrix:row2column2
output "The new matrix is:"
output "|" + row0column0 + ", " + row0column1 + ", " + row0column2 + "|"
output "|" + row1column0 + ", " + row1column1 + ", " + row1column2 + "|"
output "|" + row2column0 + ", " + row2column1 + ", " + row2column2 + "|"
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 and returns a new matrix that is a copy of the calling matrix
Return
Libraries.Compute.Matrix3: A new matrix that is a copy of this matrix
Example
use Libraries.Compute.Matrix3
Matrix3 matrix
Matrix3 copyMatrix
copyMatrix:Set(8, 7, 6, 5, 4, 3, 2, 1, 0)
matrix = copyMatrix:Copy()
number row0column0 = matrix:row0column0
number row0column1 = matrix:row0column1
number row0column2 = matrix:row0column2
number row1column0 = matrix:row1column0
number row1column1 = matrix:row1column1
number row1column2 = matrix:row1column2
number row2column0 = matrix:row2column0
number row2column1 = matrix:row2column1
number row2column2 = matrix:row2column2
output "The new matrix is:"
output "|" + row0column0 + ", " + row0column1 + ", " + row0column2 + "|"
output "|" + row1column0 + ", " + row1column1 + ", " + row1column2 + "|"
output "|" + row2column0 + ", " + row2column1 + ", " + row2column2 + "|"
Determinant()
This action computes the determinant of the matrix.
Return
number: The determinant of the matrix
Example
use Libraries.Compute.Matrix3
Matrix3 matrix
matrix:Set(2, 5, 0, 1, 3, 0, 0, 0, 1)
number determinant = matrix:Determinant()
output "The determinant of the matrix is " + determinant
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)
GetColumn(integer index)
This action multiply the matrix by a vector. Mathematically, this is v = M*v. This action won't change the matrix. This action will chagne the vector.
Parameters
- integer index
Return
GetElement(integer row, integer column)
This action transposes the matrix.
Parameters
- integer row
- integer column
Return
number: The transpose of the matrix
Example
use Libraries.Compute.Matrix3
Matrix3 matrix
matrix:Set(0, 1, 2, 3, 4, 5, 6, 7, 8)
matrix:Transpose()
number row0column0 = matrix:row0column0
number row0column1 = matrix:row0column1
number row0column2 = matrix:row0column2
number row1column0 = matrix:row1column0
number row1column1 = matrix:row1column1
number row1column2 = matrix:row1column2
number row2column0 = matrix:row2column0
number row2column1 = matrix:row2column1
number row2column2 = matrix:row2column2
output "The new matrix is:"
output "|" + row0column0 + ", " + row0column1 + ", " + row0column2 + "|"
output "|" + row1column0 + ", " + row1column1 + ", " + row1column2 + "|"
output "|" + row2column0 + ", " + row2column1 + ", " + row2column2 + "|"
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()
This action gets the rotation of the matrix in degrees.
Return
number: The rotation in degrees of the matrix
Example
use Libraries.Compute.Matrix3
Matrix3 matrix
matrix:IdentityMatrix()
matrix:SetToRotation(45)
number rotation = matrix:GetRotation()
output "The rotation is " + rotation + " degrees."
GetRotationInRadians()
This action gets the rotation of the matrix in radians.
Return
number: The rotation in radians of the matrix
Example
use Libraries.Compute.Matrix3
Matrix3 matrix
matrix:IdentityMatrix()
matrix:SetToRotation(45)
number rotation = matrix:GetRotationInRadians()
output "The rotation is " + rotation + " radians."
GetRow(integer index)
This action sets the scale component of the matrix to the passed scale vector, which is a 2D vector.
Parameters
- integer index
Return
Libraries.Compute.Vector3: The matrix with the scale component set
Example
use Libraries.Compute.Matrix3
use Libraries.Compute.Vector2
Matrix3 matrix
Vector2 scale
matrix:IdentityMatrix()
scale:Set(2, 2)
matrix:SetScale(scale)
number row0column0 = matrix:row0column0
number row0column1 = matrix:row0column1
number row0column2 = matrix:row0column2
number row1column0 = matrix:row1column0
number row1column1 = matrix:row1column1
number row1column2 = matrix:row1column2
number row2column0 = matrix:row2column0
number row2column1 = matrix:row2column1
number row2column2 = matrix:row2column2
output "The new matrix is:"
output "|" + row0column0 + ", " + row0column1 + ", " + row0column2 + "|"
output "|" + row1column0 + ", " + row1column1 + ", " + row1column2 + "|"
output "|" + row2column0 + ", " + row2column1 + ", " + row2column2 + "|"
GetScale()
This action gets the scale component of the matrix.
Return
Libraries.Compute.Vector2: The scale component as a 2D vector (Vector2)
Example
use Libraries.Compute.Matrix3
use Libraries.Compute.Vector2
Matrix3 matrix
Vector2 scale
matrix:IdentityMatrix()
matrix:SetToScaling(2, 2)
scale = matrix:GetScale()
output "The scale is [" + scale:GetX() + ", " + scale:GetY() + "]"
GetTranslation()
This action gets the translational component of the matrix.
Return
Libraries.Compute.Vector2: The translational component as a 2D vector (Vector2)
Example
use Libraries.Compute.Matrix3
use Libraries.Compute.Vector2
Matrix3 matrix
Vector2 translation
matrix:IdentityMatrix()
matrix:AddTranslationalComponent(4, 5)
translation = matrix:GetTranslation()
output "The translation is [" + translation:GetX() + ", " + translation:GetY() + "]"
IdentityMatrix()
This action sets the matrix to the identity matrix.
Return
Libraries.Compute.Matrix3: The matrix as the identity matrix
Example
use Libraries.Compute.Matrix3
Matrix3 matrix
matrix:IdentityMatrix()
number row0column0 = matrix:row0column0
number row0column1 = matrix:row0column1
number row0column2 = matrix:row0column2
number row1column0 = matrix:row1column0
number row1column1 = matrix:row1column1
number row1column2 = matrix:row1column2
number row2column0 = matrix:row2column0
number row2column1 = matrix:row2column1
number row2column2 = matrix:row2column2
output "The new matrix is:"
output "|" + row0column0 + ", " + row0column1 + ", " + row0column2 + "|"
output "|" + row1column0 + ", " + row1column1 + ", " + row1column2 + "|"
output "|" + row2column0 + ", " + row2column1 + ", " + row2column2 + "|"
Inverse()
This action computes the inverse of the matrix.
Return
Libraries.Compute.Matrix3: The inverse of the matrix
Example
use Libraries.Compute.Matrix3
Matrix3 matrix
matrix:Set(2, 5, 0, 1, 3, 0, 0, 0, 1)
matrix:Inverse()
number row0column0 = matrix:row0column0
number row0column1 = matrix:row0column1
number row0column2 = matrix:row0column2
number row1column0 = matrix:row1column0
number row1column1 = matrix:row1column1
number row1column2 = matrix:row1column2
number row2column0 = matrix:row2column0
number row2column1 = matrix:row2column1
number row2column2 = matrix:row2column2
output "The new matrix is:"
output "|" + row0column0 + ", " + row0column1 + ", " + row0column2 + "|"
output "|" + row1column0 + ", " + row1column1 + ", " + row1column2 + "|"
output "|" + row2column0 + ", " + row2column1 + ", " + row2column2 + "|"
Multiply(Libraries.Compute.Matrix3 matrixA, Libraries.Compute.Matrix3 matrixB)
This action performs the matrix multiplication matrixA * matrixB. The result is stored in the calling matrix. Calling C:Multiply(A, B) results in C = AB.
Parameters
- Libraries.Compute.Matrix3: The left hand matrix to multiply
- Libraries.Compute.Matrix3: The right hand matrix to multiply
Return
Libraries.Compute.Matrix3: The product of the two matrices
Example
use Libraries.Compute.Matrix3
Matrix3 matrixA
Matrix3 matrixB
Matrix3 product
matrixA:Set(0, 2, 4, 6, 8, 10, 12, 14, 16)
matrixB:Set(1, 3, 5, 7, 9, 11, 13, 15, 17)
product:Multiply(matrixA, matrixB)
number row0column0 = product:row0column0
number row0column1 = product:row0column1
number row0column2 = product:row0column2
number row1column0 = product:row1column0
number row1column1 = product:row1column1
number row1column2 = product:row1column2
number row2column0 = product:row2column0
number row2column1 = product:row2column1
number row2column2 = product:row2column2
output "The new matrix is:"
output "|" + row0column0 + ", " + row0column1 + ", " + row0column2 + "|"
output "|" + row1column0 + ", " + row1column1 + ", " + row1column2 + "|"
output "|" + row2column0 + ", " + row2column1 + ", " + row2column2 + "|"
Multiply(Libraries.Compute.Matrix3 matrix)
This action multiplies the calling matrix by the passed matrix and stores the result in the calling matrix. Calling A:Multiply(B) results in A = AB.
Parameters
- Libraries.Compute.Matrix3: The matrix to multiply by
Return
Libraries.Compute.Matrix3: The calling matrix after multiplication
Example
use Libraries.Compute.Matrix3
Matrix3 matrixA
Matrix3 matrixB
matrixA:Set(0, 2, 4, 6, 8, 10, 12, 14, 16)
matrixB:Set(1, 3, 5, 7, 9, 11, 13, 15, 17)
matrixA:Multiply(matrixB)
number row0column0 = matrixA:row0column0
number row0column1 = matrixA:row0column1
number row0column2 = matrixA:row0column2
number row1column0 = matrixA:row1column0
number row1column1 = matrixA:row1column1
number row1column2 = matrixA:row1column2
number row2column0 = matrixA:row2column0
number row2column1 = matrixA:row2column1
number row2column2 = matrixA:row2column2
output "The new matrix is:"
output "|" + row0column0 + ", " + row0column1 + ", " + row0column2 + "|"
output "|" + row1column0 + ", " + row1column1 + ", " + row1column2 + "|"
output "|" + row2column0 + ", " + row2column1 + ", " + row2column2 + "|"
Output()
This action sets the matrix to the rotation matrix for the passed angle in degrees counter-clockwise about the passed axis. A rotation matrix is often used in graphics programming to represent rotations.
Example
use Libraries.Compute.Matrix3
use Libraries.Compute.Vector3
Matrix3 matrix
Vector3 axis
axis:Set(0, 0, 1)
matrix:SetToRotation(axis, 45)
number row0column0 = matrix:row0column0
number row0column1 = matrix:row0column1
number row0column2 = matrix:row0column2
number row1column0 = matrix:row1column0
number row1column1 = matrix:row1column1
number row1column2 = matrix:row1column2
number row2column0 = matrix:row2column0
number row2column1 = matrix:row2column1
number row2column2 = matrix:row2column2
output "The new matrix is:"
output "|" + row0column0 + ", " + row0column1 + ", " + row0column2 + "|"
output "|" + row1column0 + ", " + row1column1 + ", " + row1column2 + "|"
output "|" + row2column0 + ", " + row2column1 + ", " + row2column2 + "|"
Rotate(number degrees)
This action rotates the matrix by the given angle in degrees.
Parameters
- number degrees: The angle in degrees
Return
Libraries.Compute.Matrix3: The matrix after rotation
Example
use Libraries.Compute.Matrix3
Matrix3 matrix
matrix:IdentityMatrix()
matrix:Rotate(45)
number row0column0 = matrix:row0column0
number row0column1 = matrix:row0column1
number row0column2 = matrix:row0column2
number row1column0 = matrix:row1column0
number row1column1 = matrix:row1column1
number row1column2 = matrix:row1column2
number row2column0 = matrix:row2column0
number row2column1 = matrix:row2column1
number row2column2 = matrix:row2column2
output "The new matrix is:"
output "|" + row0column0 + ", " + row0column1 + ", " + row0column2 + "|"
output "|" + row1column0 + ", " + row1column1 + ", " + row1column2 + "|"
output "|" + row2column0 + ", " + row2column1 + ", " + row2column2 + "|"
RotateInRadians(number radians)
This action rotates the matrix by the given angle in radians.
Parameters
- number radians: The angle in radians
Return
Libraries.Compute.Matrix3: The matrix after rotation
Example
use Libraries.Compute.Matrix3
use Libraries.Compute.Math
Math math
Matrix3 matrix
matrix:IdentityMatrix()
matrix:RotateInRadians(math:pi / 4)
number row0column0 = matrix:row0column0
number row0column1 = matrix:row0column1
number row0column2 = matrix:row0column2
number row1column0 = matrix:row1column0
number row1column1 = matrix:row1column1
number row1column2 = matrix:row1column2
number row2column0 = matrix:row2column0
number row2column1 = matrix:row2column1
number row2column2 = matrix:row2column2
output "The new matrix is:"
output "|" + row0column0 + ", " + row0column1 + ", " + row0column2 + "|"
output "|" + row1column0 + ", " + row1column1 + ", " + row1column2 + "|"
output "|" + row2column0 + ", " + row2column1 + ", " + row2column2 + "|"
Scale(Libraries.Compute.Vector2 scale)
This action scales the matrix by the given scale vector.
Parameters
- Libraries.Compute.Vector2: The scale vector
Return
Libraries.Compute.Matrix3: The matrix after scaling
Example
use Libraries.Compute.Matrix3
use Libraries.Compute.Vector2
Matrix3 matrix
Vector2 scale
matrix:IdentityMatrix()
scale:Set(2, 2)
matrix:Scale(scale)
number row0column0 = matrix:row0column0
number row0column1 = matrix:row0column1
number row0column2 = matrix:row0column2
number row1column0 = matrix:row1column0
number row1column1 = matrix:row1column1
number row1column2 = matrix:row1column2
number row2column0 = matrix:row2column0
number row2column1 = matrix:row2column1
number row2column2 = matrix:row2column2
output "The new matrix is:"
output "|" + row0column0 + ", " + row0column1 + ", " + row0column2 + "|"
output "|" + row1column0 + ", " + row1column1 + ", " + row1column2 + "|"
output "|" + row2column0 + ", " + row2column1 + ", " + row2column2 + "|"
Scale(number scaleX, number scaleY)
This action scales the matrix by the given scale values in the x and y directions.
Parameters
- number scaleX: The scale in the x-direction
- number scaleY: The scale in the y-direction
Return
Libraries.Compute.Matrix3: The matrix after scaling
Example
use Libraries.Compute.Matrix3
Matrix3 matrix
matrix:IdentityMatrix()
matrix:Scale(2, 2)
number row0column0 = matrix:row0column0
number row0column1 = matrix:row0column1
number row0column2 = matrix:row0column2
number row1column0 = matrix:row1column0
number row1column1 = matrix:row1column1
number row1column2 = matrix:row1column2
number row2column0 = matrix:row2column0
number row2column1 = matrix:row2column1
number row2column2 = matrix:row2column2
output "The new matrix is:"
output "|" + row0column0 + ", " + row0column1 + ", " + row0column2 + "|"
output "|" + row1column0 + ", " + row1column1 + ", " + row1column2 + "|"
output "|" + row2column0 + ", " + row2column1 + ", " + row2column2 + "|"
Set(Libraries.Compute.Matrix4 matrix)
This action sets the matrix to the values of the passed 4-by-4 matrix. The last row and last column of the passed 4-by-4 matrix are not used to set this matrix.
Parameters
- Libraries.Compute.Matrix4: The 4-by-4 matrix used to set the values of this matrix
Return
Libraries.Compute.Matrix3: The matrix with the values from the 4-by-4 matrix
Example
use Libraries.Compute.Matrix3
use Libraries.Compute.Matrix4
Matrix3 matrix
Matrix4 biggerMatrix
biggerMatrix:Set(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15)
matrix:Set(biggerMatrix)
number row0column0 = matrix:row0column0
number row0column1 = matrix:row0column1
number row0column2 = matrix:row0column2
number row1column0 = matrix:row1column0
number row1column1 = matrix:row1column1
number row1column2 = matrix:row1column2
number row2column0 = matrix:row2column0
number row2column1 = matrix:row2column1
number row2column2 = matrix:row2column2
output "The new matrix is:"
output "|" + row0column0 + ", " + row0column1 + ", " + row0column2 + "|"
output "|" + row1column0 + ", " + row1column1 + ", " + row1column2 + "|"
output "|" + row2column0 + ", " + row2column1 + ", " + row2column2 + "|"
Set(Libraries.Compute.Matrix3 matrix)
This action sets the matrix to be a copy of the passed matrix.
Parameters
- Libraries.Compute.Matrix3: The matrix to set this matrix as
Return
Libraries.Compute.Matrix3: The matrix with the values from the other matrix
Example
use Libraries.Compute.Matrix3
Matrix3 matrix
Matrix3 copyMatrix
copyMatrix:Set(8, 7, 6, 5, 4, 3, 2, 1, 0)
matrix:Set(copyMatrix)
number row0column0 = matrix:row0column0
number row0column1 = matrix:row0column1
number row0column2 = matrix:row0column2
number row1column0 = matrix:row1column0
number row1column1 = matrix:row1column1
number row1column2 = matrix:row1column2
number row2column0 = matrix:row2column0
number row2column1 = matrix:row2column1
number row2column2 = matrix:row2column2
output "The new matrix is:"
output "|" + row0column0 + ", " + row0column1 + ", " + row0column2 + "|"
output "|" + row1column0 + ", " + row1column1 + ", " + row1column2 + "|"
output "|" + row2column0 + ", " + row2column1 + ", " + row2column2 + "|"
Set(Libraries.Containers.Array<number> array)
This action sets the values of the matrix using the values of the passed array. The values of the array are used in order to set the matrix values row by row. For example, the first element in the array is used to set the cell of the matrix in the first row and first column, the second element is used to set the cell of the matrix in the first row and second column, the third element for the first row and third column, the fourth element for the second row and first column, etc.
Parameters
- Libraries.Containers.Array: The array that contains the values to set as the matrix values
Return
Libraries.Compute.Matrix3: The matrix with the values from the array
Example
use Libraries.Compute.Matrix3
use Libraries.Containers.Array
Matrix3 matrix
Array<number> array
integer i = 0
repeat 9 times
array:Add(i)
i = i + 1
end
matrix:Set(array)
number row0column0 = matrix:row0column0
number row0column1 = matrix:row0column1
number row0column2 = matrix:row0column2
number row1column0 = matrix:row1column0
number row1column1 = matrix:row1column1
number row1column2 = matrix:row1column2
number row2column0 = matrix:row2column0
number row2column1 = matrix:row2column1
number row2column2 = matrix:row2column2
output "The new matrix is:"
output "|" + row0column0 + ", " + row0column1 + ", " + row0column2 + "|"
output "|" + row1column0 + ", " + row1column1 + ", " + row1column2 + "|"
output "|" + row2column0 + ", " + row2column1 + ", " + row2column2 + "|"
Set(Libraries.Compute.Affine2 affine)
This action sets the matrix using the values of the passed Affine2. An Affine2 is essentially a 3-by-3 matrix used to represent transformations where the last row is always (0, 0, 1).
Parameters
- Libraries.Compute.Affine2: The affine to use to set the matrix
Return
Libraries.Compute.Matrix3: The matrix with the values from the affine
Example
use Libraries.Compute.Matrix3
use Libraries.Compute.Affine2
Matrix3 matrix
Affine2 affine
affine:Identity()
matrix:Set(affine)
number row0column0 = matrix:row0column0
number row0column1 = matrix:row0column1
number row0column2 = matrix:row0column2
number row1column0 = matrix:row1column0
number row1column1 = matrix:row1column1
number row1column2 = matrix:row1column2
number row2column0 = matrix:row2column0
number row2column1 = matrix:row2column1
number row2column2 = matrix:row2column2
output "The new matrix is:"
output "|" + row0column0 + ", " + row0column1 + ", " + row0column2 + "|"
output "|" + row1column0 + ", " + row1column1 + ", " + row1column2 + "|"
output "|" + row2column0 + ", " + row2column1 + ", " + row2column2 + "|"
Set(number row0column0, number row0column1, number row0column2, number row1column0, number row1column1, number row1column2, number row2column0, number row2column1, number row2column2)
This action sets the values of the array to the passed values.
Parameters
- number row0column0: The value of the first row, first column
- number row0column1: The value of the first row, second column
- number row0column2: The value of the first row, third column
- number row1column0: The value of the second row, first column
- number row1column1: The value of the second row, second column
- number row1column2: The value of the second row, third column
- number row2column0: The value of the third row, first column
- number row2column1: The value of the third row, second column
- number row2column2: The value of the third row, third column
Return
Libraries.Compute.Matrix3: The matrix with the passed values
Example
use Libraries.Compute.Matrix3
Matrix3 matrix
matrix:Set(0, 1, 2, 3, 4, 5, 6, 7, 8)
number row0column0 = matrix:row0column0
number row0column1 = matrix:row0column1
number row0column2 = matrix:row0column2
number row1column0 = matrix:row1column0
number row1column1 = matrix:row1column1
number row1column2 = matrix:row1column2
number row2column0 = matrix:row2column0
number row2column1 = matrix:row2column1
number row2column2 = matrix:row2column2
output "The new matrix is:"
output "|" + row0column0 + ", " + row0column1 + ", " + row0column2 + "|"
output "|" + row1column0 + ", " + row1column1 + ", " + row1column2 + "|"
output "|" + row2column0 + ", " + row2column1 + ", " + row2column2 + "|"
SetEulerZYX(number rotateX, number rotateY, number rotateZ)
pass in values in radians
Parameters
- number rotateX
- number rotateY
- number rotateZ
SetScale(Libraries.Compute.Vector3 scale)
This action sets the scale component of the matrix to the passed scale vector, which is a 3D vector. The z-component of the vector is ignored.
Parameters
- Libraries.Compute.Vector3: The scale vector to set as the scale component
Return
Libraries.Compute.Matrix3: The matrix with the scale component set
Example
use Libraries.Compute.Matrix3
use Libraries.Compute.Vector3
Matrix3 matrix
Vector3 scale
matrix:IdentityMatrix()
scale:Set(2, 2, 2)
matrix:SetScale(scale)
number row0column0 = matrix:row0column0
number row0column1 = matrix:row0column1
number row0column2 = matrix:row0column2
number row1column0 = matrix:row1column0
number row1column1 = matrix:row1column1
number row1column2 = matrix:row1column2
number row2column0 = matrix:row2column0
number row2column1 = matrix:row2column1
number row2column2 = matrix:row2column2
output "The new matrix is:"
output "|" + row0column0 + ", " + row0column1 + ", " + row0column2 + "|"
output "|" + row1column0 + ", " + row1column1 + ", " + row1column2 + "|"
output "|" + row2column0 + ", " + row2column1 + ", " + row2column2 + "|"
SetScale(Libraries.Compute.Vector2 scale)
This action sets the scale component of the matrix to the passed scale vector, which is a 2D vector.
Parameters
- Libraries.Compute.Vector2: The scale vector to set as the scale component
Return
Libraries.Compute.Matrix3: The matrix with the scale component set
Example
use Libraries.Compute.Matrix3
use Libraries.Compute.Vector2
Matrix3 matrix
Vector2 scale
matrix:IdentityMatrix()
scale:Set(2, 2)
matrix:SetScale(scale)
number row0column0 = matrix:row0column0
number row0column1 = matrix:row0column1
number row0column2 = matrix:row0column2
number row1column0 = matrix:row1column0
number row1column1 = matrix:row1column1
number row1column2 = matrix:row1column2
number row2column0 = matrix:row2column0
number row2column1 = matrix:row2column1
number row2column2 = matrix:row2column2
output "The new matrix is:"
output "|" + row0column0 + ", " + row0column1 + ", " + row0column2 + "|"
output "|" + row1column0 + ", " + row1column1 + ", " + row1column2 + "|"
output "|" + row2column0 + ", " + row2column1 + ", " + row2column2 + "|"
SetScale(number scale)
This action sets the scale component of the matrix to the passed scale value.
Parameters
- number scale: The scale value to set
Return
Libraries.Compute.Matrix3: The matrix with the scale component set
Example
use Libraries.Compute.Matrix3
Matrix3 matrix
matrix:IdentityMatrix()
matrix:SetScale(2)
number row0column0 = matrix:row0column0
number row0column1 = matrix:row0column1
number row0column2 = matrix:row0column2
number row1column0 = matrix:row1column0
number row1column1 = matrix:row1column1
number row1column2 = matrix:row1column2
number row2column0 = matrix:row2column0
number row2column1 = matrix:row2column1
number row2column2 = matrix:row2column2
output "The new matrix is:"
output "|" + row0column0 + ", " + row0column1 + ", " + row0column2 + "|"
output "|" + row1column0 + ", " + row1column1 + ", " + row1column2 + "|"
output "|" + row2column0 + ", " + row2column1 + ", " + row2column2 + "|"
SetToRotation(Libraries.Compute.Vector3 axis, number degrees)
This action sets the matrix to the rotation matrix for the passed angle in degrees counter-clockwise about the passed axis. A rotation matrix is often used in graphics programming to represent rotations.
Parameters
- Libraries.Compute.Vector3: The rotation axis
- number degrees: The angle in degrees
Return
Libraries.Compute.Matrix3: The matrix as a rotation matrix
Example
use Libraries.Compute.Matrix3
use Libraries.Compute.Vector3
Matrix3 matrix
Vector3 axis
axis:Set(0, 0, 1)
matrix:SetToRotation(axis, 45)
number row0column0 = matrix:row0column0
number row0column1 = matrix:row0column1
number row0column2 = matrix:row0column2
number row1column0 = matrix:row1column0
number row1column1 = matrix:row1column1
number row1column2 = matrix:row1column2
number row2column0 = matrix:row2column0
number row2column1 = matrix:row2column1
number row2column2 = matrix:row2column2
output "The new matrix is:"
output "|" + row0column0 + ", " + row0column1 + ", " + row0column2 + "|"
output "|" + row1column0 + ", " + row1column1 + ", " + row1column2 + "|"
output "|" + row2column0 + ", " + row2column1 + ", " + row2column2 + "|"
SetToRotation(Libraries.Compute.Vector3 axis, number cosine, number sine)
This action sets the matrix to a rotation matrix about the passed axis using the cosine and sine of the angle of rotation. A rotation matrix is often used in graphics programming to represent rotations.
Parameters
- Libraries.Compute.Vector3: The rotation axis
- number cosine: The cosine of the angle
- number sine: The sine of the angle
Return
Libraries.Compute.Matrix3: The matrix as a rotation matrix
Example
use Libraries.Compute.Matrix3
use Libraries.Compute.Vector3
use Libraries.Compute.Math
Math math
Matrix3 matrix
Vector3 axis
number cosine = math:SquareRoot(2) / 2
number sine = math:SquareRoot(2) / 2
axis:Set(0, 0, 1)
matrix:SetToRotation(axis, cosine, sine)
number row0column0 = matrix:row0column0
number row0column1 = matrix:row0column1
number row0column2 = matrix:row0column2
number row1column0 = matrix:row1column0
number row1column1 = matrix:row1column1
number row1column2 = matrix:row1column2
number row2column0 = matrix:row2column0
number row2column1 = matrix:row2column1
number row2column2 = matrix:row2column2
output "The new matrix is:"
output "|" + row0column0 + ", " + row0column1 + ", " + row0column2 + "|"
output "|" + row1column0 + ", " + row1column1 + ", " + row1column2 + "|"
output "|" + row2column0 + ", " + row2column1 + ", " + row2column2 + "|"
SetToRotation(number degrees)
This action sets the matrix to the rotation matrix for the passed angle in degrees counter-clockwise. A rotation matrix is often used in graphics programming to represent rotations.
Parameters
- number degrees: The angle in degrees
Return
Libraries.Compute.Matrix3: The matrix as a rotation matrix
Example
use Libraries.Compute.Matrix3
Matrix3 matrix
matrix:SetToRotation(45)
number row0column0 = matrix:row0column0
number row0column1 = matrix:row0column1
number row0column2 = matrix:row0column2
number row1column0 = matrix:row1column0
number row1column1 = matrix:row1column1
number row1column2 = matrix:row1column2
number row2column0 = matrix:row2column0
number row2column1 = matrix:row2column1
number row2column2 = matrix:row2column2
output "The new matrix is:"
output "|" + row0column0 + ", " + row0column1 + ", " + row0column2 + "|"
output "|" + row1column0 + ", " + row1column1 + ", " + row1column2 + "|"
output "|" + row2column0 + ", " + row2column1 + ", " + row2column2 + "|"
SetToRotationInRadians(number radians)
This action sets the matrix to the rotation matrix for the passed angle in radians. A rotation matrix is often used in graphics programming to represent rotations.
Parameters
- number radians: The angle in radians
Return
Libraries.Compute.Matrix3: The matrix as a rotation matrix
Example
use Libraries.Compute.Matrix3
use Libraries.Compute.Math
Math math
Matrix3 matrix
matrix:SetToRotationInRadians(math:pi / 4)
number row0column0 = matrix:row0column0
number row0column1 = matrix:row0column1
number row0column2 = matrix:row0column2
number row1column0 = matrix:row1column0
number row1column1 = matrix:row1column1
number row1column2 = matrix:row1column2
number row2column0 = matrix:row2column0
number row2column1 = matrix:row2column1
number row2column2 = matrix:row2column2
output "The new matrix is:"
output "|" + row0column0 + ", " + row0column1 + ", " + row0column2 + "|"
output "|" + row1column0 + ", " + row1column1 + ", " + row1column2 + "|"
output "|" + row2column0 + ", " + row2column1 + ", " + row2column2 + "|"
SetToScaling(number scaleX, number scaleY)
This action ses the matrix to a scaling matrix with the passed scales in the x and y directions. A scaling matrix is often used in graphics programming to represent a scale.
Parameters
- number scaleX: The scale in the x-direction
- number scaleY: The scale in the y-direction
Return
Libraries.Compute.Matrix3: The matrix as a scale matrix
Example
use Libraries.Compute.Matrix3
Matrix3 matrix
matrix:SetToScaling(2, 2)
number row0column0 = matrix:row0column0
number row0column1 = matrix:row0column1
number row0column2 = matrix:row0column2
number row1column0 = matrix:row1column0
number row1column1 = matrix:row1column1
number row1column2 = matrix:row1column2
number row2column0 = matrix:row2column0
number row2column1 = matrix:row2column1
number row2column2 = matrix:row2column2
output "The new matrix is:"
output "|" + row0column0 + ", " + row0column1 + ", " + row0column2 + "|"
output "|" + row1column0 + ", " + row1column1 + ", " + row1column2 + "|"
output "|" + row2column0 + ", " + row2column1 + ", " + row2column2 + "|"
SetToScaling(Libraries.Compute.Vector2 scale)
This action ses the matrix to a scaling matrix with the passed vector as the scale vector. A scaling matrix is often used in graphics programming to represent a scale.
Parameters
- Libraries.Compute.Vector2: The vector representing the scale
Return
Libraries.Compute.Matrix3: The matrix as a scale matrix
Example
use Libraries.Compute.Matrix3
use Libraries.Compute.Vector2
Matrix3 matrix
Vector2 scale
scale:Set(2, 2)
matrix:SetToScaling(scale)
number row0column0 = matrix:row0column0
number row0column1 = matrix:row0column1
number row0column2 = matrix:row0column2
number row1column0 = matrix:row1column0
number row1column1 = matrix:row1column1
number row1column2 = matrix:row1column2
number row2column0 = matrix:row2column0
number row2column1 = matrix:row2column1
number row2column2 = matrix:row2column2
output "The new matrix is:"
output "|" + row0column0 + ", " + row0column1 + ", " + row0column2 + "|"
output "|" + row1column0 + ", " + row1column1 + ", " + row1column2 + "|"
output "|" + row2column0 + ", " + row2column1 + ", " + row2column2 + "|"
SetToTranslation(Libraries.Compute.Vector2 translation)
This action sets the matrix to a translation matrix by the given vector representing the translation. A translation matrix is often used in graphics programming to represent translations.
Parameters
- Libraries.Compute.Vector2: The translation vector
Return
Libraries.Compute.Matrix3: The matrix as a translation matrix
Example
use Libraries.Compute.Matrix3
use Libraries.Compute.Vector2
Matrix3 matrix
Vector2 translation
translation:Set(4, 5)
matrix:SetToTranslation(translation)
number row0column0 = matrix:row0column0
number row0column1 = matrix:row0column1
number row0column2 = matrix:row0column2
number row1column0 = matrix:row1column0
number row1column1 = matrix:row1column1
number row1column2 = matrix:row1column2
number row2column0 = matrix:row2column0
number row2column1 = matrix:row2column1
number row2column2 = matrix:row2column2
output "The new matrix is:"
output "|" + row0column0 + ", " + row0column1 + ", " + row0column2 + "|"
output "|" + row1column0 + ", " + row1column1 + ", " + row1column2 + "|"
output "|" + row2column0 + ", " + row2column1 + ", " + row2column2 + "|"
SetToTranslation(number x, number y)
This action sets the matrix to a translation matrix by the given x and y values. A translation matrix is often used in graphics programming to represent translations.
Parameters
- number x: The x value of the translation
- number y: The y value of the translation
Return
Libraries.Compute.Matrix3: The matrix as a translation matrix
Example
use Libraries.Compute.Matrix3
Matrix3 matrix
matrix:SetToTranslation(4, 5)
number row0column0 = matrix:row0column0
number row0column1 = matrix:row0column1
number row0column2 = matrix:row0column2
number row1column0 = matrix:row1column0
number row1column1 = matrix:row1column1
number row1column2 = matrix:row1column2
number row2column0 = matrix:row2column0
number row2column1 = matrix:row2column1
number row2column2 = matrix:row2column2
output "The new matrix is:"
output "|" + row0column0 + ", " + row0column1 + ", " + row0column2 + "|"
output "|" + row1column0 + ", " + row1column1 + ", " + row1column2 + "|"
output "|" + row2column0 + ", " + row2column1 + ", " + row2column2 + "|"
Transform(Libraries.Compute.Vector3 vector)
This action multiply the matrix by a vector. Mathematically, this is v = M*v. This action won't change the matrix. This action will chagne the vector.
Parameters
Translate(number x, number y)
This action translates the matrix by the given x and y translations.
Parameters
- number x: The x component of the translation
- number y: The y component of the translation
Return
Libraries.Compute.Matrix3: The matrix after translation
Example
use Libraries.Compute.Matrix3
Matrix3 matrix
matrix:IdentityMatrix()
matrix:Translate(4, 5)
number row0column0 = matrix:row0column0
number row0column1 = matrix:row0column1
number row0column2 = matrix:row0column2
number row1column0 = matrix:row1column0
number row1column1 = matrix:row1column1
number row1column2 = matrix:row1column2
number row2column0 = matrix:row2column0
number row2column1 = matrix:row2column1
number row2column2 = matrix:row2column2
output "The new matrix is:"
output "|" + row0column0 + ", " + row0column1 + ", " + row0column2 + "|"
output "|" + row1column0 + ", " + row1column1 + ", " + row1column2 + "|"
output "|" + row2column0 + ", " + row2column1 + ", " + row2column2 + "|"
Translate(Libraries.Compute.Vector2 translation)
This action translates the matrix by the given translation vector.
Parameters
- Libraries.Compute.Vector2: The translation vector
Return
Libraries.Compute.Matrix3: The matrix after translation
Example
use Libraries.Compute.Matrix3
use Libraries.Compute.Vector2
Matrix3 matrix
Vector2 translation
matrix:IdentityMatrix()
translation:Set(4, 5)
matrix:Translate(translation)
number row0column0 = matrix:row0column0
number row0column1 = matrix:row0column1
number row0column2 = matrix:row0column2
number row1column0 = matrix:row1column0
number row1column1 = matrix:row1column1
number row1column2 = matrix:row1column2
number row2column0 = matrix:row2column0
number row2column1 = matrix:row2column1
number row2column2 = matrix:row2column2
output "The new matrix is:"
output "|" + row0column0 + ", " + row0column1 + ", " + row0column2 + "|"
output "|" + row1column0 + ", " + row1column1 + ", " + row1column2 + "|"
output "|" + row2column0 + ", " + row2column1 + ", " + row2column2 + "|"
Transpose()
Example
use Libraries.Compute.Matrix3
Matrix3 matrix
matrix:Set(0, 1, 2, 3, 4, 5, 6, 7, 8)
matrix:Transpose()
number row0column0 = matrix:row0column0
number row0column1 = matrix:row0column1
number row0column2 = matrix:row0column2
number row1column0 = matrix:row1column0
number row1column1 = matrix:row1column1
number row1column2 = matrix:row1column2
number row2column0 = matrix:row2column0
number row2column1 = matrix:row2column1
number row2column2 = matrix:row2column2
output "The new matrix is:"
output "|" + row0column0 + ", " + row0column1 + ", " + row0column2 + "|"
output "|" + row1column0 + ", " + row1column1 + ", " + row1column2 + "|"
output "|" + row2column0 + ", " + row2column1 + ", " + row2column2 + "|"
On this page
Variables TableAction Documentation- AddTranslationalComponent(number x, number y)
- AddTranslationalComponent(Libraries.Compute.Vector3 vector)
- AddTranslationalComponent(Libraries.Compute.Vector2 vector)
- Compare(Libraries.Language.Object object)
- Copy()
- Determinant()
- Equals(Libraries.Language.Object object)
- GetColumn(integer index)
- GetElement(integer row, integer column)
- GetHashCode()
- GetRotation()
- GetRotationInRadians()
- GetRow(integer index)
- GetScale()
- GetTranslation()
- IdentityMatrix()
- Inverse()
- Multiply(Libraries.Compute.Matrix3 matrixA, Libraries.Compute.Matrix3 matrixB)
- Multiply(Libraries.Compute.Matrix3 matrix)
- Output()
- Rotate(number degrees)
- RotateInRadians(number radians)
- Scale(Libraries.Compute.Vector2 scale)
- Scale(number scaleX, number scaleY)
- Set(Libraries.Compute.Matrix4 matrix)
- Set(Libraries.Compute.Matrix3 matrix)
- Set(Libraries.Containers.Array
array) - Set(Libraries.Compute.Affine2 affine)
- Set(number row0column0, number row0column1, number row0column2, number row1column0, number row1column1, number row1column2, number row2column0, number row2column1, number row2column2)
- SetEulerZYX(number rotateX, number rotateY, number rotateZ)
- SetScale(Libraries.Compute.Vector3 scale)
- SetScale(Libraries.Compute.Vector2 scale)
- SetScale(number scale)
- SetToRotation(Libraries.Compute.Vector3 axis, number degrees)
- SetToRotation(Libraries.Compute.Vector3 axis, number cosine, number sine)
- SetToRotation(number degrees)
- SetToRotationInRadians(number radians)
- SetToScaling(number scaleX, number scaleY)
- SetToScaling(Libraries.Compute.Vector2 scale)
- SetToTranslation(Libraries.Compute.Vector2 translation)
- SetToTranslation(number x, number y)
- Transform(Libraries.Compute.Vector3 vector)
- Translate(number x, number y)
- Translate(Libraries.Compute.Vector2 translation)
- Transpose()