:github_url: hide .. DO NOT EDIT THIS FILE!!! .. Generated automatically from Godot engine sources. .. Generator: https://github.com/godotengine/godot/tree/3.5/doc/tools/make_rst.py. .. XML source: https://github.com/godotengine/godot/tree/3.5/doc/classes/Transform.xml. .. _class_Transform: Transform ========= 3D transformation (3×4 matrix). Description ----------- 3×4 matrix (3 rows, 4 columns) used for 3D linear transformations. It can represent transformations such as translation, rotation, or scaling. It consists of a :ref:`basis` (first 3 columns) and a :ref:`Vector3` for the :ref:`origin` (last column). For more information, read the "Matrices and transforms" documentation article. Tutorials --------- - :doc:`Math tutorial index <../tutorials/math/index>` - :doc:`Matrices and transforms <../tutorials/math/matrices_and_transforms>` - :doc:`Using 3D transforms <../tutorials/3d/using_transforms>` - `Matrix Transform Demo `__ - `3D Platformer Demo `__ - `2.5D Demo `__ Properties ---------- +-------------------------------+------------------------------------------------+----------------------------------------+ | :ref:`Basis` | :ref:`basis` | ``Basis( 1, 0, 0, 0, 1, 0, 0, 0, 1 )`` | +-------------------------------+------------------------------------------------+----------------------------------------+ | :ref:`Vector3` | :ref:`origin` | ``Vector3( 0, 0, 0 )`` | +-------------------------------+------------------------------------------------+----------------------------------------+ Methods ------- +-----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Transform` | :ref:`Transform` **(** :ref:`Vector3` x_axis, :ref:`Vector3` y_axis, :ref:`Vector3` z_axis, :ref:`Vector3` origin **)** | +-----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Transform` | :ref:`Transform` **(** :ref:`Basis` basis, :ref:`Vector3` origin **)** | +-----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Transform` | :ref:`Transform` **(** :ref:`Transform2D` from **)** | +-----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Transform` | :ref:`Transform` **(** :ref:`Quat` from **)** | +-----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Transform` | :ref:`Transform` **(** :ref:`Basis` from **)** | +-----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Transform` | :ref:`affine_inverse` **(** **)** | +-----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Transform` | :ref:`interpolate_with` **(** :ref:`Transform` transform, :ref:`float` weight **)** | +-----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Transform` | :ref:`inverse` **(** **)** | +-----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`bool` | :ref:`is_equal_approx` **(** :ref:`Transform` transform **)** | +-----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Transform` | :ref:`looking_at` **(** :ref:`Vector3` target, :ref:`Vector3` up **)** | +-----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Transform` | :ref:`orthonormalized` **(** **)** | +-----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Transform` | :ref:`rotated` **(** :ref:`Vector3` axis, :ref:`float` angle **)** | +-----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Transform` | :ref:`scaled` **(** :ref:`Vector3` scale **)** | +-----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Transform` | :ref:`translated` **(** :ref:`Vector3` offset **)** | +-----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Variant` | :ref:`xform` **(** :ref:`Variant` v **)** | +-----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Variant` | :ref:`xform_inv` **(** :ref:`Variant` v **)** | +-----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ Constants --------- .. _class_Transform_constant_IDENTITY: .. _class_Transform_constant_FLIP_X: .. _class_Transform_constant_FLIP_Y: .. _class_Transform_constant_FLIP_Z: - **IDENTITY** = **Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0 )** --- ``Transform`` with no translation, rotation or scaling applied. When applied to other data structures, :ref:`IDENTITY` performs no transformation. - **FLIP_X** = **Transform( -1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0 )** --- ``Transform`` with mirroring applied perpendicular to the YZ plane. - **FLIP_Y** = **Transform( 1, 0, 0, 0, -1, 0, 0, 0, 1, 0, 0, 0 )** --- ``Transform`` with mirroring applied perpendicular to the XZ plane. - **FLIP_Z** = **Transform( 1, 0, 0, 0, 1, 0, 0, 0, -1, 0, 0, 0 )** --- ``Transform`` with mirroring applied perpendicular to the XY plane. Property Descriptions --------------------- .. _class_Transform_property_basis: - :ref:`Basis` **basis** +-----------+----------------------------------------+ | *Default* | ``Basis( 1, 0, 0, 0, 1, 0, 0, 0, 1 )`` | +-----------+----------------------------------------+ The basis is a matrix containing 3 :ref:`Vector3` as its columns: X axis, Y axis, and Z axis. These vectors can be interpreted as the basis vectors of local coordinate system traveling with the object. ---- .. _class_Transform_property_origin: - :ref:`Vector3` **origin** +-----------+------------------------+ | *Default* | ``Vector3( 0, 0, 0 )`` | +-----------+------------------------+ The translation offset of the transform (column 3, the fourth column). Equivalent to array index ``3``. Method Descriptions ------------------- .. _class_Transform_method_Transform: - :ref:`Transform` **Transform** **(** :ref:`Vector3` x_axis, :ref:`Vector3` y_axis, :ref:`Vector3` z_axis, :ref:`Vector3` origin **)** Constructs a Transform from four :ref:`Vector3` values (matrix columns). Each axis corresponds to local basis vectors (some of which may be scaled). ---- - :ref:`Transform` **Transform** **(** :ref:`Basis` basis, :ref:`Vector3` origin **)** Constructs a Transform from a :ref:`Basis` and :ref:`Vector3`. ---- - :ref:`Transform` **Transform** **(** :ref:`Transform2D` from **)** Constructs a Transform from a :ref:`Transform2D`. ---- - :ref:`Transform` **Transform** **(** :ref:`Quat` from **)** Constructs a Transform from a :ref:`Quat`. The origin will be ``Vector3(0, 0, 0)``. ---- - :ref:`Transform` **Transform** **(** :ref:`Basis` from **)** Constructs the Transform from a :ref:`Basis`. The origin will be Vector3(0, 0, 0). ---- .. _class_Transform_method_affine_inverse: - :ref:`Transform` **affine_inverse** **(** **)** Returns the inverse of the transform, under the assumption that the transformation is composed of rotation, scaling and translation. ---- .. _class_Transform_method_interpolate_with: - :ref:`Transform` **interpolate_with** **(** :ref:`Transform` transform, :ref:`float` weight **)** Returns a transform interpolated between this transform and another by a given ``weight`` (on the range of 0.0 to 1.0). ---- .. _class_Transform_method_inverse: - :ref:`Transform` **inverse** **(** **)** Returns the inverse of the transform, under the assumption that the transformation is composed of rotation and translation (no scaling, use :ref:`affine_inverse` for transforms with scaling). ---- .. _class_Transform_method_is_equal_approx: - :ref:`bool` **is_equal_approx** **(** :ref:`Transform` transform **)** Returns ``true`` if this transform and ``transform`` are approximately equal, by calling ``is_equal_approx`` on each component. ---- .. _class_Transform_method_looking_at: - :ref:`Transform` **looking_at** **(** :ref:`Vector3` target, :ref:`Vector3` up **)** Returns a copy of the transform rotated such that its -Z axis points towards the ``target`` position. The transform will first be rotated around the given ``up`` vector, and then fully aligned to the target by a further rotation around an axis perpendicular to both the ``target`` and ``up`` vectors. Operations take place in global space. ---- .. _class_Transform_method_orthonormalized: - :ref:`Transform` **orthonormalized** **(** **)** Returns the transform with the basis orthogonal (90 degrees), and normalized axis vectors (scale of 1 or -1). ---- .. _class_Transform_method_rotated: - :ref:`Transform` **rotated** **(** :ref:`Vector3` axis, :ref:`float` angle **)** Returns a copy of the transform rotated around the given ``axis`` by the given ``angle`` (in radians), using matrix multiplication. The ``axis`` must be a normalized vector. ---- .. _class_Transform_method_scaled: - :ref:`Transform` **scaled** **(** :ref:`Vector3` scale **)** Returns a copy of the transform with its basis and origin scaled by the given ``scale`` factor, using matrix multiplication. ---- .. _class_Transform_method_translated: - :ref:`Transform` **translated** **(** :ref:`Vector3` offset **)** Returns a copy of the transform translated by the given ``offset``, relative to the transform's basis vectors. Unlike :ref:`rotated` and :ref:`scaled`, this does not use matrix multiplication. ---- .. _class_Transform_method_xform: - :ref:`Variant` **xform** **(** :ref:`Variant` v **)** Transforms the given :ref:`Vector3`, :ref:`Plane`, :ref:`AABB`, or :ref:`PoolVector3Array` by this transform. ---- .. _class_Transform_method_xform_inv: - :ref:`Variant` **xform_inv** **(** :ref:`Variant` v **)** Inverse-transforms the given :ref:`Vector3`, :ref:`Plane`, :ref:`AABB`, or :ref:`PoolVector3Array` by this transform, under the assumption that the transformation is composed of rotation and translation (no scaling). Equivalent to calling ``inverse().xform(v)`` on this transform. For affine transformations (e.g. with scaling) see :ref:`affine_inverse` method. .. |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.)` .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`