class_transform.rst 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. .. Generated automatically by doc/tools/makerst.py in Godot's source tree.
  2. .. DO NOT EDIT THIS FILE, but the Transform.xml source instead.
  3. .. The source is found in doc/classes or modules/<name>/doc_classes.
  4. .. _class_Transform:
  5. Transform
  6. =========
  7. **Category:** Built-In Types
  8. Brief Description
  9. -----------------
  10. 3D Transformation. 3x4 matrix.
  11. Properties
  12. ----------
  13. +-------------------------------+------------------------------------------------+
  14. | :ref:`Basis<class_Basis>` | :ref:`basis<class_Transform_property_basis>` |
  15. +-------------------------------+------------------------------------------------+
  16. | :ref:`Vector3<class_Vector3>` | :ref:`origin<class_Transform_property_origin>` |
  17. +-------------------------------+------------------------------------------------+
  18. Methods
  19. -------
  20. +-----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  21. | :ref:`Transform<class_Transform>` | :ref:`Transform<class_Transform_method_Transform>` **(** :ref:`Vector3<class_Vector3>` x_axis, :ref:`Vector3<class_Vector3>` y_axis, :ref:`Vector3<class_Vector3>` z_axis, :ref:`Vector3<class_Vector3>` origin **)** |
  22. +-----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  23. | :ref:`Transform<class_Transform>` | :ref:`Transform<class_Transform_method_Transform>` **(** :ref:`Basis<class_Basis>` basis, :ref:`Vector3<class_Vector3>` origin **)** |
  24. +-----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  25. | :ref:`Transform<class_Transform>` | :ref:`Transform<class_Transform_method_Transform>` **(** :ref:`Transform2D<class_Transform2D>` from **)** |
  26. +-----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  27. | :ref:`Transform<class_Transform>` | :ref:`Transform<class_Transform_method_Transform>` **(** :ref:`Quat<class_Quat>` from **)** |
  28. +-----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  29. | :ref:`Transform<class_Transform>` | :ref:`Transform<class_Transform_method_Transform>` **(** :ref:`Basis<class_Basis>` from **)** |
  30. +-----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  31. | :ref:`Transform<class_Transform>` | :ref:`affine_inverse<class_Transform_method_affine_inverse>` **(** **)** |
  32. +-----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  33. | :ref:`Transform<class_Transform>` | :ref:`interpolate_with<class_Transform_method_interpolate_with>` **(** :ref:`Transform<class_Transform>` transform, :ref:`float<class_float>` weight **)** |
  34. +-----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  35. | :ref:`Transform<class_Transform>` | :ref:`inverse<class_Transform_method_inverse>` **(** **)** |
  36. +-----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  37. | :ref:`Transform<class_Transform>` | :ref:`looking_at<class_Transform_method_looking_at>` **(** :ref:`Vector3<class_Vector3>` target, :ref:`Vector3<class_Vector3>` up **)** |
  38. +-----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  39. | :ref:`Transform<class_Transform>` | :ref:`orthonormalized<class_Transform_method_orthonormalized>` **(** **)** |
  40. +-----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  41. | :ref:`Transform<class_Transform>` | :ref:`rotated<class_Transform_method_rotated>` **(** :ref:`Vector3<class_Vector3>` axis, :ref:`float<class_float>` phi **)** |
  42. +-----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  43. | :ref:`Transform<class_Transform>` | :ref:`scaled<class_Transform_method_scaled>` **(** :ref:`Vector3<class_Vector3>` scale **)** |
  44. +-----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  45. | :ref:`Transform<class_Transform>` | :ref:`translated<class_Transform_method_translated>` **(** :ref:`Vector3<class_Vector3>` ofs **)** |
  46. +-----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  47. | :ref:`Variant<class_Variant>` | :ref:`xform<class_Transform_method_xform>` **(** :ref:`Variant<class_Variant>` v **)** |
  48. +-----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  49. | :ref:`Variant<class_Variant>` | :ref:`xform_inv<class_Transform_method_xform_inv>` **(** :ref:`Variant<class_Variant>` v **)** |
  50. +-----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  51. Constants
  52. ---------
  53. .. _class_Transform_constant_IDENTITY:
  54. .. _class_Transform_constant_FLIP_X:
  55. .. _class_Transform_constant_FLIP_Y:
  56. .. _class_Transform_constant_FLIP_Z:
  57. - **IDENTITY** = **Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0 )**
  58. - **FLIP_X** = **Transform( -1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0 )**
  59. - **FLIP_Y** = **Transform( 1, 0, 0, 0, -1, 0, 0, 0, 1, 0, 0, 0 )**
  60. - **FLIP_Z** = **Transform( 1, 0, 0, 0, 1, 0, 0, 0, -1, 0, 0, 0 )**
  61. Description
  62. -----------
  63. Represents one or many transformations in 3D space such as translation, rotation, or scaling. It consists of a :ref:`Basis<class_Basis>` "basis" and an :ref:`Vector3<class_Vector3>` "origin". It is similar to a 3x4 matrix.
  64. Tutorials
  65. ---------
  66. - :doc:`../tutorials/math/index`
  67. - :doc:`../tutorials/3d/using_transforms`
  68. Property Descriptions
  69. ---------------------
  70. .. _class_Transform_property_basis:
  71. - :ref:`Basis<class_Basis>` **basis**
  72. The basis is a matrix containing 3 :ref:`Vector3<class_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.
  73. .. _class_Transform_property_origin:
  74. - :ref:`Vector3<class_Vector3>` **origin**
  75. The translation offset of the transform.
  76. Method Descriptions
  77. -------------------
  78. .. _class_Transform_method_Transform:
  79. - :ref:`Transform<class_Transform>` **Transform** **(** :ref:`Vector3<class_Vector3>` x_axis, :ref:`Vector3<class_Vector3>` y_axis, :ref:`Vector3<class_Vector3>` z_axis, :ref:`Vector3<class_Vector3>` origin **)**
  80. Constructs the Transform from four :ref:`Vector3<class_Vector3>`. Each axis corresponds to local basis vectors (some of which may be scaled).
  81. - :ref:`Transform<class_Transform>` **Transform** **(** :ref:`Basis<class_Basis>` basis, :ref:`Vector3<class_Vector3>` origin **)**
  82. Constructs the Transform from a :ref:`Basis<class_Basis>` and :ref:`Vector3<class_Vector3>`.
  83. - :ref:`Transform<class_Transform>` **Transform** **(** :ref:`Transform2D<class_Transform2D>` from **)**
  84. Constructs the Transform from a :ref:`Transform2D<class_Transform2D>`.
  85. - :ref:`Transform<class_Transform>` **Transform** **(** :ref:`Quat<class_Quat>` from **)**
  86. Constructs the Transform from a :ref:`Quat<class_Quat>`. The origin will be Vector3(0, 0, 0).
  87. - :ref:`Transform<class_Transform>` **Transform** **(** :ref:`Basis<class_Basis>` from **)**
  88. Constructs the Transform from a :ref:`Basis<class_Basis>`. The origin will be Vector3(0, 0, 0).
  89. .. _class_Transform_method_affine_inverse:
  90. - :ref:`Transform<class_Transform>` **affine_inverse** **(** **)**
  91. Returns the inverse of the transform, under the assumption that the transformation is composed of rotation, scaling and translation.
  92. .. _class_Transform_method_interpolate_with:
  93. - :ref:`Transform<class_Transform>` **interpolate_with** **(** :ref:`Transform<class_Transform>` transform, :ref:`float<class_float>` weight **)**
  94. Interpolates the transform to other Transform by weight amount (0-1).
  95. .. _class_Transform_method_inverse:
  96. - :ref:`Transform<class_Transform>` **inverse** **(** **)**
  97. Returns the inverse of the transform, under the assumption that the transformation is composed of rotation and translation (no scaling, use affine_inverse for transforms with scaling).
  98. .. _class_Transform_method_looking_at:
  99. - :ref:`Transform<class_Transform>` **looking_at** **(** :ref:`Vector3<class_Vector3>` target, :ref:`Vector3<class_Vector3>` up **)**
  100. Returns a copy of the transform rotated such that its -Z axis points towards the ``target`` position.
  101. 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.
  102. Operations take place in global space.
  103. .. _class_Transform_method_orthonormalized:
  104. - :ref:`Transform<class_Transform>` **orthonormalized** **(** **)**
  105. Returns the transform with the basis orthogonal (90 degrees), and normalized axis vectors.
  106. .. _class_Transform_method_rotated:
  107. - :ref:`Transform<class_Transform>` **rotated** **(** :ref:`Vector3<class_Vector3>` axis, :ref:`float<class_float>` phi **)**
  108. Rotates the transform around given axis by phi. The axis must be a normalized vector.
  109. .. _class_Transform_method_scaled:
  110. - :ref:`Transform<class_Transform>` **scaled** **(** :ref:`Vector3<class_Vector3>` scale **)**
  111. Scales the transform by the specified 3D scaling factors.
  112. .. _class_Transform_method_translated:
  113. - :ref:`Transform<class_Transform>` **translated** **(** :ref:`Vector3<class_Vector3>` ofs **)**
  114. Translates the transform by the specified offset.
  115. .. _class_Transform_method_xform:
  116. - :ref:`Variant<class_Variant>` **xform** **(** :ref:`Variant<class_Variant>` v **)**
  117. Transforms the given :ref:`Vector3<class_Vector3>`, :ref:`Plane<class_Plane>`, or :ref:`AABB<class_AABB>` by this transform.
  118. .. _class_Transform_method_xform_inv:
  119. - :ref:`Variant<class_Variant>` **xform_inv** **(** :ref:`Variant<class_Variant>` v **)**
  120. Inverse-transforms the given :ref:`Vector3<class_Vector3>`, :ref:`Plane<class_Plane>`, or :ref:`AABB<class_AABB>` by this transform.