Libraries.Compute.Affine2 Documentation

Affine2 is a specialized three-by-three matrix that represents a series of 2D transformations, such as translations, scales, flips, rotations, and shears. The last row of an affine is always 0, 0, 1.

Example Code

use Libraries.Compute.Affine2

Affine2 affine
affine:SetToTranslationRotationScale(3, 3, 45, 2, 2)

number row0column0 = affine:row0column0
number row0column1 = affine:row0column1
number row0column2 = affine:row0column2
number row1column0 = affine:row1column0
number row1column1 = affine:row1column1
number row1column2 = affine:row1column2

output "The affine is: "
output "|" + row0column0 + ", " + row0column1 + ", " + row0column2 + "|"
output "|" + row1column0 + ", " + row1column1 + ", " + row1column2 + "|"
output "|0, 0, 1|"

Inherits from: Libraries.Language.Object

Summary

Variable Summary Table

VariablesDescription
number row1column2
number row0column0
number row1column1
number row0column2
number row0column1
number row1column0

Actions Summary Table

ActionsDescription
ApplyTo(Libraries.Compute.Vector2 point)This action applies the affine transformation(s) to the passed point.
Compare(Libraries.Language.Object object)This action compares two object hash codes and returns an integer.
Determinant()This action calculates the determinant of the affine matrix.
Equals(Libraries.Language.Object object)This action determines if two objects are equal based on their hash code values.
GetHashCode()This action gets the hash code for an object.
GetTranslation()This action gets the x and y translation component of the affine matrix.
Identity()This action constructs an identity matrix.
Invert()This action inverts the affine matrix.
IsIdentity()This action determines whether this affine matrix is the identity matrix.
IsTranslation()This action determines whether this affine matrix is a translation matrix.
Multiply(Libraries.Compute.Affine2 affine)This action multiplies this affine matrix with the passed affine matrix.
Rotate(number degrees)This action multiplies the affine matrix with the (counter-clockwise) rotation matrix.
RotateRadians(number radians)This action multiplies the affine matrix with the (counter-clockwise) rotation matrix.
Scale(Libraries.Compute.Vector2 scale)This action multiplies the affine matrix with the scale matrix.
Scale(number scaleX, number scaleY)This action multiplies the affine matrix with the scale matrix.
Set(Libraries.Compute.Matrix4 matrix)This action sets the affine matrix to the 2D transformation components of the passed 4x4 matrix.
Set(Libraries.Compute.Matrix3 matrix)This action sets the affine matrix to the passed 3x3 matrix.
Set(Libraries.Compute.Affine2 other)This action sets the affine transformation to the passed affine transformation.
SetToProduct(Libraries.Compute.Affine2 left, Libraries.Compute.Affine2 right)This action sets the affine matrix to the product of the passed affine matrices.
SetToRotation(number cosine, number sine)This action sets the affine matrix to the rotation matrix that will rotate any vector in the counter-clockwise direction around the z-axis (the axis coming out of the screen).
SetToRotation(number degrees)This action sets the affine matrix as the rotation matrix with the given rotation angle in degrees.
SetToRotationRadians(number radians)This action sets the affine matrix to the rotation matrix with the given rotation angle in radians.
SetToScaling(number scaleX, number scaleY)This action sets the affine matrix to the scaling matrix with the given x and y scales.
SetToScaling(Libraries.Compute.Vector2 scale)This action sets the affine matrix to the scaling matrix with the given scaling vector.
SetToShearing(number shearX, number shearY)This action sets the affine matrix to the shearing matrix with the passed shear in x and y.
SetToShearing(Libraries.Compute.Vector2 vector)This action sets the affine matrix to the shearing matrix with the passed shear vector.
SetToTranslation(Libraries.Compute.Vector2 vector)This action sets the affine matrix to the translation matrix with the given vector.
SetToTranslation(number x, number y)This action sets the affine matrix to the translation matrix with the given x and y translations.
SetToTranslationRotationRadiansScale(number x, number y, number radians, number scaleX, number scaleY)This action sets the affine matrix to the concatenation of translation, rotation, and scale.
SetToTranslationRotationRadiansScale(Libraries.Compute.Vector2 translation, number radians, Libraries.Compute.Vector2 scale)This action sets the affine matrix to the concatenation of translation, rotation, and scale.
SetToTranslationRotationScale(Libraries.Compute.Vector2 translation, number degrees, Libraries.Compute.Vector2 scale)This action sets the affine matrix to the concatenation of translation, rotation, and scale.
SetToTranslationRotationScale(number x, number y, number degrees, number scaleX, number scaleY)This action sets the affine matrix to the concatenation of translation, rotation, and scale.
SetToTranslationScale(number x, number y, number scaleX, number scaleY)This action sets the affine matrix to the concatenation of translation and scale.
SetToTranslationScale(Libraries.Compute.Vector2 translation, Libraries.Compute.Vector2 scale)This action sets the affine matrix to the concatenation of translation and scale.
Shear(number shearX, number shearY)This action multiplies the affine matrix by the shear matrix.
Shear(Libraries.Compute.Vector2 shear)This action multiplies the affine matrix by the shear matrix.
Translate(number x, number y)This action multiplies the affine matrix with the translation matrix.
Translate(Libraries.Compute.Vector2 translate)This action multiplies this affine matrix with the translation matrix.

Actions Documentation

ApplyTo(Libraries.Compute.Vector2 point)

This action applies the affine transformation(s) to the passed point. The passed vector representing the point is altered as a result of this action.

Example Code

use Libraries.Compute.Affine2
    use Libraries.Compute.Vector2

    Affine2 affine
    Vector2 point

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

    point:Set(3, 4)

    affine:ApplyAffineTransformation(point)

    number x = point:GetX()
    number y = point:GetY()

    output "The new point is [" + x + ", " + y + "]"

Parameters

Compare(Libraries.Language.Object object)

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

Example Code

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

Parameters

Return

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

Determinant()

This action calculates the determinant of the affine matrix.

Example Code

use Libraries.Compute.Affine2

    Affine2 affine

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

    number determinant = affine:Determinant()

    output "The determinant is " + determinant

Return

number: The determinant of the affine 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.

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.

GetTranslation()

This action gets the x and y translation component of the affine matrix.

Example Code

use Libraries.Compute.Affine2
    use Libraries.Compute.Vector2

    Affine2 affine
    Vector2 translation

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

    translation = affine:GetTranslation()

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

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

Return

Libraries.Compute.Vector2: the position vector of the translation

Identity()

This action constructs an identity matrix. The resulting affine transformation is: 1.0 | 0.0 | 0.0 0.0 | 1.0 | 0.0 0.0 | 0.0 | 1.0

Example Code

use Libraries.Compute.Affine2

    Affine2 affine
    affine:Identity()

    number row0column0 = affine:row0column0
    number row0column1 = affine:row0column1
    number row0column2 = affine:row0column2
    number row1column0 = affine:row1column0
    number row1column1 = affine:row1column1
    number row1column2 = affine:row1column2

    output "The affine is: "
    output "|" + row0column0 + ", " + row0column1 + ", " + row0column2 + "|"
    output "|" + row1column0 + ", " + row1column1 + ", " + row1column2 + "|"
    output "|0, 0, 1|"

Return

Libraries.Compute.Affine2: The affine as the identy matrix

Invert()

This action inverts the affine matrix.

Example Code

use Libraries.Compute.Affine2

    Affine2 affine

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

    affine:Invert()

    number row0column0 = affine:row0column0
    number row0column1 = affine:row0column1
    number row0column2 = affine:row0column2
    number row1column0 = affine:row1column0
    number row1column1 = affine:row1column1
    number row1column2 = affine:row1column2

    output "The affine is: "
    output "|" + row0column0 + ", " + row0column1 + ", " + row0column2 + "|"
    output "|" + row1column0 + ", " + row1column1 + ", " + row1column2 + "|"
    output "|0, 0, 1|"

Return

Libraries.Compute.Affine2: The inverted affine

IsIdentity()

This action determines whether this affine matrix is the identity matrix.

Example Code

use Libraries.Compute.Affine2

    Affine2 affine

    if affine:IsIdentityMatris()
        output "The affine is the identity matrix."
    else
        output "The affine is not the identity matrix."
    end

Return

boolean: true if matrix is the identity matrix and false if it is not

IsTranslation()

This action determines whether this affine matrix is a translation matrix.

Example Code

use Libraries.Compute.Affine2

    Affine2 affine

    affine:SetToTranslation(3, 2)

    if affine:IsTranslation()
        output "The affine is a translation affine"
    else
        output "The affine is not a translation affine"
    end

Return

boolean: true if matrix is a translation matrix and false if it is not

Multiply(Libraries.Compute.Affine2 affine)

This action multiplies this affine matrix with the passed affine matrix.

Example Code

use Libraries.Compute.Affine2

    Affine2 affine
    Affine2 other

    affine:SetToTranslationRotationScale(2, 2, 45, 3, 3)
    other:SetToTranslationScale(1, 1, 3, 3)

    affine:Multiply(other)

    number row0column0 = affine:row0column0
    number row0column1 = affine:row0column1
    number row0column2 = affine:row0column2
    number row1column0 = affine:row1column0
    number row1column1 = affine:row1column1
    number row1column2 = affine:row1column2

    output "The affine is: "
    output "|" + row0column0 + ", " + row0column1 + ", " + row0column2 + "|"
    output "|" + row1column0 + ", " + row1column1 + ", " + row1column2 + "|"
    output "|0, 0, 1|"

Parameters

Return

Libraries.Compute.Affine2: The affine as the product

Rotate(number degrees)

This action multiplies the affine matrix with the (counter-clockwise) rotation matrix.

Example Code

use Libraries.Compute.Affine2

    Affine2 affine

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

    affine:Rotate(90)

    number row0column0 = affine:row0column0
    number row0column1 = affine:row0column1
    number row0column2 = affine:row0column2
    number row1column0 = affine:row1column0
    number row1column1 = affine:row1column1
    number row1column2 = affine:row1column2

    output "The affine is: "
    output "|" + row0column0 + ", " + row0column1 + ", " + row0column2 + "|"
    output "|" + row1column0 + ", " + row1column1 + ", " + row1column2 + "|"
    output "|0, 0, 1|"

Parameters

Return

Libraries.Compute.Affine2: The affine rotated

RotateRadians(number radians)

This action multiplies the affine matrix with the (counter-clockwise) rotation matrix.

Example Code

use Libraries.Compute.Affine2
    use Libraries.Compute.Math

    Affine2 affine
    Math math

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

    affine:RotateRadians(math:pi / 2)

    number row0column0 = affine:row0column0
    number row0column1 = affine:row0column1
    number row0column2 = affine:row0column2
    number row1column0 = affine:row1column0
    number row1column1 = affine:row1column1
    number row1column2 = affine:row1column2

    output "The affine is: "
    output "|" + row0column0 + ", " + row0column1 + ", " + row0column2 + "|"
    output "|" + row1column0 + ", " + row1column1 + ", " + row1column2 + "|"
    output "|0, 0, 1|"

Parameters

Return

Libraries.Compute.Affine2: The affine rotated

Scale(Libraries.Compute.Vector2 scale)

This action multiplies the affine matrix with the scale matrix.

Example Code

use Libraries.Compute.Affine2
    use Libraries.Compute.Vector2
    
    Affine2 affine
    Vector2 vector

    affine:SetToTranslationRotationScale(3, 3, 45, 2, 2)
    vector:Set(4, 4)

    affine:Scale(vector)

    number row0column0 = affine:row0column0
    number row0column1 = affine:row0column1
    number row0column2 = affine:row0column2
    number row1column0 = affine:row1column0
    number row1column1 = affine:row1column1
    number row1column2 = affine:row1column2

    output "The affine is: "
    output "|" + row0column0 + ", " + row0column1 + ", " + row0column2 + "|"
    output "|" + row1column0 + ", " + row1column1 + ", " + row1column2 + "|"
    output "|0, 0, 1|"

Parameters

Return

Libraries.Compute.Affine2: The affine scaled

Scale(number scaleX, number scaleY)

This action multiplies the affine matrix with the scale matrix.

Example Code

use Libraries.Compute.Affine2

    Affine2 affine

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

    affine:Scale(4, 4)

    number row0column0 = affine:row0column0
    number row0column1 = affine:row0column1
    number row0column2 = affine:row0column2
    number row1column0 = affine:row1column0
    number row1column1 = affine:row1column1
    number row1column2 = affine:row1column2

    output "The affine is: "
    output "|" + row0column0 + ", " + row0column1 + ", " + row0column2 + "|"
    output "|" + row1column0 + ", " + row1column1 + ", " + row1column2 + "|"
    output "|0, 0, 1|"

Parameters

Return

Libraries.Compute.Affine2: The affine scaled

Set(Libraries.Compute.Matrix4 matrix)

This action sets the affine matrix to the 2D transformation components of the passed 4x4 matrix.

Example Code

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

    Affine2 affine
    Matrix4 matrix

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

    affine:Set(matrix)

    number row0column0 = affine:row0column0
    number row0column1 = affine:row0column1
    number row0column2 = affine:row0column2
    number row1column0 = affine:row1column0
    number row1column1 = affine:row1column1
    number row1column2 = affine:row1column2

    output "The affine is: "
    output "|" + row0column0 + ", " + row0column1 + ", " + row0column2 + "|"
    output "|" + row1column0 + ", " + row1column1 + ", " + row1column2 + "|"
    output "|0, 0, 1|"

Parameters

Return

Libraries.Compute.Affine2: The affine after setting

Set(Libraries.Compute.Matrix3 matrix)

This action sets the affine matrix to the passed 3x3 matrix.

Example Code

use Libraries.Compute.Affine2
    use Libraries.Compute.Matrix3

    Affine2 affine
    Matrix3 matrix

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

    affine:Set(matrix)

    number row0column0 = affine:row0column0
    number row0column1 = affine:row0column1
    number row0column2 = affine:row0column2
    number row1column0 = affine:row1column0
    number row1column1 = affine:row1column1
    number row1column2 = affine:row1column2

    output "The affine is: "
    output "|" + row0column0 + ", " + row0column1 + ", " + row0column2 + "|"
    output "|" + row1column0 + ", " + row1column1 + ", " + row1column2 + "|"
    output "|0, 0, 1|"

Parameters

Return

Libraries.Compute.Affine2: The affine after setting

Set(Libraries.Compute.Affine2 other)

This action sets the affine transformation to the passed affine transformation.

Example Code

use Libraries.Compute.Affine2

    Affine2 affine
    Affine2 setAffine

    setAffine:SetToTranslation(3, 4)

    affine:Set(setAffine)

    number row0column0 = affine:row0column0
    number row0column1 = affine:row0column1
    number row0column2 = affine:row0column2
    number row1column0 = affine:row1column0
    number row1column1 = affine:row1column1
    number row1column2 = affine:row1column2

    output "The affine is: "
    output "|" + row0column0 + ", " + row0column1 + ", " + row0column2 + "|"
    output "|" + row1column0 + ", " + row1column1 + ", " + row1column2 + "|"
    output "|0, 0, 1|"

Parameters

Return

Libraries.Compute.Affine2: The affine after setting

SetToProduct(Libraries.Compute.Affine2 left, Libraries.Compute.Affine2 right)

This action sets the affine matrix to the product of the passed affine matrices.

Example Code

use Libraries.Compute.Affine2

    Affine2 affine
    Affine2 left
    Affine2 right

    left:SetToTranslationScale(3, 3, 2, 2)
    right:SetToTranslationRotationScale(2, 3, 45, 2, 2)

    affine:SetToProduct(left, right)

    number row0column0 = affine:row0column0
    number row0column1 = affine:row0column1
    number row0column2 = affine:row0column2
    number row1column0 = affine:row1column0
    number row1column1 = affine:row1column1
    number row1column2 = affine:row1column2

    output "The affine is: "
    output "|" + row0column0 + ", " + row0column1 + ", " + row0column2 + "|"
    output "|" + row1column0 + ", " + row1column1 + ", " + row1column2 + "|"
    output "|0, 0, 1|"

Parameters

Return

Libraries.Compute.Affine2: The affine after setting as the product

SetToRotation(number cosine, number sine)

This action sets the affine matrix to the rotation matrix that will rotate any vector in the counter-clockwise direction around the z-axis (the axis coming out of the screen).

Example Code

use Libraries.Compute.Affine2
    use Libraries.Compute.Math

    Math math

    Affine2 affine

    affine:SetToRotation(math:SquareRoot(2) / 2, math:SquareRoot(2) / 2)

    number row0column0 = affine:row0column0
    number row0column1 = affine:row0column1
    number row0column2 = affine:row0column2
    number row1column0 = affine:row1column0
    number row1column1 = affine:row1column1
    number row1column2 = affine:row1column2

    output "The affine is: "
    output "|" + row0column0 + ", " + row0column1 + ", " + row0column2 + "|"
    output "|" + row1column0 + ", " + row1column1 + ", " + row1column2 + "|"
    output "|0, 0, 1|"

Parameters

Return

Libraries.Compute.Affine2: The affine after setting

SetToRotation(number degrees)

This action sets the affine matrix as the rotation matrix with the given rotation angle in degrees.

Example Code

use Libraries.Compute.Affine2

    Affine2 affine
    
    affine:SetToRotation(45)

    number row0column0 = affine:row0column0
    number row0column1 = affine:row0column1
    number row0column2 = affine:row0column2
    number row1column0 = affine:row1column0
    number row1column1 = affine:row1column1
    number row1column2 = affine:row1column2

    output "The affine is: "
    output "|" + row0column0 + ", " + row0column1 + ", " + row0column2 + "|"
    output "|" + row1column0 + ", " + row1column1 + ", " + row1column2 + "|"
    output "|0, 0, 1|"

Parameters

Return

Libraries.Compute.Affine2: The affine after setting

SetToRotationRadians(number radians)

This action sets the affine matrix to the rotation matrix with the given rotation angle in radians.

Example Code

use Libraries.Compute.Affine2
    use Libraries.Compute.Math
    
    Math math

    Affine2 affine

    affine:SetToRotationRadians(math:pi / 4)

    number row0column0 = affine:row0column0
    number row0column1 = affine:row0column1
    number row0column2 = affine:row0column2
    number row1column0 = affine:row1column0
    number row1column1 = affine:row1column1
    number row1column2 = affine:row1column2

    output "The affine is: "
    output "|" + row0column0 + ", " + row0column1 + ", " + row0column2 + "|"
    output "|" + row1column0 + ", " + row1column1 + ", " + row1column2 + "|"
    output "|0, 0, 1|"

Parameters

Return

Libraries.Compute.Affine2: The affine after setting

SetToScaling(number scaleX, number scaleY)

This action sets the affine matrix to the scaling matrix with the given x and y scales.

Example Code

use Libraries.Compute.Affine2
    
    Affine2 affine

    affine:SetToScaling(2, 2)

    number row0column0 = affine:row0column0
    number row0column1 = affine:row0column1
    number row0column2 = affine:row0column2
    number row1column0 = affine:row1column0
    number row1column1 = affine:row1column1
    number row1column2 = affine:row1column2

    output "The affine is: "
    output "|" + row0column0 + ", " + row0column1 + ", " + row0column2 + "|"
    output "|" + row1column0 + ", " + row1column1 + ", " + row1column2 + "|"
    output "|0, 0, 1|"

Parameters

Return

Libraries.Compute.Affine2: The affine after setting

SetToScaling(Libraries.Compute.Vector2 scale)

This action sets the affine matrix to the scaling matrix with the given scaling vector.

Example Code

use Libraries.Compute.Affine2
    use Libraries.Compute.Vector2

    Affine2 affine
    Vector2 vector

    vector:Set(2, 2)

    affine:SetToScaling(vector)

    number row0column0 = affine:row0column0
    number row0column1 = affine:row0column1
    number row0column2 = affine:row0column2
    number row1column0 = affine:row1column0
    number row1column1 = affine:row1column1
    number row1column2 = affine:row1column2

    output "The affine is: "
    output "|" + row0column0 + ", " + row0column1 + ", " + row0column2 + "|"
    output "|" + row1column0 + ", " + row1column1 + ", " + row1column2 + "|"
    output "|0, 0, 1|"

Parameters

Return

Libraries.Compute.Affine2: The affine after setting

SetToShearing(number shearX, number shearY)

This action sets the affine matrix to the shearing matrix with the passed shear in x and y.

Example Code

use Libraries.Compute.Affine2

    Affine2 affine

    affine:SetToShearing(3, 2)

    number row0column0 = affine:row0column0
    number row0column1 = affine:row0column1
    number row0column2 = affine:row0column2
    number row1column0 = affine:row1column0
    number row1column1 = affine:row1column1
    number row1column2 = affine:row1column2

    output "The affine is: "
    output "|" + row0column0 + ", " + row0column1 + ", " + row0column2 + "|"
    output "|" + row1column0 + ", " + row1column1 + ", " + row1column2 + "|"
    output "|0, 0, 1|"

Parameters

Return

Libraries.Compute.Affine2: The affine after setting

SetToShearing(Libraries.Compute.Vector2 vector)

This action sets the affine matrix to the shearing matrix with the passed shear vector.

Example Code

use Libraries.Compute.Affine2
    use Libraries.Compute.Vector2

    Affine2 affine
    Vector2 vector

    vector:Set(3, 2)

    affine:SetToShearing(vector)

    number row0column0 = affine:row0column0
    number row0column1 = affine:row0column1
    number row0column2 = affine:row0column2
    number row1column0 = affine:row1column0
    number row1column1 = affine:row1column1
    number row1column2 = affine:row1column2

    output "The affine is: "
    output "|" + row0column0 + ", " + row0column1 + ", " + row0column2 + "|"
    output "|" + row1column0 + ", " + row1column1 + ", " + row1column2 + "|"
    output "|0, 0, 1|"

Parameters

Return

Libraries.Compute.Affine2: The affine after setting

SetToTranslation(Libraries.Compute.Vector2 vector)

This action sets the affine matrix to the translation matrix with the given vector.

Example Code

use Libraries.Compute.Affine2
    use Libraries.Compute.Vector2

    Affine2 affine
    Vector2 vector

    vector:Set(3, 4)

    affine:SetToTranslation(vector)

    number row0column0 = affine:row0column0
    number row0column1 = affine:row0column1
    number row0column2 = affine:row0column2
    number row1column0 = affine:row1column0
    number row1column1 = affine:row1column1
    number row1column2 = affine:row1column2

    output "The affine is: "
    output "|" + row0column0 + ", " + row0column1 + ", " + row0column2 + "|"
    output "|" + row1column0 + ", " + row1column1 + ", " + row1column2 + "|"
    output "|0, 0, 1|"

Parameters

Return

Libraries.Compute.Affine2: The affine after setting

SetToTranslation(number x, number y)

This action sets the affine matrix to the translation matrix with the given x and y translations.

Example Code

use Libraries.Compute.Affine2

    Affine2 affine

    affine:SetToTranslation(3, 4)

    number row0column0 = affine:row0column0
    number row0column1 = affine:row0column1
    number row0column2 = affine:row0column2
    number row1column0 = affine:row1column0
    number row1column1 = affine:row1column1
    number row1column2 = affine:row1column2

    output "The affine is: "
    output "|" + row0column0 + ", " + row0column1 + ", " + row0column2 + "|"
    output "|" + row1column0 + ", " + row1column1 + ", " + row1column2 + "|"
    output "|0, 0, 1|"

Parameters

Return

Libraries.Compute.Affine2: The affine after setting

SetToTranslationRotationRadiansScale(number x, number y, number radians, number scaleX, number scaleY)

This action sets the affine matrix to the concatenation of translation, rotation, and scale. This is more efficient than doing all three transformations separately.

Example Code

use Libraries.Compute.Affine2
    use Libraries.Compute.Math

    Math math

    Affine2 affine

    affine:SetToTranslationRotationRadiansScale(3, 3, math:pi / 4, 2, 2)

    number row0column0 = affine:row0column0
    number row0column1 = affine:row0column1
    number row0column2 = affine:row0column2
    number row1column0 = affine:row1column0
    number row1column1 = affine:row1column1
    number row1column2 = affine:row1column2

    output "The affine is: "
    output "|" + row0column0 + ", " + row0column1 + ", " + row0column2 + "|"
    output "|" + row1column0 + ", " + row1column1 + ", " + row1column2 + "|"
    output "|0, 0, 1|"

Parameters

Return

Libraries.Compute.Affine2: The affine after setting

SetToTranslationRotationRadiansScale(Libraries.Compute.Vector2 translation, number radians, Libraries.Compute.Vector2 scale)

This action sets the affine matrix to the concatenation of translation, rotation, and scale. This is more efficient than doing all three transformations separately.

Example Code

use Libraries.Compute.Affine2
    use Libraries.Compute.Vector2
    use Libraries.Compute.Math

    Math math

    Affine2 affine
    Vector2 translation
    Vector2 scale

    translation:Set(3, 3)
    scale:Set(2, 2)

    affine:SetToTranslationRotationRadiansScale(translation, math:pi / 4, scale)

    number row0column0 = affine:row0column0
    number row0column1 = affine:row0column1
    number row0column2 = affine:row0column2
    number row1column0 = affine:row1column0
    number row1column1 = affine:row1column1
    number row1column2 = affine:row1column2

    output "The affine is: "
    output "|" + row0column0 + ", " + row0column1 + ", " + row0column2 + "|"
    output "|" + row1column0 + ", " + row1column1 + ", " + row1column2 + "|"
    output "|0, 0, 1|"

Parameters

Return

Libraries.Compute.Affine2: The affine after setting

SetToTranslationRotationScale(Libraries.Compute.Vector2 translation, number degrees, Libraries.Compute.Vector2 scale)

This action sets the affine matrix to the concatenation of translation, rotation, and scale. This is more efficient than doing all three transformations separately.

Example Code

use Libraries.Compute.Affine2
    use Libraries.Compute.Vector2

    Affine2 affine
    Vector2 translation
    Vector2 scale

    translation:Set(3, 3)
    scale:Set(2, 2)

    affine:SetToTranslationRotationScale(translation, 45, scale)

    number row0column0 = affine:row0column0
    number row0column1 = affine:row0column1
    number row0column2 = affine:row0column2
    number row1column0 = affine:row1column0
    number row1column1 = affine:row1column1
    number row1column2 = affine:row1column2

    output "The affine is: "
    output "|" + row0column0 + ", " + row0column1 + ", " + row0column2 + "|"
    output "|" + row1column0 + ", " + row1column1 + ", " + row1column2 + "|"
    output "|0, 0, 1|"

Parameters

Return

Libraries.Compute.Affine2: The affine after setting

SetToTranslationRotationScale(number x, number y, number degrees, number scaleX, number scaleY)

This action sets the affine matrix to the concatenation of translation, rotation, and scale. This is more efficient than doing all three transformations separately.

Example Code

use Libraries.Compute.Affine2

    Affine2 affine

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

    number row0column0 = affine:row0column0
    number row0column1 = affine:row0column1
    number row0column2 = affine:row0column2
    number row1column0 = affine:row1column0
    number row1column1 = affine:row1column1
    number row1column2 = affine:row1column2

    output "The affine is: "
    output "|" + row0column0 + ", " + row0column1 + ", " + row0column2 + "|"
    output "|" + row1column0 + ", " + row1column1 + ", " + row1column2 + "|"
    output "|0, 0, 1|"

Parameters

Return

Libraries.Compute.Affine2: The affine after setting

SetToTranslationScale(number x, number y, number scaleX, number scaleY)

This action sets the affine matrix to the concatenation of translation and scale. This is more efficient than doing both separately.

Example Code

use Libraries.Compute.Affine2

    Affine2 affine

    affine:SetToTranslationScale(3, 3, 2, 2)

    number row0column0 = affine:row0column0
    number row0column1 = affine:row0column1
    number row0column2 = affine:row0column2
    number row1column0 = affine:row1column0
    number row1column1 = affine:row1column1
    number row1column2 = affine:row1column2

    output "The affine is: "
    output "|" + row0column0 + ", " + row0column1 + ", " + row0column2 + "|"
    output "|" + row1column0 + ", " + row1column1 + ", " + row1column2 + "|"
    output "|0, 0, 1|"

Parameters

Return

Libraries.Compute.Affine2: The affine after setting

SetToTranslationScale(Libraries.Compute.Vector2 translation, Libraries.Compute.Vector2 scale)

This action sets the affine matrix to the concatenation of translation and scale. This is more efficient than doing both separately.

Example Code

use Libraries.Compute.Affine2
    use Libraries.Compute.Vector2

    Affine2 affine
    Vector2 translation
    Vector2 scale

    translation:Set(3, 3)
    scale:Set(2, 2)

    affine:SetToTranslationScale(translation, scale)

    number row0column0 = affine:row0column0
    number row0column1 = affine:row0column1
    number row0column2 = affine:row0column2
    number row1column0 = affine:row1column0
    number row1column1 = affine:row1column1
    number row1column2 = affine:row1column2

    output "The affine is: "
    output "|" + row0column0 + ", " + row0column1 + ", " + row0column2 + "|"
    output "|" + row1column0 + ", " + row1column1 + ", " + row1column2 + "|"
    output "|0, 0, 1|"

Parameters

Return

Libraries.Compute.Affine2: The affine after setting

Shear(number shearX, number shearY)

This action multiplies the affine matrix by the shear matrix.

Example Code

use Libraries.Compute.Affine2

    Affine2 affine

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

    affine:Shear(2, 2)

    number row0column0 = affine:row0column0
    number row0column1 = affine:row0column1
    number row0column2 = affine:row0column2
    number row1column0 = affine:row1column0
    number row1column1 = affine:row1column1
    number row1column2 = affine:row1column2

    output "The affine is: "
    output "|" + row0column0 + ", " + row0column1 + ", " + row0column2 + "|"
    output "|" + row1column0 + ", " + row1column1 + ", " + row1column2 + "|"
    output "|0, 0, 1|"

Parameters

Return

Libraries.Compute.Affine2: The affine sheared

Shear(Libraries.Compute.Vector2 shear)

This action multiplies the affine matrix by the shear matrix.

Example Code

use Libraries.Compute.Affine2
    use Libraries.Compute.Vector2

    Affine2 affine
    Vector2 vector

    vector:Set(2, 2)
    affine:SetToTranslationRotationScale(3, 3, 45, 2, 2)

    affine:Shear(vector)

    number row0column0 = affine:row0column0
    number row0column1 = affine:row0column1
    number row0column2 = affine:row0column2
    number row1column0 = affine:row1column0
    number row1column1 = affine:row1column1
    number row1column2 = affine:row1column2

    output "The affine is: "
    output "|" + row0column0 + ", " + row0column1 + ", " + row0column2 + "|"
    output "|" + row1column0 + ", " + row1column1 + ", " + row1column2 + "|"
    output "|0, 0, 1|"

Parameters

Return

Libraries.Compute.Affine2: The affine sheared

Translate(number x, number y)

This action multiplies the affine matrix with the translation matrix.

Example Code

use Libraries.Compute.Affine2
    
    Affine2 affine

    affine:SetToTranslationRotationScale(3, 3, 45, 2, 2)
    
    affine:Translate(4, 3)

    number row0column0 = affine:row0column0
    number row0column1 = affine:row0column1
    number row0column2 = affine:row0column2
    number row1column0 = affine:row1column0
    number row1column1 = affine:row1column1
    number row1column2 = affine:row1column2

    output "The affine is: "
    output "|" + row0column0 + ", " + row0column1 + ", " + row0column2 + "|"
    output "|" + row1column0 + ", " + row1column1 + ", " + row1column2 + "|"
    output "|0, 0, 1|"

Parameters

Return

Libraries.Compute.Affine2: The affine translated

Translate(Libraries.Compute.Vector2 translate)

This action multiplies this affine matrix with the translation matrix.

Example Code

use Libraries.Compute.Affine2
    use Libraries.Compute.Vector2

    Affine2 affine
    Vector2 vector

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

    vector:Set(4, 3)

    affine:Translate(vector)

Parameters

Return

Libraries.Compute.Affine2: The affine translated