2×3 matrix (2 rows, 3 columns) used for 2D linear transformations. It can represent transformations such as translation, rotation, or scaling. It consists of a three godot.Vector2 values: x, y, and the origin.

For more information, read this documentation article: https://docs.godotengine.org/en/3.4/tutorials/math/matrices_and_transforms.html

Static variables

@:native("FlipX")staticread onlyFLIP_X:Transform2D

The transform that will flip something along the X axis.

Value: Equivalent to new Transform2D(Vector2.Left, Vector2.Down, Vector2.Zero).

@:native("FlipY")staticread onlyFLIP_Y:Transform2D

The transform that will flip something along the Y axis.

Value: Equivalent to new Transform2D(Vector2.Right, Vector2.Up, Vector2.Zero).

@:native("Identity")staticread onlyIDENTITY:Transform2D

The identity transform, with no translation, rotation, or scaling applied. This is used as a replacement for Transform2D() in GDScript. Do not use new Transform2D() with no arguments in C#, because it sets all values to zero.

Value: Equivalent to new Transform2D(Vector2.Right, Vector2.Down, Vector2.Zero).

Static methods

@:op(A == B)staticinlineop_Equality(left:Transform2D, right:Transform2D):Bool

Operator overload for godot.Transform2D == godot.Transform2D.

@:op(A != B)staticinlineop_Inequality(left:Transform2D, right:Transform2D):Bool

Operator overload for godot.Transform2D != godot.Transform2D.

@:op(A * B)staticinlineop_Multiply(left:Transform2D, right:Transform2D):Transform2D

@:op(A * B)staticinlineop_Multiply(array:NativeArray<Vector2>, transform:Transform2D):NativeArray<Vector2>

@:op(A * B)staticinlineop_Multiply(transform:Transform2D, array:NativeArray<Vector2>):NativeArray<Vector2>

@:op(A * B)staticinlineop_Multiply(rect:Rect2, transform:Transform2D):Rect2

@:op(A * B)staticinlineop_Multiply(transform:Transform2D, rect:Rect2):Rect2

@:op(A * B)staticinlineop_Multiply(vector:Vector2, transform:Transform2D):Vector2

@:op(A * B)staticinlineop_Multiply(transform:Transform2D, vector:Vector2):Vector2

Operator overload for godot.Transform2D * godot.Transform2D.

Constructor

@:native("new")new(xAxis:Vector2, yAxis:Vector2, originPos:Vector2)

@:native("new")new(rotation:Single, origin:Vector2)

@:native("new")new(xx:Single, xy:Single, yx:Single, yy:Single, ox:Single, oy:Single)

Constructs a transformation matrix from 3 vectors (matrix columns).

Parameters:

xAxis

The X vector, or column index 0.

yAxis

The Y vector, or column index 1.

originPos

The origin vector, or column index 2.

Variables

@:native("origin")origin:Vector2

The origin vector (column 2, the third column). Equivalent to array index [2]. The origin vector represents translation.

@:native("Rotation")rotation:Single

The rotation of this transformation matrix.

Value: Getting is equivalent to calling godot.Mathf.atan2 with the values of godot.Transform2D.x.

@:native("Scale")scale:Vector2

The scale of this transformation matrix.

Value: Equivalent to the lengths of each column vector, but Y is negative if the determinant is negative.

@:native("x")x:Vector2

The basis matrix's X vector (column 0). Equivalent to array index [0].

Value:

@:native("y")y:Vector2

The basis matrix's Y vector (column 1). Equivalent to array index [1].

Methods

@:native("AffineInverse")affineInverse():Transform2D

Returns the inverse of the transform, under the assumption that the transformation is composed of rotation, scaling, and translation.

Returns:

The inverse transformation matrix.

See also:

@:native("BasisXform")basisXform(v:Vector2):Vector2

Returns a vector transformed (multiplied) by the basis matrix. This method does not account for translation (the godot.Transform2D.origin vector).

Parameters:

v

A vector to transform.

Returns:

The transformed vector.

See also:

@:native("BasisXformInv")basisXformInv(v:Vector2):Vector2

Returns a vector transformed (multiplied) by the inverse basis matrix. This method does not account for translation (the godot.Transform2D.origin vector).

Note: This results in a multiplication by the inverse of the basis matrix only if it represents a rotation-reflection.

Parameters:

v

A vector to inversely transform.

Returns:

The inversely transformed vector.

See also:

@:native("InterpolateWith")interpolateWith(transform:Transform2D, weight:Single):Transform2D

Interpolates this transform to the other transform by weight.

Parameters:

transform

The other transform.

weight

A value on the range of 0.0 to 1.0, representing the amount of interpolation.

Returns:

The interpolated transform.

@:native("Inverse")inverse():Transform2D

Returns the inverse of the transform, under the assumption that the transformation is composed of rotation and translation (no scaling, use godot.Transform2D.affineInverse for transforms with scaling).

Returns:

The inverse matrix.

@:native("IsEqualApprox")isEqualApprox(other:Transform2D):Bool

Returns true if this transform and other are approximately equal, by running godot.Vector2.isEqualApprox on each component.

Parameters:

other

The other transform to compare.

Returns:

Whether or not the matrices are approximately equal.

@:native("Orthonormalized")orthonormalized():Transform2D

Returns the transform with the basis orthogonal (90 degrees), and normalized axis vectors (scale of 1 or -1).

Returns:

The orthonormalized transform.

@:native("Rotated")rotated(phi:Single):Transform2D

Rotates the transform by phi (in radians), using matrix multiplication.

Parameters:

phi

The angle to rotate, in radians.

Returns:

The rotated transformation matrix.

@:native("Scaled")scaled(scale:Vector2):Transform2D

Scales the transform by the given scaling factor, using matrix multiplication.

Parameters:

scale

The scale to introduce.

Returns:

The scaled transformation matrix.

@:native("ToString")toString():String

@:native("ToString")ToString(format:String):String

Converts this godot.Transform2D to a string.

Returns:

A string representation of this transform.

@:native("Translated")translated(offset:Vector2):Transform2D

Translates the transform by the given offset, relative to the transform's basis vectors.

Unlike godot.Transform2D.rotated and godot.Transform2D.scaled, this does not use matrix multiplication.

Parameters:

offset

The offset to translate by.

Returns:

The translated matrix.

@:native("Xform")xform(v:Vector2):Vector2

Returns a vector transformed (multiplied) by this transformation matrix.

Parameters:

v

A vector to transform.

Returns:

The transformed vector.

See also:

@:native("XformInv")xformInv(v:Vector2):Vector2

Returns a vector transformed (multiplied) by the inverse transformation matrix.

Parameters:

v

A vector to inversely transform.

Returns:

The inversely transformed vector.

See also: