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
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)
.
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)
.
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
staticinlineop_Equality(left:Transform2D, right:Transform2D):Bool
Operator overload for godot.Transform2D
== godot.Transform2D
.
staticinlineop_Inequality(left:Transform2D, right:Transform2D):Bool
Operator overload for godot.Transform2D
!= godot.Transform2D
.
staticinlineop_Multiply(left:Transform2D, right:Transform2D):Transform2D
staticinlineop_Multiply(array:NativeArray<Vector2>, transform:Transform2D):NativeArray<Vector2>
staticinlineop_Multiply(transform:Transform2D, array:NativeArray<Vector2>):NativeArray<Vector2>
staticinlineop_Multiply(rect:Rect2, transform:Transform2D):Rect2
staticinlineop_Multiply(transform:Transform2D, rect:Rect2):Rect2
staticinlineop_Multiply(vector:Vector2, transform:Transform2D):Vector2
staticinlineop_Multiply(transform:Transform2D, vector:Vector2):Vector2
Operator overload for godot.Transform2D
* godot.Transform2D
.
Constructor
new(xAxis:Vector2, yAxis:Vector2, originPos:Vector2)
new(rotation:Single, origin:Vector2)
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
origin:Vector2
The origin vector (column 2, the third column). Equivalent to array index [2]
.
The origin vector represents translation.
rotation:Single
The rotation of this transformation matrix.
Value: Getting is equivalent to calling godot.Mathf.atan2
with the values of godot.Transform2D.x
.
Methods
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:
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:
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:
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.
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.
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.
orthonormalized():Transform2D
Returns the transform with the basis orthogonal (90 degrees), and normalized axis vectors (scale of 1 or -1).
Returns:
The orthonormalized transform.
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.
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.
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.
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: