|
@@ -17,10 +17,14 @@ A 2×3 matrix representing a 2D transformation.
|
|
|
Description
|
|
|
-----------
|
|
|
|
|
|
-A 2×3 matrix (2 rows, 3 columns) used for 2D linear transformations. It can represent transformations such as translation, rotation, and scaling. It consists of three :ref:`Vector2<class_Vector2>` values: :ref:`x<class_Transform2D_property_x>`, :ref:`y<class_Transform2D_property_y>`, and the :ref:`origin<class_Transform2D_property_origin>`.
|
|
|
+The **Transform2D** built-in :ref:`Variant<class_Variant>` type is a 2×3 `matrix <https://en.wikipedia.org/wiki/Matrix_(mathematics)>`__ representing a transformation in 2D space. It contains three :ref:`Vector2<class_Vector2>` values: :ref:`x<class_Transform2D_property_x>`, :ref:`y<class_Transform2D_property_y>`, and :ref:`origin<class_Transform2D_property_origin>`. Together, they can represent translation, rotation, scale, and skew.
|
|
|
+
|
|
|
+The :ref:`x<class_Transform2D_property_x>` and :ref:`y<class_Transform2D_property_y>` axes form a 2×2 matrix, known as the transform's **basis**. The length of each axis (:ref:`Vector2.length<class_Vector2_method_length>`) influences the transform's scale, while the direction of all axes influence the rotation. Usually, both axes are perpendicular to one another. However, when you rotate one axis individually, the transform becomes skewed. Applying a skewed transform to a 2D sprite will make the sprite appear distorted.
|
|
|
|
|
|
For a general introduction, see the :doc:`Matrices and transforms <../tutorials/math/matrices_and_transforms>` tutorial.
|
|
|
|
|
|
+\ **Note:** Unlike :ref:`Transform3D<class_Transform3D>`, there is no 2D equivalent to the :ref:`Basis<class_Basis>` type. All mentions of "basis" refer to the :ref:`x<class_Transform2D_property_x>` and :ref:`y<class_Transform2D_property_y>` components of **Transform2D**.
|
|
|
+
|
|
|
.. note::
|
|
|
|
|
|
There are notable differences when using this API with C#. See :ref:`doc_c_sharp_differences` for more information.
|
|
@@ -173,7 +177,24 @@ Constants
|
|
|
|
|
|
**IDENTITY** = ``Transform2D(1, 0, 0, 1, 0, 0)`` :ref:`🔗<class_Transform2D_constant_IDENTITY>`
|
|
|
|
|
|
-The identity **Transform2D** with no translation, rotation or scaling applied. When applied to other data structures, :ref:`IDENTITY<class_Transform2D_constant_IDENTITY>` performs no transformation.
|
|
|
+The identity **Transform2D**. A transform with no translation, no rotation, and its scale being ``1``. When multiplied by another :ref:`Variant<class_Variant>` such as :ref:`Rect2<class_Rect2>` or another **Transform2D**, no transformation occurs. This means that:
|
|
|
+
|
|
|
+- The :ref:`x<class_Transform2D_property_x>` points right (:ref:`Vector2.RIGHT<class_Vector2_constant_RIGHT>`);
|
|
|
+
|
|
|
+- The :ref:`y<class_Transform2D_property_y>` points up (:ref:`Vector2.UP<class_Vector2_constant_UP>`).
|
|
|
+
|
|
|
+::
|
|
|
+
|
|
|
+ var transform = Transform2D.IDENTITY
|
|
|
+ print("| X | Y | Origin")
|
|
|
+ print("| %s | %s | %s" % [transform.x.x, transform.y.x, transform.origin.x])
|
|
|
+ print("| %s | %s | %s" % [transform.x.y, transform.y.y, transform.origin.y])
|
|
|
+ # Prints:
|
|
|
+ # | X | Y | Origin
|
|
|
+ # | 1 | 0 | 0
|
|
|
+ # | 0 | 1 | 0
|
|
|
+
|
|
|
+This is identical to creating :ref:`Transform2D<class_Transform2D_constructor_Transform2D>` without any parameters. This constant can be used to make your code clearer, and for consistency with C#.
|
|
|
|
|
|
.. _class_Transform2D_constant_FLIP_X:
|
|
|
|
|
@@ -181,7 +202,9 @@ The identity **Transform2D** with no translation, rotation or scaling applied. W
|
|
|
|
|
|
**FLIP_X** = ``Transform2D(-1, 0, 0, 1, 0, 0)`` :ref:`🔗<class_Transform2D_constant_FLIP_X>`
|
|
|
|
|
|
-The **Transform2D** that will flip something along the X axis.
|
|
|
+When any transform is multiplied by :ref:`FLIP_X<class_Transform2D_constant_FLIP_X>`, it negates all components of the :ref:`x<class_Transform2D_property_x>` axis (the X column).
|
|
|
+
|
|
|
+When :ref:`FLIP_X<class_Transform2D_constant_FLIP_X>` is multiplied by any basis, it negates the :ref:`Vector2.x<class_Vector2_property_x>` component of all axes (the X row).
|
|
|
|
|
|
.. _class_Transform2D_constant_FLIP_Y:
|
|
|
|
|
@@ -189,7 +212,9 @@ The **Transform2D** that will flip something along the X axis.
|
|
|
|
|
|
**FLIP_Y** = ``Transform2D(1, 0, 0, -1, 0, 0)`` :ref:`🔗<class_Transform2D_constant_FLIP_Y>`
|
|
|
|
|
|
-The **Transform2D** that will flip something along the Y axis.
|
|
|
+When any transform is multiplied by :ref:`FLIP_Y<class_Transform2D_constant_FLIP_Y>`, it negates all components of the :ref:`y<class_Transform2D_property_y>` axis (the Y column).
|
|
|
+
|
|
|
+When :ref:`FLIP_Y<class_Transform2D_constant_FLIP_Y>` is multiplied by any basis, it negates the :ref:`Vector2.y<class_Vector2_property_y>` component of all axes (the Y row).
|
|
|
|
|
|
.. rst-class:: classref-section-separator
|
|
|
|
|
@@ -206,7 +231,7 @@ Property Descriptions
|
|
|
|
|
|
:ref:`Vector2<class_Vector2>` **origin** = ``Vector2(0, 0)`` :ref:`🔗<class_Transform2D_property_origin>`
|
|
|
|
|
|
-The origin vector (column 2, the third column). Equivalent to array index ``2``. The origin vector represents translation.
|
|
|
+The translation offset of this transform, and the column ``2`` of the matrix. In 2D space, this can be seen as the position.
|
|
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
|
@@ -218,7 +243,9 @@ The origin vector (column 2, the third column). Equivalent to array index ``2``.
|
|
|
|
|
|
:ref:`Vector2<class_Vector2>` **x** = ``Vector2(1, 0)`` :ref:`🔗<class_Transform2D_property_x>`
|
|
|
|
|
|
-The basis matrix's X vector (column 0). Equivalent to array index ``0``.
|
|
|
+The transform basis's X axis, and the column ``0`` of the matrix. Combined with :ref:`y<class_Transform2D_property_y>`, this represents the transform's rotation, scale, and skew.
|
|
|
+
|
|
|
+On the identity transform, this vector points right (:ref:`Vector2.RIGHT<class_Vector2_constant_RIGHT>`).
|
|
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
|
@@ -230,7 +257,9 @@ The basis matrix's X vector (column 0). Equivalent to array index ``0``.
|
|
|
|
|
|
:ref:`Vector2<class_Vector2>` **y** = ``Vector2(0, 1)`` :ref:`🔗<class_Transform2D_property_y>`
|
|
|
|
|
|
-The basis matrix's Y vector (column 1). Equivalent to array index ``1``.
|
|
|
+The transform basis's Y axis, and the column ``1`` of the matrix. Combined with :ref:`x<class_Transform2D_property_x>`, this represents the transform's rotation, scale, and skew.
|
|
|
+
|
|
|
+On the identity transform, this vector points up (:ref:`Vector2.UP<class_Vector2_constant_UP>`).
|
|
|
|
|
|
.. rst-class:: classref-section-separator
|
|
|
|
|
@@ -247,7 +276,7 @@ Constructor Descriptions
|
|
|
|
|
|
:ref:`Transform2D<class_Transform2D>` **Transform2D**\ (\ ) :ref:`🔗<class_Transform2D_constructor_Transform2D>`
|
|
|
|
|
|
-Constructs a default-initialized **Transform2D** set to :ref:`IDENTITY<class_Transform2D_constant_IDENTITY>`.
|
|
|
+Constructs a **Transform2D** identical to :ref:`IDENTITY<class_Transform2D_constant_IDENTITY>`.
|
|
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
|
@@ -267,7 +296,7 @@ Constructs a **Transform2D** as a copy of the given **Transform2D**.
|
|
|
|
|
|
:ref:`Transform2D<class_Transform2D>` **Transform2D**\ (\ rotation\: :ref:`float<class_float>`, position\: :ref:`Vector2<class_Vector2>`\ )
|
|
|
|
|
|
-Constructs the transform from a given angle (in radians) and position.
|
|
|
+Constructs a **Transform2D** from a given angle (in radians) and position.
|
|
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
|
@@ -277,7 +306,7 @@ Constructs the transform from a given angle (in radians) and position.
|
|
|
|
|
|
:ref:`Transform2D<class_Transform2D>` **Transform2D**\ (\ rotation\: :ref:`float<class_float>`, scale\: :ref:`Vector2<class_Vector2>`, skew\: :ref:`float<class_float>`, position\: :ref:`Vector2<class_Vector2>`\ )
|
|
|
|
|
|
-Constructs the transform from a given angle (in radians), scale, skew (in radians) and position.
|
|
|
+Constructs a **Transform2D** from a given angle (in radians), scale, skew (in radians), and position.
|
|
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
|
@@ -287,7 +316,7 @@ Constructs the transform from a given angle (in radians), scale, skew (in radian
|
|
|
|
|
|
:ref:`Transform2D<class_Transform2D>` **Transform2D**\ (\ x_axis\: :ref:`Vector2<class_Vector2>`, y_axis\: :ref:`Vector2<class_Vector2>`, origin\: :ref:`Vector2<class_Vector2>`\ )
|
|
|
|
|
|
-Constructs the transform from 3 :ref:`Vector2<class_Vector2>` values representing :ref:`x<class_Transform2D_property_x>`, :ref:`y<class_Transform2D_property_y>`, and the :ref:`origin<class_Transform2D_property_origin>` (the three column vectors).
|
|
|
+Constructs a **Transform2D** from 3 :ref:`Vector2<class_Vector2>` values representing :ref:`x<class_Transform2D_property_x>`, :ref:`y<class_Transform2D_property_y>`, and the :ref:`origin<class_Transform2D_property_origin>` (the three matrix columns).
|
|
|
|
|
|
.. rst-class:: classref-section-separator
|
|
|
|
|
@@ -304,7 +333,9 @@ Method Descriptions
|
|
|
|
|
|
:ref:`Transform2D<class_Transform2D>` **affine_inverse**\ (\ ) |const| :ref:`🔗<class_Transform2D_method_affine_inverse>`
|
|
|
|
|
|
-Returns the inverse of the transform, under the assumption that the basis is invertible (must have non-zero determinant).
|
|
|
+Returns the inverted version of this transform. Unlike :ref:`inverse<class_Transform2D_method_inverse>`, this method works with almost any basis, including non-uniform ones, but is slower. See also :ref:`inverse<class_Transform2D_method_inverse>`.
|
|
|
+
|
|
|
+\ **Note:** For this method to return correctly, the transform's basis needs to have a determinant that is not exactly ``0`` (see :ref:`determinant<class_Transform2D_method_determinant>`).
|
|
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
|
@@ -316,9 +347,7 @@ Returns the inverse of the transform, under the assumption that the basis is inv
|
|
|
|
|
|
:ref:`Vector2<class_Vector2>` **basis_xform**\ (\ v\: :ref:`Vector2<class_Vector2>`\ ) |const| :ref:`🔗<class_Transform2D_method_basis_xform>`
|
|
|
|
|
|
-Returns a vector transformed (multiplied) by the basis matrix.
|
|
|
-
|
|
|
-This method does not account for translation (the :ref:`origin<class_Transform2D_property_origin>` vector).
|
|
|
+Returns a copy of the ``v`` vector, transformed (multiplied) by the transform basis's matrix. Unlike the multiplication operator (``*``), this method ignores the :ref:`origin<class_Transform2D_property_origin>`.
|
|
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
|
@@ -330,13 +359,9 @@ This method does not account for translation (the :ref:`origin<class_Transform2D
|
|
|
|
|
|
:ref:`Vector2<class_Vector2>` **basis_xform_inv**\ (\ v\: :ref:`Vector2<class_Vector2>`\ ) |const| :ref:`🔗<class_Transform2D_method_basis_xform_inv>`
|
|
|
|
|
|
-Returns a vector transformed (multiplied) by the inverse basis matrix, under the assumption that the basis is orthonormal (i.e. rotation/reflection is fine, scaling/skew is not).
|
|
|
-
|
|
|
-This method does not account for translation (the :ref:`origin<class_Transform2D_property_origin>` vector).
|
|
|
+Returns a copy of the ``v`` vector, transformed (multiplied) by the inverse transform basis's matrix (see :ref:`inverse<class_Transform2D_method_inverse>`). This method ignores the :ref:`origin<class_Transform2D_property_origin>`.
|
|
|
|
|
|
-\ ``transform.basis_xform_inv(vector)`` is equivalent to ``transform.inverse().basis_xform(vector)``. See :ref:`inverse<class_Transform2D_method_inverse>`.
|
|
|
-
|
|
|
-For non-orthonormal transforms (e.g. with scaling) ``transform.affine_inverse().basis_xform(vector)`` can be used instead. See :ref:`affine_inverse<class_Transform2D_method_affine_inverse>`.
|
|
|
+\ **Note:** This method assumes that this transform's basis is *orthonormal* (see :ref:`orthonormalized<class_Transform2D_method_orthonormalized>`). If the basis is not orthonormal, ``transform.affine_inverse().basis_xform(vector)`` should be used instead (see :ref:`affine_inverse<class_Transform2D_method_affine_inverse>`).
|
|
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
|
@@ -348,9 +373,13 @@ For non-orthonormal transforms (e.g. with scaling) ``transform.affine_inverse().
|
|
|
|
|
|
:ref:`float<class_float>` **determinant**\ (\ ) |const| :ref:`🔗<class_Transform2D_method_determinant>`
|
|
|
|
|
|
-Returns the determinant of the basis matrix. If the basis is uniformly scaled, then its determinant equals the square of the scale factor.
|
|
|
+Returns the `determinant <https://en.wikipedia.org/wiki/Determinant>`__ of this transform basis's matrix. For advanced math, this number can be used to determine a few attributes:
|
|
|
+
|
|
|
+- If the determinant is exactly ``0``, the basis is not invertible (see :ref:`inverse<class_Transform2D_method_inverse>`).
|
|
|
|
|
|
-A negative determinant means the basis was flipped, so one part of the scale is negative. A zero determinant means the basis isn't invertible, and is usually considered invalid.
|
|
|
+- If the determinant is a negative number, the basis represents a negative scale.
|
|
|
+
|
|
|
+\ **Note:** If the basis's scale is the same for every axis, its determinant is always that scale by the power of 2.
|
|
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
|
@@ -362,7 +391,7 @@ A negative determinant means the basis was flipped, so one part of the scale is
|
|
|
|
|
|
:ref:`Vector2<class_Vector2>` **get_origin**\ (\ ) |const| :ref:`🔗<class_Transform2D_method_get_origin>`
|
|
|
|
|
|
-Returns the transform's origin (translation).
|
|
|
+Returns this transform's translation. Equivalent to :ref:`origin<class_Transform2D_property_origin>`.
|
|
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
|
@@ -374,7 +403,7 @@ Returns the transform's origin (translation).
|
|
|
|
|
|
:ref:`float<class_float>` **get_rotation**\ (\ ) |const| :ref:`🔗<class_Transform2D_method_get_rotation>`
|
|
|
|
|
|
-Returns the transform's rotation (in radians).
|
|
|
+Returns this transform's rotation (in radians). This is equivalent to :ref:`x<class_Transform2D_property_x>`'s angle (see :ref:`Vector2.angle<class_Vector2_method_angle>`).
|
|
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
|
@@ -386,7 +415,38 @@ Returns the transform's rotation (in radians).
|
|
|
|
|
|
:ref:`Vector2<class_Vector2>` **get_scale**\ (\ ) |const| :ref:`🔗<class_Transform2D_method_get_scale>`
|
|
|
|
|
|
-Returns the scale.
|
|
|
+Returns the length of both :ref:`x<class_Transform2D_property_x>` and :ref:`y<class_Transform2D_property_y>`, as a :ref:`Vector2<class_Vector2>`. If this transform's basis is not skewed, this value is the scaling factor. It is not affected by rotation.
|
|
|
+
|
|
|
+
|
|
|
+.. tabs::
|
|
|
+
|
|
|
+ .. code-tab:: gdscript
|
|
|
+
|
|
|
+ var my_transform = Transform2D(
|
|
|
+ Vector2(2, 0),
|
|
|
+ Vector2(0, 4),
|
|
|
+ Vector2(0, 0)
|
|
|
+ )
|
|
|
+ # Rotating the Transform2D in any way preserves its scale.
|
|
|
+ my_transform = my_transform.rotated(TAU / 2)
|
|
|
+
|
|
|
+ print(my_transform.get_scale()) # Prints (2, 4).
|
|
|
+
|
|
|
+ .. code-tab:: csharp
|
|
|
+
|
|
|
+ var myTransform = new Transform2D(
|
|
|
+ Vector3(2.0f, 0.0f),
|
|
|
+ Vector3(0.0f, 4.0f),
|
|
|
+ Vector3(0.0f, 0.0f)
|
|
|
+ );
|
|
|
+ // Rotating the Transform2D in any way preserves its scale.
|
|
|
+ myTransform = myTransform.Rotated(Mathf.Tau / 2.0f);
|
|
|
+
|
|
|
+ GD.Print(myTransform.GetScale()); // Prints (2, 4, 8).
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+\ **Note:** If the value returned by :ref:`determinant<class_Transform2D_method_determinant>` is negative, the scale is also negative.
|
|
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
|
@@ -398,7 +458,7 @@ Returns the scale.
|
|
|
|
|
|
:ref:`float<class_float>` **get_skew**\ (\ ) |const| :ref:`🔗<class_Transform2D_method_get_skew>`
|
|
|
|
|
|
-Returns the transform's skew (in radians).
|
|
|
+Returns this transform's skew (in radians).
|
|
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
|
@@ -410,7 +470,9 @@ Returns the transform's skew (in radians).
|
|
|
|
|
|
:ref:`Transform2D<class_Transform2D>` **interpolate_with**\ (\ xform\: :ref:`Transform2D<class_Transform2D>`, weight\: :ref:`float<class_float>`\ ) |const| :ref:`🔗<class_Transform2D_method_interpolate_with>`
|
|
|
|
|
|
-Returns a transform interpolated between this transform and another by a given ``weight`` (on the range of 0.0 to 1.0).
|
|
|
+Returns the result of the linear interpolation between this transform and ``xform`` by the given ``weight``.
|
|
|
+
|
|
|
+The ``weight`` should be between ``0.0`` and ``1.0`` (inclusive). Values outside this range are allowed and can be used to perform *extrapolation* instead.
|
|
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
|
@@ -422,7 +484,9 @@ Returns a transform interpolated between this transform and another by a given `
|
|
|
|
|
|
:ref:`Transform2D<class_Transform2D>` **inverse**\ (\ ) |const| :ref:`🔗<class_Transform2D_method_inverse>`
|
|
|
|
|
|
-Returns the inverse of the transform, under the assumption that the transformation basis is orthonormal (i.e. rotation/reflection is fine, scaling/skew is not). Use :ref:`affine_inverse<class_Transform2D_method_affine_inverse>` for non-orthonormal transforms (e.g. with scaling).
|
|
|
+Returns the `inverted version of this transform <https://en.wikipedia.org/wiki/Invertible_matrix>`__.
|
|
|
+
|
|
|
+\ **Note:** For this method to return correctly, the transform's basis needs to be *orthonormal* (see :ref:`orthonormalized<class_Transform2D_method_orthonormalized>`). That means, the basis should only represent a rotation. If it does not, use :ref:`affine_inverse<class_Transform2D_method_affine_inverse>` instead.
|
|
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
|
@@ -434,7 +498,7 @@ Returns the inverse of the transform, under the assumption that the transformati
|
|
|
|
|
|
:ref:`bool<class_bool>` **is_conformal**\ (\ ) |const| :ref:`🔗<class_Transform2D_method_is_conformal>`
|
|
|
|
|
|
-Returns ``true`` if the transform's basis is conformal, meaning it preserves angles and distance ratios, and may only be composed of rotation and uniform scale. Returns ``false`` if the transform's basis has non-uniform scale or shear/skew. This can be used to validate if the transform is non-distorted, which is important for physics and other use cases.
|
|
|
+Returns ``true`` if this transform's basis is conformal. A conformal basis is both *orthogonal* (the axes are perpendicular to each other) and *uniform* (the axes share the same length). This method can be especially useful during physics calculations.
|
|
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
|
@@ -470,9 +534,7 @@ Returns ``true`` if this transform is finite, by calling :ref:`@GlobalScope.is_f
|
|
|
|
|
|
:ref:`Transform2D<class_Transform2D>` **looking_at**\ (\ target\: :ref:`Vector2<class_Vector2>` = Vector2(0, 0)\ ) |const| :ref:`🔗<class_Transform2D_method_looking_at>`
|
|
|
|
|
|
-Returns a copy of the transform rotated such that the rotated X-axis points towards the ``target`` position.
|
|
|
-
|
|
|
-Operations take place in global space.
|
|
|
+Returns a copy of the transform rotated such that the rotated X-axis points towards the ``target`` position, in global space.
|
|
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
|
@@ -484,7 +546,7 @@ Operations take place in global space.
|
|
|
|
|
|
:ref:`Transform2D<class_Transform2D>` **orthonormalized**\ (\ ) |const| :ref:`🔗<class_Transform2D_method_orthonormalized>`
|
|
|
|
|
|
-Returns the transform with the basis orthogonal (90 degrees), and normalized axis vectors (scale of 1 or -1).
|
|
|
+Returns a copy of this transform with its basis orthonormalized. An orthonormal basis is both *orthogonal* (the axes are perpendicular to each other) and *normalized* (the axes have a length of ``1``), which also means it can only represent rotation.
|
|
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
|
@@ -597,7 +659,7 @@ Operator Descriptions
|
|
|
|
|
|
:ref:`bool<class_bool>` **operator !=**\ (\ right\: :ref:`Transform2D<class_Transform2D>`\ ) :ref:`🔗<class_Transform2D_operator_neq_Transform2D>`
|
|
|
|
|
|
-Returns ``true`` if the transforms are not equal.
|
|
|
+Returns ``true`` if the components of both transforms are not equal.
|
|
|
|
|
|
\ **Note:** Due to floating-point precision errors, consider using :ref:`is_equal_approx<class_Transform2D_method_is_equal_approx>` instead, which is more reliable.
|
|
|
|
|
@@ -611,7 +673,9 @@ Returns ``true`` if the transforms are not equal.
|
|
|
|
|
|
:ref:`PackedVector2Array<class_PackedVector2Array>` **operator ***\ (\ right\: :ref:`PackedVector2Array<class_PackedVector2Array>`\ ) :ref:`🔗<class_Transform2D_operator_mul_PackedVector2Array>`
|
|
|
|
|
|
-Transforms (multiplies) each element of the :ref:`Vector2<class_Vector2>` array by the given **Transform2D** matrix.
|
|
|
+Transforms (multiplies) every :ref:`Vector2<class_Vector2>` element of the given :ref:`PackedVector2Array<class_PackedVector2Array>` by this transformation matrix.
|
|
|
+
|
|
|
+On larger arrays, this operation is much faster than transforming each :ref:`Vector2<class_Vector2>` individually.
|
|
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
|
@@ -623,7 +687,7 @@ Transforms (multiplies) each element of the :ref:`Vector2<class_Vector2>` array
|
|
|
|
|
|
:ref:`Rect2<class_Rect2>` **operator ***\ (\ right\: :ref:`Rect2<class_Rect2>`\ ) :ref:`🔗<class_Transform2D_operator_mul_Rect2>`
|
|
|
|
|
|
-Transforms (multiplies) the :ref:`Rect2<class_Rect2>` by the given **Transform2D** matrix.
|
|
|
+Transforms (multiplies) the :ref:`Rect2<class_Rect2>` by this transformation matrix.
|
|
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
|
@@ -635,7 +699,17 @@ Transforms (multiplies) the :ref:`Rect2<class_Rect2>` by the given **Transform2D
|
|
|
|
|
|
:ref:`Transform2D<class_Transform2D>` **operator ***\ (\ right\: :ref:`Transform2D<class_Transform2D>`\ ) :ref:`🔗<class_Transform2D_operator_mul_Transform2D>`
|
|
|
|
|
|
-Composes these two transformation matrices by multiplying them together. This has the effect of transforming the second transform (the child) by the first transform (the parent).
|
|
|
+Transforms (multiplies) this transform by the ``right`` transform.
|
|
|
+
|
|
|
+This is the operation performed between parent and child :ref:`CanvasItem<class_CanvasItem>` nodes.
|
|
|
+
|
|
|
+\ **Note:** If you need to only modify one attribute of this transform, consider using one of the following methods, instead:
|
|
|
+
|
|
|
+- For translation, see :ref:`translated<class_Transform2D_method_translated>` or :ref:`translated_local<class_Transform2D_method_translated_local>`.
|
|
|
+
|
|
|
+- For rotation, see :ref:`rotated<class_Transform2D_method_rotated>` or :ref:`rotated_local<class_Transform2D_method_rotated_local>`.
|
|
|
+
|
|
|
+- For scale, see :ref:`scaled<class_Transform2D_method_scaled>` or :ref:`scaled_local<class_Transform2D_method_scaled_local>`.
|
|
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
|
@@ -647,7 +721,7 @@ Composes these two transformation matrices by multiplying them together. This ha
|
|
|
|
|
|
:ref:`Vector2<class_Vector2>` **operator ***\ (\ right\: :ref:`Vector2<class_Vector2>`\ ) :ref:`🔗<class_Transform2D_operator_mul_Vector2>`
|
|
|
|
|
|
-Transforms (multiplies) the :ref:`Vector2<class_Vector2>` by the given **Transform2D** matrix.
|
|
|
+Transforms (multiplies) the :ref:`Vector2<class_Vector2>` by this transformation matrix.
|
|
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
|
@@ -659,7 +733,7 @@ Transforms (multiplies) the :ref:`Vector2<class_Vector2>` by the given **Transfo
|
|
|
|
|
|
:ref:`Transform2D<class_Transform2D>` **operator ***\ (\ right\: :ref:`float<class_float>`\ ) :ref:`🔗<class_Transform2D_operator_mul_float>`
|
|
|
|
|
|
-This operator multiplies all components of the **Transform2D**, including the :ref:`origin<class_Transform2D_property_origin>` vector, which scales it uniformly.
|
|
|
+Multiplies all components of the **Transform2D** by the given :ref:`float<class_float>`, including the :ref:`origin<class_Transform2D_property_origin>`. This affects the transform's scale uniformly.
|
|
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
|
@@ -671,7 +745,7 @@ This operator multiplies all components of the **Transform2D**, including the :r
|
|
|
|
|
|
:ref:`Transform2D<class_Transform2D>` **operator ***\ (\ right\: :ref:`int<class_int>`\ ) :ref:`🔗<class_Transform2D_operator_mul_int>`
|
|
|
|
|
|
-This operator multiplies all components of the **Transform2D**, including the :ref:`origin<class_Transform2D_property_origin>` vector, which scales it uniformly.
|
|
|
+Multiplies all components of the **Transform2D** by the given :ref:`int<class_int>`, including the :ref:`origin<class_Transform2D_property_origin>`. This affects the transform's scale uniformly.
|
|
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
|
@@ -683,7 +757,7 @@ This operator multiplies all components of the **Transform2D**, including the :r
|
|
|
|
|
|
:ref:`Transform2D<class_Transform2D>` **operator /**\ (\ right\: :ref:`float<class_float>`\ ) :ref:`🔗<class_Transform2D_operator_div_float>`
|
|
|
|
|
|
-This operator divides all components of the **Transform2D**, including the :ref:`origin<class_Transform2D_property_origin>` vector, which inversely scales it uniformly.
|
|
|
+Divides all components of the **Transform2D** by the given :ref:`float<class_float>`, including the :ref:`origin<class_Transform2D_property_origin>`. This affects the transform's scale uniformly.
|
|
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
|
@@ -695,7 +769,7 @@ This operator divides all components of the **Transform2D**, including the :ref:
|
|
|
|
|
|
:ref:`Transform2D<class_Transform2D>` **operator /**\ (\ right\: :ref:`int<class_int>`\ ) :ref:`🔗<class_Transform2D_operator_div_int>`
|
|
|
|
|
|
-This operator divides all components of the **Transform2D**, including the :ref:`origin<class_Transform2D_property_origin>` vector, which inversely scales it uniformly.
|
|
|
+Divides all components of the **Transform2D** by the given :ref:`int<class_int>`, including the :ref:`origin<class_Transform2D_property_origin>`. This affects the transform's scale uniformly.
|
|
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
|
@@ -707,7 +781,7 @@ This operator divides all components of the **Transform2D**, including the :ref:
|
|
|
|
|
|
:ref:`bool<class_bool>` **operator ==**\ (\ right\: :ref:`Transform2D<class_Transform2D>`\ ) :ref:`🔗<class_Transform2D_operator_eq_Transform2D>`
|
|
|
|
|
|
-Returns ``true`` if the transforms are exactly equal.
|
|
|
+Returns ``true`` if the components of both transforms are exactly equal.
|
|
|
|
|
|
\ **Note:** Due to floating-point precision errors, consider using :ref:`is_equal_approx<class_Transform2D_method_is_equal_approx>` instead, which is more reliable.
|
|
|
|
|
@@ -721,7 +795,7 @@ Returns ``true`` if the transforms are exactly equal.
|
|
|
|
|
|
:ref:`Vector2<class_Vector2>` **operator []**\ (\ index\: :ref:`int<class_int>`\ ) :ref:`🔗<class_Transform2D_operator_idx_int>`
|
|
|
|
|
|
-Access transform components using their index. ``t[0]`` is equivalent to ``t.x``, ``t[1]`` is equivalent to ``t.y``, and ``t[2]`` is equivalent to ``t.origin``.
|
|
|
+Accesses each axis (column) of this transform by their index. Index ``0`` is the same as :ref:`x<class_Transform2D_property_x>`, index ``1`` is the same as :ref:`y<class_Transform2D_property_y>`, and index ``2`` is the same as :ref:`origin<class_Transform2D_property_origin>`.
|
|
|
|
|
|
.. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
|
|
|
.. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
|