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
Summary
Variable Summary Table
Variables | Description |
---|---|
number row2column1 | |
number row1column1 | |
number row0column0 | |
number row1column2 | |
number row2column0 | |
number row0column2 | |
number row0column1 | |
number row1column0 | |
number row2column2 |
Actions Summary Table
Actions | Description |
---|---|
AddTranslationalComponent(number x, number y) | This action adds a translational component to the matrix. |
AddTranslationalComponent(Libraries.Compute.Vector3 vector) | This action adds a translational component to the matrix. |
AddTranslationalComponent(Libraries.Compute.Vector2 vector) | This action adds a translational component to the matrix. |
Compare(Libraries.Language.Object object) | This action compares two object hash codes and returns a CompareResult. |
Copy() | This action creates and returns a new matrix that is a copy of the calling matrix |
Determinant() | This action computes the determinant of the matrix. |
Equals(Libraries.Language.Object object) | This action determines if two objects are equal based on their hash code values. |
GetColumn(integer index) | |
GetElement(integer row, integer column) | |
GetHashCode() | This action gets the hash code for an object. |
GetRotation() | This action gets the rotation of the matrix in degrees. |
GetRotationInRadians() | This action gets the rotation of the matrix in radians. |
GetRow(integer index) | |
GetScale() | This action gets the scale component of the matrix. |
GetTranslation() | This action gets the translational component of the matrix. |
IdentityMatrix() | This action sets the matrix to the identity matrix. |
Inverse() | This action computes the inverse of the matrix. |
Multiply(Libraries.Compute.Matrix3 matrixA, Libraries.Compute.Matrix3 matrixB) | This action performs the matrix multiplication matrixA * matrixB. |
Multiply(Libraries.Compute.Matrix3 matrix) | This action multiplies the calling matrix by the passed matrix and stores the result in the calling matrix. |
Rotate(number degrees) | This action rotates the matrix by the given angle in degrees. |
RotateInRadians(number radians) | This action rotates the matrix by the given angle in radians. |
Scale(Libraries.Compute.Vector2 scale) | This action scales the matrix by the given scale vector. |
Scale(number scaleX, number scaleY) | This action scales the matrix by the given scale values in the x and y directions. |
Set(Libraries.Compute.Matrix4 matrix) | This action sets the matrix to the values of the passed 4-by-4 matrix. |
Set(Libraries.Compute.Matrix3 matrix) | This action sets the matrix to be a copy of the passed matrix. |
Set(Libraries.Containers.Array<number> array) | This action sets the values of the matrix using the values of the passed array. |
Set(Libraries.Compute.Affine2 affine) | This action sets the matrix using the values of the passed Affine2. |
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. |
SetScale(Libraries.Compute.Vector3 scale) | This action sets the scale component of the matrix to the passed scale vector, which is a 3D vector. |
SetScale(Libraries.Compute.Vector2 scale) | This action sets the scale component of the matrix to the passed scale vector, which is a 2D vector. |
SetScale(number scale) | This action sets the scale component of the matrix to the passed scale value. |
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. |
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. |
SetToRotation(number degrees) | This action sets the matrix to the rotation matrix for the passed angle in degrees counter-clockwise. |
SetToRotationInRadians(number radians) | This action sets the matrix to the rotation matrix for the passed angle in radians. |
SetToScaling(number scaleX, number scaleY) | This action ses the matrix to a scaling matrix with the passed scales in the x and y directions. |
SetToScaling(Libraries.Compute.Vector2 scale) | This action ses the matrix to a scaling matrix with the passed vector as the scale vector. |
SetToTranslation(Libraries.Compute.Vector2 translation) | This action sets the matrix to a translation matrix by the given vector representing the translation. |
SetToTranslation(number x, number y) | This action sets the matrix to a translation matrix by the given x and y values. |
Transform(Libraries.Compute.Vector3 vector) | |
Translate(number x, number y) | This action translates the matrix by the given x and y translations. |
Translate(Libraries.Compute.Vector2 translation) | This action translates the matrix by the given translation vector. |
Transpose() | This action transposes the matrix. |
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.
Example Code
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 + "|"
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
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.
Example Code
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 + "|"
Parameters
- Libraries.Compute.Vector3: The vector to use as the translational component
Return
Libraries.Compute.Matrix3: The matrix with the translational component
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.
Example Code
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 + "|"
Parameters
- Libraries.Compute.Vector2: The vector to use as the translational component
Return
Libraries.Compute.Matrix3: The matrix with the translational component
Compare(Libraries.Language.Object object)
This action compares two object hash codes and returns a CompareResult. The compare result is either larger if this hash code is larger than the object passed as a parameter, smaller, or equal.
Example Code
use Libraries.Language.Support.CompareResult
Object o
Object t
CompareResult result = o:Compare(t)
Parameters
- Libraries.Language.Object: The object to compare to.
Return
Libraries.Language.Support.CompareResult: The Compare result, Smaller, Equal, or Larger.
Copy()
This action creates and returns a new matrix that is a copy of the calling matrix
Example Code
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 + "|"
Return
Libraries.Compute.Matrix3: A new matrix that is a copy of this matrix
Determinant()
This action computes the determinant of the matrix.
Example Code
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
Return
number: The determinant of the matrix
Equals(Libraries.Language.Object object)
This action determines if two objects are equal based on their hash code values.
Example Code
use Libraries.Language.Object
use Libraries.Language.Types.Text
Object o
Text t
boolean result = o:Equals(t)
Parameters
- Libraries.Language.Object: The to be compared.
Return
boolean: True if the hash codes are equal and false if they are not equal.
GetColumn(integer index)
Parameters
Return
GetElement(integer row, integer column)
Parameters
Return
number
GetHashCode()
This action gets the hash code for an object.
Example Code
Object o
integer hash = o:GetHashCode()
Return
integer: The integer hash code of the object.
GetRotation()
This action gets the rotation of the matrix in degrees.
Example Code
use Libraries.Compute.Matrix3
Matrix3 matrix
matrix:IdentityMatrix()
matrix:SetToRotation(45)
number rotation = matrix:GetRotation()
output "The rotation is " + rotation + " degrees."
Return
number: The rotation in degrees of the matrix
GetRotationInRadians()
This action gets the rotation of the matrix in radians.
Example Code
use Libraries.Compute.Matrix3
Matrix3 matrix
matrix:IdentityMatrix()
matrix:SetToRotation(45)
number rotation = matrix:GetRotationInRadians()
output "The rotation is " + rotation + " radians."
Return
number: The rotation in radians of the matrix
GetRow(integer index)
Parameters
Return
GetScale()
This action gets the scale component of the matrix.
Example Code
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() + "]"
Return
Libraries.Compute.Vector2: The scale component as a 2D vector (Vector2)
GetTranslation()
This action gets the translational component of the matrix.
Example Code
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() + "]"
Return
Libraries.Compute.Vector2: The translational component as a 2D vector (Vector2)
IdentityMatrix()
This action sets the matrix to the identity matrix.
Example Code
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 + "|"
Return
Libraries.Compute.Matrix3: The matrix as the identity matrix
Inverse()
This action computes the inverse of the 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 + "|"
Return
Libraries.Compute.Matrix3: The inverse of the matrix
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.
Example Code
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 + "|"
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
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.
Example Code
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 + "|"
Parameters
- Libraries.Compute.Matrix3: The matrix to multiply by
Return
Libraries.Compute.Matrix3: The calling matrix after multiplication
Rotate(number degrees)
This action rotates the matrix by the given angle in degrees.
Example Code
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 + "|"
Parameters
- number degrees: The angle in degrees
Return
Libraries.Compute.Matrix3: The matrix after rotation
RotateInRadians(number radians)
This action rotates the matrix by the given angle in radians.
Example Code
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 + "|"
Parameters
- number radians: The angle in radians
Return
Libraries.Compute.Matrix3: The matrix after rotation
Scale(Libraries.Compute.Vector2 scale)
This action scales the matrix by the given scale vector.
Example Code
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 + "|"
Parameters
- Libraries.Compute.Vector2: The scale vector
Return
Libraries.Compute.Matrix3: The matrix after scaling
Scale(number scaleX, number scaleY)
This action scales the matrix by the given scale values in the x and y directions.
Example Code
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 + "|"
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
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.
Example Code
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 + "|"
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
Set(Libraries.Compute.Matrix3 matrix)
This action sets the matrix to be a copy of the passed matrix.
Example Code
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 + "|"
Parameters
- Libraries.Compute.Matrix3: The matrix to set this matrix as
Return
Libraries.Compute.Matrix3: The matrix with the values from the other matrix
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.
Example Code
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 + "|"
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
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).
Example Code
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 + "|"
Parameters
- Libraries.Compute.Affine2: The affine to use to set the matrix
Return
Libraries.Compute.Matrix3: The matrix with the values from the affine
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.
Example Code
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 + "|"
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
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.
Example Code
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 + "|"
Parameters
- Libraries.Compute.Vector3: The scale vector to set as the scale component
Return
Libraries.Compute.Matrix3: The matrix with the scale component set
SetScale(Libraries.Compute.Vector2 scale)
This action sets the scale component of the matrix to the passed scale vector, which is a 2D vector.
Example Code
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 + "|"
Parameters
- Libraries.Compute.Vector2: The scale vector to set as the scale component
Return
Libraries.Compute.Matrix3: The matrix with the scale component set
SetScale(number scale)
This action sets the scale component of the matrix to the passed scale value.
Example Code
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 + "|"
Parameters
- number scale: The scale value to set
Return
Libraries.Compute.Matrix3: The matrix with the scale component set
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.
Example Code
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 + "|"
Parameters
- Libraries.Compute.Vector3: The rotation axis
- number degrees: The angle in degrees
Return
Libraries.Compute.Matrix3: The matrix as a rotation matrix
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.
Example Code
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 + "|"
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
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.
Example Code
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 + "|"
Parameters
- number degrees: The angle in degrees
Return
Libraries.Compute.Matrix3: The matrix as a rotation matrix
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.
Example Code
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 + "|"
Parameters
- number radians: The angle in radians
Return
Libraries.Compute.Matrix3: The matrix as a rotation matrix
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.
Example Code
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 + "|"
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
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.
Example Code
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 + "|"
Parameters
- Libraries.Compute.Vector2: The vector representing the scale
Return
Libraries.Compute.Matrix3: The matrix as a scale matrix
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.
Example Code
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 + "|"
Parameters
- Libraries.Compute.Vector2: The translation vector
Return
Libraries.Compute.Matrix3: The matrix as a translation matrix
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.
Example Code
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 + "|"
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
Transform(Libraries.Compute.Vector3 vector)
Parameters
Translate(number x, number y)
This action translates the matrix by the given x and y translations.
Example Code
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 + "|"
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
Translate(Libraries.Compute.Vector2 translation)
This action translates the matrix by the given translation vector.
Example Code
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 + "|"
Parameters
- Libraries.Compute.Vector2: The translation vector
Return
Libraries.Compute.Matrix3: The matrix after translation
Transpose()
This action transposes the matrix.
Example Code
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 + "|"
Return
Libraries.Compute.Matrix3: The transpose of the matrix