Libraries.Compute.Matrix4 Documentation

Matrix4 is a class representing a 4x4 matrix.

Example Code

use Libraries.Compute.Matrix4

Matrix4 matrix

matrix:Set(2, 5, 0, 0, 1, 3, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)
matrix:Inverse()

number row0column0 = matrix:row0column0
number row0column1 = matrix:row0column1
number row0column2 = matrix:row0column2
number row0column3 = matrix:row0column3
number row1column0 = matrix:row1column0
number row1column1 = matrix:row1column1
number row1column2 = matrix:row1column2
number row1column3 = matrix:row1column3
number row2column0 = matrix:row2column0
number row2column1 = matrix:row2column1
number row2column2 = matrix:row2column2
number row2column3 = matrix:row2column3
number row3column0 = matrix:row3column0
number row3column1 = matrix:row3column1
number row3column2 = matrix:row3column2
number row3column3 = matrix:row3column3

output "The new matrix is:"
output "|" + row0column0 + ", " + row0column1 + ", " + row0column2 + ", " + row0column3 + "|"
output "|" + row1column0 + ", " + row1column1 + ", " + row1column2 + ", " + row1column3 + "|"
output "|" + row2column0 + ", " + row2column1 + ", " + row2column2 + ", " + row2column3 + "|"
output "|" + row3column0 + ", " + row3column1 + ", " + row3column2 + ", " + row3column3 + "|"

Inherits from: Libraries.Language.Object

Variables Table

VariablesDescription
number row2column0
number row0column3
number row1column0
number row3column1
number row1column2
number row3column2
number row0column1
number row3column3
number row2column2
number row2column1
number row3column0
number row0column2
number row0column0
number row1column3
number row2column3
number row1column1

Actions Documentation

Average(Libraries.Compute.Matrix4 other, number weight)

This action averages the matrix with the passed matrix. Translations and scales are done via a linear interpolation and rotations are done via a spherical linear interpolation.

Parameters

Return

Libraries.Compute.Matrix4: The matrix after averaging

Example

use Libraries.Compute.Matrix4

Matrix4 matrix
Matrix4 other

matrix:Set(2, 0, 3, 1, 0, 2, 1, 1, 0, 0, 2, 1, 0, 0, 0, 1)
other:Set(4, 0, 6, 2, 0, 4, 2, 2, 0, 0, 4, 2, 0, 0, 0, 2)

matrix:Average(other, 0.5)

number row0column0 = matrix:row0column0
number row0column1 = matrix:row0column1
number row0column2 = matrix:row0column2
number row0column3 = matrix:row0column3
number row1column0 = matrix:row1column0
number row1column1 = matrix:row1column1
number row1column2 = matrix:row1column2
number row1column3 = matrix:row1column3
number row2column0 = matrix:row2column0
number row2column1 = matrix:row2column1
number row2column2 = matrix:row2column2
number row2column3 = matrix:row2column3
number row3column0 = matrix:row3column0
number row3column1 = matrix:row3column1
number row3column2 = matrix:row3column2
number row3column3 = matrix:row3column3

output "The new matrix is:"
output "|" + row0column0 + ", " + row0column1 + ", " + row0column2 + ", " + row0column3 + "|"
output "|" + row1column0 + ", " + row1column1 + ", " + row1column2 + ", " + row1column3 + "|"
output "|" + row2column0 + ", " + row2column1 + ", " + row2column2 + ", " + row2column3 + "|"
output "|" + row3column0 + ", " + row3column1 + ", " + row3column2 + ", " + row3column3 + "|"

Compare(Libraries.Language.Object object)

This action compares two object hash codes and returns an integer. The result is larger if this hash code is larger than the object passed as a parameter, smaller, or equal. In this case, -1 means smaller, 0 means equal, and 1 means larger. This action was changed in Quorum 7 to return an integer, instead of a CompareResult object, because the previous implementation was causing efficiency issues.

Parameters

Return

integer: The Compare result, Smaller, Equal, or Larger.

Example

Object o
Object t
integer result = o:Compare(t) //1 (larger), 0 (equal), or -1 (smaller)

Copy()

This action creates a new matrix that is a copy of this matrix.

Return

Libraries.Compute.Matrix4: A new matrix that is a copy of this matrix

Example

use Libraries.Compute.Matrix4

Matrix4 matrix
Matrix4 copyMatrix

copyMatrix:Set(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15)

matrix = copyMatrix:Copy()

number row0column0 = matrix:row0column0
number row0column1 = matrix:row0column1
number row0column2 = matrix:row0column2
number row0column3 = matrix:row0column3
number row1column0 = matrix:row1column0
number row1column1 = matrix:row1column1
number row1column2 = matrix:row1column2
number row1column3 = matrix:row1column3
number row2column0 = matrix:row2column0
number row2column1 = matrix:row2column1
number row2column2 = matrix:row2column2
number row2column3 = matrix:row2column3
number row3column0 = matrix:row3column0
number row3column1 = matrix:row3column1
number row3column2 = matrix:row3column2
number row3column3 = matrix:row3column3

output "The new matrix is:"
output "|" + row0column0 + ", " + row0column1 + ", " + row0column2 + ", " + row0column3 + "|"
output "|" + row1column0 + ", " + row1column1 + ", " + row1column2 + ", " + row1column3 + "|"
output "|" + row2column0 + ", " + row2column1 + ", " + row2column2 + ", " + row2column3 + "|"
output "|" + row3column0 + ", " + row3column1 + ", " + row3column2 + ", " + row3column3 + "|"

Determinant()

This action computes the determinant of the matrix.

Return

number: The determinant of the matrix

Example

use Libraries.Compute.Matrix4

Matrix4 matrix

matrix:Set(2, 5, 0, 0, 1, 3, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)

number determinant = matrix:Determinant()

output "The determinant is " + determinant

Determinant3x3()

This action computes the determinant of the 3x3 matrix composed of the first three rows and first three columns of the 4x4 matrix.

Return

number: The determinant of the 3x3 upper left matrix

Example

use Libraries.Compute.Matrix4

Matrix4 matrix

matrix:Set(2, 5, 0, 0, 1, 3, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)

number determinant3x3 = matrix:Determinant3x3()

output "The determinant of the 3x3 upper left matrix is " + determinant3x3

Equals(Libraries.Language.Object object)

This action determines if two objects are equal based on their hash code values.

Parameters

Return

boolean: True if the hash codes are equal and false if they are not equal.

Example

use Libraries.Language.Object
use Libraries.Language.Types.Text
Object o
Text t
boolean result = o:Equals(t)

GetElement(integer row, integer column)

This action will multiply the provided vectors by the given Matrix4 (which can be this Matrix4 object or any other Matrix4). The results are stored in the array of Vector3 objects provided.

Parameters

  • integer row
  • integer column

Return

number:

Example

use Libraries.Compute.Matrix4
use Libraries.Compute.Vector3
use Libraries.Containers.Array

Vector3 vectorA
Vector3 vectorB
Array<Vector3> array
Matrix4 matrix

vectorA:Set(3.0, 4.0, 2.0)
vectorB:Set(-0.5, 2.0, 0)
array:Add(vectorA)
array:Add(vectorB)

matrix:row0column0 = 2 * 3 / (100 - 0)
matrix:row0column1 = 0
matrix:row0column2 = (100 + 0) / (100 - 0)
matrix:row0column3 = 0
matrix:row1column0 = 0
matrix:row1column1 = 2 * 3 / (100 - 0)
matrix:row1column2 = (100 + 0) / (100 - 0)
matrix:row1column3 = 0
matrix:row2column0 = 0
matrix:row2column1 = 0
matrix:row2column2 = -1 * (10 + 3) / (10 - 3)
matrix:row2column3 = -2 * 10 * 3 / (10 - 3)
matrix:row3column0 = 0
matrix:row3column1 = 0
matrix:row3column2 = -1
matrix:row3column3 = 0

matrix:Project(matrix, array)

integer counter = 0
repeat array:GetSize() times
    Vector3 vector = array:Get(counter)

    number newX = vector:GetX()
    number newY = vector:GetY()
    number newZ = vector:GetZ()

    output "The vector at array position " + counter + " is: [" + newX + ", " + newY + ", " + newZ + "]"

    counter = counter + 1
end

GetHashCode()

This action gets the hash code for an object.

Return

integer: The integer hash code of the object.

Example

Object o
integer hash = o:GetHashCode()

GetRotation(boolean normalizeAxes)

This action gets the rotation of the matrix and returns it as a Quaternion.

Parameters

  • boolean normalizeAxes: true to normalize the axes, false if not

Return

Libraries.Compute.Quaternion: The quaternion with the rotation of the matrix

Example

use Libraries.Compute.Matrix4
use Libraries.Compute.Quaternion

Matrix4 matrix

matrix:SetToRotation(0, 0, 1, 90)

Quaternion quaternion

quaternion = matrix:GetRotation(true)

number x = quaternion:GetX()
number y = quaternion:GetY()
number z = quaternion:GetZ()
number w = quaternion:GetW()

output "The rotation quaternion is : [" + x + ", " + y + ", " + z + ", " + w + "]"

GetRotation()

This action gets the rotation of the matrix and returns it as a Quaternion.

Return

Libraries.Compute.Quaternion: The quaternion with the rotation of the matrix

Example

use Libraries.Compute.Matrix4
use Libraries.Compute.Quaternion

Matrix4 matrix

matrix:SetToRotation(0, 0, 1, 90)

Quaternion quaternion

quaternion = matrix:GetRotation()

number x = quaternion:GetX()
number y = quaternion:GetY()
number z = quaternion:GetZ()
number w = quaternion:GetW()

output "The rotation quaternion is : [" + x + ", " + y + ", " + z + ", " + w + "]"

GetScale()

This action returns the scale components of each axis of the matrix.

Return

Libraries.Compute.Vector3: the scale vector

Example

use Libraries.Compute.Matrix4
use Libraries.Compute.Vector3

Matrix4 matrix

matrix:SetToScaling(2, 3, 4)

Vector3 scale = matrix:GetScale()

number x = scale:GetX()
number y = scale:GetY()
number z = scale:GetZ()

output "The scale vector is: [ " + x ", " + y + ", " + z + "]"

GetScaleX()

This action gets the x-component of the scale of the matrix.

Return

number: The x-component of the scale of the matrix

Example

use Libraries.Compute.Matrix4

Matrix4 matrix

matrix:SetToScaling(2, 3, 4)

number scaleX = matrix:GetScaleX()

output "The x-component of the scale is " + scaleX

GetScaleXSquared()

This action gets the square of the x-component of the scale of the matrix.

Return

number: The square of the x-component of the scale of the matrix

Example

use Libraries.Compute.Matrix4

Matrix4 matrix

matrix:SetToScaling(2, 3, 4)

number scaleXSquared = matrix:GetScaleXSquared()

output "The square of the x-component of the scale is " + scaleXSquared

GetScaleY()

This action gets the y-component of the scale of the matrix.

Return

number: The y-component of the scale of the matrix

Example

use Libraries.Compute.Matrix4

Matrix4 matrix

matrix:SetToScaling(2, 3, 4)

number scaleY = matrix:GetScaleY()

output "The y-component of the scale is " + scaleY

GetScaleYSquared()

This action gets the square of the y-component of the scale of the matrix.

Return

number: The square of the y-component of the scale of the matrix

Example

use Libraries.Compute.Matrix4

Matrix4 matrix

matrix:SetToScaling(2, 3, 4)

number scaleYSquared = matrix:GetScaleYSquared()

output "The square of the y-component of the scale is " + scaleYSquared

GetScaleZ()

This action gets the z-component of the scale of the matrix.

Return

number: The z-component of the scale of the matrix

Example

use Libraries.Compute.Matrix4

Matrix4 matrix

matrix:SetToScaling(2, 3, 4)

number scaleZ = matrix:GetScaleZ()

output "The z-component of the scale is " + scaleZ

GetScaleZSquared()

This action gets the square of the z-component of the scale of the matrix.

Return

number: The square of the z-component of the scale of the matrix

Example

use Libraries.Compute.Matrix4

Matrix4 matrix

matrix:SetToScaling(2, 3, 4)

number scaleXZSquared = matrix:GetScaleZSquared()

output "The square of the z-component of the scale is " + scaleZSquared

GetTranslation()

This action gets the translational component of the matrix..

Return

Libraries.Compute.Vector3: The translation component of the matrix

Example

use Libraries.Compute.Matrix4
use Libraries.Compute.Vector3

Matrix4 matrix

matrix:SetToTranslationAndScaling(1, 1, 1, 2, 2, 2)

Vector3 translation

translation = matrix:GetTranslation()

number x = translation:GetX()
number y = translation:GetY()
number z = translation:GetZ()

output "The translation vector is: [" + x + ", " + y + ", " + z + "]"

IdentityMatrix()

This action sets the matrix to the 4x4 identity matrix.

Return

Libraries.Compute.Matrix4: The matrix as the 4x4 identity matrix

Example

use Libraries.Compute.Matrix4

Matrix4 matrix

matrix:IdentityMatrix()

number row0column0 = matrix:row0column0
number row0column1 = matrix:row0column1
number row0column2 = matrix:row0column2
number row0column3 = matrix:row0column3
number row1column0 = matrix:row1column0
number row1column1 = matrix:row1column1
number row1column2 = matrix:row1column2
number row1column3 = matrix:row1column3
number row2column0 = matrix:row2column0
number row2column1 = matrix:row2column1
number row2column2 = matrix:row2column2
number row2column3 = matrix:row2column3
number row3column0 = matrix:row3column0
number row3column1 = matrix:row3column1
number row3column2 = matrix:row3column2
number row3column3 = matrix:row3column3

output "The new matrix is:"
output "|" + row0column0 + ", " + row0column1 + ", " + row0column2 + ", " + row0column3 + "|"
output "|" + row1column0 + ", " + row1column1 + ", " + row1column2 + ", " + row1column3 + "|"
output "|" + row2column0 + ", " + row2column1 + ", " + row2column2 + ", " + row2column3 + "|"
output "|" + row3column0 + ", " + row3column1 + ", " + row3column2 + ", " + row3column3 + "|"

Inverse()

This action computes the inverse of the matrix

Return

Libraries.Compute.Matrix4: The inverted matrix

Example

use Libraries.Compute.Matrix4

Matrix4 matrix

matrix:Set(2, 5, 0, 0, 1, 3, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)
matrix:Inverse()

number row0column0 = matrix:row0column0
number row0column1 = matrix:row0column1
number row0column2 = matrix:row0column2
number row0column3 = matrix:row0column3
number row1column0 = matrix:row1column0
number row1column1 = matrix:row1column1
number row1column2 = matrix:row1column2
number row1column3 = matrix:row1column3
number row2column0 = matrix:row2column0
number row2column1 = matrix:row2column1
number row2column2 = matrix:row2column2
number row2column3 = matrix:row2column3
number row3column0 = matrix:row3column0
number row3column1 = matrix:row3column1
number row3column2 = matrix:row3column2
number row3column3 = matrix:row3column3

output "The new matrix is:"
output "|" + row0column0 + ", " + row0column1 + ", " + row0column2 + ", " + row0column3 + "|"
output "|" + row1column0 + ", " + row1column1 + ", " + row1column2 + ", " + row1column3 + "|"
output "|" + row2column0 + ", " + row2column1 + ", " + row2column2 + ", " + row2column3 + "|"
output "|" + row3column0 + ", " + row3column1 + ", " + row3column2 + ", " + row3column3 + "|"

LinearInterpolation(Libraries.Compute.Matrix4 matrix, number alpha)

This action performs a linear interpolation between the matrix and the passed matrix by alpha. The alpha value must be between 0 and 1 inclusive.

Parameters

Return

Libraries.Compute.Matrix4: the linear interpolation of the two matrices

Example

use Libraries.Compute.Matrix3

Matrix3 matrix
Matrix3 otherMatrix

matrix:Set(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15)
otherMatrix:Set(15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0)

matrix:LinearInterpolation(otherMatrix, 0.5)

number row0column0 = matrix:row0column0
number row0column1 = matrix:row0column1
number row0column2 = matrix:row0column2
number row0column3 = matrix:row0column3
number row1column0 = matrix:row1column0
number row1column1 = matrix:row1column1
number row1column2 = matrix:row1column2
number row1column3 = matrix:row1column3
number row2column0 = matrix:row2column0
number row2column1 = matrix:row2column1
number row2column2 = matrix:row2column2
number row2column3 = matrix:row2column3
number row3column0 = matrix:row3column0
number row3column1 = matrix:row3column1
number row3column2 = matrix:row3column2
number row3column3 = matrix:row3column3

output "The new matrix is:"
output "|" + row0column0 + ", " + row0column1 + ", " + row0column2 + ", " + row0column3 + "|"
output "|" + row1column0 + ", " + row1column1 + ", " + row1column2 + ", " + row1column3 + "|"
output "|" + row2column0 + ", " + row2column1 + ", " + row2column2 + ", " + row2column3 + "|"
output "|" + row3column0 + ", " + row3column1 + ", " + row3column2 + ", " + row3column3 + "|"

Multiply(Libraries.Compute.Matrix4 matrix)

This action multiplies the calling matrix by the passed matrix.

Parameters

Return

Libraries.Compute.Matrix4: The matrix after multiplication

Example

use Libraries.Compute.Matrix4

Matrix4 matrix
Matrix4 otherMatrix

matrix:Set(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15)
otherMatrix:Set(15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0)

matrix:Multiply(otherMatrix)

number row0column0 = matrix:row0column0
number row0column1 = matrix:row0column1
number row0column2 = matrix:row0column2
number row0column3 = matrix:row0column3
number row1column0 = matrix:row1column0
number row1column1 = matrix:row1column1
number row1column2 = matrix:row1column2
number row1column3 = matrix:row1column3
number row2column0 = matrix:row2column0
number row2column1 = matrix:row2column1
number row2column2 = matrix:row2column2
number row2column3 = matrix:row2column3
number row3column0 = matrix:row3column0
number row3column1 = matrix:row3column1
number row3column2 = matrix:row3column2
number row3column3 = matrix:row3column3

output "The new matrix is:"
output "|" + row0column0 + ", " + row0column1 + ", " + row0column2 + ", " + row0column3 + "|"
output "|" + row1column0 + ", " + row1column1 + ", " + row1column2 + ", " + row1column3 + "|"
output "|" + row2column0 + ", " + row2column1 + ", " + row2column2 + ", " + row2column3 + "|"
output "|" + row3column0 + ", " + row3column1 + ", " + row3column2 + ", " + row3column3 + "|"

Multiply(Libraries.Compute.Matrix4 matrixA, Libraries.Compute.Matrix4 matrixB)

This action multiplies the two passed matrices.

Parameters

Return

Libraries.Compute.Matrix4: The product of the two matrices

Example

use Libraries.Compute.Matrix4

Matrix4 matrix
Matrix4 matrixA
Matrix4 matrixB

matrixA:Set(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15)
matrixB:Set(15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0)

matrix:Multiply(matrixA, matrixB)

number row0column0 = matrix:row0column0
number row0column1 = matrix:row0column1
number row0column2 = matrix:row0column2
number row0column3 = matrix:row0column3
number row1column0 = matrix:row1column0
number row1column1 = matrix:row1column1
number row1column2 = matrix:row1column2
number row1column3 = matrix:row1column3
number row2column0 = matrix:row2column0
number row2column1 = matrix:row2column1
number row2column2 = matrix:row2column2
number row2column3 = matrix:row2column3
number row3column0 = matrix:row3column0
number row3column1 = matrix:row3column1
number row3column2 = matrix:row3column2
number row3column3 = matrix:row3column3

output "The new matrix is:"
output "|" + row0column0 + ", " + row0column1 + ", " + row0column2 + ", " + row0column3 + "|"
output "|" + row1column0 + ", " + row1column1 + ", " + row1column2 + ", " + row1column3 + "|"
output "|" + row2column0 + ", " + row2column1 + ", " + row2column2 + ", " + row2column3 + "|"
output "|" + row3column0 + ", " + row3column1 + ", " + row3column2 + ", " + row3column3 + "|"

Project(Libraries.Compute.Matrix4 matrix, Libraries.Containers.Array<Libraries.Compute.Vector3> vectors)

This action will multiply the provided vectors by the given Matrix4 (which can be this Matrix4 object or any other Matrix4). The results are stored in the array of Vector3 objects provided.

Parameters

Example

use Libraries.Compute.Matrix4
use Libraries.Compute.Vector3
use Libraries.Containers.Array

Vector3 vectorA
Vector3 vectorB
Array<Vector3> array
Matrix4 matrix

vectorA:Set(3.0, 4.0, 2.0)
vectorB:Set(-0.5, 2.0, 0)
array:Add(vectorA)
array:Add(vectorB)

matrix:row0column0 = 2 * 3 / (100 - 0)
matrix:row0column1 = 0
matrix:row0column2 = (100 + 0) / (100 - 0)
matrix:row0column3 = 0
matrix:row1column0 = 0
matrix:row1column1 = 2 * 3 / (100 - 0)
matrix:row1column2 = (100 + 0) / (100 - 0)
matrix:row1column3 = 0
matrix:row2column0 = 0
matrix:row2column1 = 0
matrix:row2column2 = -1 * (10 + 3) / (10 - 3)
matrix:row2column3 = -2 * 10 * 3 / (10 - 3)
matrix:row3column0 = 0
matrix:row3column1 = 0
matrix:row3column2 = -1
matrix:row3column3 = 0

matrix:Project(matrix, array)

integer counter = 0
repeat array:GetSize() times
    Vector3 vector = array:Get(counter)

    number newX = vector:GetX()
    number newY = vector:GetY()
    number newZ = vector:GetZ()

    output "The vector at array position " + counter + " is: [" + newX + ", " + newY + ", " + newZ + "]"

    counter = counter + 1
end

Project(Libraries.Compute.Matrix4 matrix, Libraries.Compute.Vector3 vector)

This action performs a projection with the given matrix and vector. The result is stored in the vector.

Parameters

Example

use Libraries.Compute.Matrix4
use Libraries.Compute.Vector3

Vector3 vector
Matrix4 matrix

vector:Set(3.0, 4.0, 2.0)

matrix:row0column0 = 2 * 3 / (100 - 0)
matrix:row0column1 = 0
matrix:row0column2 = (100 + 0) / (100 - 0)
matrix:row0column3 = 0
matrix:row1column0 = 0
matrix:row1column1 = 2 * 3 / (100 - 0)
matrix:row1column2 = (100 + 0) / (100 - 0)
matrix:row1column3 = 0
matrix:row2column0 = 0
matrix:row2column1 = 0
matrix:row2column2 = -1 * (10 + 3) / (10 - 3)
matrix:row2column3 = -2 * 10 * 3 / (10 - 3)
matrix:row3column0 = 0
matrix:row3column1 = 0
matrix:row3column2 = -1
matrix:row3column3 = 0

matrix:Project(matrix, vector)

number newX = vector:GetX()
number newY = vector:GetY()
number newZ = vector:GetZ()

output "The new vector is: [" + newX + ", " + newY + ", " + newZ + "]"

Rotate(Libraries.Compute.Quaternion rotation)

This action rotates the matrix by the given quaternion specifying the rotation.

Parameters

Return

Libraries.Compute.Matrix4: The matrix rotated

Example

use Libraries.Compute.Matrix4
use Libraries.Compute.Quaternion

Matrix4 matrix
Quaternion quaternion

quaternion:Set(1, 2, 3, 4)
matrix:Set(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15)

matrix:Rotate(quaternion)

number row0column1 = matrix:row0column1
number row0column2 = matrix:row0column2
number row0column3 = matrix:row0column3
number row1column0 = matrix:row1column0
number row1column1 = matrix:row1column1
number row1column2 = matrix:row1column2
number row1column3 = matrix:row1column3
number row2column0 = matrix:row2column0
number row2column1 = matrix:row2column1
number row2column2 = matrix:row2column2
number row2column3 = matrix:row2column3
number row3column0 = matrix:row3column0
number row3column1 = matrix:row3column1
number row3column2 = matrix:row3column2
number row3column3 = matrix:row3column3

output "The new matrix is:"
output "|" + row0column0 + ", " + row0column1 + ", " + row0column2 + ", " + row0column3 + "|"
output "|" + row1column0 + ", " + row1column1 + ", " + row1column2 + ", " + row1column3 + "|"
output "|" + row2column0 + ", " + row2column1 + ", " + row2column2 + ", " + row2column3 + "|"
output "|" + row3column0 + ", " + row3column1 + ", " + row3column2 + ", " + row3column3 + "|"

Rotate(Libraries.Compute.Vector3 axis, number degrees)

This action rotates the matrix around the given axis by the given angle in degrees.

Parameters

Return

Libraries.Compute.Matrix4: The matrix rotated

Example

use Libraries.Compute.Matrix4
use Libraries.Compute.Vector3

Matrix4 matrix
Vector3 axis

axis:Set(0, 0, 1)

matrix:Set(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15)

matrix:Rotate(axis, 90)

number row0column0 = matrix:row0column0
number row0column1 = matrix:row0column1
number row0column2 = matrix:row0column2
number row0column3 = matrix:row0column3
number row1column0 = matrix:row1column0
number row1column1 = matrix:row1column1
number row1column2 = matrix:row1column2
number row1column3 = matrix:row1column3
number row2column0 = matrix:row2column0
number row2column1 = matrix:row2column1
number row2column2 = matrix:row2column2
number row2column3 = matrix:row2column3
number row3column0 = matrix:row3column0
number row3column1 = matrix:row3column1
number row3column2 = matrix:row3column2
number row3column3 = matrix:row3column3

output "The new matrix is:"
output "|" + row0column0 + ", " + row0column1 + ", " + row0column2 + ", " + row0column3 + "|"
output "|" + row1column0 + ", " + row1column1 + ", " + row1column2 + ", " + row1column3 + "|"
output "|" + row2column0 + ", " + row2column1 + ", " + row2column2 + ", " + row2column3 + "|"
output "|" + row3column0 + ", " + row3column1 + ", " + row3column2 + ", " + row3column3 + "|"

Rotate(number axisX, number axisY, number axisZ, number degrees)

This action rotates the matrix around the given axis by the given angle in degrees.

Parameters

  • number axisX: The x-component of the axis
  • number axisY: The y-component of the axis
  • number axisZ: The z-component of the axis
  • number degrees: The angle to rotate in degrees

Return

Libraries.Compute.Matrix4: The matrix rotated

Example

use Libraries.Compute.Matrix4

Matrix4 matrix

matrix:Set(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15)

matrix:Rotate(0, 0, 1, 90)

number row0column0 = matrix:row0column0
number row0column1 = matrix:row0column1
number row0column2 = matrix:row0column2
number row0column3 = matrix:row0column3
number row1column0 = matrix:row1column0
number row1column1 = matrix:row1column1
number row1column2 = matrix:row1column2
number row1column3 = matrix:row1column3
number row2column0 = matrix:row2column0
number row2column1 = matrix:row2column1
number row2column2 = matrix:row2column2
number row2column3 = matrix:row2column3
number row3column0 = matrix:row3column0
number row3column1 = matrix:row3column1
number row3column2 = matrix:row3column2
number row3column3 = matrix:row3column3

output "The new matrix is:"
output "|" + row0column0 + ", " + row0column1 + ", " + row0column2 + ", " + row0column3 + "|"
output "|" + row1column0 + ", " + row1column1 + ", " + row1column2 + ", " + row1column3 + "|"
output "|" + row2column0 + ", " + row2column1 + ", " + row2column2 + ", " + row2column3 + "|"
output "|" + row3column0 + ", " + row3column1 + ", " + row3column2 + ", " + row3column3 + "|"

Rotate(Libraries.Compute.Vector3 base, Libraries.Compute.Vector3 target)

This action rotates the matrix by the rotation between the two passed vectors.

Parameters

Return

Libraries.Compute.Matrix4: The matrix rotated

Example

use Libraries.Compute.Matrix4
use Libraries.Compute.Vector3

Matrix4 matrix
Vector3 base
Vector3 target

base:Set(1, 0, 0)
target:Set(0, 1, 0)

matrix:Set(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15)

matrix:Rotate(base, target)

number row0column1 = matrix:row0column1
number row0column2 = matrix:row0column2
number row0column3 = matrix:row0column3
number row1column0 = matrix:row1column0
number row1column1 = matrix:row1column1
number row1column2 = matrix:row1column2
number row1column3 = matrix:row1column3
number row2column0 = matrix:row2column0
number row2column1 = matrix:row2column1
number row2column2 = matrix:row2column2
number row2column3 = matrix:row2column3
number row3column0 = matrix:row3column0
number row3column1 = matrix:row3column1
number row3column2 = matrix:row3column2
number row3column3 = matrix:row3column3

output "The new matrix is:"
output "|" + row0column0 + ", " + row0column1 + ", " + row0column2 + ", " + row0column3 + "|"
output "|" + row1column0 + ", " + row1column1 + ", " + row1column2 + ", " + row1column3 + "|"
output "|" + row2column0 + ", " + row2column1 + ", " + row2column2 + ", " + row2column3 + "|"
output "|" + row3column0 + ", " + row3column1 + ", " + row3column2 + ", " + row3column3 + "|"

RotateRadians(Libraries.Compute.Vector3 axis, number radians)

This action rotates the matrix around the given axis by the given angle in radians.

Parameters

Return

Libraries.Compute.Matrix4: The matrix rotated

Example

use Libraries.Compute.Matrix4
use Libraries.Compute.Vector3
use Libraries.Compute.Math

Math math

Matrix4 matrix
Vector3 axis

axis:Set(0, 0, 1)

matrix:Set(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15)

matrix:RotateRadians(axis, math:pi / 2)

number row0column0 = matrix:row0column0
number row0column1 = matrix:row0column1
number row0column2 = matrix:row0column2
number row0column3 = matrix:row0column3
number row1column0 = matrix:row1column0
number row1column1 = matrix:row1column1
number row1column2 = matrix:row1column2
number row1column3 = matrix:row1column3
number row2column0 = matrix:row2column0
number row2column1 = matrix:row2column1
number row2column2 = matrix:row2column2
number row2column3 = matrix:row2column3
number row3column0 = matrix:row3column0
number row3column1 = matrix:row3column1
number row3column2 = matrix:row3column2
number row3column3 = matrix:row3column3

output "The new matrix is:"
output "|" + row0column0 + ", " + row0column1 + ", " + row0column2 + ", " + row0column3 + "|"
output "|" + row1column0 + ", " + row1column1 + ", " + row1column2 + ", " + row1column3 + "|"
output "|" + row2column0 + ", " + row2column1 + ", " + row2column2 + ", " + row2column3 + "|"
output "|" + row3column0 + ", " + row3column1 + ", " + row3column2 + ", " + row3column3 + "|"

RotateRadians(number axisX, number axisY, number axisZ, number radians)

This action rotates the matrix around the given axis by the given angle in radians.

Parameters

  • number axisX: The x-component of the axis
  • number axisY: The y-component of the axis
  • number axisZ: The z-component of the axis
  • number radians

Return

Libraries.Compute.Matrix4: The matrix rotated

Example

use Libraries.Compute.Matrix4
use Libraries.Compute.Math

Math math

Matrix4 matrix

matrix:Set(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15)

matrix:RotateRadians(0, 0, 1, math:pi / 2)

number row0column0 = matrix:row0column0
number row0column1 = matrix:row0column1
number row0column2 = matrix:row0column2
number row0column3 = matrix:row0column3
number row1column0 = matrix:row1column0
number row1column1 = matrix:row1column1
number row1column2 = matrix:row1column2
number row1column3 = matrix:row1column3
number row2column0 = matrix:row2column0
number row2column1 = matrix:row2column1
number row2column2 = matrix:row2column2
number row2column3 = matrix:row2column3
number row3column0 = matrix:row3column0
number row3column1 = matrix:row3column1
number row3column2 = matrix:row3column2
number row3column3 = matrix:row3column3

output "The new matrix is:"
output "|" + row0column0 + ", " + row0column1 + ", " + row0column2 + ", " + row0column3 + "|"
output "|" + row1column0 + ", " + row1column1 + ", " + row1column2 + ", " + row1column3 + "|"
output "|" + row2column0 + ", " + row2column1 + ", " + row2column2 + ", " + row2column3 + "|"
output "|" + row3column0 + ", " + row3column1 + ", " + row3column2 + ", " + row3column3 + "|"

Scale(Libraries.Compute.Vector3 scale)

This action scales the scaling portion of the transformation matrix by the passed scale vector.

Parameters

Return

Libraries.Compute.Matrix4: The matrix after scaling

Example

use Libraries.Compute.Matrix4
use Libraries.Compute.Vector3

Matrix4 matrix
Vector3 scale

matrix:IdentityMatrix()

scale:Set(2, 2, 2)

matrix:Scale(scale)

number row0column0 = matrix:row0column0
number row0column1 = matrix:row0column1
number row0column2 = matrix:row0column2
number row0column3 = matrix:row0column3
number row1column0 = matrix:row1column0
number row1column1 = matrix:row1column1
number row1column2 = matrix:row1column2
number row1column3 = matrix:row1column3
number row2column0 = matrix:row2column0
number row2column1 = matrix:row2column1
number row2column2 = matrix:row2column2
number row2column3 = matrix:row2column3
number row3column0 = matrix:row3column0
number row3column1 = matrix:row3column1
number row3column2 = matrix:row3column2
number row3column3 = matrix:row3column3

output "The new matrix is:"
output "|" + row0column0 + ", " + row0column1 + ", " + row0column2 + ", " + row0column3 + "|"
output "|" + row1column0 + ", " + row1column1 + ", " + row1column2 + ", " + row1column3 + "|"
output "|" + row2column0 + ", " + row2column1 + ", " + row2column2 + ", " + row2column3 + "|"
output "|" + row3column0 + ", " + row3column1 + ", " + row3column2 + ", " + row3column3 + "|"

Scale(number scale)

This action scales the scaling portion of the transformation matrix by the passed scale value.

Parameters

  • number scale: The scale value

Return

Libraries.Compute.Matrix4: The matrix after scaling

Example

use Libraries.Compute.Matrix4

Matrix4 matrix

matrix:IdentityMatrix()

matrix:Scale(2)

number row0column0 = matrix:row0column0
number row0column1 = matrix:row0column1
number row0column2 = matrix:row0column2
number row0column3 = matrix:row0column3
number row1column0 = matrix:row1column0
number row1column1 = matrix:row1column1
number row1column2 = matrix:row1column2
number row1column3 = matrix:row1column3
number row2column0 = matrix:row2column0
number row2column1 = matrix:row2column1
number row2column2 = matrix:row2column2
number row2column3 = matrix:row2column3
number row3column0 = matrix:row3column0
number row3column1 = matrix:row3column1
number row3column2 = matrix:row3column2
number row3column3 = matrix:row3column3

output "The new matrix is:"
output "|" + row0column0 + ", " + row0column1 + ", " + row0column2 + ", " + row0column3 + "|"
output "|" + row1column0 + ", " + row1column1 + ", " + row1column2 + ", " + row1column3 + "|"
output "|" + row2column0 + ", " + row2column1 + ", " + row2column2 + ", " + row2column3 + "|"
output "|" + row3column0 + ", " + row3column1 + ", " + row3column2 + ", " + row3column3 + "|"

Scale(number scaleX, number scaleY, number scaleZ)

This action scales the scaling portion of the transformation matrix by the passed scale vector.

Parameters

  • number scaleX: The x-component of the scale
  • number scaleY: The y-component of the scale
  • number scaleZ: The z-component of the scale

Return

Libraries.Compute.Matrix4: The matrix after scaling

Example

use Libraries.Compute.Matrix4

Matrix4 matrix
matrix:IdentityMatrix()

matrix:Scale(2, 2, 2)

number row0column0 = matrix:row0column0
number row0column1 = matrix:row0column1
number row0column2 = matrix:row0column2
number row0column3 = matrix:row0column3
number row1column0 = matrix:row1column0
number row1column1 = matrix:row1column1
number row1column2 = matrix:row1column2
number row1column3 = matrix:row1column3
number row2column0 = matrix:row2column0
number row2column1 = matrix:row2column1
number row2column2 = matrix:row2column2
number row2column3 = matrix:row2column3
number row3column0 = matrix:row3column0
number row3column1 = matrix:row3column1
number row3column2 = matrix:row3column2
number row3column3 = matrix:row3column3

output "The new matrix is:"
output "|" + row0column0 + ", " + row0column1 + ", " + row0column2 + ", " + row0column3 + "|"
output "|" + row1column0 + ", " + row1column1 + ", " + row1column2 + ", " + row1column3 + "|"
output "|" + row2column0 + ", " + row2column1 + ", " + row2column2 + ", " + row2column3 + "|"
output "|" + row3column0 + ", " + row3column1 + ", " + row3column2 + ", " + row3column3 + "|"

Set(Libraries.Compute.Matrix4 matrix)

This action sets the matrix to be a copy of the passed matrix.

Parameters

Return

Libraries.Compute.Matrix4: The matrix with the values from the other matrix

Example

use Libraries.Compute.Matrix4

Matrix4 matrix
Matrix4 copyMatrix

copyMatrix:Set(15, 14, 13, 12, 11, 10, 9, 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 row0column3 = matrix:row0column3
number row1column0 = matrix:row1column0
number row1column1 = matrix:row1column1
number row1column2 = matrix:row1column2
number row1column3 = matrix:row1column3
number row2column0 = matrix:row2column0
number row2column1 = matrix:row2column1
number row2column2 = matrix:row2column2
number row2column3 = matrix:row2column3
number row3column0 = matrix:row3column0
number row3column1 = matrix:row3column1
number row3column2 = matrix:row3column2
number row3column3 = matrix:row3column3

output "The new matrix is:"
output "|" + row0column0 + ", " + row0column1 + ", " + row0column2 + ", " + row0column3 + "|"
output "|" + row1column0 + ", " + row1column1 + ", " + row1column2 + ", " + row1column3 + "|"
output "|" + row2column0 + ", " + row2column1 + ", " + row2column2 + ", " + row2column3 + "|"
output "|" + row3column0 + ", " + row3column1 + ", " + row3column2 + ", " + row3column3 + "|"

Set(Libraries.Compute.Matrix3 matrix)

This action sets the matrix using the passed 3x3 matrix. The third column of this matrix is set to (0, 0, 1, 0).

Parameters

Return

Libraries.Compute.Matrix4: The matrix set as the 3x3 matrix

Example

use Libraries.Compute.Matrix4
use Libraries.Compute.Matrix3

Matrix4 matrix
Matrix3 setMatrix

setMatrix:Set(0, 1, 2, 3, 4, 5, 6, 7, 8)

matrix:Set(setMatrix)

number row0column0 = matrix:row0column0
number row0column1 = matrix:row0column1
number row0column2 = matrix:row0column2
number row0column3 = matrix:row0column3
number row1column0 = matrix:row1column0
number row1column1 = matrix:row1column1
number row1column2 = matrix:row1column2
number row1column3 = matrix:row1column3
number row2column0 = matrix:row2column0
number row2column1 = matrix:row2column1
number row2column2 = matrix:row2column2
number row2column3 = matrix:row2column3
number row3column0 = matrix:row3column0
number row3column1 = matrix:row3column1
number row3column2 = matrix:row3column2
number row3column3 = matrix:row3column3

output "The new matrix is:"
output "|" + row0column0 + ", " + row0column1 + ", " + row0column2 + ", " + row0column3 + "|"
output "|" + row1column0 + ", " + row1column1 + ", " + row1column2 + ", " + row1column3 + "|"
output "|" + row2column0 + ", " + row2column1 + ", " + row2column2 + ", " + row2column3 + "|"
output "|" + row3column0 + ", " + row3column1 + ", " + row3column2 + ", " + row3column3 + "|"

Set(Libraries.Containers.Array<number> array)

This action sets the values of the matrix using the values of the passed array. The array is assumed to be in row order. That is, 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

Return

Libraries.Compute.Matrix4: The matrix with the values from the array

Example

use Libraries.Compute.Matrix4
use Libraries.Containers.Array

Matrix4 matrix
Array<number> array

integer i = 0
repeat 16 times
    array:Add(i)
    i = i + 1
end

matrix:Set(array)

number row0column0 = matrix:row0column0
number row0column1 = matrix:row0column1
number row0column2 = matrix:row0column2
number row0column3 = matrix:row0column3
number row1column0 = matrix:row1column0
number row1column1 = matrix:row1column1
number row1column2 = matrix:row1column2
number row1column3 = matrix:row1column3
number row2column0 = matrix:row2column0
number row2column1 = matrix:row2column1
number row2column2 = matrix:row2column2
number row2column3 = matrix:row2column3
number row3column0 = matrix:row3column0
number row3column1 = matrix:row3column1
number row3column2 = matrix:row3column2
number row3column3 = matrix:row3column3

output "The new matrix is:"
output "|" + row0column0 + ", " + row0column1 + ", " + row0column2 + ", " + row0column3 + "|"
output "|" + row1column0 + ", " + row1column1 + ", " + row1column2 + ", " + row1column3 + "|"
output "|" + row2column0 + ", " + row2column1 + ", " + row2column2 + ", " + row2column3 + "|"
output "|" + row3column0 + ", " + row3column1 + ", " + row3column2 + ", " + row3column3 + "|"

Set(number translationX, number translationY, number translationZ, number quaternionX, number quaternionY, number quaternionZ, number quaternionW)

This action sets the matrix to the passed translation and rotation.

Parameters

  • number translationX: The x-component of the translation vector
  • number translationY: The y-component of the translation vector
  • number translationZ: The z-component of the translation vector
  • number quaternionX: The x-component of the quaternion
  • number quaternionY: The y-component of the quaternion
  • number quaternionZ: The z-component of the quaternion
  • number quaternionW: The w-component of the quaternion

Return

Libraries.Compute.Matrix4: The matrix with the passed translation and rotation

Example

use Libraries.Compute.Matrix4

Matrix4 matrix

matrix:Set(1, 2, 3, 0, 0, 1, 0)

number row0column0 = matrix:row0column0
number row0column1 = matrix:row0column1
number row0column2 = matrix:row0column2
number row0column3 = matrix:row0column3
number row1column0 = matrix:row1column0
number row1column1 = matrix:row1column1
number row1column2 = matrix:row1column2
number row1column3 = matrix:row1column3
number row2column0 = matrix:row2column0
number row2column1 = matrix:row2column1
number row2column2 = matrix:row2column2
number row2column3 = matrix:row2column3
number row3column0 = matrix:row3column0
number row3column1 = matrix:row3column1
number row3column2 = matrix:row3column2
number row3column3 = matrix:row3column3

output "The new matrix is:"
output "|" + row0column0 + ", " + row0column1 + ", " + row0column2 + ", " + row0column3 + "|"
output "|" + row1column0 + ", " + row1column1 + ", " + row1column2 + ", " + row1column3 + "|"
output "|" + row2column0 + ", " + row2column1 + ", " + row2column2 + ", " + row2column3 + "|"
output "|" + row3column0 + ", " + row3column1 + ", " + row3column2 + ", " + row3column3 + "|"

Set(Libraries.Compute.Affine2 affine)

This action sets the matrix to the given affine matrix.

Parameters

Return

Libraries.Compute.Matrix4: The matrix set to the affine

Example

use Libraries.Compute.Matrix4
use Libraries.Compute.Affine2

Matrix4 matrix
Affine2 affine

affine:Identity()

matrix:Set(affine)

number row0column0 = matrix:row0column0
number row0column1 = matrix:row0column1
number row0column2 = matrix:row0column2
number row0column3 = matrix:row0column3
number row1column0 = matrix:row1column0
number row1column1 = matrix:row1column1
number row1column2 = matrix:row1column2
number row1column3 = matrix:row1column3
number row2column0 = matrix:row2column0
number row2column1 = matrix:row2column1
number row2column2 = matrix:row2column2
number row2column3 = matrix:row2column3
number row3column0 = matrix:row3column0
number row3column1 = matrix:row3column1
number row3column2 = matrix:row3column2
number row3column3 = matrix:row3column3

output "The new matrix is:"
output "|" + row0column0 + ", " + row0column1 + ", " + row0column2 + ", " + row0column3 + "|"
output "|" + row1column0 + ", " + row1column1 + ", " + row1column2 + ", " + row1column3 + "|"
output "|" + row2column0 + ", " + row2column1 + ", " + row2column2 + ", " + row2column3 + "|"
output "|" + row3column0 + ", " + row3column1 + ", " + row3column2 + ", " + row3column3 + "|"

Set(number quaternionX, number quaternionY, number quaternionZ, number quaternionW)

This action sets the matrix to a rotation matrix representing the passed Quaternion values. This action is mainly useful for graphics programming.

Parameters

  • number quaternionX: The x-component of the quaternion
  • number quaternionY: The y-component of the quaternion
  • number quaternionZ: The z-component of the quaternion
  • number quaternionW: The w-component of the quaternion

Return

Libraries.Compute.Matrix4: The matrix as a rotation matrix representing the Quaternion

Example

use Libraries.Compute.Matrix4

Matrix4 matrix

matrix:Set(1, 2, 3, 4)

number row0column0 = matrix:row0column0
number row0column1 = matrix:row0column1
number row0column2 = matrix:row0column2
number row0column3 = matrix:row0column3
number row1column0 = matrix:row1column0
number row1column1 = matrix:row1column1
number row1column2 = matrix:row1column2
number row1column3 = matrix:row1column3
number row2column0 = matrix:row2column0
number row2column1 = matrix:row2column1
number row2column2 = matrix:row2column2
number row2column3 = matrix:row2column3
number row3column0 = matrix:row3column0
number row3column1 = matrix:row3column1
number row3column2 = matrix:row3column2
number row3column3 = matrix:row3column3

output "The new matrix is:"
output "|" + row0column0 + ", " + row0column1 + ", " + row0column2 + ", " + row0column3 + "|"
output "|" + row1column0 + ", " + row1column1 + ", " + row1column2 + ", " + row1column3 + "|"
output "|" + row2column0 + ", " + row2column1 + ", " + row2column2 + ", " + row2column3 + "|"
output "|" + row3column0 + ", " + row3column1 + ", " + row3column2 + ", " + row3column3 + "|"

Set(Libraries.Compute.Vector3 position, Libraries.Compute.Quaternion orientation)

This action sets the matrix to the passed translation and rotation.

Parameters

Return

Libraries.Compute.Matrix4: The matrix with the passed translation and rotation

Example

use Libraries.Compute.Matrix4
use Libraries.Compute.Vector3
use Libraries.Compute.Quaternion

Matrix4 matrix
Vector3 position
Quaternion orientation

position:Set(1, 2, 3)
orientation:Set(0, 0, 1, 0)

matrix:Set(position, orientation)

number row0column0 = matrix:row0column0
number row0column1 = matrix:row0column1
number row0column2 = matrix:row0column2
number row0column3 = matrix:row0column3
number row1column0 = matrix:row1column0
number row1column1 = matrix:row1column1
number row1column2 = matrix:row1column2
number row1column3 = matrix:row1column3
number row2column0 = matrix:row2column0
number row2column1 = matrix:row2column1
number row2column2 = matrix:row2column2
number row2column3 = matrix:row2column3
number row3column0 = matrix:row3column0
number row3column1 = matrix:row3column1
number row3column2 = matrix:row3column2
number row3column3 = matrix:row3column3

output "The new matrix is:"
output "|" + row0column0 + ", " + row0column1 + ", " + row0column2 + ", " + row0column3 + "|"
output "|" + row1column0 + ", " + row1column1 + ", " + row1column2 + ", " + row1column3 + "|"
output "|" + row2column0 + ", " + row2column1 + ", " + row2column2 + ", " + row2column3 + "|"
output "|" + row3column0 + ", " + row3column1 + ", " + row3column2 + ", " + row3column3 + "|"

Set(number row0column0, number row0column1, number row0column2, number row0column3, number row1column0, number row1column1, number row1column2, number row1column3, number row2column0, number row2column1, number row2column2, number row2column3, number row3column0, number row3column1, number row3column2, number row3column3)

This action sets the values of the matrix 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 row0column3: The value of the first row, fourth 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 row1column3: The value of the second row, fourth 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
  • number row2column3: The value of the third row, fourth column
  • number row3column0: The value of the fourth row, first column
  • number row3column1: The value of the fourth row, second column
  • number row3column2: The value of the fourth row, thrid column
  • number row3column3: The value of the fourth row fourth column

Return

Libraries.Compute.Matrix4: The matrix with the passed values

Example

use Libraries.Compute.Matrix4

Matrix4 matrix
matrix:Set(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15)

number row0column0 = matrix:row0column0
number row0column1 = matrix:row0column1
number row0column2 = matrix:row0column2
number row0column3 = matrix:row0column3
number row1column0 = matrix:row1column0
number row1column1 = matrix:row1column1
number row1column2 = matrix:row1column2
number row1column3 = matrix:row1column3
number row2column0 = matrix:row2column0
number row2column1 = matrix:row2column1
number row2column2 = matrix:row2column2
number row2column3 = matrix:row2column3
number row3column0 = matrix:row3column0
number row3column1 = matrix:row3column1
number row3column2 = matrix:row3column2
number row3column3 = matrix:row3column3

output "The new matrix is:"
output "|" + row0column0 + ", " + row0column1 + ", " + row0column2 + ", " + row0column3 + "|"
output "|" + row1column0 + ", " + row1column1 + ", " + row1column2 + ", " + row1column3 + "|"
output "|" + row2column0 + ", " + row2column1 + ", " + row2column2 + ", " + row2column3 + "|"
output "|" + row3column0 + ", " + row3column1 + ", " + row3column2 + ", " + row3column3 + "|"

Set(Libraries.Compute.Vector3 xAxis, Libraries.Compute.Vector3 yAxis, Libraries.Compute.Vector3 zAxis, Libraries.Compute.Vector3 position)

This action sets the four columns of the matrix to correspond to the x-, y-, and z-axis of the vector space. The fourth column represents the translation.

Parameters

Return

Libraries.Compute.Matrix4: The matrix set to the vectors

Example

use Libraries.Compute.Matrix4
use Libraries.Compute.Vector3

Matrix4 matrix
Vector3 xAxis
Vector3 yAxis
Vector3 zAxis
Vector3 position

xAxis:Set(1, 0, 0)
yAxis:Set(0, 1, 0)
zAxis:Set(0, 0, 1)
position:Set(2, 3, 5)

matrix:Set(xAxis, yAxis, zAxis, position)

number row0column0 = matrix:row0column0
number row0column1 = matrix:row0column1
number row0column2 = matrix:row0column2
number row0column3 = matrix:row0column3
number row1column0 = matrix:row1column0
number row1column1 = matrix:row1column1
number row1column2 = matrix:row1column2
number row1column3 = matrix:row1column3
number row2column0 = matrix:row2column0
number row2column1 = matrix:row2column1
number row2column2 = matrix:row2column2
number row2column3 = matrix:row2column3
number row3column0 = matrix:row3column0
number row3column1 = matrix:row3column1
number row3column2 = matrix:row3column2
number row3column3 = matrix:row3column3

output "The new matrix is:"
output "|" + row0column0 + ", " + row0column1 + ", " + row0column2 + ", " + row0column3 + "|"
output "|" + row1column0 + ", " + row1column1 + ", " + row1column2 + ", " + row1column3 + "|"
output "|" + row2column0 + ", " + row2column1 + ", " + row2column2 + ", " + row2column3 + "|"
output "|" + row3column0 + ", " + row3column1 + ", " + row3column2 + ", " + row3column3 + "|"

Set(Libraries.Compute.Vector3 position, Libraries.Compute.Quaternion orientation, Libraries.Compute.Vector3 scale)

This action sets the matrix to the passed translation, rotation, and scale.

Parameters

Return

Libraries.Compute.Matrix4: The matrix with the passed translation, rotation, and scale.

Example

use Libraries.Compute.Matrix4
use Libraries.Compute.Vector3
use Libraries.Compute.Quaternion

Matrix4 matrix
Vector3 position
Quaternion orientation
Vector3 scale

position:Set(1, 2, 3)
orientation:Set(0, 0, 1, 0)
scale:Set(2, 2, 2)

matrix:Set(position, orientation, scale)

number row0column0 = matrix:row0column0
number row0column1 = matrix:row0column1
number row0column2 = matrix:row0column2
number row0column3 = matrix:row0column3
number row1column0 = matrix:row1column0
number row1column1 = matrix:row1column1
number row1column2 = matrix:row1column2
number row1column3 = matrix:row1column3
number row2column0 = matrix:row2column0
number row2column1 = matrix:row2column1
number row2column2 = matrix:row2column2
number row2column3 = matrix:row2column3
number row3column0 = matrix:row3column0
number row3column1 = matrix:row3column1
number row3column2 = matrix:row3column2
number row3column3 = matrix:row3column3

output "The new matrix is:"
output "|" + row0column0 + ", " + row0column1 + ", " + row0column2 + ", " + row0column3 + "|"
output "|" + row1column0 + ", " + row1column1 + ", " + row1column2 + ", " + row1column3 + "|"
output "|" + row2column0 + ", " + row2column1 + ", " + row2column2 + ", " + row2column3 + "|"
output "|" + row3column0 + ", " + row3column1 + ", " + row3column2 + ", " + row3column3 + "|"

Set(number translationX, number translationY, number translationZ, number quaternionX, number quaternionY, number quaternionZ, number quaternionW, number scaleX, number scaleY, number scaleZ)

This action sets the matrix to the passed translation, rotation, and scale.

Parameters

  • number translationX: The x-component of the translation vector
  • number translationY: The y-component of the translation vector
  • number translationZ: The z-component of the translation vector
  • number quaternionX: The x-component of the quaternion
  • number quaternionY: The y-component of the quaternion
  • number quaternionZ: The z-component of the quaternion
  • number quaternionW: The w-component of the quaternion
  • number scaleX: The x-component of the scale vector
  • number scaleY: The y-component of the scale vector
  • number scaleZ: The z-component of the scale vector

Return

Libraries.Compute.Matrix4: The matrix with the passed translation, rotation, and scale.

Example

use Libraries.Compute.Matrix4

Matrix4 matrix

matrix:Set(1, 2, 3, 0, 0, 1, 0, 2, 2, 2)

number row0column0 = matrix:row0column0
number row0column1 = matrix:row0column1
number row0column2 = matrix:row0column2
number row0column3 = matrix:row0column3
number row1column0 = matrix:row1column0
number row1column1 = matrix:row1column1
number row1column2 = matrix:row1column2
number row1column3 = matrix:row1column3
number row2column0 = matrix:row2column0
number row2column1 = matrix:row2column1
number row2column2 = matrix:row2column2
number row2column3 = matrix:row2column3
number row3column0 = matrix:row3column0
number row3column1 = matrix:row3column1
number row3column2 = matrix:row3column2
number row3column3 = matrix:row3column3

output "The new matrix is:"
output "|" + row0column0 + ", " + row0column1 + ", " + row0column2 + ", " + row0column3 + "|"
output "|" + row1column0 + ", " + row1column1 + ", " + row1column2 + ", " + row1column3 + "|"
output "|" + row2column0 + ", " + row2column1 + ", " + row2column2 + ", " + row2column3 + "|"
output "|" + row3column0 + ", " + row3column1 + ", " + row3column2 + ", " + row3column3 + "|"

Set(Libraries.Compute.Quaternion quaternion)

This action sets the matrix to a rotation matrix representing the passed Quaternion. This action is mainly useful for graphics programming.

Parameters

Return

Libraries.Compute.Matrix4: The matrix as a rotation matrix representing the Quaternion

Example

use Libraries.Compute.Matrix4
use Libraries.Compute.Quaternion

Matrix4 matrix
Quaternion quaternion

quaternion:Set(1, 2, 3, 4)
matrix:Set(quaternion)

number row0column0 = matrix:row0column0
number row0column1 = matrix:row0column1
number row0column2 = matrix:row0column2
number row0column3 = matrix:row0column3
number row1column0 = matrix:row1column0
number row1column1 = matrix:row1column1
number row1column2 = matrix:row1column2
number row1column3 = matrix:row1column3
number row2column0 = matrix:row2column0
number row2column1 = matrix:row2column1
number row2column2 = matrix:row2column2
number row2column3 = matrix:row2column3
number row3column0 = matrix:row3column0
number row3column1 = matrix:row3column1
number row3column2 = matrix:row3column2
number row3column3 = matrix:row3column3

output "The new matrix is:"
output "|" + row0column0 + ", " + row0column1 + ", " + row0column2 + ", " + row0column3 + "|"
output "|" + row1column0 + ", " + row1column1 + ", " + row1column2 + ", " + row1column3 + "|"
output "|" + row2column0 + ", " + row2column1 + ", " + row2column2 + ", " + row2column3 + "|"
output "|" + row3column0 + ", " + row3column1 + ", " + row3column2 + ", " + row3column3 + "|"

SetAsAffine(Libraries.Compute.Matrix4 matrix)

This action sets the matrix as an affine, representing a series of 2D transformations.

Parameters

Return

Libraries.Compute.Matrix4: The matrix set as an affine

Example

use Libraries.Compute.Matrix4

Matrix4 matrix
Matrix4 affine

affine:SetToTranslationAndScaling(1, 1, 1, 2, 2, 2)

matrix:SetAsAffine(affine)

number row0column0 = matrix:row0column0
number row0column1 = matrix:row0column1
number row0column2 = matrix:row0column2
number row0column3 = matrix:row0column3
number row1column0 = matrix:row1column0
number row1column1 = matrix:row1column1
number row1column2 = matrix:row1column2
number row1column3 = matrix:row1column3
number row2column0 = matrix:row2column0
number row2column1 = matrix:row2column1
number row2column2 = matrix:row2column2
number row2column3 = matrix:row2column3
number row3column0 = matrix:row3column0
number row3column1 = matrix:row3column1
number row3column2 = matrix:row3column2
number row3column3 = matrix:row3column3

output "The new matrix is:"
output "|" + row0column0 + ", " + row0column1 + ", " + row0column2 + ", " + row0column3 + "|"
output "|" + row1column0 + ", " + row1column1 + ", " + row1column2 + ", " + row1column3 + "|"
output "|" + row2column0 + ", " + row2column1 + ", " + row2column2 + ", " + row2column3 + "|"
output "|" + row3column0 + ", " + row3column1 + ", " + row3column2 + ", " + row3column3 + "|"

SetAsAffine(Libraries.Compute.Affine2 affine)

This action sets the matrix as an affine, representing a series of 2D transformations.

Parameters

Return

Libraries.Compute.Matrix4: The matrix set as an affine

Example

use Libraries.Compute.Matrix4
use Libraries.Compute.Affine2

Matrix4 matrix
Affine2 affine

affine:SetToTranslationRotationScale(1, 1, 45, 2, 2)

matrix:SetAsAffine(affine)

number row0column0 = matrix:row0column0
number row0column1 = matrix:row0column1
number row0column2 = matrix:row0column2
number row0column3 = matrix:row0column3
number row1column0 = matrix:row1column0
number row1column1 = matrix:row1column1
number row1column2 = matrix:row1column2
number row1column3 = matrix:row1column3
number row2column0 = matrix:row2column0
number row2column1 = matrix:row2column1
number row2column2 = matrix:row2column2
number row2column3 = matrix:row2column3
number row3column0 = matrix:row3column0
number row3column1 = matrix:row3column1
number row3column2 = matrix:row3column2
number row3column3 = matrix:row3column3

output "The new matrix is:"
output "|" + row0column0 + ", " + row0column1 + ", " + row0column2 + ", " + row0column3 + "|"
output "|" + row1column0 + ", " + row1column1 + ", " + row1column2 + ", " + row1column3 + "|"
output "|" + row2column0 + ", " + row2column1 + ", " + row2column2 + ", " + row2column3 + "|"
output "|" + row3column0 + ", " + row3column1 + ", " + row3column2 + ", " + row3column3 + "|"

SetFromEulerAngles(number yaw, number pitch, number roll)

This action sets the matrix to a rotation matrix with the given Euler angles given in degrees.

Parameters

  • number yaw: The yaw angle
  • number pitch: The pitch angle
  • number roll: The roll angle

Return

Libraries.Compute.Matrix4: the matrix as a rotation matrix

Example

use Libraries.Compute.Matrix4

Matrix4 matrix

matrix:SetFromEulerAngles(45, 90, 180)

number row0column0 = matrix:row0column0
number row0column1 = matrix:row0column1
number row0column2 = matrix:row0column2
number row0column3 = matrix:row0column3
number row1column0 = matrix:row1column0
number row1column1 = matrix:row1column1
number row1column2 = matrix:row1column2
number row1column3 = matrix:row1column3
number row2column0 = matrix:row2column0
number row2column1 = matrix:row2column1
number row2column2 = matrix:row2column2
number row2column3 = matrix:row2column3
number row3column0 = matrix:row3column0
number row3column1 = matrix:row3column1
number row3column2 = matrix:row3column2
number row3column3 = matrix:row3column3

output "The new matrix is:"
output "|" + row0column0 + ", " + row0column1 + ", " + row0column2 + ", " + row0column3 + "|"
output "|" + row1column0 + ", " + row1column1 + ", " + row1column2 + ", " + row1column3 + "|"
output "|" + row2column0 + ", " + row2column1 + ", " + row2column2 + ", " + row2column3 + "|"
output "|" + row3column0 + ", " + row3column1 + ", " + row3column2 + ", " + row3column3 + "|"

SetFromEulerAnglesRadians(number yaw, number pitch, number roll)

This action sets the matrix to a rotation matrix with the given Euler angles given in radians.

Parameters

  • number yaw: The yaw angle
  • number pitch: The pitch angle
  • number roll: The roll angle

Return

Libraries.Compute.Matrix4: the matrix as a rotation matrix

Example

use Libraries.Compute.Matrix4
use Libraries.Compute.Math

Math math

Matrix4 matrix

matrix:SetFromEulerAnglesRadians(math:pi / 4, math:pi / 2, math:pi)

number row0column0 = matrix:row0column0
number row0column1 = matrix:row0column1
number row0column2 = matrix:row0column2
number row0column3 = matrix:row0column3
number row1column0 = matrix:row1column0
number row1column1 = matrix:row1column1
number row1column2 = matrix:row1column2
number row1column3 = matrix:row1column3
number row2column0 = matrix:row2column0
number row2column1 = matrix:row2column1
number row2column2 = matrix:row2column2
number row2column3 = matrix:row2column3
number row3column0 = matrix:row3column0
number row3column1 = matrix:row3column1
number row3column2 = matrix:row3column2
number row3column3 = matrix:row3column3

output "The new matrix is:"
output "|" + row0column0 + ", " + row0column1 + ", " + row0column2 + ", " + row0column3 + "|"
output "|" + row1column0 + ", " + row1column1 + ", " + row1column2 + ", " + row1column3 + "|"
output "|" + row2column0 + ", " + row2column1 + ", " + row2column2 + ", " + row2column3 + "|"
output "|" + row3column0 + ", " + row3column1 + ", " + row3column2 + ", " + row3column3 + "|"

SetToLookAt(Libraries.Compute.Vector3 position, Libraries.Compute.Vector3 target, Libraries.Compute.Vector3 up)

This action sets the matrix to look at another matrix with a direction, target, and up vector. When multiplied with a translation matrix, we get a camera model view matrix.

Parameters

Return

Libraries.Compute.Matrix4: the matrix

Example

use Libraries.Compute.Matrix4
use Libraries.Compute.Vector3

Matrix4 matrix
Vector3 direction
Vector3 target
Vector3 up

direction:Set(0, 0, 1)
target:Set(0, 0, 3)
up:Set(0, 1, 0)

matrix:SetToLookAt(direction, target, up)

number row0column0 = matrix:row0column0
number row0column1 = matrix:row0column1
number row0column2 = matrix:row0column2
number row0column3 = matrix:row0column3
number row1column0 = matrix:row1column0
number row1column1 = matrix:row1column1
number row1column2 = matrix:row1column2
number row1column3 = matrix:row1column3
number row2column0 = matrix:row2column0
number row2column1 = matrix:row2column1
number row2column2 = matrix:row2column2
number row2column3 = matrix:row2column3
number row3column0 = matrix:row3column0
number row3column1 = matrix:row3column1
number row3column2 = matrix:row3column2
number row3column3 = matrix:row3column3

output "The new matrix is:"
output "|" + row0column0 + ", " + row0column1 + ", " + row0column2 + ", " + row0column3 + "|"
output "|" + row1column0 + ", " + row1column1 + ", " + row1column2 + ", " + row1column3 + "|"
output "|" + row2column0 + ", " + row2column1 + ", " + row2column2 + ", " + row2column3 + "|"
output "|" + row3column0 + ", " + row3column1 + ", " + row3column2 + ", " + row3column3 + "|"

SetToLookAt(Libraries.Compute.Vector3 direction, Libraries.Compute.Vector3 up)

This action sets the matrix to look at another matrix with a direction and an up vector. When multiplied with a translation matrix, we get a camera model view matrix.

Parameters

Return

Libraries.Compute.Matrix4: the matrix

Example

use Libraries.Compute.Matrix4
use Libraries.Compute.Vector3

Matrix4 matrix
Vector3 direction
Vector3 up

direction:Set(0, 0, 1)
up:Set(0, 1, 0)

matrix:SetToLookAt(direction, up)

number row0column0 = matrix:row0column0
number row0column1 = matrix:row0column1
number row0column2 = matrix:row0column2
number row0column3 = matrix:row0column3
number row1column0 = matrix:row1column0
number row1column1 = matrix:row1column1
number row1column2 = matrix:row1column2
number row1column3 = matrix:row1column3
number row2column0 = matrix:row2column0
number row2column1 = matrix:row2column1
number row2column2 = matrix:row2column2
number row2column3 = matrix:row2column3
number row3column0 = matrix:row3column0
number row3column1 = matrix:row3column1
number row3column2 = matrix:row3column2
number row3column3 = matrix:row3column3

output "The new matrix is:"
output "|" + row0column0 + ", " + row0column1 + ", " + row0column2 + ", " + row0column3 + "|"
output "|" + row1column0 + ", " + row1column1 + ", " + row1column2 + ", " + row1column3 + "|"
output "|" + row2column0 + ", " + row2column1 + ", " + row2column2 + ", " + row2column3 + "|"
output "|" + row3column0 + ", " + row3column1 + ", " + row3column2 + ", " + row3column3 + "|"

SetToOrthographic(number left, number right, number bottom, number top, number near, number far)

This action sets the matrix to an orthographic projection matrix.

Parameters

  • number left: The left clipping plane
  • number right: The right clipping plane
  • number bottom: The bottom clipping plane
  • number top: The top clipping plane
  • number near: The near plane
  • number far: The far plane

Return

Libraries.Compute.Matrix4: The matrix as an orthographic projection matrix

Example

use Libraries.Compute.Matrix4

Matrix4 matrix

matrix:SetToOrthographic(0, 1, 0, 1, 0, 1)

number row0column0 = matrix:row0column0
number row0column1 = matrix:row0column1
number row0column2 = matrix:row0column2
number row0column3 = matrix:row0column3
number row1column0 = matrix:row1column0
number row1column1 = matrix:row1column1
number row1column2 = matrix:row1column2
number row1column3 = matrix:row1column3
number row2column0 = matrix:row2column0
number row2column1 = matrix:row2column1
number row2column2 = matrix:row2column2
number row2column3 = matrix:row2column3
number row3column0 = matrix:row3column0
number row3column1 = matrix:row3column1
number row3column2 = matrix:row3column2
number row3column3 = matrix:row3column3

output "The new matrix is:"
output "|" + row0column0 + ", " + row0column1 + ", " + row0column2 + ", " + row0column3 + "|"
output "|" + row1column0 + ", " + row1column1 + ", " + row1column2 + ", " + row1column3 + "|"
output "|" + row2column0 + ", " + row2column1 + ", " + row2column2 + ", " + row2column3 + "|"
output "|" + row3column0 + ", " + row3column1 + ", " + row3column2 + ", " + row3column3 + "|"

SetToOrthographic2D(number x, number y, number width, number height, number near, number far)

This action sets the matrix to an orthographic projection matrix with an origin at (x, y) with the given width and height and the given near and far planes.

Parameters

  • number x: The x-coordinate of the origin
  • number y: The y-coordinate of the origin
  • number width: The width
  • number height: The height
  • number near: The near plane
  • number far: The far plane

Return

Libraries.Compute.Matrix4: The matrix as a 2D orthographic projection matrix

Example

use Libraries.Compute.Matrix4

Matrix4 matrix

matrix:SetToOrthographic2D(0, 0, 100, 100, 0, 1)

number row0column0 = matrix:row0column0
number row0column1 = matrix:row0column1
number row0column2 = matrix:row0column2
number row0column3 = matrix:row0column3
number row1column0 = matrix:row1column0
number row1column1 = matrix:row1column1
number row1column2 = matrix:row1column2
number row1column3 = matrix:row1column3
number row2column0 = matrix:row2column0
number row2column1 = matrix:row2column1
number row2column2 = matrix:row2column2
number row2column3 = matrix:row2column3
number row3column0 = matrix:row3column0
number row3column1 = matrix:row3column1
number row3column2 = matrix:row3column2
number row3column3 = matrix:row3column3

output "The new matrix is:"
output "|" + row0column0 + ", " + row0column1 + ", " + row0column2 + ", " + row0column3 + "|"
output "|" + row1column0 + ", " + row1column1 + ", " + row1column2 + ", " + row1column3 + "|"
output "|" + row2column0 + ", " + row2column1 + ", " + row2column2 + ", " + row2column3 + "|"
output "|" + row3column0 + ", " + row3column1 + ", " + row3column2 + ", " + row3column3 + "|"

SetToOrthographic2D(number x, number y, number width, number height)

This action sets the matrix to an orthographic projection matrix with an origin at (x, y) with the given width and height. The near and far plane are set to 0 and 1, respectively.

Parameters

  • number x: The x-coordinate of the origin
  • number y: The y-coordinate of the origin
  • number width: The width
  • number height: The height

Return

Libraries.Compute.Matrix4: The matrix as a 2D orthographic projection matrix

Example

use Libraries.Compute.Matrix4

Matrix4 matrix

matrix:SetToOrthographic2D(0, 0, 100, 100)

number row0column0 = matrix:row0column0
number row0column1 = matrix:row0column1
number row0column2 = matrix:row0column2
number row0column3 = matrix:row0column3
number row1column0 = matrix:row1column0
number row1column1 = matrix:row1column1
number row1column2 = matrix:row1column2
number row1column3 = matrix:row1column3
number row2column0 = matrix:row2column0
number row2column1 = matrix:row2column1
number row2column2 = matrix:row2column2
number row2column3 = matrix:row2column3
number row3column0 = matrix:row3column0
number row3column1 = matrix:row3column1
number row3column2 = matrix:row3column2
number row3column3 = matrix:row3column3

output "The new matrix is:"
output "|" + row0column0 + ", " + row0column1 + ", " + row0column2 + ", " + row0column3 + "|"
output "|" + row1column0 + ", " + row1column1 + ", " + row1column2 + ", " + row1column3 + "|"
output "|" + row2column0 + ", " + row2column1 + ", " + row2column2 + ", " + row2column3 + "|"
output "|" + row3column0 + ", " + row3column1 + ", " + row3column2 + ", " + row3column3 + "|"

SetToProjection(number left, number right, number bottom, number top, number near, number far)

Sets the matrix to a projection matrix with a near/far plane, and left, bottom, right and top specifying the points on the near plane that are mapped to the lower left and upper right corners of the viewport. This allows a projection matrix to be created with an off-center vanishing point.

Parameters

  • number left: The left point of the near plane
  • number right: The right point of the near plane
  • number bottom: The bottom of the near plane
  • number top: The top of the near plane
  • number near: The near plane
  • number far: The far plane

Return

Libraries.Compute.Matrix4: The matrix as a projection matrix

Example

use Libraries.Compute.Matrix4

Matrix4 matrix

matrix:SetToProjection(0, 10, 0, 10, 0, 1)

number row0column0 = matrix:row0column0
number row0column1 = matrix:row0column1
number row0column2 = matrix:row0column2
number row0column3 = matrix:row0column3
number row1column0 = matrix:row1column0
number row1column1 = matrix:row1column1
number row1column2 = matrix:row1column2
number row1column3 = matrix:row1column3
number row2column0 = matrix:row2column0
number row2column1 = matrix:row2column1
number row2column2 = matrix:row2column2
number row2column3 = matrix:row2column3
number row3column0 = matrix:row3column0
number row3column1 = matrix:row3column1
number row3column2 = matrix:row3column2
number row3column3 = matrix:row3column3

output "The new matrix is:"
output "|" + row0column0 + ", " + row0column1 + ", " + row0column2 + ", " + row0column3 + "|"
output "|" + row1column0 + ", " + row1column1 + ", " + row1column2 + ", " + row1column3 + "|"
output "|" + row2column0 + ", " + row2column1 + ", " + row2column2 + ", " + row2column3 + "|"
output "|" + row3column0 + ", " + row3column1 + ", " + row3column2 + ", " + row3column3 + "|"

SetToProjection(number nearPlane, number farPlane, number fieldOfViewHeight, number aspectRatio)

This action sets the matrix to a projection matrix with the near and far planes, the field of view height, and the aspect ratio.

Parameters

  • number nearPlane: The near plane
  • number farPlane: The far plane
  • number fieldOfViewHeight: The height of the field of view
  • number aspectRatio: the aspect ratio

Return

Libraries.Compute.Matrix4: The matrix as a projection matrix

Example

use Libraries.Compute.Matrix4

Matrix4 matrix

matrix:SetToProjection(0, 1, 10, 2)

number row0column0 = matrix:row0column0
number row0column1 = matrix:row0column1
number row0column2 = matrix:row0column2
number row0column3 = matrix:row0column3
number row1column0 = matrix:row1column0
number row1column1 = matrix:row1column1
number row1column2 = matrix:row1column2
number row1column3 = matrix:row1column3
number row2column0 = matrix:row2column0
number row2column1 = matrix:row2column1
number row2column2 = matrix:row2column2
number row2column3 = matrix:row2column3
number row3column0 = matrix:row3column0
number row3column1 = matrix:row3column1
number row3column2 = matrix:row3column2
number row3column3 = matrix:row3column3

output "The new matrix is:"
output "|" + row0column0 + ", " + row0column1 + ", " + row0column2 + ", " + row0column3 + "|"
output "|" + row1column0 + ", " + row1column1 + ", " + row1column2 + ", " + row1column3 + "|"
output "|" + row2column0 + ", " + row2column1 + ", " + row2column2 + ", " + row2column3 + "|"
output "|" + row3column0 + ", " + row3column1 + ", " + row3column2 + ", " + row3column3 + "|"

SetToRotation(Libraries.Compute.Vector3 axis, number degrees)

This action sets the matrix to the rotation matrix about the passed axis with the given angle in degrees.

Parameters

Return

Libraries.Compute.Matrix4: the matrix as a rotation matrix

Example

use Libraries.Compute.Matrix4
use Libraries.Compute.Vector3

Matrix4 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 row0column3 = matrix:row0column3
number row1column0 = matrix:row1column0
number row1column1 = matrix:row1column1
number row1column2 = matrix:row1column2
number row1column3 = matrix:row1column3
number row2column0 = matrix:row2column0
number row2column1 = matrix:row2column1
number row2column2 = matrix:row2column2
number row2column3 = matrix:row2column3
number row3column0 = matrix:row3column0
number row3column1 = matrix:row3column1
number row3column2 = matrix:row3column2
number row3column3 = matrix:row3column3

output "The new matrix is:"
output "|" + row0column0 + ", " + row0column1 + ", " + row0column2 + ", " + row0column3 + "|"
output "|" + row1column0 + ", " + row1column1 + ", " + row1column2 + ", " + row1column3 + "|"
output "|" + row2column0 + ", " + row2column1 + ", " + row2column2 + ", " + row2column3 + "|"
output "|" + row3column0 + ", " + row3column1 + ", " + row3column2 + ", " + row3column3 + "|"

SetToRotation(number baseX, number baseY, number baseZ, number targetX, number targetY, number targetZ)

This action sets the matrix to a rotation matrix between the two vectors.

Parameters

  • number baseX: The x-component of the base vector
  • number baseY: The y-component of the base vector
  • number baseZ: The z-component of the base vector
  • number targetX: The x-component of the target vector
  • number targetY: The y-component of the target vector
  • number targetZ: The z-component of the target vector

Return

Libraries.Compute.Matrix4: The matrix as a rotation matrix

Example

use Libraries.Compute.Matrix4

Matrix4 matrix

matrix:SetToRotation(1, 0, 0, 0, 1, 0)

number row0column0 = matrix:row0column0
number row0column1 = matrix:row0column1
number row0column2 = matrix:row0column2
number row0column3 = matrix:row0column3
number row1column0 = matrix:row1column0
number row1column1 = matrix:row1column1
number row1column2 = matrix:row1column2
number row1column3 = matrix:row1column3
number row2column0 = matrix:row2column0
number row2column1 = matrix:row2column1
number row2column2 = matrix:row2column2
number row2column3 = matrix:row2column3
number row3column0 = matrix:row3column0
number row3column1 = matrix:row3column1
number row3column2 = matrix:row3column2
number row3column3 = matrix:row3column3

output "The new matrix is:"
output "|" + row0column0 + ", " + row0column1 + ", " + row0column2 + ", " + row0column3 + "|"
output "|" + row1column0 + ", " + row1column1 + ", " + row1column2 + ", " + row1column3 + "|"
output "|" + row2column0 + ", " + row2column1 + ", " + row2column2 + ", " + row2column3 + "|"
output "|" + row3column0 + ", " + row3column1 + ", " + row3column2 + ", " + row3column3 + "|"

SetToRotation(number axisX, number axisY, number axisZ, number degrees)

This action sets the matrix to the rotation matrix about the passed axis with the given angle in degrees.

Parameters

  • number axisX: The x-component of the rotation axis
  • number axisY: The y-component of the rotation axis
  • number axisZ: The z-component of the rotation axis
  • number degrees: the angle in degrees

Return

Libraries.Compute.Matrix4: the matrix as a rotation matrix

Example

use Libraries.Compute.Matrix4

Matrix4 matrix

matrix:SetToRotation(0, 0, 1, 45)

number row0column0 = matrix:row0column0
number row0column1 = matrix:row0column1
number row0column2 = matrix:row0column2
number row0column3 = matrix:row0column3
number row1column0 = matrix:row1column0
number row1column1 = matrix:row1column1
number row1column2 = matrix:row1column2
number row1column3 = matrix:row1column3
number row2column0 = matrix:row2column0
number row2column1 = matrix:row2column1
number row2column2 = matrix:row2column2
number row2column3 = matrix:row2column3
number row3column0 = matrix:row3column0
number row3column1 = matrix:row3column1
number row3column2 = matrix:row3column2
number row3column3 = matrix:row3column3

output "The new matrix is:"
output "|" + row0column0 + ", " + row0column1 + ", " + row0column2 + ", " + row0column3 + "|"
output "|" + row1column0 + ", " + row1column1 + ", " + row1column2 + ", " + row1column3 + "|"
output "|" + row2column0 + ", " + row2column1 + ", " + row2column2 + ", " + row2column3 + "|"
output "|" + row3column0 + ", " + row3column1 + ", " + row3column2 + ", " + row3column3 + "|"

SetToRotation(Libraries.Compute.Vector3 base, Libraries.Compute.Vector3 target)

This action sets the matrix to a rotation matrix between the two vectors.

Parameters

Return

Libraries.Compute.Matrix4: The matrix as a rotation matrix

Example

use Libraries.Compute.Matrix4
use Libraries.Compute.Vector3

Matrix4 matrix
Vector3 base
Vector3 target

base:Set(1, 0, 0)
target:Set(0, 1, 0)

matrix:SetToRotation(base, target)

number row0column0 = matrix:row0column0
number row0column1 = matrix:row0column1
number row0column2 = matrix:row0column2
number row0column3 = matrix:row0column3
number row1column0 = matrix:row1column0
number row1column1 = matrix:row1column1
number row1column2 = matrix:row1column2
number row1column3 = matrix:row1column3
number row2column0 = matrix:row2column0
number row2column1 = matrix:row2column1
number row2column2 = matrix:row2column2
number row2column3 = matrix:row2column3
number row3column0 = matrix:row3column0
number row3column1 = matrix:row3column1
number row3column2 = matrix:row3column2
number row3column3 = matrix:row3column3

output "The new matrix is:"
output "|" + row0column0 + ", " + row0column1 + ", " + row0column2 + ", " + row0column3 + "|"
output "|" + row1column0 + ", " + row1column1 + ", " + row1column2 + ", " + row1column3 + "|"
output "|" + row2column0 + ", " + row2column1 + ", " + row2column2 + ", " + row2column3 + "|"
output "|" + row3column0 + ", " + row3column1 + ", " + row3column2 + ", " + row3column3 + "|"

SetToRotationRadians(Libraries.Compute.Vector3 axis, number radians)

This action sets the matrix to the rotation matrix about the passed axis with the given angle in radians.

Parameters

Return

Libraries.Compute.Matrix4: the matrix as a rotation matrix

Example

use Libraries.Compute.Matrix4
use Libraries.Compute.Vector3
use Libraries.Compute.Math

Math math

Matrix4 matrix
Vector3 axis

axis:Set(0, 0, 1)
matrix:SetToRotationRadians(axis, math:pi / 4)

number row0column0 = matrix:row0column0
number row0column1 = matrix:row0column1
number row0column2 = matrix:row0column2
number row0column3 = matrix:row0column3
number row1column0 = matrix:row1column0
number row1column1 = matrix:row1column1
number row1column2 = matrix:row1column2
number row1column3 = matrix:row1column3
number row2column0 = matrix:row2column0
number row2column1 = matrix:row2column1
number row2column2 = matrix:row2column2
number row2column3 = matrix:row2column3
number row3column0 = matrix:row3column0
number row3column1 = matrix:row3column1
number row3column2 = matrix:row3column2
number row3column3 = matrix:row3column3

output "The new matrix is:"
output "|" + row0column0 + ", " + row0column1 + ", " + row0column2 + ", " + row0column3 + "|"
output "|" + row1column0 + ", " + row1column1 + ", " + row1column2 + ", " + row1column3 + "|"
output "|" + row2column0 + ", " + row2column1 + ", " + row2column2 + ", " + row2column3 + "|"
output "|" + row3column0 + ", " + row3column1 + ", " + row3column2 + ", " + row3column3 + "|"

SetToRotationRadians(number axisX, number axisY, number axisZ, number radians)

This action sets the matrix to the rotation matrix about the passed axis with the given angle in radians.

Parameters

  • number axisX: The x-component of the rotation axis
  • number axisY: The y-component of the rotation axis
  • number axisZ: The z-component of the rotation axis
  • number radians: the angle in radians

Return

Libraries.Compute.Matrix4: the matrix as a rotation matrix

Example

use Libraries.Compute.Matrix4
use Libraries.Compute.Math

Math math

Matrix4 matrix

matrix:SetToRotationRadians(0, 0, 1, math:pi / 4)

number row0column0 = matrix:row0column0
number row0column1 = matrix:row0column1
number row0column2 = matrix:row0column2
number row0column3 = matrix:row0column3
number row1column0 = matrix:row1column0
number row1column1 = matrix:row1column1
number row1column2 = matrix:row1column2
number row1column3 = matrix:row1column3
number row2column0 = matrix:row2column0
number row2column1 = matrix:row2column1
number row2column2 = matrix:row2column2
number row2column3 = matrix:row2column3
number row3column0 = matrix:row3column0
number row3column1 = matrix:row3column1
number row3column2 = matrix:row3column2
number row3column3 = matrix:row3column3

output "The new matrix is:"
output "|" + row0column0 + ", " + row0column1 + ", " + row0column2 + ", " + row0column3 + "|"
output "|" + row1column0 + ", " + row1column1 + ", " + row1column2 + ", " + row1column3 + "|"
output "|" + row2column0 + ", " + row2column1 + ", " + row2column2 + ", " + row2column3 + "|"
output "|" + row3column0 + ", " + row3column1 + ", " + row3column2 + ", " + row3column3 + "|"

SetToScaling(Libraries.Compute.Vector3 scale)

This action sets the matrix to a scaling matrix with the passed vector representing the scale.

Parameters

Return

Libraries.Compute.Matrix4: The matrix as a scaling matrix

Example


use Libraries.Compute.Matrix4
use Libraries.Compute.Vector3

Matrix4 matrix
Vector3 scale

scale:Set(1, 2, 2)

matrix:SetToScaling(scale)

number row0column0 = matrix:row0column0
number row0column1 = matrix:row0column1
number row0column2 = matrix:row0column2
number row0column3 = matrix:row0column3
number row1column0 = matrix:row1column0
number row1column1 = matrix:row1column1
number row1column2 = matrix:row1column2
number row1column3 = matrix:row1column3
number row2column0 = matrix:row2column0
number row2column1 = matrix:row2column1
number row2column2 = matrix:row2column2
number row2column3 = matrix:row2column3
number row3column0 = matrix:row3column0
number row3column1 = matrix:row3column1
number row3column2 = matrix:row3column2
number row3column3 = matrix:row3column3

output "The new matrix is:"
output "|" + row0column0 + ", " + row0column1 + ", " + row0column2 + ", " + row0column3 + "|"
output "|" + row1column0 + ", " + row1column1 + ", " + row1column2 + ", " + row1column3 + "|"
output "|" + row2column0 + ", " + row2column1 + ", " + row2column2 + ", " + row2column3 + "|"
output "|" + row3column0 + ", " + row3column1 + ", " + row3column2 + ", " + row3column3 + "|"

SetToScaling(number scaleX, number scaleY, number scaleZ)

This action sets the matrix to a scaling matrix with the passed vector representing the scale.

Parameters

  • number scaleX
  • number scaleY
  • number scaleZ

Return

Libraries.Compute.Matrix4: The matrix as a scaling matrix

Example


use Libraries.Compute.Matrix4
use Libraries.Compute.Vector3

Matrix4 matrix
Vector3 scale

scale:Set(1, 2, 2)

matrix:SetToScaling(scale)

number row0column0 = matrix:row0column0
number row0column1 = matrix:row0column1
number row0column2 = matrix:row0column2
number row0column3 = matrix:row0column3
number row1column0 = matrix:row1column0
number row1column1 = matrix:row1column1
number row1column2 = matrix:row1column2
number row1column3 = matrix:row1column3
number row2column0 = matrix:row2column0
number row2column1 = matrix:row2column1
number row2column2 = matrix:row2column2
number row2column3 = matrix:row2column3
number row3column0 = matrix:row3column0
number row3column1 = matrix:row3column1
number row3column2 = matrix:row3column2
number row3column3 = matrix:row3column3

output "The new matrix is:"
output "|" + row0column0 + ", " + row0column1 + ", " + row0column2 + ", " + row0column3 + "|"
output "|" + row1column0 + ", " + row1column1 + ", " + row1column2 + ", " + row1column3 + "|"
output "|" + row2column0 + ", " + row2column1 + ", " + row2column2 + ", " + row2column3 + "|"
output "|" + row3column0 + ", " + row3column1 + ", " + row3column2 + ", " + row3column3 + "|"

SetToTranslation(Libraries.Compute.Vector3 vector)

This action sets the matrix to the translation matrix with the passed translation

Parameters

Return

Libraries.Compute.Matrix4: The matrix as a translation matrix

Example

use Libraries.Compute.Matrix4
use Libraries.Compute.Vector3

Matrix4 matrix
Vector3 vector

vector:Set(1, 2, 3)
matrix:SetToTranslation(vector)

number row0column0 = matrix:row0column0
number row0column1 = matrix:row0column1
number row0column2 = matrix:row0column2
number row0column3 = matrix:row0column3
number row1column0 = matrix:row1column0
number row1column1 = matrix:row1column1
number row1column2 = matrix:row1column2
number row1column3 = matrix:row1column3
number row2column0 = matrix:row2column0
number row2column1 = matrix:row2column1
number row2column2 = matrix:row2column2
number row2column3 = matrix:row2column3
number row3column0 = matrix:row3column0
number row3column1 = matrix:row3column1
number row3column2 = matrix:row3column2
number row3column3 = matrix:row3column3

output "The new matrix is:"
output "|" + row0column0 + ", " + row0column1 + ", " + row0column2 + ", " + row0column3 + "|"
output "|" + row1column0 + ", " + row1column1 + ", " + row1column2 + ", " + row1column3 + "|"
output "|" + row2column0 + ", " + row2column1 + ", " + row2column2 + ", " + row2column3 + "|"
output "|" + row3column0 + ", " + row3column1 + ", " + row3column2 + ", " + row3column3 + "|"

SetToTranslation(number x, number y, number z)

This action sets the matrix to the translation matrix with the passed translation

Parameters

  • number x: The x-component of the translation
  • number y: The y-component of the translation
  • number z: The z-component of the translation

Return

Libraries.Compute.Matrix4: The matrix as a translation matrix

Example

use Libraries.Compute.Matrix4

Matrix4 matrix

matrix:SetToTranslation(1, 2, 3)

number row0column0 = matrix:row0column0
number row0column1 = matrix:row0column1
number row0column2 = matrix:row0column2
number row0column3 = matrix:row0column3
number row1column0 = matrix:row1column0
number row1column1 = matrix:row1column1
number row1column2 = matrix:row1column2
number row1column3 = matrix:row1column3
number row2column0 = matrix:row2column0
number row2column1 = matrix:row2column1
number row2column2 = matrix:row2column2
number row2column3 = matrix:row2column3
number row3column0 = matrix:row3column0
number row3column1 = matrix:row3column1
number row3column2 = matrix:row3column2
number row3column3 = matrix:row3column3

output "The new matrix is:"
output "|" + row0column0 + ", " + row0column1 + ", " + row0column2 + ", " + row0column3 + "|"
output "|" + row1column0 + ", " + row1column1 + ", " + row1column2 + ", " + row1column3 + "|"
output "|" + row2column0 + ", " + row2column1 + ", " + row2column2 + ", " + row2column3 + "|"
output "|" + row3column0 + ", " + row3column1 + ", " + row3column2 + ", " + row3column3 + "|"

SetToTranslationAndScaling(Libraries.Compute.Vector3 translation, Libraries.Compute.Vector3 scaling)

This action sets the matrix to the translation and scaling matrix with the passed translations and scales.

Parameters

Return

Libraries.Compute.Matrix4: the matrix as a translation and scaling matrix

Example

use Libraries.Compute.Matrix4
use Libraries.Compute.Vector3

Matrix4 matrix
Vector3 translation
Vector3 scaling

translation:Set(1, 2, 3)
scaling:Set(3, 3, 3)

matrix:SetToTranslationAndScaling(translation, scaling)

number row0column0 = matrix:row0column0
number row0column1 = matrix:row0column1
number row0column2 = matrix:row0column2
number row0column3 = matrix:row0column3
number row1column0 = matrix:row1column0
number row1column1 = matrix:row1column1
number row1column2 = matrix:row1column2
number row1column3 = matrix:row1column3
number row2column0 = matrix:row2column0
number row2column1 = matrix:row2column1
number row2column2 = matrix:row2column2
number row2column3 = matrix:row2column3
number row3column0 = matrix:row3column0
number row3column1 = matrix:row3column1
number row3column2 = matrix:row3column2
number row3column3 = matrix:row3column3

output "The new matrix is:"
output "|" + row0column0 + ", " + row0column1 + ", " + row0column2 + ", " + row0column3 + "|"
output "|" + row1column0 + ", " + row1column1 + ", " + row1column2 + ", " + row1column3 + "|"
output "|" + row2column0 + ", " + row2column1 + ", " + row2column2 + ", " + row2column3 + "|"
output "|" + row3column0 + ", " + row3column1 + ", " + row3column2 + ", " + row3column3 + "|"

SetToTranslationAndScaling(number translationX, number translationY, number translationZ, number scalingX, number scalingY, number scalingZ)

This action sets the matrix to the translation and scaling matrix with the passed translations and scales.

Parameters

  • number translationX: The x-component of the translation vector
  • number translationY: The y-component of the translation vector
  • number translationZ: The z-component of the translation vector
  • number scalingX: The x-component of the scaling vector
  • number scalingY: The y-component of the scaling vector
  • number scalingZ: The z-component of the scaling vector

Return

Libraries.Compute.Matrix4: the matrix as a translation and scaling matrix

Example

use Libraries.Compute.Matrix4

Matrix4 matrix

matrix:SetToTranslationAndScaling(1, 2, 3, 3, 3, 3)

number row0column0 = matrix:row0column0
number row0column1 = matrix:row0column1
number row0column2 = matrix:row0column2
number row0column3 = matrix:row0column3
number row1column0 = matrix:row1column0
number row1column1 = matrix:row1column1
number row1column2 = matrix:row1column2
number row1column3 = matrix:row1column3
number row2column0 = matrix:row2column0
number row2column1 = matrix:row2column1
number row2column2 = matrix:row2column2
number row2column3 = matrix:row2column3
number row3column0 = matrix:row3column0
number row3column1 = matrix:row3column1
number row3column2 = matrix:row3column2
number row3column3 = matrix:row3column3

output "The new matrix is:"
output "|" + row0column0 + ", " + row0column1 + ", " + row0column2 + ", " + row0column3 + "|"
output "|" + row1column0 + ", " + row1column1 + ", " + row1column2 + ", " + row1column3 + "|"
output "|" + row2column0 + ", " + row2column1 + ", " + row2column2 + ", " + row2column3 + "|"
output "|" + row3column0 + ", " + row3column1 + ", " + row3column2 + ", " + row3column3 + "|"

SetToWorld(Libraries.Compute.Vector3 position, Libraries.Compute.Vector3 forward, Libraries.Compute.Vector3 up)

This action sets the matrix to a world with the given position, forward, and up vectors.

Parameters

Return

Libraries.Compute.Matrix4: The matrix set to the world

Example

use Libraries.Compute.Matrix4
use Libraries.Compute.Vector3

Matrix4 matrix
Vector3 position
Vector3 forward
Vector3 up

position:Set(0, 0, 0)
forward:Set(1, 0, 0)
up:Set(0, 1, 0)

matrix:SetToWorld(position, forward, up)

number row0column0 = matrix:row0column0
number row0column1 = matrix:row0column1
number row0column2 = matrix:row0column2
number row0column3 = matrix:row0column3
number row1column0 = matrix:row1column0
number row1column1 = matrix:row1column1
number row1column2 = matrix:row1column2
number row1column3 = matrix:row1column3
number row2column0 = matrix:row2column0
number row2column1 = matrix:row2column1
number row2column2 = matrix:row2column2
number row2column3 = matrix:row2column3
number row3column0 = matrix:row3column0
number row3column1 = matrix:row3column1
number row3column2 = matrix:row3column2
number row3column3 = matrix:row3column3

output "The new matrix is:"
output "|" + row0column0 + ", " + row0column1 + ", " + row0column2 + ", " + row0column3 + "|"
output "|" + row1column0 + ", " + row1column1 + ", " + row1column2 + ", " + row1column3 + "|"
output "|" + row2column0 + ", " + row2column1 + ", " + row2column2 + ", " + row2column3 + "|"
output "|" + row3column0 + ", " + row3column1 + ", " + row3column2 + ", " + row3column3 + "|"

SetTranslation(number x, number y, number z)

This action sets the translational component of the matrix to the given translation vector.

Parameters

  • number x: The x-component of the translation
  • number y: The y-component of the translation
  • number z: The z-component of the translation

Return

Libraries.Compute.Matrix4: The matrix with the translation component

Example

use Libraries.Compute.Matrix4

Matrix4 matrix

matrix:SetTranslation(1, 2, 3)

number row0column0 = matrix:row0column0
number row0column1 = matrix:row0column1
number row0column2 = matrix:row0column2
number row0column3 = matrix:row0column3
number row1column0 = matrix:row1column0
number row1column1 = matrix:row1column1
number row1column2 = matrix:row1column2
number row1column3 = matrix:row1column3
number row2column0 = matrix:row2column0
number row2column1 = matrix:row2column1
number row2column2 = matrix:row2column2
number row2column3 = matrix:row2column3
number row3column0 = matrix:row3column0
number row3column1 = matrix:row3column1
number row3column2 = matrix:row3column2
number row3column3 = matrix:row3column3

output "The new matrix is:"
output "|" + row0column0 + ", " + row0column1 + ", " + row0column2 + ", " + row0column3 + "|"
output "|" + row1column0 + ", " + row1column1 + ", " + row1column2 + ", " + row1column3 + "|"
output "|" + row2column0 + ", " + row2column1 + ", " + row2column2 + ", " + row2column3 + "|"
output "|" + row3column0 + ", " + row3column1 + ", " + row3column2 + ", " + row3column3 + "|"

SetTranslation(Libraries.Compute.Vector3 vector)

This action sets the translational component of the matrix to the given translation vector.

Parameters

Return

Libraries.Compute.Matrix4: The matrix with the translation component

Example

use Libraries.Compute.Matrix4
use Libraries.Compute.Vctor3

Matrix4 matrix
Vector3 vector

vector:Set(1, 2, 3)
matrix:SetTranslation(vector)

number row0column0 = matrix:row0column0
number row0column1 = matrix:row0column1
number row0column2 = matrix:row0column2
number row0column3 = matrix:row0column3
number row1column0 = matrix:row1column0
number row1column1 = matrix:row1column1
number row1column2 = matrix:row1column2
number row1column3 = matrix:row1column3
number row2column0 = matrix:row2column0
number row2column1 = matrix:row2column1
number row2column2 = matrix:row2column2
number row2column3 = matrix:row2column3
number row3column0 = matrix:row3column0
number row3column1 = matrix:row3column1
number row3column2 = matrix:row3column2
number row3column3 = matrix:row3column3

output "The new matrix is:"
output "|" + row0column0 + ", " + row0column1 + ", " + row0column2 + ", " + row0column3 + "|"
output "|" + row1column0 + ", " + row1column1 + ", " + row1column2 + ", " + row1column3 + "|"
output "|" + row2column0 + ", " + row2column1 + ", " + row2column2 + ", " + row2column3 + "|"
output "|" + row3column0 + ", " + row3column1 + ", " + row3column2 + ", " + row3column3 + "|"

ToNormalMatrix()

This action sets the matrix to a normal matrix by removing the translational part and transposing the matrix.

Return

Libraries.Compute.Matrix4: The matrix as a normal matrix

Example

use Libraries.Compute.Matrix4

Matrix4 matrix

matrix:SetToTranslation(3, 4, 5)

matrix:ToNormalMatrix()

number row0column0 = matrix:row0column0
number row0column1 = matrix:row0column1
number row0column2 = matrix:row0column2
number row0column3 = matrix:row0column3
number row1column0 = matrix:row1column0
number row1column1 = matrix:row1column1
number row1column2 = matrix:row1column2
number row1column3 = matrix:row1column3
number row2column0 = matrix:row2column0
number row2column1 = matrix:row2column1
number row2column2 = matrix:row2column2
number row2column3 = matrix:row2column3
number row3column0 = matrix:row3column0
number row3column1 = matrix:row3column1
number row3column2 = matrix:row3column2
number row3column3 = matrix:row3column3

output "The new matrix is:"
output "|" + row0column0 + ", " + row0column1 + ", " + row0column2 + ", " + row0column3 + "|"
output "|" + row1column0 + ", " + row1column1 + ", " + row1column2 + ", " + row1column3 + "|"
output "|" + row2column0 + ", " + row2column1 + ", " + row2column2 + ", " + row2column3 + "|"
output "|" + row3column0 + ", " + row3column1 + ", " + row3column2 + ", " + row3column3 + "|"

TransformWorldCoordinate(Libraries.Compute.Vector3 coordinate)

This action takes a Vector3 representing a coordinate in 3D space (for example, the position of an Item3D) and transforms it by multiplying it with this Matrix. This can be used to apply translation, scaling, and rotation to a 3D point. The result is returned in a new Vector3 object.

Parameters

Return

Libraries.Compute.Vector3:

Example

use Libraries.Compute.Matrix4
use Libraries.Compute.Vector3

Matrix4 matrix
matrix:SetToTranslation(3, 0, 1)
matrix:Scale(2)

Vector3 coordinate
coordinate:Set(-2, 4, 2)
Vector3 result = matrix:TransformWorldCoordinate(coordinate)

output "Transformed coordinate is at " + result:GetX() + ", " + result:GetY() + ", " + result:GetZ()

TransformWorldCoordinate(number x, number y, number z, Libraries.Compute.Vector3 out)

This action takes a coordinate in 3D space (for example, the position of an Item3D) and transforms it by multiplying it with this Matrix. This can be used to apply translation, scaling, and rotation to a 3D point. The result is stored in the provided Vector3 parameter.

Parameters

  • number x: The x coordinate of the 3D point to transform.
  • number y: The y coordinate of the 3D point to transform.
  • number z: The z coordinate of the 3D point to transform.
  • Libraries.Compute.Vector3: A Vector3 to store the result in. This is the same Vector3 returned by the action.

Return

Libraries.Compute.Vector3:

Example

use Libraries.Compute.Matrix4
use Libraries.Compute.Vector3

Matrix4 matrix
matrix:SetToTranslation(3, 0, 1)
matrix:Scale(2)

Vector3 result
matrix:TransformWorldCoordinate(-2, 4, 2, result)

output "Transformed coordinate is at " + result:GetX() + ", " + result:GetY() + ", " + result:GetZ()

TransformWorldCoordinate(number x, number y, number z)

This action takes a coordinate in 3D space (for example, the position of an Item3D) and transforms it by multiplying it with this Matrix. This can be used to apply translation, scaling, and rotation to a 3D point. The result is returned in a new Vector3 object.

Parameters

  • number x: The x coordinate of the 3D point to transform.
  • number y: The y coordinate of the 3D point to transform.
  • number z: The z coordinate of the 3D point to transform.

Return

Libraries.Compute.Vector3:

Example

use Libraries.Compute.Matrix4
use Libraries.Compute.Vector3

Matrix4 matrix
matrix:SetToTranslation(3, 0, 1)
matrix:Scale(2)

Vector3 result = matrix:TransformWorldCoordinate(-2, 4, 2)

output "Transformed coordinate is at " + result:GetX() + ", " + result:GetY() + ", " + result:GetZ()

TransformWorldCoordinate(Libraries.Compute.Vector3 coordinate, Libraries.Compute.Vector3 out)

This action takes a Vector3 representing a coordinate in 3D space (for example, the position of an Item3D) and transforms it by multiplying it with this Matrix. This can be used to apply translation, scaling, and rotation to a 3D point. The result is stored in the second parameter, the "out" Vector3. The same Vector3 can be safely passed as both parameters in order to store the result in the original coordinate vector.

Parameters

Return

Libraries.Compute.Vector3:

Example

use Libraries.Compute.Matrix4
use Libraries.Compute.Vector3

Matrix4 matrix
matrix:SetToTranslation(3, 0, 1)
matrix:Scale(2)

Vector3 coordinate
coordinate:Set(-2, 4, 2)
Vector3 result
matrix:TransformWorldCoordinate(coordinate, result)

output "Transformed coordinate is at " + result:GetX() + ", " + result:GetY() + ", " + result:GetZ()

Translate(number x, number y, number z)

This action adds a translational component to the matrix.

Parameters

  • number x: The x-component of the translation vector
  • number y: The y-component of the translation vector
  • number z: The z-component of the translation vector

Return

Libraries.Compute.Matrix4: The matrix with the translational component added

Example

use Libraries.Compute.Matrix4

Matrix4 matrix

matrix:IdentityMatrix()

matrix:Translate(1, 2, 4)

number row0column0 = matrix:row0column0
number row0column1 = matrix:row0column1
number row0column2 = matrix:row0column2
number row0column3 = matrix:row0column3
number row1column0 = matrix:row1column0
number row1column1 = matrix:row1column1
number row1column2 = matrix:row1column2
number row1column3 = matrix:row1column3
number row2column0 = matrix:row2column0
number row2column1 = matrix:row2column1
number row2column2 = matrix:row2column2
number row2column3 = matrix:row2column3
number row3column0 = matrix:row3column0
number row3column1 = matrix:row3column1
number row3column2 = matrix:row3column2
number row3column3 = matrix:row3column3

output "The new matrix is:"
output "|" + row0column0 + ", " + row0column1 + ", " + row0column2 + ", " + row0column3 + "|"
output "|" + row1column0 + ", " + row1column1 + ", " + row1column2 + ", " + row1column3 + "|"
output "|" + row2column0 + ", " + row2column1 + ", " + row2column2 + ", " + row2column3 + "|"
output "|" + row3column0 + ", " + row3column1 + ", " + row3column2 + ", " + row3column3 + "|"

Translate(Libraries.Compute.Vector3 vector)

This action adds a translational component to the matrix.

Parameters

Return

Libraries.Compute.Matrix4: The matrix with the translational component added

Example

use Libraries.Compute.Matrix4
use Libraries.Compute.Vector3

Matrix4 matrix
Vector3 vector

matrix:IdentityMatrix()
vector:Set(1, 2, 4)

matrix:Translate(vector)

number row0column0 = matrix:row0column0
number row0column1 = matrix:row0column1
number row0column2 = matrix:row0column2
number row0column3 = matrix:row0column3
number row1column0 = matrix:row1column0
number row1column1 = matrix:row1column1
number row1column2 = matrix:row1column2
number row1column3 = matrix:row1column3
number row2column0 = matrix:row2column0
number row2column1 = matrix:row2column1
number row2column2 = matrix:row2column2
number row2column3 = matrix:row2column3
number row3column0 = matrix:row3column0
number row3column1 = matrix:row3column1
number row3column2 = matrix:row3column2
number row3column3 = matrix:row3column3

output "The new matrix is:"
output "|" + row0column0 + ", " + row0column1 + ", " + row0column2 + ", " + row0column3 + "|"
output "|" + row1column0 + ", " + row1column1 + ", " + row1column2 + ", " + row1column3 + "|"
output "|" + row2column0 + ", " + row2column1 + ", " + row2column2 + ", " + row2column3 + "|"
output "|" + row3column0 + ", " + row3column1 + ", " + row3column2 + ", " + row3column3 + "|"

Transpose()

This action transposes the matrix.

Return

Libraries.Compute.Matrix4: The matrix transposed

Example

use Libraries.Compute.Matrix4

Matrix4 matrix

matrix:Set(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15)

matrix:Transpose()

number row0column0 = matrix:row0column0
number row0column1 = matrix:row0column1
number row0column2 = matrix:row0column2
number row0column3 = matrix:row0column3
number row1column0 = matrix:row1column0
number row1column1 = matrix:row1column1
number row1column2 = matrix:row1column2
number row1column3 = matrix:row1column3
number row2column0 = matrix:row2column0
number row2column1 = matrix:row2column1
number row2column2 = matrix:row2column2
number row2column3 = matrix:row2column3
number row3column0 = matrix:row3column0
number row3column1 = matrix:row3column1
number row3column2 = matrix:row3column2
number row3column3 = matrix:row3column3

output "The new matrix is:"
output "|" + row0column0 + ", " + row0column1 + ", " + row0column2 + ", " + row0column3 + "|"
output "|" + row1column0 + ", " + row1column1 + ", " + row1column2 + ", " + row1column3 + "|"
output "|" + row2column0 + ", " + row2column1 + ", " + row2column2 + ", " + row2column3 + "|"
output "|" + row3column0 + ", " + row3column1 + ", " + row3column2 + ", " + row3column3 + "|"