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

Summary

Variable Summary Table

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

Actions Summary Table

ActionsDescription
Average(Libraries.Compute.Matrix4 other, number weight)This action averages the matrix with the passed matrix.
Compare(Libraries.Language.Object object)This action compares two object hash codes and returns a CompareResult.
Copy()This action creates a new matrix that is a copy of this matrix.
Determinant()This action computes the determinant of the matrix.
Determinant3x3()This action computes the determinant of the 3x3 matrix composed of the first three rows and first three columns of the 4x4 matrix.
Equals(Libraries.Language.Object object)This action determines if two objects are equal based on their hash code values.
GetElement(integer row, integer column)
GetHashCode()This action gets the hash code for an object.
GetRotation(boolean normalizeAxes)This action gets the rotation of the matrix and returns it as a Quaternion.
GetRotation()This action gets the rotation of the matrix and returns it as a Quaternion.
GetScale()This action returns the scale components of each axis of the matrix.
GetScaleX()This action gets the x-component of the scale of the matrix.
GetScaleXSquared()This action gets the square of the x-component of the scale of the matrix.
GetScaleY()This action gets the y-component of the scale of the matrix.
GetScaleYSquared()This action gets the square of the y-component of the scale of the matrix.
GetScaleZ()This action gets the z-component of the scale of the matrix.
GetScaleZSquared()This action gets the square of the z-component of the scale of the matrix.
GetTranslation()This action gets the translational component of the matrix.
IdentityMatrix()This action sets the matrix to the 4x4 identity matrix.
Inverse()This action computes the inverse of the matrix
LinearInterpolation(Libraries.Compute.Matrix4 matrix, number alpha)This action performs a linear interpolation between the matrix and the passed matrix by alpha.
Multiply(Libraries.Compute.Matrix4 matrix)This action multiplies the calling matrix by the passed matrix.
Multiply(Libraries.Compute.Matrix4 matrixA, Libraries.Compute.Matrix4 matrixB)This action multiplies the two passed matrices.
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).
Project(Libraries.Compute.Matrix4 matrix, Libraries.Compute.Vector3 vector)This action performs a projection with the given matrix and vector.
Rotate(Libraries.Compute.Quaternion rotation)This action rotates the matrix by the given quaternion specifying the rotation.
Rotate(Libraries.Compute.Vector3 axis, number degrees)This action rotates the matrix around the given axis by the given angle in degrees.
Rotate(number axisX, number axisY, number axisZ, number degrees)This action rotates the matrix around the given axis by the given angle in degrees.
Rotate(Libraries.Compute.Vector3 base, Libraries.Compute.Vector3 target)This action rotates the matrix by the rotation between the two passed vectors.
RotateRadians(Libraries.Compute.Vector3 axis, number radians)This action rotates the matrix around the given axis by the given angle in radians.
RotateRadians(number axisX, number axisY, number axisZ, number radians)This action rotates the matrix around the given axis by the given angle in radians.
Scale(Libraries.Compute.Vector3 scale)This action scales the scaling portion of the transformation matrix by the passed scale vector.
Scale(number scale)This action scales the scaling portion of the transformation matrix by the passed scale value.
Scale(number scaleX, number scaleY, number scaleZ)This action scales the scaling portion of the transformation matrix by the passed scale vector.
Set(Libraries.Compute.Matrix4 matrix)This action sets the matrix to be a copy of the passed matrix.
Set(Libraries.Compute.Matrix3 matrix)This action sets the matrix using the passed 3x3 matrix.
Set(Libraries.Containers.Array<number> array)This action sets the values of the matrix using the values of the passed array.
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.
Set(Libraries.Compute.Affine2 affine)This action sets the matrix to the given affine matrix.
Set(number quaternionX, number quaternionY, number quaternionZ, number quaternionW)This action sets the matrix to a rotation matrix representing the passed Quaternion values.
Set(Libraries.Compute.Vector3 position, Libraries.Compute.Quaternion orientation)This action sets the matrix to the passed translation and rotation.
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.
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.
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.
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.
Set(Libraries.Compute.Quaternion quaternion)This action sets the matrix to a rotation matrix representing the passed Quaternion.
SetAsAffine(Libraries.Compute.Matrix4 matrix)This action sets the matrix as an affine, representing a series of 2D transformations.
SetAsAffine(Libraries.Compute.Affine2 affine)This action sets the matrix as an affine, representing a series of 2D transformations.
SetFromEulerAngles(number yaw, number pitch, number roll)This action sets the matrix to a rotation matrix with the given Euler angles given in degrees.
SetFromEulerAnglesRadians(number yaw, number pitch, number roll)This action sets the matrix to a rotation matrix with the given Euler angles given in radians.
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.
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.
SetToOrthographic(number left, number right, number bottom, number top, number near, number far)This action sets the matrix to an orthographic projection matrix.
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.
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.
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.
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.
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.
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.
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.
SetToRotation(Libraries.Compute.Vector3 base, Libraries.Compute.Vector3 target)This action sets the matrix to a rotation matrix between the two vectors.
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.
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.
SetToScaling(Libraries.Compute.Vector3 scale)This action sets the matrix to a scaling matrix with the passed vector representing the scale.
SetToScaling(number scaleX, number scaleY, number scaleZ)This action sets the matrix to a scaling matrix with the passed vector representing the scale.
SetToTranslation(Libraries.Compute.Vector3 vector)This action sets the matrix to the translation matrix with the passed translation
SetToTranslation(number x, number y, number z)This action sets the matrix to the translation matrix with the passed translation
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.
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.
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.
SetTranslation(number x, number y, number z)This action sets the translational component of the matrix to the given translation vector.
SetTranslation(Libraries.Compute.Vector3 vector)This action sets the translational component of the matrix to the given translation vector.
ToNormalMatrix()This action sets the matrix to a normal matrix by removing the translational part and transposing the matrix.
Translate(number x, number y, number z)This action adds a translational component to the matrix.
Translate(Libraries.Compute.Vector3 vector)This action adds a translational component to the matrix.
Transpose()This action transposes the matrix.

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.

Example Code

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 + "|"

Parameters

Return

Libraries.Compute.Matrix4: The matrix after averaging

Compare(Libraries.Language.Object object)

This action compares two object hash codes and returns a CompareResult. The compare result is either larger if this hash code is larger than the object passed as a parameter, smaller, or equal.

Example Code

use Libraries.Language.Support.CompareResult
        Object o
        Object t
        CompareResult result = o:Compare(t)

Parameters

Return

Libraries.Language.Support.CompareResult: The Compare result, Smaller, Equal, or Larger.

Copy()

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

Example Code

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 + "|"

Return

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

Determinant()

This action computes the determinant of the 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)

    number determinant = matrix:Determinant()

    output "The determinant is " + determinant

Return

number: The determinant of the matrix

Determinant3x3()

This action computes the determinant of the 3x3 matrix composed of the first three rows and first three columns of the 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)

    number determinant3x3 = matrix:Determinant3x3()

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

Return

number: The determinant of the 3x3 upper left matrix

Equals(Libraries.Language.Object object)

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

Example Code

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

Parameters

Return

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

GetElement(integer row, integer column)

Parameters

Return

number

GetHashCode()

This action gets the hash code for an object.

Example Code

Object o
        integer hash = o:GetHashCode()

Return

integer: The integer hash code of the object.

GetRotation(boolean normalizeAxes)

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

Example Code

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 + "]"

Parameters

Return

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

GetRotation()

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

Example Code

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 + "]"

Return

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

GetScale()

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

Example Code

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 + "]"

Return

Libraries.Compute.Vector3: the scale vector

GetScaleX()

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

Example Code

use Libraries.Compute.Matrix4

    Matrix4 matrix

    matrix:SetToScaling(2, 3, 4)

    number scaleX = matrix:GetScaleX()

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

Return

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

GetScaleXSquared()

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

Example Code

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

Return

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

GetScaleY()

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

Example Code

use Libraries.Compute.Matrix4

    Matrix4 matrix

    matrix:SetToScaling(2, 3, 4)

    number scaleY = matrix:GetScaleY()

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

Return

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

GetScaleYSquared()

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

Example Code

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

Return

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

GetScaleZ()

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

Example Code

use Libraries.Compute.Matrix4

    Matrix4 matrix

    matrix:SetToScaling(2, 3, 4)

    number scaleZ = matrix:GetScaleZ()

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

Return

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

GetScaleZSquared()

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

Example Code

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

Return

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

GetTranslation()

This action gets the translational component of the matrix..

Example Code

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 + "]"

Return

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

IdentityMatrix()

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

Example Code

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 + "|"

Return

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

Inverse()

This action computes the inverse of the 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 + "|"

Return

Libraries.Compute.Matrix4: The inverted matrix

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.

Example Code

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 + "|"

Parameters

Return

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

Multiply(Libraries.Compute.Matrix4 matrix)

This action multiplies the calling matrix by the passed matrix.

Example Code

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 + "|"

Parameters

Return

Libraries.Compute.Matrix4: The matrix after multiplication

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

This action multiplies the two passed matrices.

Example Code

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 + "|"

Parameters

Return

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

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.

Example Code

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

Parameters

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.

Example Code

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 + "]"

Parameters

Rotate(Libraries.Compute.Quaternion rotation)

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

Example Code

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 + "|"

Parameters

Return

Libraries.Compute.Matrix4: The matrix rotated

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

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

Example Code

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 + "|"

Parameters

Return

Libraries.Compute.Matrix4: The matrix rotated

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

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

Example Code

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 + "|"

Parameters

Return

Libraries.Compute.Matrix4: The matrix rotated

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

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

Example Code

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 + "|"

Parameters

Return

Libraries.Compute.Matrix4: The matrix rotated

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

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

Example Code

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 + "|"

Parameters

Return

Libraries.Compute.Matrix4: The matrix rotated

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

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

Example Code

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 + "|"

Parameters

Return

Libraries.Compute.Matrix4: The matrix rotated

Scale(Libraries.Compute.Vector3 scale)

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

Example Code

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 + "|"

Parameters

Return

Libraries.Compute.Matrix4: The matrix after scaling

Scale(number scale)

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

Example Code

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 + "|"

Parameters

Return

Libraries.Compute.Matrix4: The matrix after scaling

Scale(number scaleX, number scaleY, number scaleZ)

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

Example Code

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 + "|"

Parameters

Return

Libraries.Compute.Matrix4: The matrix after scaling

Set(Libraries.Compute.Matrix4 matrix)

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

Example Code

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 + "|"

Parameters

Return

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

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).

Example Code

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 + "|"

Parameters

Return

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

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.

Example Code

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 + "|"

Parameters

Return

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

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.

Example Code

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 + "|"

Parameters

Return

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

Set(Libraries.Compute.Affine2 affine)

This action sets the matrix to the given affine matrix.

Example Code

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 + "|"

Parameters

Return

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

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.

Example Code

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 + "|"

Parameters

Return

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

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

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

Example Code

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 + "|"

Parameters

Return

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

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.

Example Code

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 + "|"

Parameters

Return

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

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.

Example Code

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 + "|"

Parameters

Return

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

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.

Example Code

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 + "|"

Parameters

Return

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

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.

Example Code

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 + "|"

Parameters

Return

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

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.

Example Code

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 + "|"

Parameters

Return

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

SetAsAffine(Libraries.Compute.Matrix4 matrix)

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

Example Code

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 + "|"

Parameters

Return

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

SetAsAffine(Libraries.Compute.Affine2 affine)

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

Example Code

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 + "|"

Parameters

Return

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

SetFromEulerAngles(number yaw, number pitch, number roll)

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

Example Code

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 + "|"

Parameters

Return

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

SetFromEulerAnglesRadians(number yaw, number pitch, number roll)

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

Example Code

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 + "|"

Parameters

Return

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

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.

Example Code

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 + "|"

Parameters

Return

Libraries.Compute.Matrix4: the matrix

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.

Example Code

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 + "|"

Parameters

Return

Libraries.Compute.Matrix4: the matrix

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

This action sets the matrix to an orthographic projection matrix.

Example Code

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 + "|"

Parameters

Return

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

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.

Example Code

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 + "|"

Parameters

Return

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

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.

Example Code

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 + "|"

Parameters

Return

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

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.

Example Code

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 + "|"

Parameters

Return

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

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.

Example Code

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 + "|"

Parameters

Return

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

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.

Example Code

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 + "|"

Parameters

Return

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

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.

Example Code

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 + "|"

Parameters

Return

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

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.

Example Code

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 + "|"

Parameters

Return

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

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

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

Example Code

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 + "|"

Parameters

Return

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

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.

Example Code

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 + "|"

Parameters

Return

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

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.

Example Code

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 + "|"

Parameters

Return

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

SetToScaling(Libraries.Compute.Vector3 scale)

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

Example Code

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 + "|"

Parameters

Return

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

SetToScaling(number scaleX, number scaleY, number scaleZ)

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

Example Code

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 + "|"

Parameters

Return

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

SetToTranslation(Libraries.Compute.Vector3 vector)

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

Example Code

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 + "|"

Parameters

Return

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

SetToTranslation(number x, number y, number z)

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

Example Code

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 + "|"

Parameters

Return

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

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.

Example Code

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 + "|"

Parameters

Return

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

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.

Example Code

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 + "|"

Parameters

Return

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

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.

Example Code

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 + "|"

Parameters

Return

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

SetTranslation(number x, number y, number z)

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

Example Code

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 + "|"

Parameters

Return

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

SetTranslation(Libraries.Compute.Vector3 vector)

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

Example Code

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 + "|"

Parameters

Return

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

ToNormalMatrix()

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

Example Code

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 + "|"

Return

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

Translate(number x, number y, number z)

This action adds a translational component to the matrix.

Example Code

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 + "|"

Parameters

Return

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

Translate(Libraries.Compute.Vector3 vector)

This action adds a translational component to the matrix.

Example Code

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 + "|"

Parameters

Return

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

Transpose()

This action transposes the matrix.

Example Code

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 + "|"

Return

Libraries.Compute.Matrix4: The matrix transposed