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

VariablesDescription
number row0column0
number row2column1
number row2column2
number row1column0
number row2column0
number row0column2
number row0column1
number row1column1
number row1column2

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

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

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

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

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

Libraries.Compute.Vector3:

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

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

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

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

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 row