Class SRTValue2D

A structure that describes the scale, rotation and translation transformation in 2D space. Rotation is stored as angle in radians.

SRTValue2D constructors

Functions which can be used to create new instances of SRTValue2D.

Synopsis

Methods
SRTValue2D()

Default constructor

SRTValue2D()

Constructor with supplied scale, rotation and translation

SRTValue2D()

Default constructor.

Example
local srtvalue2d = SRTValue2D()
SRTValue2D(scale, rotationInRadians, translation)

Constructor with supplied scale, rotation and translation.

Example
local srtvalue2d = SRTValue2D(scale, rotationInRadians, translation)
Parameters
scale (Vector2)

The scale.

rotationInRadians (float)

The rotation angle in radians.

translation (Vector2)

The translation.

SRTValue2D methods

Methods of SRTValue2D class.

Synopsis

Methods
SRTValue2D:getScale()

Returns the scale

SRTValue2D:setScale()

Sets the scale

SRTValue2D:scale()

Multiplies the current scale with the provided scaling factor

SRTValue2D:uniformScale()

Multiplies the current scale with the provided uniform scaling factor

SRTValue2D:getScaleX()

Returns the scale along the x-axis

SRTValue2D:setScaleX()

Sets the scale along the x-axis

SRTValue2D:getScaleY()

Returns the scale along the y-axis

SRTValue2D:setScaleY()

Sets the scale along the y-axis

SRTValue2D:getRotation()

Returns the rotation

SRTValue2D:setRotation()

Sets the rotation

SRTValue2D:rotate()

Adds a rotation angle to the current rotation

SRTValue2D:getTranslation()

Returns the translation

SRTValue2D:setTranslation()

Sets the translation

SRTValue2D:translate()

Adds the provided translation to the current translation

SRTValue2D:getTranslationX()

Returns the translation along the x-axis

SRTValue2D:setTranslationX()

Sets the translation along the x-axis

SRTValue2D:getTranslationY()

Returns the translation along the y-axis

SRTValue2D:setTranslationY()

Sets the translation along the y-axis

SRTValue2D:toMatrix()

Converts the SRT representation to Matrix3x3 transform

SRTValue2D.createScale()

Creates a scale SRT

SRTValue2D.createRotation()

Creates a rotation SRT

SRTValue2D.createTranslation()

Creates a translation SRT

SRTValue2D.create()

Attempts to create an SRT object from a given transformation 3x3 matrix

SRTValue2D:translated()

Translates the SRT object

SRTValue2D:scaled()

Scales the SRT object

SRTValue2D:rotated()

Rotates the SRT object

SRTValue2D:getScale()

Returns the scale.

Return Values
(Vector2)

The scale.

SRTValue2D:setScale(value)

Sets the scale.

Parameters
value (Vector2)

The scale.

SRTValue2D:scale(factor)

Multiplies the current scale with the provided scaling factor.

Parameters
factor (Vector2)

The scaling factor.

SRTValue2D:uniformScale(factor)

Multiplies the current scale with the provided uniform scaling factor.

Parameters
factor (float)

The scaling factor.

SRTValue2D:getScaleX()

Returns the scale along the x-axis.

Return Values
(float)

The x component of the scale.

SRTValue2D:setScaleX(value)

Sets the scale along the x-axis.

Parameters
value (float)

The x component of the scale.

SRTValue2D:getScaleY()

Returns the scale along the y-axis.

Return Values
(float)

The y component of the scale.

SRTValue2D:setScaleY(value)

Sets the scale along the y-axis.

Parameters
value (float)

The y component of the scale.

SRTValue2D:getRotation()

Returns the rotation.

Return Values
(float)

The rotation angle in radians.

SRTValue2D:setRotation(rotationInRadians)

Sets the rotation.

Parameters
rotationInRadians (float)

The rotation angle in radians.

SRTValue2D:rotate(rotationInRadians)

Adds a rotation angle to the current rotation.

Parameters
rotationInRadians (float)

The rotation angle in radians.

SRTValue2D:getTranslation()

Returns the translation.

Return Values
(Vector2)

The translation.

SRTValue2D:setTranslation(value)

Sets the translation.

Parameters
value (Vector2)

The translation.

SRTValue2D:translate(translation)

Adds the provided translation to the current translation.

Parameters
translation (Vector2)

The translation term.

SRTValue2D:getTranslationX()

Returns the translation along the x-axis.

Return Values
(float)

The x component of the translation.

SRTValue2D:setTranslationX(value)

Sets the translation along the x-axis.

Parameters
value (float)

The x component of the translation.

SRTValue2D:getTranslationY()

Returns the translation along the y-axis.

Return Values
(float)

The y component of the translation.

SRTValue2D:setTranslationY(value)

Sets the translation along the y-axis.

Parameters
value (float)

The y component of the translation.

SRTValue2D:toMatrix()

Converts the SRT representation to Matrix3x3 transform.

Return Values
(Matrix3x3)

A matrix representation of the SRT object.

SRTValue2D.createScale(scale)

Creates a scale SRT.

Parameters
scale (Vector2)

The scale.

Return Values
(SRTValue2D)

An SRT object with scale.

SRTValue2D.createRotation(rotationInRadians)

Creates a rotation SRT.

Parameters
rotationInRadians (float)

The rotation angle in radians.

Return Values
(SRTValue2D)

An SRT object with rotation.

SRTValue2D.createTranslation(translation)

Creates a translation SRT.

Parameters
translation (Vector2)

The translation.

Return Values
(SRTValue2D)

An SRT object with translation.

SRTValue2D.create(matrix)

Attempts to create an SRT object from a given transformation 3x3 matrix. Note that you can decompose a matrix into SRT only if its column vectors are orthogonal to each other.

Parameters
matrix (Matrix3x3)

The transformation 3x3 matrix.

Return Values
(SRTValue2D or nil)

If the matrix is decomposable, returns an SRTValue3D object, otherwise nil.

SRTValue2D:translated(translation)

Translates the SRT object.

Parameters
translation (Vector2)

The translation term.

Return Values
(SRTValue2D)

A new SRT object with the translation applied.

SRTValue2D:scaled(scale)

Scales the SRT object.

Parameters
scale (Vector2)

The scaling factor.

Return Values
(SRTValue2D)

A new SRT object with the scale applied.

SRTValue2D:rotated(rotationInRadians)

Rotates the SRT object.

Parameters
rotationInRadians (float)

The rotation angle in degrees.

Return Values
(SRTValue2D)

A new SRT object with the rotation applied.

SRTValue2D functions

SRTValue2D specific standalone functions, which are not a part of the SRTValue2D class.