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
Variables Table
Variables | Description |
---|---|
number row0column1 | |
number row1column0 | |
number row1column2 | |
number row0column0 | |
number row1column1 | |
number row0column2 |
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.
Parameters
- Libraries.Compute.Vector2: The point to apply the transformations to
Example
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 + "]"
Compare(Libraries.Language.Object object)
This action compares two object hash codes and returns an integer. The result is larger if this hash code is larger than the object passed as a parameter, smaller, or equal. In this case, -1 means smaller, 0 means equal, and 1 means larger. This action was changed in Quorum 7 to return an integer, instead of a CompareResult object, because the previous implementation was causing efficiency issues.
Parameters
- Libraries.Language.Object: The object to compare to.
Return
integer: The Compare result, Smaller, Equal, or Larger.
Example
Object o
Object t
integer result = o:Compare(t) //1 (larger), 0 (equal), or -1 (smaller)
Determinant()
This action calculates the determinant of the affine matrix.
Return
number: The determinant of the affine matrix
Example
use Libraries.Compute.Affine2
Affine2 affine
affine:SetToTranslationRotationScale(3, 3, 45, 2, 2)
number determinant = affine:Determinant()
output "The determinant is " + determinant
Equals(Libraries.Language.Object object)
This action determines if two objects are equal based on their hash code values.
Parameters
- Libraries.Language.Object: The to be compared.
Return
boolean: True if the hash codes are equal and false if they are not equal.
Example
use Libraries.Language.Object
use Libraries.Language.Types.Text
Object o
Text t
boolean result = o:Equals(t)
GetHashCode()
This action gets the hash code for an object.
Return
integer: The integer hash code of the object.
Example
Object o
integer hash = o:GetHashCode()
GetTranslation()
This action gets the x and y translation component of the affine matrix.
Return
Libraries.Compute.Vector2: the position vector of the translation
Example
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 + "]"
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
Return
Libraries.Compute.Affine2: The affine as the identy matrix
Example
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|"
Invert()
Example
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|"
IsIdentity()
This action determines whether this affine matrix is the identity matrix.
Return
boolean: true if matrix is the identity matrix and false if it is not
Example
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
IsTranslation()
This action determines whether this affine matrix is a translation matrix.
Return
boolean: true if matrix is a translation matrix and false if it is not
Example
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
Multiply(Libraries.Compute.Affine2 affine)
This action multiplies this affine matrix with the passed affine matrix.
Parameters
- Libraries.Compute.Affine2: The affine matrix to multiply by
Return
Libraries.Compute.Affine2: The affine as the product
Example
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|"
Rotate(number degrees)
This action multiplies the affine matrix with the (counter-clockwise) rotation matrix.
Parameters
- number degrees: The angle in degrees
Return
Libraries.Compute.Affine2: The affine rotated
Example
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|"
RotateRadians(number radians)
This action multiplies the affine matrix with the (counter-clockwise) rotation matrix.
Parameters
- number radians: The angle in radians
Return
Libraries.Compute.Affine2: The affine rotated
Example
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|"
Scale(Libraries.Compute.Vector2 scale)
This action multiplies the affine matrix with the scale matrix.
Parameters
- Libraries.Compute.Vector2: The scale vector
Return
Libraries.Compute.Affine2: The affine scaled
Example
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|"
Scale(number scaleX, number scaleY)
This action multiplies the affine matrix with the scale matrix.
Parameters
- number scaleX: The scale in the x-direction
- number scaleY: The scale in the y-direction
Return
Libraries.Compute.Affine2: The affine scaled
Example
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|"
Set(Libraries.Compute.Matrix4 matrix)
This action sets the affine matrix to the 2D transformation components of the passed 4x4 matrix.
Parameters
- Libraries.Compute.Matrix4: The matrix to set as the affine matrix
Return
Libraries.Compute.Affine2: The affine after setting
Example
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|"
Set(Libraries.Compute.Matrix3 matrix)
This action sets the affine matrix to the passed 3x3 matrix.
Parameters
- Libraries.Compute.Matrix3: The matrix to set as the affine matrix
Return
Libraries.Compute.Affine2: The affine after setting
Example
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|"
Set(Libraries.Compute.Affine2 other)
This action sets the affine transformation to the passed affine transformation.
Parameters
- Libraries.Compute.Affine2: The affine matrix to use to set this affine matrix
Return
Libraries.Compute.Affine2: The affine after setting
Example
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|"
SetToProduct(Libraries.Compute.Affine2 left, Libraries.Compute.Affine2 right)
This action sets the affine matrix to the product of the passed affine matrices.
Parameters
- Libraries.Compute.Affine2: The left affine matrix
- Libraries.Compute.Affine2: The right affine matrix
Return
Libraries.Compute.Affine2: The affine after setting as the product
Example
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|"
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).
Parameters
- number cosine
- number sine
Return
Libraries.Compute.Affine2: The affine after setting
Example
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|"
SetToRotation(number degrees)
This action sets the affine matrix as the rotation matrix with the given rotation angle in degrees.
Parameters
- number degrees: The rotation angle in degrees
Return
Libraries.Compute.Affine2: The affine after setting
Example
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|"
SetToRotationRadians(number radians)
This action sets the affine matrix to the rotation matrix with the given rotation angle in radians.
Parameters
- number radians: The rotation angle in radians
Return
Libraries.Compute.Affine2: The affine after setting
Example
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|"
SetToScaling(number scaleX, number scaleY)
This action sets the affine matrix to the scaling matrix with the given x and y scales.
Parameters
- number scaleX: The amount to scale in the x-direction
- number scaleY: The amount to scale in the y-direction
Return
Libraries.Compute.Affine2: The affine after setting
Example
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|"
SetToScaling(Libraries.Compute.Vector2 scale)
This action sets the affine matrix to the scaling matrix with the given scaling vector.
Parameters
- Libraries.Compute.Vector2: The scaling vector
Return
Libraries.Compute.Affine2: The affine after setting
Example
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|"
SetToShearing(number shearX, number shearY)
This action sets the affine matrix to the shearing matrix with the passed shear in x and y.
Parameters
- number shearX: The shear in x
- number shearY: The shear in y
Return
Libraries.Compute.Affine2: The affine after setting
Example
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|"
SetToShearing(Libraries.Compute.Vector2 vector)
This action sets the affine matrix to the shearing matrix with the passed shear vector.
Parameters
- Libraries.Compute.Vector2: The shear vector
Return
Libraries.Compute.Affine2: The affine after setting
Example
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|"
SetToTranslation(Libraries.Compute.Vector2 vector)
This action sets the affine matrix to the translation matrix with the given vector.
Parameters
- Libraries.Compute.Vector2: The translation vector
Return
Libraries.Compute.Affine2: The affine after setting
Example
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|"
SetToTranslation(number x, number y)
This action sets the affine matrix to the translation matrix with the given x and y translations.
Parameters
- number x: The translation x-coordinate
- number y: The translation y-coordinate
Return
Libraries.Compute.Affine2: The affine after setting
Example
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|"
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.
Parameters
- number x: The translation in x
- number y: The translation in y
- number radians: The angle in radians to rotate
- number scaleX: The amount to scale in the x-direction
- number scaleY: The amount to scale in the y-direction
Return
Libraries.Compute.Affine2: The affine after setting
Example
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|"
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.
Parameters
- Libraries.Compute.Vector2: The translation vector
- number radians
- Libraries.Compute.Vector2: The scale vector
Return
Libraries.Compute.Affine2: The affine after setting
Example
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|"
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.
Parameters
- Libraries.Compute.Vector2: The translation vector
- number degrees: The angle in degrees to rotate
- Libraries.Compute.Vector2: The scale vector
Return
Libraries.Compute.Affine2: The affine after setting
Example
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|"
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.
Parameters
- number x: The translation in x
- number y: The translation in y
- number degrees: The angle in degrees to rotate
- number scaleX: The amount to scale in the x-direction
- number scaleY: The amount to scale in the y-direction
Return
Libraries.Compute.Affine2: The affine after setting
Example
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|"
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.
Parameters
- number x: The translation in x
- number y: The translation in y
- number scaleX: The scale in the x-direction
- number scaleY: The scale in the y-direction
Return
Libraries.Compute.Affine2: The affine after setting
Example
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|"
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.
Parameters
- Libraries.Compute.Vector2: The translation vector
- Libraries.Compute.Vector2: The scale vector
Return
Libraries.Compute.Affine2: The affine after setting
Example
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|"
Shear(number shearX, number shearY)
This action multiplies the affine matrix by the shear matrix.
Parameters
- number shearX: The shear in the x-direction
- number shearY: The shear in the y-direction
Return
Libraries.Compute.Affine2: The affine sheared
Example
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|"
Shear(Libraries.Compute.Vector2 shear)
This action multiplies the affine matrix by the shear matrix.
Parameters
- Libraries.Compute.Vector2: The shear vector
Return
Libraries.Compute.Affine2: The affine sheared
Example
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|"
Translate(number x, number y)
This action multiplies the affine matrix with the translation matrix.
Parameters
- number x: The x-component of the translation vector
- number y: The y-component of the translation vector
Return
Libraries.Compute.Affine2: The affine translated
Example
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|"
Translate(Libraries.Compute.Vector2 translate)
This action multiplies this affine matrix with the translation matrix.
Parameters
- Libraries.Compute.Vector2: The translation vector
Return
Libraries.Compute.Affine2: The affine translated
Example
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)
On this page
Variables TableAction Documentation- ApplyTo(Libraries.Compute.Vector2 point)
- Compare(Libraries.Language.Object object)
- Determinant()
- Equals(Libraries.Language.Object object)
- GetHashCode()
- GetTranslation()
- Identity()
- Invert()
- IsIdentity()
- IsTranslation()
- Multiply(Libraries.Compute.Affine2 affine)
- Rotate(number degrees)
- RotateRadians(number radians)
- Scale(Libraries.Compute.Vector2 scale)
- Scale(number scaleX, number scaleY)
- Set(Libraries.Compute.Matrix4 matrix)
- Set(Libraries.Compute.Matrix3 matrix)
- Set(Libraries.Compute.Affine2 other)
- SetToProduct(Libraries.Compute.Affine2 left, Libraries.Compute.Affine2 right)
- SetToRotation(number cosine, number sine)
- SetToRotation(number degrees)
- SetToRotationRadians(number radians)
- SetToScaling(number scaleX, number scaleY)
- SetToScaling(Libraries.Compute.Vector2 scale)
- SetToShearing(number shearX, number shearY)
- SetToShearing(Libraries.Compute.Vector2 vector)
- SetToTranslation(Libraries.Compute.Vector2 vector)
- SetToTranslation(number x, number y)
- SetToTranslationRotationRadiansScale(number x, number y, number radians, number scaleX, number scaleY)
- SetToTranslationRotationRadiansScale(Libraries.Compute.Vector2 translation, number radians, Libraries.Compute.Vector2 scale)
- SetToTranslationRotationScale(Libraries.Compute.Vector2 translation, number degrees, Libraries.Compute.Vector2 scale)
- SetToTranslationRotationScale(number x, number y, number degrees, number scaleX, number scaleY)
- SetToTranslationScale(number x, number y, number scaleX, number scaleY)
- SetToTranslationScale(Libraries.Compute.Vector2 translation, Libraries.Compute.Vector2 scale)
- Shear(number shearX, number shearY)
- Shear(Libraries.Compute.Vector2 shear)
- Translate(number x, number y)
- Translate(Libraries.Compute.Vector2 translate)