:github_url: hide .. Generated automatically by doc/tools/make_rst.py in Godot's source tree. .. DO NOT EDIT THIS FILE, but the Transform3D.xml source instead. .. The source is found in doc/classes or modules//doc_classes. .. _class_Transform3D: Transform3D =========== 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 documentation 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)`` | +-------------------------------+--------------------------------------------------+--------------------------------------+ Constructors ------------ +---------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Transform3D` | :ref:`Transform3D` **(** **)** | +---------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Transform3D` | :ref:`Transform3D` **(** :ref:`Transform3D` from **)** | +---------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Transform3D` | :ref:`Transform3D` **(** :ref:`Basis` basis, :ref:`Vector3` origin **)** | +---------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Transform3D` | :ref:`Transform3D` **(** :ref:`Vector3` x_axis, :ref:`Vector3` y_axis, :ref:`Vector3` z_axis, :ref:`Vector3` origin **)** | +---------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ Methods ------- +---------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Transform3D` | :ref:`affine_inverse` **(** **)** |const| | +---------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Transform3D` | :ref:`interpolate_with` **(** :ref:`Transform3D` xform, :ref:`float` weight **)** |const| | +---------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Transform3D` | :ref:`inverse` **(** **)** |const| | +---------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`bool` | :ref:`is_equal_approx` **(** :ref:`Transform3D` xform **)** |const| | +---------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Transform3D` | :ref:`looking_at` **(** :ref:`Vector3` target, :ref:`Vector3` up=Vector3(0, 1, 0) **)** |const| | +---------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Transform3D` | :ref:`orthonormalized` **(** **)** |const| | +---------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Transform3D` | :ref:`rotated` **(** :ref:`Vector3` axis, :ref:`float` phi **)** |const| | +---------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Transform3D` | :ref:`scaled` **(** :ref:`Vector3` scale **)** |const| | +---------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Transform3D` | :ref:`sphere_interpolate_with` **(** :ref:`Transform3D` xform, :ref:`float` weight **)** |const| | +---------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Transform3D` | :ref:`translated` **(** :ref:`Vector3` offset **)** |const| | +---------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ Operators --------- +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`bool` | :ref:`operator !=` **(** **)** | +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`bool` | :ref:`operator !=` **(** :ref:`Transform3D` right **)** | +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`AABB` | :ref:`operator *` **(** :ref:`AABB` right **)** | +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`PackedVector3Array` | :ref:`operator *` **(** :ref:`PackedVector3Array` right **)** | +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Transform3D` | :ref:`operator *` **(** :ref:`Transform3D` right **)** | +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Vector3` | :ref:`operator *` **(** :ref:`Vector3` right **)** | +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Transform3D` | :ref:`operator *` **(** :ref:`float` right **)** | +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Transform3D` | :ref:`operator *` **(** :ref:`int` right **)** | +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`bool` | :ref:`operator ==` **(** **)** | +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`bool` | :ref:`operator ==` **(** :ref:`Transform3D` right **)** | +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------+ Constants --------- .. _class_Transform3D_constant_IDENTITY: .. _class_Transform3D_constant_FLIP_X: .. _class_Transform3D_constant_FLIP_Y: .. _class_Transform3D_constant_FLIP_Z: - **IDENTITY** = **Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0)** --- ``Transform3D`` with no translation, rotation or scaling applied. When applied to other data structures, :ref:`IDENTITY` performs no transformation. - **FLIP_X** = **Transform3D(-1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0)** --- ``Transform3D`` with mirroring applied perpendicular to the YZ plane. - **FLIP_Y** = **Transform3D(1, 0, 0, 0, -1, 0, 0, 0, 1, 0, 0, 0)** --- ``Transform3D`` with mirroring applied perpendicular to the XZ plane. - **FLIP_Z** = **Transform3D(1, 0, 0, 0, 1, 0, 0, 0, -1, 0, 0, 0)** --- ``Transform3D`` with mirroring applied perpendicular to the XY plane. Property Descriptions --------------------- .. _class_Transform3D_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_Transform3D_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``. Constructor Descriptions ------------------------ .. _class_Transform3D_constructor_Transform3D: - :ref:`Transform3D` **Transform3D** **(** **)** Constructs a default-initialized ``Transform3D`` set to :ref:`IDENTITY`. ---- - :ref:`Transform3D` **Transform3D** **(** :ref:`Transform3D` from **)** Constructs a ``Transform3D`` as a copy of the given ``Transform3D``. ---- - :ref:`Transform3D` **Transform3D** **(** :ref:`Basis` basis, :ref:`Vector3` origin **)** Constructs a Transform3D from a :ref:`Basis` and :ref:`Vector3`. ---- - :ref:`Transform3D` **Transform3D** **(** :ref:`Vector3` x_axis, :ref:`Vector3` y_axis, :ref:`Vector3` z_axis, :ref:`Vector3` origin **)** Constructs a Transform3D from four :ref:`Vector3` values (matrix columns). Each axis corresponds to local basis vectors (some of which may be scaled). Method Descriptions ------------------- .. _class_Transform3D_method_affine_inverse: - :ref:`Transform3D` **affine_inverse** **(** **)** |const| Returns the inverse of the transform, under the assumption that the transformation is composed of rotation, scaling and translation. ---- .. _class_Transform3D_method_interpolate_with: - :ref:`Transform3D` **interpolate_with** **(** :ref:`Transform3D` xform, :ref:`float` weight **)** |const| Returns a transform interpolated between this transform and another by a given ``weight`` (on the range of 0.0 to 1.0). ---- .. _class_Transform3D_method_inverse: - :ref:`Transform3D` **inverse** **(** **)** |const| 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_Transform3D_method_is_equal_approx: - :ref:`bool` **is_equal_approx** **(** :ref:`Transform3D` xform **)** |const| Returns ``true`` if this transform and ``transform`` are approximately equal, by calling ``is_equal_approx`` on each component. ---- .. _class_Transform3D_method_looking_at: - :ref:`Transform3D` **looking_at** **(** :ref:`Vector3` target, :ref:`Vector3` up=Vector3(0, 1, 0) **)** |const| Returns a copy of the transform rotated such that the forward axis (-Z) points towards the ``target`` position. The up axis (+Y) points as close to the ``up`` vector as possible while staying perpendicular to the forward axis. The resulting transform is orthonormalized. The existing rotation, scale, and skew information from the original transform is discarded. The ``target`` and ``up`` vectors cannot be zero, cannot be parallel to each other, and are defined in global/parent space. ---- .. _class_Transform3D_method_orthonormalized: - :ref:`Transform3D` **orthonormalized** **(** **)** |const| Returns the transform with the basis orthogonal (90 degrees), and normalized axis vectors (scale of 1 or -1). ---- .. _class_Transform3D_method_rotated: - :ref:`Transform3D` **rotated** **(** :ref:`Vector3` axis, :ref:`float` phi **)** |const| Rotates the transform around the given axis by the given angle (in radians), using matrix multiplication. The axis must be a normalized vector. ---- .. _class_Transform3D_method_scaled: - :ref:`Transform3D` **scaled** **(** :ref:`Vector3` scale **)** |const| Scales basis and origin of the transform by the given scale factor, using matrix multiplication. ---- .. _class_Transform3D_method_sphere_interpolate_with: - :ref:`Transform3D` **sphere_interpolate_with** **(** :ref:`Transform3D` xform, :ref:`float` weight **)** |const| Returns a transform spherically interpolated between this transform and another by a given ``weight`` (on the range of 0.0 to 1.0). ---- .. _class_Transform3D_method_translated: - :ref:`Transform3D` **translated** **(** :ref:`Vector3` offset **)** |const| Translates the transform by the given offset, relative to the transform's basis vectors. Unlike :ref:`rotated` and :ref:`scaled`, this does not use matrix multiplication. Operator Descriptions --------------------- .. _class_Transform3D_operator_neq_bool: - :ref:`bool` **operator !=** **(** **)** ---- - :ref:`bool` **operator !=** **(** :ref:`Transform3D` right **)** Returns ``true`` if the transforms are not equal. \ **Note:** Due to floating-point precision errors, consider using :ref:`is_equal_approx` instead, which is more reliable. ---- .. _class_Transform3D_operator_mul_AABB: - :ref:`AABB` **operator *** **(** :ref:`AABB` right **)** Transforms (multiplies) the :ref:`AABB` by the given ``Transform3D`` matrix. ---- - :ref:`PackedVector3Array` **operator *** **(** :ref:`PackedVector3Array` right **)** Transforms (multiplies) each element of the :ref:`Vector3` array by the given ``Transform3D`` matrix. ---- - :ref:`Transform3D` **operator *** **(** :ref:`Transform3D` right **)** 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). ---- - :ref:`Vector3` **operator *** **(** :ref:`Vector3` right **)** Transforms (multiplies) the :ref:`Vector3` by the given ``Transform3D`` matrix. ---- - :ref:`Transform3D` **operator *** **(** :ref:`float` right **)** This operator multiplies all components of the ``Transform3D``, including the origin vector, which scales it uniformly. ---- - :ref:`Transform3D` **operator *** **(** :ref:`int` right **)** This operator multiplies all components of the ``Transform3D``, including the origin vector, which scales it uniformly. ---- .. _class_Transform3D_operator_eq_bool: - :ref:`bool` **operator ==** **(** **)** ---- - :ref:`bool` **operator ==** **(** :ref:`Transform3D` right **)** Returns ``true`` if the transforms are exactly equal. \ **Note:** Due to floating-point precision errors, consider using :ref:`is_equal_approx` instead, which is more reliable. .. |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.)` .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)` .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)` .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`